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