1 /*********************************************************************/
2 /* bibView: Administration of BibTeX-Databases */
3 /* (Verwaltung von BibTeX-Literaturdatenbanken) */
4 /* */
5 /* Module: gui_main.c */
6 /* */
7 /* - Realize main application window */
8 /* - */
9 /* */
10 /* Author: Holger Martin, martinh@informatik.tu-muenchen.de */
11 /* Peter M. Urban, urban@informatik.tu-muenchen.de */
12 /* */
13 /* History: */
14 /* 11.22.91 PMU created */
15 /* 05.26.92 Version 1.0 released */
16 /* */
17 /* Copyright 1992 TU MUENCHEN */
18 /* See ./Copyright for complete rights and liability information. */
19 /* */
20 /*********************************************************************/
21
22 #include <stdio.h>
23 #include <X11/Intrinsic.h>
24 #include <X11/StringDefs.h>
25 #include <X11/Xaw/Paned.h>
26 #include <X11/Xaw/Form.h>
27 #include <X11/Xaw/Box.h>
28 #include <X11/Xaw/Command.h>
29 #include <X11/Xaw/MenuButton.h>
30 #include <X11/Xaw/SimpleMenu.h>
31 #include <X11/Xaw/SmeBSB.h>
32 #include <X11/Xaw/SmeLine.h>
33 /* #include <X11/bitmaps/xlogo16>
34 #include <X11/bitmaps/gray> */
35 #include "bibview.h"
36
37
38 /* imported global variables */
39 /* ------------------------- */
40 extern Widget topLevel;
41 extern Pixmap chkmarkPixmap;
42 extern Pixmap bvIconPixmap;
43
44
45 /* macros and definitions */
46 /* ---------------------- */
47
48 /* structure hold a menu entry */
49 typedef struct {
50 String name;
51 XtCallbackProc cb;
52 Boolean *bool;
53 } menuEntry;
54
55
56 /* local function prototypes */
57 /* ------------------------- */
58 static void OptionsSelect(Widget w, XtPointer client_data, XtPointer garbage);
59 static void createMenu(String name, menuEntry item[], Widget *menu, Widget parent, Boolean isBool);
60
61 /* exported variables */
62 /* ------------------ */
63 Widget mainMenu, desktop;
64
65
66 /* local global variables */
67 /* ---------------------- */
68
69 /* Widgets for main window */
70 static Widget mwWin,
71 mwCommandBox,
72 mwFile, mwFileMenu,
73 mwServices, mwServicesMenu,
74 mwOptions, mwOptionsMenu,
75 mwWindow, mwWindowMenu,
76 mwHelp, mwHelpMenu,
77 mwDesktop;
78
79
80 static menuEntry fileEntry[] = {
81 { "line1", NULL, NULL },
82 { "item1", copNewCmd, NULL },
83 { "item2", copOpenCmd, NULL },
84 { "item3", csaCloseBibCmd, NULL },
85 { "item4", csaSaveBibCmd, NULL },
86 { "item5", csaSaveAsBibCmd, NULL },
87 { "line2", NULL, NULL },
88 { "item6", csaQuitBibviewCmd, NULL },
89 { NULL, NULL, NULL }
90 };
91
92 static menuEntry servicesEntry[] = {
93 { "line1", NULL, NULL },
94 { "item1", cseCheckBibCmd, NULL },
95 { "item2", cseCollateBibCmd, NULL },
96 { "item3", cprPrintBibCmd, NULL },
97 { "item4", cseEditMacrosCmd, NULL },
98 { "item5", cseLoadConfigCmd, NULL },
99 { NULL, NULL, NULL }
100 };
101
102 static menuEntry optionsEntry[] = {
103 { "line1", NULL, NULL },
104 { "item1", cotOptionsControl,
105 &optionsStatus[OPT_BEEP_ON_ERROR] },
106 { "item2", cotOptionsControl,
107 &optionsStatus[OPT_BACKUP_ON_SAVE] },
108 { "item3", cotOptionIconOnDeskCmd,
109 &optionsStatus[OPT_ICON_ON_DESKTOP] },
110 { "item4", cotOptionsControl,
111 &optionsStatus[OPT_AUTO_CHECK_BIB] },
112 { "item5", cotOptionsControl,
113 &optionsStatus[OPT_REQUIRED_FIELDS] },
114 { "item6", cotOptionsControl,
115 &optionsStatus[OPT_IGNORE_CASE] },
116 { "item7", cotOptionsControl,
117 &optionsStatus[OPT_PRINT_AS_BIB] },
118 { "item8", cotOptionsControl,
119 &optionsStatus[OPT_DISPLAY_ERRWIN] },
120 { NULL, NULL, NULL }
121 };
122
123 static menuEntry windowEntry[] = {
124 { "line1", NULL, NULL },
125 { "item1", gubCascadeCmd, NULL },
126 { NULL, NULL, NULL }
127 };
128
129 static menuEntry helpEntry[] = {
130 { "line1", NULL, NULL },
131 { "item1", hlpOpenHelpWinCmd, NULL },
132 { "item2", hlpOpenHelpWinCmd, NULL },
133 { "item3", hlpOpenHelpWinCmd, NULL },
134 { "item4", hlpOpenHelpWinCmd, NULL },
135 { "item5", hlpOpenHelpWinCmd, NULL },
136 { "item6", hlpOpenHelpWinCmd, NULL },
137 { "line2", NULL, NULL },
138 { "info", guwProgInfo, NULL },
139 { NULL, NULL, NULL }
140 };
141
142
143
144 /*********************************************************************/
145 /* gwmMainWin: */
146 /* Realize main application window */
147 /*********************************************************************/
148 int
gwmMainWin(void)149 gwmMainWin (void)
150 {
151 mwWin = XtVaCreateManagedWidget("mainwin",
152 panedWidgetClass, topLevel, NULL);
153
154 /* create command buttons */
155 mainMenu =
156 mwCommandBox = XtVaCreateManagedWidget("commandBox",
157 boxWidgetClass, mwWin, NULL);
158 mwFile = XtVaCreateManagedWidget("file",
159 menuButtonWidgetClass, mwCommandBox, NULL);
160 mwServices = XtVaCreateManagedWidget("services",
161 menuButtonWidgetClass, mwCommandBox, NULL);
162 mwOptions = XtVaCreateManagedWidget("options",
163 menuButtonWidgetClass, mwCommandBox, NULL);
164 mwWindow = XtVaCreateManagedWidget("window",
165 menuButtonWidgetClass, mwCommandBox, NULL);
166 mwHelp = XtVaCreateManagedWidget("help",
167 menuButtonWidgetClass, mwCommandBox, NULL);
168
169 /* make pulldownmenus for command boxes */
170 createMenu("fileMenu", fileEntry, &mwFileMenu, mwFile, FALSE);
171 createMenu("servicesMenu", servicesEntry, &mwServicesMenu, mwServices, FALSE);
172 createMenu("optionsMenu", optionsEntry, &mwOptionsMenu, mwOptions, TRUE);
173 createMenu("windowMenu", windowEntry, &mwWindowMenu, mwWindow, FALSE);
174 createMenu("helpMenu", helpEntry, &mwHelpMenu, mwHelp, FALSE);
175
176 desktop =
177 mwDesktop = XtVaCreateManagedWidget("desktop",
178 formWidgetClass, mwWin,
179 XtNresizable, TRUE, NULL);
180 return(OK);
181 }
182
183
184
185 /*********************************************************************/
186 /* createMenu: */
187 /* Build a main application window pulldown menu */
188 /*********************************************************************/
189 static void
createMenu(String menuName,menuEntry item[],Widget * menu,Widget parent,Boolean isBool)190 createMenu (String menuName, menuEntry item[], Widget *menu, Widget parent, Boolean isBool)
191 {
192 static Widget w;
193 int i = 0;
194 String iname;
195
196 *menu = XtVaCreatePopupShell(menuName,
197 simpleMenuWidgetClass,
198 parent, NULL);
199 i = 0;
200 while ((iname = item[i].name) != NULL) {
201 if (strncmp("line", iname, 4) == 0) /* use a line pane */
202 w = XtVaCreateManagedWidget(iname,
203 smeLineObjectClass, *menu, NULL);
204 else {
205 w = XtVaCreateManagedWidget(iname,
206 smeBSBObjectClass, *menu, NULL);
207 if (isBool) {
208 if (*item[i].bool)
209 XtVaSetValues(w, XtNleftBitmap, chkmarkPixmap, NULL);
210 }
211 XtAddCallback(w, XtNcallback, item[i].cb, (XtPointer) i);
212 }
213 i++;
214 } /* endwhile */
215 }
216
217
218
219
220