Some compile fixes, not enough
[erwise] / Ui / UiPage.c
1 static char *rcsid = "$Id: UiPage.c,v 1.4 1992/03/26 18:13:50 kny Exp kny $";
2
3 #include "UiIncludes.h"
4
5
6 static uiHierarchy_t *uifindoraddhierarchy(char *topaddress);
7 static uiHierarchy_t *uifindhierarchy(char *topaddress);
8 static int uideletehierarchy(uiHierarchy_t * hierarchy);
9 static uiPage_t *uifindpage(HText_t * htext, uiHierarchy_t * hierarchy);
10 static uiPage_t *
11  uiaddpage(HText_t * htext, HTextObject_t * htextobject,
12             uiHierarchy_t * hierarchy, uiPage_t * prevpage);
13 static int uideletepage(uiPage_t * page, uiHierarchy_t * hierarchy);
14 static void uideletepagecallbacks(uiPage_t * page);
15 static uiPage_t *uifindshadowpage(uiHierarchy_t * hierarchy, uiPage_t * page);
16 static int uicreatepagewidgets(uiPage_t * page, uiPage_t * prevpage,
17                                 char *title);
18 static void uicreatepageform(uiPage_t * page, char *title, Widget topwdg);
19 static Widget uicreatepagemenu(uiPage_t * page, Widget formwdg);
20 static Widget uicreatepagemenuitem(uiPage_t * page, Widget menuwdg,
21                                     int itempos, int level);
22 static int uifindnextitem(int itempos, int level);
23 static Widget uicreatepagecontrol(uiPage_t * page, Widget formwdg, char *title);
24 static void uicreatepagelabel(Widget parentwdg, char *label);
25 static void uicreatepagebutton(uiPage_t * page, Widget parentwdg, char *name,
26                                 int leftpos, int rightpos);
27 static Widget uicreatepagefind(uiPage_t * page, Widget formwdg,
28                                 Widget controlwdg);
29 static Widget uicreatepagescroll(uiPage_t * page, Widget formwdg,
30                                   Widget menuwdg, Widget controlwdg);
31 static void uiconnectpage(uiPage_t * page);
32 static void uipageupdatescrollbars(uiPage_t * page);
33 static uiActionData_t *uicreatepageactiondata(uiPage_t * page,
34                                                char *actionname);
35 static void uisetcurrentpage(uiPage_t * page);
36 static int uideletepageinternal(char *topaddress, HText_t * htext);
37
38 static void uipageactivatecb(Widget wdg, uiActionData_t * actiondata,
39                               XmAnyCallbackStruct * calldata);
40 static void uipagekludgecb(Widget wdg, uiActionData_t * actiondata,
41                             XEvent * event);
42 static void uipageexposecb(Widget wdg, uiPage_t * page,
43                             XmDrawingAreaCallbackStruct * calldata);
44 static void uipageresizecb(Widget wdg, uiPage_t * page,
45                             XmDrawingAreaCallbackStruct * calldata);
46 static void uipageinputcb(char *topaddress, HText_t * htext,
47                            HTextObject_t * htextobject, void *parameter);
48 static void uipagescrollbarcb(char *topaddress, HText_t * htext,
49                            HTextObject_t * htextobject, void *parameter);
50 static void uipagedowncb(char *topaddress, HText_t * htext,
51                           HTextObject_t * htextobject, void *parameter);
52 static void uipageupcb(char *topaddress, HText_t * htext,
53                         HTextObject_t * htextobject, void *parameter);
54 static void uipagetopcb(char *topaddress, HText_t * htext,
55                          HTextObject_t * htextobject, void *parameter);
56 static void uipagebottomcb(char *topaddress, HText_t * htext,
57                             HTextObject_t * htextobject, void *parameter);
58
59 uiPageInfo_t uiPageInfo =
60 {
61     (uiPage_t *) NULL,
62     (Widget) NULL,
63     (void *) NULL
64 };
65
66
67 int UiDisplayPage(topaddress, prevhtext, htext, htextobject, title)
68 char *topaddress;
69 HText_t *prevhtext;
70 HText_t *htext;
71 HTextObject_t *htextobject;
72 char *title;
73 {
74     uiHierarchy_t *hierarchy;
75     uiPage_t *prevpage, *page;
76
77     if (!(hierarchy = uifindoraddhierarchy(topaddress)))
78         return UI_ERROR;
79
80     if (!(page = uifindpage(htext, hierarchy)) || !page->Visible) {
81         prevpage = uifindpage(prevhtext, hierarchy);
82
83         if (!page)
84             if (!(page = uiaddpage(htext, htextobject, hierarchy, prevpage))) {
85                 if (!hierarchy->Pages)
86                     (void) uideletehierarchy(hierarchy);        /* already an error */
87
88                 return UI_ERROR;
89             }
90         if (uicreatepagewidgets(page, prevpage, title) == UI_OK) {
91             uisetcurrentpage(page);
92
93             return UI_OK;
94         } else
95             return UI_ERROR;
96     } else {
97         XRaiseWindow(XtDisplay(page->Gfx.TopWdg), XtWindow(page->Gfx.TopWdg));
98         uisetcurrentpage(page);
99     }
100
101     return UI_OK;
102 }
103
104
105 int UiDeletePage(topaddress, htext)
106 char *topaddress;
107 HText_t *htext;
108 {
109     uiHierarchy_t *hierarchy;
110     uiPage_t *page, *shadowpage;
111     uiAction_t *tmpaction;
112
113     if (!(hierarchy = uifindhierarchy(topaddress)))
114         return UI_ERROR;
115
116     if (!(page = uifindpage(htext, hierarchy)))
117         return UI_ERROR;
118
119     XlDeleteText(htext);
120
121     shadowpage = uifindshadowpage(hierarchy, page);
122
123     if (page->Visible)
124         XtDestroyWidget(XtParent(page->Gfx.FormWdg));
125     uideletepage(page, hierarchy);
126
127     if (shadowpage) {           /* Recursive destroy, oh yeah */
128         tmpaction = uiFindAction("Close");
129         (tmpaction->Callback) (topaddress, shadowpage->HText,
130                           shadowpage->HTextObject, tmpaction->Parameter);
131     }
132     return UI_OK;
133 }
134
135
136 int UiSetCursor(topaddress, htext, htextobject)
137 char *topaddress;
138 HText_t *htext;
139 HTextObject_t *htextobject;
140 {
141     uiHierarchy_t *hierarchy;
142     uiPage_t *page;
143     int tmpx, tmpy;
144
145     if (!(hierarchy = uifindhierarchy(topaddress)))
146         return UI_ERROR;
147
148     if (!(page = uifindpage(htext, hierarchy)))
149         return UI_ERROR;
150
151     page->HTextObject = htextobject;
152
153     if (!page->Visible)
154         return UI_OK;
155
156     XlSetCursor(htext, htextobject);
157
158     XlGetCoordinates(&tmpx, &tmpy, htextobject);
159     if (tmpx < page->Layout.X || tmpx > page->Layout.X + page->Layout.Width)
160         page->Layout.X = tmpx - page->Layout.Width / 2;
161     if (tmpy < page->Layout.Y || tmpy > page->Layout.Y + page->Layout.Height)
162         page->Layout.Y = tmpy - page->Layout.Height / 2;
163
164     uipageupdatescrollbars(page);
165     XlMoveWindow(page->Layout.X, page->Layout.Y, page->HText);
166
167     return UI_OK;
168 }
169
170
171 void uiPageUpdateWindow(page)
172 uiPage_t *page;
173 {
174     HTextObject_t *htextobject;
175     int tmpwidth;
176
177     if (page->Settings.UseFixed)
178         tmpwidth = page->Settings.FixedWidth - page->Settings.LeftMargin -
179             page->Settings.RightMargin;
180     else
181         tmpwidth = page->Layout.Width - page->Settings.LeftMargin -
182             page->Settings.RightMargin;
183
184     htextobject = XlLocateHTextObject(0, 0, page->HText);
185     XlFormatText(page->Settings.LeftMargin, tmpwidth,
186                  page->Settings.TopMargin, &page->Layout.VirtualWidth,
187                  &page->Layout.VirtualHeight, page->HText);
188     XlGetCoordinates(&page->Layout.X, &page->Layout.Y, htextobject);
189
190     if (page->Layout.VirtualWidth > tmpwidth + page->Settings.LeftMargin)
191         page->Layout.VirtualWidth += page->Settings.RightMargin;
192     else
193         page->Layout.VirtualWidth = tmpwidth + page->Settings.LeftMargin +
194             page->Settings.RightMargin;
195     page->Layout.VirtualHeight += page->Settings.BottomMargin;
196
197     if (!page->Settings.UseFixed)
198         page->Layout.X = 0;
199     uipageupdatescrollbars(page);
200
201     XlSetPageCoordinates(page->Layout.X, page->Layout.Y, page->HText);
202 }
203
204
205 void uiPageAttachCallbacks()
206 {
207     UiAttachCallback("Top", uipagetopcb, (void *) NULL);
208     UiAttachCallback("Bottom", uipagebottomcb, (void *) NULL);
209 }
210
211
212 void uiPageDefineKeys()
213 {
214     UiBindKey("space", UI_NONE, uipagedowncb, (void *) NULL);
215     UiBindKey("Delete", UI_NONE, uipageupcb, (void *) NULL);
216
217     UiBindKey("less", UI_SHIFT, uipagetopcb, (void *) NULL);
218     UiBindKey("greater", UI_SHIFT, uipagebottomcb, (void *) NULL);
219 }
220
221
222 static uiHierarchy_t *
223  uifindoraddhierarchy(topaddress)
224 char *topaddress;
225 {
226     uiHierarchy_t *tmphierarchy;
227
228     if (!(tmphierarchy = uifindhierarchy(topaddress))) {
229         tmphierarchy = uiTopLevel.Hierarchies;
230         if (!tmphierarchy)
231             tmphierarchy = uiTopLevel.Hierarchies =
232                 (uiHierarchy_t *) uiMalloc(sizeof(*tmphierarchy));
233         else {
234             while (tmphierarchy->Next)
235                 tmphierarchy = tmphierarchy->Next;
236             tmphierarchy = tmphierarchy->Next =
237                 (uiHierarchy_t *) uiMalloc(sizeof(*tmphierarchy));
238         }
239         tmphierarchy->Address = topaddress;
240         tmphierarchy->Pages = (uiPage_t *) NULL;
241         tmphierarchy->Next = (uiHierarchy_t *) NULL;
242     }
243     return tmphierarchy;
244 }
245
246
247 static uiHierarchy_t *
248  uifindhierarchy(topaddress)
249 char *topaddress;
250 {
251     uiHierarchy_t *tmphierarchy = uiTopLevel.Hierarchies;
252
253     while (tmphierarchy && strcmp(tmphierarchy->Address, topaddress))
254         tmphierarchy = tmphierarchy->Next;
255
256     return tmphierarchy;
257 }
258
259
260 static int uideletehierarchy(hierarchy)
261 uiHierarchy_t *hierarchy;
262 {
263     uiHierarchy_t *tmphierarchy = uiTopLevel.Hierarchies;
264
265     if (hierarchy == tmphierarchy)
266         if (tmphierarchy->Next) {
267             uiTopLevel.Hierarchies = hierarchy->Next;
268             uisetcurrentpage(hierarchy->Next->Pages);
269         } else {
270             uiTopLevel.Hierarchies = (uiHierarchy_t *) NULL;
271             uisetcurrentpage((uiPage_t *) NULL);
272         }
273     else {
274         while (tmphierarchy->Next && tmphierarchy->Next != hierarchy)
275             tmphierarchy = tmphierarchy->Next;
276         if (tmphierarchy->Next) {
277             tmphierarchy->Next = tmphierarchy->Next->Next;
278             uisetcurrentpage(tmphierarchy->Pages);
279         } else {
280             /* This shouldn't happen unless we have a stray pointer */
281             uiDisplayWarning("Messed up hierarchy-list");
282
283             return UI_ERROR;
284         }
285     }
286
287     uiFree(hierarchy);
288
289     return UI_OK;
290 }
291
292
293 static uiPage_t *
294  uifindpage(htext, hierarchy)
295 HText_t *htext;
296 uiHierarchy_t *hierarchy;
297 {
298     uiPage_t *tmppage = hierarchy->Pages;
299
300     while (tmppage && tmppage->HText != htext)
301         tmppage = tmppage->Next;
302
303     return tmppage;
304 }
305
306
307 static uiPage_t *
308  uiaddpage(htext, htextobject, hierarchy, prevpage)
309 HText_t *htext;
310 HTextObject_t *htextobject;
311 uiHierarchy_t *hierarchy;
312 uiPage_t *prevpage;
313 {
314     uiPage_t *tmppage = hierarchy->Pages;
315
316     if (!tmppage)
317         tmppage = hierarchy->Pages =
318             (uiPage_t *) uiMalloc(sizeof(*tmppage));
319     else {
320         while (tmppage->Next)
321             tmppage = tmppage->Next;
322         tmppage = tmppage->Next =
323             (uiPage_t *) uiMalloc(sizeof(*tmppage));
324     }
325     tmppage->HText = htext;
326     tmppage->HTextObject = htextobject;
327     tmppage->Hierarchy = hierarchy;
328
329     if (prevpage) {
330         tmppage->Settings.TopMargin = prevpage->Settings.TopMargin;
331         tmppage->Settings.BottomMargin = prevpage->Settings.BottomMargin;
332         tmppage->Settings.LeftMargin = prevpage->Settings.LeftMargin;
333         tmppage->Settings.RightMargin = prevpage->Settings.RightMargin;
334         tmppage->Settings.OnePageMode = prevpage->Settings.OnePageMode;
335         tmppage->Settings.UseFixed = prevpage->Settings.UseFixed;
336         tmppage->Settings.FixedWidth = prevpage->Settings.FixedWidth;
337         tmppage->Layout.Width = prevpage->Layout.Width;
338         tmppage->Layout.Height = prevpage->Layout.Height;
339     } else {
340         uiGlobalSettings_t *gs = &uiTopLevel.GlobalSettings;
341
342         tmppage->Settings.TopMargin = gs->TopMargin;
343         tmppage->Settings.BottomMargin = gs->BottomMargin;
344         tmppage->Settings.LeftMargin = gs->LeftMargin;
345         tmppage->Settings.RightMargin = gs->RightMargin;
346         tmppage->Settings.OnePageMode = gs->OnePageMode;
347         tmppage->Settings.UseFixed = gs->UseFixed;
348         tmppage->Settings.FixedWidth = gs->FixedWidth;
349         tmppage->Layout.Width = gs->Width;
350         tmppage->Layout.Height = gs->Height;
351     }
352
353     /* X and Y are href-dependent, Width and Height default, or previous */
354     tmppage->Layout.X = 0;
355     tmppage->Layout.Y = 0;
356
357     tmppage->Callbacks = (uiPageCBList_t *) NULL;
358     tmppage->Next = (uiPage_t *) NULL;
359
360     return tmppage;
361 }
362
363
364 static int uideletepage(page, hierarchy)
365 uiPage_t *page;
366 uiHierarchy_t *hierarchy;
367 {
368     uiPage_t *tmppage = hierarchy->Pages;
369
370     if (tmppage == page)
371         if (tmppage->Next) {
372             hierarchy->Pages = tmppage->Next;
373             uisetcurrentpage(tmppage->Next);
374         } else
375             uideletehierarchy(hierarchy);
376     else {
377         while (tmppage->Next && tmppage->Next != page)
378             tmppage = tmppage->Next;
379         if (tmppage->Next) {
380             tmppage->Next = tmppage->Next->Next;
381             if (tmppage->Next)
382                 uisetcurrentpage(tmppage->Next);
383             else
384                 uisetcurrentpage(tmppage);
385         } else {
386             /* This shouldn't happen unless we have a stray pointer */
387             uiDisplayWarning("Messed up page-list");
388
389             return UI_ERROR;
390         }
391     }
392
393     uiListUpdateDialog(page);
394     uideletepagecallbacks(page);
395     uiFree(page);
396
397     return UI_OK;
398 }
399
400
401 static void uideletepagecallbacks(page)
402 uiPage_t *page;
403 {
404     uiPageCBList_t *tmpcb = page->Callbacks;
405
406     while (tmpcb) {
407         tmpcb = tmpcb->Next;
408         uiFree(page->Callbacks);
409         page->Callbacks = tmpcb;
410     }
411 }
412
413
414 static uiPage_t *
415  uifindshadowpage(hierarchy, page)
416 uiHierarchy_t *hierarchy;
417 uiPage_t *page;
418 {
419     uiPage_t *tmppage = hierarchy->Pages;
420
421     while (tmppage)
422         if (tmppage != page && tmppage->Gfx.TopWdg == page->Gfx.TopWdg)
423             return tmppage;
424         else
425             tmppage = tmppage->Next;
426
427     return (uiPage_t *) NULL;
428 }
429
430
431 static int uicreatepagewidgets(page, prevpage, title)
432 uiPage_t *page;
433 uiPage_t *prevpage;
434 char *title;
435 {
436     uiTopLevelGfx_t *topgfx = &uiTopLevel.TopGfx;
437     uiPageGfx_t *pagegfx = &page->Gfx;
438     Widget topwdg, bottomwdg;
439
440     /* Ahemm, we could of course try to salvage as much as possible
441        of the widget tree, but why bother? No, just destroy everything
442        except for the toplevel shell, no need to remove callbacks and
443        event handlers
444     */
445     if (prevpage && prevpage->Settings.OnePageMode) {
446         topwdg = prevpage->Gfx.TopWdg;
447         uideletepageinternal(prevpage->Hierarchy->Address, prevpage->HText);
448         uicreatepageform(page, title, topwdg);
449     } else
450         uicreatepageform(page, title, (Widget) NULL);
451
452     page->Visible = TRUE;
453     pagegfx->MenuWdg = uicreatepagemenu(page, pagegfx->FormWdg);
454     XtManageChild(pagegfx->MenuWdg);
455     pagegfx->ControlWdg = uicreatepagecontrol(page, pagegfx->FormWdg, title);
456     XtManageChild(pagegfx->ControlWdg);
457     page->Gfx.FindTextWdg = (Widget) NULL;
458     if (HTAnchor_isIndex(page->HText->node_anchor)) {
459         pagegfx->FindWdg = uicreatepagefind(page, pagegfx->FormWdg,
460                                             pagegfx->ControlWdg);
461         XtManageChild(pagegfx->FindWdg);
462         bottomwdg = pagegfx->FindWdg;
463     } else
464         bottomwdg = pagegfx->ControlWdg;
465     pagegfx->DrawAreaWdg = uicreatepagescroll(page, pagegfx->FormWdg,
466                                             pagegfx->MenuWdg, bottomwdg);
467
468     XtManageChild(pagegfx->FormWdg);
469     XtRealizeWidget(pagegfx->TopWdg);
470
471     /* Do setup that cannot be done before managing the form */
472     XtVaSetValues(pagegfx->HScrollBarWdg,
473                   XmNrightAttachment, XmATTACH_FORM,
474                   XmNrightOffset, uiGetArg(pagegfx->FormWdg, XmNwidth) -
475                   uiGetArg(pagegfx->DrawAreaWdg, XmNwidth), NULL);
476     uiconnectpage(page);
477
478     /* Is this really necessary?
479     XmUpdateDisplay(XtParent(pagegfx->FormWdg));
480     Nope, don't think so */
481
482     return UI_OK;
483 }
484
485
486 static void uicreatepageform(page, title, topwdg)
487 uiPage_t *page;
488 char *title;
489 Widget topwdg;
490 {
491     ArgList args;
492     Cardinal nargs;
493     char *tmptitle;
494
495     if (topwdg)
496         page->Gfx.TopWdg = topwdg;
497     else
498         page->Gfx.TopWdg = XtCreateApplicationShell("Page",
499                                                 topLevelShellWidgetClass,
500                                                     NULL, 0);
501     if (title) {
502         tmptitle = uiMalloc(strlen(UI_ERWISE_TITLE) + strlen(title) + 4);
503         sprintf(tmptitle, "%s - %s", UI_ERWISE_TITLE, title);
504         XtVaSetValues(page->Gfx.TopWdg,
505                       XmNtitle, tmptitle, NULL);
506         uiFree(tmptitle);
507     } else
508         XtVaSetValues(page->Gfx.TopWdg,
509                       XmNtitle, UI_ERWISE_TITLE, NULL);
510
511     args = uiVaSetArgs(&nargs,
512                        NULL);
513     page->Gfx.FormWdg = XmCreateForm(page->Gfx.TopWdg, "Form", args, nargs);
514 }
515
516
517 static char *uimenu[] =
518 {
519     "Page", NULL,
520     " Search", "Search",
521     " Copy", "Copy",
522     " List", "List",
523     " Load to file", "Load to file",
524     " Print", "Print",
525     " Settings", "Settings",
526     " ", NULL,
527     " Close", "Close",
528     "Movement", "Movement",
529     " Top", "Top",
530     " Bottom", "Bottom",
531     " Prev tag", "Prev tag",
532     " Next tag", "Next tag",
533     "Hierarchy", NULL,
534     " Home", "Home",
535     " Recall", "Recall",
536     " Back", "Back",
537     " Prev page", "Prev page",
538     " Next page", "Next page",
539     " Close", NULL,
540     "  hierarchy", "Close hierarchy",
541     "Misc", NULL,
542     " Connections", "Connections",
543     " Controlpanel", "Controlpanel",
544     " Defaults", "Defaults",
545     "Help", NULL,
546     " On function", "On function",
547     " Manual", "Help",
548     NULL
549 };
550
551 static Widget
552  uicreatepagemenu(page, formwdg)
553 uiPage_t *page;
554 Widget formwdg;
555 {
556     ArgList args;
557     Cardinal nargs;
558     Widget menuwdg, tmpmenuwdg;
559     int itempos = 0;
560
561     args = uiVaSetArgs(&nargs,
562                        XmNleftAttachment, XmATTACH_FORM,
563                        XmNrightAttachment, XmATTACH_FORM,
564                        XmNtopAttachment, XmATTACH_FORM, NULL);
565     menuwdg = XmCreateMenuBar(formwdg, "menubar", args, nargs);
566
567     do {
568         tmpmenuwdg = uicreatepagemenuitem(page, menuwdg, itempos, 0);
569         if (ui_HELPMENU(uimenu[itempos]))
570             XtVaSetValues(menuwdg,
571                           XmNmenuHelpWidget, tmpmenuwdg, NULL);
572         itempos = uifindnextitem(itempos, 0);
573     }
574     while (ui_VALID(itempos));
575
576     return menuwdg;
577 }
578
579
580 static Widget
581  uicreatepagemenuitem(page, menuwdg, itempos, level)
582 uiPage_t *page;
583 Widget menuwdg;
584 int itempos;
585 int level;
586 {
587     int childitempos = itempos;
588     int childlevel = level + 1;
589     char *label;
590     ArgList args;
591     Cardinal nargs;
592     Widget pulldownwdg;
593     Widget cascadewdg;
594     Widget tmpwdg;
595     uiActionData_t *actiondata;
596
597     label = &uimenu[itempos][level];
598     if (ui_VALID(uifindnextitem(itempos, childlevel))) {
599         pulldownwdg = XmCreatePulldownMenu(menuwdg, "Pulldown", NULL, 0);
600         args = uiVaSetArgs(&nargs, XmNsubMenuId, pulldownwdg, NULL);
601         cascadewdg = XmCreateCascadeButtonGadget(menuwdg, label, args, nargs);
602         XtManageChild(cascadewdg);
603
604         while (ui_VALID(childitempos =
605                         uifindnextitem(childitempos, childlevel)))
606             uicreatepagemenuitem(page, pulldownwdg, childitempos, childlevel);
607
608         tmpwdg = cascadewdg;
609     } else {
610         if (label[0]) {
611             if (ui_TOGGLE(label)) {
612                 tmpwdg = XmCreateToggleButtonGadget(menuwdg, label, NULL, 0);
613             } else {
614                 tmpwdg = XmCreatePushButtonGadget(menuwdg, label, NULL, 0);
615                 actiondata = uicreatepageactiondata(page, uimenu[itempos + 1]);
616                 XtAddCallback(tmpwdg, XmNactivateCallback,
617                               (XtCallbackProc) uipageactivatecb,
618                               (caddr_t) actiondata);
619             }
620         } else
621             tmpwdg = XmCreateSeparatorGadget(menuwdg, "Separator", NULL, 0);
622         XtManageChild(tmpwdg);
623     }
624
625     return tmpwdg;
626 }
627
628
629 static int uifindnextitem(itempos, level)
630 int itempos;
631 int level;
632 {
633     int i = itempos + 2;
634
635     while (uimenu[i] &&
636            (uimenu[i][level] == ' ' || uimenu[i][level] == '*'))
637         i += 2;
638     if (!uimenu[i] ||
639     (level && uimenu[i][level - 1] != ' ' && uimenu[i][level - 1] != '*'))
640         return UI_INVALID;
641
642     return i;
643 }
644
645
646 static Widget
647  uicreatepagecontrol(page, formwdg, title)
648 uiPage_t *page;
649 Widget formwdg;
650 char *title;
651 {
652     ArgList args;
653     Cardinal nargs;
654     Widget controlwdg;
655
656     args = uiVaSetArgs(&nargs,
657                        XmNheight, 70,
658                        XmNshadowThickness, 2,
659                        XmNleftAttachment, XmATTACH_FORM,
660                        XmNrightAttachment, XmATTACH_FORM,
661                        XmNbottomAttachment, XmATTACH_FORM, NULL);
662     controlwdg = XmCreateForm(formwdg, "Control", args, nargs);
663
664     uicreatepagelabel(controlwdg,
665                 HTAnchor_address((HTAnchor *) page->HText->node_anchor));
666
667     uicreatepagebutton(page, controlwdg, "Prev tag", 1, 16);
668     uicreatepagebutton(page, controlwdg, "Next tag", 17, 32);
669     uicreatepagebutton(page, controlwdg, "Prev page", 35, 50);
670     uicreatepagebutton(page, controlwdg, "Back", 51, 66);
671     uicreatepagebutton(page, controlwdg, "Next page", 67, 82);
672     uicreatepagebutton(page, controlwdg, "Close", 85, 99);
673
674     return controlwdg;
675 }
676
677
678 static void uicreatepagelabel(parentwdg, label)
679 Widget parentwdg;
680 char *label;
681 {
682     Widget labelwdg;
683     XmString labelstr;
684
685     labelstr = XmStringCreateSimple(label);
686     labelwdg = XmCreateLabelGadget(parentwdg, "Label", (ArgList) NULL, 0);
687     XtVaSetValues(labelwdg,
688                   XmNtopAttachment, XmATTACH_FORM,
689                   XmNtopOffset, 5,
690                   XmNleftAttachment, XmATTACH_FORM,
691                   XmNleftOffset, 5,
692                   XmNrightAttachment, XmATTACH_FORM,
693                   XmNrightOffset, 5,
694                   XmNlabelString, labelstr, NULL);
695
696     XtManageChild(labelwdg);
697 }
698
699
700 static void uicreatepagebutton(page, parentwdg, name, leftpos, rightpos)
701 uiPage_t *page;
702 Widget parentwdg;
703 char *name;
704 int leftpos;
705 int rightpos;
706 {
707     Widget tmpwdg;
708     uiActionData_t *actiondata;
709
710     tmpwdg = XmCreatePushButtonGadget(parentwdg, name, (ArgList) NULL, 0);
711     XtVaSetValues(tmpwdg,
712                   XmNbottomAttachment, XmATTACH_FORM,
713                   XmNbottomOffset, 5,
714                   XmNleftAttachment, XmATTACH_POSITION,
715                   XmNleftPosition, leftpos,
716                   XmNrightAttachment, XmATTACH_POSITION,
717                   XmNrightPosition, rightpos, NULL);
718     actiondata = uicreatepageactiondata(page, name);
719     XtAddCallback(tmpwdg, XmNactivateCallback, uipageactivatecb,
720                   (caddr_t) actiondata);
721
722     XtManageChild(tmpwdg);
723 }
724
725
726 static Widget
727  uicreatepagefind(page, formwdg, controlwdg)
728 uiPage_t *page;
729 Widget formwdg;
730 Widget controlwdg;
731 {
732     Widget framewdg, findformwdg, buttonwdg, textwdg;
733     uiActionData_t *actiondata;
734     XmString labelstr;
735
736     labelstr = XmStringCreateSimple("     Find:     ");
737
738     framewdg = XmCreateFrame(formwdg, "FindFrame", (ArgList) NULL, 0);
739     XtVaSetValues(framewdg,
740                   XmNshadowType, XmSHADOW_OUT,
741                   XmNmarginWidth, 2,
742                   XmNmarginHeight, 2,
743                   XmNleftAttachment, XmATTACH_FORM,
744                   XmNrightAttachment, XmATTACH_FORM,
745                   XmNbottomAttachment, XmATTACH_WIDGET,
746                   XmNbottomWidget, controlwdg,
747                   XmNbottomOffset, 1, NULL);
748
749     findformwdg = XmCreateForm(framewdg, "FindForm", (ArgList) NULL, 0);
750     XtManageChild(findformwdg);
751
752     buttonwdg = XmCreatePushButtonGadget(findformwdg, "FindButton",
753                                          (ArgList) NULL, 0);
754     XtVaSetValues(buttonwdg,
755                   XmNlabelString, labelstr,
756                   XmNtopAttachment, XmATTACH_FORM,
757                   XmNleftAttachment, XmATTACH_FORM,
758                   XmNbottomAttachment, XmATTACH_FORM, NULL);
759     actiondata = uicreatepageactiondata(page, "IndexFind");
760     XtAddCallback(buttonwdg, XmNactivateCallback, uipageactivatecb,
761                   (caddr_t) actiondata);
762     XmStringFree(labelstr);
763     XtManageChild(buttonwdg);
764
765     textwdg = XmCreateText(findformwdg, "FindText", (ArgList) NULL, 0);
766     XtVaSetValues(textwdg,
767                   XmNtopAttachment, XmATTACH_FORM,
768                   XmNleftAttachment, XmATTACH_WIDGET,
769                   XmNleftWidget, buttonwdg,
770                   XmNrightAttachment, XmATTACH_FORM,
771                   XmNbottomAttachment, XmATTACH_FORM, NULL);
772     XtAddCallback(textwdg, XmNactivateCallback, uipageactivatecb,
773                   (caddr_t) actiondata);
774     XtAddCallback(textwdg, XmNactivateCallback,
775               (XtCallbackProc) uiDialogVariableCB, (caddr_t) "FindText");
776     XtAddCallback(textwdg, XmNlosingFocusCallback,
777               (XtCallbackProc) uiDialogVariableCB, (caddr_t) "FindText");
778     XtAddCallback(textwdg, XmNvalueChangedCallback,
779               (XtCallbackProc) uiDialogVariableCB, (caddr_t) "FindText");
780     (void) uiAddWidgetInfo("FindText", textwdg, uiWTtext);      /* Ignore */
781     page->Gfx.FindTextWdg = textwdg;
782     XtManageChild(textwdg);
783
784     return framewdg;
785 }
786
787
788 static Widget
789  uicreatepagescroll(page, formwdg, menuwdg, bottomwdg)
790 uiPage_t *page;
791 Widget formwdg;
792 Widget menuwdg;
793 Widget bottomwdg;
794 {
795     ArgList args;
796     Cardinal nargs;
797     Widget drawwdg, hsbwdg, vsbwdg;
798     uiActionData_t *actiondata;
799
800     args = uiVaSetArgs(&nargs,
801                        XmNorientation, XmHORIZONTAL,
802                        XmNwidth, page->Layout.Width,
803                        XmNbottomAttachment, XmATTACH_WIDGET,
804                        XmNbottomWidget, bottomwdg,
805                        XmNbottomOffset, 2, NULL);
806     hsbwdg = XmCreateScrollBar(formwdg, "HScrollBar", args, nargs);
807     page->Gfx.HScrollBarWdg = hsbwdg;
808     actiondata = uicreatepageactiondata(page, "HScrollBar");
809     XtAddCallback(hsbwdg, XmNvalueChangedCallback,
810               (XtCallbackProc) uipageactivatecb, (caddr_t *) actiondata);
811     UiAttachCallback("HScrollBar", uipagescrollbarcb, (void *) "HScrollBar");
812
813     args = uiVaSetArgs(&nargs,
814                        XmNorientation, XmVERTICAL,
815                        XmNheight, page->Layout.Height,
816                        XmNtopAttachment, XmATTACH_WIDGET,
817                        XmNtopWidget, menuwdg,
818                        XmNrightAttachment, XmATTACH_FORM,
819                        XmNbottomAttachment, XmATTACH_WIDGET,
820                        XmNbottomWidget, hsbwdg, NULL);
821     vsbwdg = XmCreateScrollBar(formwdg, "VScrollBar", args, nargs);
822     page->Gfx.VScrollBarWdg = vsbwdg;
823     actiondata = uicreatepageactiondata(page, "VScrollBar");
824     XtAddCallback(vsbwdg, XmNvalueChangedCallback,
825               (XtCallbackProc) uipageactivatecb, (caddr_t *) actiondata);
826     UiAttachCallback("VScrollBar", uipagescrollbarcb, (void *) "VScrollBar");
827
828     args = uiVaSetArgs(&nargs,
829                        XmNwidth, page->Layout.Width,
830                        XmNheight, page->Layout.Height,
831                        XmNtopAttachment, XmATTACH_WIDGET,
832                        XmNtopWidget, menuwdg,
833                        XmNleftAttachment, XmATTACH_FORM,
834                        XmNrightAttachment, XmATTACH_WIDGET,
835                        XmNrightWidget, vsbwdg,
836                        XmNbottomAttachment, XmATTACH_WIDGET,
837                        XmNbottomWidget, hsbwdg, NULL);
838     drawwdg = XmCreateDrawingArea(formwdg, "Draw", args, nargs);
839     XtAddCallback(drawwdg, XmNexposeCallback, (XtCallbackProc) uipageexposecb,
840                   (caddr_t) page);
841     XtAddCallback(drawwdg, XmNresizeCallback, (XtCallbackProc) uipageresizecb,
842                   (caddr_t) page);
843     actiondata = uicreatepageactiondata(page, "PageInput");
844     XtAddCallback(drawwdg, XmNinputCallback, (XtCallbackProc) uipageactivatecb,
845                   (caddr_t) actiondata);
846     XtAddEventHandler(drawwdg, KeyPressMask, FALSE, uipagekludgecb,
847                       (caddr_t) actiondata);
848     UiAttachCallback("PageInput", uipageinputcb, (void *) NULL);
849
850     XtManageChild(drawwdg);
851     XtManageChild(hsbwdg);
852     XtManageChild(vsbwdg);
853
854     return drawwdg;
855 }
856
857
858 static void uiconnectpage(page)
859 uiPage_t *page;
860 {
861     Widget drawwdg = page->Gfx.DrawAreaWdg;
862     Widget hsbwdg = page->Gfx.HScrollBarWdg;
863     Widget vsbwdg = page->Gfx.VScrollBarWdg;
864     int tmpwidth;
865
866     XlSetupText(XtDisplay(drawwdg), XtWindow(drawwdg),
867                 (Pixel) uiGetArg(drawwdg, XmNforeground),
868                 (Pixel) uiGetArg(drawwdg, XmNbackground), page->HText);
869
870     if (page->Settings.UseFixed)
871         tmpwidth = page->Settings.FixedWidth - page->Settings.LeftMargin -
872             page->Settings.RightMargin;
873     else
874         tmpwidth = page->Layout.Width - page->Settings.LeftMargin -
875             page->Settings.RightMargin;
876
877     XlFormatText(page->Settings.LeftMargin, tmpwidth,
878                  page->Settings.TopMargin, &page->Layout.VirtualWidth,
879                  &page->Layout.VirtualHeight, page->HText);
880
881     if (page->Layout.VirtualWidth > tmpwidth + page->Settings.LeftMargin)
882         page->Layout.VirtualWidth += page->Settings.RightMargin;
883     else
884         page->Layout.VirtualWidth = tmpwidth + page->Settings.LeftMargin +
885             page->Settings.RightMargin;
886     page->Layout.VirtualHeight += page->Settings.BottomMargin;
887
888     if (page->HTextObject)
889         XlGetCoordinates(&page->Layout.X, &page->Layout.Y, page->HTextObject);
890     page->Layout.X = 0;
891     uipageupdatescrollbars(page);
892     if (page->HTextObject)
893         XlMoveWindow(page->Layout.X, page->Layout.Y, page->HText);
894
895     XlSetCursor(page->HText, page->HTextObject);
896 }
897
898
899 static void uipageupdatescrollbars(page)
900 uiPage_t *page;
901 {
902     Widget hsbwdg = page->Gfx.HScrollBarWdg;
903     Widget vsbwdg = page->Gfx.VScrollBarWdg;
904     int maxwidth, maxheight;
905     int hsbwidth, vsbheight;
906
907     maxwidth = page->Layout.VirtualWidth;
908     if (page->Layout.X + page->Layout.Width > maxwidth)
909         page->Layout.X -= ((page->Layout.X + page->Layout.Width) - maxwidth);
910     hsbwidth = (page->Layout.Width > maxwidth) ? maxwidth : page->Layout.Width;
911     if (page->Layout.X < 0)
912         page->Layout.X = 0;
913
914     maxheight = page->Layout.VirtualHeight;
915     if (page->Layout.Y + page->Layout.Height > maxheight)
916         page->Layout.Y -= ((page->Layout.Y + page->Layout.Height) - maxheight);
917     vsbheight =
918         (page->Layout.Height > maxheight) ? maxheight : page->Layout.Height;
919     if (page->Layout.Y < 0)
920         page->Layout.Y = 0;
921
922
923     XtVaSetValues(hsbwdg,
924                   XmNmaximum, maxwidth,
925                   XmNvalue, page->Layout.X,
926                   XmNsliderSize, hsbwidth,
927                   XmNincrement, hsbwidth / 10,
928                   XmNpageIncrement, hsbwidth, NULL);
929     XtVaSetValues(vsbwdg,
930                   XmNmaximum, maxheight,
931                   XmNvalue, page->Layout.Y,
932                   XmNsliderSize, vsbheight,
933                   XmNincrement, vsbheight / 10,
934                   XmNpageIncrement, vsbheight, NULL);
935 }
936
937
938 uiActionData_t *
939  uicreatepageactiondata(page, actionname)
940 uiPage_t *page;
941 char *actionname;
942 {
943     uiPageCBList_t *tmppagecb = page->Callbacks;
944
945     if (!tmppagecb)
946         tmppagecb =
947             page->Callbacks = (uiPageCBList_t *) uiMalloc(sizeof(*tmppagecb));
948     else {
949         while (tmppagecb->Next)
950             tmppagecb = tmppagecb->Next;
951         tmppagecb = tmppagecb->Next =
952             (uiPageCBList_t *) uiMalloc(sizeof(*tmppagecb));
953     }
954     tmppagecb->ActionData.ActionName = actionname;
955     tmppagecb->ActionData.Page = page;
956     tmppagecb->Next = (uiPageCBList_t *) NULL;
957
958     return &tmppagecb->ActionData;
959 }
960
961
962 static void uisetcurrentpage(page)
963 uiPage_t *page;
964 {
965     uiPage_t *oldpage;
966
967     oldpage = uiPageInfo.CurrentPage;
968     uiPageInfo.CurrentPage = page;
969
970     if (oldpage != page) {
971         uiPageSettingsUpdateDialog();
972         uiSearchUpdateDialog();
973         uiControlPanelUpdateDialog();
974         uiPrintUpdateDialog();
975         uiRecallUpdateDialog();
976         uiConnectionsUpdateDialog();
977     }
978 }
979
980
981 static int uideletepageinternal(topaddress, htext)
982 char *topaddress;
983 HText_t *htext;
984 {
985     uiHierarchy_t *hierarchy;
986     uiPage_t *page;
987     Widget topwdg;
988
989     if (!(hierarchy = uifindhierarchy(topaddress)))
990         return UI_ERROR;
991
992     if (!(page = uifindpage(htext, hierarchy)))
993         return UI_ERROR;
994
995 /*    XlDeleteText(htext);*/
996
997     topwdg = page->Gfx.TopWdg;
998     page = hierarchy->Pages;
999     while (page) {
1000         if (page->Gfx.TopWdg == topwdg) {
1001             if (page->Visible)
1002                 XtDestroyWidget(page->Gfx.FormWdg);
1003             page->Visible = FALSE;
1004         }
1005         page = page->Next;
1006     }
1007 /*    uideletepage(page, hierarchy);*/
1008
1009     return UI_OK;
1010 }
1011
1012
1013 static void uipageactivatecb(wdg, actiondata, calldata)
1014 Widget wdg;
1015 uiActionData_t *actiondata;
1016 XmAnyCallbackStruct *calldata;
1017 {
1018     uiAction_t *tmpaction;
1019
1020     uiPageInfo.Wdg = wdg;
1021     uiPageInfo.CallData = (void *) calldata;
1022     uisetcurrentpage(actiondata->Page);
1023     if (actiondata->Page->Gfx.FindTextWdg) {
1024         (void) uiAddWidgetInfo("FindText", actiondata->Page->Gfx.FindTextWdg,
1025                                uiWTtext);       /* Ignore */
1026         (void) uiDialogVariableCB((Widget) NULL, "FindText",
1027                                   (XmAnyCallbackStruct *) NULL);        /* Hmm? */
1028     }
1029     if (tmpaction = uiFindAction(actiondata->ActionName)) {
1030         uiDefineCursor(uiBusyCursor);
1031         if (uiHelpOnActionCB) {
1032             (*uiHelpOnActionCB) (actiondata->ActionName);
1033             uiHelpOnActionCB = (void (*) (char *actionstring)) NULL;
1034         } else
1035             (*tmpaction->Callback) (actiondata->Page->Hierarchy->Address,
1036                                     actiondata->Page->HText,
1037                                     actiondata->Page->HTextObject,
1038                                     tmpaction->Parameter);
1039         uiUndefineCursor();
1040     }
1041 }
1042
1043
1044 /*
1045  *  Massive braindamage ahead ... default translation in
1046  *  drawingarea-widget for return is activate, even if the widget
1047  *  doesn't support activate. Gawd! Anyway, we have to resort to this:
1048  */
1049
1050 static void uipagekludgecb(wdg, actiondata, event)
1051 Widget wdg;
1052 uiActionData_t *actiondata;
1053 XEvent *event;
1054 {
1055     XKeyEvent *kevent = (XKeyEvent *) event;
1056     XmAnyCallbackStruct tmpstruct;
1057
1058     if (XLookupKeysym(kevent, kevent->state) == XK_Return) {
1059         tmpstruct.event = event;
1060         uipageactivatecb(wdg, actiondata, &tmpstruct);
1061     }
1062 }
1063
1064
1065 static void uipageexposecb(wdg, page, calldata)
1066 Widget wdg;
1067 uiPage_t *page;
1068 XmDrawingAreaCallbackStruct *calldata;
1069 {
1070     XExposeEvent *event = (XExposeEvent *) calldata->event;
1071
1072 #ifdef DEBUG
1073     printf("Explode: %d %d %d %d %x\n",
1074            event->x, event->y, event->width, event->height, page->HText);
1075 #endif
1076     XlRedraw(event->x, event->y, event->width, event->height, page->HText);
1077 }
1078
1079
1080 static void uipageresizecb(wdg, page, calldata)
1081 Widget wdg;
1082 uiPage_t *page;
1083 XmDrawingAreaCallbackStruct *calldata;
1084 {
1085     Widget hsbwdg = page->Gfx.HScrollBarWdg;
1086     Widget vsbwdg = page->Gfx.VScrollBarWdg;
1087     HTextObject_t *htextobject;
1088
1089 #ifdef DEBUG
1090     printf("Resize: %d %d\n",
1091            (int) ((Dimension) uiGetArg(wdg, XmNwidth)),
1092            (int) ((Dimension) uiGetArg(wdg, XmNheight)));
1093 #endif
1094
1095     if (!XtIsRealized(page->Gfx.DrawAreaWdg))
1096         return;
1097
1098     XlClearWindow(page->Layout.Width, page->Layout.Height, page->HText);
1099
1100     page->Layout.Width = (int) ((Dimension) uiGetArg(wdg, XmNwidth));
1101     page->Layout.Height = (int) ((Dimension) uiGetArg(wdg, XmNheight));
1102
1103     uiPageUpdateWindow(page);
1104 }
1105
1106
1107 static void uipageinputcb(topaddress, htext, htextobject, parameter)
1108 char *topaddress;
1109 HText_t *htext;
1110 HTextObject_t *htextobject;
1111 void *parameter;
1112 {
1113     Widget wdg = uiPageInfo.Wdg;
1114     uiPage_t *page = uiPageInfo.CurrentPage;
1115     XmDrawingAreaCallbackStruct *calldata =
1116     (XmDrawingAreaCallbackStruct *) uiPageInfo.CallData;
1117     XButtonEvent *bevent = (XButtonEvent *) calldata->event;
1118     XKeyEvent *kevent = (XKeyEvent *) calldata->event;
1119     static int dragx, dragy;
1120     static Time oldtime = (Time) 0;
1121     uiAction_t *tmpaction;
1122     uiKey_t *tmpkey;
1123     KeySym keysym;
1124     char *keysymstring;
1125     switch (bevent->type) {
1126     case ButtonPress:
1127         switch (bevent->button) {
1128         case 1:
1129             page->HTextObject = XlLocateHTextObject(bevent->x, bevent->y,
1130                                                     page->HText);
1131             XlSetCursor(htext, page->HTextObject);
1132             if (page->HTextObject) {
1133                 if (bevent->time - oldtime <
1134                     uiTopLevel.GlobalSettings.DoubleClickTime)
1135                     tmpaction = uiFindAction("Get page");
1136                 else
1137                     tmpaction = uiFindAction("Click page");
1138                 if (tmpaction) {
1139                     uiDefineCursor(uiBusyCursor);
1140                     if (uiHelpOnActionCB) {
1141                         (*uiHelpOnActionCB) ("Get page");
1142                         uiHelpOnActionCB = (void (*) (char *actionstring)) NULL;
1143                     } else
1144                         (*tmpaction->Callback) (topaddress, htext,
1145                                                 page->HTextObject,
1146                                                 tmpaction->Parameter);
1147                     uiUndefineCursor();
1148                 }
1149                 oldtime = (Time) 0;
1150             }
1151             oldtime = bevent->time;
1152             break;
1153         case 2:
1154             dragx = bevent->x;
1155             dragy = bevent->y;
1156             break;
1157         }
1158         break;
1159     case ButtonRelease:
1160         switch (bevent->button) {
1161         case 2:
1162             page->Layout.X -= (bevent->x - dragx);
1163             page->Layout.Y -= (bevent->y - dragy);
1164             uipageupdatescrollbars(page);
1165             XlMoveWindow(page->Layout.X, page->Layout.Y, page->HText);
1166             break;
1167         }
1168         break;
1169     case KeyPress:
1170         keysym = XLookupKeysym(kevent, 0);
1171         if (keysym != NoSymbol && (keysymstring = XKeysymToString(keysym))) {
1172             if (tmpkey = uiFindKey(keysymstring, kevent->state)) {
1173                 uiDefineCursor(uiBusyCursor);
1174                 if (uiHelpOnActionCB) {
1175                     (*uiHelpOnActionCB) (keysymstring);
1176                     uiHelpOnActionCB = (void (*) (char *actionstring)) NULL;
1177                 } else
1178                     (*tmpkey->Callback) (topaddress,
1179                                          htext,
1180                                          page->HTextObject,
1181                                          tmpkey->Parameter);
1182                 uiUndefineCursor();
1183             }
1184         }
1185         break;
1186     }
1187 }
1188
1189
1190 static void uipagescrollbarcb(topaddress, htext, htextobject, parameter)
1191 char *topaddress;
1192 HText_t *htext;
1193 HTextObject_t *htextobject;
1194 void *parameter;
1195 {
1196     XmUpdateDisplay(uiPageInfo.CurrentPage->Gfx.DrawAreaWdg);
1197
1198     if (!strcmp("HScrollBar", (char *) parameter))
1199         uiPageInfo.CurrentPage->Layout.X =
1200             ((XmScrollBarCallbackStruct *) uiPageInfo.CallData)->value;
1201     else
1202         uiPageInfo.CurrentPage->Layout.Y =
1203             ((XmScrollBarCallbackStruct *) uiPageInfo.CallData)->value;
1204
1205 #ifdef DEBUG
1206     printf("scrollbar: %d %d\n", uiPageInfo.CurrentPage->Layout.X,
1207            uiPageInfo.CurrentPage->Layout.Y);
1208 #endif
1209     XlMoveWindow(uiPageInfo.CurrentPage->Layout.X,
1210                  uiPageInfo.CurrentPage->Layout.Y,
1211                  uiPageInfo.CurrentPage->HText);
1212 }
1213
1214
1215 static void uipagedowncb(topaddress, htext, htextobject, parameter)
1216 char *topaddress;
1217 HText_t *htext;
1218 HTextObject_t *htextobject;
1219 void *parameter;
1220 {
1221     uiPage_t *page = uiPageInfo.CurrentPage;
1222
1223     page->Layout.Y = page->Layout.Y + page->Layout.Height;
1224
1225     uipageupdatescrollbars(page);
1226     XlMoveWindow(page->Layout.X, page->Layout.Y, page->HText);
1227 }
1228
1229
1230 static void uipageupcb(topaddress, htext, htextobject, parameter)
1231 char *topaddress;
1232 HText_t *htext;
1233 HTextObject_t *htextobject;
1234 void *parameter;
1235 {
1236     uiPage_t *page = uiPageInfo.CurrentPage;
1237
1238     page->Layout.Y = page->Layout.Y - page->Layout.Height;
1239
1240     uipageupdatescrollbars(page);
1241     XlMoveWindow(page->Layout.X, page->Layout.Y, page->HText);
1242 }
1243
1244
1245 static void uipagetopcb(topaddress, htext, htextobject, parameter)
1246 char *topaddress;
1247 HText_t *htext;
1248 HTextObject_t *htextobject;
1249 void *parameter;
1250 {
1251     uiPage_t *page = uiPageInfo.CurrentPage;
1252
1253     page->Layout.Y = 0;
1254
1255     uipageupdatescrollbars(page);
1256     XlMoveWindow(page->Layout.X, page->Layout.Y, page->HText);
1257 }
1258
1259
1260 static void uipagebottomcb(topaddress, htext, htextobject, parameter)
1261 char *topaddress;
1262 HText_t *htext;
1263 HTextObject_t *htextobject;
1264 void *parameter;
1265 {
1266     uiPage_t *page = uiPageInfo.CurrentPage;
1267
1268     page->Layout.Y = page->Layout.VirtualHeight - page->Layout.Height;
1269
1270     uipageupdatescrollbars(page);
1271     XlMoveWindow(page->Layout.X, page->Layout.Y, page->HText);
1272 }