Tk Source Code

Check-in [3e448325]
Login
Bounty program for improvements to Tcl and certain Tcl packages.
Tcl 2019 Conference, Houston/TX, US, Nov 4-8
Send your abstracts to [email protected]
or submit via the online form by Sep 9.

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:New files from René Zaumseil
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | tip-510
Files: files | file ages | folders
SHA3-256: 3e4483258b261b186684c48f9c5642069c4109e5d4b6d1184168faae1224f607
User & Date: fvogel 2019-05-08 19:47:55
Context
2019-05-08
19:47
New files from RenĂ© Zaumseil Leaf check-in: 3e448325 user: fvogel tags: tip-510
2019-04-12
20:10
Repair test tk-1.2 check-in: e608f7c6 user: fvogel tags: tip-510
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to doc/tkoWidget.3.md.

64
65
66
67
68
69
70


71
72
73
74
75
76
77


78
79
80
81
82
83
84
### Struct: `tkoWidgetOptionDefine`

    typedef struct tkoWidgetOptionDefine {
      const char *option;    /* Name of option. Starts with "-" minus sign */
      const char *dbname;    /* Option DB name or synonym option if dbclass is NULL */
      const char *dbclass;   /* Option DB class name or NULL for synonym options. */
      const char *defvalue;  /* Default value. */


      const char *proc;      /* If not NULL it is the body of the newly created -option method */
      Tcl_MethodCallProc *method;     /* If not NULL it is the function name of the -option method */
      int flags;             /* if TKO_WIDGETOPTIONREADONLY then option is only setable at creation time */
      tkoWidgetOptionType type;       /* if greater 0 then option type used in common option set method */
      Tcl_ObjectMetadataType *meta;   /* meta data address used in common option set method */
      int offset;            /* offset in meta data struct */
    } tkoWidgetOptionDefine;



### Enum: `tkoWidgetOptionType`

Suported enum type in the TkowidgetOptinSet() function. In comments is the type of the address provided in the **TkoWidgetOptionSet** funtion.

    typedef enum tkoWidgetOptionType {
        TKO_SET_CLASS = 1,     /* (Tcl_Obj **)address */






>
>


<




>
>







64
65
66
67
68
69
70
71
72
73
74

75
76
77
78
79
80
81
82
83
84
85
86
87
### Struct: `tkoWidgetOptionDefine`

    typedef struct tkoWidgetOptionDefine {
      const char *option;    /* Name of option. Starts with "-" minus sign */
      const char *dbname;    /* Option DB name or synonym option if dbclass is NULL */
      const char *dbclass;   /* Option DB class name or NULL for synonym options. */
      const char *defvalue;  /* Default value. */
      int flags;             /* bit array of TKO_OPTION_* values to configure option behaviour */
      Tcl_Obj *optionPtr;    /* tko internally used, always init with NULL! */
      const char *proc;      /* If not NULL it is the body of the newly created -option method */
      Tcl_MethodCallProc *method;     /* If not NULL it is the function name of the -option method */

      tkoWidgetOptionType type;       /* if greater 0 then option type used in common option set method */
      Tcl_ObjectMetadataType *meta;   /* meta data address used in common option set method */
      int offset;            /* offset in meta data struct */
    } tkoWidgetOptionDefine;
    #define TKO_OPTION_READONLY 0x1 /* option is only setable at creation time */
    #define TKO_OPTION_HIDE     0x2 /* option is hidden in configure method */ 

### Enum: `tkoWidgetOptionType`

Suported enum type in the TkowidgetOptinSet() function. In comments is the type of the address provided in the **TkoWidgetOptionSet** funtion.

    typedef enum tkoWidgetOptionType {
        TKO_SET_CLASS = 1,     /* (Tcl_Obj **)address */

Changes to doc/tkoWidget.n.md.

3
4
5
6
7
8
9

10
11
12
13
14
15
16
17
18
19
20










21
22
23
24
25
26
27
...
135
136
137
138
139
140
141








142
143
144
145
146
147
148
149
150
151
152
153




154

155
156


157

158
159
160
161
162
163
164
165
166
167
168
169
170
171

172


173

174
175
176
177
178
179


180





181
182
183
184
185
186
187
188
189
190
191
*   [SYNOPSIS](#SYNOPSIS)
*   [TKO STANDARD OPTIONS](#TKO-STANDARD-OPTIONS)  
  [-class, class, Class](#-class)  
  [-screen, screen, Screen](#-screen)  
*   [DESCRIPTION](#DESCRIPTION)  
*   [WIDGET METHODS](#WIDGET-METHODS)  
*   [WIDGET OPTIONS](#WIDGET-OPTIONS)  

*   [SEE ALSO](#SEE-ALSO)  
*   [KEYWORDS](#KEYWORDS)  
*   [COPYRIGHT](#COPYRIGHT)  

<a name="SYNOPSIS"></a>
## SYNOPSIS

    oo::class create "widgetClass" {
      {*}$::tko::unknown    ;# define unknown method to support common tk widget style
      superclass "tkoClass" ;# one of the provided tko widget class's
      variable tko          ;# array with options *$tko(-option)* and widget path *$tko(.)*










    }

The command creates a new Tcl class whose name is *widgetClass*. This command may be used to create new widgets. Each new widget class has as a *tkoClass* as superclass. The common functionality is in the **tko::widget** class. Currently the following *tkoClass* superclasses are provided:

**::tko::toplevel** *pathName ?option value? ..*

**::tko::frame** *pathName ?option value? ..*
................................................................................

> > Add a new option. If ?flags? is equal "1" then the option is readonly and can only be set in this call. Before adding a new option a *-option* method must created. The method will be called without any arguments. The method can access the new value using the *tko(-option)* array variable. If the method throws a n error the array variable will be reset to the old value.

> **configure optiondel** *-option*

> > Delete the given option and unset the entry in the tko array variable. The created *-option* method's are not deleted. This is the task of the caller.









> **configure optionvar**

> > The method return the global varname of the tko array variable holding all option values.

<a name="method-cget"></a>
**\_tko\_configure**

> This is an virtuel method of the **tko::widget** class. This method will be called at the end of each **configure** *-option value ..* call. It can be implemented in each class to amke necessary changes. If it is implemented it should also call **next** to notify underlying classes.

<a name="WIDGET-OPTIONS"></a>
### WIDGET OPTIONS





Widget options can be dynamically added and removed at class or object level.


Add options at class level:




    oo::class create myWidget {
      {*}$::tko::unknown
      superclass ::tko::frame
      variable tko
      method -myoption {} {puts $tko(-myoption)}
      method -myreadonly {} {puts $tko(-myreadonly)}
      constructor {optionlist arglist} {
        next [concat $optionlist {
          {-myoption myOption MyOption value}
          {-myreadonly myReadonly MyReadonly value 1}
        }] $arglist
      }
    }


Deal with optons at object level. This is the raw part. May be we should add some sugar to it.




    myWidget .w
    oo::objdefine .w method -o1 {} {puts $tko(-o1)}
    oo::objdefine .w method -o2 {} {puts $tko(-o2)}
    .w configure optionadd -o1 o1 O1 v1 1
    .w configure optionadd -o2 o2 O2 v2
    ...


    .w optiondel -o1






Widget option values are saved in an option array. The option name is the field name in the array. Additionally is an field "**.**" containing the tk widget path name of the widget. The name of the option array variable can be retrieved using the following code:
    set myVar [.w configure optionvar]
    parray $myVar

<a name="SEE-ALSO"></a>
## SEE ALSO

[frame][], [labelframe][], [toplevel][], [oo::class][]

<a name="KEYWORDS"></a>






>







|



>
>
>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>












>
>
>
>

>

<
>
>

>
|






|


|


<
>
|
>
>
|
>
|
|
|
|

<
>
>
|
>
>
>
>
>

<
<
<







3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
...
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179

180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196

197
198
199
200
201
202
203
204
205
206
207

208
209
210
211
212
213
214
215
216



217
218
219
220
221
222
223
*   [SYNOPSIS](#SYNOPSIS)
*   [TKO STANDARD OPTIONS](#TKO-STANDARD-OPTIONS)  
  [-class, class, Class](#-class)  
  [-screen, screen, Screen](#-screen)  
*   [DESCRIPTION](#DESCRIPTION)  
*   [WIDGET METHODS](#WIDGET-METHODS)  
*   [WIDGET OPTIONS](#WIDGET-OPTIONS)  
*   [EXAMPLES](#EXAMPLES)  
*   [SEE ALSO](#SEE-ALSO)  
*   [KEYWORDS](#KEYWORDS)  
*   [COPYRIGHT](#COPYRIGHT)  

<a name="SYNOPSIS"></a>
## SYNOPSIS

    oo::class create myWidget {
      {*}$::tko::unknown    ;# define unknown method to support common tk widget style
      superclass "tkoClass" ;# one of the provided tko widget class's
      variable tko          ;# array with options *$tko(-option)* and widget path *$tko(.)*
      method -myoption {...};# deal with option when set
      ...
      constructor {optionlist arglist} {
        next [concat {
          {-myoption myOption MyOption value}
          ...
        } $optionlist] $arglist
        ...
      }
      destructor {next}
    }

The command creates a new Tcl class whose name is *widgetClass*. This command may be used to create new widgets. Each new widget class has as a *tkoClass* as superclass. The common functionality is in the **tko::widget** class. Currently the following *tkoClass* superclasses are provided:

**::tko::toplevel** *pathName ?option value? ..*

**::tko::frame** *pathName ?option value? ..*
................................................................................

> > Add a new option. If ?flags? is equal "1" then the option is readonly and can only be set in this call. Before adding a new option a *-option* method must created. The method will be called without any arguments. The method can access the new value using the *tko(-option)* array variable. If the method throws a n error the array variable will be reset to the old value.

> **configure optiondel** *-option*

> > Delete the given option and unset the entry in the tko array variable. The created *-option* method's are not deleted. This is the task of the caller.

> **configure optionhide** *?-option? ..*

> > If no *-option* is given return a list of all not configure'able options. Otherwise hide all of the given options.

> **configure optionshow** *?-option? ..*

> > If no *-option* is given return a list of all configure'able options. Otherwise make all of the given options configure'able.

> **configure optionvar**

> > The method return the global varname of the tko array variable holding all option values.

<a name="method-cget"></a>
**\_tko\_configure**

> This is an virtuel method of the **tko::widget** class. This method will be called at the end of each **configure** *-option value ..* call. It can be implemented in each class to amke necessary changes. If it is implemented it should also call **next** to notify underlying classes.

<a name="WIDGET-OPTIONS"></a>
### WIDGET OPTIONS

Widget option values are saved in an option array. The option name is the field name in the array. Additionally is an field "**.**" containing the tk widget path name of the widget. The name of the option array variable can be retrieved using the following code:
    set myVar [.w configure optionvar]
    parray $myVar

Widget options can be dynamically added and removed at class or object level.
It is possible to hide and unhide options.


<a name="EXAMPLES"></a>
### EXAMPLES

    # Add options at class creation:
    oo::class create ::myWidget {
      {*}$::tko::unknown
      superclass ::tko::frame
      variable tko
      method -myoption {} {puts $tko(-myoption)}
      method -myreadonly {} {puts $tko(-myreadonly)}
      constructor {optionlist arglist} {
        next [concat {
          {-myoption myOption MyOption value}
          {-myreadonly myReadonly MyReadonly value 1}
        } $optionlist] $arglist
      }
    }

    proc output {} {
      puts "config: [.w configure]"
      puts "normal: [.w configure optionhide]"
      puts "hidden: [.w configure optionshow]"
    }
    # Add options at object level:
    ::myWidget .w
    oo::objdefine .w method -o1 {} {my variable tko; puts $tko(-o1)}
    oo::objdefine .w method -o2 {} {my variable tko; puts $tko(-o2)}
    .w configure optionadd -o1 o1 O1 v1 1 ;#->
    .w configure optionadd -o2 o2 O2 v2

    output
    # Remove one and hide rest
    .w configure optiondel -o2
    .w configure optionhide {*}[.w configure optionshow]
    output
    # Reverse state
    .w configure optionshow {*}[.w configure optionhide]
    output





<a name="SEE-ALSO"></a>
## SEE ALSO

[frame][], [labelframe][], [toplevel][], [oo::class][]

<a name="KEYWORDS"></a>

Changes to generic/tko/tkoFrame.c.

162
163
164
165
166
167
168






169
170
171
172
173
174
175
...
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
    Tcl_Obj * const objv[]);
static int FrameMethod_tko_configure(
    ClientData clientData,
    Tcl_Interp * interp,
    Tcl_ObjectContext context,
    int objc,
    Tcl_Obj * const objv[]);






static int FrameMethod_labelanchor(
    ClientData clientData,
    Tcl_Interp * interp,
    Tcl_ObjectContext context,
    int objc,
    Tcl_Obj * const objv[]);
static int FrameMethod_labelwidget(
................................................................................
 * Definition of options created in object constructor.
 * Order of used options in definition is important:
 * -class -visual -colormap -container -use
 */

/* Common options for all defined widgets. */
#define FRAME_COMMONDEFINE \
	{ "-background" , "background", "Background",\
		DEF_FRAME_BG_COLOR, NULL, NULL, 0,\
		TKO_SET_3DBORDER, &frameMeta, offsetof(tkoFrame, border)}, \
	{ "-bg" , "-background", NULL, NULL, NULL, NULL, 0,0,NULL,0}, \
	{ "-bd" , "-borderwidth", NULL, NULL, NULL, NULL, 0,0,NULL,0}, \
	{ "-cursor" , "cursor", "Cursor", \
		DEF_FRAME_CURSOR, NULL, NULL, 0, \
		TKO_SET_CURSOR, &frameMeta, offsetof(tkoFrame, cursor)}, \
	{ "-height" , "height", "Height", \
		DEF_FRAME_HEIGHT, NULL, NULL, 0,\
		TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, height)}, \
	{ "-highlightbackground", "highlightbackground", "highlightBackground", \
		DEF_FRAME_HIGHLIGHT_BG, NULL, NULL, 0,\
		TKO_SET_XCOLOR, &frameMeta, offsetof(tkoFrame, highlightBgColorPtr)}, \
	{ "-highlightcolor", "highlightColor", "HighlightColor", \
		DEF_FRAME_HIGHLIGHT, NULL, NULL, 0,\
		TKO_SET_XCOLOR, &frameMeta, offsetof(tkoFrame, highlightColorPtr)}, \
	{ "-highlightthickness" , "highlightThickness", "HighlightThickness", \
		DEF_FRAME_HIGHLIGHT_WIDTH, NULL, NULL, 0,\
		TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, highlightWidth)}, \
	{ "-padx" , "padX", "Pad",\
		DEF_FRAME_PADX, NULL, NULL, 0,\
		TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, padX)}, \
	{ "-pady" , "padY", "Pad", \
		DEF_FRAME_PADY, NULL, NULL, 0,\
		TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, padY)}, \
	{ "-takefocus" , "takeFocus", "TakeFocus", \
		DEF_FRAME_TAKE_FOCUS, NULL, NULL, 0,\
		TKO_SET_STRING, NULL, 0}, \
	{ "-width" , "width", "Width", \
		DEF_FRAME_WIDTH, NULL, NULL, 0,\
		TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, width)}, \
	{ NULL,NULL,NULL,NULL,NULL,NULL,0,\
		0,NULL,0}

/* tko::frame options */
static tkoWidgetOptionDefine frameOptions[] = {
    {"-class", "class", "Class", "TkoFrame",
            NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_CLASS, NULL, 0},
    {"-visual", "visual", "Visual",
            DEF_FRAME_VISUAL, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_VISUAL, NULL, 0},
    {"-colormap", "colormap", "Colormap",
            DEF_FRAME_COLORMAP, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_COLORMAP, NULL, 0},
    {"-container", "container", "Container",
            DEF_FRAME_CONTAINER, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_CONTAINER, &frameMeta, offsetof(tkoFrame, isContainer)},
    {"-borderwidth", "borderWidth", "BorderWidth",
            DEF_FRAME_BORDER_WIDTH, NULL, NULL, 0,
        TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, borderWidth)},
    {"-relief", "relief", "Relief",
            DEF_FRAME_RELIEF, NULL, NULL, 0,
        TKO_SET_RELIEF, &frameMeta, offsetof(tkoFrame, relief)},
    FRAME_COMMONDEFINE
};

/* tko::toplevel options */
static tkoWidgetOptionDefine toplevelOptions[] = {
    {"-screen", "screen", "Screen",
            "", NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_STRING, NULL, 0},
    {"-class", "class", "Class",
            "TkoToplevel", NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_CLASS, NULL, 0},
    {"-container", "container", "Container",
            DEF_FRAME_CONTAINER, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_CONTAINER, &frameMeta, offsetof(tkoFrame, isContainer)},
    {"-use", "use", "Use",
            DEF_TOPLEVEL_USE, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_USENULL, &frameMeta, offsetof(tkoFrame, useThis)},
    {"-visual", "visual", "Visual",
            DEF_FRAME_VISUAL, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_VISUAL, NULL, 0},
    {"-colormap", "colormap", "Colormap",
            DEF_FRAME_COLORMAP, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_COLORMAP, NULL, 0},
    {"-borderwidth", "borderWidth", "BorderWidth",
            DEF_FRAME_BORDER_WIDTH, NULL, NULL, 0,
        TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, borderWidth)},
    {"-menu", "menu", "Menu",
            DEF_TOPLEVEL_MENU, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &frameMeta, offsetof(tkoFrame, menuName)},
    {"-relief", "relief", "Relief",
            DEF_FRAME_RELIEF, NULL, NULL, 0,
        TKO_SET_RELIEF, &frameMeta, offsetof(tkoFrame, relief)},
    FRAME_COMMONDEFINE
};

/* tko::labelframe options */
static tkoWidgetOptionDefine labelframeOptions[] = {
    {"-class", "class", "Class",
            "TkoLabelframe", NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_CLASS, NULL, 0},
    {"-visual", "visual", "Visual",
            DEF_FRAME_VISUAL, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_VISUAL, NULL, 0},
    {"-colormap", "colormap", "Colormap",
            DEF_FRAME_COLORMAP, NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_COLORMAP, NULL, 0},
    {"-borderwidth", "borderWidth", "BorderWidth",
            DEF_LABELFRAME_BORDER_WIDTH, NULL, NULL, 0,
        TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, borderWidth)},
    {"-fg", "-foreground", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-font", "font", "Font",
            DEF_LABELFRAME_FONT, NULL, NULL, 0,
        TKO_SET_FONT, &frameMeta, offsetof(tkoLabelframe, tkfont)},
    {"-foreground", "foreground", "Foreground",
            DEF_LABELFRAME_FG, NULL, NULL, 0,
        TKO_SET_XCOLOR, &frameMeta, offsetof(tkoLabelframe, textColorPtr)},
    {"-labelanchor", "labelAnchor", "LabelAnchor",
            DEF_LABELFRAME_LABELANCHOR, NULL, FrameMethod_labelanchor, 0,
        0, NULL, 0},
    {"-labelwidget", "labelWidget", "LabelWidget",
            "", NULL, FrameMethod_labelwidget, 0,
        0, NULL, 0},
    {"-relief", "relief", "Relief",
            DEF_LABELFRAME_RELIEF, NULL, NULL, 0,
        TKO_SET_RELIEF, &frameMeta, offsetof(tkoFrame, relief)},
    {"-text", "text", "Text",
            DEF_LABELFRAME_TEXT, NULL, NULL, 0,
        TKO_SET_TCLOBJ, &frameMeta, offsetof(tkoLabelframe, textPtr)},
    FRAME_COMMONDEFINE
};

/*
 * Definition of object methods created in Tko_FrameInit() function.
 */







>
>
>
>
>
>







 







|
<
|
|
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<



|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|





|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|





|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
<
|
|
<
|
|
|
<
|
|
<
|
<
|
|
<
|







162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
...
271
272
273
274
275
276
277
278

279
280
281
282

283
284

285
286

287
288

289
290

291
292

293
294

295
296

297
298

299
300

301
302
303
304

305
306

307
308

309
310

311
312

313
314

315
316
317
318
319
320
321

322
323

324
325

326
327

328
329

330
331

332
333

334
335

336
337

338
339
340
341
342
343
344

345
346

347
348

349
350

351
352

353

354
355

356
357
358

359
360

361

362
363

364
365
366
367
368
369
370
371
    Tcl_Obj * const objv[]);
static int FrameMethod_tko_configure(
    ClientData clientData,
    Tcl_Interp * interp,
    Tcl_ObjectContext context,
    int objc,
    Tcl_Obj * const objv[]);
static int FrameMethod_tko_option(
	ClientData clientData,
	Tcl_Interp * interp,
	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[]);
static int FrameMethod_labelanchor(
    ClientData clientData,
    Tcl_Interp * interp,
    Tcl_ObjectContext context,
    int objc,
    Tcl_Obj * const objv[]);
static int FrameMethod_labelwidget(
................................................................................
 * Definition of options created in object constructor.
 * Order of used options in definition is important:
 * -class -visual -colormap -container -use
 */

/* Common options for all defined widgets. */
#define FRAME_COMMONDEFINE \
	{ "-background" , "background", "Background", DEF_FRAME_BG_COLOR, 0, NULL, \

        NULL, NULL,	TKO_SET_3DBORDER, &frameMeta, offsetof(tkoFrame, border)}, \
	{ "-bg" , "-background", NULL, NULL, 0, NULL, NULL, NULL,0,NULL,0}, \
	{ "-bd" , "-borderwidth", NULL, NULL, 0, NULL, NULL, NULL,0,NULL,0}, \
	{ "-cursor" , "cursor", "Cursor", DEF_FRAME_CURSOR, 0, NULL, \

		NULL, NULL, TKO_SET_CURSOR, &frameMeta, offsetof(tkoFrame, cursor)}, \
	{ "-height" , "height", "Height", DEF_FRAME_HEIGHT, 0, NULL, \

		NULL, NULL, TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, height)}, \
	{ "-highlightbackground", "highlightbackground", "highlightBackground", DEF_FRAME_HIGHLIGHT_BG, 0, NULL, \

		NULL, NULL, TKO_SET_XCOLOR, &frameMeta, offsetof(tkoFrame, highlightBgColorPtr)}, \
	{ "-highlightcolor", "highlightColor", "HighlightColor", DEF_FRAME_HIGHLIGHT, 0,NULL, \

		NULL, NULL, TKO_SET_XCOLOR, &frameMeta, offsetof(tkoFrame, highlightColorPtr)}, \
	{ "-highlightthickness" , "highlightThickness", "HighlightThickness", DEF_FRAME_HIGHLIGHT_WIDTH,  0,NULL, \

		NULL, NULL, TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, highlightWidth)}, \
	{ "-padx" , "padX", "Pad", DEF_FRAME_PADX, 0,NULL, \

		NULL, NULL, TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, padX)}, \
	{ "-pady" , "padY", "Pad", DEF_FRAME_PADY, 0,NULL, \

		NULL, NULL, TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, padY)}, \
	{ "-takefocus" , "takeFocus", "TakeFocus", DEF_FRAME_TAKE_FOCUS,  0,NULL, \

		NULL, NULL, TKO_SET_STRING, NULL, 0}, \
	{ "-width" , "width", "Width", DEF_FRAME_WIDTH,  0,NULL, \

		NULL, NULL, TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, width)}, \
	{ NULL,NULL,NULL,NULL,0,NULL, NULL,NULL,0,NULL,0}


/* tko::frame options */
static tkoWidgetOptionDefine frameOptions[] = {
    {"-class", "class", "Class", "TkoFrame", TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_CLASS, NULL, 0},
    {"-visual", "visual", "Visual", DEF_FRAME_VISUAL, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_VISUAL, NULL, 0},
    {"-colormap", "colormap", "Colormap", DEF_FRAME_COLORMAP, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_COLORMAP, NULL, 0},
    {"-container", "container", "Container", DEF_FRAME_CONTAINER, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_CONTAINER, &frameMeta, offsetof(tkoFrame, isContainer)},
    {"-borderwidth", "borderWidth", "BorderWidth", DEF_FRAME_BORDER_WIDTH, 0,NULL,

	NULL, NULL, TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, borderWidth)},
    {"-relief", "relief", "Relief", DEF_FRAME_RELIEF, 0,NULL,

	NULL, NULL, TKO_SET_RELIEF, &frameMeta, offsetof(tkoFrame, relief)},
    FRAME_COMMONDEFINE
};

/* tko::toplevel options */
static tkoWidgetOptionDefine toplevelOptions[] = {
    {"-screen", "screen", "Screen", "", TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_STRING, NULL, 0},
    {"-class", "class", "Class", "TkoToplevel", TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_CLASS, NULL, 0},
    {"-container", "container", "Container", DEF_FRAME_CONTAINER, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_CONTAINER, &frameMeta, offsetof(tkoFrame, isContainer)},
    {"-use", "use", "Use", DEF_TOPLEVEL_USE, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_USENULL, &frameMeta, offsetof(tkoFrame, useThis)},
    {"-visual", "visual", "Visual", DEF_FRAME_VISUAL, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_VISUAL, NULL, 0},
    {"-colormap", "colormap", "Colormap", DEF_FRAME_COLORMAP, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_COLORMAP, NULL, 0},
    {"-borderwidth", "borderWidth", "BorderWidth", DEF_FRAME_BORDER_WIDTH, 0,NULL,

	NULL, NULL, TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, borderWidth)},
    {"-menu", "menu", "Menu", DEF_TOPLEVEL_MENU, 0,NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &frameMeta, offsetof(tkoFrame, menuName)},
    {"-relief", "relief", "Relief", DEF_FRAME_RELIEF, 0,NULL,

	NULL, NULL, TKO_SET_RELIEF, &frameMeta, offsetof(tkoFrame, relief)},
    FRAME_COMMONDEFINE
};

/* tko::labelframe options */
static tkoWidgetOptionDefine labelframeOptions[] = {
    {"-class", "class", "Class", "TkoLabelframe", TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_CLASS, NULL, 0},
    {"-visual", "visual", "Visual", DEF_FRAME_VISUAL, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_VISUAL, NULL, 0},
    {"-colormap", "colormap", "Colormap", DEF_FRAME_COLORMAP, TKO_OPTION_READONLY,NULL,

	NULL, NULL, TKO_SET_COLORMAP, NULL, 0},
    {"-borderwidth", "borderWidth", "BorderWidth", DEF_LABELFRAME_BORDER_WIDTH, 0,NULL,

	NULL, NULL, TKO_SET_PIXEL, &frameMeta, offsetof(tkoFrame, borderWidth)},
    {"-fg", "-foreground", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-font", "font", "Font", DEF_LABELFRAME_FONT, 0,NULL,

	NULL, NULL, TKO_SET_FONT, &frameMeta, offsetof(tkoLabelframe, tkfont)},
	{"-foreground", "foreground", "Foreground", DEF_LABELFRAME_FG, 0, NULL,

	NULL, NULL, TKO_SET_XCOLOR, &frameMeta, offsetof(tkoLabelframe, textColorPtr)},
    {"-labelanchor", "labelAnchor", "LabelAnchor", DEF_LABELFRAME_LABELANCHOR, 0, NULL,
	NULL, FrameMethod_labelanchor, 0, NULL, 0},

    {"-labelwidget", "labelWidget", "LabelWidget", "",0, NULL,
	NULL, FrameMethod_labelwidget, 0, NULL, 0},

    {"-relief", "relief", "Relief", DEF_LABELFRAME_RELIEF, 0, NULL,

	NULL, NULL, TKO_SET_RELIEF, &frameMeta, offsetof(tkoFrame, relief)},
    {"-text", "text", "Text", DEF_LABELFRAME_TEXT, 0, NULL,

	NULL, NULL, TKO_SET_TCLOBJ, &frameMeta, offsetof(tkoLabelframe, textPtr)},
    FRAME_COMMONDEFINE
};

/*
 * Definition of object methods created in Tko_FrameInit() function.
 */

Changes to generic/tko/tkoGraph.c.

311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
/*
 * graphOptionDefine --
 *
 * Options and option methods created in class constructor.
 */
static tkoWidgetOptionDefine graphOptionDefine[] = {
    {"-class", "class", "Class",
            "TkoGraph", NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_CLASS, NULL, 0},
    {"-style", "style", "Style",
            "line", NULL, GraphMethod_style, TKO_WIDGETOPTIONREADONLY,
        0, NULL, 0},
    {"-aspect", "aspect", "Aspect",
            DEF_GRAPH_ASPECT_RATIO, NULL, NULL, 0,
        TKO_SET_DOUBLE, &graphMeta, offsetof(RbcGraph, aspect)},
    {"-background", "background", "Background",
            DEF_GRAPH_BACKGROUND, NULL, NULL, 0,
        TKO_SET_3DBORDER, &graphMeta, offsetof(RbcGraph, border)},
    {"-barmode", "barMode", "BarMode",
            DEF_GRAPH_BAR_MODE, NULL, GraphMethod_barmode, 0,
        0, NULL, 0},
    {"-barwidth", "barWidth", "BarWidth",
            DEF_GRAPH_BAR_WIDTH, NULL, GraphMethod_barwidth, 0,
        0, NULL, 0},
    {"-baseline", "baseline", "Baseline",
            DEF_GRAPH_BAR_BASELINE, NULL, NULL, 0,
        TKO_SET_DOUBLE, &graphMeta, offsetof(RbcGraph, baseline)},
    {"-bd", "-borderwidth", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-bg", "-background", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-bm", "-bottommargin", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-borderwidth", "borderWidth", "BorderWidth",
            DEF_GRAPH_BORDERWIDTH, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph, borderWidth)},
    {"-bottommargin", "bottomMargin", "Margin",
            DEF_GRAPH_MARGIN, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,
                margins[RBC_MARGIN_BOTTOM].reqSize)},
    {"-bottomvariable", "bottomVariable", "BottomVariable",
            DEF_GRAPH_MARGIN_VAR, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph,
                margins[RBC_MARGIN_BOTTOM].varName)},
    {"-bufferelements", "bufferElements", "BufferElements",
            DEF_GRAPH_BUFFER_ELEMENTS, NULL, NULL, 0,
        TKO_SET_BOOLEAN, &graphMeta, offsetof(RbcGraph, backingStore)},
    {"-buffergraph", "bufferGraph", "BufferGraph",
            DEF_GRAPH_BUFFER_GRAPH, NULL, NULL, 0,
        TKO_SET_BOOLEAN, &graphMeta, offsetof(RbcGraph, doubleBuffer)},
    {"-cursor", "cursor", "Cursor",
            DEF_GRAPH_CURSOR, NULL, NULL, 0,
        TKO_SET_CURSOR, &graphMeta, offsetof(RbcGraph, cursor)},
    {"-fg", "-foreground", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-font", "font", "Font",
            DEF_GRAPH_FONT, NULL, NULL, 0,
        TKO_SET_FONT, &graphMeta, offsetof(RbcGraph, titleTextStyle.font)},
    {"-foreground", "foreground", "Foreground",
            DEF_GRAPH_TITLE_COLOR, NULL, NULL, 0,
        TKO_SET_XCOLOR, &graphMeta, offsetof(RbcGraph, titleTextStyle.color)},
    {"-halo", "halo", "Halo",
            DEF_GRAPH_HALO, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph, halo)},
    {"-height", "height", "Height",
            DEF_GRAPH_HEIGHT, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph, reqHeight)},
    {"-highlightbackground", "highlightBackground", "HighlightBackground",
            DEF_GRAPH_HIGHLIGHT_BACKGROUND, NULL, NULL, 0,
        TKO_SET_XCOLOR, &graphMeta, offsetof(RbcGraph, highlightBgColor)},
    {"-highlightcolor", "highlightColor", "HighlightColor",
            DEF_GRAPH_HIGHLIGHT_COLOR, 0, NULL, 0,
        TKO_SET_XCOLOR, &graphMeta, offsetof(RbcGraph, highlightColor)},
    {"-highlightthickness", "highlightThickness", "HighlightThickness",
            DEF_GRAPH_HIGHLIGHT_WIDTH, NULL, NULL, 0,
        TKO_SET_PIXEL, &graphMeta, offsetof(RbcGraph, highlightWidth)},
    {"-invertxy", "invertXY", "InvertXY",
            DEF_GRAPH_INVERT_XY, NULL, NULL, 0,
        TKO_SET_BOOLEAN, &graphMeta, offsetof(RbcGraph, inverted)},
    {"-justify", "justify", "Justify",
            DEF_GRAPH_JUSTIFY, NULL, NULL, 0,
        TKO_SET_JUSTIFY, &graphMeta, offsetof(RbcGraph,
                titleTextStyle.justify)},
    {"-leftmargin", "leftMargin", "Margin",
            DEF_GRAPH_MARGIN, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,
                margins[RBC_MARGIN_LEFT].reqSize)},
    {"-leftvariable", "leftVariable", "LeftVariable",
            DEF_GRAPH_MARGIN_VAR, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph,
                margins[RBC_MARGIN_LEFT].varName)},
    {"-lm", "-leftmargin", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-plotbackground", "plotBackground", "Background",
            DEF_GRAPH_PLOT_BG_MONO, NULL, NULL, 0,
        TKO_SET_XCOLOR, &graphMeta, offsetof(RbcGraph, plotBg)},
    {"-plotborderwidth", "plotBorderWidth", "BorderWidth",
            DEF_GRAPH_PLOT_BW_COLOR, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,
                plotBorderWidth)},
    {"-plotpadx", "plotPadX", "PlotPad",
            DEF_GRAPH_PLOT_PADX, NULL, GraphMethod_plotpadx, 0,
        0, NULL, 0},
    {"-plotpady", "plotPadY", "PlotPad",
            DEF_GRAPH_PLOT_PADY, NULL, GraphMethod_plotpady, 0,
        0, NULL, 0},
    {"-plotrelief", "plotRelief", "Relief",
            DEF_GRAPH_PLOT_RELIEF, NULL, NULL, 0,
        TKO_SET_RELIEF, &graphMeta, offsetof(RbcGraph, plotRelief)},
    {"-relief", "relief", "Relief",
            DEF_GRAPH_RELIEF, NULL, NULL, 0,
        TKO_SET_RELIEF, &graphMeta, offsetof(RbcGraph, relief)},
    {"-rightmargin", "rightMargin", "Margin",
            DEF_GRAPH_MARGIN, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,
                margins[RBC_MARGIN_RIGHT].reqSize)},
    {"-rightvariable", "rightVariable", "RightVariable",
            DEF_GRAPH_MARGIN_VAR, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph,
                margins[RBC_MARGIN_RIGHT].varName)},
    {"-rm", "-rightmargin", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-shadow", "shadow", "Shadow",
            DEF_GRAPH_SHADOW_COLOR, NULL, GraphMethod_shadow, 0,
        0, NULL, 0},
    {"-takefocus", "takeFocus", "TakeFocus",
            DEF_GRAPH_TAKE_FOCUS, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph, takeFocus)},
    {"-tile", "tile", "Tile",
            NULL, NULL, GraphMethod_tile, 0,
        0, NULL, 0},
    {"-title", "title", "Title",
            DEF_GRAPH_TITLE, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph, title)},
    {"-tm", "-topmargin", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-topmargin", "-topmargin", "Margin",
            DEF_GRAPH_MARGIN, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,
                margins[RBC_MARGIN_TOP].reqSize)},
    {"-topvariable", "topVariable", "TopVariable",
            DEF_GRAPH_MARGIN_VAR, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph,
                margins[RBC_MARGIN_TOP].varName)},
    {"-width", "width", "Width",
            DEF_GRAPH_WIDTH, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph, reqWidth)},
    {NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, 0}
};

/*
 * graphMethods --
 *
 * Methods created in class constructor.
 */






|
<
|
|
|
<
|
<
|
|
<
|
|
|
<
|
|
<
|
<
|
|
<
|
<
|
<
|
<
|
|
<
|
<
|
<
|
<
|
<
|
|
<
|
|
<
|
|
<
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
<
|
<
|
<
|
<
|
<
|
<
|
<
|
|
<
|
<
|
|
<
|
|
<
|
<
|
|
<
|
|
<
|
<
|
<
|
<
|
<
|
|
<
|
<
|
|
|
<
|
<
|
|
<
|
<
|
<
|
<
|
<
|
<
|
|







311
312
313
314
315
316
317
318

319
320
321

322

323
324

325
326
327

328
329

330

331
332

333

334

335

336
337

338

339

340

341

342
343

344
345

346
347

348

349
350

351
352

353
354

355
356

357
358

359
360

361
362

363
364

365

366

367

368

369

370

371

372
373

374

375
376

377
378

379

380
381

382
383

384

385

386

387

388
389

390

391
392
393

394

395
396

397

398

399

400

401

402
403
404
405
406
407
408
409
410
/*
 * graphOptionDefine --
 *
 * Options and option methods created in class constructor.
 */
static tkoWidgetOptionDefine graphOptionDefine[] = {
    {"-class", "class", "Class", "TkoGraph", TKO_OPTION_READONLY, NULL,

	NULL, NULL, TKO_SET_CLASS, NULL, 0},
    {"-style", "style", "Style", "line", TKO_OPTION_READONLY, NULL,
	NULL, GraphMethod_style, 0, NULL, 0},

    {"-aspect", "aspect", "Aspect", DEF_GRAPH_ASPECT_RATIO, 0, NULL,

	NULL, NULL, TKO_SET_DOUBLE, &graphMeta, offsetof(RbcGraph, aspect)},
    {"-background", "background", "Background", DEF_GRAPH_BACKGROUND, 0, NULL,

	NULL, NULL, TKO_SET_3DBORDER, &graphMeta, offsetof(RbcGraph, border)},
    {"-barmode", "barMode", "BarMode", DEF_GRAPH_BAR_MODE, 0, NULL,
	NULL, GraphMethod_barmode, 0, NULL, 0},

    {"-barwidth", "barWidth", "BarWidth", DEF_GRAPH_BAR_WIDTH, 0, NULL,
	NULL, GraphMethod_barwidth, 0, NULL, 0},

    {"-baseline", "baseline", "Baseline", DEF_GRAPH_BAR_BASELINE, 0, NULL,

	NULL, NULL, TKO_SET_DOUBLE, &graphMeta, offsetof(RbcGraph, baseline)},
    {"-bd", "-borderwidth", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-bg", "-background", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-bm", "-bottommargin", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-borderwidth", "borderWidth", "BorderWidth", DEF_GRAPH_BORDERWIDTH, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph, borderWidth)},
    {"-bottommargin", "bottomMargin", "Margin", DEF_GRAPH_MARGIN, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,margins[RBC_MARGIN_BOTTOM].reqSize)},

    {"-bottomvariable", "bottomVariable", "BottomVariable", DEF_GRAPH_MARGIN_VAR, 0, NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph,margins[RBC_MARGIN_BOTTOM].varName)},

    {"-bufferelements", "bufferElements", "BufferElements", DEF_GRAPH_BUFFER_ELEMENTS, 0, NULL,

	NULL, NULL, TKO_SET_BOOLEAN, &graphMeta, offsetof(RbcGraph, backingStore)},
    {"-buffergraph", "bufferGraph", "BufferGraph", DEF_GRAPH_BUFFER_GRAPH, 0, NULL,

	NULL, NULL, TKO_SET_BOOLEAN, &graphMeta, offsetof(RbcGraph, doubleBuffer)},
    {"-cursor", "cursor", "Cursor", DEF_GRAPH_CURSOR, 0, NULL,

	NULL, NULL, TKO_SET_CURSOR, &graphMeta, offsetof(RbcGraph, cursor)},
    {"-fg", "-foreground", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-font", "font", "Font", DEF_GRAPH_FONT, 0, NULL,

	NULL, NULL, TKO_SET_FONT, &graphMeta, offsetof(RbcGraph, titleTextStyle.font)},
    {"-foreground", "foreground", "Foreground", DEF_GRAPH_TITLE_COLOR, 0, NULL,

	NULL, NULL, TKO_SET_XCOLOR, &graphMeta, offsetof(RbcGraph, titleTextStyle.color)},
    {"-halo", "halo", "Halo", DEF_GRAPH_HALO, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph, halo)},
    {"-height", "height", "Height", DEF_GRAPH_HEIGHT, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph, reqHeight)},
    {"-highlightbackground", "highlightBackground", "HighlightBackground", DEF_GRAPH_HIGHLIGHT_BACKGROUND, 0, NULL,

	NULL, NULL, TKO_SET_XCOLOR, &graphMeta, offsetof(RbcGraph, highlightBgColor)},
    {"-highlightcolor", "highlightColor", "HighlightColor", DEF_GRAPH_HIGHLIGHT_COLOR, 0, NULL,

	NULL, NULL, TKO_SET_XCOLOR, &graphMeta, offsetof(RbcGraph, highlightColor)},
    {"-highlightthickness", "highlightThickness", "HighlightThickness", DEF_GRAPH_HIGHLIGHT_WIDTH, 0, NULL,

	NULL, NULL, TKO_SET_PIXEL, &graphMeta, offsetof(RbcGraph, highlightWidth)},
    {"-invertxy", "invertXY", "InvertXY", DEF_GRAPH_INVERT_XY, 0, NULL,

	NULL, NULL, TKO_SET_BOOLEAN, &graphMeta, offsetof(RbcGraph, inverted)},
    {"-justify", "justify", "Justify", DEF_GRAPH_JUSTIFY, 0, NULL,

	NULL, NULL, TKO_SET_JUSTIFY, &graphMeta, offsetof(RbcGraph,titleTextStyle.justify)},

    {"-leftmargin", "leftMargin", "Margin", DEF_GRAPH_MARGIN, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,margins[RBC_MARGIN_LEFT].reqSize)},

    {"-leftvariable", "leftVariable", "LeftVariable", DEF_GRAPH_MARGIN_VAR, 0, NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph,margins[RBC_MARGIN_LEFT].varName)},

    {"-lm", "-leftmargin", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-plotbackground", "plotBackground", "Background", DEF_GRAPH_PLOT_BG_MONO, 0, NULL,

	NULL, NULL, TKO_SET_XCOLOR, &graphMeta, offsetof(RbcGraph, plotBg)},
    {"-plotborderwidth", "plotBorderWidth", "BorderWidth", DEF_GRAPH_PLOT_BW_COLOR, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,plotBorderWidth)},

    {"-plotpadx", "plotPadX", "PlotPad", DEF_GRAPH_PLOT_PADX, 0, NULL,
	NULL, GraphMethod_plotpadx, 0, NULL, 0},

    {"-plotpady", "plotPadY", "PlotPad", DEF_GRAPH_PLOT_PADY, 0, NULL,
	NULL, GraphMethod_plotpady, 0, NULL, 0},

    {"-plotrelief", "plotRelief", "Relief", DEF_GRAPH_PLOT_RELIEF, 0, NULL,

	NULL, NULL, TKO_SET_RELIEF, &graphMeta, offsetof(RbcGraph, plotRelief)},
    {"-relief", "relief", "Relief", DEF_GRAPH_RELIEF, 0, NULL,

	NULL, NULL, TKO_SET_RELIEF, &graphMeta, offsetof(RbcGraph, relief)},
    {"-rightmargin", "rightMargin", "Margin", DEF_GRAPH_MARGIN, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,margins[RBC_MARGIN_RIGHT].reqSize)},

    {"-rightvariable", "rightVariable", "RightVariable", DEF_GRAPH_MARGIN_VAR, 0, NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph,margins[RBC_MARGIN_RIGHT].varName)},

    {"-rm", "-rightmargin", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-shadow", "shadow", "Shadow", DEF_GRAPH_SHADOW_COLOR, 0, NULL,
	NULL, GraphMethod_shadow, 0, NULL, 0},

    {"-takefocus", "takeFocus", "TakeFocus", DEF_GRAPH_TAKE_FOCUS, 0, NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph, takeFocus)},
    {"-tile", "tile", "Tile", NULL, 0, NULL,
	NULL, GraphMethod_tile, 0, NULL, 0},

    {"-title", "title", "Title", DEF_GRAPH_TITLE, 0, NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph, title)},
    {"-tm", "-topmargin", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-topmargin", "-topmargin", "Margin", DEF_GRAPH_MARGIN, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph,margins[RBC_MARGIN_TOP].reqSize)},

    {"-topvariable", "topVariable", "TopVariable", DEF_GRAPH_MARGIN_VAR, 0, NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &graphMeta, offsetof(RbcGraph,margins[RBC_MARGIN_TOP].varName)},

    {"-width", "width", "Width", DEF_GRAPH_WIDTH, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &graphMeta, offsetof(RbcGraph, reqWidth)},
    {NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0}
};

/*
 * graphMethods --
 *
 * Methods created in class constructor.
 */

Changes to generic/tko/tkoPath.c.

386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
/* 
 * pathOptionDefine --
 *
 * Options and option methods created in class constructor.
 */
static tkoWidgetOptionDefine pathOptionDefine[] = {
    {"-class", "class", "Class",
            "TkoPath", NULL, NULL, TKO_WIDGETOPTIONREADONLY,
        TKO_SET_CLASS, NULL, 0},
    {"-background", "background", "Background",
            DEF_CANVAS_BG_COLOR, NULL, NULL, 0,
        TKO_SET_3DBORDER, &pathMeta, offsetof(TkPathCanvas, bgBorder)},
    {"-bd", "-borderwidth", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-bg", "-background", NULL, NULL, NULL, NULL, 0,
        0, NULL, 0},
    {"-borderwidth", "borderWidth", "BorderWidth",
            DEF_CANVAS_BORDER_WIDTH, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,
                borderWidth)},
    {"-closeenough", "closeEnough", "CloseEnough",
            DEF_CANVAS_CLOSE_ENOUGH, NULL, NULL, 0,
        TKO_SET_DOUBLE, &pathMeta, offsetof(TkPathCanvas, closeEnough)},
    {"-confine", "confine", "Confine",
            DEF_CANVAS_CONFINE, NULL, NULL, 0,
        TKO_SET_BOOLEAN, &pathMeta, offsetof(TkPathCanvas, confine)},
    {"-cursor", "cursor", "Cursor",
            DEF_CANVAS_CURSOR, NULL, NULL, 0,
        TKO_SET_CURSOR, &pathMeta, offsetof(TkPathCanvas, cursor)},
    {"-height", "height", "Height",
            DEF_CANVAS_HEIGHT, NULL, NULL, 0,
        TKO_SET_PIXEL, &pathMeta, offsetof(TkPathCanvas, height)},
    {"-highlightbackground", "highlightBackground", "HighlightBackground",
            DEF_CANVAS_HIGHLIGHT_BG, NULL, NULL, 0,
        TKO_SET_XCOLOR, &pathMeta, offsetof(TkPathCanvas,
                highlightBgColorPtr)},
    {"-highlightcolor", "highlightColor", "HighlightColor",
            DEF_CANVAS_HIGHLIGHT, NULL, NULL, 0,
        TKO_SET_XCOLOR, &pathMeta, offsetof(TkPathCanvas, highlightColorPtr)},
    {"-highlightthickness", "highlightThickness", "HighlightThickness",
            DEF_CANVAS_HIGHLIGHT_WIDTH, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,
                highlightWidth)},
    {"-insertbackground", "insertBackground", "Foreground",
            DEF_CANVAS_INSERT_BG, NULL, NULL, 0,
        TKO_SET_3DBORDER, &pathMeta, offsetof(TkPathCanvas,
                textInfo.insertBorder)},
    {"-insertborderwidth", "insertBorderWidth", "BorderWidth",
            DEF_CANVAS_INSERT_BD_COLOR, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,
                textInfo.insertBorderWidth)},
    {"-insertofftime", "insertOffTime", "OffTime",
            DEF_CANVAS_INSERT_OFF_TIME, NULL, NULL, 0,
        TKO_SET_INT, &pathMeta, offsetof(TkPathCanvas, insertOffTime)},
    {"-insertontime", "insertOnTime", "OnTime",
            DEF_CANVAS_INSERT_ON_TIME, NULL, NULL, 0,
        TKO_SET_INT, &pathMeta, offsetof(TkPathCanvas, insertOnTime)},
    {"-insertwidth", "insertWidth", "InsertWidth",
            DEF_CANVAS_INSERT_ON_TIME, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,
                textInfo.insertWidth)},
    {"-offset", "offset", "Offset",
            "0,0", NULL, PathMethod_offset, 0,
        0, NULL, 0},
    {"-relief", "relief", "Relief",
            DEF_CANVAS_RELIEF, NULL, NULL, 0,
        TKO_SET_RELIEF, &pathMeta, offsetof(TkPathCanvas, relief)},
    {"-scrollregion", "scrollRegion", "ScrollRegion",
            DEF_CANVAS_SCROLL_REGION, NULL, NULL, 0,
        TKO_SET_SCROLLREGION, &pathMeta, offsetof(TkPathCanvas, scroll)},
    {"-selectbackground", "selectBackground", "Foreground",
            DEF_CANVAS_SELECT_COLOR, NULL, NULL, 0,
        TKO_SET_3DBORDER, &pathMeta, offsetof(TkPathCanvas,
                textInfo.selBorder)},
    {"-selectborderwidth", "selectBorderWidth", "BorderWidth",
            DEF_CANVAS_SELECT_BD_COLOR, NULL, NULL, 0,
        TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,
                textInfo.selBorderWidth)},
    {"-selectforeground", "selectForeground", "Background",
            DEF_CANVAS_SELECT_FG_COLOR, NULL, NULL, 0,
        TKO_SET_XCOLOR, &pathMeta, offsetof(TkPathCanvas,
                textInfo.selFgColorPtr)},
    {"-state", "state", "State",
            PATH_DEF_STATE, NULL, PathMethod_state, 0,
        0, NULL, 0},
    {"-tagstyle", "", "",
            "expr", NULL, PathMethod_tagstyle, 0,
        0, NULL, 0},
    {"-takefocus", "takeFocus", "TakeFocus",
            DEF_CANVAS_TAKE_FOCUS, NULL, NULL, 0,
        TKO_SET_STRING, NULL, 0},
    {"-width", "width", "Width",
            DEF_CANVAS_WIDTH, NULL, NULL, 0,
        TKO_SET_PIXEL, &pathMeta, offsetof(TkPathCanvas, width)},
    {"-xscrollcommand", "xScrollCommand", "ScrollCommand",
            DEF_CANVAS_X_SCROLL_CMD, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &pathMeta, offsetof(TkPathCanvas, xScrollCmd)},
    {"-xscrollincrement", "xScrollIncrement", "ScrollIncrement",
            DEF_CANVAS_X_SCROLL_INCREMENT, NULL, NULL, 0,
        TKO_SET_PIXEL, &pathMeta, offsetof(TkPathCanvas, xScrollIncrement)},
    {"-yscrollcommand", "yScrollCommand", "ScrollCommand",
            DEF_CANVAS_Y_SCROLL_CMD, NULL, NULL, 0,
        TKO_SET_STRINGNULL, &pathMeta, offsetof(TkPathCanvas, yScrollCmd)},
    {"-yscrollincrement", "yScrollIncrement", "ScrollIncrement",
            DEF_CANVAS_Y_SCROLL_INCREMENT, NULL, NULL, 0,
        TKO_SET_PIXEL, &pathMeta, offsetof(TkPathCanvas, yScrollIncrement)},
    {NULL, NULL, NULL, NULL, NULL, NULL, 0, 0, NULL, 0}
};

/*
 * pathMethods --
 *
 * Methods created in class constructor.
 */






|
<
|
|
<
|
|
<
|
<
|
<
|
<
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
<
|
<
|
|
<
|
<
|
<
|
<
|
<
|
<
|
<
|
|
<
|
|
<
|
<
|
|
<
|
<
|
|
<
|
|
<
|
<
|
<
|
<
|
<
|
<
|
|
<
|
|
<
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|
<
|
|







386
387
388
389
390
391
392
393

394
395

396
397

398

399

400

401

402
403

404
405

406
407

408
409

410

411

412
413

414

415

416

417

418

419

420
421

422
423

424

425
426

427

428
429

430
431

432

433

434

435

436

437
438

439
440

441

442
443

444
445

446
447

448
449

450
451

452
453
454
455
456
457
458
459
460
/* 
 * pathOptionDefine --
 *
 * Options and option methods created in class constructor.
 */
static tkoWidgetOptionDefine pathOptionDefine[] = {
    {"-class", "class", "Class", "TkoPath", TKO_OPTION_READONLY, NULL,

	NULL, NULL, TKO_SET_CLASS, NULL, 0},
    {"-background", "background", "Background", DEF_CANVAS_BG_COLOR, 0, NULL,

	NULL, NULL, TKO_SET_3DBORDER, &pathMeta, offsetof(TkPathCanvas, bgBorder)},
    {"-bd", "-borderwidth", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-bg", "-background", NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0},

    {"-borderwidth", "borderWidth", "BorderWidth", DEF_CANVAS_BORDER_WIDTH, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,borderWidth)},

    {"-closeenough", "closeEnough", "CloseEnough", DEF_CANVAS_CLOSE_ENOUGH, 0, NULL,

	NULL, NULL, TKO_SET_DOUBLE, &pathMeta, offsetof(TkPathCanvas, closeEnough)},
    {"-confine", "confine", "Confine", DEF_CANVAS_CONFINE, 0, NULL,

	NULL, NULL, TKO_SET_BOOLEAN, &pathMeta, offsetof(TkPathCanvas, confine)},
    {"-cursor", "cursor", "Cursor", DEF_CANVAS_CURSOR, 0, NULL,

	NULL, NULL, TKO_SET_CURSOR, &pathMeta, offsetof(TkPathCanvas, cursor)},
    {"-height", "height", "Height", DEF_CANVAS_HEIGHT, 0, NULL,

	NULL, NULL, TKO_SET_PIXEL, &pathMeta, offsetof(TkPathCanvas, height)},
    {"-highlightbackground", "highlightBackground", "HighlightBackground", DEF_CANVAS_HIGHLIGHT_BG, 0, NULL,

	NULL, NULL, TKO_SET_XCOLOR, &pathMeta, offsetof(TkPathCanvas, highlightBgColorPtr)},

    {"-highlightcolor", "highlightColor", "HighlightColor", DEF_CANVAS_HIGHLIGHT, 0, NULL,

	NULL, NULL, TKO_SET_XCOLOR, &pathMeta, offsetof(TkPathCanvas, highlightColorPtr)},
    {"-highlightthickness", "highlightThickness", "HighlightThickness", DEF_CANVAS_HIGHLIGHT_WIDTH, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,highlightWidth)},

    {"-insertbackground", "insertBackground", "Foreground", DEF_CANVAS_INSERT_BG, 0, NULL,

	NULL, NULL, TKO_SET_3DBORDER, &pathMeta, offsetof(TkPathCanvas,textInfo.insertBorder)},

    {"-insertborderwidth", "insertBorderWidth", "BorderWidth", DEF_CANVAS_INSERT_BD_COLOR, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,textInfo.insertBorderWidth)},

    {"-insertofftime", "insertOffTime", "OffTime", DEF_CANVAS_INSERT_OFF_TIME, 0, NULL,

	NULL, NULL, TKO_SET_INT, &pathMeta, offsetof(TkPathCanvas, insertOffTime)},
    {"-insertontime", "insertOnTime", "OnTime", DEF_CANVAS_INSERT_ON_TIME, 0, NULL,

	NULL, NULL, TKO_SET_INT, &pathMeta, offsetof(TkPathCanvas, insertOnTime)},
    {"-insertwidth", "insertWidth", "InsertWidth", DEF_CANVAS_INSERT_ON_TIME, 0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,textInfo.insertWidth)},

    {"-offset", "offset", "Offset", "0,0", 0, NULL,
	NULL, PathMethod_offset, 0, NULL, 0},

    {"-relief", "relief", "Relief", DEF_CANVAS_RELIEF, 0, NULL,

	NULL, NULL, TKO_SET_RELIEF, &pathMeta, offsetof(TkPathCanvas, relief)},
    {"-scrollregion", "scrollRegion", "ScrollRegion", DEF_CANVAS_SCROLL_REGION, 0, NULL,

	NULL, NULL, TKO_SET_SCROLLREGION, &pathMeta, offsetof(TkPathCanvas, scroll)},
    {"-selectbackground", "selectBackground", "Foreground", DEF_CANVAS_SELECT_COLOR, 0, NULL,

	NULL, NULL, TKO_SET_3DBORDER, &pathMeta, offsetof(TkPathCanvas,textInfo.selBorder)},

    {"-selectborderwidth", "selectBorderWidth", "BorderWidth", DEF_CANVAS_SELECT_BD_COLOR,0, NULL,

	NULL, NULL, TKO_SET_PIXELNONEGATIV, &pathMeta, offsetof(TkPathCanvas,textInfo.selBorderWidth)},

    {"-selectforeground", "selectForeground", "Background", DEF_CANVAS_SELECT_FG_COLOR, 0, NULL,

	NULL, NULL, TKO_SET_XCOLOR, &pathMeta, offsetof(TkPathCanvas,textInfo.selFgColorPtr)},

    {"-state", "state", "State", PATH_DEF_STATE, 0, NULL,
	NULL, PathMethod_state, 0, NULL, 0},

    {"-tagstyle", "", "", "expr", 0, NULL,
	NULL, PathMethod_tagstyle, 0, NULL, 0},

    {"-takefocus", "takeFocus", "TakeFocus", DEF_CANVAS_TAKE_FOCUS, 0, NULL,

	NULL, NULL, TKO_SET_STRING, NULL, 0},
    {"-width", "width", "Width", DEF_CANVAS_WIDTH, 0, NULL,

	NULL, NULL, TKO_SET_PIXEL, &pathMeta, offsetof(TkPathCanvas, width)},
    {"-xscrollcommand", "xScrollCommand", "ScrollCommand", DEF_CANVAS_X_SCROLL_CMD, 0, NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &pathMeta, offsetof(TkPathCanvas, xScrollCmd)},
    {"-xscrollincrement", "xScrollIncrement", "ScrollIncrement", DEF_CANVAS_X_SCROLL_INCREMENT, 0, NULL,

	NULL, NULL, TKO_SET_PIXEL, &pathMeta, offsetof(TkPathCanvas, xScrollIncrement)},
    {"-yscrollcommand", "yScrollCommand", "ScrollCommand", DEF_CANVAS_Y_SCROLL_CMD, 0, NULL,

	NULL, NULL, TKO_SET_STRINGNULL, &pathMeta, offsetof(TkPathCanvas, yScrollCmd)},
    {"-yscrollincrement", "yScrollIncrement", "ScrollIncrement", DEF_CANVAS_Y_SCROLL_INCREMENT, 0, NULL,

	NULL, NULL, TKO_SET_PIXEL, &pathMeta, offsetof(TkPathCanvas, yScrollIncrement)},
    {NULL, NULL, NULL, NULL, 0, NULL, NULL, NULL, 0, NULL, 0}
};

/*
 * pathMethods --
 *
 * Methods created in class constructor.
 */

Changes to generic/tko/tkoWidget.c.

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
..
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
...
137
138
139
140
141
142
143
144

145
146
147
148
149



150
151
152
153
154
155
156
...
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
...
235
236
237
238
239
240
241

242
243
244
245

246
247
248
249

250
251
252
253
254
255
256

257
258
259
260
261
262
263
264
265
266
267





268
269
270
271
272

273
274
275
276
277
278
279
280

281


282
283
284
285
286
287
288
289
290
291

292
293
294
295
296
297

298
299
300
301
302
303
304
...
305
306
307
308
309
310
311








312
313
314
315
316
317
318
319
320
321

322
323
324
325
326
327
328
329
330
331
332
333




334
335
336
337
338
339
340
341
342

343
344
345
346
347
348
349
350
351
352
353
354
355
...
806
807
808
809
810
811
812
813
814
815

816
817
818
819
820
821
822
...
836
837
838
839
840
841
842



843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
...
864
865
866
867
868
869
870






871
872
873
874
875
876
877
878
...
906
907
908
909
910
911
912












































913
914
915
916
917
918
919
920
...
928
929
930
931
932
933
934
935
936
937
938







939
940
941
942

943
944
945
946
947

948
949
950



951
952
953
954
955
956
957






958
959

960
961



962

963







964


965



966
967
968
969
970
971







972
973

974
975
976




977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
....
1015
1016
1017
1018
1019
1020
1021

1022
1023

1024
1025
1026
1027
1028
1029
1030
....
1044
1045
1046
1047
1048
1049
1050







1051
1052
1053
1054
1055
1056
1057
....
1121
1122
1123
1124
1125
1126
1127
1128








1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139

1140
1141

1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155



1156
1157





1158
1159





1160
1161
1162
1163
1164
1165
1166
1167
....
1260
1261
1262
1263
1264
1265
1266






1267
1268
1269
1270
1271
1272
1273
....
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
....
1314
1315
1316
1317
1318
1319
1320






1321
1322
1323
1324
1325
1326
1327
1328
....
1358
1359
1360
1361
1362
1363
1364
1365

1366
1367
1368
1369
1370
1371
1372
....
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
....
1828
1829
1830
1831
1832
1833
1834
1835
























































1836
 */
typedef struct WidgetOption {
    Tcl_Obj *option;           /* Name of option */
    Tcl_Obj *dbname;           /* Database name or name of synonym option */
    Tcl_Obj *dbclass;          /* Class name or NULL for synonym options */
    Tcl_Obj *defvalue;         /* Default value from initialization */
    Tcl_Obj *value;            /* Contain last known value of option */
    int flags;
} WidgetOption;

/*
 * Static tcl objects.
 */
Tk_Uid TkoUid_class = NULL;
tkoObj TkoObj =
................................................................................
	Tcl_Obj * const objv[]);
static int WidgetMethod_configure(
	ClientData clientData,
	Tcl_Interp * interp,
	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[]);
static int
WidgetMethod_tko_configure(
	ClientData clientData,
	Tcl_Interp * interp,
	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[])
{              /* virtual method */
	return TCL_OK;
}
static int
WidgetMethod_(
	ClientData clientData,
	Tcl_Interp * interp,
	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[])
{              /* common option set method */
	tkoWidgetOptionDefine *define = (tkoWidgetOptionDefine *)clientData;
	return TkoWidgetOptionSet(interp, context, objv[objc - 1],
		define->type, define->meta, define->offset);
}

/*
 * Functions
 */
static char *WidgetOptionTrace(
    ClientData clientData,
    Tcl_Interp * interp,
................................................................................
static int WidgetOptionSet(
    Tcl_Interp * interp,
    tkoWidget * widget,
    Tcl_Obj * option,
    Tcl_Obj * value);
static void WidgetMetaDestroy(
    tkoWidget * widget);
static void

WidgetMetaDelete(
    ClientData clientData)
{
    Tcl_EventuallyFree(clientData, (Tcl_FreeProc *) WidgetMetaDestroy);
}




/*
 * tkoWidgetMeta --
 */
Tcl_ObjectMetadataType tkoWidgetMeta = {
    TCL_OO_METADATA_VERSION_CURRENT,
    "tkoWidgetMeta",
................................................................................
 */
int
TkoWidgetClassDefine(
    Tcl_Interp * interp,
    Tcl_Class clazz,
    Tcl_Obj * classname,
    const Tcl_MethodType * methods,
    const tkoWidgetOptionDefine * options)
{
    Tcl_Obj *listPtr;
    int i;
    Tcl_Obj *option;
    Tcl_MethodType *methodPtr;
    Tcl_Obj *myObjv[6];
    Tcl_Obj *retPtr;
................................................................................
        Tcl_SetObjResult(interp, Tcl_ObjPrintf("missing class name"));
        return TCL_ERROR;
    }
    /*
     * Add methods
     */
    if(methods) {

        if(methods[0].name == NULL && methods[0].callProc) {
            Tcl_ClassSetConstructor(interp, clazz,
                Tcl_NewMethod(interp, clazz, NULL, 1, &methods[0], NULL));
        }

        if(methods[1].name == NULL && methods[1].callProc) {
            Tcl_ClassSetDestructor(interp, clazz,
                Tcl_NewMethod(interp, clazz, NULL, 1, &methods[1], NULL));
        }

        for(i = 2; methods[i].name != NULL; i++) {
            tmpObj = Tcl_NewStringObj(methods[i].name, -1);
            Tcl_IncrRefCount(tmpObj);
            Tcl_NewMethod(interp, clazz, tmpObj, 1, &methods[i], NULL);
            Tcl_DecrRefCount(tmpObj);
        }
        i++;

        for(; methods[i].name != NULL; i++) {
            tmpObj = Tcl_NewStringObj(methods[i].name, -1);
            Tcl_IncrRefCount(tmpObj);
            Tcl_NewMethod(interp, clazz, tmpObj, 0, &methods[i], NULL);
            Tcl_DecrRefCount(tmpObj);
        }
    }
    /*
     *Add options
     */
    if(options) {





        retPtr =
            Tcl_ObjGetVar2(interp, TkoObj.tko_options, classname,
            TCL_GLOBAL_ONLY);
        if(retPtr == NULL) {
            retPtr = Tcl_NewObj();

        } else {
            if(Tcl_ListObjLength(interp, retPtr, &i) != TCL_OK) {
                Tcl_SetObjResult(interp,
                    Tcl_ObjPrintf("::tko::options(%s) variable is not list",
                        Tcl_GetString(classname)));
                goto error;
            }
        }

        Tcl_IncrRefCount(retPtr);


        for(i = 0;; i++) {
            if(options[i].option == NULL)
                break;  /* end of options */
            if(options[i].dbname == NULL) {
                Tcl_SetObjResult(interp,
                    Tcl_ObjPrintf("wrong option definition: %d", i));
                goto error;
            }
            listPtr = Tcl_NewObj();
            option = Tcl_NewStringObj(options[i].option, -1);

            Tcl_ListObjAppendElement(interp, listPtr, option);
            Tcl_ListObjAppendElement(interp, listPtr,
                Tcl_NewStringObj(options[i].dbname, -1));
            /* synonym option, ignore rest */
            if(options[i].dbclass == NULL) {
                Tcl_ListObjAppendElement(interp, retPtr, listPtr);

                continue;
            }
            /* normal option */
            Tcl_ListObjAppendElement(interp, listPtr,
                Tcl_NewStringObj(options[i].dbclass, -1));
            if(options[i].defvalue == NULL) {
                Tcl_ListObjAppendElement(interp, listPtr, TkoObj.empty);
................................................................................
            } else {
                Tcl_ListObjAppendElement(interp, listPtr,
                    Tcl_NewStringObj(options[i].defvalue, -1));
            }
            Tcl_ListObjAppendElement(interp, listPtr,
                Tcl_NewIntObj(options[i].flags));
            Tcl_ListObjAppendElement(interp, retPtr, listPtr);








            if(options[i].proc != NULL) {
                myObjv[0] = TkoObj.oo_define;
                myObjv[1] = classname;
                myObjv[2] = TkoObj.method;
                myObjv[3] = option;
                myObjv[4] = TkoObj.empty;
                myObjv[5] = Tcl_NewStringObj(options[i].proc, -1);
                Tcl_IncrRefCount(myObjv[5]);
                if(Tcl_EvalObjv(interp, 6, myObjv, TCL_EVAL_GLOBAL) != TCL_OK) {
                    Tcl_DecrRefCount(myObjv[5]);

                    goto error;
                }
                Tcl_DecrRefCount(myObjv[5]);
            } else if(options[i].method != NULL) {
                methodPtr = (Tcl_MethodType *) ckalloc(sizeof(Tcl_MethodType));
                methodPtr->version = TCL_OO_METHOD_VERSION_CURRENT;
                methodPtr->name = options[i].option;
                methodPtr->callProc = options[i].method;
                methodPtr->deleteProc = NULL;
                methodPtr->cloneProc = NULL;
                Tcl_NewMethod(interp, clazz, option, 0, methodPtr, NULL);
            } else if(options[i].type >= 0) {




                methodPtr = (Tcl_MethodType *) ckalloc(sizeof(Tcl_MethodType));
                methodPtr->version = TCL_OO_METHOD_VERSION_CURRENT;
                methodPtr->name = options[i].option;
                methodPtr->callProc = WidgetMethod_;
                methodPtr->deleteProc = NULL;
                methodPtr->cloneProc = NULL;
                Tcl_NewMethod(interp, clazz, option, 0, methodPtr,
                    (ClientData) & options[i]);
            }

        }
        Tcl_IncrRefCount(retPtr);
        Tcl_ObjSetVar2(interp, TkoObj.tko_options, classname, retPtr,
            TCL_GLOBAL_ONLY);
        Tcl_SetObjResult(interp, retPtr);
        Tcl_DecrRefCount(retPtr);
    }
    return TCL_OK;
  error:
    Tcl_DecrRefCount(retPtr);
    return TCL_ERROR;
}

................................................................................
{
    int result, index;
    Tcl_Object object;
    tkoWidget *widget;         /* widget. */
    int skip;
    Tcl_Obj *myObjv[2];
	static const char *const commandNames[] =
	{ "init", "optionadd", "optiondel", "optionvar", NULL };
	enum command {
		COMMAND_INIT, COMMAND_OPTIONADD, COMMAND_OPTIONDEL,

		COMMAND_OPTIONVAR
	};
    Tcl_Obj *dbclass = NULL;
    Tcl_Obj *defvalue = NULL;
    Tcl_Obj *flags = NULL;
	Tcl_HashSearch search;
	Tcl_HashEntry *entryPtr;
................................................................................
    }
    /* configure */
    if(objc - skip == 0) {
	    retPtr = Tcl_NewObj();
        entryPtr = Tcl_FirstHashEntry(&widget->optionsTable, &search);
        while(entryPtr != NULL) {       /* TODO Tcl_DuplicateObj()? */
            optionPtr = (WidgetOption *) Tcl_GetHashValue(entryPtr);



            listPtr = Tcl_NewObj();
            Tcl_ListObjAppendElement(interp, listPtr, optionPtr->option);
            Tcl_ListObjAppendElement(interp, listPtr, optionPtr->dbname);
            if(optionPtr->dbclass != NULL) {
                Tcl_ListObjAppendElement(interp, listPtr, optionPtr->dbclass);
                Tcl_ListObjAppendElement(interp, listPtr, optionPtr->defvalue);
                Tcl_ListObjAppendElement(interp, listPtr, optionPtr->value);
            }
            Tcl_ListObjAppendElement(interp, retPtr, listPtr);
            entryPtr = Tcl_NextHashEntry(&search);
        }
        /* Return sorted list */
        myObjv[0] = TkoObj.lsort;
        myObjv[1] = retPtr;
        return (Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL));
    }
    /* configure "-option ?value? .." */
................................................................................
                Tk_GetUid(Tcl_GetString(objv[skip])));
            if(entryPtr == NULL) {
                Tcl_SetObjResult(interp, Tcl_ObjPrintf("unknown option \"%s\"",
                        Tcl_GetString(objv[skip])));
                return TCL_ERROR;
            }
            optionPtr = (WidgetOption *) Tcl_GetHashValue(entryPtr);






            if(optionPtr->dbclass == NULL) {
                entryPtr =
                    Tcl_FindHashEntry(&widget->optionsTable,
                    Tk_GetUid(Tcl_GetString(optionPtr->dbname)));
                if(entryPtr == NULL) {
                    Tcl_SetObjResult(interp,
                        Tcl_ObjPrintf("unknown option \"%s\"",
                            Tcl_GetString(objv[skip])));
................................................................................
    result =
        Tcl_GetIndexFromObj(interp, objv[skip], commandNames, "option", 0,
        &index);
    if(result != TCL_OK) {
        return result;
    }
    switch (index) {












































    case COMMAND_OPTIONADD:
        dbclass = NULL;
        defvalue = NULL;
        flags = NULL;
        if(objc - skip == 3) {  /* configure add option dbname */
            ;
        } else if(objc - skip == 4) {   /* configure add option dbname dbclass */
            dbclass = objv[skip + 3];
................................................................................
        } else {
            Tcl_WrongNumArgs(interp, skip + 1, objv,
                "option ?synonym?|?dbname dbclass ?default? ?flags??");
            return TCL_ERROR;
        }
        return (WidgetOptionAdd(interp, widget, objv[skip + 1], objv[skip + 2],
                dbclass, defvalue, flags, NULL, 0));
    case COMMAND_INIT:
        // collect all not readonly options and configure
        Tcl_Preserve(widget);
        myObjv[0] = widget->myCmd;







        entryPtr = Tcl_FirstHashEntry(&widget->optionsTable, &search);
        while(entryPtr != NULL) {
            optionPtr = Tcl_GetHashValue(entryPtr);
            if(optionPtr->dbclass == NULL) {    /* synonym option */

                if(optionPtr->value) {
                    Tcl_ObjSetVar2(interp, widget->optionsArray,
                        optionPtr->dbname, optionPtr->value, TCL_GLOBAL_ONLY);
                    Tcl_DecrRefCount(optionPtr->value);
                    optionPtr->value = NULL;

                }
            } else {    /* normal option */
                if(optionPtr->flags == 0) {



                    myObjv[1] = optionPtr->option;
                    if(Tcl_EvalObjv(interp, 2, myObjv,
                            TCL_EVAL_GLOBAL) != TCL_OK) {
                        retPtr = Tcl_GetObjResult(interp);
                        Tcl_IncrRefCount(retPtr);
                        Tcl_Release(widget);
                        Tcl_DeleteCommandFromToken(interp, widget->widgetCmd);






                        Tcl_SetObjResult(interp, retPtr);
                        Tcl_DecrRefCount(retPtr);

                        return TCL_ERROR;
                    }



                }

            }







            entryPtr = Tcl_NextHashEntry(&search);


        }



        myObjv[1] = TkoObj._tko_configure;
        if(Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL) != TCL_OK) {
            retPtr = Tcl_GetObjResult(interp);
            Tcl_IncrRefCount(retPtr);
            Tcl_Release(widget);
            Tcl_DeleteCommandFromToken(interp, widget->widgetCmd);







            Tcl_SetObjResult(interp, retPtr);
            Tcl_DecrRefCount(retPtr);

            return TCL_ERROR;
        }
        Tcl_Release(widget);




        return TCL_OK;
    case COMMAND_OPTIONDEL:
        if(objc - skip == 2) {
            return (WidgetOptionDel(interp, widget, objv[skip + 1]));
        }
        Tcl_WrongNumArgs(interp, skip + 1, objv, "option");
        return TCL_ERROR;
    case COMMAND_OPTIONVAR:
        if(objc - skip == 1) {
            Tcl_SetObjResult(interp, widget->optionsArray);
            return TCL_OK;
        }
        Tcl_WrongNumArgs(interp, skip + 1, objv, "");
        return TCL_ERROR;
    }
................................................................................
    WidgetOption *optionPtr;
    Tk_Uid valueUid;
    int isNew;
    Tk_Uid optionUid;
    Tk_Uid dbnameUid;
    Tk_Uid dbclassUid;
    int intFlags;

    Tcl_Obj *myObjv[2];
    const char *ch;


    if(option == NULL || (ch = Tcl_GetString(option))[0] != '-') {
        Tcl_SetObjResult(interp, Tcl_NewStringObj("missing or wrong option",
                -1));
        return TCL_ERROR;
    }
    if(dbname == NULL) {
................................................................................
    intFlags = 0;
    if(flags != NULL && Tcl_GetIntFromObj(interp, flags, &intFlags) != TCL_OK) {
        Tcl_SetObjResult(interp,
            Tcl_ObjPrintf("wrong flags \"%s\" for option \"%s\"",
                Tcl_GetString(flags), ch));
        return TCL_ERROR;
    }







    /* return if no widget given, all class checks are done */
    if(widget == NULL) {
        return TCL_OK;
    }
    optionUid = Tk_GetUid(ch);
    dbnameUid = Tk_GetUid(Tcl_GetString(dbname));
    entryPtr = Tcl_CreateHashEntry(&widget->optionsTable, optionUid, &isNew);
................................................................................
        /*
         * No given value defaults to empty string.
         */
        if(optionPtr->value == NULL) {
            optionPtr->value = TkoObj.empty;
        }
        Tcl_IncrRefCount(optionPtr->value);
        /* 








         * Set default value of option in array variable.
         */
        if(Tcl_ObjSetVar2(interp, widget->optionsArray, option,
                optionPtr->value, TCL_GLOBAL_ONLY|TCL_LEAVE_ERR_MSG) == NULL) {
            goto error;
        }
        if(intFlags & TKO_WIDGETOPTIONREADONLY) {
            /*
             * Readonly options can only be set on creation time.
             * All other attempts will be refused in the trace function.
             * Therefore we do not have to remove the -option method.

             */
            if(initmode) {

                myObjv[0] = widget->myCmd;
                myObjv[1] = option;
                if(Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL) != TCL_OK) {
                    goto error;
                }
            }
            /*
             * We set the value again because the -option method may have changed it.
             */
            if(optionPtr->value) {
                Tcl_DecrRefCount(optionPtr->value);
            }
            optionPtr->value = Tcl_ObjGetVar2(interp, widget->optionsArray, option, TCL_GLOBAL_ONLY);   /*TODO flags? */
            Tcl_IncrRefCount(optionPtr->value);



        }
    }





    return TCL_OK;
  error:





    WidgetOptionDelEntry(entryPtr);
    return TCL_ERROR;
}

/*
 * WidgetOptionConfigure --
 *
 * Results:
................................................................................
        Tk_GetUid(Tcl_GetString(option)));
    if(entryPtr == NULL) {
        Tcl_SetObjResult(interp, Tcl_ObjPrintf("unknown option \"%s\"",
                Tcl_GetString(option)));
        return TCL_ERROR;
    }
    optionPtr = Tcl_GetHashValue(entryPtr);






    /* synonym option */
    if(optionPtr->dbclass == NULL) {
        entryPtr =
            Tcl_FindHashEntry(&widget->optionsTable,
            Tk_GetUid(Tcl_GetString(optionPtr->dbname)));
        if(entryPtr == NULL) {
            Tcl_SetObjResult(interp,
................................................................................
static int
WidgetOptionSet(
    Tcl_Interp * interp,
    tkoWidget * widget,
    Tcl_Obj * option,
    Tcl_Obj * value)
{
Tcl_HashEntry *entryPtr;
WidgetOption *optionPtr;

    if(option == NULL || value == NULL) {
        Tcl_SetObjResult(interp, Tcl_ObjPrintf("missing option and/or value"));
        return TCL_ERROR;
    }
    entryPtr =
        Tcl_FindHashEntry(&widget->optionsTable,
................................................................................
        Tk_GetUid(Tcl_GetString(option)));
    if(entryPtr == NULL) {
        Tcl_SetObjResult(interp,
            Tcl_ObjPrintf("unknown option \"%s\"", Tcl_GetString(option)));
        return TCL_ERROR;
    }
    optionPtr = Tcl_GetHashValue(entryPtr);






    /* synonym option */
    if(optionPtr->dbclass == NULL) {
        entryPtr =
            Tcl_FindHashEntry(&widget->optionsTable,
            Tk_GetUid(Tcl_GetString(optionPtr->dbname)));
        if(entryPtr == NULL) {
            Tcl_SetObjResult(interp,
                Tcl_ObjPrintf("unknown synonym option \"%s\"",
................................................................................
 */
Tcl_Obj *
TkoWidgetOptionGet(
    Tcl_Interp * interp,
    Tcl_Object object,
    Tcl_Obj * option)
{
tkoWidget *widget = (tkoWidget *) Tcl_ObjectGetMetadata(object, &tkoWidgetMeta);

    if(widget == NULL) {
        return NULL;
    }
    return Tcl_ObjGetVar2(interp, widget->optionsArray, option,
        TCL_GLOBAL_ONLY);
}

................................................................................
    entryPtr = Tcl_FindHashEntry(&widget->optionsTable, Tk_GetUid(name2));
    if(entryPtr == NULL) {
        myRet = Tcl_ObjPrintf("option \"%s\" not found", name2);
        Tcl_IncrRefCount(myRet);
        return (char *)myRet;
    }
    optionPtr = (WidgetOption *) Tcl_GetHashValue(entryPtr);
    if(optionPtr->flags & TKO_WIDGETOPTIONREADONLY) {
        myRet = Tcl_ObjPrintf("option \"%s\" is readonly", name2);
        Tcl_IncrRefCount(myRet);
        return (char *)myRet;
    }
    myObjv[0] = widget->myCmd;
    myObjv[1] = optionPtr->option;
    if(Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL) != TCL_OK) {
................................................................................
    if(optionPtr->defvalue)
        Tcl_DecrRefCount(optionPtr->defvalue);
    if(optionPtr->value)
        Tcl_DecrRefCount(optionPtr->value);
    ckfree(optionPtr);
    Tcl_DeleteHashEntry(entry);
}

























































/* vim: set ts=4 sw=4 sts=4 ff=unix et : */






|







 







<
|




|
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







|
>
|
|
<
|
<
>
>
>







 







|







 







>




>




>







>











>
>
>
>
>





>





|

<
>
|
>
>










>






>







 







>
>
>
>
>
>
>
>










>












>
>
>
>









>

<



<







 







|


>







 







>
>
>
|








<







 







>
>
>
>
>
>
|







 







>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
|







 







|
|
|
<
>
>
>
>
>
>
>
|
|
|
<
>
|
<
<
<
<
>
|
<
<
>
>
>
|
|
<
<
<
<
|
>
>
>
>
>
>
|
<
>
|
|
>
>
>
|
>
|
>
>
>
>
>
>
>
|
>
>
|
>
>
>
|
|
<
<
<
<
>
>
>
>
>
>
>
|
<
>
|
|
<
>
>
>
>
|
<
<
<
|
<
<
|







 







>


>







 







>
>
>
>
>
>
>







 







|
>
>
>
>
>
>
>
>
|
|
|
|
|
|
<
|
<
<
<
>
|
<
>
|
|
|
|
|
<
|
|
|
|
|
|
|
|
>
>
>
|
|
>
>
>
>
>

|
>
>
>
>
>
|







 







>
>
>
>
>
>







 







|
|







 







>
>
>
>
>
>
|







 







|
>







 







|







 








>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>

34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
..
70
71
72
73
74
75
76

77
78
79
80
81
82















83
84
85
86
87
88
89
...
121
122
123
124
125
126
127
128
129
130
131

132

133
134
135
136
137
138
139
140
141
142
...
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
...
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275

276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
...
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357

358
359
360

361
362
363
364
365
366
367
...
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
...
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867

868
869
870
871
872
873
874
...
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
...
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
...
993
994
995
996
997
998
999
1000
1001
1002

1003
1004
1005
1006
1007
1008
1009
1010
1011
1012

1013
1014




1015
1016


1017
1018
1019
1020
1021




1022
1023
1024
1025
1026
1027
1028
1029

1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054




1055
1056
1057
1058
1059
1060
1061
1062

1063
1064
1065

1066
1067
1068
1069
1070



1071


1072
1073
1074
1075
1076
1077
1078
1079
....
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
....
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
....
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239

1240



1241
1242

1243
1244
1245
1246
1247
1248

1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
....
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
....
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
....
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
....
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
....
1903
1904
1905
1906
1907
1908
1909
1910
1911
1912
1913
1914
1915
1916
1917
....
1955
1956
1957
1958
1959
1960
1961
1962
1963
1964
1965
1966
1967
1968
1969
1970
1971
1972
1973
1974
1975
1976
1977
1978
1979
1980
1981
1982
1983
1984
1985
1986
1987
1988
1989
1990
1991
1992
1993
1994
1995
1996
1997
1998
1999
2000
2001
2002
2003
2004
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
 */
typedef struct WidgetOption {
    Tcl_Obj *option;           /* Name of option */
    Tcl_Obj *dbname;           /* Database name or name of synonym option */
    Tcl_Obj *dbclass;          /* Class name or NULL for synonym options */
    Tcl_Obj *defvalue;         /* Default value from initialization */
    Tcl_Obj *value;            /* Contain last known value of option */
    int flags;				   /* see flags in struct tkoWidgetOptionDefine */
} WidgetOption;

/*
 * Static tcl objects.
 */
Tk_Uid TkoUid_class = NULL;
tkoObj TkoObj =
................................................................................
	Tcl_Obj * const objv[]);
static int WidgetMethod_configure(
	ClientData clientData,
	Tcl_Interp * interp,
	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[]);

static int WidgetMethod_tko_configure(
	ClientData clientData,
	Tcl_Interp * interp,
	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[]);
















/*
 * Functions
 */
static char *WidgetOptionTrace(
    ClientData clientData,
    Tcl_Interp * interp,
................................................................................
static int WidgetOptionSet(
    Tcl_Interp * interp,
    tkoWidget * widget,
    Tcl_Obj * option,
    Tcl_Obj * value);
static void WidgetMetaDestroy(
    tkoWidget * widget);
static void WidgetMetaDelete(
	ClientData clientData);
static int WidgetMethod_(
	ClientData clientData,

	Tcl_Interp * interp,

	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[]);

/*
 * tkoWidgetMeta --
 */
Tcl_ObjectMetadataType tkoWidgetMeta = {
    TCL_OO_METADATA_VERSION_CURRENT,
    "tkoWidgetMeta",
................................................................................
 */
int
TkoWidgetClassDefine(
    Tcl_Interp * interp,
    Tcl_Class clazz,
    Tcl_Obj * classname,
    const Tcl_MethodType * methods,
    tkoWidgetOptionDefine * options)
{
    Tcl_Obj *listPtr;
    int i;
    Tcl_Obj *option;
    Tcl_MethodType *methodPtr;
    Tcl_Obj *myObjv[6];
    Tcl_Obj *retPtr;
................................................................................
        Tcl_SetObjResult(interp, Tcl_ObjPrintf("missing class name"));
        return TCL_ERROR;
    }
    /*
     * Add methods
     */
    if(methods) {
		/* constructor */
        if(methods[0].name == NULL && methods[0].callProc) {
            Tcl_ClassSetConstructor(interp, clazz,
                Tcl_NewMethod(interp, clazz, NULL, 1, &methods[0], NULL));
        }
		/* destructor */
        if(methods[1].name == NULL && methods[1].callProc) {
            Tcl_ClassSetDestructor(interp, clazz,
                Tcl_NewMethod(interp, clazz, NULL, 1, &methods[1], NULL));
        }
		/* public */
        for(i = 2; methods[i].name != NULL; i++) {
            tmpObj = Tcl_NewStringObj(methods[i].name, -1);
            Tcl_IncrRefCount(tmpObj);
            Tcl_NewMethod(interp, clazz, tmpObj, 1, &methods[i], NULL);
            Tcl_DecrRefCount(tmpObj);
        }
        i++;
		/* private */
        for(; methods[i].name != NULL; i++) {
            tmpObj = Tcl_NewStringObj(methods[i].name, -1);
            Tcl_IncrRefCount(tmpObj);
            Tcl_NewMethod(interp, clazz, tmpObj, 0, &methods[i], NULL);
            Tcl_DecrRefCount(tmpObj);
        }
    }
    /*
     *Add options
     */
    if(options) {
		/*
		 * Option definitions will be saved in the tko::options array variable.
		 * All options of a class are saved as a list under tko::option(classname)
		 * Here we ensure this variable exists and is a proper list.
		 */
        retPtr =
            Tcl_ObjGetVar2(interp, TkoObj.tko_options, classname,
            TCL_GLOBAL_ONLY);
        if(retPtr == NULL) {
            retPtr = Tcl_NewObj();
			Tcl_IncrRefCount(retPtr);
        } else {
            if(Tcl_ListObjLength(interp, retPtr, &i) != TCL_OK) {
                Tcl_SetObjResult(interp,
                    Tcl_ObjPrintf("::tko::options(%s) variable is not list",
                        Tcl_GetString(classname)));
                return TCL_ERROR;
            }

			retPtr = Tcl_DuplicateObj(retPtr);
			Tcl_IncrRefCount(retPtr);
        }
		/* Loop over all option definitions */
        for(i = 0;; i++) {
            if(options[i].option == NULL)
                break;  /* end of options */
            if(options[i].dbname == NULL) {
                Tcl_SetObjResult(interp,
                    Tcl_ObjPrintf("wrong option definition: %d", i));
                goto error;
            }
            listPtr = Tcl_NewObj();
            option = Tcl_NewStringObj(options[i].option, -1);
            Tcl_IncrRefCount(option);
            Tcl_ListObjAppendElement(interp, listPtr, option);
            Tcl_ListObjAppendElement(interp, listPtr,
                Tcl_NewStringObj(options[i].dbname, -1));
            /* synonym option, ignore rest */
            if(options[i].dbclass == NULL) {
                Tcl_ListObjAppendElement(interp, retPtr, listPtr);
				Tcl_DecrRefCount(option);
                continue;
            }
            /* normal option */
            Tcl_ListObjAppendElement(interp, listPtr,
                Tcl_NewStringObj(options[i].dbclass, -1));
            if(options[i].defvalue == NULL) {
                Tcl_ListObjAppendElement(interp, listPtr, TkoObj.empty);
................................................................................
            } else {
                Tcl_ListObjAppendElement(interp, listPtr,
                    Tcl_NewStringObj(options[i].defvalue, -1));
            }
            Tcl_ListObjAppendElement(interp, listPtr,
                Tcl_NewIntObj(options[i].flags));
            Tcl_ListObjAppendElement(interp, retPtr, listPtr);
			/*
			 * Now we create the necessary -option method if provided.
			 * If given we use the code provided in the proc body.
			 * Or we create the -option method with the given method.
			 * Or we use the internal implementation of a given type.
			 * If none of the above are provided it is up to the caller
			 * to create the necessary -option method.
			 */
            if(options[i].proc != NULL) {
                myObjv[0] = TkoObj.oo_define;
                myObjv[1] = classname;
                myObjv[2] = TkoObj.method;
                myObjv[3] = option;
                myObjv[4] = TkoObj.empty;
                myObjv[5] = Tcl_NewStringObj(options[i].proc, -1);
                Tcl_IncrRefCount(myObjv[5]);
                if(Tcl_EvalObjv(interp, 6, myObjv, TCL_EVAL_GLOBAL) != TCL_OK) {
                    Tcl_DecrRefCount(myObjv[5]);
					Tcl_DecrRefCount(option);
                    goto error;
                }
                Tcl_DecrRefCount(myObjv[5]);
            } else if(options[i].method != NULL) {
                methodPtr = (Tcl_MethodType *) ckalloc(sizeof(Tcl_MethodType));
                methodPtr->version = TCL_OO_METHOD_VERSION_CURRENT;
                methodPtr->name = options[i].option;
                methodPtr->callProc = options[i].method;
                methodPtr->deleteProc = NULL;
                methodPtr->cloneProc = NULL;
                Tcl_NewMethod(interp, clazz, option, 0, methodPtr, NULL);
            } else if(options[i].type >= 0) {
				if (options[i].optionPtr == NULL) {
					options[i].optionPtr = option;
					Tcl_IncrRefCount(option);
				}
                methodPtr = (Tcl_MethodType *) ckalloc(sizeof(Tcl_MethodType));
                methodPtr->version = TCL_OO_METHOD_VERSION_CURRENT;
                methodPtr->name = options[i].option;
                methodPtr->callProc = WidgetMethod_;
                methodPtr->deleteProc = NULL;
                methodPtr->cloneProc = NULL;
                Tcl_NewMethod(interp, clazz, option, 0, methodPtr,
                    (ClientData) & options[i]);
            }
			Tcl_DecrRefCount(option);
        }

        Tcl_ObjSetVar2(interp, TkoObj.tko_options, classname, retPtr,
            TCL_GLOBAL_ONLY);
        Tcl_SetObjResult(interp, retPtr);

    }
    return TCL_OK;
  error:
    Tcl_DecrRefCount(retPtr);
    return TCL_ERROR;
}

................................................................................
{
    int result, index;
    Tcl_Object object;
    tkoWidget *widget;         /* widget. */
    int skip;
    Tcl_Obj *myObjv[2];
	static const char *const commandNames[] =
	{ "init", "optionadd", "optiondel", "optionhide", "optionshow", "optionvar", NULL };
	enum command {
		COMMAND_INIT, COMMAND_OPTIONADD, COMMAND_OPTIONDEL,
		COMMAND_OPTIONHIDE, COMMAND_OPTIONSHOW,
		COMMAND_OPTIONVAR
	};
    Tcl_Obj *dbclass = NULL;
    Tcl_Obj *defvalue = NULL;
    Tcl_Obj *flags = NULL;
	Tcl_HashSearch search;
	Tcl_HashEntry *entryPtr;
................................................................................
    }
    /* configure */
    if(objc - skip == 0) {
	    retPtr = Tcl_NewObj();
        entryPtr = Tcl_FirstHashEntry(&widget->optionsTable, &search);
        while(entryPtr != NULL) {       /* TODO Tcl_DuplicateObj()? */
            optionPtr = (WidgetOption *) Tcl_GetHashValue(entryPtr);
            entryPtr = Tcl_NextHashEntry(&search);
			/* hidden option, not visible in configure method */
			if (optionPtr->flags&TKO_OPTION_HIDE) continue;
			listPtr = Tcl_NewObj();
            Tcl_ListObjAppendElement(interp, listPtr, optionPtr->option);
            Tcl_ListObjAppendElement(interp, listPtr, optionPtr->dbname);
            if(optionPtr->dbclass != NULL) {
                Tcl_ListObjAppendElement(interp, listPtr, optionPtr->dbclass);
                Tcl_ListObjAppendElement(interp, listPtr, optionPtr->defvalue);
                Tcl_ListObjAppendElement(interp, listPtr, optionPtr->value);
            }
            Tcl_ListObjAppendElement(interp, retPtr, listPtr);

        }
        /* Return sorted list */
        myObjv[0] = TkoObj.lsort;
        myObjv[1] = retPtr;
        return (Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL));
    }
    /* configure "-option ?value? .." */
................................................................................
                Tk_GetUid(Tcl_GetString(objv[skip])));
            if(entryPtr == NULL) {
                Tcl_SetObjResult(interp, Tcl_ObjPrintf("unknown option \"%s\"",
                        Tcl_GetString(objv[skip])));
                return TCL_ERROR;
            }
            optionPtr = (WidgetOption *) Tcl_GetHashValue(entryPtr);
			/* hidden option, not visible in configure method */
			if (optionPtr->flags&TKO_OPTION_HIDE) {
				Tcl_SetObjResult(interp, Tcl_ObjPrintf("hidden option \"%s\"",
					Tcl_GetString(objv[skip])));
				return TCL_ERROR;
			}
			if(optionPtr->dbclass == NULL) {
                entryPtr =
                    Tcl_FindHashEntry(&widget->optionsTable,
                    Tk_GetUid(Tcl_GetString(optionPtr->dbname)));
                if(entryPtr == NULL) {
                    Tcl_SetObjResult(interp,
                        Tcl_ObjPrintf("unknown option \"%s\"",
                            Tcl_GetString(objv[skip])));
................................................................................
    result =
        Tcl_GetIndexFromObj(interp, objv[skip], commandNames, "option", 0,
        &index);
    if(result != TCL_OK) {
        return result;
    }
    switch (index) {
	case COMMAND_INIT:
		// collect all not readonly options and configure
		Tcl_Preserve(widget);
		myObjv[0] = widget->myCmd;
		entryPtr = Tcl_FirstHashEntry(&widget->optionsTable, &search);
		while (entryPtr != NULL) {
			optionPtr = Tcl_GetHashValue(entryPtr);
			entryPtr = Tcl_NextHashEntry(&search);
			if (optionPtr->dbclass == NULL) {    /* synonym option */
				if (optionPtr->value) {
					Tcl_ObjSetVar2(interp, widget->optionsArray,
						optionPtr->dbname, optionPtr->value, TCL_GLOBAL_ONLY);
					Tcl_DecrRefCount(optionPtr->value);
					optionPtr->value = NULL;
				}
			}
			else {    /* normal option */
				if ((optionPtr->flags & TKO_OPTION_READONLY) == 0) {
					myObjv[1] = optionPtr->option;
					if (Tcl_EvalObjv(interp, 2, myObjv,
						TCL_EVAL_GLOBAL) != TCL_OK) {
						retPtr = Tcl_GetObjResult(interp);
						Tcl_IncrRefCount(retPtr);
						Tcl_Release(widget);
						Tcl_DeleteCommandFromToken(interp, widget->widgetCmd);
						Tcl_SetObjResult(interp, retPtr);
						Tcl_DecrRefCount(retPtr);
						return TCL_ERROR;
					}
				}
			}
		}
		myObjv[1] = TkoObj._tko_configure;
		if (Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL) != TCL_OK) {
			retPtr = Tcl_GetObjResult(interp);
			Tcl_IncrRefCount(retPtr);
			Tcl_Release(widget);
			Tcl_DeleteCommandFromToken(interp, widget->widgetCmd);
			Tcl_SetObjResult(interp, retPtr);
			Tcl_DecrRefCount(retPtr);
			return TCL_ERROR;
		}
		Tcl_Release(widget);
		return TCL_OK;
	case COMMAND_OPTIONADD:
        dbclass = NULL;
        defvalue = NULL;
        flags = NULL;
        if(objc - skip == 3) {  /* configure add option dbname */
            ;
        } else if(objc - skip == 4) {   /* configure add option dbname dbclass */
            dbclass = objv[skip + 3];
................................................................................
        } else {
            Tcl_WrongNumArgs(interp, skip + 1, objv,
                "option ?synonym?|?dbname dbclass ?default? ?flags??");
            return TCL_ERROR;
        }
        return (WidgetOptionAdd(interp, widget, objv[skip + 1], objv[skip + 2],
                dbclass, defvalue, flags, NULL, 0));
    case COMMAND_OPTIONDEL:
        if(objc - skip == 2) {
            return (WidgetOptionDel(interp, widget, objv[skip + 1]));

        }
        Tcl_WrongNumArgs(interp, skip + 1, objv, "option");
        return TCL_ERROR;
	case COMMAND_OPTIONHIDE:
		/* no further args, return hidden options */
		if (objc - skip == 1) {
			retPtr = Tcl_NewObj();
			entryPtr = Tcl_FirstHashEntry(&widget->optionsTable, &search);
			while (entryPtr != NULL) {
				optionPtr = Tcl_GetHashValue(entryPtr);

				entryPtr = Tcl_NextHashEntry(&search);
				if (optionPtr->flags&TKO_OPTION_HIDE) {




					Tcl_ListObjAppendElement(interp, retPtr, optionPtr->option);
				}


			}
			/* Return sorted list */
			myObjv[0] = TkoObj.lsort;
			myObjv[1] = retPtr;
			return (Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL));




		/* hide given options */
		} else {
			skip++;
			while (skip < objc) {
				entryPtr = Tcl_FindHashEntry(&widget->optionsTable,
						Tk_GetUid(Tcl_GetString(objv[skip])));
				if (entryPtr == NULL) {
					Tcl_SetObjResult(interp,

						Tcl_ObjPrintf("unknown option \"%s\"", Tcl_GetString(objv[skip])));
					return TCL_ERROR;
				}
				optionPtr = Tcl_GetHashValue(entryPtr);
				optionPtr->flags |= TKO_OPTION_HIDE;
				skip++;
			}
			return TCL_OK;
		}
	case COMMAND_OPTIONSHOW:
		/* no further args, return configure'able options */
		if (objc - skip == 1) {
			retPtr = Tcl_NewObj();
			entryPtr = Tcl_FirstHashEntry(&widget->optionsTable, &search);
			while (entryPtr != NULL) {
				optionPtr = Tcl_GetHashValue(entryPtr);
				entryPtr = Tcl_NextHashEntry(&search);
				if ((optionPtr->flags & TKO_OPTION_HIDE) == 0) {
					Tcl_ListObjAppendElement(interp, retPtr, optionPtr->option);
				}
			}
			/* Return sorted list */
			myObjv[0] = TkoObj.lsort;
			myObjv[1] = retPtr;
			return (Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL));




		/* make given options configure'able */
		} else {
			skip++;
			while (skip < objc) {
				entryPtr = Tcl_FindHashEntry(&widget->optionsTable,
					Tk_GetUid(Tcl_GetString(objv[skip])));
				if (entryPtr == NULL) {
					Tcl_SetObjResult(interp,

						Tcl_ObjPrintf("unknown option \"%s\"", Tcl_GetString(objv[skip])));
					return TCL_ERROR;
				}

				optionPtr = Tcl_GetHashValue(entryPtr);
				optionPtr->flags &= ~TKO_OPTION_HIDE;
				skip++;
			}
			return TCL_OK;



		}


	case COMMAND_OPTIONVAR:
        if(objc - skip == 1) {
            Tcl_SetObjResult(interp, widget->optionsArray);
            return TCL_OK;
        }
        Tcl_WrongNumArgs(interp, skip + 1, objv, "");
        return TCL_ERROR;
    }
................................................................................
    WidgetOption *optionPtr;
    Tk_Uid valueUid;
    int isNew;
    Tk_Uid optionUid;
    Tk_Uid dbnameUid;
    Tk_Uid dbclassUid;
    int intFlags;
	int readonly;
    Tcl_Obj *myObjv[2];
    const char *ch;
	int traceadd = 0; /* if not 0 then readd trace on array variable */

    if(option == NULL || (ch = Tcl_GetString(option))[0] != '-') {
        Tcl_SetObjResult(interp, Tcl_NewStringObj("missing or wrong option",
                -1));
        return TCL_ERROR;
    }
    if(dbname == NULL) {
................................................................................
    intFlags = 0;
    if(flags != NULL && Tcl_GetIntFromObj(interp, flags, &intFlags) != TCL_OK) {
        Tcl_SetObjResult(interp,
            Tcl_ObjPrintf("wrong flags \"%s\" for option \"%s\"",
                Tcl_GetString(flags), ch));
        return TCL_ERROR;
    }
	if (intFlags & TKO_OPTION_READONLY) {
		intFlags &= ~TKO_OPTION_READONLY;
		readonly = TKO_OPTION_READONLY;
	}
	else {
		readonly = 0;
	}
    /* return if no widget given, all class checks are done */
    if(widget == NULL) {
        return TCL_OK;
    }
    optionUid = Tk_GetUid(ch);
    dbnameUid = Tk_GetUid(Tcl_GetString(dbname));
    entryPtr = Tcl_CreateHashEntry(&widget->optionsTable, optionUid, &isNew);
................................................................................
        /*
         * No given value defaults to empty string.
         */
        if(optionPtr->value == NULL) {
            optionPtr->value = TkoObj.empty;
        }
        Tcl_IncrRefCount(optionPtr->value);
		/*
		 * Outside initmode the trace on the array variable needs to be disabled.
		 */
		if (initmode == 0) {
			Tcl_UntraceVar2(interp, Tcl_GetString(widget->optionsArray), NULL,
				TCL_TRACE_WRITES | TCL_TRACE_RESULT_OBJECT, WidgetOptionTrace, widget);
			traceadd = 1;
		}
		/*
		 *Set option array variable
		 */
		if (Tcl_ObjSetVar2(interp, widget->optionsArray, option,
			optionPtr->value, TCL_GLOBAL_ONLY | TCL_LEAVE_ERR_MSG) == NULL) {
			goto error;
		}

		/*



		 * Do initialization with -option method.
		 */

		if (readonly || initmode == 0) {
			myObjv[0] = widget->myCmd;
			myObjv[1] = option;
			if (Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL) != TCL_OK) {
				goto error;
			}

			/*
			* We set the value again because the -option method may have changed it.
			*/
			if (optionPtr->value) {
				Tcl_DecrRefCount(optionPtr->value);
			}
			optionPtr->value = Tcl_ObjGetVar2(interp, widget->optionsArray, option, TCL_GLOBAL_ONLY);   /*TODO flags? */
			Tcl_IncrRefCount(optionPtr->value);
			/* Now we are ready to set the readonly bit */
			if (readonly) {
				optionPtr->flags |= TKO_OPTION_READONLY;
			}
		}
    }
	if (traceadd) {
		Tcl_TraceVar2(interp, Tcl_GetString(widget->optionsArray), NULL,
			TCL_TRACE_WRITES | TCL_TRACE_RESULT_OBJECT, WidgetOptionTrace, widget);
	}
    return TCL_OK;
error:
	if (traceadd) {
		/* There should be no error and thus we don't need to save the result. */
		Tcl_TraceVar2(interp, Tcl_GetString(widget->optionsArray), NULL,
			TCL_TRACE_WRITES | TCL_TRACE_RESULT_OBJECT, WidgetOptionTrace, widget);
	}
	WidgetOptionDelEntry(entryPtr);
    return TCL_ERROR;
}

/*
 * WidgetOptionConfigure --
 *
 * Results:
................................................................................
        Tk_GetUid(Tcl_GetString(option)));
    if(entryPtr == NULL) {
        Tcl_SetObjResult(interp, Tcl_ObjPrintf("unknown option \"%s\"",
                Tcl_GetString(option)));
        return TCL_ERROR;
    }
    optionPtr = Tcl_GetHashValue(entryPtr);
	/* hidden option, not visible in cget method */
	if (optionPtr->flags&TKO_OPTION_HIDE) {
		Tcl_SetObjResult(interp, Tcl_ObjPrintf("hidden option \"%s\"",
			Tcl_GetString(option)));
        return TCL_ERROR;
	}
    /* synonym option */
    if(optionPtr->dbclass == NULL) {
        entryPtr =
            Tcl_FindHashEntry(&widget->optionsTable,
            Tk_GetUid(Tcl_GetString(optionPtr->dbname)));
        if(entryPtr == NULL) {
            Tcl_SetObjResult(interp,
................................................................................
static int
WidgetOptionSet(
    Tcl_Interp * interp,
    tkoWidget * widget,
    Tcl_Obj * option,
    Tcl_Obj * value)
{
    Tcl_HashEntry *entryPtr;
    WidgetOption *optionPtr;

    if(option == NULL || value == NULL) {
        Tcl_SetObjResult(interp, Tcl_ObjPrintf("missing option and/or value"));
        return TCL_ERROR;
    }
    entryPtr =
        Tcl_FindHashEntry(&widget->optionsTable,
................................................................................
        Tk_GetUid(Tcl_GetString(option)));
    if(entryPtr == NULL) {
        Tcl_SetObjResult(interp,
            Tcl_ObjPrintf("unknown option \"%s\"", Tcl_GetString(option)));
        return TCL_ERROR;
    }
    optionPtr = Tcl_GetHashValue(entryPtr);
	/* hidden option, not visible in cget method */
	if (optionPtr->flags&TKO_OPTION_HIDE) {
		Tcl_SetObjResult(interp, Tcl_ObjPrintf("hidden option \"%s\"",
			Tcl_GetString(option)));
		return TCL_ERROR;
	}
	/* synonym option */
    if(optionPtr->dbclass == NULL) {
        entryPtr =
            Tcl_FindHashEntry(&widget->optionsTable,
            Tk_GetUid(Tcl_GetString(optionPtr->dbname)));
        if(entryPtr == NULL) {
            Tcl_SetObjResult(interp,
                Tcl_ObjPrintf("unknown synonym option \"%s\"",
................................................................................
 */
Tcl_Obj *
TkoWidgetOptionGet(
    Tcl_Interp * interp,
    Tcl_Object object,
    Tcl_Obj * option)
{
    tkoWidget *widget = (tkoWidget *) Tcl_ObjectGetMetadata(object, &tkoWidgetMeta);

    if(widget == NULL) {
        return NULL;
    }
    return Tcl_ObjGetVar2(interp, widget->optionsArray, option,
        TCL_GLOBAL_ONLY);
}

................................................................................
    entryPtr = Tcl_FindHashEntry(&widget->optionsTable, Tk_GetUid(name2));
    if(entryPtr == NULL) {
        myRet = Tcl_ObjPrintf("option \"%s\" not found", name2);
        Tcl_IncrRefCount(myRet);
        return (char *)myRet;
    }
    optionPtr = (WidgetOption *) Tcl_GetHashValue(entryPtr);
    if(optionPtr->flags & TKO_OPTION_READONLY) {
        myRet = Tcl_ObjPrintf("option \"%s\" is readonly", name2);
        Tcl_IncrRefCount(myRet);
        return (char *)myRet;
    }
    myObjv[0] = widget->myCmd;
    myObjv[1] = optionPtr->option;
    if(Tcl_EvalObjv(interp, 2, myObjv, TCL_EVAL_GLOBAL) != TCL_OK) {
................................................................................
    if(optionPtr->defvalue)
        Tcl_DecrRefCount(optionPtr->defvalue);
    if(optionPtr->value)
        Tcl_DecrRefCount(optionPtr->value);
    ckfree(optionPtr);
    Tcl_DeleteHashEntry(entry);
}

/*
 * WidgetMethod_tko_configure --
 *	Virtual method called after configuring options.
 *	Should be implemented in derived classes.
 *
 * Results:
 *
 * Side effects:
 */
static int
WidgetMethod_tko_configure(
	ClientData clientData,
	Tcl_Interp * interp,
	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[])
{              /* virtual method */
	return TCL_OK;
}

/*
 * WidgetMetaDelete --
 *	Delete widget meta data when all preserve calls done.
 *
 * Results:
 *
 * Side effects:
 */
static void
WidgetMetaDelete(
	ClientData clientData)
{
	Tcl_EventuallyFree(clientData, (Tcl_FreeProc *)WidgetMetaDestroy);
}

/*
 * WidgetMethod_ --
 *	Call standard option set method.
 *
 * Results:
 *
 * Side effects:
 */
static int
WidgetMethod_(
	ClientData clientData,
	Tcl_Interp * interp,
	Tcl_ObjectContext context,
	int objc,
	Tcl_Obj * const objv[])
{              /* common option set method */
	tkoWidgetOptionDefine *define = (tkoWidgetOptionDefine *)clientData;
	return TkoWidgetOptionSet(interp, context, define->optionPtr,
		define->type, define->meta, define->offset);
}

/* vim: set ts=4 sw=4 sts=4 ff=unix et : */

Changes to generic/tko/tkoWidget.h.

160
161
162
163
164
165
166


167
168
169
170
171
172
173
174

175
176
177
178
179
180
181
...
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
 *   the TkoWidgetOptionSet() function call.
 */
    typedef struct tkoWidgetOptionDefine {
        const char *option;    /* Name of option. Starts with "-" minus sign */
        const char *dbname;    /* Option DB name or synonym option if dbclass is NULL */
        const char *dbclass;   /* Option DB class name or NULL for synonym options. */
        const char *defvalue;  /* Default value. */


        const char *proc;      /* If not NULL it is the body of the newly created -option method */
        Tcl_MethodCallProc *method;     /* If not NULL it is the function name of the -option method */
        int flags;             /* if TKO_WIDGETOPTIONREADONLY then option is only setable at creation time */
        tkoWidgetOptionType type;       /* if greater 0 then option type used in common option set method */
        Tcl_ObjectMetadataType *meta;   /* meta data address used in common option set method */
        int offset;            /* offset in meta data struct */
    } tkoWidgetOptionDefine;
#define TKO_WIDGETOPTIONREADONLY 0x1    /* option is only setable at creation time */


/* tkoFrame.c */
    MODULE_SCOPE int Tko_FrameInit(
        Tcl_Interp * interp);
/* tkoVector.c */
    MODULE_SCOPE int Tko_VectorInit(
        Tcl_Interp * interp);
................................................................................
        Tcl_ObjectMetadataType * meta,
        size_t offset);
    MODULE_SCOPE int TkoWidgetClassDefine(
        Tcl_Interp * interp,
        Tcl_Class clazz,
        Tcl_Obj * classname,
        const Tcl_MethodType * methods,
        const tkoWidgetOptionDefine * options);

/*
 * end block for C++
 */

#ifdef __cplusplus
}
#endif
#endif                         /* _TKOWIDGET_H */
/* vim: set ts=4 sw=4 sts=4 ff=unix et : */






>
>


<




|
>







 







|










160
161
162
163
164
165
166
167
168
169
170

171
172
173
174
175
176
177
178
179
180
181
182
183
...
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
 *   the TkoWidgetOptionSet() function call.
 */
    typedef struct tkoWidgetOptionDefine {
        const char *option;    /* Name of option. Starts with "-" minus sign */
        const char *dbname;    /* Option DB name or synonym option if dbclass is NULL */
        const char *dbclass;   /* Option DB class name or NULL for synonym options. */
        const char *defvalue;  /* Default value. */
        int flags;             /* bit array of TKO_OPTION_* values to configure option behaviour */
		Tcl_Obj *optionPtr;    /* tko internally used, always init with NULL! */
        const char *proc;      /* If not NULL it is the body of the newly created -option method */
        Tcl_MethodCallProc *method;     /* If not NULL it is the function name of the -option method */

        tkoWidgetOptionType type;       /* if greater 0 then option type used in common option set method */
        Tcl_ObjectMetadataType *meta;   /* meta data address used in common option set method */
        int offset;            /* offset in meta data struct */
    } tkoWidgetOptionDefine;
#define TKO_OPTION_READONLY 0x1 /* option is only setable at creation time */
#define TKO_OPTION_HIDE     0x2 /* option is hidden in configure method */      

/* tkoFrame.c */
    MODULE_SCOPE int Tko_FrameInit(
        Tcl_Interp * interp);
/* tkoVector.c */
    MODULE_SCOPE int Tko_VectorInit(
        Tcl_Interp * interp);
................................................................................
        Tcl_ObjectMetadataType * meta,
        size_t offset);
    MODULE_SCOPE int TkoWidgetClassDefine(
        Tcl_Interp * interp,
        Tcl_Class clazz,
        Tcl_Obj * classname,
        const Tcl_MethodType * methods,
        tkoWidgetOptionDefine * options);

/*
 * end block for C++
 */

#ifdef __cplusplus
}
#endif
#endif                         /* _TKOWIDGET_H */
/* vim: set ts=4 sw=4 sts=4 ff=unix et : */

Changes to tests/tko/tkoFrame.test.

1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733











1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
....
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
test frame-20.3 {configure optionadd missing command} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    .f configure optionadd -option option Option value
} -cleanup {
    deleteWindows
} -returnCodes error -match glob -result {can't set*unknown method*}

test frame-20.4 {configure optionadd} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    .f configure optionadd -option option Option value
    .f cget -option
} -cleanup {
    deleteWindows
} -result {value}

test frame-20.5 {configure optiondel} -setup {











    deleteWindows
} -body {
    ::tko::frame .f
    .f configure optiondel -notexist
} -cleanup {
    deleteWindows
} -returnCodes error -match glob -result {unknown option "-notexist"}

test frame-20.6 {configure optionadd} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    set ret [llength [.f configure]]
    .f configure optionadd -option option Option value
    lappend ret [llength [.f configure]]
................................................................................
    .f cget -option
    .f configure optiondel -option
    lappend ret [llength [.f configure]]
} -cleanup {
    deleteWindows
} -result {18 19 18}

test frame-20.7 {configure optionadd readonly} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    set ret [llength [.f configure]]
    .f configure optionadd -option option Option value 1
    if {[.f cget -option] ne {value}} {error "option not set"}
    .f configure -option test
} -cleanup {
    deleteWindows
} -returnCodes error -match glob -result {* is readonly}

test frame-20.8 {configure optionvar get} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    .f configure optionadd -option option Option value
    set [.f configure optionvar](-option)
} -cleanup {
    deleteWindows
} -result {value}

test frame-20.9 {configure optionvar set} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    .f configure optionadd -option option Option value
    set [.f configure optionvar](-option) other
    .f cget -option






|












|
>
>
>
>
>
>
>
>
>
>
>








|







 







|












|










|







1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
....
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
test frame-20.3 {configure optionadd missing command} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    .f configure optionadd -option option Option value
} -cleanup {
    deleteWindows
} -returnCodes error -match glob -result {unknown method "-option": must be*}

test frame-20.4 {configure optionadd} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    .f configure optionadd -option option Option value
    .f cget -option
} -cleanup {
    deleteWindows
} -result {value}

test frame-20.5 {configure optionadd modify} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {my variable tko; set tko(-option) new}
    .f configure optionadd -option option Option value
    .f cget -option
} -cleanup {
    deleteWindows
} -result {new}

test frame-20.6 {configure optiondel} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    .f configure optiondel -notexist
} -cleanup {
    deleteWindows
} -returnCodes error -match glob -result {unknown option "-notexist"}

test frame-20.7 {configure optionaddand optiondel} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    set ret [llength [.f configure]]
    .f configure optionadd -option option Option value
    lappend ret [llength [.f configure]]
................................................................................
    .f cget -option
    .f configure optiondel -option
    lappend ret [llength [.f configure]]
} -cleanup {
    deleteWindows
} -result {18 19 18}

test frame-20.8 {configure optionadd readonly} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    set ret [llength [.f configure]]
    .f configure optionadd -option option Option value 1
    if {[.f cget -option] ne {value}} {error "option not set"}
    .f configure -option test
} -cleanup {
    deleteWindows
} -returnCodes error -match glob -result {* is readonly}

test frame-20.9 {configure optionvar get} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    .f configure optionadd -option option Option value
    set [.f configure optionvar](-option)
} -cleanup {
    deleteWindows
} -result {value}

test frame-20.10 {configure optionvar set} -setup {
    deleteWindows
} -body {
    ::tko::frame .f
    ::oo::objdefine .f method -option {} {}
    .f configure optionadd -option option Option value
    set [.f configure optionvar](-option) other
    .f cget -option