source: nanovis/tags/1.1.4/Switch.h @ 6369

Last change on this file since 6369 was 4893, checked in by ldelgass, 9 years ago

merge r4056 from trunk

  • Property svn:eol-style set to native
File size: 3.9 KB
Line 
1/* -*- mode: c++; c-basic-offset: 4; indent-tabs-mode: nil -*- */
2/*
3 * Switch.h --
4 *
5 *      Copyright 1993-2004 George A Howlett.
6 *
7 *      Permission is hereby granted, free of charge, to any person
8 *      obtaining a copy of this software and associated documentation
9 *      files (the "Software"), to deal in the Software without
10 *      restriction, including without limitation the rights to use,
11 *      copy, modify, merge, publish, distribute, sublicense, and/or
12 *      sell copies of the Software, and to permit persons to whom the
13 *      Software is furnished to do so, subject to the following
14 *      conditions:
15 *
16 *      The above copyright notice and this permission notice shall be
17 *      included in all copies or substantial portions of the
18 *      Software.
19 *
20 *      THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
21 *      KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
22 *      WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
23 *      PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
24 *      OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 *      OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
26 *      OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
27 *      SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 */
29
30#ifndef NV_SWITCH_H
31#define NV_SWITCH_H
32
33#ifdef HAVE_STDDEF_H
34#  include <stddef.h>
35#endif /* HAVE_STDDEF_H */
36
37namespace nv {
38
39typedef int (SwitchParseProc)(ClientData clientData, Tcl_Interp *interp,
40                              const char *switchName, Tcl_Obj *valueObjPtr,
41                              char *record, int offset,
42                              int flags);
43
44typedef void (SwitchFreeProc)(char *record, int offset, int flags);
45
46typedef struct {
47    SwitchParseProc *parseProc; /* Procedure to parse a switch
48                                 * value and store it in its *
49                                 * converted form in the data *
50                                 * record. */
51
52    SwitchFreeProc *freeProc;   /* Procedure to free a switch. */
53
54    ClientData clientData;      /* Arbitrary one-word value used by
55                                 * switch parser, passed to
56                                 * parseProc. */
57} SwitchCustom;
58
59
60/*
61 * Type values for SwitchSpec structures.  See the user
62 * documentation for details.
63 */
64typedef enum {
65    SWITCH_BOOLEAN,
66    SWITCH_DOUBLE,
67    SWITCH_BITMASK,
68    SWITCH_BITMASK_NEG,
69    SWITCH_FLOAT,
70    SWITCH_INT,
71    SWITCH_INT_NNEG,
72    SWITCH_INT_POS,
73    SWITCH_LIST,
74    SWITCH_LONG,
75    SWITCH_LONG_NNEG,
76    SWITCH_LONG_POS,
77    SWITCH_OBJ,
78    SWITCH_STRING,
79    SWITCH_VALUE,
80    SWITCH_CUSTOM,
81    SWITCH_END
82} SwitchTypes;
83
84
85typedef struct {
86    SwitchTypes type;           /* Type of option, such as
87                                 * SWITCH_COLOR; see definitions
88                                 * below.  Last option in table must
89                                 * have type SWITCH_END. */
90
91    const char *switchName;     /* Switch used to specify option in
92                                 * argv.  NULL means this spec is part
93                                 * of a group. */
94
95    const char *help;           /* Help string. */
96    int offset;                 /* Where in widget record to store
97                                 * value; use Blt_Offset macro to
98                                 * generate values for this. */
99
100    int flags;                  /* Any combination of the values
101                                 * defined below. */
102
103    unsigned int mask;
104
105    SwitchCustom *customPtr;    /* If type is SWITCH_CUSTOM then
106                                 * this is a pointer to info about how
107                                 * to parse and print the option.
108                                 * Otherwise it is irrelevant. */
109} SwitchSpec;
110
111#define SWITCH_DEFAULTS         (0) 
112#define SWITCH_ARGV_PARTIAL     (1<<1)
113#define SWITCH_OBJV_PARTIAL     (1<<1)
114
115/*
116 * Possible flag values for Blt_SwitchSpec structures.  Any bits at or
117 * above BLT_SWITCH_USER_BIT may be used by clients for selecting
118 * certain entries.
119 */
120#define SWITCH_NULL_OK          (1<<0)
121#define SWITCH_DONT_SET_DEFAULT (1<<3)
122#define SWITCH_SPECIFIED        (1<<4)
123#define SWITCH_USER_BIT         (1<<8)
124
125extern int ParseSwitches(Tcl_Interp *interp, SwitchSpec *specPtr,
126                         int objc, Tcl_Obj *const *objv,
127                         void *rec, int flags);
128
129extern void FreeSwitches(SwitchSpec *specs, void *rec, int flags);
130
131extern int SwitchChanged TCL_VARARGS(SwitchSpec *, specs);
132 
133}
134
135#endif
Note: See TracBrowser for help on using the repository browser.