~ubuntu-branches/ubuntu/precise/pcb/precise

« back to all changes in this revision

Viewing changes to src/printdialog.c

  • Committer: Bazaar Package Importer
  • Author(s): Hamish Moffatt
  • Date: 2005-02-20 13:14:00 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20050220131400-pfz66g5vhx0azl8f
Tags: 1.99j+20050127-2
* Improved package description: (closes: #295405)
* Fixed dependency: tk84 -> tk8.4 (closes: #295404)
* Updated README.debian (closes: #269578)
* Applied patch to src/djopt.c to allow compilation with gcc-4.0
  (closes: #294319), thanks to Andreas Jochens for the patch.
* Prevent example files from being compressed

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* $Id: printdialog.c,v 1.5 2005/01/03 12:57:00 danmc Exp $ */
 
2
 
1
3
/*
2
4
 *                            COPYRIGHT
3
5
 *
24
26
 *
25
27
 */
26
28
 
27
 
static  char    *rcsid = "$Id: printdialog.c,v 1.1 1998/02/19 18:06:34 sync Exp $";
28
29
 
29
30
/* print dialog routines
30
31
 */
31
32
 
 
33
#ifdef HAVE_CONFIG_H
 
34
#include "config.h"
 
35
#endif
 
36
 
32
37
#include <stdlib.h>
33
38
 
34
39
#include "global.h"
52
57
#include <X11/Xaw/Scrollbar.h>
53
58
#include <X11/Xaw/Toggle.h>
54
59
 
 
60
#ifdef HAVE_LIBDMALLOC
 
61
#include <dmalloc.h>
 
62
#endif
 
63
 
 
64
RCSID("$Id: printdialog.c,v 1.5 2005/01/03 12:57:00 danmc Exp $");
 
65
 
 
66
 
55
67
/* ---------------------------------------------------------------------------
56
68
 * define resource for X11R4 (names have changed from R4 to R5)
57
69
 * and scrollbar sizes
69
81
/* ---------------------------------------------------------------------------
70
82
 * some local identifiers
71
83
 */
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,
87
 
                                                        DOSFilenames = 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 };
94
104
 
95
105
/* ---------------------------------------------------------------------------
96
106
 * some local prototypes
97
107
 */
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);
107
117
 
108
118
/* ---------------------------------------------------------------------------
109
119
 * creates 'device' menu
110
120
 */
111
 
static Widget CreateDeviceMenu(Widget Parent, Widget Top, Widget Left)
 
121
static Widget
 
122
CreateDeviceMenu (Widget Parent, Widget Top, Widget Left)
112
123
{
113
 
        int             i;
114
 
 
115
 
                /* setup menu-link when called the first time */
116
 
        if (!DeviceMenuEntries)
 
124
  int i;
 
125
 
 
126
  /* setup menu-link when called the first time */
 
127
  if (!DeviceMenuEntries)
 
128
    {
 
129
      DeviceInfoTypePtr ptr;
 
130
 
 
131
      /* get number of entries */
 
132
      for (i = 0; PrintingDevice[i].Query; i++);
 
133
      DeviceMenuEntries = (PopupEntryTypePtr) MyCalloc (i + 1,
 
134
                                                        sizeof
 
135
                                                        (PopupEntryType),
 
136
                                                        "CreateDeviceMenu()");
 
137
      DeviceMenu.Entries = DeviceMenuEntries;
 
138
 
 
139
      /* copy media description to menu-entry structure */
 
140
      for (i = 0, ptr = PrintingDevice; ptr->Query; i++, ptr++)
117
141
        {
118
 
                DeviceInfoTypePtr       ptr;
119
 
 
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;
125
 
 
126
 
                        /* copy media description to menu-entry structure */
127
 
                for (i = 0, ptr = PrintingDevice; ptr->Query; i++, ptr++)
128
 
                {
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;
134
 
                }
135
 
 
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;
141
147
        }
142
 
        return(InitMenuButton(Parent, &DeviceMenuButton, Top, Left));
 
148
 
 
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;
 
154
    }
 
155
  return (InitMenuButton (Parent, &DeviceMenuButton, Top, Left));
143
156
}
144
157
 
145
158
/* ---------------------------------------------------------------------------
146
159
 * callback for device selection (menu)
147
160
 */
148
 
static void CB_Device(Widget W, XtPointer ClientData, XtPointer CallData)
 
161
static void
 
162
CB_Device (Widget W, XtPointer ClientData, XtPointer CallData)
149
163
{
150
 
        DeviceSelection = (PrintDeviceTypePtr) ClientData;
151
 
        XtVaSetValues(DeviceMenuButton.W,
152
 
                XtNlabel, DeviceSelection->Name,
153
 
                NULL);
154
 
 
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);
159
 
 
160
 
        XtVaSetValues(InvertW, XtNsensitive, True, NULL);
161
 
 
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);
166
 
 
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);
171
 
 
172
 
                /* unmap panner and medias selector if not supported */
173
 
        if (PannerW)
174
 
        {
175
 
                if (DeviceSelection->HandlesMedia)
176
 
                        XMapWindow(Dpy, XtWindow(PannerW));
177
 
                else
178
 
                        XUnmapWindow(Dpy, XtWindow(PannerW));
179
 
        }
 
164
  DeviceSelection = (PrintDeviceTypePtr) ClientData;
 
165
  XtVaSetValues (DeviceMenuButton.W, XtNlabel, DeviceSelection->Name, NULL);
 
166
 
 
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);
 
171
 
 
172
  XtVaSetValues (InvertW, XtNsensitive, True, NULL);
 
173
 
 
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);
 
178
 
 
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)
 
185
    {
 
186
      XUnmapWindow (Dpy, XtWindow (ScaleW));
 
187
      XUnmapWindow (Dpy, XtWindow (ScrollbarW));
 
188
      XUnmapWindow (Dpy, XtWindow (scaleLabel));
 
189
    }
 
190
  else
 
191
    {
 
192
      XMapWindow (Dpy, XtWindow (scaleLabel));
 
193
      XMapWindow (Dpy, XtWindow (ScrollbarW));
 
194
      XMapWindow (Dpy, XtWindow (ScaleW));
 
195
    }
 
196
 
 
197
  /* unmap panner and medias selector if not supported */
 
198
  if (PannerW)
 
199
    {
 
200
      if (DeviceSelection->HandlesMedia)
 
201
        XMapWindow (Dpy, XtWindow (PannerW));
 
202
      else
 
203
        XUnmapWindow (Dpy, XtWindow (PannerW));
 
204
    }
180
205
}
181
206
 
182
207
/* ---------------------------------------------------------------------------
183
208
 * updates scale label
184
209
 */
185
 
static void UpdateScale(void)
 
210
static void
 
211
UpdateScale (void)
186
212
{
187
 
        char    s[10];
 
213
  char s[10];
188
214
 
189
 
        sprintf(s, "%4.2f", Scale);
190
 
        XtVaSetValues(ScaleW, XtNlabel, s, NULL);
 
215
  sprintf (s, "%4.2f", Scale);
 
216
  XtVaSetValues (ScaleW, XtNlabel, s, NULL);
191
217
}
192
218
 
193
219
/* ---------------------------------------------------------------------------
194
220
 * updates the position of the scrollbar thumb
195
221
 * the thumb position is passed (range 0..1)
196
222
 */
197
 
static void UpdateScrollbar(float NewScale)
 
223
static void
 
224
UpdateScrollbar (float NewScale)
198
225
{
199
 
        float   top;
 
226
  float top;
200
227
 
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);
208
 
        UpdateScale();
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);
 
235
  UpdateScale ();
 
236
  PrintPannerUpdate (Scale, RotateFlag, OutlineFlag, AlignmentFlag);
210
237
}
211
238
 
212
239
/* ---------------------------------------------------------------------------
213
240
 * callback function for OK and cancel button
214
241
 */
215
 
static void CB_CancelOrOK(Widget W, XtPointer ClientData, XtPointer CallData)
 
242
static void
 
243
CB_CancelOrOK (Widget W, XtPointer ClientData, XtPointer CallData)
216
244
{
217
 
        ReturnCode = (int) ClientData;
 
245
  ReturnCode = (long int) ClientData;
218
246
}
219
247
 
220
248
/* ---------------------------------------------------------------------------
221
249
 * callback function for the toggle buttons
222
250
 * just updates the slider
223
251
 */
224
 
static void CB_Flags(Widget W, XtPointer ClientData, XtPointer CallData)
225
 
{
226
 
        Boolean *ptr = (Boolean *) ClientData;
227
 
 
228
 
        XtVaGetValues(W, XtNstate, ptr, NULL);
229
 
        PrintPannerUpdate(Scale, RotateFlag, OutlineFlag, AlignmentFlag);
230
 
}
231
 
 
232
 
/* ---------------------------------------------------------------------------
233
 
 * callback function for scrolling
234
 
 * see Athena Widget manual for details
235
 
 */
236
 
static void CB_ScrollProc(Widget W, XtPointer ClientData, XtPointer CallData)
237
 
{
238
 
        float   top;
239
 
        int             delta = (int) CallData;
240
 
 
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);
246
 
}
247
 
 
248
 
/* ---------------------------------------------------------------------------
249
 
 * callback function for scrolling
250
 
 * see Athena Widget manual for details
251
 
 */
252
 
static void CB_JumpProc(Widget W, XtPointer ClientData, XtPointer CallData)
253
 
{
254
 
        float   top = *(float *) CallData;
255
 
 
256
 
        UpdateScrollbar((float) (MAX_SCALE -MIN_SCALE) *top +(float) MIN_SCALE);
 
252
static void
 
253
CB_Flags (Widget W, XtPointer ClientData, XtPointer CallData)
 
254
{
 
255
  Boolean *ptr = (Boolean *) ClientData;
 
256
 
 
257
  XtVaGetValues (W, XtNstate, ptr, NULL);
 
258
  PrintPannerUpdate (Scale, RotateFlag, OutlineFlag, AlignmentFlag);
 
259
}
 
260
 
 
261
/* ---------------------------------------------------------------------------
 
262
 * callback function for scrolling
 
263
 * see Athena Widget manual for details
 
264
 */
 
265
static void
 
266
CB_ScrollProc (Widget W, XtPointer ClientData, XtPointer CallData)
 
267
{
 
268
  float top;
 
269
  long int delta = (long int) CallData;
 
270
 
 
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);
 
276
}
 
277
 
 
278
/* ---------------------------------------------------------------------------
 
279
 * callback function for scrolling
 
280
 * see Athena Widget manual for details
 
281
 */
 
282
static void
 
283
CB_JumpProc (Widget W, XtPointer ClientData, XtPointer CallData)
 
284
{
 
285
  float top = *(float *) CallData;
 
286
 
 
287
  UpdateScrollbar ((float) (MAX_SCALE - MIN_SCALE) * top + (float) MIN_SCALE);
257
288
}
258
289
 
259
290
/* ---------------------------------------------------------------------------
260
291
 * callback function for the selection of DOS filenames
261
292
 */
262
 
static void CB_DOS(Widget W, XtPointer ClientData, XtPointer CallData)
 
293
static void
 
294
CB_DOS (Widget W, XtPointer ClientData, XtPointer CallData)
263
295
{
264
 
        XtVaGetValues(W, XtNstate, &DOSFilenames, NULL);
265
 
        if (DOSFilenames)
266
 
        {
267
 
                XUnmapWindow(Dpy, XtWindow(FilenameLabelW));
268
 
                XUnmapWindow(Dpy, XtWindow(FilenameW));
269
 
        }
270
 
        else
271
 
        {
272
 
                XMapWindow(Dpy, XtWindow(FilenameLabelW));
273
 
                XMapWindow(Dpy, XtWindow(FilenameW));
274
 
        }
275
 
        XtVaSetValues(FilenameW, XtNsensitive, !DOSFilenames, NULL);
 
296
  XtVaGetValues (W, XtNstate, &DOSFilenames, NULL);
 
297
  if (DOSFilenames)
 
298
    {
 
299
      XUnmapWindow (Dpy, XtWindow (FilenameLabelW));
 
300
      XUnmapWindow (Dpy, XtWindow (FilenameW));
 
301
    }
 
302
  else
 
303
    {
 
304
      XMapWindow (Dpy, XtWindow (FilenameLabelW));
 
305
      XMapWindow (Dpy, XtWindow (FilenameW));
 
306
    }
 
307
  XtVaSetValues (FilenameW, XtNsensitive, !DOSFilenames, NULL);
276
308
}
277
309
 
278
310
/* ---------------------------------------------------------------------------
281
313
 *
282
314
 * offset[xy] are relativ to the center of the media and output area
283
315
 */
284
 
void PrintDialog(void)
 
316
void
 
317
PrintDialog (void)
285
318
{
286
 
                        Widget                          masterform,
287
 
                                                                label,
288
 
                                                                device,
289
 
                                                                outline,
290
 
                                                                alignment,
291
 
                                                                drillhelper,
292
 
                                                                DOSnames;
293
 
                        MediaTypePtr            media;
294
 
                        Dimension                       width,
295
 
                                                                height;
296
 
                        Position                        offsetx,
297
 
                                                                offsety;
298
 
        static  Boolean                         mirrorflag = False,
299
 
                                                                invertflag = False,
300
 
                                                                colorflag = 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 }};
308
 
 
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);
313
 
 
314
 
                /* clear offset --> recenter output */
315
 
        offsetx = offsety = 0;
316
 
 
317
 
        Popup = XtVaCreatePopupShell("popup", transientShellWidgetClass,
318
 
                Output.Toplevel,
319
 
                XtNallowShellResize, True,
320
 
                XtNmappedWhenManaged, False,
321
 
                XtNinput, True,
322
 
                NULL);
323
 
 
324
 
                /* the form that holds everything */
325
 
        masterform = XtVaCreateManagedWidget("printMasterForm", formWidgetClass,
326
 
                Popup,
327
 
                XtNresizable, True,
328
 
                NULL);
329
 
 
330
 
                /* now all buttons, labels ... */
331
 
        label = XtVaCreateManagedWidget("comment", labelWidgetClass,
332
 
                masterform,
333
 
                LAYOUT_TOP,
334
 
                XtNlabel, "print settings:",
335
 
                NULL);
336
 
        label = XtVaCreateManagedWidget("comment", labelWidgetClass,
337
 
                masterform,
338
 
                LAYOUT_TOP,
339
 
                XtNfromVert, label,
340
 
                XtNlabel, "select device driver:",
341
 
                NULL);
342
 
        device = CreateDeviceMenu(masterform, label, NULL);
343
 
        label = XtVaCreateManagedWidget("comment", labelWidgetClass,
344
 
                masterform,
345
 
                LAYOUT_TOP,
346
 
                XtNfromVert, device,
347
 
                XtNlabel, "select rotation, mirroring, colored output...:",
348
 
                NULL);
349
 
        RotateW = XtVaCreateManagedWidget("rotate", toggleWidgetClass,
350
 
                masterform,
351
 
                LAYOUT_TOP,
352
 
                XtNfromVert, label,
353
 
                XtNstate, RotateFlag,
354
 
                XtNsensitive, DeviceSelection->HandlesRotate,
355
 
                NULL);
356
 
        MirrorW = XtVaCreateManagedWidget("mirror", toggleWidgetClass,
357
 
                masterform,
358
 
                LAYOUT_TOP,
359
 
                XtNfromVert, label,
360
 
                XtNfromHoriz, RotateW,
361
 
                XtNstate, mirrorflag,
362
 
                XtNsensitive, DeviceSelection->HandlesMirror,
363
 
                NULL);
364
 
        ColorW = XtVaCreateManagedWidget("color", toggleWidgetClass,
365
 
                masterform,
366
 
                LAYOUT_TOP,
367
 
                XtNfromVert, label,
368
 
                XtNfromHoriz, MirrorW,
369
 
                XtNstate, colorflag,
370
 
                XtNsensitive, DeviceSelection->HandlesColor,
371
 
                NULL);
372
 
        InvertW = XtVaCreateManagedWidget("invert", toggleWidgetClass,
373
 
                masterform,
374
 
                LAYOUT_TOP,
375
 
                XtNfromVert, ColorW,
376
 
                XtNstate, invertflag,
377
 
                XtNsensitive, True,
378
 
                NULL);
379
 
        label = XtVaCreateManagedWidget("comment", labelWidgetClass,
380
 
                masterform,
381
 
                LAYOUT_TOP,
382
 
                XtNfromVert, InvertW,
383
 
                XtNlabel, "select outline and alignment targets:",
384
 
                NULL);
385
 
        outline = XtVaCreateManagedWidget("outline", toggleWidgetClass,
386
 
                masterform,
387
 
                LAYOUT_TOP,
388
 
                XtNfromVert, label,
389
 
                XtNstate, OutlineFlag,
390
 
                NULL);
391
 
        alignment = XtVaCreateManagedWidget("alignment", toggleWidgetClass,
392
 
                masterform,
393
 
                LAYOUT_TOP,
394
 
                XtNfromVert, label,
395
 
                XtNfromHoriz, outline,
396
 
                XtNstate, AlignmentFlag,
397
 
                NULL);
398
 
        drillhelper = XtVaCreateManagedWidget("drillhelper", toggleWidgetClass,
399
 
                masterform,
400
 
                LAYOUT_TOP,
401
 
                XtNfromVert, label,
402
 
                XtNfromHoriz, alignment,
403
 
                XtNstate, drillhelperflag,
404
 
                NULL);
405
 
        label = XtVaCreateManagedWidget("comment", labelWidgetClass,
406
 
                masterform,
407
 
                LAYOUT_TOP,
408
 
                XtNfromVert, outline,
409
 
                XtNlabel, "select output scale here:",
410
 
                NULL);
411
 
        ScrollbarW = XtVaCreateManagedWidget("scrollbar", scrollbarWidgetClass,
412
 
                masterform,
413
 
                LAYOUT_TOP,
414
 
                XtNfromVert, label,
415
 
                XtNlength, SCROLLBAR_LENGTH,
416
 
                XtNminimumThumb, THUMB_LENGTH,
417
 
                XtNorientation, XtorientHorizontal,
418
 
                NULL);
419
 
        ScaleW = XtVaCreateManagedWidget("scale", labelWidgetClass,
420
 
                masterform,
421
 
                LAYOUT_TOP,
422
 
                XtNfromVert, label,
423
 
                XtNfromHoriz, ScrollbarW,
424
 
                NULL);
425
 
        PannerW = PrintPannerCreate(masterform, ScrollbarW, NULL);
426
 
        label = XtVaCreateManagedWidget("comment", labelWidgetClass,
427
 
                masterform,
428
 
                LAYOUT_TOP,
429
 
                XtNfromVert, PannerW ? PannerW : ScrollbarW,
430
 
                XtNlabel, "select for DOS compatible filenames:",
431
 
                NULL);
432
 
        DOSnames = XtVaCreateManagedWidget("dosNames", toggleWidgetClass,
433
 
                masterform,
434
 
                LAYOUT_TOP,
435
 
                XtNfromVert, label,
436
 
                XtNstate, DOSFilenames,
437
 
                XtNlabel, "DOS (8.3) names",
438
 
                NULL);
439
 
        FilenameLabelW = XtVaCreateManagedWidget("comment", labelWidgetClass,
440
 
                masterform,
441
 
                LAYOUT_TOP,
442
 
                XtNfromVert, DOSnames,
443
 
                XtNlabel, "enter filename:",
444
 
                NULL);
445
 
        FilenameW = XtVaCreateManagedWidget("input", asciiTextWidgetClass,
446
 
                masterform,
447
 
                XtNresizable, True,
448
 
                XtNresize, XawtextResizeWidth,
449
 
                XtNstring, PCB->PrintFilename,
450
 
                XtNwrap, XawtextWrapNever,
451
 
                XtNeditType, XawtextEdit,
452
 
                XtNfromVert, FilenameLabelW,
453
 
                LAYOUT_TOP,
454
 
                NULL);
455
 
 
456
 
                /* now we add the buttons, the first one is always default */
457
 
        AddButtons(masterform, FilenameW, buttons, ENTRIES(buttons));
458
 
 
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);
467
 
 
468
 
                /* override default translations and
469
 
                 * install accelerators for buttons
470
 
                 */
471
 
        XtOverrideTranslations(FilenameW,
472
 
                XtParseTranslationTable(InputTranslations));
473
 
        XtInstallAccelerators(FilenameW, buttons[0].W);
474
 
        XtInstallAccelerators(FilenameW, buttons[1].W);
475
 
 
476
 
                /* set focus to input line */
477
 
        XtSetKeyboardFocus(masterform, FilenameW);
478
 
 
479
 
                /* the panner widget has to be realized before the offset can be set;
480
 
                 * update sliders and buttons too
481
 
                 */
482
 
        XtRealizeWidget(Popup);
483
 
        CB_DOS(DOSnames, NULL, NULL);
484
 
        PrintPannerSetSliderPosition(offsetx, offsety);
485
 
        UpdateScale();
486
 
        PrintPannerUpdate(Scale, RotateFlag, OutlineFlag, AlignmentFlag);
487
 
        UpdateScrollbar(Scale);
488
 
 
489
 
                /* update menu button according to old settings
490
 
                 * thanks to: John M. Harrison <jmh@nei.mv.com>
491
 
                 */
492
 
        CB_Device(device, (XtPointer) DeviceSelection, NULL);
493
 
 
494
 
                /* now display dialog window and handle input */
495
 
        StartDialog(Popup);
496
 
        DialogEventLoop(&ReturnCode);
497
 
 
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);
504
 
 
505
 
                /* get media selection and transform center-based offset
506
 
                 * to upper-left corner
507
 
                 */
508
 
        if (DeviceSelection->HandlesMedia)
509
 
        {
510
 
                PrintPannerGetSliderPosition(&offsetx, &offsety);
511
 
                PrintPannerGetSize(&width, &height);
512
 
                media = PrintPannerGetMedia();
513
 
                offsetx += ((media->Width -width) /2);
514
 
                offsety += ((media->Height -height) /2);
515
 
        }
516
 
        else
517
 
        {
518
 
                        /* use some defaults if the device doesn't handle media */
519
 
                media = NULL;
520
 
                offsetx = offsety = 0;
521
 
        }
522
 
 
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);
527
 
 
528
 
                /* now everything is saved; destroy the dialog */
529
 
        EndDialog(Popup);
530
 
 
531
 
                /* call the printing routine if everything is OK;
532
 
                 * convert offsets to distance from upper-left corner
533
 
                 */
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,
539
 
                        offsetx, offsety,
540
 
                        silkscreentextflag);
 
319
  Widget masterform, label, device, outline, alignment, drillhelper, DOSnames;
 
320
  MediaTypePtr media;
 
321
  Dimension width, height;
 
322
  Position offsetx, offsety;
 
323
  static Boolean mirrorflag = False,
 
324
    invertflag = 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}
 
331
  };
 
332
 
 
333
  /* initialize command if called the first time */
 
334
  if (!PCB->PrintFilename)
 
335
    PCB->PrintFilename = EvaluateFilename (Settings.PrintFile,
 
336
                                           NULL,
 
337
                                           PCB->
 
338
                                           Filename ? PCB->Filename :
 
339
                                           "noname", NULL);
 
340
 
 
341
  /* clear offset --> recenter output */
 
342
  offsetx = offsety = 0;
 
343
 
 
344
  Popup = XtVaCreatePopupShell ("popup", transientShellWidgetClass,
 
345
                                Output.Toplevel,
 
346
                                XtNallowShellResize, True,
 
347
                                XtNmappedWhenManaged, False,
 
348
                                XtNinput, True, NULL);
 
349
 
 
350
  /* the form that holds everything */
 
351
  masterform = XtVaCreateManagedWidget ("printMasterForm", formWidgetClass,
 
352
                                        Popup, XtNresizable, True, NULL);
 
353
 
 
354
  /* now all buttons, labels ... */
 
355
  label = XtVaCreateManagedWidget ("comment", labelWidgetClass,
 
356
                                   masterform,
 
357
                                   LAYOUT_TOP,
 
358
                                   XtNlabel, "print settings:", NULL);
 
359
  label = XtVaCreateManagedWidget ("comment", labelWidgetClass,
 
360
                                   masterform,
 
361
                                   LAYOUT_TOP,
 
362
                                   XtNfromVert, label,
 
363
                                   XtNlabel, "select device driver:", NULL);
 
364
  device = CreateDeviceMenu (masterform, label, NULL);
 
365
  label = XtVaCreateManagedWidget ("comment", labelWidgetClass,
 
366
                                   masterform,
 
367
                                   LAYOUT_TOP,
 
368
                                   XtNfromVert, device,
 
369
                                   XtNlabel,
 
370
                                   "select rotation, mirroring, colored output...:",
 
371
                                   NULL);
 
372
  RotateW =
 
373
    XtVaCreateManagedWidget ("rotate", toggleWidgetClass, masterform,
 
374
                             LAYOUT_TOP, XtNfromVert, label, XtNstate,
 
375
                             RotateFlag, XtNsensitive,
 
376
                             DeviceSelection->HandlesRotate, NULL);
 
377
  MirrorW =
 
378
    XtVaCreateManagedWidget ("mirror", toggleWidgetClass, masterform,
 
379
                             LAYOUT_TOP, XtNfromVert, label, XtNfromHoriz,
 
380
                             RotateW, XtNstate, mirrorflag, XtNsensitive,
 
381
                             DeviceSelection->HandlesMirror, NULL);
 
382
  ColorW =
 
383
    XtVaCreateManagedWidget ("color", toggleWidgetClass, masterform,
 
384
                             LAYOUT_TOP, XtNfromVert, label, XtNfromHoriz,
 
385
                             MirrorW, XtNstate, colorflag, XtNsensitive,
 
386
                             DeviceSelection->HandlesColor, NULL);
 
387
  InvertW =
 
388
    XtVaCreateManagedWidget ("invert", toggleWidgetClass, masterform,
 
389
                             LAYOUT_TOP, XtNfromVert, ColorW, XtNstate,
 
390
                             invertflag, XtNsensitive, True, NULL);
 
391
  label =
 
392
    XtVaCreateManagedWidget ("comment", labelWidgetClass, masterform,
 
393
                             LAYOUT_TOP, XtNfromVert, InvertW, XtNlabel,
 
394
                             "select outline and alignment targets:", NULL);
 
395
  outline =
 
396
    XtVaCreateManagedWidget ("outline", toggleWidgetClass, masterform,
 
397
                             LAYOUT_TOP, XtNfromVert, label, XtNstate,
 
398
                             OutlineFlag, NULL);
 
399
  alignment =
 
400
    XtVaCreateManagedWidget ("alignment", toggleWidgetClass, masterform,
 
401
                             LAYOUT_TOP, XtNfromVert, label, XtNfromHoriz,
 
402
                             outline, XtNstate, AlignmentFlag, NULL);
 
403
  drillhelper =
 
404
    XtVaCreateManagedWidget ("drillhelper", toggleWidgetClass, masterform,
 
405
                             LAYOUT_TOP, XtNfromVert, label, XtNfromHoriz,
 
406
                             alignment, XtNstate, drillhelperflag, NULL);
 
407
  scaleLabel =
 
408
    XtVaCreateManagedWidget ("comment", labelWidgetClass, masterform,
 
409
                             LAYOUT_TOP, XtNfromVert, outline, XtNlabel,
 
410
                             "select output scale here:", NULL);
 
411
  ScrollbarW =
 
412
    XtVaCreateManagedWidget ("scrollbar", scrollbarWidgetClass, masterform,
 
413
                             LAYOUT_TOP, XtNfromVert, scaleLabel, XtNlength,
 
414
                             SCROLLBAR_LENGTH, XtNminimumThumb, THUMB_LENGTH,
 
415
                             XtNorientation, XtorientHorizontal, NULL);
 
416
  ScaleW =
 
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,
 
422
                                   masterform,
 
423
                                   LAYOUT_TOP,
 
424
                                   XtNfromVert,
 
425
                                   PannerW ? PannerW : ScrollbarW, XtNlabel,
 
426
                                   "select for DOS compatible filenames:",
 
427
                                   NULL);
 
428
  DOSnames =
 
429
    XtVaCreateManagedWidget ("dosNames", toggleWidgetClass, masterform,
 
430
                             LAYOUT_TOP, XtNfromVert, label, XtNstate,
 
431
                             DOSFilenames, XtNlabel, "DOS (8.3) names", NULL);
 
432
  FilenameLabelW =
 
433
    XtVaCreateManagedWidget ("comment", labelWidgetClass, masterform,
 
434
                             LAYOUT_TOP, XtNfromVert, DOSnames, XtNlabel,
 
435
                             "enter filename:", NULL);
 
436
  FilenameW =
 
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);
 
443
 
 
444
  /* now we add the buttons, the first one is always default */
 
445
  AddButtons (masterform, FilenameW, buttons, ENTRIES (buttons));
 
446
 
 
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);
 
456
 
 
457
  /* override default translations and
 
458
   * install accelerators for buttons
 
459
   */
 
460
  XtOverrideTranslations (FilenameW,
 
461
                          XtParseTranslationTable (InputTranslations));
 
462
  XtInstallAccelerators (FilenameW, buttons[0].W);
 
463
  XtInstallAccelerators (FilenameW, buttons[1].W);
 
464
 
 
465
  /* set focus to input line */
 
466
  XtSetKeyboardFocus (masterform, FilenameW);
 
467
 
 
468
  /* the panner widget has to be realized before the offset can be set;
 
469
   * update sliders and buttons too
 
470
   */
 
471
  XtRealizeWidget (Popup);
 
472
  CB_DOS (DOSnames, NULL, NULL);
 
473
  PrintPannerSetSliderPosition (offsetx, offsety);
 
474
  UpdateScale ();
 
475
  PrintPannerUpdate (Scale, RotateFlag, OutlineFlag, AlignmentFlag);
 
476
  UpdateScrollbar (Scale);
 
477
 
 
478
  /* update menu button according to old settings
 
479
   * thanks to: John M. Harrison <jmh@nei.mv.com>
 
480
   */
 
481
  CB_Device (device, (XtPointer) DeviceSelection, NULL);
 
482
 
 
483
  /* now display dialog window and handle input */
 
484
  StartDialog (Popup);
 
485
  DialogEventLoop (&ReturnCode);
 
486
 
 
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);
 
493
 
 
494
  /* get media selection and transform center-based offset
 
495
   * to upper-left corner
 
496
   */
 
497
  if (DeviceSelection->HandlesMedia)
 
498
    {
 
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);
 
504
    }
 
505
  else
 
506
    {
 
507
      /* use some defaults if the device doesn't handle media */
 
508
      media = NULL;
 
509
      offsetx = offsety = 0;
 
510
    }
 
511
 
 
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);
 
516
 
 
517
  /* now everything is saved; destroy the dialog */
 
518
  EndDialog (Popup);
 
519
 
 
520
  /* call the printing routine if everything is OK;
 
521
   * convert offsets to distance from upper-left corner
 
522
   */
 
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);
541
528
}