1 /*-------------------------------------------------------------------------*/
2 /* menus.h								   */
3 /* Copyright (c) 2002  Tim Edwards, Johns Hopkins University        	   */
4 /*-------------------------------------------------------------------------*/
5 
6 /*-------------------------------------------------------------------------*/
7 /* Hierarchical menus must be listed in bottom-up order			   */
8 /*-------------------------------------------------------------------------*/
9 /* Note:  underscore (_) before name denotes a color to paint the button.  */
10 /*	  colon (:) before name denotes a stipple, defined by the data	   */
11 /*		    passed to setfill().				   */
12 /*-------------------------------------------------------------------------*/
13 
14 #ifdef _MENUDEP
15 
16 #define submenu(a)      a, (sizeof (a) / sizeof(menustruct)), NULL, NULL
17 #define action(b,c)     NULL, 0, NULL, NULL
18 #define setaction(b,c)  NULL, 1, NULL, NULL
19 #define toolaction(b,c) NULL, NULL
20 #define noaction        NULL, 0, NULL, NULL
21 #define offset(a)	0
22 
23 #else                   /* real definitions. . .*/
24 
25 #define submenu(a)	a, (sizeof (a) / sizeof(menustruct)), \
26 			(XtCallbackProc)DoNothing, NULL
27 #define action(b,c)	NULL, 0, (XtCallbackProc)b, c
28 #define setaction(b,c)	NULL, 1, (XtCallbackProc)b, c
29 #define toolaction(b,c) (XtCallbackProc)b, c
30 #define noaction	NULL, 0, (XtCallbackProc)DoNothing, NULL
31 #define offset(a)	Number(XtOffset(XCWindowDataPtr, a))
32 
33 #endif
34 
35 /* Inclusions for pixmap icons */
36 
37 #include "tool_bar.h"
38 
39 /* Things commented out here are reminders of future implementations. */
40 
41 menustruct Fonts[] = {
42 	{"Add New Font", action(addnewfont, NULL)},
43 	{" ", noaction},
44 };
45 
46 /* Note the unorthodox passing of integer constants through type pointer */
47 
48 menustruct FontStyles[] = {
49 	{"Normal", setaction(fontstyle, Number(0))},
50 	{"Bold", action(fontstyle, Number(1))},
51 	{"Italic", action(fontstyle, Number(2))},
52 	{"BoldItalic", action(fontstyle, Number(3))},
53 	{" ", noaction},
54 	{"Subscript", action(addtotext, Number(SUBSCRIPT))},
55 	{"Superscript", action(addtotext, Number(SUPERSCRIPT))},
56 	{"Normalscript", action(addtotext, Number(NORMALSCRIPT))},
57 	{" ", noaction},
58 	{"Underline", action(addtotext, Number(UNDERLINE))},
59 	{"Overline", action(addtotext, Number(OVERLINE))},
60 	{"No line", action(addtotext, Number(NOLINE))},
61 };
62 
63 menustruct FontEncodings[] = {
64 	{"Standard", action(fontencoding, Number(0))},
65 	{"ISO-Latin1", setaction(fontencoding, Number(2))},
66 };
67 
68 menustruct TextSpacing[] = {
69 	{"Tab stop", action(addtotext, Number(TABSTOP))},
70 	{"Tab forward", action(addtotext, Number(TABFORWARD))},
71 	{"Tab backward", action(addtotext, Number(TABBACKWARD))},
72 	{"Carriage Return", action(addtotext, Number(RETURN))},
73 	{"1/2 space", action(addtotext, Number(HALFSPACE))},
74 	{"1/4 space", action(addtotext, Number(QTRSPACE))},
75 	{"Kern", action(getkern, NULL)},
76 	{"Character", action(addtotext, Number(SPECIAL))},
77 };
78 
79 menustruct Anchors[] = {
80 	{"Left Anchored", setaction(sethanchor, Number(NORMAL))},
81 	{"Center Anchored", action(sethanchor, Number(NOTLEFT))},
82 	{"Right Anchored", action(sethanchor, Number(NOTLEFT | RIGHT))},
83 	{" ", noaction},
84 	{"Top Anchored", action(setvanchor, Number(NOTBOTTOM | TOP))},
85 	{"Middle Anchored", action(setvanchor, Number(NOTBOTTOM))},
86 	{"Bottom Anchored", setaction(setvanchor, Number(NORMAL))},
87 	{" ", noaction},
88 	{"Flip Invariant", setaction(setanchorbit, Number(FLIPINV))},
89 };
90 
91 menustruct BoxEditStyles[] = {
92 	{"Manhattan Box Edit", setaction(boxedit, Number(MANHATTAN))},
93 	{"Rhomboid X", action(boxedit, Number(RHOMBOIDX))},
94 	{"Rhomboid Y", action(boxedit, Number(RHOMBOIDY))},
95 	{"Rhomboid A", action(boxedit, Number(RHOMBOIDA))},
96 	{"Normal", action(boxedit, Number(NORMAL))},
97 };
98 
99 menustruct GridStyles[] = {
100 	{"Decimal Inches", action(getgridtype, Number(DEC_INCH))},
101 	{"Fractional Inches", setaction(getgridtype, Number(FRAC_INCH))},
102 	{"Centimeters", action(getgridtype, Number(CM))},
103 	{" ", noaction},
104 	{"Drawing Scale", action(getdscale, NULL)},
105 };
106 
107 menustruct Libraries[] = {
108 	{"Add New Library", action(newlibrary, NULL)},
109 	{" ", noaction},
110 	{"Library 1", action(startcatalog, Number(LIBRARY))},
111 	{"Library 2", action(startcatalog, Number(LIBRARY + 1))},
112 };
113 
114 menustruct Pages[] = {
115 	{"Add New Page", action(newpagemenu, Number(255))},
116 	{" ", noaction},
117 	{"Page 1", action(newpagemenu, Number(0))},
118 	{"Page 2", action(newpagemenu, Number(1))},
119 	{"Page 3", action(newpagemenu, Number(2))},
120 	{"Page 4", action(newpagemenu, Number(3))},
121 	{"Page 5", action(newpagemenu, Number(4))},
122 	{"Page 6", action(newpagemenu, Number(5))},
123 	{"Page 7", action(newpagemenu, Number(6))},
124 	{"Page 8", action(newpagemenu, Number(7))},
125 	{"Page 9", action(newpagemenu, Number(8))},
126 	{"Page 10", action(newpagemenu, Number(9))}
127 };
128 
129 menustruct BorderStyles[] = {
130 	{"Linewidth", action(getwwidth, NULL)},
131 	{" ", noaction},
132 	{"Solid", setaction(setline, Number(NORMAL))},
133 	{"Dashed", action(setline, Number(DASHED))},
134 	{"Dotted", action(setline, Number(DOTTED))},
135 	{"Unbordered", action(setline, Number(NOBORDER))},
136 	{" ", noaction},
137 	{"Closed", action(setclosure, Number(UNCLOSED))},
138 	{"Bounding Box", action(makebbox, Number(BBOX))},
139 };
140 
141 menustruct Colors[] = {
142 	{"Add New Color", action(addnewcolor, NULL)},
143 	{" ", noaction},
144 	{"Inherit Color", setaction(setcolor, Number(1))},
145 	{"_Black", action(setcolor, NULL)},
146 	{"_White", action(setcolor, NULL)},
147 };
148 
149 menustruct Parameterize[] = {
150 	{"Substring", action(promptparam, NULL)},
151 	{"Numeric", action(startparam, Number(P_NUMERIC))},
152 	{"Style", action(startparam, Number(P_STYLE))},
153 	{"Anchoring", action(startparam, Number(P_ANCHOR))},
154 	{"Start Angle", action(startparam, Number(P_ANGLE1))},
155 	{"End Angle", action(startparam, Number(P_ANGLE2))},
156 	{"Radius", action(startparam, Number(P_RADIUS))},
157 	{"Minor Axis", action(startparam, Number(P_MINOR_AXIS))},
158 	{"Rotation", action(startparam, Number(P_ROTATION))},
159 	{"Scale", action(startparam, Number(P_SCALE))},
160 	{"Linewidth", action(startparam, Number(P_LINEWIDTH))},
161 	{"Color", action(startparam, Number(P_COLOR))},
162 	{"Position", action(startparam, Number(P_POSITION))},
163 };
164 
165 menustruct Stipples[] = {
166 	{":Black",  action(setfill, Number(OPAQUE | FILLED | FILLSOLID))},
167 	{":Gray12", action(setfill, Number(OPAQUE | FILLED | STIP2 | STIP1))},
168 	{":Gray25", action(setfill, Number(OPAQUE | FILLED | STIP2 | STIP0))},
169 	{":Gray37", action(setfill, Number(OPAQUE | FILLED | STIP2))},
170 	{":Gray50", action(setfill, Number(OPAQUE | FILLED | STIP0 | STIP1))},
171 	{":Gray62", action(setfill, Number(OPAQUE | FILLED | STIP1))},
172 	{":Gray75", action(setfill, Number(OPAQUE | FILLED | STIP0))},
173 	{":Gray87", action(setfill, Number(OPAQUE | FILLED))},
174 	{":White", setaction(setfill, Number(FILLSOLID))},
175 	{" ", noaction},
176 	{"Opaque", action(setopaque, Number(OPAQUE))},
177 	{"Transparent", setaction(setopaque, Number(NORMAL))},
178 };
179 
180 menustruct TextMenu[] = {
181 	{"Text Size", action(gettsize, NULL)},
182 	{"Font", submenu(Fonts)},
183 	{"Style", submenu(FontStyles)},
184 	{"Encoding", submenu(FontEncodings)},
185 	{"Insert", submenu(TextSpacing)},
186 	{"Anchoring (keypad)", submenu(Anchors)},
187 	{"Parameterize", action(promptparam, NULL)},
188 	{"Unparameterize", action(startunparam, Number(P_SUBSTRING))},
189 	{" ", noaction},
190 	{"Set LaTeX Mode", action(setanchorbit, Number(LATEXLABEL))},
191 	{" ", noaction},
192 	{"Make Label (t)", action(changetool, Number(XCF_Text))},
193 };
194 
195 menustruct PolyMenu[] = {
196 	{"Border", submenu(BorderStyles)},
197 	{"Fill", submenu(Stipples)},
198 	{"Color", submenu(Colors)},
199 	{" ", noaction},
200 	{"Object size", action(getosize, NULL)},
201 	{"Parameters", submenu(Parameterize)},
202 	{"Center Object", setaction(toggle, offset(center))},
203 	{"Manhattan Draw", action(toggle, offset(manhatn))},
204 	{"Polygon Edit", submenu(BoxEditStyles)},
205 };
206 
207 menustruct FilterMenu[] = {
208 	{"Labels", setaction(selectfilter, Number(LABEL))},
209 	{"Objects", setaction(selectfilter, Number(OBJINST))},
210 	{"Polygons", setaction(selectfilter, Number(POLYGON))},
211 	{"Arcs", setaction(selectfilter, Number(ARC))},
212 	{"Splines", setaction(selectfilter, Number(SPLINE))},
213 	{"Paths", setaction(selectfilter, Number(PATH))},
214 };
215 
216 menustruct RotateMenu[] = {
217 	{"Flip Horizontal (f)", action(exec_or_changetool, Number(XCF_Flip_X))},
218 	{"Flip Vertical (F)", action(exec_or_changetool, Number(XCF_Flip_Y))},
219 	{" ", noaction},
220 	{"Rotate CW 90", action(rotatetool, Number(90))},
221 	{"Rotate CW 45", action(rotatetool, Number(45))},
222 	{"Rotate CW 30", action(rotatetool, Number(30))},
223 	{"Rotate CW 15 (r)", action(rotatetool, Number(15))},
224 	{"Rotate CW 5 (o)", action(rotatetool, Number(3))},
225 	{"Rotate CW 1", action(rotatetool, Number(1))},
226 	{" ", noaction},
227 	{"Rotate CCW 90", action(rotatetool, Number(-90))},
228 	{"Rotate CCW 45", action(rotatetool, Number(-45))},
229 	{"Rotate CCW 30", action(rotatetool, Number(-30))},
230 	{"Rotate CCW 15 (R)", action(rotatetool, Number(-15))},
231 	{"Rotate CCW 5 (O)", action(rotatetool, Number(-5))},
232 	{"Rotate CCW 1", action(rotatetool, Number(-1))},
233 };
234 
235 menustruct LineMenu[] = {
236 	{"Global Linewidth", action(getwirewidth, NULL)},
237 	{"Wire Linewidth", action(getwwidth, NULL)},
238 };
239 
240 menustruct GridMenu[] = {
241 	{"Grid", setaction(toggle, offset(gridon))},
242 	{"Axes", setaction(toggle, offset(axeson))},
243 	{"Grid spacing", action(getgridspace, NULL)},
244 	{"Grid type/display", submenu(GridStyles)},
245 };
246 
247 menustruct SnapMenu[] = {
248 	{"Snap-to", setaction(toggle, offset(snapto))},
249         {"Snap spacing", action(getsnapspace, NULL)},
250 };
251 
252 menustruct PinConvert[] = {
253 	{"Normal label", action(dopintype, Number(NORMAL))},
254 	{"Local Pin", action(dopintype, Number(LOCAL))},
255 	{"Global Pin", action(dopintype, Number(GLOBAL))},
256 	{"Info label", action(dopintype, Number(INFO))},
257 };
258 
259 menustruct SchemaMenu[] = {
260 	{"Make Pin (T)", action(changetool, Number(XCF_Pin_Label))},
261 	{"Make Info Pin (I)", action(changetool, Number(XCF_Info_Label))},
262 	{"Make Global Pin (G)", action(changetool, Number(XCF_Pin_Global))},
263 	{"Convert Label to...", submenu(PinConvert)},
264 	{"Pin Visibility", action(setpinanchorbit, Number(PINVISIBLE))},
265 /*	{"Make Object Non-Schematic", action(maketrivial, NULL)}, */
266 	{"Make Matching Symbol", action(dobeforeswap, NULL)},
267 	{"Associate with Symbol", action(startschemassoc, Number(1))},
268 	{"Highlight Connectivity", action(startconnect, NULL)},
269 	{"Auto-number Components", action(callwritenet, Number(4))},
270 	{" ", noaction},
271 	{"Write spice", action(callwritenet, Number(0))},
272 	{"Write flattened spice", action(callwritenet, Number(3))},
273 	{"Write sim", action(callwritenet, Number(1))},
274 	{"Write pcb", action(callwritenet, Number(2))},
275 };
276 
277 menustruct WindowMenu[] = {
278 	{"Zoom In (Z)", action(zoominrefresh, NULL)},
279 	{"Zoom Out (z)", action(zoomoutrefresh, NULL)},
280 	{"Full View (v)", action(zoomview, NULL)},
281 	{"Pan (p)", action(pantool, Number(6))},
282 	{"Refresh ( )", action(refresh, NULL)},
283 	{" ", noaction},
284 	{"Library Directory (L)", action(startcatalog, Number(LIBLIB))},
285 	{"Goto Library", submenu(Libraries)},
286 	{" ", noaction},
287 	{"Page Directory (P)", action(startcatalog, Number(PAGELIB))},
288 	{"Goto Page", submenu(Pages)}
289 };
290 
291 menustruct FileMenu[] = {
292 #ifdef XC_WIN32
293 	{"New window", action(win32_new_window, NULL)},
294 	{" ", noaction},
295 #endif
296 	{"Read Xcircuit File", action(getfile, Number(NORMAL))},
297 	{"Import Xcircuit PS", action(getfile, Number(IMPORT))},
298 #if !defined(HAVE_CAIRO) || defined(HAVE_GS)
299 	{"Import background PS", action(getfile, Number(PSBKGROUND))},
300 #endif
301 #ifdef HAVE_CAIRO
302 	{"Import graphic image", action(getfile, Number(IMPORTGRAPHIC))},
303 #endif
304 #ifdef ASG
305 	{"Import SPICE deck", action(getfile, Number(IMPORTSPICE))},
306 #endif
307 	{"Execute script", action(getfile, Number(SCRIPT))},
308 	{"Write Xcircuit PS (W)", action(outputpopup, NULL)},
309 	{" ", noaction},
310 	{"Add To Library", action(getlib, NULL)},
311 	{"Load New Library", action(getuserlib, NULL)},
312 	{"Save Library", action(savelibpopup, NULL)},
313 	{" ", noaction},
314         {"Clear Page", action(resetbutton, Number(0))},
315 	{" ", noaction},
316 	{"Quit", action(quitcheck, NULL)},
317 };
318 
319 menustruct OptionMenu[] = {
320 	{"Alt Colors", action(inversecolor, offset(invert))},
321 	{"Show Bounding box", action(toggle, offset(bboxon))},
322 	{"Edit in place", setaction(toggle, offset(editinplace))},
323 	{"Show Pin Positions", action(toggle, offset(pinpointon))},
324 #ifdef HAVE_XPM
325 	{"Disable Toolbar", action(dotoolbar, NULL)},
326 #endif
327 	{"Grid", submenu(GridMenu)},
328 	{"Snap-to", submenu(SnapMenu)},
329 	{"Linewidth", submenu(LineMenu)},
330 	{"Elements", submenu(PolyMenu)},
331 	{" ", noaction},
332 	{"Help!", action(starthelp, NULL)},
333 };
334 
335 menustruct EditMenu[] = {
336 	{"Undo (u)", action(undo_call, NULL)},
337 	{"Redo (U)", action(redo_call, NULL)},
338 	{" ", noaction},
339 	{"Delete (d)", action(exec_or_changetool, Number(XCF_Delete))},
340 	{"Copy (c)", action(exec_or_changetool, Number(XCF_Copy))},
341 	{"Edit (e)", action(exec_or_changetool, Number(XCF_Edit))},
342 	{"Rotate/Flip", submenu(RotateMenu)},
343 	{"Deselect (x)", action(startdesel, NULL)},
344 	{"Select filter", submenu(FilterMenu)},
345 	{"Push selected (>)", action(exec_or_changetool, Number(XCF_Push))},
346 	{"Pop hierarchy (<)", action(popobject, Number(0))},
347 	{" ", noaction},
348 	{"Make User Object (m)", action(selectsave, NULL)},
349 	{"Make Arc (a)", action(changetool, Number(XCF_Arc))},
350 	{"Make Box (b)", action(changetool, Number(XCF_Box))},
351 	{"Make Spline (s)", action(changetool, Number(XCF_Spline))},
352 	{"Join (j)", action(join, NULL)},
353 };
354 
355 menustruct TopButtons[] = {
356 	{"File", submenu(FileMenu)},
357 	{"Edit", submenu(EditMenu)},
358 	{"Text", submenu(TextMenu)},
359 	{"Options", submenu(OptionMenu)},
360 	{"Window", submenu(WindowMenu)},
361 	{"Netlist", submenu(SchemaMenu)},
362 };
363 
364 short maxbuttons = sizeof(TopButtons) / sizeof(menustruct);
365 
366 #ifdef HAVE_XPM
367 /* Toolbar buttons */
368 toolbarstruct ToolBar[] = {
369 	{"Pan",	   pn_xpm,  toolaction(pantool, Number(6)),
370 		"pan mode"},
371 	{"Wire",   w_xpm,  toolaction(changetool, Number(XCF_Wire)),
372 		"draw wire"},
373 	{"Box",    b_xpm,  toolaction(changetool, Number(XCF_Box)),
374 		"draw box"},
375 	{"Arc",    a_xpm,  toolaction(changetool, Number(XCF_Arc)),
376 		"draw arc"},
377 	{"Spline", s_xpm,  toolaction(changetool, Number(XCF_Spline)),
378 		"draw spline"},
379 	{"Text",   t_xpm,  toolaction(changetool, Number(XCF_Text)),
380 		"enter text"},
381 	{"Move",   mv_xpm, toolaction(exec_or_changetool, Number(XCF_Move)),
382 		"move element"},
383 	{"Copy",   cp_xpm, toolaction(exec_or_changetool, Number(XCF_Copy)),
384 		"copy element"},
385 	{"Edit",   e_xpm,  toolaction(exec_or_changetool, Number(XCF_Edit)),
386 		"edit element"},
387 	{"Delete", d2_xpm, toolaction(exec_or_changetool, Number(XCF_Delete)),
388 		"delete element"},
389 	{"RotP",   cw_xpm, toolaction(rotatetool, Number(15)),
390 		"rotate 15 degrees clockwise"},
391 	{"RotN",  ccw_xpm, toolaction(rotatetool, Number(-15)),
392 		"rotate 15 degrees counterclockwise"},
393 	{"HFlip",  fx_xpm, toolaction(exec_or_changetool, Number(XCF_Flip_X)),
394 		"flip horizontal"},
395 	{"VFlip",  fy_xpm, toolaction(exec_or_changetool, Number(XCF_Flip_Y)),
396 		"flip vertical"},
397 	{"Push",  pu2_xpm, toolaction(exec_or_changetool, Number(XCF_Push)),
398 		"push (edit object)"},
399 	{"Pop",   po2_xpm, toolaction(popobject, Number(0)),
400 		"pop (return from object edit)"},
401 	{"Make",   mk_xpm, toolaction(selectsave, NULL),
402 		"make an object from selected elements"},
403 	{"Join",   pz_xpm, toolaction(join, NULL),
404 		"join elements into polygon or path"},
405 	{"Unjoin", uj_xpm, toolaction(unjoin, NULL),
406 		"separate path into elements"},
407 	{"Colors", co_xpm, toolaction(color_popup, NULL),
408 		"set color"},
409 	{"Border", bd_xpm, toolaction(border_popup, NULL),
410 		"set border and line properties"},
411 	{"Fills",  fi_xpm, toolaction(fill_popup, NULL),
412 		"set fill properties"},
413 	{"Parameters", pm_xpm,  toolaction(param_popup, NULL),
414 		"parameterize properties"},
415 	{"Library",li_xpm, toolaction(changecat, NULL),
416 		"go to next library"},
417 	{"Libdir", yp_xpm, toolaction(startcatalog, Number(LIBLIB)),
418 		"go to library directory"},
419 	{"Pagedir",pl_xpm, toolaction(startcatalog, Number(PAGELIB)),
420 		"go to page directory"},
421 	{"ZoomI",  z4_xpm, toolaction(zoominrefresh, NULL),
422 		"zoom in"},
423 	{"ZoomO",  z5_xpm, toolaction(zoomoutrefresh, NULL),
424 		"zoom out"},
425 	{"Help",   i_xpm,  toolaction(starthelp, NULL),
426 		"pop up help window"},
427 };
428 
429 short toolbuttons = sizeof(ToolBar) / sizeof(toolbarstruct);
430 #endif
431 
432 #undef submenu
433 #undef action
434 #undef setaction
435 #undef toolaction
436 #undef noaction
437 #undef offset
438 
439 /*-------------------------------------------------------------------------*/
440