58
83
/* ---------------------------------------------------------------------------
59
84
* some local prototypes
61
static void CBPOPUP_Display(Widget, XtPointer, XtPointer);
62
static void CBPOPUP_Settings(Widget, XtPointer, XtPointer);
63
static void CBPOPUP_File(Widget, XtPointer, XtPointer);
64
static void CBPOPUP_Buffer(Widget, XtPointer, XtPointer);
65
static void CBPOPUP_Sizes(Widget, XtPointer, XtPointer);
66
static void CBPOPUP_Window(Widget, XtPointer, XtPointer);
67
static void CB_Action(Widget, XtPointer, XtPointer);
68
static void CB_Position(Widget, XtPointer, XtPointer);
69
static void CB_ElementPosition(Widget, XtPointer, XtPointer);
70
static void CB_TextPosition(Widget, XtPointer, XtPointer);
71
static void CB_ObjectPosition(Widget, XtPointer, XtPointer);
72
static void CB_About(Widget, XtPointer, XtPointer);
73
static void InitPopupTree(Widget, PopupEntryTypePtr);
74
static void InitPopupMenu(Widget, PopupMenuTypePtr);
75
static void DoWindows(Widget, XtPointer, XtPointer);
76
static Widget InitializeSizesMenu(Widget, Widget, Widget);
77
static Boolean InitCheckPixmap(void);
86
static void InitPopupTree (Widget, PopupEntryTypePtr);
87
static void InitPopupMenu (Widget, PopupMenuTypePtr);
88
static Boolean InitCheckPixmap (void);
79
90
/* ---------------------------------------------------------------------------
80
91
* some local identifiers
82
static Pixmap Check = BadAlloc;
84
/*-----------------------------------------------------------------------------
85
* pop up menu for third mouse button
87
static PopupEntryType pMenuEntries[] = {
88
{ "header", "Operations on Selections", NULL, NULL, NULL },
89
{ "unselect", "Unselect All", CB_Action, "Unselect,All", NULL },
90
{ "remove", "Remove Selected", CB_Action,
91
"RemoveSelected", NULL },
92
{ "copy", "Copy Selection to Buffer", CB_Action,
94
"PasteBuffer,AddSelected\n"
97
{ "cut", "Cut Selection to Buffer", CB_Action,
99
"PasteBuffer,AddSelected\n"
103
{ "hide", "Toggle Name Visibility", CB_Action,
104
"ToggleHideName,Selected", NULL},
105
{ "header", "Operations on This Object", NULL, NULL, NULL },
106
{ "edit", "Edit Name", CB_Action, "ChangeName,Object", NULL },
107
{ "report", "Object Report", CB_Action, "Report,Object", NULL },
108
{ "rotate", "Rotate Object", CB_Action,
112
"Mode,Restore", NULL },
113
{ "therm", "Toggle Thermal", CB_Action,
117
"Mode,Restore", NULL },
118
{ "lookup", "Lookup Connections", CB_Action,
119
"Connection,Find", NULL },
120
{ "reset", "Reset All Connections", CB_Action,
122
"Display,Redraw", NULL },
123
{ "line", NULL, NULL, NULL, NULL },
124
{ "undo", "Undo Last Operation", CB_Action, "Undo", NULL },
125
{ "redo", "Redo Last Undone Operation", CB_Action, "Redo", NULL },
126
{ "line", NULL, NULL, NULL, NULL },
127
{ "lmode", "Line Tool", CB_Action, "Mode,Line", NULL },
128
{ "rmode", "Rectangle Tool", CB_Action, "Mode,Rectangle", NULL },
129
{ "amode", "Selection Tool", CB_Action, "Mode,Arrow", NULL },
130
{ "tmode", "Text Tool", CB_Action, "Mode,Text", NULL },
131
{ "nmode", "No Tool", CB_Action, "Mode,None", NULL },
132
{ NULL, NULL, NULL, NULL, NULL }};
133
static PopupMenuType pMenu =
134
{ "pmenu", NULL, pMenuEntries, NULL, NULL, NULL};
135
static PopupEntryType p2MenuEntries[] = {
136
{ "nmode", "No Tool", CB_Action, "Mode,None", NULL },
137
{ NULL, NULL, NULL, NULL, NULL }};
138
static PopupMenuType p2Menu =
139
{ "p2menu", NULL, p2MenuEntries, NULL, NULL, NULL};
141
/* ---------------------------------------------------------------------------
144
static PopupEntryType FileMenuEntries[] = {
145
{ "about", "About...", CB_About, NULL, NULL },
146
{ "save", "save layout", CB_Action, "Save,Layout", NULL },
147
{ "saveas", "save layout as...", CB_Action, "Save,LayoutAs", NULL },
148
{ "load", "load layout", CB_Action, "Load,Layout", NULL },
149
{ "loadelement", "load element data to paste-buffer", CB_Action,
150
"PasteBuffer,Clear\n"
151
"Load,ElementToBuffer", NULL },
152
{ "loadlayout", "load layout data to paste-buffer", CB_Action,
153
"PasteBuffer,Clear\n"
154
"Load,LayoutToBuffer", NULL },
155
{ "loadnetlist", "load netlist file", CB_Action, "Load,Netlist", NULL },
156
{ "print", "print layout...", CB_Action, "Print", NULL },
157
{ "line", NULL, NULL, NULL, NULL },
158
{ "header", "save connection data of", NULL, NULL, NULL },
159
{ "savesingle", "a single element", CB_ElementPosition,
160
"Save,ElementConnections", NULL },
161
{ "saveall", "all elements", CB_Action, "Save,AllConnections", NULL },
162
{ "saveunused", "unused pins", CB_Action, "Save,AllUnusedPins", NULL },
163
{ "line", NULL, NULL, NULL, NULL },
164
{ "new", "start new layout", CB_Action, "New", NULL },
165
{ "line", NULL, NULL, NULL, NULL },
166
{ "quit", "quit program", CB_Action, "Quit", NULL },
167
{ NULL, NULL, NULL, NULL, NULL }};
168
static PopupMenuType FileMenu =
169
{ "file", NULL, FileMenuEntries, CBPOPUP_File, NULL, NULL};
170
static MenuButtonType FileMenuButton =
171
{ "file", "File", &FileMenu, NULL};
173
/* ---------------------------------------------------------------------------
176
static PopupEntryType EditMenuEntries[] = {
177
{ "undo", "undo last operation", CB_Action, "Undo", NULL },
178
{ "redo", "redo last undone operation", CB_Action, "Redo", NULL },
179
{ "clear", "clear undo-buffer", CB_Action, "Undo,ClearList", NULL },
180
{ "line", NULL, NULL, NULL, NULL },
181
{ "cut", "cut selection to buffer", CB_Position,
182
"PasteBuffer,Clear\n"
183
"PasteBuffer,AddSelected\n"
187
{ "copy", "copy selection to buffer", CB_Position,
188
"PasteBuffer,Clear\n"
189
"PasteBuffer,AddSelected\n"
192
{ "paste", "paste buffer to layout", CB_Action, "Mode,PasteBuffer", NULL },
193
{ "line", NULL, NULL, NULL, NULL },
194
{ "unselect", "unselect all", CB_Action, "Unselect,All", NULL },
195
{ "select", "select all", CB_Action, "Select,All", NULL },
196
{ "line", NULL, NULL, NULL, NULL },
197
{ "header", "Edit Names", NULL, NULL, NULL },
198
{ "edit", "edit text on layout", CB_TextPosition, "ChangeName,Object", NULL },
199
{ "layoutname", "edit name of layout", CB_Action, "ChangeName,Layout", NULL },
200
{ "layername", "edit name of active layer", CB_Action, "ChangeName,Layer", NULL },
201
{ "line", NULL, NULL, NULL, NULL },
202
{ "boardSize", "change board size...", CB_Action, "AdjustStyle,0", NULL },
203
{ NULL, NULL, NULL, NULL, NULL }};
204
static PopupMenuType EditMenu =
205
{ "edit", NULL, EditMenuEntries, NULL, NULL, NULL };
206
static MenuButtonType EditMenuButton =
207
{ "edits", "Edit", &EditMenu, NULL};
209
/* ---------------------------------------------------------------------------
210
* display menu button
212
static PopupEntryType DisplayMenuEntries[] = {
213
{ "redraw", "redraw layout", CB_Action, "Display,Redraw", NULL },
214
{ "center", "center layout", CB_Position, "Display,Center", NULL },
215
{ "line", NULL, NULL, NULL, NULL },
216
{ "displayGrid", "display grid", CB_Action, "Display,Grid", NULL },
217
{ "toggleGrid", "use absolute grid", CB_Position,
218
"Display,ToggleGrid", NULL },
219
{ "solderSide", "view solder side", CB_Position, "SwapSides", NULL },
220
{ "line", NULL, NULL, NULL, NULL },
221
{ "header", "grid setting", NULL, NULL, NULL },
222
{ "grid05", " 5 mil", CB_Action, "SetValue,Grid,5", NULL },
223
{ "grid10", "10 mil", CB_Action, "SetValue,Grid,10", NULL },
224
{ "grid20", "20 mil", CB_Action, "SetValue,Grid,20", NULL },
225
{ "grid25", "25 mil", CB_Action, "SetValue,Grid,25", NULL },
226
{ "grid50", "50 mil", CB_Action, "SetValue,Grid,50", NULL },
227
{ "grid100", "100 mil", CB_Action, "SetValue,Grid,100", NULL },
228
{ "gridInc", "increment by 5", CB_Action, "SetValue,Grid,+5", NULL },
229
{ "gridDec", "decrement by 5", CB_Action, "SetValue,Grid,-5", NULL },
230
{ "line", NULL, NULL, NULL, NULL },
231
{ "header", "zoom setting", NULL, NULL, NULL },
232
{ "zoom1", "1 : 1 ", CB_Position, "SetValue,Zoom,0", NULL },
233
{ "zoom2", "1 : 2 ", CB_Position, "SetValue,Zoom,1", NULL },
234
{ "zoom4", "1 : 4 ", CB_Position, "SetValue,Zoom,2", NULL },
235
{ "zoom8", "1 : 8 ", CB_Position, "SetValue,Zoom,3", NULL },
236
{ "zoom16", "1 :16 ", CB_Position, "SetValue,Zoom,4", NULL },
237
{ "line", NULL, NULL, NULL, NULL },
238
{ "header", "displayed element-name", NULL, NULL, NULL },
239
{ "description", "description", CB_Action, "Display,Description", NULL },
240
{ "onPCB", "name on PCB", CB_Action, "Display,NameOnPCB", NULL },
241
{ "value", "value", CB_Action, "Display,Value", NULL },
242
{ "line", NULL, NULL, NULL, NULL },
243
{ "pinout", "open pinout window", CB_ElementPosition, "Display,Pinout", NULL },
244
{ NULL, NULL, NULL, NULL, NULL }};
245
static PopupMenuType DisplayMenu =
246
{ "display", NULL, DisplayMenuEntries, CBPOPUP_Display, NULL, NULL};
247
static MenuButtonType DisplayMenuButton =
248
{ "display", "Screen", &DisplayMenu, NULL};
250
/* ----------------------------------------------------------------------
251
* Sizes menu button - contains variable contents
253
static PopupEntryType SizesMenuEntries[NUM_STYLES * 2 + 2];
254
static PopupMenuType SizesMenu =
255
{ "sizes", NULL, SizesMenuEntries, CBPOPUP_Sizes, NULL, NULL };
256
static MenuButtonType SizesMenuButton =
257
{ "sizes", "Sizes", &SizesMenu, NULL};
259
/* ---------------------------------------------------------------------------
260
* settings menu button
262
static PopupEntryType SettingsMenuEntries[] = {
263
{ "header", "layer-groups", NULL, NULL, NULL },
264
{ "lgedit", "edit layer-groupings", CB_Action, "EditLayerGroups", NULL },
265
{ "line", NULL, NULL, NULL, NULL },
266
{ "toggleAllDirections", "'all-direction' lines", CB_Action,
267
"Display,Toggle45Degree", NULL },
268
{ "toggleRubberBandMode", "rubber band mode", CB_Action,
269
"Display,ToggleRubberBandMode", NULL },
270
{ "toggleSwapStartDirection", "auto swap line start angle", CB_Action,
271
"Display,ToggleStartDirection", NULL },
272
{ NULL, NULL, NULL, NULL, NULL }};
273
static PopupMenuType SettingsMenu =
274
{ "settings", NULL, SettingsMenuEntries, CBPOPUP_Settings, NULL, NULL };
275
static MenuButtonType SettingsMenuButton =
276
{ "settings", "Settings", &SettingsMenu, NULL};
278
/* ---------------------------------------------------------------------------
279
* selection menu button
281
static PopupEntryType SelectionMenuEntries[] = {
282
{ "select", "select all objects", CB_Action, "Select,All", NULL },
283
{ "selectconnection", "select all connected objects", CB_Action,
284
"Select,Connection", NULL },
285
{ "line", NULL, NULL, NULL, NULL },
286
{ "unselect", "unselect all objects", CB_Action, "Unselect,All", NULL },
287
{ "unselectconnection", "unselect all connected objects", CB_Action,
288
"Unselect,Connection", NULL },
290
{ "line", NULL, NULL, NULL, NULL },
291
{ "header", "select by name", NULL, NULL, NULL },
292
{ "allByName", "all objects", CB_Action, "Select,ObjectByName", NULL },
293
{ "elementByName", "elements", CB_Action, "Select,ElementByName", NULL },
294
{ "padByName", "pads", CB_Action, "Select,PadByName", NULL },
295
{ "pinByName", "pins", CB_Action, "Select,PinByName", NULL },
296
{ "textByName", "text objects", CB_Action, "Select,TextByName", NULL },
297
{ "viaByName", "vias", CB_Action, "Select,ViaByName", NULL },
299
{ "line", NULL, NULL, NULL, NULL },
300
{ "remove", "remove selected objects", CB_Action,
301
"RemoveSelected", NULL },
302
{ "line", NULL, NULL, NULL, NULL },
303
{ "header", "change size of selected objects", NULL, NULL, NULL },
304
{ "decrementline", "lines -10 mil", CB_Action,
305
"ChangeSize,SelectedLines,-10", NULL },
306
{ "incrementline", "lines +10 mil", CB_Action,
307
"ChangeSize,SelectedLines,+10", NULL },
308
{ "decrementpad", "pads -10 mil", CB_Action,
309
"ChangeSize,SelectedPads,-10", NULL },
310
{ "incrementpad", "pads +10 mil", CB_Action,
311
"ChangeSize,SelectedPads,+10", NULL },
312
{ "decrementpin", "pins -10 mil", CB_Action,
313
"ChangeSize,SelectedPins,-10", NULL },
314
{ "incrementpin", "pins +10 mil", CB_Action,
315
"ChangeSize,SelectedPins,+10", NULL },
316
{ "decrementtext", "texts -10 mil", CB_Action,
317
"ChangeSize,SelectedTexts,-10", NULL },
318
{ "incrementtext", "texts +10 mil", CB_Action,
319
"ChangeSize,SelectedTexts,+10", NULL },
320
{ "decrementvia", "vias -10 mil", CB_Action,
321
"ChangeSize,SelectedVias,-10", NULL },
322
{ "incrementvia", "vias +10 mil", CB_Action,
323
"ChangeSize,SelectedVias,+10", NULL },
324
{ "line", NULL, NULL, NULL, NULL },
325
{ "header", "change drilling hole of selected objects", NULL, NULL, NULL },
326
{ "decrementviahole", "vias -10 mil", CB_Action,
327
"ChangeDrillSize,SelectedVias,-10", NULL },
328
{ "incrementviahole", "vias +10 mil", CB_Action,
329
"ChangeDrillSize,SelectedVias,+10", NULL },
330
{ "decrementpinhole", "pins -10 mil", CB_Action,
331
"ChangeDrillSize,SelectedPins,-10", NULL },
332
{ "incrementpinhole", "pins +10 mil", CB_Action,
333
"ChangeDrillSize,SelectedPins,+10", NULL },
334
{ "line", NULL, NULL, NULL, NULL },
335
{ "header", "change square-flag of selected objects", NULL, NULL, NULL },
336
{ "elementsquare", "elements", CB_Action,
337
"ChangeSquare,SelectedElements", NULL },
338
{ "pinsquare", "pins", CB_Action,
339
"ChangeSquare,SelectedPins", NULL },
340
{ NULL, NULL, NULL, NULL, NULL }};
341
static PopupMenuType SelectionMenu =
342
{ "selection", NULL, SelectionMenuEntries, NULL, NULL, NULL };
343
static MenuButtonType SelectionMenuButton =
344
{ "selection", "Select", &SelectionMenu, NULL};
346
/* ---------------------------------------------------------------------------
347
* paste buffer menu button
349
static PopupEntryType BufferMenuEntries[] = {
350
{ "copy", "copy selection to buffer", CB_Position,
351
"PasteBuffer,Clear\n"
352
"PasteBuffer,AddSelected\n"
355
{ "cut", "cut selection to buffer", CB_Position,
356
"PasteBuffer,Clear\n"
357
"PasteBuffer,AddSelected\n"
361
{ "paste", "paste buffer to layout", CB_Action, "Mode,PasteBuffer", NULL },
362
{ "line", NULL, NULL, NULL, NULL },
363
{ "rotate", "rotate buffer 90 deg", CB_Action,
365
"PasteBuffer,Rotate,1",
367
{ "line", NULL, NULL, NULL, NULL },
368
{ "clear", "clear buffer", CB_Action, "PasteBuffer,Clear", NULL },
369
{ "convert", "convert buffer to element", CB_Action, "PasteBuffer,Convert", NULL },
370
{ "line", NULL, NULL, NULL, NULL },
371
{ "header", "select current buffer", NULL, NULL, NULL },
372
{ "buffer1", "#1", CB_Action, "PasteBuffer,1", NULL },
373
{ "buffer2", "#2", CB_Action, "PasteBuffer,2", NULL },
374
{ "buffer3", "#3", CB_Action, "PasteBuffer,3", NULL },
375
{ "buffer4", "#4", CB_Action, "PasteBuffer,4", NULL },
376
{ "buffer5", "#5", CB_Action, "PasteBuffer,5", NULL },
377
{ NULL, NULL, NULL, NULL, NULL }};
378
static PopupMenuType BufferMenu =
379
{ "buffer", NULL, BufferMenuEntries, CBPOPUP_Buffer, NULL, NULL };
380
static MenuButtonType BufferMenuButton =
381
{ "buffer", "Buffer", &BufferMenu, NULL};
383
/* ---------------------------------------------------------------------------
384
* connection menu button
386
static PopupEntryType ConnectionMenuEntries[] = {
387
{ "lookup", "lookup connection to object", CB_ObjectPosition,
388
"Connection,Find", NULL },
389
{ "resetPVP", "reset scanned pads/pins/vias", CB_Action,
390
"Connection,ResetPinsViasAndPads\n"
391
"Display,Redraw", NULL },
392
{ "resetLR", "reset scanned lines/polygons", CB_Action,
393
"Connection,ResetLinesAndPolygons\n"
394
"Display,Redraw", NULL },
395
{ "reset", "reset all connections", CB_Action,
397
"Display,Redraw", NULL },
398
{ NULL, NULL, NULL, NULL, NULL }};
399
static PopupMenuType ConnectionMenu =
400
{ "connections", NULL, ConnectionMenuEntries, NULL, NULL, NULL };
401
static MenuButtonType ConnectionMenuButton =
402
{ "connections", "Connects", &ConnectionMenu, NULL};
404
/* ---------------------------------------------------------------------------
407
static PopupEntryType ReportMenuEntries[] = {
408
{ "report", "generate object report", CB_Position, "Report,Object", NULL },
409
{ "drillreport", "generate drill summary", CB_Action, "Report,DrillReport", NULL },
410
{ "foundreport", "report found pins/pads", CB_Action, "Report,FoundPins", NULL },
411
{ NULL, NULL, NULL, NULL, NULL }};
412
static PopupMenuType ReportMenu =
413
{ "report", NULL, ReportMenuEntries, NULL, NULL, NULL };
414
static MenuButtonType ReportMenuButton =
415
{ "report", "Info", &ReportMenu, NULL};
417
/* ---------------------------------------------------------------------------
418
* windows menu button
420
static PopupEntryType WindowMenuEntries[] = {
421
{ "layout", "board layout", DoWindows, "1", NULL },
422
{ "library", "library", DoWindows, "2", NULL },
423
{ "log", "message log", DoWindows, "3", NULL },
424
{ "netlist", "netlist", DoWindows, "4", NULL },
425
{ NULL, NULL, NULL, NULL, NULL }};
426
static PopupMenuType WindowMenu =
427
{ "window", NULL, WindowMenuEntries, CBPOPUP_Window, NULL, NULL };
428
static MenuButtonType WindowMenuButton =
429
{ "window", "Window", &WindowMenu, NULL};
431
static void FillSizesMenu(void)
433
static char name[NUM_STYLES * 2 + 1][8];
434
static char label[NUM_STYLES * 2 + 1][64];
435
static char action[NUM_STYLES * 2 + 1][16];
438
for (i = 0; i < NUM_STYLES; i++)
440
sprintf(name[i],"size%d", i+1);
441
sprintf(label[i], "use '%s' routing style", PCB->RouteStyle[i].Name);
442
sprintf(action[i], "RouteStyle,%d", i+1);
443
SizesMenuEntries[i].Name = name[i];
444
SizesMenuEntries[i].Label = label[i];
445
SizesMenuEntries[i].Callback = CB_Action;
446
SizesMenuEntries[i].ClientData = (XtPointer) action[i];
448
for (i = NUM_STYLES; i < 2*NUM_STYLES; i++)
450
sprintf(name[i],"size%d", i+1);
451
sprintf(label[i], "adjust '%s' sizes ...", PCB->RouteStyle[i - NUM_STYLES].Name);
452
sprintf(action[i], "AdjustStyle,%d", i - NUM_STYLES +1);
453
SizesMenuEntries[i].Name = name[i];
454
SizesMenuEntries[i].Label = label[i];
455
SizesMenuEntries[i].Callback = CB_Action;
456
SizesMenuEntries[i].ClientData = (XtPointer) action[i];
458
sprintf(name[i],"size%d",i+1);
459
sprintf(label[i],"adjust active sizes ...");
460
sprintf(action[i],"AdjustStyle,0");
461
SizesMenuEntries[i].Name = name[i];
462
SizesMenuEntries[i].Label = label[i];
463
SizesMenuEntries[i].Callback = CB_Action;
464
SizesMenuEntries[i].ClientData = (XtPointer) action[i];
466
SizesMenuEntries[i].Name = NULL;
467
SizesMenuEntries[i].Label = NULL;
470
void UpdateSizesMenu(void)
475
for (i = 0; i < 2*NUM_STYLES + 1; i++)
476
XtVaSetValues(SizesMenuEntries[i].W, XtNlabel, SizesMenuEntries[i].Label, NULL);
478
/* ----------------------------------------------------------------------
479
* Initializes the sizes menu with the routing style names etc.
481
static Widget InitializeSizesMenu(Widget Parent, Widget Top, Widget Last)
484
return(InitMenuButton(Parent, &SizesMenuButton, Top, Last));
93
static Pixmap Check = BadAlloc;
95
/* --------------------------------------------------------------------------- */
97
/* FLAG(style,FlagCurrentStyle) */
103
if (style->Thick == Settings.LineThickness &&
104
style->Diameter == Settings.ViaThickness &&
105
style->Hole == Settings.ViaDrillingHole)
112
/* MENU(sizes,SizesMenuInclude) */
114
SizesMenuInclude(Resource *menu)
119
for (i = 0; i < NUM_STYLES; i++)
122
Resource *sub = resource_create(menu);
123
resource_add_val (sub, 0, PCB->RouteStyle[i].Name, 0);
124
sprintf(tmp, "SizesLabel(%d,use)", i);
125
resource_add_val (sub, 0, MyStrdup(tmp, "SizesMenuInclude"), 0);
126
sprintf(tmp, "RouteStyle(%d)", i+1);
127
resource_add_val (sub, 0, MyStrdup(tmp, "SizesMenuInclude"), 0);
128
sprintf(tmp, "CheckWhen(style,%d)", i+1);
129
resource_add_val (sub, 0, MyStrdup(tmp, "SizesMenuInclude"), 0);
130
resource_add_val (menu, 0, 0, sub);
132
acc = resource_create(sub);
133
sprintf(tmp, "Ctrl-%d", i+1);
134
resource_add_val (acc, 0, MyStrdup(tmp, "SizesMenuInclude"), 0);
135
sprintf(tmp, "Ctrl<Key>%d", i+1);
136
resource_add_val (acc, 0, MyStrdup(tmp, "SizesMenuInclude"), 0);
137
resource_add_val (sub, "a", 0, acc);
139
for (i = 0; i < NUM_STYLES; i++)
141
Resource *sub = resource_create(menu);
142
resource_add_val (sub, 0, PCB->RouteStyle[i].Name, 0);
143
sprintf(tmp, "SizesLabel(%d,set)", i);
144
resource_add_val (sub, 0, MyStrdup(tmp, "SizesMenuInclude"), 0);
145
sprintf(tmp, "AdjustStyle(%d)", i+1);
146
resource_add_val (sub, 0, MyStrdup(tmp, "SizesMenuInclude"), 0);
147
resource_add_val (menu, 0, 0, sub);
151
/* ACTION(SizesLabel,ActionSizesLabel) POPUP */
153
ActionSizesLabel (Widget w, XEvent * e, String * argv, Cardinal * argc)
156
int i = atoi(argv[0]);
158
if (strcmp(argv[1], "use") == 0)
159
sprintf(tmp, "Use '%s' routing style", PCB->RouteStyle[i].Name);
161
sprintf(tmp, "Adjust '%s' sizes ...", PCB->RouteStyle[i].Name);
162
XtVaSetValues (w, XtNlabel, tmp, NULL);
487
165
/* ----------------------------------------------------------------------
488
166
* menu callback for window menu
490
static void DoWindows(Widget W, XtPointer ClientData, XtPointer CallData)
492
int n = atoi( (char *) ClientData);
497
XRaiseWindow(Dpy, XtWindow(Output.Toplevel));
500
XMapRaised(Dpy, Library.Wind);
503
if (Settings.UseLogWindow)
504
XMapRaised(Dpy, LogWindID);
507
if (PCB->NetlistLib.Wind)
508
XMapRaised(Dpy, PCB->NetlistLib.Wind);
514
/* ----------------------------------------------------------------------
515
* menu callback interface for actions routines that don't need
516
* position information
518
* ClientData passes a pointer to a comma seperated list of arguments.
519
* The first one determines the action routine to be called, the
520
* rest of them are arguments to the action routine
522
* if more than one action is to be called a new list is seperated
525
static void CB_Action(Widget W, XtPointer ClientData, XtPointer CallData)
527
static char **array = NULL;
528
static size_t number = 0;
535
/* get a copy of the string and split it */
536
copy = MyStrdup((char *) ClientData, "CB_CallActionWithoutPosition()");
538
/* first loop over all action routines;
539
* strtok cannot be used in nested loops because it saves
540
* a pointer in a private data area which would be corrupted
543
for (current = copy; current; current = next)
545
/* lookup seperating '\n' character;
546
* update pointer if not at the end of the string
548
for (next = current; *next && *next != '\n'; next++);
557
token = strtok(current, ",");
558
for (n = 0; token; token = strtok(NULL, ","), n++)
560
/* allocate memory if necessary */
564
array = MyRealloc(array, number*sizeof(char *),
565
"CB_CallActionWithoutPosition()");
569
/* call action routine */
570
XtCallActionProc(Output.Output, array[0], NULL, &array[1], n-1);
577
/* ----------------------------------------------------------------------
578
* menu callback interface for misc actions routines that need
579
* position information
581
static void CB_Position(Widget W, XtPointer ClientData, XtPointer CallData)
583
int TheMode = Settings.Mode;
584
char *asString = (char *) ClientData;
586
if (!TEST_FLAG(ABSOLUTEFLAG, PCB) && strncmp("Display,ToggleGrid", asString, 18) == 0)
587
CB_Action(W, ClientData,CallData);
590
Settings.Mode = NO_MODE;
592
"Move the pointer to the appropriate screen position and press a button."))
593
CB_Action(W, ClientData, CallData);
594
if (Settings.Mode == NO_MODE)
595
Settings.Mode = TheMode;
599
/* ----------------------------------------------------------------------
600
* menu callback interface for element related actions routines that need
601
* position information
603
static void CB_ElementPosition(Widget W,
604
XtPointer ClientData, XtPointer CallData)
606
if (GetPosition("press a button at the element's location"))
607
CB_Action(W, ClientData, CallData);
610
/* ----------------------------------------------------------------------
611
* menu callback interface for text related actions routines that need
612
* position information
614
static void CB_TextPosition(Widget W,
615
XtPointer ClientData, XtPointer CallData)
617
if (GetPosition("press a button at the text location"))
618
CB_Action(W, ClientData, CallData);
621
/* ----------------------------------------------------------------------
622
* menu callback interface for pin/via related actions routines that need
623
* position information update
625
static void CB_ObjectPosition(Widget W,
626
XtPointer ClientData, XtPointer CallData)
628
if (GetPosition("press a button at a 'connecting-objects' location"))
629
CB_Action(W, ClientData, CallData);
632
/* ----------------------------------------------------------------------
633
* called before sizes menu is popped up
634
* used to mark the current route style
636
static void CBPOPUP_Sizes(Widget W, XtPointer ClientData, XtPointer CallData)
641
RemoveCheckFromMenu(&SizesMenu);
642
for (i = 0; i < NUM_STYLES; i++)
644
if (PCB->RouteStyle[i].Thick == Settings.LineThickness &&
645
PCB->RouteStyle[i].Diameter == Settings.ViaThickness &&
646
PCB->RouteStyle[i].Hole == Settings.ViaDrillingHole)
648
sprintf(menuname, "size%d", i+1);
649
CheckEntry(&SizesMenu, menuname);
655
/* ----------------------------------------------------------------------
656
* called before display menu is popped up
657
* used to mark the current grid-mode, zoom value ...
659
static void CBPOPUP_Display(Widget W, XtPointer ClientData, XtPointer CallData)
661
RemoveCheckFromMenu(&DisplayMenu);
662
XtSetSensitive(XtNameToWidget(DisplayMenu.W, "displayGrid"),
663
GetGridFactor() != 0);
664
if (TEST_FLAG(ABSOLUTEFLAG, PCB))
665
CheckEntry(&DisplayMenu, "toggleGrid");
666
if (Settings.DrawGrid)
667
CheckEntry(&DisplayMenu, "displayGrid");
668
if (Settings.ShowSolderSide)
669
CheckEntry(&DisplayMenu, "solderSide");
672
case 0: CheckEntry(&DisplayMenu, "zoom1"); break;
673
case 1: CheckEntry(&DisplayMenu, "zoom2"); break;
674
case 2: CheckEntry(&DisplayMenu, "zoom4"); break;
675
case 3: CheckEntry(&DisplayMenu, "zoom8"); break;
676
case 4: CheckEntry(&DisplayMenu, "zoom16"); break;
678
CheckEntry(&DisplayMenu,
679
TEST_FLAG(NAMEONPCBFLAG, PCB) ? "onPCB" :
680
TEST_FLAG(DESCRIPTIONFLAG, PCB) ? "description" : "value");
683
/* ----------------------------------------------------------------------
684
* called before settings menu is popped up
685
* used to mark the boolean settings
687
static void CBPOPUP_Settings(Widget W, XtPointer ClientData, XtPointer CallData)
689
RemoveCheckFromMenu(&SettingsMenu);
690
if (TEST_FLAG(ALLDIRECTIONFLAG, PCB))
691
CheckEntry(&SettingsMenu, "toggleAllDirections");
692
if (TEST_FLAG(RUBBERBANDFLAG, PCB))
693
CheckEntry(&SettingsMenu, "toggleRubberBandMode");
694
if (TEST_FLAG(SWAPSTARTDIRFLAG, PCB))
695
CheckEntry(&SettingsMenu, "toggleSwapStartDirection");
699
/* ----------------------------------------------------------------------
700
* called before file menu is popped up
701
* enables/disables printing
703
static void CBPOPUP_File(Widget W, XtPointer ClientData, XtPointer CallData)
705
XtSetSensitive(XtNameToWidget(FileMenu.W, "print"),
706
!IsDataEmpty(PCB->Data));
709
/* ----------------------------------------------------------------------
710
* called before buffer menu is popped up
712
static void CBPOPUP_Buffer(Widget W, XtPointer ClientData, XtPointer CallData)
716
RemoveCheckFromMenu(&BufferMenu);
717
sprintf(name, "buffer%i", Settings.BufferNumber+1);
718
CheckEntry(&BufferMenu, name);
721
/* ----------------------------------------------------------------------
722
* called before window menu is popped up
723
* enables/disables log window
725
static void CBPOPUP_Window(Widget W, XtPointer ClientData, XtPointer CallData)
727
XtSetSensitive(XtNameToWidget(WindowMenu.W, "log"),
728
Settings.UseLogWindow);
729
XtSetSensitive(XtNameToWidget(WindowMenu.W, "netlist"),
730
PCB->NetlistLib.Wind != 0);
734
/* ----------------------------------------------------------------------
735
* callback routine used by about entry
737
static void CB_About(Widget W, XtPointer ClientData, XtPointer CallData)
169
/* ACTION(DoWindows,ActionDoWindows) */
171
ActionDoWindows (Widget w, XEvent * e, String * argv, Cardinal * argc)
182
XRaiseWindow (Dpy, XtWindow (Output.Toplevel));
185
XMapRaised (Dpy, Library.Wind);
188
if (Settings.UseLogWindow)
189
XMapRaised (Dpy, LogWindID);
192
if (PCB->NetlistLib.Wind)
193
XMapRaised (Dpy, PCB->NetlistLib.Wind);
201
/* FLAG(grid,FlagGrid) */
205
return (int)PCB->Grid;
208
/* FLAG(zoom,FlagZoom) */
212
int zoom = (int)(PCB->Zoom + (PCB->Zoom < 0 ? -0.5 : 0.5));
213
if (abs(PCB->Zoom - zoom) > 0.1)
214
zoom = -8; /* not close enough to integer value */
218
/* FLAG(elementname,FlagElementName) */
222
if (TEST_FLAG (NAMEONPCBFLAG, PCB))
224
if (TEST_FLAG (DESCRIPTIONFLAG, PCB))
229
/* FLAG(gridfactor,FlagGridFactor) */
233
return GetGridFactor() != 0;
236
/* FLAG(shownumber,FlagTESTFLAG,SHOWNUMBERFLAG) */
237
/* FLAG(localref,FlagTESTFLAG,LOCALREFFLAG) */
238
/* FLAG(checkplanes,FlagTESTFLAG,CHECKPLANESFLAG) */
239
/* FLAG(showdrc,FlagTESTFLAG,SHOWDRCFLAG) */
240
/* FLAG(rubberband,FlagTESTFLAG,RUBBERBANDFLAG) */
241
/* FLAG(description,FlagTESTFLAG,DESCRIPTIONFLAG) */
242
/* FLAG(nameonpcb,FlagTESTFLAG,NAMEONPCBFLAG) */
243
/* FLAG(autodrc,FlagTESTFLAG,AUTODRCFLAG) */
244
/* FLAG(alldirection,FlagTESTFLAG,ALLDIRECTIONFLAG) */
245
/* FLAG(swapstartdir,FlagTESTFLAG,SWAPSTARTDIRFLAG) */
246
/* FLAG(uniquename,FlagTESTFLAG,UNIQUENAMEFLAG) */
247
/* FLAG(clearnew,FlagTESTFLAG,CLEARNEWFLAG) */
248
/* FLAG(snappin,FlagTESTFLAG,SNAPPINFLAG) */
249
/* FLAG(showmask,FlagTESTFLAG,SHOWMASKFLAG) */
250
/* FLAG(thindraw,FlagTESTFLAG,THINDRAWFLAG) */
251
/* FLAG(orthomove,FlagTESTFLAG,ORTHOMOVEFLAG) */
252
/* FLAG(liveroute,FlagTESTFLAG,LIVEROUTEFLAG) */
254
FlagTESTFLAG(int bit)
256
return TEST_FLAG(bit, PCB) ? 1 : 0;
259
/* FLAG(clearline,FlagSETTINGS,XtOffsetOf(SettingType,ClearLine)) */
260
/* FLAG(uniquenames,FlagSETTINGS,XtOffsetOf(SettingType,UniqueNames)) */
261
/* FLAG(uselogwindow,FlagSETTINGS,XtOffsetOf(SettingType,UseLogWindow)) */
262
/* FLAG(raiselogwindow,FlagSETTINGS,XtOffsetOf(SettingType,RaiseLogWindow)) */
263
/* FLAG(showsolderside,FlagSETTINGS,XtOffsetOf(SettingType,ShowSolderSide)) */
264
/* FLAG(savelastcommand,FlagSETTINGS,XtOffsetOf(SettingType,SaveLastCommand)) */
265
/* FLAG(saveintmp,FlagSETTINGS,XtOffsetOf(SettingType,SaveInTMP)) */
266
/* FLAG(drawgrid,FlagSETTINGS,XtOffsetOf(SettingType,DrawGrid)) */
267
/* FLAG(ratwarn,FlagSETTINGS,XtOffsetOf(SettingType,RatWarn)) */
268
/* FLAG(stipplepolygons,FlagSETTINGS,XtOffsetOf(SettingType,StipplePolygons)) */
269
/* FLAG(alldirectionlines,FlagSETTINGS,XtOffsetOf(SettingType,AllDirectionLines)) */
270
/* FLAG(rubberbandmode,FlagSETTINGS,XtOffsetOf(SettingType,RubberBandMode)) */
271
/* FLAG(swapstartdirection,FlagSETTINGS,XtOffsetOf(SettingType,SwapStartDirection)) */
272
/* FLAG(showdrc,FlagSETTINGS,XtOffsetOf(SettingType,ShowDRC)) */
273
/* FLAG(liveroute,FlagSETTINGS,XtOffsetOf(SettingType,liveRouting)) */
274
/* FLAG(resetafterelement,FlagSETTINGS,XtOffsetOf(SettingType,ResetAfterElement)) */
275
/* FLAG(ringbellwhenfinished,FlagSETTINGS,XtOffsetOf(SettingType,RingBellWhenFinished)) */
277
FlagSETTINGS(int ofs)
279
return *(Boolean *)((char *)(&Settings) + ofs);
282
/* FLAG(netlist,FlagNetlist) */
286
return PCB->NetlistLib.Wind != 0;
742
289
/* ---------------------------------------------------------------------------
743
290
* remove all 'check' symbols from menu entries
745
void RemoveCheckFromMenu(PopupMenuTypePtr MenuPtr)
293
RemoveCheckFromMenu (PopupMenuTypePtr MenuPtr)
747
PopupEntryTypePtr entries = MenuPtr->Entries;
295
PopupEntryTypePtr entries = MenuPtr->Entries;
749
for (; entries->Name; entries++)
751
XtVaSetValues(entries->W, XtNleftBitmap, None, NULL);
297
for (; entries->Name; entries++)
299
XtVaSetValues (entries->W, XtNleftBitmap, None, NULL);
754
302
/* ---------------------------------------------------------------------------
755
303
* add 'check' symbol to menu entry
757
void CheckEntry(PopupMenuTypePtr MenuPtr, String WidgetName)
306
CheckEntry (PopupMenuTypePtr MenuPtr, String WidgetName)
759
PopupEntryTypePtr entries = MenuPtr->Entries;
308
PopupEntryTypePtr entries = MenuPtr->Entries;
761
if (InitCheckPixmap())
762
for (; entries->Name; entries++)
763
if (entries->Label && !strcmp(entries->Name, (char *) WidgetName))
765
XtVaSetValues(entries->W, XtNleftBitmap, Check, NULL);
310
if (InitCheckPixmap ())
311
for (; entries->Name; entries++)
312
if (entries->Label && !strcmp (entries->Name, (char *) WidgetName))
314
XtVaSetValues (entries->W, XtNleftBitmap, Check, NULL);
770
319
/* ---------------------------------------------------------------------------