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 7 typedef int (Blt_SwitchParseProc) _ANSI_ARGS_((ClientData clientData, 8 Tcl_Interp *interp, char *switchName, char *value, char *record, 9 int offset)); 10 11 typedef void (Blt_SwitchFreeProc) _ANSI_ARGS_((char *ptr)); 12 13 typedef 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 */ 27 typedef 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, 31 BLT_SWITCH_OBJ, BLT_SWITCH_CUSTOM, 32 BLT_SWITCH_END 33 } Blt_SwitchTypes; 34 35 typedef struct { 36 Blt_SwitchTypes type; /* Type of option, such as BLT_SWITCH_COLOR; 37 * see definitions below. Last option in 38 * table must have type BLT_SWITCH_END. */ 39 char *switchName; /* Switch used to specify option in argv. 40 * NULL means this spec is part of a group. */ 41 int offset; /* Where in widget record to store value; 42 * use Blt_Offset macro to generate values 43 * for this. */ 44 int flags; /* Any combination of the values defined 45 * below. */ 46 Blt_SwitchCustom *customPtr; /* If type is BLT_SWITCH_CUSTOM then this is 47 * a pointer to info about how to parse and 48 * print the option. Otherwise it is 49 * irrelevant. */ 50 int value; 51 } Blt_SwitchSpec; 52 53 #define BLT_SWITCH_ARGV_ONLY (1<<0) 54 #define BLT_SWITCH_OBJV_ONLY (1<<0) 55 #define BLT_SWITCH_ARGV_PARTIAL (1<<1) 56 #define BLT_SWITCH_OBJV_PARTIAL (1<<1) 57 #define BLT_SWITCH_EXACT (1<<2) 58 /* 59 * Possible flag values for Blt_SwitchSpec structures. Any bits at 60 * or above BLT_SWITCH_USER_BIT may be used by clients for selecting 61 * certain entries. 62 */ 63 #define BLT_SWITCH_NULL_OK (1<<0) 64 #define BLT_SWITCH_DONT_SET_DEFAULT (1<<3) 65 #define BLT_SWITCH_SPECIFIED (1<<4) 66 #define BLT_SWITCH_USER_BIT (1<<8) 67 68 extern int Blt_ProcessSwitches _ANSI_ARGS_((Tcl_Interp *interp, 69 Blt_SwitchSpec *specs, int argc, char **argv, char *record, int flags)); 70 71 extern void Blt_FreeSwitches _ANSI_ARGS_((Tcl_Interp *interp, Blt_SwitchSpec *specs, char *record, 72 int flags)); 73 74 extern int Blt_SwitchChanged _ANSI_ARGS_(TCL_VARARGS(Blt_SwitchSpec *, specs)); 75 76 extern Blt_SwitchSpec * Blt_GetCachedSwitchSpecs _ANSI_ARGS_((Tcl_Interp *interp, 77 const Blt_SwitchSpec *staticSpecs)); 78 79 #if (TCL_VERSION_NUMBER >= _VERSION(8,0,0)) 80 extern int Blt_ProcessObjSwitches _ANSI_ARGS_((Tcl_Interp *interp, 81 Blt_SwitchSpec *specPtr, int objc, Tcl_Obj *CONST *objv, char *record, 82 int flags)); 83 #endif 84