1 static char *rcsid = "$Id: UiInit.c,v 1.3 1992/03/26 18:13:50 kny Exp kny $";
3 #include "UiIncludes.h"
6 static void uisetupdefaults(int argc, char *argv[],
7 void *(*configpf) (void *table, char *item));
8 static Widget uicreatebutton(Widget parentwdg, char *name, int leftpos,
11 static void uitopactivatecb(Widget wdg, caddr_t actionname,
12 XmPushButtonCallbackStruct * calldata);
15 uiTopLevel_t uiTopLevel;
16 Cursor uiBusyCursor, uiArrowCursor;
17 void *(*uiConfigPF) (void *table, char *item);
18 void *(*uiConfigSetPF) (void *table, char *item, void *value);
21 int UiInitialize(argc, argv, configpf, configsetpf)
24 void *(*configpf) (void *table, char *item);
25 void *(*configsetpf) (void *table, char *item, void *value);
27 uiTopLevelGfx_t *topgfx = &uiTopLevel.TopGfx;
29 uiConfigPF = configpf;
30 uiConfigSetPF = configsetpf;
32 topgfx->TopWdg = XtInitialize(argv[0], "Erwise", NULL, 0, &argc, argv);
33 topgfx->FormWdg = XmCreateForm(topgfx->TopWdg, "Form",
35 XtVaSetValues(topgfx->FormWdg,
38 topgfx->InfoWdg = uicreatebutton(topgfx->FormWdg, "Info", 0, 25);
39 topgfx->OpenWdg = uicreatebutton(topgfx->FormWdg, "Open", 25, 50);
40 topgfx->QuitWdg = uicreatebutton(topgfx->FormWdg, "Quit", 50, 75);
41 topgfx->HelpWdg = uicreatebutton(topgfx->FormWdg, "Help", 75, 100);
43 XtManageChild(topgfx->FormWdg);
44 XtRealizeWidget(topgfx->TopWdg);
46 XlSetupResources(configpf);
48 uisetupdefaults(argc, argv, configpf);
50 uiBusyCursor = XCreateFontCursor(XtDisplay(topgfx->TopWdg), XC_watch);
51 uiArrowCursor = XCreateFontCursor(XtDisplay(topgfx->TopWdg),
67 if (value && !strncasecmp(value, "mouse", strlen("mouse")))
73 static void uisetupdefaults(argc, argv, configpf)
76 void *(*configpf) (void *table, char *item);
78 uiGlobalSettings_t *gs = &uiTopLevel.GlobalSettings;
81 if (table = configpf((void *) NULL, C_GLOBALSETTINGS)) {
82 gs->TopMargin = atoi((char *) configpf(table, C_TOPMARGIN));
83 gs->BottomMargin = atoi((char *) configpf(table, C_BOTTOMMARGIN));
84 gs->LeftMargin = atoi((char *) configpf(table, C_LEFTMARGIN));
85 gs->RightMargin = atoi((char *) configpf(table, C_RIGHTMARGIN));
86 gs->UseFixed = TruthValue((char *) configpf(table, C_FIXEDWIDTHMODE));
87 gs->FixedWidth = atoi((char *) configpf(table, C_FIXEDWIDTH));
88 gs->OnePageMode = TruthValue((char *) configpf(table, C_ONEPAGEMODE));
89 gs->Width = atoi((char *) configpf(table, C_WIDTH));
90 gs->Height = atoi((char *) configpf(table, C_HEIGHT));
92 (Time) atoi((char *) configpf(table, C_DOUBLECLICKTIME));
93 gs->SearchPlacement = PlaceValue((char *) configpf(table, C_SEARCH));
94 gs->ControlPanelPlacement =
95 PlaceValue((char *) configpf(table, C_CONTROLPANEL));
97 PlaceValue((char *) configpf(table, C_LIST));
99 PlaceValue((char *) configpf(table, C_RECALL));
100 gs->PageSettingsPlacement =
101 PlaceValue((char *) configpf(table, C_PAGESETTINGS));
103 uiDisplayWarning("failed to get configurations for global settings");
105 if (table = configpf((void *) NULL, C_DEFAULTS))
106 uiSelectionArray = (char **) configpf(table, C_DEFAULTSTABLE);
108 uiDisplayWarning("failed to get configurations for selection");
110 uiPageAttachCallbacks();
116 uicreatebutton(parentwdg, name, leftpos, rightpos)
124 tmpwdg = XmCreatePushButtonGadget(parentwdg, name,
126 XtVaSetValues(tmpwdg,
127 XmNtopAttachment, XmATTACH_FORM,
128 XmNbottomAttachment, XmATTACH_FORM,
129 XmNleftAttachment, XmATTACH_POSITION,
130 XmNleftPosition, leftpos,
131 XmNrightAttachment, XmATTACH_POSITION,
132 XmNrightPosition, rightpos, NULL);
133 XtAddCallback(tmpwdg, XmNactivateCallback, uitopactivatecb,
135 XtManageChild(tmpwdg);
141 static void uitopactivatecb(wdg, actionname, calldata)
144 XmPushButtonCallbackStruct *calldata;
146 uiAction_t *tmpaction;
148 if (tmpaction = uiFindAction((char *) actionname))
149 if (uiHelpOnActionCB) {
150 (*uiHelpOnActionCB) (actionname);
151 uiHelpOnActionCB = (void (*) (char *actionstring)) NULL;
153 (*tmpaction->Callback) ((char *) NULL, (HText_t *) NULL,
154 (HTextObject_t *) NULL,
155 tmpaction->Parameter);