63
73
/* ---------------------------------------------------------------------------
66
typedef struct /* description for a single mode button */
76
typedef struct /* description for a single mode button */
68
char *Name, /* the widgets name and label */
70
int Mode; /* mode ID */
71
char *Bitmap; /* background bitmap data */
72
unsigned int Width, /* bitmap size */
75
} ModeButtonType, *ModeButtonTypePtr;
78
char *Name, /* the widgets name and label */
80
int Mode; /* mode ID */
81
unsigned char *Bitmap; /* background bitmap data */
82
unsigned int Width, /* bitmap size */
86
ModeButtonType, *ModeButtonTypePtr;
77
88
/* ---------------------------------------------------------------------------
78
89
* some local prototypes
80
static Widget AddLabel(String, Widget, Widget, Widget);
81
static void AddDrawingLayerSelection(Widget);
82
static void AddOnOffSelection(Widget);
83
static void UpdateDrawingLayerSelection(void);
84
static void UpdateOnOffSelection(void);
85
static Cardinal GetGroupOfLayer(Cardinal);
86
static void PushOnTopOfLayerStack(int);
87
static void CBPOPUP_SetDrawingLayer(Widget, XtPointer, XtPointer);
88
static void CB_SetOnOff(Widget, XtPointer, XtPointer);
89
static void CB_SetDrawingLayer(Widget, XtPointer, XtPointer);
90
static void CB_SetMode(Widget, XtPointer, XtPointer);
91
static Widget AddLabel (String, Widget, Widget, Widget);
92
static void AddDrawingLayerSelection (Widget);
93
static void AddOnOffSelection (Widget);
94
static void UpdateDrawingLayerSelection (void);
95
static void UpdateOnOffSelection (void);
96
static void PushOnTopOfLayerStack (int);
97
static void CBPOPUP_SetDrawingLayer (Widget, XtPointer, XtPointer);
98
static void CB_SetOnOff (Widget, XtPointer, XtPointer);
99
static void CB_SetDrawingLayer (Widget, XtPointer, XtPointer);
100
static void CB_SetMode (Widget, XtPointer, XtPointer);
92
102
/* ---------------------------------------------------------------------------
93
103
* some local identifiers
95
static Widget OnOffWidgets[MAX_LAYER+6]; /* widgets for on/off selection */
97
static PopupEntryType DrawingLayerMenuEntries[MAX_LAYER+2];
98
static PopupMenuType DrawingLayerMenu =
99
{ "drawingLayer", NULL, DrawingLayerMenuEntries,
100
CBPOPUP_SetDrawingLayer, NULL, NULL };
101
static MenuButtonType DrawingLayerMenuButton =
102
{ "drawingLayer", "DrawingLayer", &DrawingLayerMenu, NULL};
104
static ModeButtonType ModeButtons[] = {
105
{ "viaIcon", "via", VIA_MODE, ViaModeIcon_bits,
106
ViaModeIcon_width, ViaModeIcon_height, NULL },
107
{ "lineIcon", "line", LINE_MODE, LineModeIcon_bits,
108
LineModeIcon_width, LineModeIcon_height, NULL },
109
{ "arcIcon", "arc", ARC_MODE, ArcModeIcon_bits,
110
ArcModeIcon_width, ArcModeIcon_height, NULL},
111
{ "textIcon", "text", TEXT_MODE, TextModeIcon_bits,
112
TextModeIcon_width, TextModeIcon_height, NULL },
113
{ "rectangleIcon", "rectangle", RECTANGLE_MODE, RectModeIcon_bits,
114
RectModeIcon_width, RectModeIcon_height, NULL },
115
{ "polygonIcon", "polygon", POLYGON_MODE, PolygonModeIcon_bits,
116
PolygonModeIcon_width, PolygonModeIcon_height, NULL },
117
{ "bufferIcon", "buffer", PASTEBUFFER_MODE, BufferModeIcon_bits,
118
BufferModeIcon_width, BufferModeIcon_height, NULL },
119
{ "removeIcon", "remove", REMOVE_MODE, RemoveModeIcon_bits,
120
RemoveModeIcon_width, RemoveModeIcon_height, NULL },
121
{ "rotateIcon", "rotate", ROTATE_MODE, RotateModeIcon_bits,
122
RotateModeIcon_width, RotateModeIcon_height, NULL },
123
{ "insertPointIcon", "insertPoint", INSERTPOINT_MODE,
124
InsertPointModeIcon_bits, InsertPointModeIcon_width,
125
InsertPointModeIcon_height, NULL },
126
{ "thermalIcon", "thermal", THERMAL_MODE, ThermalModeIcon_bits,
127
ThermalModeIcon_width, ThermalModeIcon_height, NULL},
128
{ "selectIcon", "select", ARROW_MODE, SelModeIcon_bits,
129
SelModeIcon_width, SelModeIcon_height, NULL}};
105
static Widget OnOffWidgets[MAX_LAYER + 6]; /* widgets for on/off selection */
107
static PopupEntryType DrawingLayerMenuEntries[MAX_LAYER + 3];
108
static PopupMenuType DrawingLayerMenu =
109
{ "drawingLayer", NULL, DrawingLayerMenuEntries,
110
CBPOPUP_SetDrawingLayer, NULL, NULL
112
static MenuButtonType DrawingLayerMenuButton =
113
{ "drawingLayer", "DrawingLayer", &DrawingLayerMenu, NULL };
115
static ModeButtonType ModeButtons[] = {
116
{"viaIcon", "via", VIA_MODE, ViaModeIcon_bits,
117
ViaModeIcon_width, ViaModeIcon_height, NULL},
118
{"lineIcon", "line", LINE_MODE, LineModeIcon_bits,
119
LineModeIcon_width, LineModeIcon_height, NULL},
120
{"arcIcon", "arc", ARC_MODE, ArcModeIcon_bits,
121
ArcModeIcon_width, ArcModeIcon_height, NULL},
122
{"textIcon", "text", TEXT_MODE, TextModeIcon_bits,
123
TextModeIcon_width, TextModeIcon_height, NULL},
124
{"rectangleIcon", "rectangle", RECTANGLE_MODE, RectModeIcon_bits,
125
RectModeIcon_width, RectModeIcon_height, NULL},
126
{"polygonIcon", "polygon", POLYGON_MODE, PolygonModeIcon_bits,
127
PolygonModeIcon_width, PolygonModeIcon_height, NULL},
128
{"bufferIcon", "buffer", PASTEBUFFER_MODE, BufferModeIcon_bits,
129
BufferModeIcon_width, BufferModeIcon_height, NULL},
130
{"removeIcon", "remove", REMOVE_MODE, RemoveModeIcon_bits,
131
RemoveModeIcon_width, RemoveModeIcon_height, NULL},
132
{"rotateIcon", "rotate", ROTATE_MODE, RotateModeIcon_bits,
133
RotateModeIcon_width, RotateModeIcon_height, NULL},
134
{"insertPointIcon", "insertPoint", INSERTPOINT_MODE,
135
InsertPointModeIcon_bits, InsertPointModeIcon_width,
136
InsertPointModeIcon_height, NULL},
137
{"thermalIcon", "thermal", THERMAL_MODE, ThermalModeIcon_bits,
138
ThermalModeIcon_width, ThermalModeIcon_height, NULL},
139
{"selectIcon", "select", ARROW_MODE, SelModeIcon_bits,
140
SelModeIcon_width, SelModeIcon_height, NULL},
141
{"panIcon", "pan", PAN_MODE, PanModeIcon_bits,
142
PanModeIcon_width, PanModeIcon_height, NULL},
143
{"lockIcon", "lock", LOCK_MODE, LockModeIcon_bits,
144
LockModeIcon_width, LockModeIcon_height, NULL}
131
147
/* ---------------------------------------------------------------------------
132
148
* adds a label without border, surrounded by additional space
133
149
* at the specified position
135
static Widget AddLabel(String Label, Widget Parent, Widget Top, Widget Left)
152
AddLabel (String Label, Widget Parent, Widget Top, Widget Left)
140
label = XtVaCreateManagedWidget("label", labelWidgetClass,
145
XtNjustify, XtJustifyCenter,
148
XtVaGetValues(label, XtNheight, &height, NULL);
149
XtVaSetValues(label, XtNheight, 3*height/2, NULL);
157
label = XtVaCreateManagedWidget ("label", labelWidgetClass,
162
XtNjustify, XtJustifyCenter,
164
XtVaGetValues (label, XtNheight, &height, NULL);
165
XtVaSetValues (label, XtNheight, 3 * height / 2, NULL);
153
169
/* ---------------------------------------------------------------------------
154
170
* create drawing-layer selection menu
156
static void AddDrawingLayerSelection(Widget Parent)
173
AddDrawingLayerSelection (Widget Parent)
158
static char name[MAX_LAYER + 1][20];
163
/* fill struct and initialize menu button */
164
for (i = 0; i < MAX_LAYER + 1; i++)
166
/* the widgets name is used for the 'CheckEntry()' funtion
167
* and must be declared static therefore
169
sprintf(name[i], "layer%-i", i+1);
170
DrawingLayerMenuEntries[i].Name = name[i];
171
DrawingLayerMenuEntries[i].Label = name[i];
172
DrawingLayerMenuEntries[i].Callback = CB_SetDrawingLayer;
173
DrawingLayerMenuEntries[i].ClientData = (XtPointer) i;
177
/* init routine exits on NULL pointer */
178
DrawingLayerMenuEntries[i].Name = NULL;
179
DrawingLayerMenuEntries[i].Label = NULL;
180
label = AddLabel("active", Parent, NULL, NULL);
181
InitMenuButton(Parent, &DrawingLayerMenuButton, label, NULL);
182
XtVaGetValues(DrawingLayerMenuButton.W,
183
XtNbackground, &background,
185
XtVaSetValues(DrawingLayerMenuButton.W,
186
XtNforeground, background,
175
static char name[MAX_LAYER + 2][20];
180
/* fill struct and initialize menu button */
181
for (i = 0; i < MAX_LAYER + 2; i++)
183
/* the widgets name is used for the 'CheckEntry()' funtion
184
* and must be declared static therefore
186
sprintf (name[i], "layer%-li", i + 1);
187
DrawingLayerMenuEntries[i].Name = name[i];
188
DrawingLayerMenuEntries[i].Label = name[i];
189
DrawingLayerMenuEntries[i].Callback = CB_SetDrawingLayer;
190
DrawingLayerMenuEntries[i].ClientData = (XtPointer) i;
193
/* init routine exits on NULL pointer */
194
DrawingLayerMenuEntries[i].Name = NULL;
195
DrawingLayerMenuEntries[i].Label = NULL;
196
label = AddLabel ("active", Parent, NULL, NULL);
197
InitMenuButton (Parent, &DrawingLayerMenuButton, label, NULL);
198
XtVaGetValues (DrawingLayerMenuButton.W, XtNbackground, &background, NULL);
199
XtVaSetValues (DrawingLayerMenuButton.W, XtNforeground, background, NULL);
190
202
/* ---------------------------------------------------------------------------
191
203
* adds the layer On/Off selection buttons to our dialog (downwards)
192
204
* the label for the layer buttons are set by UpdateOnOffSelection()
194
static void AddOnOffSelection(Widget Parent)
207
AddOnOffSelection (Widget Parent)
196
static char name[MAX_LAYER+5][20];
202
/* insert a label at the top */
203
last = AddLabel("on/off", Parent, NULL, NULL);
205
for (i = 0; i < MAX_LAYER+5; i++)
209
static char name[MAX_LAYER + 5][20];
215
/* insert a label at the top */
216
last = AddLabel ("on/off", Parent, NULL, NULL);
218
for (i = 0; i < MAX_LAYER + 5; i++)
209
case MAX_LAYER: /* settings for elements */
210
color = PCB->ElementColor;
212
strcpy(name[i], "elements");
215
case MAX_LAYER+1: /* settings for pins */
216
color = PCB->PinColor;
218
strcpy(name[i], "pins");
221
case MAX_LAYER+2: /* settings for vias */
222
color = PCB->ViaColor;
224
strcpy(name[i], "vias");
227
case MAX_LAYER+3: /* settings for objects on opposite side */
228
color = PCB->InvisibleObjectsColor;
230
strcpy(name[i], "invisible");
233
case MAX_LAYER+4: /* settings for rats */
234
color = PCB->RatColor;
236
strcpy(name[i], "rats");
240
default: /* layers */
241
color = PCB->Data->Layer[i].Color;
243
sprintf(name[i], "layer%-i", i+1);
247
/* create widget and install callback function */
248
OnOffWidgets[i] = XtVaCreateManagedWidget(name[i],toggleWidgetClass,
251
XtNforeground, color,
256
last = OnOffWidgets[i];
257
XtAddCallback(last, XtNcallback, CB_SetOnOff, (XtPointer) i);
222
case MAX_LAYER: /* settings for elements */
223
color = PCB->ElementColor;
225
strcpy (name[i], "elements");
228
case MAX_LAYER + 1: /* settings for pins */
229
color = PCB->PinColor;
231
strcpy (name[i], "pins");
234
case MAX_LAYER + 2: /* settings for vias */
235
color = PCB->ViaColor;
237
strcpy (name[i], "vias");
240
case MAX_LAYER + 3: /* settings for objects on opposite side */
241
color = PCB->InvisibleObjectsColor;
243
strcpy (name[i], "invisible");
246
case MAX_LAYER + 4: /* settings for rats */
247
color = PCB->RatColor;
249
strcpy (name[i], "rats");
253
default: /* layers */
254
color = PCB->Data->Layer[i].Color;
256
sprintf (name[i], "layer%-li", i + 1);
260
/* create widget and install callback function */
261
OnOffWidgets[i] = XtVaCreateManagedWidget (name[i], toggleWidgetClass,
264
XtNforeground, color,
268
XtAddEventHandler (OnOffWidgets[i], EnterWindowMask, False,
269
CB_StopScroll, NULL);
270
last = OnOffWidgets[i];
271
XtAddCallback (last, XtNcallback, CB_SetOnOff, (XtPointer) i);
261
275
/* ---------------------------------------------------------------------------
262
276
* updates the drawing-layer selection menu
264
static void UpdateDrawingLayerSelection(void)
279
UpdateDrawingLayerSelection (void)
268
/* PCB may have changed; we have to make sure that the
269
* labels are set correct
271
for (i = 0; i < MAX_LAYER; i++)
272
XtVaSetValues(DrawingLayerMenuEntries[i].W,
273
XtNlabel, UNKNOWN(PCB->Data->Layer[i].Name),
274
XtNforeground, PCB->Data->Layer[i].Color,
276
XtVaSetValues(DrawingLayerMenuEntries[i].W,
277
XtNlabel, UNKNOWN(PCB->Data->Layer[i].Name),
278
XtNforeground, PCB->ElementColor,
281
/* set the label of the menu-button itself and reset a flag */
282
XtVaSetValues(DrawingLayerMenuButton.W,
283
XtNlabel, UNKNOWN(CURRENT->Name),
284
XtNbackground, CURRENT->Color,
283
/* PCB may have changed; we have to make sure that the
284
* labels are set correct
286
for (i = 0; i < MAX_LAYER; i++)
287
XtVaSetValues (DrawingLayerMenuEntries[i].W,
288
XtNlabel, UNKNOWN (PCB->Data->Layer[i].Name),
289
XtNforeground, PCB->Data->Layer[i].Color, NULL);
290
XtVaSetValues (DrawingLayerMenuEntries[i].W,
291
XtNlabel, UNKNOWN (PCB->Data->Layer[i].Name),
292
XtNforeground, PCB->ElementColor, NULL);
294
XtVaSetValues (DrawingLayerMenuEntries[i].W,
295
XtNlabel, "Netlist", XtNforeground, PCB->RatColor, NULL);
296
/* set the label of the menu-button itself */
298
XtVaSetValues (DrawingLayerMenuButton.W,
299
XtNlabel, "Netlist", XtNbackground, PCB->RatColor, NULL);
301
XtVaSetValues (DrawingLayerMenuButton.W,
302
XtNlabel, UNKNOWN (CURRENT->Name),
303
XtNbackground, CURRENT->Color, NULL);
288
306
/* ---------------------------------------------------------------------------
289
307
* updates the layer On/Off selection buttons
291
static void UpdateOnOffSelection(void)
310
UpdateOnOffSelection (void)
295
/* the buttons for elements, vias and pins never
296
* change their label, so we only check the layer buttons
298
for (i = 0; i < MAX_LAYER; i++)
299
XtVaSetValues(OnOffWidgets[i],
300
XtNlabel, UNKNOWN(PCB->Data->Layer[i].Name),
301
XtNstate, PCB->Data->Layer[i].On,
304
/* now set the state of elements, pins and vias */
305
XtVaSetValues(OnOffWidgets[i++], XtNstate, PCB->ElementOn, NULL);
306
XtVaSetValues(OnOffWidgets[i++], XtNstate, PCB->PinOn, NULL);
307
XtVaSetValues(OnOffWidgets[i++], XtNstate, PCB->ViaOn, NULL);
308
XtVaSetValues(OnOffWidgets[i++], XtNstate, PCB->InvisibleObjectsOn, NULL);
309
XtVaSetValues(OnOffWidgets[i++], XtNstate, PCB->RatOn, NULL);
314
/* the buttons for elements, vias and pins never
315
* change their label, so we only check the layer buttons
317
for (i = 0; i < MAX_LAYER; i++)
318
XtVaSetValues (OnOffWidgets[i],
319
XtNlabel, UNKNOWN (PCB->Data->Layer[i].Name),
320
XtNstate, PCB->Data->Layer[i].On, NULL);
322
/* now set the state of elements, pins and vias */
323
XtVaSetValues (OnOffWidgets[i++], XtNstate, PCB->ElementOn, NULL);
324
XtVaSetValues (OnOffWidgets[i++], XtNstate, PCB->PinOn, NULL);
325
XtVaSetValues (OnOffWidgets[i++], XtNstate, PCB->ViaOn, NULL);
326
XtVaSetValues (OnOffWidgets[i++], XtNstate, PCB->InvisibleObjectsOn, NULL);
327
XtVaSetValues (OnOffWidgets[i++], XtNstate, PCB->RatOn, NULL);
312
330
/* ----------------------------------------------------------------------
313
331
* lookup the group to which a layer belongs to
314
332
* returns MAX_LAYER if no group is found
316
static Cardinal GetGroupOfLayer(Cardinal Layer)
335
GetGroupOfLayer (Cardinal Layer)
321
if (Layer == MAX_LAYER)
323
for (group = 0; group < MAX_LAYER; group++)
324
for (i = 0; i < PCB->LayerGroups.Number[group]; i++)
325
if (PCB->LayerGroups.Entries[group][i] == Layer)
339
if (Layer == MAX_LAYER)
341
for (group = 0; group < MAX_LAYER; group++)
342
for (i = 0; i < PCB->LayerGroups.Number[group]; i++)
343
if (PCB->LayerGroups.Entries[group][i] == Layer)
330
348
/* ----------------------------------------------------------------------
331
349
* changes the visibility of all layers in a group
332
350
* returns the number of changed layers
334
int ChangeGroupVisibility(Cardinal Layer, Boolean On, Boolean ChangeStackOrder)
353
ChangeGroupVisibility (Cardinal Layer, Boolean On, Boolean ChangeStackOrder)
338
changed = 1; /* at least the current layer changes */
340
/* special case of silk layer */
341
if (Layer == MAX_LAYER)
344
PCB->SilkActive = On && ChangeStackOrder;
346
BACKSILKLAYER->On = (On && PCB->InvisibleObjectsOn);
347
UpdateOnOffSelection();
350
PCB->SilkActive = (On && ChangeStackOrder) ? False : PCB->SilkActive;
352
/* decrement 'i' to keep stack in order of layergroup */
353
if ((group = GetGroupOfLayer(Layer)) < MAX_LAYER)
354
for (i = PCB->LayerGroups.Number[group]; i;)
356
int layer = PCB->LayerGroups.Entries[group][--i];
358
/* dont count the passed member of the group */
359
if (layer != Layer && layer < MAX_LAYER)
361
PCB->Data->Layer[layer].On = On;
363
/* push layer on top of stack if switched on */
364
if (On && ChangeStackOrder)
365
PushOnTopOfLayerStack(layer);
370
/* change at least the passed layer */
371
PCB->Data->Layer[Layer].On = On;
372
if (On && ChangeStackOrder)
373
PushOnTopOfLayerStack(Layer);
375
/* update control panel and exit */
376
UpdateOnOffSelection();
355
int group, i, changed = 1; /* at least the current layer changes */
357
/* special case of rat (netlist layer) */
358
if (Layer == MAX_LAYER + 1)
361
PCB->RatDraw = On && ChangeStackOrder;
364
UpdateOnOffSelection ();
368
PCB->RatDraw = (On && ChangeStackOrder) ? False : PCB->RatDraw;
370
/* special case of silk layer */
371
if (Layer == MAX_LAYER)
374
PCB->SilkActive = On && ChangeStackOrder;
375
PCB->Data->SILKLAYER.On = On;
376
PCB->Data->BACKSILKLAYER.On = (On && PCB->InvisibleObjectsOn);
377
UpdateOnOffSelection ();
380
PCB->SilkActive = (On && ChangeStackOrder) ? False : PCB->SilkActive;
382
/* decrement 'i' to keep stack in order of layergroup */
383
if ((group = GetGroupOfLayer (Layer)) < MAX_LAYER)
384
for (i = PCB->LayerGroups.Number[group]; i;)
386
int layer = PCB->LayerGroups.Entries[group][--i];
388
/* dont count the passed member of the group */
389
if (layer != Layer && layer < MAX_LAYER)
391
PCB->Data->Layer[layer].On = On;
393
/* push layer on top of stack if switched on */
394
if (On && ChangeStackOrder)
395
PushOnTopOfLayerStack (layer);
400
/* change at least the passed layer */
401
PCB->Data->Layer[Layer].On = On;
402
if (On && ChangeStackOrder)
403
PushOnTopOfLayerStack (Layer);
405
/* update control panel and exit */
406
UpdateOnOffSelection ();
380
410
/* ---------------------------------------------------------------------------
381
411
* move layer (number is passed in) to top of layerstack
383
static void PushOnTopOfLayerStack(int NewTop)
414
PushOnTopOfLayerStack (int NewTop)
387
/* ignore COMPONENT_LAYER and SOLDER_LAYER */
388
if (NewTop < MAX_LAYER)
390
/* first find position of passed one */
391
for (i = 0; i < MAX_LAYER; i++)
392
if (LayerStack[i] == NewTop)
395
/* bring this element to the top of the stack */
397
LayerStack[i] = LayerStack[i-1];
398
LayerStack[0] = NewTop;
418
/* ignore COMPONENT_LAYER and SOLDER_LAYER */
419
if (NewTop < MAX_LAYER)
421
/* first find position of passed one */
422
for (i = 0; i < MAX_LAYER; i++)
423
if (LayerStack[i] == NewTop)
426
/* bring this element to the top of the stack */
428
LayerStack[i] = LayerStack[i - 1];
429
LayerStack[0] = NewTop;
402
433
/* ---------------------------------------------------------------------------
403
434
* callback routine, called when drawing-layer menu pops up
405
static void CBPOPUP_SetDrawingLayer(Widget W,
406
XtPointer ClientData, XtPointer CallData)
437
CBPOPUP_SetDrawingLayer (Widget W, XtPointer ClientData, XtPointer CallData)
410
RemoveCheckFromMenu(&DrawingLayerMenu);
411
sprintf(name, "layer%-i", MIN(INDEXOFCURRENT, MAX_LAYER) + 1);
412
CheckEntry(&DrawingLayerMenu, name);
441
RemoveCheckFromMenu (&DrawingLayerMenu);
443
sprintf (name, "layer%-i", MAX_LAYER + 2);
445
sprintf (name, "layer%-i", MIN (INDEXOFCURRENT, MAX_LAYER) + 1);
446
CheckEntry (&DrawingLayerMenu, name);
415
450
/* ---------------------------------------------------------------------------
418
453
* this routine is either called from one of the toggle widgets or
419
454
* from the output window by using accelerators
421
static void CB_SetDrawingLayer(Widget W,
422
XtPointer ClientData, XtPointer CallData)
457
CB_SetDrawingLayer (Widget W, XtPointer ClientData, XtPointer CallData)
426
ChangeGroupVisibility((int) ClientData, True, True);
428
XtVaSetValues(DrawingLayerMenuButton.W,
429
XtNlabel, UNKNOWN(lay->Name),
430
XtNbackground, lay->Color,
461
ChangeGroupVisibility ((long int) ClientData, True, True);
464
XtVaSetValues (DrawingLayerMenuButton.W,
465
XtNlabel, "Netlist", XtNbackground, PCB->RatColor, NULL);
467
XtVaSetValues (DrawingLayerMenuButton.W,
468
XtNlabel, UNKNOWN (lay->Name),
469
XtNbackground, lay->Color, NULL);
435
473
/* ---------------------------------------------------------------------------
436
474
* callback routine, called when On/Off flag of layer is changed
438
static void CB_SetOnOff(Widget W, XtPointer ClientData, XtPointer CallData)
477
CB_SetOnOff (Widget W, XtPointer ClientData, XtPointer CallData)
440
Boolean state, Redraw = False;
441
int layer = (int) ClientData;
443
/* get new state of widget */
444
XtVaGetValues(W, XtNstate, &state, NULL);
446
/* set redraw flag if object exists */
449
case MAX_LAYER+1: /* settings for pins */
451
Redraw |= (PCB->Data->ElementN != 0);
454
case MAX_LAYER+2: /* settings for vias */
456
Redraw |= (PCB->Data->ViaN != 0);
459
case MAX_LAYER+3: /* settings for invisible objects */
460
PCB->InvisibleObjectsOn = state;
461
BACKSILKLAYER->On = (state && PCB->ElementOn);
465
case MAX_LAYER+4: /* settings for rat lines */
467
Redraw |= (PCB->Data->RatN != 0);
474
/* check if active layer is in the group;
475
* if YES, make a different one active if possible
477
if ((group = GetGroupOfLayer(layer)) ==
478
GetGroupOfLayer(MIN(MAX_LAYER, INDEXOFCURRENT)))
480
/* find next visible layer and make it
481
* active so this one can be turned off
483
for (i = (layer + 1) % (MAX_LAYER + 1);
484
i != layer; i = (i + 1) % (MAX_LAYER + 1))
485
if (PCB->Data->Layer[i].On == True &&
486
GetGroupOfLayer(i) != group)
490
ChangeGroupVisibility((int) i, True, True);
491
XtVaSetValues(DrawingLayerMenuButton.W,
492
XtNlabel, UNKNOWN(CURRENT->Name),
493
XtNbackground, CURRENT->Color,
498
/* everything else off, we can't turn this off too */
499
XtVaSetValues(W, XtNstate, True, NULL);
504
/* switch layer group on/off */
505
ChangeGroupVisibility(layer, state, False);
479
Boolean state, Redraw = False;
480
long int layer = (long int) ClientData;
482
/* get new state of widget */
483
XtVaGetValues (W, XtNstate, &state, NULL);
485
/* set redraw flag if object exists */
488
case MAX_LAYER + 1: /* settings for pins */
490
Redraw |= (PCB->Data->ElementN != 0);
493
case MAX_LAYER + 2: /* settings for vias */
495
Redraw |= (PCB->Data->ViaN != 0);
498
case MAX_LAYER + 3: /* settings for invisible objects */
499
PCB->InvisibleObjectsOn = state;
500
PCB->Data->BACKSILKLAYER.On = (state && PCB->ElementOn);
504
case MAX_LAYER + 4: /* settings for rat lines */
506
Redraw |= (PCB->Data->RatN != 0);
513
/* check if active layer is in the group;
514
* if YES, make a different one active if possible
516
if ((group = GetGroupOfLayer (layer)) ==
517
GetGroupOfLayer (MIN (MAX_LAYER, INDEXOFCURRENT)))
519
/* find next visible layer and make it
520
* active so this one can be turned off
522
for (i = (layer + 1) % (MAX_LAYER + 1);
523
i != layer; i = (i + 1) % (MAX_LAYER + 1))
524
if (PCB->Data->Layer[i].On == True &&
525
GetGroupOfLayer (i) != group)
529
ChangeGroupVisibility ((int) i, True, True);
530
XtVaSetValues (DrawingLayerMenuButton.W,
531
XtNlabel, UNKNOWN (CURRENT->Name),
532
XtNbackground, CURRENT->Color, NULL);
536
/* everything else off, we can't turn this off too */
537
XtVaSetValues (W, XtNstate, True, NULL);
542
/* switch layer group on/off */
543
ChangeGroupVisibility (layer, state, False);
514
552
/* ---------------------------------------------------------------------------
518
556
* returns popup shell widget
520
void InitControlPanel(Widget Parent, Widget Top, Widget Left)
559
InitControlPanel (Widget Parent, Widget Top, Widget Left)
526
masterform = XtVaCreateManagedWidget("controlMasterForm", formWidgetClass,
532
InitOutputPanner(masterform, NULL, NULL);
533
visible = XtVaCreateManagedWidget("onOffSelection", formWidgetClass,
535
XtNfromVert, Output.panner,
538
drawing = XtVaCreateManagedWidget("currentSelection", formWidgetClass,
540
XtNfromVert, visible,
544
/* we now add the other widgets to the two forms */
545
AddOnOffSelection(visible);
546
AddDrawingLayerSelection(drawing);
547
Output.Control = masterform;
561
Widget masterform, visible, drawing;
563
masterform = XtVaCreateManagedWidget ("controlMasterForm", formWidgetClass,
566
XtNfromVert, Top, LAYOUT_TOP, NULL);
567
InitOutputPanner (masterform, NULL, NULL);
568
visible = XtVaCreateManagedWidget ("onOffSelection", formWidgetClass,
570
XtNfromVert, Output.panner,
571
XtNfromHoriz, NULL, NULL);
572
drawing = XtVaCreateManagedWidget ("currentSelection", formWidgetClass,
574
XtNfromVert, visible,
575
XtNfromHoriz, NULL, NULL);
577
/* we now add the other widgets to the two forms */
578
AddOnOffSelection (visible);
579
AddDrawingLayerSelection (drawing);
580
Output.Control = masterform;
550
583
/* ---------------------------------------------------------------------------
551
584
* updates label and sizes in control panel
553
void UpdateControlPanel(void)
587
UpdateControlPanel (void)
555
UpdateOnOffSelection();
556
UpdateDrawingLayerSelection();
589
UpdateOnOffSelection ();
590
UpdateDrawingLayerSelection ();
559
593
/* ---------------------------------------------------------------------------
560
594
* callback routine, called when current mode is changed
562
static void CB_SetMode(Widget W, XtPointer ClientData, XtPointer CallData)
597
CB_SetMode (Widget W, XtPointer ClientData, XtPointer CallData)
564
ModeButtonTypePtr button;
566
/* the radio group is determined by the widget of button 0 */
567
button = (ModeButtonTypePtr) XawToggleGetCurrent(ModeButtons[0].W);
568
SetMode(button ? button->Mode : NO_MODE);
599
ModeButtonTypePtr button;
601
/* the radio group is determined by the widget of button 0 */
602
button = (ModeButtonTypePtr) XawToggleGetCurrent (ModeButtons[0].W);
604
SetMode (button->Mode);
571
607
/* ---------------------------------------------------------------------------
572
608
* updates the mode selection buttons to reflect the currently set mode
574
void UpdateModeSelection(void)
611
UpdateModeSelection (void)
576
/* reset all buttons if no mode is selected;
577
* the first buttons widget identifies the radio group whereas
578
* radioData points to the array member itself
580
if (Settings.Mode == NO_MODE)
581
XawToggleUnsetCurrent(ModeButtons[0].W);
613
/* reset all buttons if no mode is selected;
614
* the first buttons widget identifies the radio group whereas
615
* radioData points to the array member itself
586
for (i = 0; i < ENTRIES(ModeButtons); i++)
587
if (Settings.Mode == ModeButtons[i].Mode)
589
XawToggleSetCurrent(ModeButtons[0].W,
590
(XtPointer) &ModeButtons[i]);
619
for (i = 0; i < ENTRIES (ModeButtons); i++)
620
if (Settings.Mode == ModeButtons[i].Mode)
622
XawToggleSetCurrent (ModeButtons[0].W, (XtPointer) & ModeButtons[i]);
596
627
/* ---------------------------------------------------------------------------
597
628
* initializes mode buttons
599
Widget InitModeButtons(Widget Parent, Widget Top, Widget Left)
631
InitModeButtons (Widget Parent, Widget Top, Widget Left)
603
for (i = 0; i < ENTRIES(ModeButtons); i++)
635
static char *translations =
636
"<EnterWindow>: highlight(Always) \n"
637
"<LeaveWindow>: unhighlight() \n"
638
"<Btn1Down>,<Btn1Up>: toggle() notify() \n";
640
XtTranslations translationtable;
643
masterform = XtVaCreateManagedWidget ("toolMasterForm", formWidgetClass,
646
XtNfromVert, Top, LAYOUT_TOP, NULL);
651
translationtable = XtParseTranslationTable (translations);
653
for (i = 0; i < ENTRIES (ModeButtons); i++)
657
/* create background pixmap */
658
bitmap = XCreateBitmapFromData (Dpy, XtWindow (Parent),
659
(char *) ModeButtons[i].Bitmap,
660
ModeButtons[i].Width,
661
ModeButtons[i].Height);
663
/* create radio button; use label only if pixmap creation failed
664
* layout has to be set here else X11R4 fails
666
if (bitmap != BadAlloc)
667
ModeButtons[i].W = XtVaCreateManagedWidget (ModeButtons[i].Name,
677
ModeButtons[i].W = XtVaCreateManagedWidget (ModeButtons[i].Name,
681
ModeButtons[i].Label,
686
XtAddEventHandler (ModeButtons[i].W, EnterWindowMask, False,
687
CB_StopScroll, NULL);
688
/* the first entry identifies the radiogroup,
689
* we have to make sure that no NULL is passed to XtNradioData
691
XtVaSetValues (ModeButtons[i].W,
692
XtNradioGroup, ModeButtons[0].W,
693
XtNradioData, (XtPointer) & ModeButtons[i], NULL);
694
XtAddCallback (ModeButtons[i].W, XtNcallback,
695
CB_SetMode, (XtPointer) & ModeButtons[i]);
697
/* update position for next widget */
698
if (i % BUTTONS_PER_ROW == BUTTONS_PER_ROW - 1)
607
/* create background pixmap */
608
bitmap = XCreateBitmapFromData(Dpy, XtWindow(Parent),
609
ModeButtons[i].Bitmap, ModeButtons[i].Width, ModeButtons[i].Height);
611
/* create radio button; use label only if pixmap creation failed
612
* layout has to be set here else X11R4 fails
614
if (bitmap != BadAlloc)
615
ModeButtons[i].W = XtVaCreateManagedWidget(ModeButtons[i].Name,
624
ModeButtons[i].W = XtVaCreateManagedWidget(ModeButtons[i].Name,
627
XtNlabel, ModeButtons[i].Label,
633
/* the first entry identifies the radiogroup,
634
* we have to make sure that no NULL is passed to XtNradioData
636
XtVaSetValues(ModeButtons[i].W,
637
XtNradioGroup, ModeButtons[0].W,
638
XtNradioData, (XtPointer) &ModeButtons[i],
640
XtAddCallback(ModeButtons[i].W, XtNcallback,
641
CB_SetMode, (XtPointer) &ModeButtons[i]);
643
/* update position for next widget */
644
if (i % BUTTONS_PER_ROW == BUTTONS_PER_ROW - 1)
647
Top = ModeButtons[i].W;
650
Left = ModeButtons[i].W;
701
Top = ModeButtons[i].W;
652
return(ModeButtons[i-1].W);
704
Left = ModeButtons[i].W;
706
return (ModeButtons[i - 1].W);