1
2
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
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
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
|
/* $Id: ttkWidget.h,v 1.1 2006/10/31 01:42:26 hobbs Exp $
* Copyright (c) 2003, Joe English
*
* Helper routines for widget implementations.
*
* Require: ttkTheme.h.
*/
#ifndef WIDGET_H
#define WIDGET_H 1
/* State flags for 'flags' field.
* @@@ todo: distinguish:
* need reconfigure, need redisplay, redisplay pending
*/
#define WIDGET_DESTROYED 0x0001
#define REDISPLAY_PENDING 0x0002 /* scheduled call to RedisplayWidget */
#define WIDGET_REALIZED 0x0010 /* set at first ConfigureNotify */
#define CURSOR_ON 0x0020 /* See BlinkCursor() */
#define WIDGET_USER_FLAG 0x0100 /* 0x0100 - 0x8000 for user flags */
/*
* Bit fields for OptionSpec 'mask' field:
*/
#define READONLY_OPTION 0x1
#define STYLE_CHANGED 0x2
#define GEOMETRY_CHANGED 0x4
/*
* Core widget elements
*/
typedef struct WidgetSpec_ WidgetSpec; /* Forward */
typedef struct
{
Tk_Window tkwin; /* Window associated with widget */
Tcl_Interp *interp; /* Interpreter associated with widget. */
WidgetSpec *widgetSpec; /* Widget class hooks */
Tcl_Command widgetCmd; /* Token for widget command. */
Tk_OptionTable optionTable; /* Option table */
Ttk_Layout layout; /* Widget layout */
/*
* Storage for resources:
*/
Tcl_Obj *takeFocusPtr; /* Storage for -takefocus option */
Tcl_Obj *cursorObj; /* Storage for -cursor option */
Tcl_Obj *styleObj; /* Name of currently-applied style */
Tcl_Obj *classObj; /* Class name (readonly option) */
Ttk_State state; /* Current widget state */
unsigned int flags; /* internal flags, see above */
} WidgetCore;
/*
* Subcommand specifications:
*/
typedef int (*WidgetSubcommandProc)(
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr);
typedef struct {
const char *name;
WidgetSubcommandProc command;
} WidgetCommandSpec;
extern int WidgetEnsembleCommand( /* Run an ensemble command */
WidgetCommandSpec *commands, int cmdIndex,
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], void *recordPtr);
/*
* Widget specifications:
*/
struct WidgetSpec_
{
const char *className; /* Widget class name */
size_t recordSize; /* #bytes in widget record */
Tk_OptionSpec *optionSpecs; /* Option specifications */
WidgetCommandSpec *commands; /* Widget instance subcommands */
/*
* Hooks:
*/
int (*initializeProc)(Tcl_Interp *, void *recordPtr);
void (*cleanupProc)(void *recordPtr);
int (*configureProc)(Tcl_Interp *, void *recordPtr, int flags);
int (*postConfigureProc)(Tcl_Interp *, void *recordPtr, int flags);
Ttk_Layout (*getLayoutProc)(Tcl_Interp *,Ttk_Theme, void *recordPtr);
int (*sizeProc)(void *recordPtr, int *widthPtr, int *heightPtr);
void (*layoutProc)(void *recordPtr);
void (*displayProc)(void *recordPtr, Drawable d);
};
/*
* Common factors for widget implementations:
*/
extern int NullInitialize(Tcl_Interp *, void *);
extern int NullPostConfigure(Tcl_Interp *, void *, int);
extern void NullCleanup(void *recordPtr);
extern Ttk_Layout WidgetGetLayout(Tcl_Interp *, Ttk_Theme, void *recordPtr);
extern Ttk_Layout WidgetGetOrientedLayout(
Tcl_Interp *, Ttk_Theme, void *recordPtr, Tcl_Obj *orientObj);
extern int WidgetSize(void *recordPtr, int *w, int *h);
extern void WidgetDoLayout(void *recordPtr);
extern void WidgetDisplay(void *recordPtr, Drawable);
extern int CoreConfigure(Tcl_Interp*, void *, int mask);
/* Commands present in all widgets:
*/
extern int WidgetConfigureCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
extern int WidgetCgetCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
extern int WidgetInstateCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
extern int WidgetStateCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
/* Common widget commands:
*/
extern int WidgetIdentifyCommand(Tcl_Interp *, int, Tcl_Obj*const[], void *);
extern int WidgetConstructorObjCmd(ClientData,Tcl_Interp*,int,Tcl_Obj*CONST[]);
#define RegisterWidget(interp, name, specPtr) \
Tcl_CreateObjCommand(interp, name, \
WidgetConstructorObjCmd, (ClientData)specPtr,NULL)
/* WIDGET_TAKES_FOCUS --
* Add this to the OptionSpecs table of widgets that
* take keyboard focus during traversal to override
* CoreOptionSpec's -takefocus default value:
*/
#define WIDGET_TAKES_FOCUS \
{TK_OPTION_STRING, "-takefocus", "takeFocus", "TakeFocus", \
"ttk::takefocus", Tk_Offset(WidgetCore, takeFocusPtr), -1, 0,0,0 }
/* WIDGET_INHERIT_OPTIONS(baseOptionSpecs) --
* Add this at the end of an OptionSpecs table to inherit
* the options from 'baseOptionSpecs'.
*/
#define WIDGET_INHERIT_OPTIONS(baseOptionSpecs) \
{TK_OPTION_END, 0,0,0, NULL, -1,-1, 0, (ClientData)baseOptionSpecs, 0}
/*
* Useful routines for use inside widget implementations:
*/
extern int WidgetDestroyed(WidgetCore *);
#define WidgetDestroyed(corePtr) ((corePtr)->flags & WIDGET_DESTROYED)
extern void WidgetChangeState(WidgetCore *,
unsigned int setBits, unsigned int clearBits);
extern void TtkRedisplayWidget(WidgetCore *);
extern void TtkResizeWidget(WidgetCore *);
extern void TrackElementState(WidgetCore *);
extern void BlinkCursor(WidgetCore *);
/*
* -state option values (compatibility)
*/
extern void CheckStateOption(WidgetCore *, Tcl_Obj *);
/*
* Variable traces:
*/
typedef void (*Ttk_TraceProc)(void *recordPtr, const char *value);
typedef struct TtkTraceHandle_ Ttk_TraceHandle;
extern Ttk_TraceHandle *Ttk_TraceVariable(
Tcl_Interp*, Tcl_Obj *varnameObj, Ttk_TraceProc callback, void *clientData);
extern void Ttk_UntraceVariable(Ttk_TraceHandle *);
extern int Ttk_FireTrace(Ttk_TraceHandle *);
/*
* Utility routines for managing -image option:
*/
extern int GetImageList(
Tcl_Interp *, WidgetCore *, Tcl_Obj *imageOption, Tk_Image **imageListPtr);
extern void FreeImageList(Tk_Image *);
/*
* Virtual events:
*/
extern void SendVirtualEvent(Tk_Window tgtWin, const char *eventName);
/*
* Helper routines for data accessor commands:
*/
extern int EnumerateOptions(
Tcl_Interp *, void *recordPtr, Tk_OptionSpec *, Tk_OptionTable, Tk_Window);
extern int GetOptionValue(
Tcl_Interp *, void *recordPtr, Tcl_Obj *optName, Tk_OptionTable, Tk_Window);
/*
* Helper routines for scrolling widgets (see scroll.c).
*/
typedef struct {
int first; /* First visible item */
int last; /* Last visible item */
int total; /* Total #items */
char *scrollCmd; /* Widget option */
} Scrollable;
typedef struct ScrollHandleRec *ScrollHandle;
extern ScrollHandle CreateScrollHandle(WidgetCore *, Scrollable *);
extern void FreeScrollHandle(ScrollHandle);
extern int ScrollviewCommand(
Tcl_Interp *interp, int objc, Tcl_Obj *const objv[], ScrollHandle);
extern void ScrollTo(ScrollHandle, int newFirst);
extern void Scrolled(ScrollHandle, int first, int last, int total);
extern void ScrollbarUpdateRequired(ScrollHandle);
/*
* Tag sets (work in progress, half-baked)
*/
typedef struct TtkTag *Ttk_Tag;
typedef struct TtkTagTable *Ttk_TagTable;
extern Ttk_TagTable Ttk_CreateTagTable(Tk_OptionTable, int tagRecSize);
extern void Ttk_DeleteTagTable(Ttk_TagTable);
extern Ttk_Tag Ttk_GetTag(Ttk_TagTable, const char *tagName);
extern Ttk_Tag Ttk_GetTagFromObj(Ttk_TagTable, Tcl_Obj *);
extern Tcl_Obj **Ttk_TagRecord(Ttk_Tag);
extern int Ttk_GetTagListFromObj(
Tcl_Interp *interp, Ttk_TagTable, Tcl_Obj *objPtr,
int *nTags_rtn, void **taglist_rtn);
extern void Ttk_FreeTagList(void **taglist);
/*
* Useful widget base classes:
*/
extern Tk_OptionSpec CoreOptionSpecs[];
/*
* String tables for widget resource specifications:
*/
extern const char *TTKOrientStrings[];
extern const char *TTKCompoundStrings[];
extern const char *TTKDefaultStrings[];
/*
* ... other option types...
*/
extern int TtkGetLabelAnchorFromObj(Tcl_Interp*,Tcl_Obj*,Ttk_PositionSpec *);
/*
* Package initialiation routines:
*/
extern void RegisterElements(Tcl_Interp *);
#if defined(__WIN32__)
#define Ttk_PlatformInit Ttk_WinPlatformInit
extern int Ttk_WinPlatformInit(Tcl_Interp *);
#elif defined(MAC_OSX_TK)
#define Ttk_PlatformInit Ttk_MacPlatformInit
extern int Ttk_MacPlatformInit(Tcl_Interp *);
#else
#define Ttk_PlatformInit(interp) /* TTK_X11PlatformInit() */
#endif
#endif /* WIDGET_H */
|