set da1 [gnocl::drawingArea -tooltip "HELLO" ]
$da1 option add -onMotion
$da1 option add -onMotion
$da1 option add -onEnter
$da1 option add -onButtonPress
$da1 option add -onButtonRelease
$da1 option add -onButtonMotion
$da1 configure -onMotion {puts "%x %y WHEE..."}
$da1 configure -onEnter {puts "%x %y Hello Moto"}
$da1 configure -onButtonPress {puts "%x %y Press.."}
$da1 configure -onButtonRelease {puts "%x %y Release.."}
$da1 configure -onButtonMotion {puts "%x %y MOOOOOOOOOOOOOOOOOTION.."}
Gnocl now does make some additional defaults of its own to make the code implementation harmoize with the other widgets. This show hows its done:
static gint _n = 4; /* counter,number of implements widget options */
static GnoclOption drawingAreaOptions[] =
{
/* common widget options */
{ "-tooltip", GNOCL_OBJ, "", gnoclOptTooltip },
{ "-data", GNOCL_OBJ, "", gnoclOptData },
{ "-name", GNOCL_STRING, "name" },
{ "-onShowHelp", GNOCL_OBJ, "", gnoclOptOnShowHelp },
/* widget specific options */
{ "", 0, "", NULL },
{ "", 0, "", NULL },
{ "", 0, "", NULL },
{ "", 0, "", NULL },
{ NULL },
};
static GnoclOption drawingAreaOptions[] =
{
/* common widget options */
{ "-tooltip", GNOCL_OBJ, "", gnoclOptTooltip },
{ "-data", GNOCL_OBJ, "", gnoclOptData },
{ "-name", GNOCL_STRING, "name" },
{ "-onShowHelp", GNOCL_OBJ, "", gnoclOptOnShowHelp },
/* widget specific options */
{ "", 0, "", NULL },
{ "", 0, "", NULL },
{ "", 0, "", NULL },
{ "", 0, "", NULL },
{ NULL },
};
As can be seen, the options array is statically defined with some extra spaces for run-time additions. At the moment there are only a few blanks, but this can modified later. Initially I thought of dyanamically reallocating memory for the array but this simple method seems the most straightforward solution.
No comments:
Post a Comment