earlybrowserreborn - Blame information for rev 2

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 roytam 1 static char *rcsid = "$Id: UiInit.c,v 1.3 1992/03/26 18:13:50 kny Exp kny $";
2  
3 #include "UiIncludes.h"
4  
5  
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,
9                               int rightpos);
10  
2 roytam 11 static void uitopactivatecb(Widget wdg, XtPointer actionname,
12                              XtPointer calldata);
1 roytam 13  
14  
15 uiTopLevel_t uiTopLevel;
16 Cursor uiBusyCursor, uiArrowCursor;
17 void *(*uiConfigPF) (void *table, char *item);
18 void *(*uiConfigSetPF) (void *table, char *item, void *value);
19  
20  
21 int UiInitialize(argc, argv, configpf, configsetpf)
22 int argc;
23 char *argv[];
24 void *(*configpf) (void *table, char *item);
25 void *(*configsetpf) (void *table, char *item, void *value);
26 {
27     uiTopLevelGfx_t *topgfx = &uiTopLevel.TopGfx;
28  
29     uiConfigPF = configpf;
30     uiConfigSetPF = configsetpf;
31  
32     topgfx->TopWdg = XtInitialize(argv[0], "Erwise", NULL, 0, &argc, argv);
33     topgfx->FormWdg = XmCreateForm(topgfx->TopWdg, "Form",
34                                    (ArgList) NULL, 0);
35     XtVaSetValues(topgfx->FormWdg,
36                   XmNwidth, 280,
37                   XmNheight, 70, NULL);
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);
42  
43     XtManageChild(topgfx->FormWdg);
44     XtRealizeWidget(topgfx->TopWdg);
45  
46     XlSetupResources(configpf);
47  
48     uisetupdefaults(argc, argv, configpf);
49  
50     uiBusyCursor = XCreateFontCursor(XtDisplay(topgfx->TopWdg), XC_watch);
51     uiArrowCursor = XCreateFontCursor(XtDisplay(topgfx->TopWdg),
52                                       XC_right_ptr);
53  
54     return UI_OK;
55 }
56  
57  
58 void UiMainLoop()
59 {
60     XtMainLoop();
61 }
62  
63  
64 int PlaceValue(value)
65 char *value;
66 {
67     if (value && !strncasecmp(value, "mouse", strlen("mouse")))
68         return TRUE;
69     return FALSE;
70 }
71  
72  
73 static void uisetupdefaults(argc, argv, configpf)
74 int argc;
75 char *argv[];
76 void *(*configpf) (void *table, char *item);
77 {
78     uiGlobalSettings_t *gs = &uiTopLevel.GlobalSettings;
79     void *table;
80  
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));
91         gs->DoubleClickTime =
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));
96         gs->ListPlacement =
97             PlaceValue((char *) configpf(table, C_LIST));
98         gs->RecallPlacement =
99             PlaceValue((char *) configpf(table, C_RECALL));
100         gs->PageSettingsPlacement =
101             PlaceValue((char *) configpf(table, C_PAGESETTINGS));
102     } else
103         uiDisplayWarning("failed to get configurations for global settings");
104  
105     if (table = configpf((void *) NULL, C_DEFAULTS))
106         uiSelectionArray = (char **) configpf(table, C_DEFAULTSTABLE);
107     else
108         uiDisplayWarning("failed to get configurations for selection");
109  
110     uiPageAttachCallbacks();
111     uiPageDefineKeys();
112 }
113  
114  
115 static Widget
116  uicreatebutton(parentwdg, name, leftpos, rightpos)
117 Widget parentwdg;
118 char *name;
119 int leftpos;
120 int rightpos;
121 {
122     Widget tmpwdg;
123  
124     tmpwdg = XmCreatePushButtonGadget(parentwdg, name,
125                                       (ArgList) NULL, 0);
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,
2 roytam 134                   (XtPointer) name);
1 roytam 135     XtManageChild(tmpwdg);
136  
137     return tmpwdg;
138 }
139  
140  
141 static void uitopactivatecb(wdg, actionname, calldata)
142 Widget wdg;
2 roytam 143 XtPointer actionname;
144 XtPointer calldata;
1 roytam 145 {
146     uiAction_t *tmpaction;
147  
148     if (tmpaction = uiFindAction((char *) actionname))
149         if (uiHelpOnActionCB) {
150             (*uiHelpOnActionCB) (actionname);
151             uiHelpOnActionCB = (void (*) (char *actionstring)) NULL;
152         } else
153             (*tmpaction->Callback) ((char *) NULL, (HText_t *) NULL,
154                                     (HTextObject_t *) NULL,
155                                     tmpaction->Parameter);
156 }