aboutsummaryrefslogtreecommitdiff
path: root/generic/Types.h
blob: a508402567d1f1a59793dcdbb3ff626c978b727c (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
354
355
356
357
/*
 * Types.h -- Types used by the Radar 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

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


#ifdef __CPLUSPLUS__
extern "C" {
#endif


#ifndef PTK
#define Arg                       char *
#define LangFreeProc              void
#define LangString(p)	          (p)
#define LangCopyArg(p)	          (p)
#define LangStringArg(p)          (p)
#define LangSetString(a,b)        (*(a)=(b))
#define LangSetArg(a,b)           (*(a)=(b))
#define Lang_SplitList(a,b,c,d,e) (Tcl_SplitList(a,b,c,d))
#endif

  
typedef void		*RadarItemClassId;
typedef	void		*RadarItemId;

typedef double		RadarReal;
typedef int		RadarBool;	/* Keep it an int to keep Tk happy */
typedef RadarReal	RadarPos;
typedef RadarReal	RadarDim;
typedef XColor		*RadarColor;
typedef Tk_Font		RadarFont;
typedef Tk_Window	RadarWindow;
typedef void		*RadarPtr;
typedef Tk_Image	RadarImage;
typedef Arg		*RadarAttrList;

typedef struct {
  RadarPos	x, y;
} RadarPoint;

typedef struct {
  RadarPos	x, y, w, h;
} RadarRect;
/*
 * RadarBBox: 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 {
  RadarPoint	orig, corner;
} RadarBBox;

/*
 * Describe the clipping at a given node
 * of the item hierarchy.
 */
typedef struct {
  RadarBool	simple;		/* The clip is an aligned rectangle.	*/
  Region	region;		/* The X region used to draw and to	*/
				/* probe for picking.			*/
  RadarBBox	clip_box;	/* The bounding box of the clip area.	*/
} ClipState;

/*
 * 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;
  RadarBool read_only;
} RadarAttrConfig;

/*
 * When adding new type in the following enum
 * do not forget to update attribute_type_strings
 * in Item.c.
 */
#define	RADAR_CONFIG_END	0
#define RADAR_CONFIG_COLOR	1
#define RADAR_CONFIG_BOOL	2
#define RADAR_CONFIG_PATTERN	3
#define RADAR_CONFIG_TEXT	4
#define RADAR_CONFIG_FONT	5
#define RADAR_CONFIG_BORDER	6
#define RADAR_CONFIG_RELIEF	7
#define RADAR_CONFIG_DIM	8
#define RADAR_CONFIG_PRI	9
#define RADAR_CONFIG_JUSTIFY	10
#define RADAR_CONFIG_AUTO_JUSTIFY 11
#define RADAR_CONFIG_LINE_END	12
#define RADAR_CONFIG_LABEL_FORMAT 13
#define RADAR_CONFIG_LINE_STYLE	14
#define RADAR_CONFIG_LINE_SHAPE	15
#define RADAR_CONFIG_ITEM	16
#define RADAR_CONFIG_ANGLE	17
#define RADAR_CONFIG_INT	18
#define RADAR_CONFIG_UINT	19
#define RADAR_CONFIG_POINT	20
#define RADAR_CONFIG_RECT	21
#define RADAR_CONFIG_PATTERNS	22
#define RADAR_CONFIG_ANCHOR	23
#define RADAR_CONFIG_TAGS	24
#define RADAR_CONFIG_POINTS	25
#define RADAR_CONFIG_MAP_INFO	26
#define RADAR_CONFIG_IMAGE	27
#define RADAR_CONFIG_LEADER_ANCHORS 28
#define RADAR_CONFIG_JOIN_STYLE	29
#define	RADAR_CONFIG_CAP_STYLE	30
  
#define RADAR_DRAW_FLAG		1 << 0
#define	RADAR_COORDS_FLAG	1 << 1
#define RADAR_TRANSFO_FLAG	1 << 2
#define	RADAR_REPICK_FLAG	1 << 3
#define	RADAR_BORDER_FLAG	1 << 4
#define	RADAR_CLFC_FLAG		1 << 5	/* Clear Label Format Cache. */
#define RADAR_IMAGE_FLAG	1 << 6	/* Update image pointer. */
#define RADAR_VIS_FLAG		1 << 7	/* Visibility has changed. */
#define RADAR_MOVED_FLAG	1 << 8	/* Item has moved. */
#define RADAR_ITEM_FLAG		1 << 9	/* Signal a change in item type attribute. */
#define RADAR_MAP_INFO_FLAG	1 << 10	/* Update mapinfo pointer. */
#define RADAR_LAYOUT_FLAG	1 << 10	/* A layout need update. */
#define RADAR_POLAR_FLAG	1 << 11	/* Signal a cartesian to polar change. */
#define RADAR_CARTESIAN_FLAG	1 << 12	/* Signal a polar to cartesian change. */
#define RADAR_TILE_FLAG		1 << 13	/* Update tile pointer. */

/*
 * Type and constant values for alignments.
 */
typedef char	RadarJustify;
#define RadarJustifyLeft	TK_JUSTIFY_LEFT
#define RadarJustifyRight	TK_JUSTIFY_RIGHT
#define RadarJustifyCenter	TK_JUSTIFY_CENTER

/*
 * Type and constant values for anchors.
 */
typedef Tk_Anchor	RadarAnchor;
#define RadarAnchorN	TK_ANCHOR_N
#define RadarAnchorS	TK_ANCHOR_S
#define RadarAnchorE	TK_ANCHOR_E
#define RadarAnchorW	TK_ANCHOR_W
#define RadarAnchorNE	TK_ANCHOR_NE
#define RadarAnchorNW	TK_ANCHOR_NW
#define RadarAnchorSE	TK_ANCHOR_SE
#define RadarAnchorSW	TK_ANCHOR_SW
#define RadarAnchorCenter	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 steps in the color gradient.
 */
#define RELIEF_STEPS	2

/*
 * Type and constant values for automatic alignments.
 */
typedef struct {
  RadarBool	automatic;
  RadarJustify	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 RadarPixel(color)	((color)->pixel)
#define RadarFontId(font)	(Tk_FontId(font))
#define RadarWindowId(win)	(Tk_WindowId(win))
#define RadarTextWidth(font, text, len) (Tk_TextWidth(font, text, len))
#define RadarMalloc(size)	(ckalloc(size))
#define RadarFree(ptr)		(ckfree((char *)(ptr)))
#define RadarRealloc(ptr, size)	(ckrealloc((void *)(ptr), size))
/*
 * How to make ptk include the right stdio.h ?
 */
#ifndef PTK
#define RadarWarning(msg)	(fprintf(stderr, "%s\n", (msg)))
#else
#define RadarWarning(msg)
#endif
  
#define RadarUnspecifiedPattern	None
#define RadarUnspecifiedImage	None
#define RadarUnspecifiedColor	NULL
#define RADAR_OK		TCL_OK
#define RADAR_ERROR		TCL_ERROR
#define RADAR_NO_ITEM		NULL

/*
 * Various constants used by items.
 */
#define RADAR_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 RADAR_NO_PART		-1
#define RADAR_CURRENT_POSITION	-2
#define RADAR_SPEED_VECTOR	-3
#define RADAR_LEADER		-4
#define RADAR_CONNECTION	-5


/*
 * 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 */