source: trunk/kitgen/8.x/blt/generic/bltSwitch.h

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

initial commit

File size: 2.8 KB
RevLine 
[175]1#ifdef offsetof
2#define Blt_Offset(type, field) ((int) offsetof(type, field))
3#else
4#define Blt_Offset(type, field) ((int) ((char *) &((type *) 0)->field))
5#endif
6
7typedef int (Blt_SwitchParseProc) _ANSI_ARGS_((ClientData clientData,
8 Tcl_Interp *interp, char *switchName, char *value, char *record,
9 int offset));
10
11typedef void (Blt_SwitchFreeProc) _ANSI_ARGS_((char *ptr));
12
13typedef struct {
14 Blt_SwitchParseProc *parseProc; /* Procedure to parse a switch value
15 * and store it in its converted
16 * form in the data record. */
17 Blt_SwitchFreeProc *freeProc; /* Procedure to free a switch. */
18 ClientData clientData; /* Arbitrary one-word value
19 * used by switch parser,
20 * passed to parseProc. */
21} Blt_SwitchCustom;
22
23/*
24 * Type values for Blt_SwitchSpec structures. See the user
25 * documentation for details.
26 */
27typedef enum {
28 BLT_SWITCH_BOOLEAN, BLT_SWITCH_INT, BLT_SWITCH_INT_POSITIVE,
29 BLT_SWITCH_INT_NONNEGATIVE, BLT_SWITCH_DOUBLE, BLT_SWITCH_STRING,
30 BLT_SWITCH_LIST, BLT_SWITCH_FLAG, BLT_SWITCH_VALUE, BLT_SWITCH_CUSTOM,
31 BLT_SWITCH_END
32} Blt_SwitchTypes;
33
34typedef struct {
35 Blt_SwitchTypes type; /* Type of option, such as BLT_SWITCH_COLOR;
36 * see definitions below. Last option in
37 * table must have type BLT_SWITCH_END. */
38 char *switchName; /* Switch used to specify option in argv.
39 * NULL means this spec is part of a group. */
40 int offset; /* Where in widget record to store value;
41 * use Blt_Offset macro to generate values
42 * for this. */
43 int flags; /* Any combination of the values defined
44 * below. */
45 Blt_SwitchCustom *customPtr; /* If type is BLT_SWITCH_CUSTOM then this is
46 * a pointer to info about how to parse and
47 * print the option. Otherwise it is
48 * irrelevant. */
49 int value;
50} Blt_SwitchSpec;
51
52#define BLT_SWITCH_ARGV_ONLY (1<<0)
53#define BLT_SWITCH_OBJV_ONLY (1<<0)
54#define BLT_SWITCH_ARGV_PARTIAL (1<<1)
55#define BLT_SWITCH_OBJV_PARTIAL (1<<1)
56/*
57 * Possible flag values for Blt_SwitchSpec structures. Any bits at
58 * or above BLT_SWITCH_USER_BIT may be used by clients for selecting
59 * certain entries.
60 */
61#define BLT_SWITCH_NULL_OK (1<<0)
62#define BLT_SWITCH_DONT_SET_DEFAULT (1<<3)
63#define BLT_SWITCH_SPECIFIED (1<<4)
64#define BLT_SWITCH_USER_BIT (1<<8)
65
66extern int Blt_ProcessSwitches _ANSI_ARGS_((Tcl_Interp *interp,
67 Blt_SwitchSpec *specs, int argc, char **argv, char *record, int flags));
68
69extern void Blt_FreeSwitches _ANSI_ARGS_((Blt_SwitchSpec *specs, char *record,
70 int flags));
71
72extern int Blt_SwitchChanged _ANSI_ARGS_(TCL_VARARGS(Blt_SwitchSpec *, specs));
73
74#if (TCL_VERSION_NUMBER >= _VERSION(8,0,0))
75extern int Blt_ProcessObjSwitches _ANSI_ARGS_((Tcl_Interp *interp,
76 Blt_SwitchSpec *specPtr, int objc, Tcl_Obj *CONST *objv, char *record,
77 int flags));
78#endif
Note: See TracBrowser for help on using the repository browser.