Tk Source Code

tkoWidget(3) -- oo class like widgets


TkoWidgetClassDefine, TkoWidgetOptionVar, TkoWidgetOptionGet, TkoWidgetOptionSet, TkoWidgetWindow -- tko widget class commands


#include "tkoWidget.h"

Tk_Window *
Tcl_Obj *
Tcl_Obj *


Tcl_Interp *interp Used interpreter.
Tcl_Class clazz Oo class of widget.
Tcl_Obj *classname Oo class name of widget.
const Tcl_MethodType *methods This array defines class methods to create. For creation methods see [Tcl_NewMethod] manpage. If the method name of the first array entry is not NULL it will be used as constructor, if the second method name is not NULL it used as destructor. Then follow public methods until an entry with an method name equal NULL comes. Then follow private methods until an entry with an method name equal NULL comes.
const tkoWidgetOptionDefine *options This array contain option definitions.
Tcl_Object object This is the current object reference.
Tcl_Obj *option The name of the used option.
Tcl_ObjectContext context The context of the current object. Used to get associated object data.
tkoWidgetOptionType type A type used in the common option setting routine.
Tcl_ObjectMetadataType *meta The type of metadata attaches to the current object.
size_t offset Offset of variable to set in the attaches meta data record.


The TkoWidgetClassDefine function can be used to define options and methods of an tko::widget subclass. The function is used in the widget class definition of a new tko widget class.

The TkoWidgetWindow function return the address of the internally created Tk_Window. Subclasses should check the address on NULL after creation. If the Tk_Window* at these address is NULL the widget is destroyed and it should not be used.

The TkoWidgetOptionVar function return the globally accessible name of the array variable holding the option values. Additionall there is an field "." containing the tk widget path name of the widget.

The TkoWidgetOptionGet function returns the current value of the given option.

The TkoWidgetOptionSet function can be used to check given option values and set C record structure fields at the given offset. The record will be retrieved using the given meta metadata. The type must be one of the tkoWidgetOptionType described below.

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 */
    TKO_SET_VISUAL, /* (Tcl_Obj **)address */
    TKO_SET_COLORMAP,       /* (Tcl_Obj **)address */
    TKO_SET_USENULL,        /* (Tcl_Obj **)address */
    TKO_SET_CONTAINER,      /* (int *)address */
    TKO_SET_TCLOBJ, /* (Tcl_Obj **)address */
    TKO_SET_XCOLOR, /* (Xcolor **)address */
    TKO_SET_3DBORDER,       /* (Tk_3DBorder *)address */
    TKO_SET_PIXEL,  /* (int *)address */
    TKO_SET_PIXELNONEGATIV, /* (int *)address */
    TKO_SET_PIXELPOSITIV,   /* (int *)address */
    TKO_SET_DOUBLE, /* (double *)address */
    TKO_SET_BOOLEAN,        /* (int *)address */
    TKO_SET_CURSOR, /* (Tk_Cursor *)address */
    TKO_SET_INT,    /* (int *)address */
    TKO_SET_RELIEF, /* (int *)address */
    TKO_SET_ANCHOR, /* (int *)address */
    TKO_SET_WINDOW, /* (Tk_Window *)address */
    TKO_SET_FONT,   /* (Tk_Font *)address */
    TKO_SET_STRING, /* (char **)address */
    TKO_SET_STRINGNULL,     /* (char **)address */
    TKO_SET_SCROLLREGION,   /* (int *[4])address */
    TKO_SET_JUSTIFY /* (Tk_Justify *)address */
} tkoWidgetOptionType;


frame, labelframe, toplevel, oo::class


oo widget method option


© 2019- RenĂ© Zaumseil [email protected]

BSD style license.