|
|
1.1 root 1: /*
2: %Z% %M% version %I% %Q%of %H% %T%
3: Last Delta: %G% %U% to %P%
4: */
5: #include <stdio.h>
6: #include <jerq.h>
7: #define abs(A) ((A)<0 ? -(A) : (A))
8: #define isletter(C) ((C>='a' && (C)<='z') || (C>='A' && (C)<='Z'))
9: #define isdigit(C) (C>='0' && (C)<='9')
10: #define MOUSE_XY (sub(mouse.xy, Pt(1,1)))
11:
12: #define BORDER 4
13: #define BrushSize 60 /* Height of brush frame */
14: #define ButSize 60 /* Height of button frame */
15: #define LW 2 /* line width for frame boxes */
16: #define MW 5 /* Margin width between frames*/
17: #define Xmin BORDER /* left edge of frame */
18: #define Xmax (Drect.corner.x - BORDER) /* right edge of frame */
19: #define XPicSize (Drect.corner.x - 2 * (LW + BORDER)) /* Width of Pic frame */
20: #define Ymin BORDER /* top of frame */
21: #define Ymax (Drect.corner.y - BORDER) /* bottom of frame */
22: #define YBR (Ymin+LW+MW+BrushSize+LW) /* bottom of brush frame */
23: #define YPIC (YBR+MW) /* top of drawing frame */
24: #define Ybut (Ymax - ButSize - 2 * LW) /* Top of button frame */
25: #define YBOT (Ybut - MW) /* bottom of drawing frame */
26: #define YPicSize (YBOT - YPIC) /* Height of Pic frame */
27: #define YCEN ((YBR+Ymin)>>1) /* center line of brush area */
28: #define Xbut (((Xmax-Xmin)<<1)/3)
29: #define XeditD ((Xmax-Xmin)/2)
30: #define Xtext (Xmin+LW)
31: #define Ytext (Ybut+ButSize/6)
32: #define butHt min(((ButSize-(LW<<2))/3), ((Xmax-Xbut-(3*LW))/18))
33:
34: #define TNULL (struct thing *)0
35:
36: #define CIRCLE 0
37: #define BOX 1
38: #define ELLIPSE 2
39: #define LINE 3
40: #define ARC 4
41: #define SPLINE 5
42: #define TEXT 6
43: #define MACRO 7
44: #define REVLINE 8 /* Special case for spline editing only! */
45: #define NUMBR 7
46: #define DXBR ((Xmax-Xmin)/NUMBR)
47:
48: #define MAXTEXT 100
49: #define MAXNAMESIZE 64
50:
51: #define PIC NUMBR
52: #define ED PIC+1
53: #define BRUSH PIC+1
54: #define GROWCIRCLE BRUSH+1
55: #define MOVE BRUSH+2
56: #define GROWEWID BRUSH+3
57: #define GROWEHT BRUSH+4
58:
59: #define RADdefault ((Xmax-Xmin)/24)
60: #define WIDdefault ((Xmax-Xmin)/8)
61: #define HTdefault ((Xmax-Xmin)/12)
62: #define nearlyStraight 5
63: #define nearEDGE 5
64: #define nearPT 8
65:
66: #define SOLID 0
67: #define DASHED 1
68: #define DOTTED 2
69: #define startARROW 1
70: #define endARROW 2
71: #define doubleARROW 3
72:
73: #define ROMAN 1
74: #define ITALIC 2
75: #define BOLD 3
76: #define DEFONT 4
77: #define CENTER 0
78: #define LEFTJUST 1
79: #define RIGHTJUST 2
80: #define POINTSIZE 10
81:
82: #define GRIDon 1
83: #define GRIDoff 0
84:
85: #define WHITEfield 1
86: #define BLACKfield 0
87:
88: #define INITbuttons 0
89: #define DRAWbuttons 1
90: #define EDITbuttons 2
91: #define SPLINEbuttons 3
92: #define BLANKbuttons 4
93: #define MACRObuttons 5
94: #define COPYbuttons 6
95: #define MOVEbuttons 7
96: #define QUITbuttons 8
97: #define READbuttons 9
98: #define numButtonStates 10
99:
100: #define fontBlk struct FONTBlk
101: struct FONTBlk {
102: short ps, num, useCount;
103: Font *f;
104: fontBlk *next, *last;
105: };
106:
107: typedef struct {
108: Point start, end;
109: } pointPair;
110:
111: typedef struct {
112: short ht, wid;
113: } intPair;
114:
115: typedef struct {
116: short used, size;
117: Point *plist
118: } pointStream;
119:
120: typedef struct {
121: short just;
122: char *s;
123: fontBlk *f;
124: } textString;
125:
126: struct macro {
127: char *name;
128: short outName;
129: short useCount;
130: Rectangle bb;
131: struct thing *parts;
132: struct macro *next;
133: struct macro *xReflectionOf, *yReflectionOf;
134: };
135:
136: struct thing {
137: short type;
138: Point origin;
139: Rectangle bb;
140: union {
141: short brush;
142: short radius;
143: Point corner;
144: Point end;
145: pointPair arc;
146: intPair ellipse;
147: textString text;
148: pointStream spline;
149: struct macro *list;
150: } otherValues;
151: short arrow, boorder;
152: struct thing *next, *last;
153: };
154:
155: extern fontBlk *fonts;
156:
157: extern Rectangle *Select();
158: extern Rectangle moveBox();
159: extern Rectangle macroBB();
160: extern Rectangle canon();
161:
162: extern struct macro *recordMacro();
163:
164: extern struct thing *newCircle();
165: extern struct thing *newBox();
166: extern struct thing *newEllipse();
167: extern struct thing *newLine();
168: extern struct thing *newArc();
169: extern struct thing *newText();
170: extern struct thing *newSpline();
171: extern struct thing *newMacro();
172: extern struct thing *selectThing();
173: extern struct thing *copyThing();
174: extern struct thing *deleteThing();
175: extern struct thing *deleteAllThings();
176: extern struct thing *insert();
177: extern struct thing *remove();
178: extern struct thing *doMouseButtons();
179: extern struct thing *place();
180: extern struct thing *displayCommandMenu();
181: extern struct thing *displayThingMenu();
182: extern struct thing *doGet();
183: extern struct thing *doClear();
184: extern struct thing *defineMacro();
185: extern struct thing *makeRelative();
186: extern struct thing *reflect();
187:
188: extern Point track();
189: extern Point track2();
190: extern Point computeArcOrigin();
191: extern Point near();
192: extern Point jchar();
193: extern Point PtCurrent;
194:
195: extern char *getString();
196: extern char *getSpace();
197:
198: extern FILE *popen();
199:
200: extern fontBlk *findFont();
201:
202: extern xtipple ();
203:
204: extern Cursor carrot, crossHairs, prompt, hourglass,
205: pointsize, candle, rusure;
206: extern Texture grid, plain, rvplain;
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.