source: trunk/kitgen/8.x/blt/generic/bltObjConfig.h@ 175

Last change on this file since 175 was 175, checked in by demin, 12 years ago

initial commit

File size: 9.3 KB
Line 
1/*
2 * bltObjConfig.h --
3 *
4 * This file contains the Tcl_Obj based versions of the old
5 * Tk_ConfigureWidget procedures.
6 *
7 * Copyright (c) 1990-1994 The Regents of the University of California.
8 * Copyright (c) 1994-1997 Sun Microsystems, Inc.
9 *
10 * See the file "license.terms" for information on usage and redistribution
11 * of this file, and for a DISCLAIMER OF ALL WARRANTIES.
12 *
13 */
14
15#ifndef BLT_OBJCONFIG_H
16#define BLT_OBJCONFIG_H
17
18/*
19 * This is a Tcl_Obj based replacement for the widget configuration
20 * functions in Tk.
21 *
22 * What not use the new Tk_Option interface?
23 *
24 * There were design changes in the new Tk_Option interface that
25 * make it unwieldy.
26 *
27 * o You have to dynamically allocate, store, and deallocate
28 * your option table.
29 * o The Tk_FreeConfigOptions routine requires a tkwin argument.
30 * Unfortunately, most widgets save the display pointer and
31 * deference their tkwin when the window is destroyed.
32 * o There's no TK_CONFIG_CUSTOM functionality. This means that
33 * save special options must be saved as strings by
34 * Tk_ConfigureWidget and processed later, thus losing the
35 * benefits of Tcl_Objs. It also make error handling
36 * problematic, since you don't pick up certain errors like
37 *
38 * .widget configure -myoption bad -myoption good
39 *
40 * You will never see the first "bad" value.
41 * o Especially compared to the former Tk_ConfigureWidget calls,
42 * the new interface is overly complex. If there was a big
43 * performance win, it might be worth the effort. But let's
44 * face it, this biggest wins are in processing custom options
45 * values with thousands of elements. Most common resources
46 * (font, color, etc) have string tokens anyways.
47 *
48 * On the other hand, the replacement functions in this file fell
49 * into place quite easily both from the aspect of API writer and
50 * user. The biggest benefit is that you don't need to change lots
51 * of working code just to get the benefits of Tcl_Objs.
52 *
53 */
54#define SIDE_LEFT (0)
55#define SIDE_TOP (1)
56#define SIDE_RIGHT (2)
57#define SIDE_BOTTOM (3)
58
59#define SIDE_HORIZONTAL(s) (!((s) & 0x1))
60#define SIDE_VERTICAL(s) ((s) & 0x1)
61
62#ifndef Blt_Offset
63#ifdef offsetof
64#define Blt_Offset(type, field) ((int) offsetof(type, field))
65#else
66#define Blt_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
67#endif
68#endif /* Blt_Offset */
69
70typedef int (Blt_OptionParseProc) _ANSI_ARGS_((ClientData clientData,
71 Tcl_Interp *interp, Tk_Window tkwin, Tcl_Obj *objPtr, char *widgRec,
72 int offset));
73typedef Tcl_Obj *(Blt_OptionPrintProc) _ANSI_ARGS_((ClientData clientData,
74 Tcl_Interp *interp, Tk_Window tkwin, char *widgRec, int offset));
75typedef void (Blt_OptionFreeProc) _ANSI_ARGS_((ClientData clientData,
76 Display *display, char *widgRec, int offset));
77
78typedef struct Blt_CustomOption {
79 Blt_OptionParseProc *parseProc; /* Procedure to call to parse an
80 * option and store it in converted
81 * form. */
82 Blt_OptionPrintProc *printProc; /* Procedure to return a printable
83 * string describing an existing
84 * option. */
85 Blt_OptionFreeProc *freeProc; /* Procedure to free the value. */
86
87 ClientData clientData; /* Arbitrary one-word value used by
88 * option parser: passed to
89 * parseProc and printProc. */
90} Blt_CustomOption;
91
92/*
93 * Structure used to specify information for Tk_ConfigureWidget. Each
94 * structure gives complete information for one option, including
95 * how the option is specified on the command line, where it appears
96 * in the option database, etc.
97 */
98
99typedef struct {
100 int type; /* Type of option, such as BLT_CONFIG_COLOR;
101 * see definitions below. Last option in
102 * table must have type BLT_CONFIG_END. */
103 char *switchName; /* Switch used to specify option in argv.
104 * NULL means this spec is part of a group. */
105 Tk_Uid dbName; /* Name for option in option database. */
106 Tk_Uid dbClass; /* Class for option in database. */
107 Tk_Uid defValue; /* Default value for option if not
108 * specified in command line or database. */
109 int offset; /* Where in widget record to store value;
110 * use Tk_Offset macro to generate values
111 * for this. */
112 int specFlags; /* Any combination of the values defined
113 * below; other bits are used internally
114 * by tkConfig.c. */
115 Blt_CustomOption *customPtr; /* If type is BLT_CONFIG_CUSTOM then this is
116 * a pointer to info about how to parse and
117 * print the option. Otherwise it is
118 * irrelevant. */
119} Blt_ConfigSpec;
120
121/*
122 * Type values for Blt_ConfigSpec structures. See the user
123 * documentation for details.
124 */
125
126typedef enum {
127 BLT_CONFIG_ACTIVE_CURSOR,
128 BLT_CONFIG_ANCHOR,
129 BLT_CONFIG_BITMAP,
130 BLT_CONFIG_BOOLEAN,
131 BLT_CONFIG_BORDER,
132 BLT_CONFIG_CAP_STYLE,
133 BLT_CONFIG_COLOR,
134 BLT_CONFIG_CURSOR,
135 BLT_CONFIG_CUSTOM,
136 BLT_CONFIG_DOUBLE,
137 BLT_CONFIG_FONT,
138 BLT_CONFIG_INT,
139 BLT_CONFIG_JOIN_STYLE,
140 BLT_CONFIG_JUSTIFY,
141 BLT_CONFIG_MM,
142 BLT_CONFIG_PIXELS,
143 BLT_CONFIG_RELIEF,
144 BLT_CONFIG_STRING,
145 BLT_CONFIG_SYNONYM,
146 BLT_CONFIG_UID,
147 BLT_CONFIG_WINDOW,
148
149 BLT_CONFIG_BITFLAG,
150 BLT_CONFIG_DASHES,
151 BLT_CONFIG_DISTANCE, /* */
152 BLT_CONFIG_FILL,
153 BLT_CONFIG_FLOAT,
154 BLT_CONFIG_LIST,
155 BLT_CONFIG_LISTOBJ,
156 BLT_CONFIG_PAD,
157 BLT_CONFIG_POS_DISTANCE, /* */
158 BLT_CONFIG_SHADOW, /* */
159 BLT_CONFIG_SIDE,
160 BLT_CONFIG_STATE,
161 BLT_CONFIG_TILE,
162
163 BLT_CONFIG_END
164} Blt_ConfigTypes;
165
166/*
167 * Possible values for flags argument to Tk_ConfigureWidget:
168 */
169
170#define BLT_CONFIG_OBJV_ONLY 1
171#define BLT_CONFIG_OBJS 0x80
172
173/*
174 * Possible flag values for Blt_ConfigSpec structures. Any bits at
175 * or above BLT_CONFIG_USER_BIT may be used by clients for selecting
176 * certain entries. Before changing any values here, coordinate with
177 * tkOldConfig.c (internal-use-only flags are defined there).
178 */
179
180#define BLT_CONFIG_NULL_OK 1
181#define BLT_CONFIG_COLOR_ONLY 2
182#define BLT_CONFIG_MONO_ONLY 4
183#define BLT_CONFIG_DONT_SET_DEFAULT 8
184#define BLT_CONFIG_OPTION_SPECIFIED 0x10
185#define BLT_CONFIG_USER_BIT 0x100
186
187/*
188 * Values for "flags" field of Blt_ConfigSpec structures. Be sure
189 * to coordinate these values with those defined in tk.h
190 * (BLT_CONFIG_COLOR_ONLY, etc.). There must not be overlap!
191 *
192 * INIT - Non-zero means (char *) things have been
193 * converted to Tk_Uid's.
194 */
195
196#define INIT 0x20
197
198EXTERN int Blt_ConfigureInfoFromObj _ANSI_ARGS_((Tcl_Interp *interp,
199 Tk_Window tkwin, Blt_ConfigSpec *specs, char *widgRec,
200 Tcl_Obj *objPtr, int flags));
201EXTERN int Blt_ConfigureValueFromObj _ANSI_ARGS_((Tcl_Interp *interp,
202 Tk_Window tkwin, Blt_ConfigSpec *specs, char * widgRec,
203 Tcl_Obj *objPtr, int flags));
204EXTERN int Blt_ConfigureWidgetFromObj _ANSI_ARGS_((Tcl_Interp *interp,
205 Tk_Window tkwin, Blt_ConfigSpec *specs, int objc, Tcl_Obj *CONST *objv,
206 char *widgRec, int flags));
207EXTERN int Blt_ConfigureComponentFromObj _ANSI_ARGS_((Tcl_Interp *interp,
208 Tk_Window tkwin, char *name, char *className, Blt_ConfigSpec *specs,
209 int objc, Tcl_Obj *CONST *objv, char *widgRec, int flags));
210
211EXTERN int Blt_ObjConfigModified _ANSI_ARGS_(TCL_VARARGS(Blt_ConfigSpec *, specs));
212EXTERN void Blt_FreeObjOptions _ANSI_ARGS_((Blt_ConfigSpec *specs,
213 char *widgRec, Display *display, int needFlags));
214
215EXTERN int Blt_ObjIsOption _ANSI_ARGS_((Blt_ConfigSpec *specs, Tcl_Obj *objPtr,
216 int flags));
217
218EXTERN int Blt_GetPositionFromObj _ANSI_ARGS_((Tcl_Interp *interp,
219 Tcl_Obj *objPtr, int *indexPtr));
220
221EXTERN int Blt_GetPixelsFromObj _ANSI_ARGS_((Tcl_Interp *interp,
222 Tk_Window tkwin, Tcl_Obj *objPtr, int flags, int *valuePtr));
223
224EXTERN int Blt_GetPadFromObj _ANSI_ARGS_((Tcl_Interp *interp,
225 Tk_Window tkwin, Tcl_Obj *objPtr, Blt_Pad *padPtr));
226
227EXTERN int Blt_GetShadowFromObj _ANSI_ARGS_((Tcl_Interp *interp,
228 Tk_Window tkwin, Tcl_Obj *objPtr, Shadow *shadowPtr));
229
230EXTERN int Blt_GetStateFromObj _ANSI_ARGS_((Tcl_Interp *interp,
231 Tcl_Obj *objPtr, int *statePtr));
232
233EXTERN int Blt_GetFillFromObj _ANSI_ARGS_((Tcl_Interp *interp,
234 Tcl_Obj *objPtr, int *fillPtr));
235
236EXTERN int Blt_GetDashesFromObj _ANSI_ARGS_((Tcl_Interp *interp,
237 Tcl_Obj *objPtr, Blt_Dashes *dashesPtr));
238
239
240#if ((TK_VERSION_NUMBER >= _VERSION(8,0,0)) && \
241 (TK_VERSION_NUMBER < _VERSION(8,1,0)))
242EXTERN int Tk_GetAnchorFromObj _ANSI_ARGS_((Tcl_Interp *interp,
243 Tcl_Obj *objPtr, Tk_Anchor *anchorPtr));
244EXTERN int Tk_GetJustifyFromObj _ANSI_ARGS_((Tcl_Interp *interp,
245 Tcl_Obj *objPtr, Tk_Justify *justifyPtr));
246EXTERN int Tk_GetReliefFromObj _ANSI_ARGS_((Tcl_Interp *interp,
247 Tcl_Obj *objPtr, int *reliefPtr));
248EXTERN int Tk_GetMMFromObj _ANSI_ARGS_((Tcl_Interp *interp, Tk_Window tkwin,
249 Tcl_Obj *objPtr, double *doublePtr));
250EXTERN int Tk_GetPixelsFromObj _ANSI_ARGS_((Tcl_Interp *interp,
251 Tk_Window tkwin, Tcl_Obj *objPtr, int *intPtr));
252EXTERN Tk_3DBorder Tk_Alloc3DBorderFromObj _ANSI_ARGS_((Tcl_Interp *interp,
253 Tk_Window tkwin, Tcl_Obj *objPtr));
254EXTERN Pixmap Tk_AllocBitmapFromObj _ANSI_ARGS_((Tcl_Interp *interp,
255 Tk_Window tkwin, Tcl_Obj *objPtr));
256EXTERN Tk_Font Tk_AllocFontFromObj _ANSI_ARGS_((Tcl_Interp *interp,
257 Tk_Window tkwin, Tcl_Obj *objPtr));
258EXTERN Tk_Cursor Tk_AllocCursorFromObj _ANSI_ARGS_((Tcl_Interp *interp,
259 Tk_Window tkwin, Tcl_Obj *objPtr));
260EXTERN XColor *Tk_AllocColorFromObj _ANSI_ARGS_((Tcl_Interp *interp,
261 Tk_Window tkwin, Tcl_Obj *objPtr));
262#endif /* 8.0 */
263
264#endif /* BLT_OBJCONFIG_H */
Note: See TracBrowser for help on using the repository browser.