1 /*
2  * @(#)gremlin.h	1.1	10/21/84
3  *
4  * Standard definitions used by the SUN Gremlin picture editor.
5  *
6  * Mark Opperman (opcode@monet.BERKELEY)
7  *
8  */
9 
10 #include <stdio.h>
11 #include <math.h>
12 
13 #define nullpt  -1
14 
15 #define MAXPOINTS 200
16 
17 #define pixmask     1
18 #define csetmask    2
19 #define scratchmask 4
20 
21 #define BOTLEFT 0
22 #define BOTRIGHT 1
23 #define CENTCENT 2
24 #define VECTOR 3
25 #define ARC 4
26 #define CURVE 5
27 #define POLYGON 6
28 #define TOPLEFT 10
29 #define TOPCENT 11
30 #define TOPRIGHT 12
31 #define CENTLEFT 13
32 #define CENTRIGHT 14
33 #define BOTCENT 15
34 #define TEXT(t) ( ((t) <= CENTCENT) || ((t) >= TOPLEFT) )
35 /* WARNING * WARNING * WARNING * WARNING * WARNING * WARNING * WARNING
36  *    The above (TEXT) test is dependent on the relative values of the
37  *    constants and will have to change if these values change or if new
38  *    commands are added with value greater than BOTCENT
39  */
40 
41 
42 #define RFONT 0
43 #define IFONT 1
44 #define BFONT 2
45 #define SFONT 3
46 
47 #define NOADJ 0
48 #define HORZ  1
49 #define VERT  2
50 #define MAN   3
51 
52 #define NUSER 4
53 #define NFONTS 4
54 #define NBRUSHES 6
55 #define NSIZES 4
56 #define NSTIPPLES 8
57 #define NJUSTS 9
58 #define JUSTMODES 17
59 
60 #define ADD 1
61 #define DELETE 2
62 #define MOD 3
63 
64 #define Delimiter(c) ((c == '\0') || (c == ' ') || (c == '\t'))
65 
66 #define MINMAX(min, max, val)   if (val < min) \
67 				    min = val; \
68 				else if (val > max) \
69 				    max = val;
70 
71 /* The following represents the maximum distance a point may be from another
72  * and still be affected by gravity.  The distance is represented as the
73  * square of the number of pixels (32) of the actual distance.
74  */
75 
76 #define MAXGDIST 1024	/* 32 * 32 */
77 
78 typedef struct point {
79 	    float x, y;
80 	    struct point *nextpt;
81         } POINT;
82 
83 typedef struct elmt {
84 	    int type, brushf, size, textlength;
85 	    char *textpt;
86 	    POINT *ptlist;
87 	    struct elmt *nextelt, *setnext;
88         } ELT;
89 
90 typedef struct unlt {
91 	    int action;
92 	    ELT *(*dbase), *oldelt, *newelt;
93 	    struct unlt *nextun;
94         } UNELT;
95 
96 
97 /*
98  * database macros
99  */
100 
101 #define DBInit()	  ((ELT *) NULL)
102 #define DBNextElt(elt)    ((elt)->nextelt)
103 #define DBNextofSet(elt)  ((elt)->setnext)
104 #define DBNullelt(elt)    ((elt) == NULL)
105 
106 #define PTInit()	  ((POINT *) NULL)
107 #define PTNextPoint(pt)   ((pt)->nextpt)
108 #define Nullpoint(pt)     ((pt) == (POINT *) NULL)
109 
110 
111 /* sun version parameters */
112 
113 /* icon display parameters */
114 
115 #define ICON_SIZE  16
116 #define ICON_BORDER  8
117 
118 #define MENU_TOP  0	/* 17 */
119 #define MENU_LEFT  0
120 #define MENU_RIGHT  104
121 #define MENU_BOTTOM  1000
122 #define MENU_COLUMNS  4
123 
124 #define MENU_X  (ICON_SIZE + ICON_BORDER)
125 #define MENU_Y  (ICON_SIZE + ICON_BORDER)
126 
127 /* subwindow stuff */
128 
129 #define TEXTSW_HEIGHT 33
130 #define MENUSW_WIDTH 104
131 #define PIXSW_WIDTH 512
132 #define PIXSW_HEIGHT 512
133 
134 #define stipple1_pr  white_pr
135 #define stipple2_pr  gray_pr
136 #define stipple3_pr  _50_pr
137 #define stipple4_pr  black_pr
138 
139 #define is_stipple(pr)  (((pr) == &stipple1_pr) || ((pr) == &stipple2_pr) || \
140 			 ((pr) == &stipple3_pr) || ((pr) == &stipple4_pr) || \
141 			 ((pr) == &stipple5_pr) || ((pr) == &stipple6_pr) || \
142 			 ((pr) == &stipple7_pr) || ((pr) == &stipple8_pr))
143 
144 #define winx_to_db(x) ((float) ((x) + SUN_XORIGIN))
145 #define winy_to_db(y) ((float) (SUN_YORIGIN - (y)))
146 #define dbx_to_win(x) (((int) (x)) - SUN_XORIGIN)
147 #define dby_to_win(y) (SUN_YORIGIN  - ((int) (y)))
148 
149 struct _menu {
150 	    int menu_x;				/* icon x coordinate */
151 	    int menu_y;				/* icon y coordinate */
152 	    struct pixrect *menu_icon;		/* icon pixrect pointer */
153 	    int (*menu_function)();		/* left button function */
154 	    int (*menu_modify)();		/* middle button function */
155 	    int (*menu_help)();			/* right button function */
156 	};
157 
158 #define TEXT_BASELINE  10
159 #define TEXT_BUFMAX  128
160 
161 #ifndef TRUE
162 #define TRUE (1)
163 #define FALSE (0)
164 #endif
165