aboutsummaryrefslogtreecommitdiff
path: root/generic/Types.h
blob: 73bfd4ad419452ef5b808182646717c8d7e259a3 (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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
/*
 * Types.h -- Types used by the Zinc widget.
 *
 * Authors		: Patrick Lecoanet.
 * Creation date	: Mon Feb  1 12:13:24 1999
 *
 * $Id$
 */

/*
 *  Copyright (c) 1993 - 1999 CENA, Patrick Lecoanet --
 *
 * This code is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This code is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this code; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 *
 */


#ifndef _Types_h
#define _Types_h

#define NEED_REAL_STDIO
#include <tk.h>
#include <X11/Xutil.h>
#ifdef PTK
#include <tkVMacro.h>
#endif
#include <stdio.h>


#ifdef __CPLUSPLUS__
extern "C" {
#endif


typedef void		*ZnItemClassId;
typedef	void		*ZnItemId;

typedef double		ZnReal;	/* Keep it a double for GPC & libart. */
typedef int		ZnBool;	/* Keep it an int to keep Tk & GPC happy */
typedef ZnReal		ZnPos;
typedef ZnReal		ZnDim;
typedef XColor		*ZnColor;
typedef Tk_Font		ZnFont;
typedef Tk_Window	ZnWindow;
typedef void		*ZnPtr;
typedef Tk_Image	ZnImage;

typedef struct {
  ZnPos	x, y;
} ZnPoint;

typedef struct {
  ZnPos	x, y, w, h;
} ZnRect;

typedef struct {
  int		num_points;
  ZnPoint	*points;
} ZnContour;

/*
 * contour1/hole1 can be used to store a single contour
 * without having to alloc the holes & contours arrays.
 */
typedef struct {
  int		num_contours;
  ZnBool	*holes;
  ZnContour	*contours;
  ZnBool	*cw;
  ZnBool	hole1;
  ZnContour	contour1;
  ZnBool	cw1;
} ZnPoly;
  
/*
 * ZnBBox: orig is into the area while corner is not.
 * Thus the test: ((bbox.orig.x == bbox.corner.x) ||
 *                 (bbox.orig.y == bbox.corner.y))
 * tells whether the bbox is empty or not.
 * When interpreting bboxes the X coordinate system is
 * the norm. x goes from left toward the right and y
 * goes from the top toward the bottom. Bboxes are
 * always axes aligned.
 */
typedef struct {
  ZnPoint	orig, corner;
} ZnBBox;

/*
 * Operator constants for the coord method.
 */
#define COORDS_READ		0
#define COORDS_READ_ALL		1
#define COORDS_REPLACE		2
#define COORDS_REPLACE_ALL	3
#define COORDS_ADD		4
#define COORDS_ADD_LAST		5
#define COORDS_REMOVE		6
  
/*
 * Types and constants for attribute processing.
 */
typedef struct {
  int	type;
  char	*name;
  Tk_Uid uid;
  int	offset;
  int	bool_bit;
  int	flags;
  ZnBool read_only;
} ZnAttrConfig;

/*
 * When adding new type in the following enum
 * do not forget to update attribute_type_strings
 * in Item.c.
 */
#define	ZN_CONFIG_END		0
#define ZN_CONFIG_COLOR		1
#define ZN_CONFIG_BOOL		2
#define ZN_CONFIG_PATTERN	3
#define ZN_CONFIG_TEXT		4
#define ZN_CONFIG_FONT		5
#define ZN_CONFIG_BORDER	6
#define ZN_CONFIG_RELIEF	7
#define ZN_CONFIG_DIM		8
#define ZN_CONFIG_PRI		9
#define ZN_CONFIG_JUSTIFY	10
#define ZN_CONFIG_AUTO_JUSTIFY	11
#define ZN_CONFIG_LINE_END	12
#define ZN_CONFIG_LABEL_FORMAT	13
#define ZN_CONFIG_LINE_STYLE	14
#define ZN_CONFIG_LINE_SHAPE	15
#define ZN_CONFIG_ITEM		16
#define ZN_CONFIG_ANGLE		17
#define ZN_CONFIG_INT		18
#define ZN_CONFIG_UINT		19
#define ZN_CONFIG_POINT		20
#define ZN_CONFIG_RECT		21
#define ZN_CONFIG_PATTERNS	22
#define ZN_CONFIG_ANCHOR	23
#define ZN_CONFIG_TAGS		24
#define ZN_CONFIG_POINTS	25
#define ZN_CONFIG_MAP_INFO	26
#define ZN_CONFIG_IMAGE		27
#define ZN_CONFIG_LEADER_ANCHORS 28
#define ZN_CONFIG_JOIN_STYLE	29
#define	ZN_CONFIG_CAP_STYLE	30
#define	ZN_CONFIG_GRADIENT	31
#define	ZN_CONFIG_WINDOW	32

#define ZN_DRAW_FLAG	1 << 0
#define	ZN_COORDS_FLAG	1 << 1
#define ZN_TRANSFO_FLAG	1 << 2
#define	ZN_REPICK_FLAG	1 << 3
#define	ZN_BORDER_FLAG	1 << 4
#define	ZN_CLFC_FLAG	1 << 5	/* Clear Label Format Cache. */
#define ZN_IMAGE_FLAG	1 << 6	/* Update image pointer. */
#define ZN_VIS_FLAG	1 << 7	/* Visibility has changed. */
#define ZN_MOVED_FLAG	1 << 8	/* Item has moved. */
#define ZN_ITEM_FLAG	1 << 9	/* Signal a change in an item type attribute. */
#define ZN_MAP_INFO_FLAG	1 << 10	/* Update mapinfo pointer. */
#define ZN_LAYOUT_FLAG	1 << 10	/* A layout need update. */
#define ZN_POLAR_FLAG	1 << 11	/* Signal a cartesian to polar change. */
#define ZN_CARTESIAN_FLAG	1 << 12	/* Signal a polar to cartesian change. */
#define ZN_TILE_FLAG	1 << 13	/* Update tile pointer. */
#define ZN_WINDOW_FLAG	1 << 14	/* Signal a change in a window type attribute. */

/*
 * Type and constant values for alignments.
 */
typedef char	ZnJustify;
#define ZnJustifyLeft	TK_JUSTIFY_LEFT
#define ZnJustifyRight	TK_JUSTIFY_RIGHT
#define ZnJustifyCenter	TK_JUSTIFY_CENTER

/*
 * Type and constant values for anchors.
 */
typedef Tk_Anchor	ZnAnchor;
#define ZnAnchorN	TK_ANCHOR_N
#define ZnAnchorS	TK_ANCHOR_S
#define ZnAnchorE	TK_ANCHOR_E
#define ZnAnchorW	TK_ANCHOR_W
#define ZnAnchorNE	TK_ANCHOR_NE
#define ZnAnchorNW	TK_ANCHOR_NW
#define ZnAnchorSE	TK_ANCHOR_SE
#define ZnAnchorSW	TK_ANCHOR_SW
#define ZnAnchorCenter	TK_ANCHOR_CENTER

/*
 * Type and constant values for borders.
 */
typedef unsigned char	Border;
#define NO_BORDER	0
#define LEFT_BORDER	1
#define RIGHT_BORDER	2
#define TOP_BORDER	4
#define BOTTOM_BORDER	8
#define CONTOUR_BORDER	(LEFT_BORDER|RIGHT_BORDER|TOP_BORDER|BOTTOM_BORDER)
#define COUNTER_OBLIQUE	16
#define OBLIQUE		32

#define LEFT_SPEC		"left"
#define RIGHT_SPEC		"right"
#define	TOP_SPEC		"top"
#define BOTTOM_SPEC		"bottom"
#define CONTOUR_SPEC		"contour"
#define COUNTER_OBLIQUE_SPEC	"counteroblique"
#define OBLIQUE_SPEC		"oblique"
#define NO_BORDER_SPEC		"noborder"

/*
 * Type and constant values for line styles, line shapes and line ends.
 */
typedef unsigned char	LineStyle;
typedef unsigned char	LineEndStyle;
typedef unsigned char	LineShape;

/* LineStyle */
#define LINE_SIMPLE			0
#define LINE_DASHED			1
#define LINE_MIXED			2
#define LINE_DOTTED			3
/* LineShape */
#define LINE_STRAIGHT			0
#define LINE_LEFT_LIGHTNING        	1
#define LINE_LEFT_CORNER		2
#define LINE_DOUBLE_LEFT_CORNER		3
#define LINE_RIGHT_LIGHTNING		4
#define LINE_RIGHT_CORNER		5
#define LINE_DOUBLE_RIGHT_CORNER	6

#define SIMPLE_SPEC		"simple"
#define	DASHED_SPEC		"dashed"
#define DOTTED_SPEC		"dotted"
#define	MIXED_SPEC		"mixed"

#define STRAIGHT_SPEC		"straight"
#define RIGHT_LIGHTNING_SPEC	"rightlightning"
#define LEFT_LIGHTNING_SPEC	"leftlightning"
#define RIGHT_CORNER_SPEC	"rightcorner"
#define LEFT_CORNER_SPEC	"leftcorner"
#define DOUBLE_RIGHT_CORNER_SPEC  "doublerightcorner"
#define DOUBLE_LEFT_CORNER_SPEC	"doubleleftcorner"

/*
 * Type and constant values for relief styles.
 */
typedef int	ReliefStyle;	/* Keep it an int to keep Tk happy */
#define RELIEF_BEVEL_OUT	TK_RELIEF_RAISED
#define RELIEF_FLAT		TK_RELIEF_FLAT
#define RELIEF_BEVEL_IN		TK_RELIEF_SUNKEN
#define RELIEF_GROOVE		TK_RELIEF_GROOVE
#define RELIEF_RIDGE		TK_RELIEF_RIDGE
/*
 * Number of steps for relief drawing. This translate in
 * RELIEF_STEPS*2+1 color shades in the color gradient.
 */
#define RELIEF_STEPS		6
#define DEFAULT_NUM_SHADES	6
  
/*
 * Types of gradients.
 */
#define ZN_AXIAL_GRADIENT	0
#define ZN_RADIAL_GRADIENT	1

/*
 * Type and constant values for automatic alignments.
 */
typedef struct {
  ZnBool	automatic;
  ZnJustify	align[3];
} AutoAlign;
#define AA_LEFT			0
#define AA_CENTER		1
#define AA_RIGHT		2

#define AA_LEFT_SPEC		"l"
#define AA_CENTER_SPEC		"c"
#define AA_RIGHT_SPEC		"r"
#define AA_AUTO_SPEC		"-"

/*
 * Type for leader anchors.
 */
typedef struct {
  int		left_x;		/* left leader anchor field or percent of bbox */
  int		right_x;	/* right leader anchor field or percent of bbox */
  short		left_y;		/* left leader percent of bbox or < 0 if field */
  short		right_y;	/* right leader percent of bbox or < 0 if field */
} LeaderAnchorsStruct, *LeaderAnchors;

#define ZnPixel(color)		((color)->pixel)
#define ZnFontId(font)		(Tk_FontId(font))
#define ZnWindowId(win)		(Tk_WindowId(win))
#define ZnTextWidth(font, text, len) (Tk_TextWidth(font, text, len))
#define ZnMalloc(size)		(ckalloc(size))
#define ZnFree(ptr)		(ckfree((char *)(ptr)))
#define ZnRealloc(ptr, size)	(ckrealloc((void *)(ptr), size))
#define ZnWarning(msg)		(fprintf(stderr, "%s\n", (msg)))
  
#define ZnUnspecifiedPattern	None
#define ZnUnspecifiedImage	None
#define ZnUnspecifiedColor	NULL
#define ZN_OK			TCL_OK
#define ZN_ERROR		TCL_ERROR
#define ZN_NO_ITEM		NULL

/*
 * Various constants used by items.
 */
#define ZN_ANY_CIRCLES		-1

/*
 * Constants for item parts. The fields or item indexable parts are coded
 * as positive or null integers. The item specific parts (not indexable) are
 * coded as negatives begining at -2 up to -9 which is the current limit. The
 * -1 value is reserved to indicate no part.
 */

#define PART_NUMBER_TO_BIT(part)	(1 << (ABS(part)-2))
#define ZN_NO_PART		-1


/*
 * Some flags macros.
 */
#define ISSET(var, mask)	((var) & (mask))
#define ISCLEAR(var, mask)	(((var) & (mask)) == 0)
#define SET(var,mask)		((var) |= (mask))
#define CLEAR(var, mask)	((var) &= ~(mask))
#define ASSIGN(var, mask, bool)	((bool) ? SET((var), (mask)) : CLEAR((var), (mask)))


#ifdef __CPLUSPLUS__
}
#endif

#endif /* _Types_h */