Adding new ItemType to Canvas
Available news archives: comp.lang.tcl - comp.lang.python - comp.security.firewalls - sci.crypt - comp.lang.php - comp.lang.javascript
Google
 
Web news.hping.org


comp.lang.tcl archive

Adding new ItemType to Canvas

From: Jingzhao Ou <jingzhao.ou@gmail.com>
Date: Sat Sep 17 2005 - 22:05:26 CEST

Dear all,

I want to add a new ItemType to the Canvas widget. The implemenation
will be in C and hopefully be able to work crossplatform.

I checked out the source code of Tk. It seems that this is possible
using "Tk_CreateItemType(typePtr)". The source code recommends to check
out the implemenation of the built-in types on how to create new
ItemType.

Then, I look at "TkCanvLine.c". I copied this file into a new directory
and then changed "line" to "myline" in the new file to see if things
can work. (see the following snippet)

=============================================================
Tk_ItemType tkLineType = {
    "myline", /* name */
    sizeof(LineItem), /* itemSize */
    CreateLine, /* createProc */
    configSpecs, /* configSpecs */
=============================================================

However, to compile the file, the following header files are required:

#include "tkInt.h"
#include "tkPort.h"
#include "tkCanvas.h"

I am trying to get the new C file work with ActiveTcl. (1) The
"include" directory of ActiveTcl only provide "tkInt.h". (2)
"tkCancas.h" is simple and can be copied from the source.

(3) My current problem is how to deal with "tkPort.h"? It is not
included in the ActiveTcl distribution and requires quite some other
files in the Tk source.

Can any one kindly give me some suggestions on how to resolve the above
issues?

Thanks a lot!

Best regards,
Jingzhao
Received on Thu Sep 29 14:37:29 2005