summaryrefslogtreecommitdiff
path: root/menus.h
blob: d5064234f49b373a0182ba5ec4da3c2aea2571a8 (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
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
/*-------------------------------------------------------------------------*/
/* menus.h								   */
/* Copyright (c) 2002  Tim Edwards, Johns Hopkins University        	   */
/*-------------------------------------------------------------------------*/

/*-------------------------------------------------------------------------*/
/* Hierarchical menus must be listed in bottom-up order			   */
/*-------------------------------------------------------------------------*/
/* Note:  underscore (_) before name denotes a color to paint the button.  */
/*	  colon (:) before name denotes a stipple, defined by the data	   */
/*		    passed to setfill().				   */
/*-------------------------------------------------------------------------*/

#ifdef _MENUDEP

#define submenu(a)      a, (sizeof (a) / sizeof(menustruct)), NULL, NULL
#define action(b,c)     NULL, 0, NULL, NULL
#define setaction(b,c)  NULL, 1, NULL, NULL
#define toolaction(b,c) NULL, NULL
#define noaction        NULL, 0, NULL, NULL
#define offset(a)	0

#else                   /* real definitions. . .*/

#define submenu(a)	a, (sizeof (a) / sizeof(menustruct)), \
			(XtCallbackProc)DoNothing, NULL
#define action(b,c)	NULL, 0, (XtCallbackProc)b, c
#define setaction(b,c)	NULL, 1, (XtCallbackProc)b, c
#define toolaction(b,c) (XtCallbackProc)b, c
#define noaction	NULL, 0, (XtCallbackProc)DoNothing, NULL
#define offset(a)	Number(XtOffset(XCWindowDataPtr, a))

#endif

/* Inclusions for pixmap icons */

#include "tool_bar.h"

/* Things commented out here are reminders of future implementations. */

menustruct Fonts[] = {
	{"Add New Font", action(addnewfont, NULL)},
	{" ", noaction},
};

/* Note the unorthodox passing of integer constants through type pointer */

menustruct FontStyles[] = {
	{"Normal", setaction(fontstyle, Number(0))},
	{"Bold", action(fontstyle, Number(1))},
	{"Italic", action(fontstyle, Number(2))},
	{"BoldItalic", action(fontstyle, Number(3))},
	{" ", noaction},
	{"Subscript", action(addtotext, Number(SUBSCRIPT))},
	{"Superscript", action(addtotext, Number(SUPERSCRIPT))},
	{"Normalscript", action(addtotext, Number(NORMALSCRIPT))},
	{" ", noaction},
	{"Underline", action(addtotext, Number(UNDERLINE))},
	{"Overline", action(addtotext, Number(OVERLINE))},
	{"No line", action(addtotext, Number(NOLINE))},
};

menustruct FontEncodings[] = {
	{"Standard", action(fontencoding, Number(0))},
	{"ISO-Latin1", setaction(fontencoding, Number(2))},
};

menustruct TextSpacing[] = {
	{"Tab stop", action(addtotext, Number(TABSTOP))},
	{"Tab forward", action(addtotext, Number(TABFORWARD))},
	{"Tab backward", action(addtotext, Number(TABBACKWARD))},
	{"Carriage Return", action(addtotext, Number(RETURN))},
	{"1/2 space", action(addtotext, Number(HALFSPACE))},
	{"1/4 space", action(addtotext, Number(QTRSPACE))},
	{"Kern", action(getkern, NULL)},
	{"Character", action(addtotext, Number(SPECIAL))},
};

menustruct Anchors[] = {
	{"Left Anchored", setaction(sethanchor, Number(NORMAL))},
	{"Center Anchored", action(sethanchor, Number(NOTLEFT))},
	{"Right Anchored", action(sethanchor, Number(NOTLEFT | RIGHT))},
	{" ", noaction},
	{"Top Anchored", action(setvanchor, Number(NOTBOTTOM | TOP))},
	{"Middle Anchored", action(setvanchor, Number(NOTBOTTOM))},
	{"Bottom Anchored", setaction(setvanchor, Number(NORMAL))},
	{" ", noaction},
	{"Flip Invariant", setaction(setanchorbit, Number(FLIPINV))},
};
	
menustruct BoxEditStyles[] = {
	{"Manhattan Box Edit", setaction(boxedit, Number(MANHATTAN))},
	{"Rhomboid X", action(boxedit, Number(RHOMBOIDX))},
	{"Rhomboid Y", action(boxedit, Number(RHOMBOIDY))},
	{"Rhomboid A", action(boxedit, Number(RHOMBOIDA))},
	{"Normal", action(boxedit, Number(NORMAL))},
};

menustruct GridStyles[] = {
	{"Decimal Inches", action(getgridtype, Number(DEC_INCH))},
	{"Fractional Inches", setaction(getgridtype, Number(FRAC_INCH))},
	{"Centimeters", action(getgridtype, Number(CM))},
	{" ", noaction},
	{"Drawing Scale", action(getdscale, NULL)},
};

menustruct Libraries[] = {
	{"Add New Library", action(newlibrary, NULL)},
	{" ", noaction},
	{"Library 1", action(startcatalog, Number(LIBRARY))},
	{"Library 2", action(startcatalog, Number(LIBRARY + 1))},
};

menustruct Pages[] = {
	{"Add New Page", action(newpagemenu, Number(255))},
	{" ", noaction},
	{"Page 1", action(newpagemenu, Number(0))},
	{"Page 2", action(newpagemenu, Number(1))},
	{"Page 3", action(newpagemenu, Number(2))},
	{"Page 4", action(newpagemenu, Number(3))},
	{"Page 5", action(newpagemenu, Number(4))},
	{"Page 6", action(newpagemenu, Number(5))},
	{"Page 7", action(newpagemenu, Number(6))},
	{"Page 8", action(newpagemenu, Number(7))},
	{"Page 9", action(newpagemenu, Number(8))},
	{"Page 10", action(newpagemenu, Number(9))}
};

menustruct BorderStyles[] = {
	{"Linewidth", action(getwwidth, NULL)},
	{" ", noaction},
	{"Solid", setaction(setline, Number(NORMAL))},
	{"Dashed", action(setline, Number(DASHED))},
	{"Dotted", action(setline, Number(DOTTED))},
	{"Unbordered", action(setline, Number(NOBORDER))},
	{" ", noaction},
	{"Closed", action(setclosure, Number(UNCLOSED))}, 
	{"Bounding Box", action(makebbox, Number(BBOX))},
};

menustruct Colors[] = {
	{"Add New Color", action(addnewcolor, NULL)},
	{" ", noaction},
	{"Inherit Color", setaction(setcolor, Number(1))},
	{"_Black", action(setcolor, NULL)},
	{"_White", action(setcolor, NULL)},
};

menustruct Parameterize[] = {
	{"Substring", action(promptparam, NULL)},
	{"Numeric", action(startparam, Number(P_NUMERIC))},
	{"Style", action(startparam, Number(P_STYLE))},
	{"Anchoring", action(startparam, Number(P_ANCHOR))},
	{"Start Angle", action(startparam, Number(P_ANGLE1))},
	{"End Angle", action(startparam, Number(P_ANGLE2))},
	{"Radius", action(startparam, Number(P_RADIUS))},
	{"Minor Axis", action(startparam, Number(P_MINOR_AXIS))},
	{"Rotation", action(startparam, Number(P_ROTATION))},
	{"Scale", action(startparam, Number(P_SCALE))},
	{"Linewidth", action(startparam, Number(P_LINEWIDTH))},
	{"Color", action(startparam, Number(P_COLOR))},
	{"Position", action(startparam, Number(P_POSITION))},
};

menustruct Stipples[] = {
	{":Black",  action(setfill, Number(OPAQUE | FILLED | FILLSOLID))},
	{":Gray12", action(setfill, Number(OPAQUE | FILLED | STIP2 | STIP1))},
	{":Gray25", action(setfill, Number(OPAQUE | FILLED | STIP2 | STIP0))},
	{":Gray37", action(setfill, Number(OPAQUE | FILLED | STIP2))},
	{":Gray50", action(setfill, Number(OPAQUE | FILLED | STIP0 | STIP1))},
	{":Gray62", action(setfill, Number(OPAQUE | FILLED | STIP1))},
	{":Gray75", action(setfill, Number(OPAQUE | FILLED | STIP0))},
	{":Gray87", action(setfill, Number(OPAQUE | FILLED))},
	{":White", setaction(setfill, Number(FILLSOLID))},
	{" ", noaction},
	{"Opaque", action(setopaque, Number(OPAQUE))},
	{"Transparent", setaction(setopaque, Number(NORMAL))},
};

menustruct TextMenu[] = {
	{"Text Size", action(gettsize, NULL)},
	{"Font", submenu(Fonts)},
	{"Style", submenu(FontStyles)},
	{"Encoding", submenu(FontEncodings)},
	{"Insert", submenu(TextSpacing)},             
	{"Anchoring (keypad)", submenu(Anchors)},
	{"Parameterize", action(promptparam, NULL)},
	{"Unparameterize", action(startunparam, Number(P_SUBSTRING))},
	{" ", noaction},
	{"Set LaTeX Mode", action(setanchorbit, Number(LATEXLABEL))},
	{" ", noaction},
	{"Make Label (t)", action(changetool, Number(XCF_Text))},
};

menustruct PolyMenu[] = {
	{"Border", submenu(BorderStyles)},
	{"Fill", submenu(Stipples)},
	{"Color", submenu(Colors)},
	{" ", noaction},
	{"Object size", action(getosize, NULL)},
	{"Parameters", submenu(Parameterize)},
	{"Center Object", setaction(toggle, offset(center))},
	{"Manhattan Draw", action(toggle, offset(manhatn))},
	{"Polygon Edit", submenu(BoxEditStyles)},
};

menustruct FilterMenu[] = {
	{"Labels", setaction(selectfilter, Number(LABEL))},
	{"Objects", setaction(selectfilter, Number(OBJINST))},
	{"Polygons", setaction(selectfilter, Number(POLYGON))},
	{"Arcs", setaction(selectfilter, Number(ARC))},
	{"Splines", setaction(selectfilter, Number(SPLINE))},
	{"Paths", setaction(selectfilter, Number(PATH))},
};

menustruct RotateMenu[] = {
	{"Flip Horizontal (f)", action(exec_or_changetool, Number(XCF_Flip_X))},
	{"Flip Vertical (F)", action(exec_or_changetool, Number(XCF_Flip_Y))},
	{" ", noaction},
	{"Rotate CW 90", action(rotatetool, Number(90))},
	{"Rotate CW 45", action(rotatetool, Number(45))},
	{"Rotate CW 30", action(rotatetool, Number(30))},
	{"Rotate CW 15 (r)", action(rotatetool, Number(15))},
	{"Rotate CW 5 (o)", action(rotatetool, Number(3))},
	{"Rotate CW 1", action(rotatetool, Number(1))},
	{" ", noaction},
	{"Rotate CCW 90", action(rotatetool, Number(-90))},
	{"Rotate CCW 45", action(rotatetool, Number(-45))},
	{"Rotate CCW 30", action(rotatetool, Number(-30))}, 
	{"Rotate CCW 15 (R)", action(rotatetool, Number(-15))},
	{"Rotate CCW 5 (O)", action(rotatetool, Number(-5))},
	{"Rotate CCW 1", action(rotatetool, Number(-1))},
};

menustruct LineMenu[] = {
	{"Global Linewidth", action(getwirewidth, NULL)},
	{"Wire Linewidth", action(getwwidth, NULL)},
};

menustruct GridMenu[] = {
	{"Grid", setaction(toggle, offset(gridon))},
	{"Axes", setaction(toggle, offset(axeson))},
	{"Grid spacing", action(getgridspace, NULL)},
	{"Grid type/display", submenu(GridStyles)},
};

menustruct SnapMenu[] = {
	{"Snap-to", setaction(toggle, offset(snapto))},
        {"Snap spacing", action(getsnapspace, NULL)},
};

menustruct PinConvert[] = {
	{"Normal label", action(dopintype, Number(NORMAL))},
	{"Local Pin", action(dopintype, Number(LOCAL))},
	{"Global Pin", action(dopintype, Number(GLOBAL))},
	{"Info label", action(dopintype, Number(INFO))},
};

menustruct SchemaMenu[] = {
	{"Make Pin (T)", action(changetool, Number(XCF_Pin_Label))},
	{"Make Info Pin (I)", action(changetool, Number(XCF_Info_Label))},
	{"Make Global Pin (G)", action(changetool, Number(XCF_Pin_Global))},
	{"Convert Label to...", submenu(PinConvert)},
	{"Pin Visibility", action(setpinanchorbit, Number(PINVISIBLE))},
/*	{"Make Object Non-Schematic", action(maketrivial, NULL)}, */
	{"Make Matching Symbol", action(dobeforeswap, NULL)},
	{"Associate with Symbol", action(startschemassoc, Number(1))},
	{"Highlight Connectivity", action(startconnect, NULL)},
	{"Auto-number Components", action(callwritenet, Number(4))},
	{" ", noaction},
	{"Write spice", action(callwritenet, Number(0))},
	{"Write flattened spice", action(callwritenet, Number(3))},
	{"Write sim", action(callwritenet, Number(1))},
	{"Write pcb", action(callwritenet, Number(2))},
};

menustruct WindowMenu[] = {
	{"Zoom In (Z)", action(zoominrefresh, NULL)},
	{"Zoom Out (z)", action(zoomoutrefresh, NULL)},
	{"Full View (v)", action(zoomview, NULL)},
	{"Pan (p)", action(pantool, Number(6))},
	{"Refresh ( )", action(refresh, NULL)},
	{" ", noaction},
	{"Library Directory (L)", action(startcatalog, Number(LIBLIB))},
	{"Goto Library", submenu(Libraries)},
	{" ", noaction},
	{"Page Directory (P)", action(startcatalog, Number(PAGELIB))},
	{"Goto Page", submenu(Pages)}
};

menustruct FileMenu[] = {
#ifdef XC_WIN32
	{"New window", action(win32_new_window, NULL)},
	{" ", noaction},
#endif
	{"Read Xcircuit File", action(getfile, Number(NORMAL))},
	{"Import Xcircuit PS", action(getfile, Number(IMPORT))},
#if !defined(HAVE_CAIRO) || defined(HAVE_GS)
	{"Import background PS", action(getfile, Number(PSBKGROUND))},
#endif
#ifdef HAVE_CAIRO
	{"Import graphic image", action(getfile, Number(IMPORTGRAPHIC))},
#endif
#ifdef ASG
	{"Import SPICE deck", action(getfile, Number(IMPORTSPICE))},
#endif
	{"Execute script", action(getfile, Number(SCRIPT))},
	{"Write Xcircuit PS (W)", action(outputpopup, NULL)},
	{" ", noaction},
	{"Add To Library", action(getlib, NULL)},
	{"Load New Library", action(getuserlib, NULL)},
	{"Save Library", action(savelibpopup, NULL)},
	{" ", noaction},
        {"Clear Page", action(resetbutton, Number(0))},
	{" ", noaction},
	{"Quit", action(quitcheck, NULL)},
};

menustruct OptionMenu[] = {
	{"Alt Colors", action(inversecolor, offset(invert))},
	{"Show Bounding box", action(toggle, offset(bboxon))},
	{"Edit in place", setaction(toggle, offset(editinplace))},
	{"Show Pin Positions", action(toggle, offset(pinpointon))},
#ifdef HAVE_XPM
	{"Disable Toolbar", action(dotoolbar, NULL)},
#endif
	{"Grid", submenu(GridMenu)},
	{"Snap-to", submenu(SnapMenu)},
	{"Linewidth", submenu(LineMenu)},
	{"Elements", submenu(PolyMenu)},
	{" ", noaction},
	{"Help!", action(starthelp, NULL)},
};

menustruct EditMenu[] = {
	{"Undo (u)", action(undo_call, NULL)},
	{"Redo (U)", action(redo_call, NULL)},
	{" ", noaction},
	{"Delete (d)", action(exec_or_changetool, Number(XCF_Delete))},
	{"Copy (c)", action(exec_or_changetool, Number(XCF_Copy))},
	{"Edit (e)", action(exec_or_changetool, Number(XCF_Edit))},
	{"Rotate/Flip", submenu(RotateMenu)},
	{"Deselect (x)", action(startdesel, NULL)},
	{"Select filter", submenu(FilterMenu)},
	{"Push selected (>)", action(exec_or_changetool, Number(XCF_Push))},
	{"Pop hierarchy (<)", action(popobject, Number(0))},
	{" ", noaction},
	{"Make User Object (m)", action(selectsave, NULL)},
	{"Make Arc (a)", action(changetool, Number(XCF_Arc))},
	{"Make Box (b)", action(changetool, Number(XCF_Box))},
	{"Make Spline (s)", action(changetool, Number(XCF_Spline))},
	{"Join (j)", action(join, NULL)},
};

menustruct TopButtons[] = {
	{"File", submenu(FileMenu)},
	{"Edit", submenu(EditMenu)},
	{"Text", submenu(TextMenu)},
	{"Options", submenu(OptionMenu)},
	{"Window", submenu(WindowMenu)},
	{"Netlist", submenu(SchemaMenu)},
};

short maxbuttons = sizeof(TopButtons) / sizeof(menustruct);

#ifdef HAVE_XPM
/* Toolbar buttons */
toolbarstruct ToolBar[] = {
	{"Pan",	   pn_xpm,  toolaction(pantool, Number(6)),
		"pan mode"},
	{"Wire",   w_xpm,  toolaction(changetool, Number(XCF_Wire)),
		"draw wire"},
	{"Box",    b_xpm,  toolaction(changetool, Number(XCF_Box)),
		"draw box"},
	{"Arc",    a_xpm,  toolaction(changetool, Number(XCF_Arc)),
		"draw arc"},
	{"Spline", s_xpm,  toolaction(changetool, Number(XCF_Spline)),
		"draw spline"},
	{"Text",   t_xpm,  toolaction(changetool, Number(XCF_Text)),
		"enter text"},
	{"Move",   mv_xpm, toolaction(exec_or_changetool, Number(XCF_Move)),
		"move element"},
	{"Copy",   cp_xpm, toolaction(exec_or_changetool, Number(XCF_Copy)),
		"copy element"},
	{"Edit",   e_xpm,  toolaction(exec_or_changetool, Number(XCF_Edit)),
		"edit element"},
	{"Delete", d2_xpm, toolaction(exec_or_changetool, Number(XCF_Delete)),
		"delete element"},
	{"RotP",   cw_xpm, toolaction(rotatetool, Number(15)),
		"rotate 15 degrees clockwise"},
	{"RotN",  ccw_xpm, toolaction(rotatetool, Number(-15)),
		"rotate 15 degrees counterclockwise"},
	{"HFlip",  fx_xpm, toolaction(exec_or_changetool, Number(XCF_Flip_X)),
		"flip horizontal"},
	{"VFlip",  fy_xpm, toolaction(exec_or_changetool, Number(XCF_Flip_Y)),
		"flip vertical"},
	{"Push",  pu2_xpm, toolaction(exec_or_changetool, Number(XCF_Push)),
		"push (edit object)"},
	{"Pop",   po2_xpm, toolaction(popobject, Number(0)),
		"pop (return from object edit)"},
	{"Make",   mk_xpm, toolaction(selectsave, NULL),
		"make an object from selected elements"},
	{"Join",   pz_xpm, toolaction(join, NULL),
		"join elements into polygon or path"},
	{"Unjoin", uj_xpm, toolaction(unjoin, NULL),
		"separate path into elements"},
	{"Colors", co_xpm, toolaction(color_popup, NULL),
		"set color"},
	{"Border", bd_xpm, toolaction(border_popup, NULL),
		"set border and line properties"},
	{"Fills",  fi_xpm, toolaction(fill_popup, NULL),
		"set fill properties"},
	{"Parameters", pm_xpm,  toolaction(param_popup, NULL),
		"parameterize properties"},
	{"Library",li_xpm, toolaction(changecat, NULL),
		"go to next library"},
	{"Libdir", yp_xpm, toolaction(startcatalog, Number(LIBLIB)),
		"go to library directory"},
	{"Pagedir",pl_xpm, toolaction(startcatalog, Number(PAGELIB)),
		"go to page directory"},
	{"ZoomI",  z4_xpm, toolaction(zoominrefresh, NULL),
		"zoom in"},
	{"ZoomO",  z5_xpm, toolaction(zoomoutrefresh, NULL),
		"zoom out"},
	{"Help",   i_xpm,  toolaction(starthelp, NULL),
		"pop up help window"},
};

short toolbuttons = sizeof(ToolBar) / sizeof(toolbarstruct);
#endif

#undef submenu
#undef action
#undef setaction
#undef toolaction
#undef noaction
#undef offset

/*-------------------------------------------------------------------------*/