Some compile fixes, not enough
[erwise] / Ui / UiPrint.c
1 static char *rcsid = "$Id$";
2
3 #include "UiIncludes.h"
4
5
6 static Widget uicreateprintformdialog();
7 static Widget uicreateprintcmd(Widget formwdg);
8 static Widget
9  uicreateprintmargin(Widget formwdg, Widget topwdg,
10                       char *name, char *labeltext, int pos);
11 static Widget uicreateprintseparator(Widget formwdg, Widget topwdg);
12 static Widget uicreateprintwidth(Widget formwdg, Widget topwdg);
13 static Widget uicreateprintfile(Widget formwdg, Widget topwdg);
14 static void uicreateprintbuttons(Widget formwdg, Widget topwdg);
15 static void uiprintmargincb(char *address, HText_t * htext,
16                              HTextObject_t * htextobject,
17                              void *parameter);
18 static void uiprintwidthcb(char *address, HText_t * htext,
19                             HTextObject_t * htextobject,
20                             void *parameter);
21 static void uiprintbuttoncb(char *address, HText_t * htext,
22                              HTextObject_t * htextobject,
23                              void *parameter);
24
25
26 static uiActionData_t uiactiondata[8] =
27 {
28     {"LArrowDown", (uiPage_t *) NULL},
29     {"LArrowUp", (uiPage_t *) NULL},
30     {"RArrowDown", (uiPage_t *) NULL},
31     {"RArrowUp", (uiPage_t *) NULL},
32     {"TArrowDown", (uiPage_t *) NULL},
33     {"TArrowUp", (uiPage_t *) NULL},
34     {"BArrowDown", (uiPage_t *) NULL},
35     {"BArrowUp", (uiPage_t *) NULL}
36 };
37
38
39 static Widget uiprinttextwidget[] =
40 {
41     (Widget) NULL,
42     (Widget) NULL,
43     (Widget) NULL,
44     (Widget) NULL
45 };
46
47
48 int UiDisplayPrintDialog(type)
49 int type;
50 {
51     uiPrintGfx_t *printgfx = &uiTopLevel.PrintGfx;
52     Widget separatorwdg, tmpwdg;
53
54
55     if (printgfx->FormWdg) {
56         XtMapWidget(XtParent(printgfx->FormWdg));
57
58         return UI_OK;
59     }
60     printgfx->FormWdg = uicreateprintformdialog();
61
62     printgfx->PrintCmdWdg = uicreateprintcmd(printgfx->FormWdg);
63     printgfx->PrintFileWdg = uicreateprintfile(printgfx->FormWdg,
64                                                printgfx->PrintCmdWdg);
65
66     printgfx->LeftMarginWdg = uicreateprintmargin(printgfx->FormWdg,
67                                                   printgfx->PrintFileWdg,
68                                                   "PrintLeft", "Left",
69                                                   UI_LEFT);
70     printgfx->RightMarginWdg =
71         uicreateprintmargin(printgfx->FormWdg, printgfx->LeftMarginWdg,
72                             "PrintRight", "Right", UI_LEFT);
73     printgfx->TopMarginWdg = uicreateprintmargin(printgfx->FormWdg,
74                                                  printgfx->PrintFileWdg,
75                                             "PrintTop", "Top", UI_RIGHT);
76     printgfx->BottomMarginWdg =
77         uicreateprintmargin(printgfx->FormWdg, printgfx->TopMarginWdg,
78                             "PrintBottom", "Bottom", UI_RIGHT);
79
80     tmpwdg = uicreateprintwidth(printgfx->FormWdg, printgfx->BottomMarginWdg);
81
82     separatorwdg = uicreateprintseparator(printgfx->FormWdg, tmpwdg);
83     uicreateprintbuttons(printgfx->FormWdg, separatorwdg);
84     XtManageChild(printgfx->FormWdg);
85     XtRealizeWidget(XtParent(printgfx->FormWdg));
86
87     return UI_OK;
88 }
89
90
91 void uiPrintUpdateDialog()
92 {
93     if (uiTopLevel.PrintGfx.FormWdg) {
94         if (uiPageInfo.CurrentPage) {
95         } else
96             XtUnmapWidget(XtParent(uiTopLevel.PrintGfx.FormWdg));
97     }
98 }
99
100
101 static Widget
102  uicreateprintformdialog()
103 {
104     ArgList args;
105     Cardinal nargs;
106     Widget formwdg;
107     Widget topwdg;
108
109     topwdg = XtCreateApplicationShell("Print",
110                                       topLevelShellWidgetClass,
111                                       NULL, 0);
112     XtVaSetValues(topwdg,
113                   XmNtitle, UI_PRINT_TITLE, NULL);
114
115     args = uiVaSetArgs(&nargs,
116                        XmNresizePolicy, XmRESIZE_NONE,
117                        XmNautoUnmanage, FALSE, NULL);
118     formwdg = XmCreateForm(topwdg, "Print", args, nargs);
119
120     return formwdg;
121 }
122
123
124 static Widget
125  uicreateprintmargin(formwdg, topwdg, name, labeltext, pos)
126 Widget formwdg;
127 Widget topwdg;
128 char *name;
129 char *labeltext;
130 int pos;
131 {
132     ArgList args;
133     Cardinal nargs;
134     XmString labelstr;
135     static int callnr = 0;
136     Widget marginformwdg, labelwdg;
137     Widget margindownwdg, marginupwdg, textwdg;
138     static char textvar[4][18]; /* strlen("PrintBottomMargin") */
139     char *text;
140
141     args = uiVaSetArgs(&nargs,
142                        XmNtopAttachment, XmATTACH_WIDGET,
143                        XmNtopWidget, topwdg,
144                        XmNtopOffset, UI_PRINT_WDG_OFFSET,
145                        XmNleftAttachment, XmATTACH_POSITION,
146                        XmNleftPosition, 5 + 50 * (pos == UI_RIGHT),
147                        XmNrightAttachment, XmATTACH_POSITION,
148                     XmNrightPosition, 45 + 50 * (pos == UI_RIGHT), NULL);
149     marginformwdg = XmCreateForm(formwdg, "MarginForm", args, nargs);
150     XtManageChild(marginformwdg);
151
152     labelstr = XmStringCreateSimple(labeltext);
153     args = uiVaSetArgs(&nargs,
154                        XmNlabelString, labelstr,
155                        XmNalignment, XmALIGNMENT_BEGINNING,
156                        XmNtopAttachment, XmATTACH_FORM,
157                        XmNleftAttachment, XmATTACH_POSITION,
158                        XmNleftPosition, 5,
159                        XmNrightAttachment, XmATTACH_POSITION,
160                        XmNrightPosition, 40,
161                        XmNbottomAttachment, XmATTACH_FORM, NULL);
162     labelwdg = XmCreateLabelGadget(marginformwdg, "TextLabel", args, nargs);
163     XtManageChild(labelwdg);
164     XmStringFree(labelstr);
165
166     args = uiVaSetArgs(&nargs,
167                        XmNarrowDirection, XmARROW_DOWN,
168                        XmNwidth, 15,
169                        XmNheight, 5,
170                        XmNtopAttachment, XmATTACH_POSITION,
171                        XmNtopPosition, 50,
172                        XmNrightAttachment, XmATTACH_POSITION,
173                        XmNrightPosition, 95,
174                        XmNbottomAttachment, XmATTACH_FORM, NULL);
175     margindownwdg = XmCreateArrowButtonGadget(marginformwdg,
176                                          uiactiondata[callnr].ActionName,
177                                               args, nargs);
178     uiactiondata[callnr].Page = uiPageInfo.CurrentPage;
179     XtAddCallback(margindownwdg, XmNactivateCallback,
180                   (XtCallbackProc) uiDialogActivateCB,
181                   (caddr_t) & uiactiondata[callnr]);
182     UiAttachCallback(uiactiondata[callnr].ActionName, uiprintmargincb,
183                      uiactiondata[callnr].ActionName);
184     callnr++;
185     XtManageChild(margindownwdg);
186
187     args = uiVaSetArgs(&nargs,
188                        XmNarrowDirection, XmARROW_UP,
189                        XmNwidth, 15,
190                        XmNheight, 5,
191                        XmNrightAttachment, XmATTACH_POSITION,
192                        XmNrightPosition, 95,
193                        XmNtopAttachment, XmATTACH_FORM,
194                        XmNbottomAttachment, XmATTACH_POSITION,
195                        XmNbottomPosition, 50, NULL);
196     marginupwdg = XmCreateArrowButtonGadget(marginformwdg, "ArrowDown",
197                                             args, nargs);
198     uiactiondata[callnr].Page = uiPageInfo.CurrentPage;
199     XtAddCallback(marginupwdg, XmNactivateCallback,
200                   (XtCallbackProc) uiDialogActivateCB,
201                   (caddr_t) & uiactiondata[callnr]);
202     UiAttachCallback(uiactiondata[callnr].ActionName, uiprintmargincb,
203                      uiactiondata[callnr].ActionName);
204     callnr++;
205     XtManageChild(marginupwdg);
206
207     text = textvar[callnr / 2 - 1];
208     sprintf(text, "%sMargin", name);
209     args = uiVaSetArgs(&nargs,
210                        XmNcolumns, 4,
211                        XmNtopAttachment, XmATTACH_FORM,
212                        XmNrightAttachment, XmATTACH_WIDGET,
213                        XmNrightWidget, margindownwdg,
214                        XmNbottomAttachment, XmATTACH_FORM,
215                        XmNvalue, "0", NULL);
216     textwdg = XmCreateText(marginformwdg, text, args, nargs);
217     uiprinttextwidget[callnr / 2 - 1] = textwdg;
218     XtAddCallback(textwdg, XmNactivateCallback,
219                   (XtCallbackProc) uiDialogVariableCB, (caddr_t) text);
220     XtAddCallback(textwdg, XmNlosingFocusCallback,
221                   (XtCallbackProc) uiDialogVariableCB, (caddr_t) text);
222     XtAddCallback(textwdg, XmNvalueChangedCallback,
223                   (XtCallbackProc) uiDialogVariableCB, (caddr_t) text);
224     (void) uiAddWidgetInfo(text, textwdg, uiWTtext);    /* ignore */
225     XtManageChild(textwdg);
226
227     return marginformwdg;
228 }
229
230
231 static Widget
232  uicreateprintseparator(formwdg, topwdg)
233 Widget formwdg;
234 Widget topwdg;
235 {
236     ArgList args;
237     Cardinal nargs;
238     Widget separatorwdg;
239
240     args = uiVaSetArgs(&nargs,
241                        XmNtopAttachment, XmATTACH_WIDGET,
242                        XmNtopWidget, topwdg,
243                        XmNtopOffset, UI_PRINT_WDG_OFFSET,
244                        XmNleftAttachment, XmATTACH_FORM,
245                        XmNrightAttachment, XmATTACH_FORM, NULL);
246     separatorwdg = XmCreateSeparatorGadget(formwdg, "PRINTSeparator",
247                                            args, nargs);
248     XtManageChild(separatorwdg);
249
250     return separatorwdg;
251 }
252
253
254 static Widget
255  uicreateprintcmd(formwdg)
256 Widget formwdg;
257 {
258     XmString labelstr;
259     ArgList args;
260     Cardinal nargs;
261     Widget tmpformwdg;
262     Widget labelwdg;
263     Widget textwdg;
264     static uiActionData_t actiondata[2];
265
266     labelstr = XmStringCreateSimple("Print command");
267     args = uiVaSetArgs(&nargs,
268                        XmNtopAttachment, XmATTACH_FORM,
269                        XmNtopOffset, UI_PRINT_WDG_OFFSET,
270                        XmNrightAttachment, XmATTACH_FORM,
271                        XmNrightOffset, UI_PRINT_WDG_OFFSET,
272                        XmNleftAttachment, XmATTACH_FORM,
273                        XmNleftOffset, UI_PRINT_WDG_OFFSET, NULL);
274     tmpformwdg = XmCreateForm(formwdg, "PrintcmdForm", args, nargs);
275     XtManageChild(tmpformwdg);
276
277     args = uiVaSetArgs(&nargs,
278                        XmNlabelString, labelstr,
279                        XmNtopAttachment, XmATTACH_FORM,
280                        XmNleftAttachment, XmATTACH_FORM,
281                        XmNbottomAttachment, XmATTACH_FORM, NULL);
282     labelwdg = XmCreateLabelGadget(tmpformwdg, "Label", args, nargs);
283     XtManageChild(labelwdg);
284
285     args = uiVaSetArgs(&nargs,
286                        XmNtopAttachment, XmATTACH_FORM,
287                        XmNbottomAttachment, XmATTACH_FORM,
288                        XmNrightAttachment, XmATTACH_WIDGET,
289                        XmNleftAttachment, XmATTACH_WIDGET,
290                        XmNleftWidget, labelwdg,
291                        XmNleftOffset, UI_PRINT_WDG_OFFSET,
292                        XmNvalue, "lpr", NULL);
293     textwdg = XmCreateText(tmpformwdg, "PrintCmd", args, nargs);
294     uiTopLevel.PrintGfx.WidthWdg = textwdg;
295     XtAddCallback(textwdg, XmNactivateCallback,
296                   (XtCallbackProc) uiDialogVariableCB,
297                   (caddr_t) "PrintCommand");
298     XtAddCallback(textwdg, XmNlosingFocusCallback,
299                   (XtCallbackProc) uiDialogVariableCB,
300                   (caddr_t) "PrintCommand");
301     XtAddCallback(textwdg, XmNvalueChangedCallback,
302                   (XtCallbackProc) uiDialogVariableCB,
303                   (caddr_t) "PrintCommand");
304     /* Ignore */
305     (void) uiAddWidgetInfo("PrintCommand", textwdg, uiWTtext);
306     XtManageChild(textwdg);
307
308     return tmpformwdg;
309 }
310
311
312 static Widget
313  uicreateprintfile(formwdg, topwdg)
314 Widget formwdg;
315 Widget topwdg;
316 {
317     XmString labelstr;
318     ArgList args;
319     Cardinal nargs;
320     Widget tmpformwdg, widthwdg;
321     Widget textwdg;
322     static uiActionData_t actiondata[2];
323
324     labelstr = XmStringCreateSimple("Print to a file:");
325     args = uiVaSetArgs(&nargs,
326                        XmNtopAttachment, XmATTACH_WIDGET,
327                        XmNtopWidget, topwdg,
328                        XmNtopOffset, UI_PRINT_WDG_OFFSET,
329                        XmNrightAttachment, XmATTACH_FORM,
330                        XmNrightOffset, UI_PRINT_WDG_OFFSET,
331                        XmNleftAttachment, XmATTACH_FORM,
332                        XmNleftOffset, UI_PRINT_WDG_OFFSET, NULL);
333     tmpformwdg = XmCreateForm(formwdg, "FileForm", args, nargs);
334     XtManageChild(tmpformwdg);
335
336     args = uiVaSetArgs(&nargs,
337                        XmNlabelString, labelstr,
338                        XmNtopAttachment, XmATTACH_FORM,
339                        XmNleftAttachment, XmATTACH_FORM,
340                        XmNbottomAttachment, XmATTACH_FORM, NULL);
341     widthwdg = XmCreateToggleButtonGadget(tmpformwdg, "PrintToFile",
342                                           args, nargs);
343     XtAddCallback(widthwdg, XmNvalueChangedCallback,
344                   (XtCallbackProc) uiDialogVariableCB,
345                   (caddr_t) "PrintToFile");
346     /* Ignore */
347     (void) uiAddWidgetInfo("PrintToFile", widthwdg, uiWTcheckbutton);
348     XtManageChild(widthwdg);
349
350     args = uiVaSetArgs(&nargs,
351                        XmNtopAttachment, XmATTACH_FORM,
352                        XmNbottomAttachment, XmATTACH_FORM,
353                        XmNrightAttachment, XmATTACH_FORM,
354                        XmNleftAttachment, XmATTACH_WIDGET,
355                        XmNleftWidget, widthwdg,
356                        XmNvalue, "foobar.www", NULL);
357     textwdg = XmCreateText(tmpformwdg, "PrintFileName", args, nargs);
358     uiTopLevel.PrintGfx.WidthWdg = textwdg;
359     XtAddCallback(textwdg, XmNactivateCallback,
360                   (XtCallbackProc) uiDialogVariableCB,
361                   (caddr_t) "PrintFileName");
362     XtAddCallback(textwdg, XmNlosingFocusCallback,
363                   (XtCallbackProc) uiDialogVariableCB,
364                   (caddr_t) "PrintfileName");
365     XtAddCallback(textwdg, XmNvalueChangedCallback,
366                   (XtCallbackProc) uiDialogVariableCB,
367                   (caddr_t) "PrintFileName");
368     /* Ignore */
369     (void) uiAddWidgetInfo("PrintFileName", textwdg, uiWTtext);
370     XtManageChild(textwdg);
371
372     return tmpformwdg;
373 }
374
375
376 static Widget
377  uicreateprintwidth(formwdg, topwdg)
378 Widget formwdg;
379 Widget topwdg;
380 {
381     XmString labelstr;
382     ArgList args;
383     Cardinal nargs;
384     Widget tmpformwdg, labelwdg;
385     Widget textwdg, widthdownwdg, widthupwdg;
386     static uiActionData_t actiondata[2];
387
388     labelstr = XmStringCreateSimple("Width");
389     args = uiVaSetArgs(&nargs,
390                        XmNtopAttachment, XmATTACH_WIDGET,
391                        XmNtopWidget, topwdg,
392                        XmNtopOffset, UI_PRINT_WDG_OFFSET,
393                        XmNleftAttachment, XmATTACH_POSITION,
394                        XmNleftPosition, 5,
395                        XmNrightAttachment, XmATTACH_POSITION,
396                        XmNrightPosition, 45, NULL);
397     tmpformwdg = XmCreateForm(formwdg, "WidthForm", args, nargs);
398     XtManageChild(tmpformwdg);
399
400     args = uiVaSetArgs(&nargs,
401                        XmNlabelString, labelstr,
402                        XmNalignment, XmALIGNMENT_BEGINNING,
403                        XmNtopAttachment, XmATTACH_FORM,
404                        XmNleftAttachment, XmATTACH_POSITION,
405                        XmNleftPosition, 5,
406                        XmNrightAttachment, XmATTACH_POSITION,
407                        XmNrightPosition, 40,
408                        XmNbottomAttachment, XmATTACH_FORM, NULL);
409     labelwdg = XmCreateLabelGadget(tmpformwdg, "Label", args, nargs);
410     XtManageChild(labelwdg);
411
412     args = uiVaSetArgs(&nargs,
413                        XmNarrowDirection, XmARROW_DOWN,
414                        XmNwidth, 15,
415                        XmNheight, 5,
416                        XmNtopAttachment, XmATTACH_POSITION,
417                        XmNtopPosition, 50,
418                        XmNrightAttachment, XmATTACH_POSITION,
419                        XmNrightPosition, 95,
420                        XmNbottomAttachment, XmATTACH_FORM, NULL);
421     widthdownwdg = XmCreateArrowButtonGadget(tmpformwdg, "WidthDown",
422                                              args, nargs);
423     actiondata[0].ActionName = "WidthDown";
424     actiondata[0].Page = uiPageInfo.CurrentPage;
425     XtAddCallback(widthdownwdg, XmNactivateCallback,
426                   (XtCallbackProc) uiDialogActivateCB,
427                   (caddr_t) & actiondata[0]);
428     UiAttachCallback("WidthDown", uiprintwidthcb, "WidthDown");
429     XtManageChild(widthdownwdg);
430
431     args = uiVaSetArgs(&nargs,
432                        XmNarrowDirection, XmARROW_UP,
433                        XmNwidth, 15,
434                        XmNheight, 5,
435                        XmNrightAttachment, XmATTACH_POSITION,
436                        XmNrightPosition, 95,
437                        XmNtopAttachment, XmATTACH_FORM,
438                        XmNbottomAttachment, XmATTACH_POSITION,
439                        XmNbottomPosition, 50, NULL);
440     widthupwdg = XmCreateArrowButtonGadget(tmpformwdg, "WidthUp",
441                                            args, nargs);
442     actiondata[1].ActionName = "WidthUp";
443     actiondata[1].Page = uiPageInfo.CurrentPage;
444     XtAddCallback(widthupwdg, XmNactivateCallback,
445                   (XtCallbackProc) uiDialogActivateCB,
446                   (caddr_t) & actiondata[1]);
447     UiAttachCallback("WidthUp", uiprintwidthcb, "WidthUp");
448     XtManageChild(widthupwdg);
449
450     args = uiVaSetArgs(&nargs,
451                        XmNcolumns, 4,
452                        XmNtopAttachment, XmATTACH_FORM,
453                        XmNrightAttachment, XmATTACH_WIDGET,
454                        XmNrightWidget, widthdownwdg,
455                        XmNbottomAttachment, XmATTACH_FORM,
456                        XmNvalue, "80", NULL);
457     textwdg = XmCreateText(tmpformwdg, "PrintWidth", args, nargs);
458     uiTopLevel.PrintGfx.WidthWdg = textwdg;
459     XtAddCallback(textwdg, XmNactivateCallback,
460                   (XtCallbackProc) uiDialogVariableCB,
461                   (caddr_t) "PrintWidth");
462     XtAddCallback(textwdg, XmNlosingFocusCallback,
463                   (XtCallbackProc) uiDialogVariableCB,
464                   (caddr_t) "PrintWidth");
465     XtAddCallback(textwdg, XmNvalueChangedCallback,
466                   (XtCallbackProc) uiDialogVariableCB,
467                   (caddr_t) "PrintWidth");
468     /* Ignore */
469     (void) uiAddWidgetInfo("PrintWidth", textwdg, uiWTtext);
470     XtManageChild(textwdg);
471
472     return tmpformwdg;
473 }
474
475
476 static void uicreateprintbuttons(formwdg, topwdg)
477 Widget formwdg;
478 Widget topwdg;
479 {
480     ArgList args;
481     Cardinal nargs;
482     Widget okwdg, closewdg;
483     static uiActionData_t actiondata[3];
484
485     args = uiVaSetArgs(&nargs,
486                        XmNtopAttachment, XmATTACH_WIDGET,
487                        XmNtopWidget, topwdg,
488                        XmNtopOffset, UI_PRINT_WDG_OFFSET,
489                        XmNleftAttachment, XmATTACH_POSITION,
490                        XmNleftPosition, 5,
491                        XmNrightAttachment, XmATTACH_POSITION,
492                        XmNrightPosition, 25,
493                        XmNbottomAttachment, XmATTACH_FORM,
494                        XmNbottomOffset, UI_PRINT_WDG_OFFSET, NULL);
495     okwdg = XmCreatePushButtonGadget(formwdg, "Print", args, nargs);
496     actiondata[0].ActionName = "PRINTOk";
497     actiondata[0].Page = uiPageInfo.CurrentPage;
498     XtAddCallback(okwdg, XmNactivateCallback,
499                   (XtCallbackProc) uiDialogActivateCB,
500                   (caddr_t) & actiondata[0]);
501     UiAttachCallback("PRINTOk", uiprintbuttoncb, "PRINTOk");
502     XtManageChild(okwdg);
503
504     args = uiVaSetArgs(&nargs,
505                        XmNtopAttachment, XmATTACH_WIDGET,
506                        XmNtopWidget, topwdg,
507                        XmNtopOffset, UI_PRINT_WDG_OFFSET,
508                        XmNleftAttachment, XmATTACH_POSITION,
509                        XmNleftPosition, 75,
510                        XmNrightAttachment, XmATTACH_POSITION,
511                        XmNrightPosition, 95,
512                        XmNbottomAttachment, XmATTACH_FORM,
513                        XmNbottomOffset, UI_PRINT_WDG_OFFSET, NULL);
514     closewdg = XmCreatePushButtonGadget(formwdg, "Close", args, nargs);
515     actiondata[2].ActionName = "PRINTClose";
516     actiondata[2].Page = uiPageInfo.CurrentPage;
517     XtAddCallback(closewdg, XmNactivateCallback,
518                   (XtCallbackProc) uiDialogActivateCB,
519                   (caddr_t) & actiondata[2]);
520     UiAttachCallback("PRINTClose", uiprintbuttoncb, "PRINTClose");
521     XtManageChild(closewdg);
522 }
523
524
525
526 static void uiprintmargincb(address, htext, htextobject, parameter)
527 char *address;
528 HText_t *htext;
529 HTextObject_t *htextobject;
530 void *parameter;
531 {
532     int i;
533     Widget textwdg;
534     char *text;
535     int margin;
536     char tmpbuffer[5];
537
538     for (i = 0; i < 8; i++)
539         if (!strcmp(uiactiondata[i].ActionName, (char *) parameter)) {
540             textwdg = uiprinttextwidget[i / 2];
541             text = XmTextGetString(textwdg);
542             margin = atoi(text);
543             if (i % 2) {
544                 margin += 1;
545                 if (margin > 9999)
546                     margin = 9999;
547                 sprintf(tmpbuffer, "%d", margin);
548                 XmTextSetString(textwdg, tmpbuffer);
549             } else {
550                 margin = (margin - 1) * (margin > 0);
551                 sprintf(tmpbuffer, "%d", margin);
552                 XmTextSetString(textwdg, tmpbuffer);
553             }
554             XtFree(text);
555
556             return;
557         }
558 }
559
560
561 static void uiprintwidthcb(address, htext, htextobject, parameter)
562 char *address;
563 HText_t *htext;
564 HTextObject_t *htextobject;
565 void *parameter;
566 {
567     Widget textwdg = uiTopLevel.PrintGfx.WidthWdg;
568     char *fixedtext;
569     int width;
570     char tmpbuffer[5];
571
572     fixedtext = XmTextGetString(textwdg);
573     width = atoi(fixedtext);
574
575     if (!strcmp("WidthDown", (char *) parameter)) {
576         if (width) {
577             width = (width - 5) * (width > 4);
578             sprintf(tmpbuffer, "%d", width);
579             XmTextSetString(textwdg, tmpbuffer);
580         }
581     } else {
582         width += 5;
583         if (width > 9999)
584             width = 9999;
585         sprintf(tmpbuffer, "%d", width);
586         XmTextSetString(textwdg, tmpbuffer);
587     }
588
589     XtFree(fixedtext);
590 }
591
592
593 static void uiprintbuttoncb(address, htext, htextobject, parameter)
594 char *address;
595 HText_t *htext;
596 HTextObject_t *htextobject;
597 void *parameter;
598 {
599     uiPage_t *page = uiPageInfo.CurrentPage;
600
601     if (!strcmp("PRINTOk", (char *) parameter)) {
602         Print(htext);
603         XtUnmapWidget(XtParent(uiTopLevel.PrintGfx.FormWdg));
604     } else if (!strcmp("PRINTClose", (char *) parameter))
605         XtUnmapWidget(XtParent(uiTopLevel.PrintGfx.FormWdg));
606     else                        /* Shouldn't reach this point */
607         uiDisplayWarning("printbuttoncb called with illegal parameter");
608 }