69
81
/* ---------------------------------------------------------------------------
70
82
* some local identifiers
72
static Widget Popup, /* the popup shells */
73
ScrollbarW, /* scaling scrollbar */
74
ColorW, /* color button */
75
RotateW, /* rotate button */
76
MirrorW, /* mirror button */
77
InvertW, /* invert color button */
78
ScaleW, /* scale label */
79
PannerW, /* panner widget */
80
FilenameLabelW, /* a label */
81
FilenameW; /* input line */
82
static float Scale = 1.0; /* initial scaling factor */
83
static int ReturnCode; /* returncode of buttons */
84
static Boolean RotateFlag = False, /* initial rotation flag */
85
OutlineFlag = False,/* don't draw board outline.. */
86
AlignmentFlag = False,
88
static PrintDeviceTypePtr DeviceSelection = NULL; /* selcted device */
89
static PopupEntryType *DeviceMenuEntries = NULL;
90
static PopupMenuType DeviceMenu =
91
{ "device", NULL, NULL, NULL, NULL, NULL };
92
static MenuButtonType DeviceMenuButton =
93
{ "device", "Device", &DeviceMenu, NULL };
84
static Widget Popup, /* the popup shells */
85
ScrollbarW, /* scaling scrollbar */
86
ColorW, /* color button */
87
RotateW, /* rotate button */
88
MirrorW, /* mirror button */
89
InvertW, /* invert color button */
90
ScaleW, /* scale label */
91
scaleLabel, PannerW, /* panner widget */
92
FilenameLabelW, /* a label */
93
FilenameW; /* input line */
94
static float Scale = 1.0; /* initial scaling factor */
95
static long int ReturnCode; /* returncode of buttons */
96
static Boolean RotateFlag = False, /* initial rotation flag */
97
OutlineFlag = False, /* don't draw board outline.. */
98
AlignmentFlag = False, DOSFilenames = False;
99
static PrintDeviceTypePtr DeviceSelection = NULL; /* selcted device */
100
static PopupEntryType *DeviceMenuEntries = NULL;
101
static PopupMenuType DeviceMenu = { "device", NULL, NULL, NULL, NULL, NULL };
102
static MenuButtonType DeviceMenuButton =
103
{ "device", "Device", &DeviceMenu, NULL };
95
105
/* ---------------------------------------------------------------------------
96
106
* some local prototypes
98
static Widget CreateDeviceMenu(Widget, Widget, Widget);
99
static void CB_Device(Widget, XtPointer, XtPointer);
100
static void UpdateScale(void);
101
static void UpdateScrollbar(float);
102
static void CB_CancelOrOK(Widget, XtPointer, XtPointer);
103
static void CB_Flags(Widget, XtPointer, XtPointer);
104
static void CB_ScrollProc(Widget, XtPointer, XtPointer);
105
static void CB_JumpProc(Widget, XtPointer, XtPointer);
106
static void CB_DOS(Widget, XtPointer, XtPointer);
108
static Widget CreateDeviceMenu (Widget, Widget, Widget);
109
static void CB_Device (Widget, XtPointer, XtPointer);
110
static void UpdateScale (void);
111
static void UpdateScrollbar (float);
112
static void CB_CancelOrOK (Widget, XtPointer, XtPointer);
113
static void CB_Flags (Widget, XtPointer, XtPointer);
114
static void CB_ScrollProc (Widget, XtPointer, XtPointer);
115
static void CB_JumpProc (Widget, XtPointer, XtPointer);
116
static void CB_DOS (Widget, XtPointer, XtPointer);
108
118
/* ---------------------------------------------------------------------------
109
119
* creates 'device' menu
111
static Widget CreateDeviceMenu(Widget Parent, Widget Top, Widget Left)
122
CreateDeviceMenu (Widget Parent, Widget Top, Widget Left)
115
/* setup menu-link when called the first time */
116
if (!DeviceMenuEntries)
126
/* setup menu-link when called the first time */
127
if (!DeviceMenuEntries)
129
DeviceInfoTypePtr ptr;
131
/* get number of entries */
132
for (i = 0; PrintingDevice[i].Query; i++);
133
DeviceMenuEntries = (PopupEntryTypePtr) MyCalloc (i + 1,
136
"CreateDeviceMenu()");
137
DeviceMenu.Entries = DeviceMenuEntries;
139
/* copy media description to menu-entry structure */
140
for (i = 0, ptr = PrintingDevice; ptr->Query; i++, ptr++)
118
DeviceInfoTypePtr ptr;
120
/* get number of entries */
121
for (i = 0; PrintingDevice[i].Query; i++);
122
DeviceMenuEntries = (PopupEntryTypePtr) MyCalloc(i+1,
123
sizeof(PopupEntryType), "CreateDeviceMenu()");
124
DeviceMenu.Entries = DeviceMenuEntries;
126
/* copy media description to menu-entry structure */
127
for (i = 0, ptr = PrintingDevice; ptr->Query; i++, ptr++)
129
DeviceMenuEntries[i].Name = ptr->Info->Name;
130
DeviceMenuEntries[i].Label = ptr->Info->Name;
131
DeviceMenuEntries[i].Callback = CB_Device;
132
DeviceMenuEntries[i].ClientData = (char *) ptr->Info;
133
DeviceMenuEntries[i].W = NULL;
136
/* thanks for the bug-fix Sander (sander@centerline.com) */
137
DeviceMenuEntries[i].Name = NULL;
138
if (!DeviceSelection)
139
DeviceSelection = PrintingDevice[0].Info;
140
DeviceMenuButton.Label = DeviceSelection->Name;
142
DeviceMenuEntries[i].Name = ptr->Info->Name;
143
DeviceMenuEntries[i].Label = ptr->Info->Name;
144
DeviceMenuEntries[i].Callback = CB_Device;
145
DeviceMenuEntries[i].ClientData = (char *) ptr->Info;
146
DeviceMenuEntries[i].W = NULL;
142
return(InitMenuButton(Parent, &DeviceMenuButton, Top, Left));
149
/* thanks for the bug-fix Sander (sander@centerline.com) */
150
DeviceMenuEntries[i].Name = NULL;
151
if (!DeviceSelection)
152
DeviceSelection = PrintingDevice[0].Info;
153
DeviceMenuButton.Label = DeviceSelection->Name;
155
return (InitMenuButton (Parent, &DeviceMenuButton, Top, Left));
145
158
/* ---------------------------------------------------------------------------
146
159
* callback for device selection (menu)
148
static void CB_Device(Widget W, XtPointer ClientData, XtPointer CallData)
162
CB_Device (Widget W, XtPointer ClientData, XtPointer CallData)
150
DeviceSelection = (PrintDeviceTypePtr) ClientData;
151
XtVaSetValues(DeviceMenuButton.W,
152
XtNlabel, DeviceSelection->Name,
155
/* switch off color button if not supported */
156
if (!DeviceSelection->HandlesColor)
157
XtVaSetValues(ColorW, XtNstate, False, NULL);
158
XtVaSetValues(ColorW, XtNsensitive, DeviceSelection->HandlesColor, NULL);
160
XtVaSetValues(InvertW, XtNsensitive, True, NULL);
162
/* switch off rotate button if not supported */
163
if (!DeviceSelection->HandlesRotate)
164
XtVaSetValues(RotateW, XtNstate, False, NULL);
165
XtVaSetValues(RotateW, XtNsensitive, DeviceSelection->HandlesRotate, NULL);
167
/* switch off mirror button if not supported */
168
if (!DeviceSelection->HandlesMirror)
169
XtVaSetValues(MirrorW, XtNstate, False, NULL);
170
XtVaSetValues(MirrorW, XtNsensitive, DeviceSelection->HandlesMirror, NULL);
172
/* unmap panner and medias selector if not supported */
175
if (DeviceSelection->HandlesMedia)
176
XMapWindow(Dpy, XtWindow(PannerW));
178
XUnmapWindow(Dpy, XtWindow(PannerW));
164
DeviceSelection = (PrintDeviceTypePtr) ClientData;
165
XtVaSetValues (DeviceMenuButton.W, XtNlabel, DeviceSelection->Name, NULL);
167
/* switch off color button if not supported */
168
if (!DeviceSelection->HandlesColor)
169
XtVaSetValues (ColorW, XtNstate, False, NULL);
170
XtVaSetValues (ColorW, XtNsensitive, DeviceSelection->HandlesColor, NULL);
172
XtVaSetValues (InvertW, XtNsensitive, True, NULL);
174
/* switch off rotate button if not supported */
175
if (!DeviceSelection->HandlesRotate)
176
XtVaSetValues (RotateW, XtNstate, False, NULL);
177
XtVaSetValues (RotateW, XtNsensitive, DeviceSelection->HandlesRotate, NULL);
179
/* switch off mirror button if not supported */
180
if (!DeviceSelection->HandlesMirror)
181
XtVaSetValues (MirrorW, XtNstate, False, NULL);
182
XtVaSetValues (MirrorW, XtNsensitive, DeviceSelection->HandlesMirror, NULL);
183
/* switch off scale adjustment if not supported */
184
if (!DeviceSelection->HandlesScale)
186
XUnmapWindow (Dpy, XtWindow (ScaleW));
187
XUnmapWindow (Dpy, XtWindow (ScrollbarW));
188
XUnmapWindow (Dpy, XtWindow (scaleLabel));
192
XMapWindow (Dpy, XtWindow (scaleLabel));
193
XMapWindow (Dpy, XtWindow (ScrollbarW));
194
XMapWindow (Dpy, XtWindow (ScaleW));
197
/* unmap panner and medias selector if not supported */
200
if (DeviceSelection->HandlesMedia)
201
XMapWindow (Dpy, XtWindow (PannerW));
203
XUnmapWindow (Dpy, XtWindow (PannerW));
182
207
/* ---------------------------------------------------------------------------
183
208
* updates scale label
185
static void UpdateScale(void)
189
sprintf(s, "%4.2f", Scale);
190
XtVaSetValues(ScaleW, XtNlabel, s, NULL);
215
sprintf (s, "%4.2f", Scale);
216
XtVaSetValues (ScaleW, XtNlabel, s, NULL);
193
219
/* ---------------------------------------------------------------------------
194
220
* updates the position of the scrollbar thumb
195
221
* the thumb position is passed (range 0..1)
197
static void UpdateScrollbar(float NewScale)
224
UpdateScrollbar (float NewScale)
201
/* set new scale, ignore all but first digit behind decimal dot */
202
NewScale = MIN(NewScale, MAX_SCALE);
203
NewScale = MAX(NewScale, MIN_SCALE);
204
Scale = ((int) (10.0*NewScale)) /10.0;
205
top = (Scale -MIN_SCALE) / (MAX_SCALE -MIN_SCALE);
206
top = MIN(top, (1.0 -((float) THUMB_LENGTH /(float) SCROLLBAR_LENGTH)));
207
XawScrollbarSetThumb(ScrollbarW, top, -1.0);
209
PrintPannerUpdate(Scale, RotateFlag, OutlineFlag, AlignmentFlag);
228
/* set new scale, ignore all but first digit behind decimal dot */
229
NewScale = MIN (NewScale, MAX_SCALE);
230
NewScale = MAX (NewScale, MIN_SCALE);
231
Scale = ((int) (10.0 * NewScale)) / 10.0;
232
top = (Scale - MIN_SCALE) / (MAX_SCALE - MIN_SCALE);
233
top = MIN (top, (1.0 - ((float) THUMB_LENGTH / (float) SCROLLBAR_LENGTH)));
234
XawScrollbarSetThumb (ScrollbarW, top, -1.0);
236
PrintPannerUpdate (Scale, RotateFlag, OutlineFlag, AlignmentFlag);
212
239
/* ---------------------------------------------------------------------------
213
240
* callback function for OK and cancel button
215
static void CB_CancelOrOK(Widget W, XtPointer ClientData, XtPointer CallData)
243
CB_CancelOrOK (Widget W, XtPointer ClientData, XtPointer CallData)
217
ReturnCode = (int) ClientData;
245
ReturnCode = (long int) ClientData;
220
248
/* ---------------------------------------------------------------------------
221
249
* callback function for the toggle buttons
222
250
* just updates the slider
224
static void CB_Flags(Widget W, XtPointer ClientData, XtPointer CallData)
226
Boolean *ptr = (Boolean *) ClientData;
228
XtVaGetValues(W, XtNstate, ptr, NULL);
229
PrintPannerUpdate(Scale, RotateFlag, OutlineFlag, AlignmentFlag);
232
/* ---------------------------------------------------------------------------
233
* callback function for scrolling
234
* see Athena Widget manual for details
236
static void CB_ScrollProc(Widget W, XtPointer ClientData, XtPointer CallData)
239
int delta = (int) CallData;
241
/* get thumb postion */
242
XtVaGetValues(W, XtNtopOfThumb, &top, NULL);
243
top += ((float) delta/ (float) SCROLLBAR_LENGTH);
244
top = MIN(1.0, MAX(top, 0.0));
245
UpdateScrollbar((float) (MAX_SCALE -MIN_SCALE) *top +(float) MIN_SCALE);
248
/* ---------------------------------------------------------------------------
249
* callback function for scrolling
250
* see Athena Widget manual for details
252
static void CB_JumpProc(Widget W, XtPointer ClientData, XtPointer CallData)
254
float top = *(float *) CallData;
256
UpdateScrollbar((float) (MAX_SCALE -MIN_SCALE) *top +(float) MIN_SCALE);
253
CB_Flags (Widget W, XtPointer ClientData, XtPointer CallData)
255
Boolean *ptr = (Boolean *) ClientData;
257
XtVaGetValues (W, XtNstate, ptr, NULL);
258
PrintPannerUpdate (Scale, RotateFlag, OutlineFlag, AlignmentFlag);
261
/* ---------------------------------------------------------------------------
262
* callback function for scrolling
263
* see Athena Widget manual for details
266
CB_ScrollProc (Widget W, XtPointer ClientData, XtPointer CallData)
269
long int delta = (long int) CallData;
271
/* get thumb postion */
272
XtVaGetValues (W, XtNtopOfThumb, &top, NULL);
273
top += ((float) delta / (float) SCROLLBAR_LENGTH);
274
top = MIN (1.0, MAX (top, 0.0));
275
UpdateScrollbar ((float) (MAX_SCALE - MIN_SCALE) * top + (float) MIN_SCALE);
278
/* ---------------------------------------------------------------------------
279
* callback function for scrolling
280
* see Athena Widget manual for details
283
CB_JumpProc (Widget W, XtPointer ClientData, XtPointer CallData)
285
float top = *(float *) CallData;
287
UpdateScrollbar ((float) (MAX_SCALE - MIN_SCALE) * top + (float) MIN_SCALE);
259
290
/* ---------------------------------------------------------------------------
260
291
* callback function for the selection of DOS filenames
262
static void CB_DOS(Widget W, XtPointer ClientData, XtPointer CallData)
294
CB_DOS (Widget W, XtPointer ClientData, XtPointer CallData)
264
XtVaGetValues(W, XtNstate, &DOSFilenames, NULL);
267
XUnmapWindow(Dpy, XtWindow(FilenameLabelW));
268
XUnmapWindow(Dpy, XtWindow(FilenameW));
272
XMapWindow(Dpy, XtWindow(FilenameLabelW));
273
XMapWindow(Dpy, XtWindow(FilenameW));
275
XtVaSetValues(FilenameW, XtNsensitive, !DOSFilenames, NULL);
296
XtVaGetValues (W, XtNstate, &DOSFilenames, NULL);
299
XUnmapWindow (Dpy, XtWindow (FilenameLabelW));
300
XUnmapWindow (Dpy, XtWindow (FilenameW));
304
XMapWindow (Dpy, XtWindow (FilenameLabelW));
305
XMapWindow (Dpy, XtWindow (FilenameW));
307
XtVaSetValues (FilenameW, XtNsensitive, !DOSFilenames, NULL);
278
310
/* ---------------------------------------------------------------------------
282
314
* offset[xy] are relativ to the center of the media and output area
284
void PrintDialog(void)
298
static Boolean mirrorflag = False,
301
drillhelperflag = False,
302
silkscreentextflag = False;
303
static DialogButtonType buttons[] = {
304
{ "defaultButton", " OK ", CB_CancelOrOK,
305
(XtPointer) OK_BUTTON, NULL },
306
{ "cancelButton", "No/Cancel", CB_CancelOrOK,
307
(XtPointer) CANCEL_BUTTON, NULL }};
309
/* initialize command if called the first time */
310
if (!PCB->PrintFilename)
311
PCB->PrintFilename = EvaluateFilename(Settings.PrintFile,
312
NULL, PCB->Filename ? PCB->Filename : "noname", NULL);
314
/* clear offset --> recenter output */
315
offsetx = offsety = 0;
317
Popup = XtVaCreatePopupShell("popup", transientShellWidgetClass,
319
XtNallowShellResize, True,
320
XtNmappedWhenManaged, False,
324
/* the form that holds everything */
325
masterform = XtVaCreateManagedWidget("printMasterForm", formWidgetClass,
330
/* now all buttons, labels ... */
331
label = XtVaCreateManagedWidget("comment", labelWidgetClass,
334
XtNlabel, "print settings:",
336
label = XtVaCreateManagedWidget("comment", labelWidgetClass,
340
XtNlabel, "select device driver:",
342
device = CreateDeviceMenu(masterform, label, NULL);
343
label = XtVaCreateManagedWidget("comment", labelWidgetClass,
347
XtNlabel, "select rotation, mirroring, colored output...:",
349
RotateW = XtVaCreateManagedWidget("rotate", toggleWidgetClass,
353
XtNstate, RotateFlag,
354
XtNsensitive, DeviceSelection->HandlesRotate,
356
MirrorW = XtVaCreateManagedWidget("mirror", toggleWidgetClass,
360
XtNfromHoriz, RotateW,
361
XtNstate, mirrorflag,
362
XtNsensitive, DeviceSelection->HandlesMirror,
364
ColorW = XtVaCreateManagedWidget("color", toggleWidgetClass,
368
XtNfromHoriz, MirrorW,
370
XtNsensitive, DeviceSelection->HandlesColor,
372
InvertW = XtVaCreateManagedWidget("invert", toggleWidgetClass,
376
XtNstate, invertflag,
379
label = XtVaCreateManagedWidget("comment", labelWidgetClass,
382
XtNfromVert, InvertW,
383
XtNlabel, "select outline and alignment targets:",
385
outline = XtVaCreateManagedWidget("outline", toggleWidgetClass,
389
XtNstate, OutlineFlag,
391
alignment = XtVaCreateManagedWidget("alignment", toggleWidgetClass,
395
XtNfromHoriz, outline,
396
XtNstate, AlignmentFlag,
398
drillhelper = XtVaCreateManagedWidget("drillhelper", toggleWidgetClass,
402
XtNfromHoriz, alignment,
403
XtNstate, drillhelperflag,
405
label = XtVaCreateManagedWidget("comment", labelWidgetClass,
408
XtNfromVert, outline,
409
XtNlabel, "select output scale here:",
411
ScrollbarW = XtVaCreateManagedWidget("scrollbar", scrollbarWidgetClass,
415
XtNlength, SCROLLBAR_LENGTH,
416
XtNminimumThumb, THUMB_LENGTH,
417
XtNorientation, XtorientHorizontal,
419
ScaleW = XtVaCreateManagedWidget("scale", labelWidgetClass,
423
XtNfromHoriz, ScrollbarW,
425
PannerW = PrintPannerCreate(masterform, ScrollbarW, NULL);
426
label = XtVaCreateManagedWidget("comment", labelWidgetClass,
429
XtNfromVert, PannerW ? PannerW : ScrollbarW,
430
XtNlabel, "select for DOS compatible filenames:",
432
DOSnames = XtVaCreateManagedWidget("dosNames", toggleWidgetClass,
436
XtNstate, DOSFilenames,
437
XtNlabel, "DOS (8.3) names",
439
FilenameLabelW = XtVaCreateManagedWidget("comment", labelWidgetClass,
442
XtNfromVert, DOSnames,
443
XtNlabel, "enter filename:",
445
FilenameW = XtVaCreateManagedWidget("input", asciiTextWidgetClass,
448
XtNresize, XawtextResizeWidth,
449
XtNstring, PCB->PrintFilename,
450
XtNwrap, XawtextWrapNever,
451
XtNeditType, XawtextEdit,
452
XtNfromVert, FilenameLabelW,
456
/* now we add the buttons, the first one is always default */
457
AddButtons(masterform, FilenameW, buttons, ENTRIES(buttons));
459
/* add callback functions, update panner and thumb position */
460
XtAddCallback(RotateW, XtNcallback, CB_Flags,(XtPointer) &RotateFlag);
461
XtAddCallback(outline, XtNcallback, CB_Flags,(XtPointer) &OutlineFlag);
462
XtAddCallback(alignment, XtNcallback, CB_Flags,(XtPointer) &AlignmentFlag);
463
XtAddCallback(DOSnames, XtNcallback, CB_DOS, NULL);
464
XtAddCallback(ScrollbarW, XtNscrollProc, CB_ScrollProc, NULL);
465
XtAddCallback(ScrollbarW, XtNjumpProc, CB_JumpProc, NULL);
466
XtAddCallback(ScrollbarW, XtNscrollProc, CB_ScrollProc, NULL);
468
/* override default translations and
469
* install accelerators for buttons
471
XtOverrideTranslations(FilenameW,
472
XtParseTranslationTable(InputTranslations));
473
XtInstallAccelerators(FilenameW, buttons[0].W);
474
XtInstallAccelerators(FilenameW, buttons[1].W);
476
/* set focus to input line */
477
XtSetKeyboardFocus(masterform, FilenameW);
479
/* the panner widget has to be realized before the offset can be set;
480
* update sliders and buttons too
482
XtRealizeWidget(Popup);
483
CB_DOS(DOSnames, NULL, NULL);
484
PrintPannerSetSliderPosition(offsetx, offsety);
486
PrintPannerUpdate(Scale, RotateFlag, OutlineFlag, AlignmentFlag);
487
UpdateScrollbar(Scale);
489
/* update menu button according to old settings
490
* thanks to: John M. Harrison <jmh@nei.mv.com>
492
CB_Device(device, (XtPointer) DeviceSelection, NULL);
494
/* now display dialog window and handle input */
496
DialogEventLoop(&ReturnCode);
498
/* get button settings, offsets and media description */
499
XtVaGetValues(RotateW, XtNstate, &RotateFlag, NULL);
500
XtVaGetValues(MirrorW, XtNstate, &mirrorflag, NULL);
501
XtVaGetValues(drillhelper, XtNstate, &drillhelperflag, NULL);
502
XtVaGetValues(ColorW, XtNstate, &colorflag, NULL);
503
XtVaGetValues(InvertW, XtNstate, &invertflag, NULL);
505
/* get media selection and transform center-based offset
506
* to upper-left corner
508
if (DeviceSelection->HandlesMedia)
510
PrintPannerGetSliderPosition(&offsetx, &offsety);
511
PrintPannerGetSize(&width, &height);
512
media = PrintPannerGetMedia();
513
offsetx += ((media->Width -width) /2);
514
offsety += ((media->Height -height) /2);
518
/* use some defaults if the device doesn't handle media */
520
offsetx = offsety = 0;
523
/* release old command and allocate new string */
524
SaveFree(PCB->PrintFilename);
525
XtVaGetValues(FilenameW, XtNstring, &PCB->PrintFilename, NULL);
526
PCB->PrintFilename = StripWhiteSpaceAndDup(PCB->PrintFilename);
528
/* now everything is saved; destroy the dialog */
531
/* call the printing routine if everything is OK;
532
* convert offsets to distance from upper-left corner
534
if (ReturnCode == OK_BUTTON && PCB->PrintFilename)
535
Print(PCB->PrintFilename, Scale,
536
mirrorflag, RotateFlag, colorflag, invertflag,
537
OutlineFlag, AlignmentFlag, drillhelperflag, DOSFilenames,
538
DeviceSelection, media,
319
Widget masterform, label, device, outline, alignment, drillhelper, DOSnames;
321
Dimension width, height;
322
Position offsetx, offsety;
323
static Boolean mirrorflag = False,
325
colorflag = False, drillhelperflag = False, silkscreentextflag = False;
326
static DialogButtonType buttons[] = {
327
{"defaultButton", " OK ", CB_CancelOrOK,
328
(XtPointer) OK_BUTTON, NULL},
329
{"cancelButton", "No/Cancel", CB_CancelOrOK,
330
(XtPointer) CANCEL_BUTTON, NULL}
333
/* initialize command if called the first time */
334
if (!PCB->PrintFilename)
335
PCB->PrintFilename = EvaluateFilename (Settings.PrintFile,
338
Filename ? PCB->Filename :
341
/* clear offset --> recenter output */
342
offsetx = offsety = 0;
344
Popup = XtVaCreatePopupShell ("popup", transientShellWidgetClass,
346
XtNallowShellResize, True,
347
XtNmappedWhenManaged, False,
348
XtNinput, True, NULL);
350
/* the form that holds everything */
351
masterform = XtVaCreateManagedWidget ("printMasterForm", formWidgetClass,
352
Popup, XtNresizable, True, NULL);
354
/* now all buttons, labels ... */
355
label = XtVaCreateManagedWidget ("comment", labelWidgetClass,
358
XtNlabel, "print settings:", NULL);
359
label = XtVaCreateManagedWidget ("comment", labelWidgetClass,
363
XtNlabel, "select device driver:", NULL);
364
device = CreateDeviceMenu (masterform, label, NULL);
365
label = XtVaCreateManagedWidget ("comment", labelWidgetClass,
370
"select rotation, mirroring, colored output...:",
373
XtVaCreateManagedWidget ("rotate", toggleWidgetClass, masterform,
374
LAYOUT_TOP, XtNfromVert, label, XtNstate,
375
RotateFlag, XtNsensitive,
376
DeviceSelection->HandlesRotate, NULL);
378
XtVaCreateManagedWidget ("mirror", toggleWidgetClass, masterform,
379
LAYOUT_TOP, XtNfromVert, label, XtNfromHoriz,
380
RotateW, XtNstate, mirrorflag, XtNsensitive,
381
DeviceSelection->HandlesMirror, NULL);
383
XtVaCreateManagedWidget ("color", toggleWidgetClass, masterform,
384
LAYOUT_TOP, XtNfromVert, label, XtNfromHoriz,
385
MirrorW, XtNstate, colorflag, XtNsensitive,
386
DeviceSelection->HandlesColor, NULL);
388
XtVaCreateManagedWidget ("invert", toggleWidgetClass, masterform,
389
LAYOUT_TOP, XtNfromVert, ColorW, XtNstate,
390
invertflag, XtNsensitive, True, NULL);
392
XtVaCreateManagedWidget ("comment", labelWidgetClass, masterform,
393
LAYOUT_TOP, XtNfromVert, InvertW, XtNlabel,
394
"select outline and alignment targets:", NULL);
396
XtVaCreateManagedWidget ("outline", toggleWidgetClass, masterform,
397
LAYOUT_TOP, XtNfromVert, label, XtNstate,
400
XtVaCreateManagedWidget ("alignment", toggleWidgetClass, masterform,
401
LAYOUT_TOP, XtNfromVert, label, XtNfromHoriz,
402
outline, XtNstate, AlignmentFlag, NULL);
404
XtVaCreateManagedWidget ("drillhelper", toggleWidgetClass, masterform,
405
LAYOUT_TOP, XtNfromVert, label, XtNfromHoriz,
406
alignment, XtNstate, drillhelperflag, NULL);
408
XtVaCreateManagedWidget ("comment", labelWidgetClass, masterform,
409
LAYOUT_TOP, XtNfromVert, outline, XtNlabel,
410
"select output scale here:", NULL);
412
XtVaCreateManagedWidget ("scrollbar", scrollbarWidgetClass, masterform,
413
LAYOUT_TOP, XtNfromVert, scaleLabel, XtNlength,
414
SCROLLBAR_LENGTH, XtNminimumThumb, THUMB_LENGTH,
415
XtNorientation, XtorientHorizontal, NULL);
417
XtVaCreateManagedWidget ("scale", labelWidgetClass, masterform,
418
LAYOUT_TOP, XtNfromVert, scaleLabel,
419
XtNfromHoriz, ScrollbarW, NULL);
420
PannerW = PrintPannerCreate (masterform, ScrollbarW, NULL);
421
label = XtVaCreateManagedWidget ("comment", labelWidgetClass,
425
PannerW ? PannerW : ScrollbarW, XtNlabel,
426
"select for DOS compatible filenames:",
429
XtVaCreateManagedWidget ("dosNames", toggleWidgetClass, masterform,
430
LAYOUT_TOP, XtNfromVert, label, XtNstate,
431
DOSFilenames, XtNlabel, "DOS (8.3) names", NULL);
433
XtVaCreateManagedWidget ("comment", labelWidgetClass, masterform,
434
LAYOUT_TOP, XtNfromVert, DOSnames, XtNlabel,
435
"enter filename:", NULL);
437
XtVaCreateManagedWidget ("input", asciiTextWidgetClass, masterform,
438
XtNresizable, True, XtNresize,
439
XawtextResizeWidth, XtNstring,
440
PCB->PrintFilename, XtNwrap, XawtextWrapNever,
441
XtNeditType, XawtextEdit, XtNfromVert,
442
FilenameLabelW, LAYOUT_TOP, NULL);
444
/* now we add the buttons, the first one is always default */
445
AddButtons (masterform, FilenameW, buttons, ENTRIES (buttons));
447
/* add callback functions, update panner and thumb position */
448
XtAddCallback (RotateW, XtNcallback, CB_Flags, (XtPointer) & RotateFlag);
449
XtAddCallback (outline, XtNcallback, CB_Flags, (XtPointer) & OutlineFlag);
450
XtAddCallback (alignment, XtNcallback, CB_Flags,
451
(XtPointer) & AlignmentFlag);
452
XtAddCallback (DOSnames, XtNcallback, CB_DOS, NULL);
453
XtAddCallback (ScrollbarW, XtNscrollProc, CB_ScrollProc, NULL);
454
XtAddCallback (ScrollbarW, XtNjumpProc, CB_JumpProc, NULL);
455
XtAddCallback (ScrollbarW, XtNscrollProc, CB_ScrollProc, NULL);
457
/* override default translations and
458
* install accelerators for buttons
460
XtOverrideTranslations (FilenameW,
461
XtParseTranslationTable (InputTranslations));
462
XtInstallAccelerators (FilenameW, buttons[0].W);
463
XtInstallAccelerators (FilenameW, buttons[1].W);
465
/* set focus to input line */
466
XtSetKeyboardFocus (masterform, FilenameW);
468
/* the panner widget has to be realized before the offset can be set;
469
* update sliders and buttons too
471
XtRealizeWidget (Popup);
472
CB_DOS (DOSnames, NULL, NULL);
473
PrintPannerSetSliderPosition (offsetx, offsety);
475
PrintPannerUpdate (Scale, RotateFlag, OutlineFlag, AlignmentFlag);
476
UpdateScrollbar (Scale);
478
/* update menu button according to old settings
479
* thanks to: John M. Harrison <jmh@nei.mv.com>
481
CB_Device (device, (XtPointer) DeviceSelection, NULL);
483
/* now display dialog window and handle input */
485
DialogEventLoop (&ReturnCode);
487
/* get button settings, offsets and media description */
488
XtVaGetValues (RotateW, XtNstate, &RotateFlag, NULL);
489
XtVaGetValues (MirrorW, XtNstate, &mirrorflag, NULL);
490
XtVaGetValues (drillhelper, XtNstate, &drillhelperflag, NULL);
491
XtVaGetValues (ColorW, XtNstate, &colorflag, NULL);
492
XtVaGetValues (InvertW, XtNstate, &invertflag, NULL);
494
/* get media selection and transform center-based offset
495
* to upper-left corner
497
if (DeviceSelection->HandlesMedia)
499
PrintPannerGetSliderPosition (&offsetx, &offsety);
500
PrintPannerGetSize (&width, &height);
501
media = PrintPannerGetMedia ();
502
offsetx += ((media->Width/100 - width) / 2);
503
offsety += ((media->Height/100 - height) / 2);
507
/* use some defaults if the device doesn't handle media */
509
offsetx = offsety = 0;
512
/* release old command and allocate new string */
513
SaveFree (PCB->PrintFilename);
514
XtVaGetValues (FilenameW, XtNstring, &PCB->PrintFilename, NULL);
515
PCB->PrintFilename = StripWhiteSpaceAndDup (PCB->PrintFilename);
517
/* now everything is saved; destroy the dialog */
520
/* call the printing routine if everything is OK;
521
* convert offsets to distance from upper-left corner
523
if (ReturnCode == OK_BUTTON && PCB->PrintFilename)
524
Print (PCB->PrintFilename, Scale,
525
mirrorflag, RotateFlag, colorflag, invertflag,
526
OutlineFlag, AlignmentFlag, drillhelperflag, DOSFilenames,
527
DeviceSelection, media, (LocationType)offsetx * 100, (LocationType)offsety * 100, silkscreentextflag);