summaryrefslogtreecommitdiffstats
path: root/src/bltConfig.h
blob: 55003bef7578241af9252d92fdf8b21a21966f10 (plain)
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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
/*
 * Smithsonian Astrophysical Observatory, Cambridge, MA, USA
 * This code has been modified under the terms listed below and is made
 * available under the same terms.
 */

/* 
 * bltConfig.h --
 *
 *	Copyright 1993-2004 George A Howlett.
 *
 *	Permission is hereby granted, free of charge, to any person
 *	obtaining a copy of this software and associated documentation
 *	files (the "Software"), to deal in the Software without
 *	restriction, including without limitation the rights to use,
 *	copy, modify, merge, publish, distribute, sublicense, and/or
 *	sell copies of the Software, and to permit persons to whom the
 *	Software is furnished to do so, subject to the following
 *	conditions:
 *
 *	The above copyright notice and this permission notice shall be
 *	included in all copies or substantial portions of the
 *	Software.
 *
 *	THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY
 *	KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
 *	WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
 *	PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS
 *	OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
 *	OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
 *	OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
 *	SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 */

#ifndef BLT_CONFIG_H
#define BLT_CONFIG_H

typedef int (Blt_OptionParseProc)(ClientData clientData, Tcl_Interp *interp, 
	Tk_Window tkwin, Tcl_Obj *objPtr, char *widgRec, int offset, int flags);
typedef Tcl_Obj *(Blt_OptionPrintProc)(ClientData clientData, 
	Tcl_Interp *interp, Tk_Window tkwin, char *widgRec, int offset, 
	int flags);
typedef void (Blt_OptionFreeProc)(ClientData clientData, Display *display, 
	char *widgRec, int offset);

typedef struct Blt_CustomOption {
    Blt_OptionParseProc *parseProc;	/* Procedure to call to parse
					 * an option and store it in
					 * converted form. */

    Blt_OptionPrintProc *printProc;	/* Procedure to return a
					 * Tcl_Obj representing an
					 * existing option value. */

    Blt_OptionFreeProc *freeProc;	/* Procedure used to free the
					 * value. */

    ClientData clientData;		/* Arbitrary one-word value
					 * used by option parser:
					 * passed to parseProc and
					 * printProc. */
} Blt_CustomOption;

/*
 * Structure used to specify information for Tk_ConfigureWidget.  Each
 * structure gives complete information for one option, including
 * how the option is specified on the command line, where it appears
 * in the option database, etc.
 */

typedef struct {
    int type;			/* Type of option, such as
				 * BLT_CONFIG_COLOR; see definitions
				 * below.  Last option in table must
				 * have type BLT_CONFIG_END. */

    const char *switchName;	/* Switch used to specify option in
				 * argv.  NULL means this spec is part
				 * of a group. */

    Tk_Uid dbName;		/* Name for option in option
				 * database. */

    Tk_Uid dbClass;		/* Class for option in database. */

    Tk_Uid defValue;		/* Default value for option if not
				 * specified in command line or
				 * database. */

    int offset;			/* Where in widget record to store
				 * value; use Blt_Offset macro to
				 * generate values for this. */

    int specFlags;		/* Any combination of the values
				 * defined below; other bits are used
				 * internally by tkConfig.c. */

    Blt_CustomOption *customPtr; /* If type is BLT_CONFIG_CUSTOM then
				 * this is a pointer to info about how
				 * to parse and print the option.
				 * Otherwise it is irrelevant. */
} Blt_ConfigSpec;

/*
 * Type values for Blt_ConfigSpec structures.  See the user
 * documentation for details.
 */
typedef enum {
    BLT_CONFIG_BOOLEAN, 
    BLT_CONFIG_INT, 
    BLT_CONFIG_DOUBLE, 
    BLT_CONFIG_STRING,
    BLT_CONFIG_UID,
    BLT_CONFIG_COLOR, 
    BLT_CONFIG_FONT, 
    BLT_CONFIG_BITMAP,
    BLT_CONFIG_BORDER, 
    BLT_CONFIG_RELIEF, 
    BLT_CONFIG_CURSOR, 
    BLT_CONFIG_ACTIVE_CURSOR, 
    BLT_CONFIG_JUSTIFY, 
    BLT_CONFIG_ANCHOR, 
    BLT_CONFIG_SYNONYM, 
    BLT_CONFIG_CAP_STYLE, 
    BLT_CONFIG_JOIN_STYLE,
    BLT_CONFIG_PIXELS,		/* 1.1c 2m 3.2i. */
    BLT_CONFIG_MM, 
    BLT_CONFIG_WINDOW, 
    BLT_CONFIG_CUSTOM, 
    BLT_CONFIG_END,

    BLT_CONFIG_BITMASK,
    BLT_CONFIG_DASHES,
    BLT_CONFIG_FILL,
    BLT_CONFIG_INT_NNEG,	/* 0..N */
    BLT_CONFIG_INT_POS,		/* 1..N */
    BLT_CONFIG_LIST,
    BLT_CONFIG_OBJ,
    BLT_CONFIG_PAD,
    BLT_CONFIG_PIXELS_NNEG,	/* 1.1c 2m 3.2i excluding negative
				   values. */
    BLT_CONFIG_PIXELS_POS,	/* 1.1c 2m 3.2i excluding negative
				 * values and zero. */
    BLT_CONFIG_STATE, 
    BLT_CONFIG_BACKGROUND
} Blt_ConfigTypes;

/*
 * Possible values for flags argument to Tk_ConfigureWidget:
 */
#define BLT_CONFIG_OBJV_ONLY	1

/*
 * Possible flag values for Blt_ConfigSpec structures.  Any bits at or
 * above BLT_CONFIG_USER_BIT may be used by clients for selecting
 * certain entries.  Before changing any values here, coordinate with
 * tkOldConfig.c (internal-use-only flags are defined there).
 */
/*
 * Values for "flags" field of Blt_ConfigSpec structures.  Be sure to
 * coordinate these values with those defined in tk.h
 * (BLT_CONFIG_COLOR_ONLY, etc.).  There must not be overlap!
 *
 * INIT -		Non-zero means (char *) things have been
 *			converted to Tk_Uid's.
 */
#define INIT				(1<<0)
#define BLT_CONFIG_NULL_OK		(1<<1)
#define BLT_CONFIG_COLOR_ONLY		(1<<2)
#define BLT_CONFIG_MONO_ONLY		(1<<3)
#define BLT_CONFIG_DONT_SET_DEFAULT	(1<<4)
#define BLT_CONFIG_OPTION_SPECIFIED	(1<<5)
#define BLT_CONFIG_USER_BIT		(1<<8)


#define STATE_NORMAL		(0)
#define STATE_ACTIVE		(1<<0)
#define STATE_DISABLED		(1<<1)
#define STATE_EMPHASIS		(1<<2)

/*
 *---------------------------------------------------------------------------
 *
 * Blt_Pad --
 *
 * 	Specifies vertical and horizontal padding.
 *
 *	Padding can be specified on a per side basis.  The fields
 *	side1 and side2 refer to the opposite sides, either
 *	horizontally or vertically.
 *
 *		side1	side2
 *              -----   -----
 *          x | left    right
 *	    y | top     bottom
 *
 *---------------------------------------------------------------------------
 */
typedef struct {
    unsigned short int side1, side2;
} Blt_Pad;

#define padLeft  	xPad.side1
#define padRight  	xPad.side2
#define padTop		yPad.side1
#define padBottom	yPad.side2
#define PADDING(x)	((x).side1 + (x).side2)

/*
 *---------------------------------------------------------------------------
 *
 * The following enumerated values are used as bit flags.
 *	FILL_NONE		Neither coordinate plane is specified 
 *	FILL_X			Horizontal plane.
 *	FILL_Y			Vertical plane.
 *	FILL_BOTH		Both vertical and horizontal planes.
 *
 *---------------------------------------------------------------------------
 */
#define FILL_NONE	0
#define FILL_X		1
#define FILL_Y		2
#define FILL_BOTH	3

/*
 *---------------------------------------------------------------------------
 *
 * Blt_Dashes --
 *
 * 	List of dash values (maximum 11 based upon PostScript limit).
 *
 *---------------------------------------------------------------------------
 */
typedef struct {
    unsigned char values[12];
    int offset;
} Blt_Dashes;

#define LineIsDashed(d) ((d).values[0] != 0)

/*
 * Blt_Limits --
 *
 * 	Defines the bounding of a size (width or height) in the paneset.  It may
 * 	be related to the widget, pane or paneset size.
 */
typedef struct {
    int flags;				/* Flags indicate whether using default
					 * values for limits or not. See flags
					 * below. */
    int max, min;			/* Values for respective limits. */
    int nom;				/* Nominal starting value. */
} Blt_Limits;

extern void Blt_SetDashes (Display *display, GC gc, Blt_Dashes *dashesPtr);

extern int Blt_ConfigureInfoFromObj(Tcl_Interp *interp, Tk_Window tkwin, 
	Blt_ConfigSpec *specs, char *widgRec, Tcl_Obj *objPtr, int flags);

extern int Blt_ConfigureValueFromObj(Tcl_Interp *interp, Tk_Window tkwin, 
	Blt_ConfigSpec *specs, char *widgRec, Tcl_Obj *objPtr, int flags);

extern int Blt_ConfigureWidgetFromObj(Tcl_Interp *interp, Tk_Window tkwin, 
	Blt_ConfigSpec *specs, int objc, Tcl_Obj *const *objv, char *widgRec, 
	int flags);

extern int Blt_ConfigureComponentFromObj(Tcl_Interp *interp, 
	Tk_Window tkwin, const char *name, const char *className, 
	Blt_ConfigSpec *specs, int objc, Tcl_Obj *const *objv, char *widgRec, 
	int flags);

extern int Blt_ConfigModified TCL_VARARGS(Blt_ConfigSpec *, specs);

extern const char *Blt_NameOfState(int state);

extern void Blt_FreeOptions(Blt_ConfigSpec *specs, char *widgRec, 
	Display *display, int needFlags);

extern int Blt_GetPixelsFromObj(Tcl_Interp *interp, Tk_Window tkwin, 
	Tcl_Obj *objPtr, int flags, int *valuePtr);

extern int Blt_GetPadFromObj(Tcl_Interp *interp, Tk_Window tkwin, 
	Tcl_Obj *objPtr, Blt_Pad *padPtr);

extern int Blt_GetStateFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 
	int *statePtr);

extern int Blt_GetFillFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 
	int *fillPtr);

extern int Blt_GetDashesFromObj(Tcl_Interp *interp, Tcl_Obj *objPtr, 
	Blt_Dashes *dashesPtr);

#endif /* BLT_CONFIG_H */