1 /*
2  *  CreateUserInterface - routines to create user interface
3  *
4  *  RCS:
5  *      $Revision$
6  *      $Date$
7  *
8  *  Description:
9  *      text
10  *
11  *  Input Parameters:
12  *      type    identifier  description
13  *
14  *      text
15  *
16  *  Output Parameters:
17  *      type    identifier  description
18  *
19  *      text
20  *
21  *  Return Values:
22  *      value   description
23  *
24  *  Side Effects:
25  *      text
26  *
27  *  Limitations and Comments:
28  *      text
29  *
30  *  Development History:
31  *      who                  when       why
32  *      MA_Muquit@fccc.edu   30-May-96  first cut
33  */
34 
35 #include "xhead.h"
36 #include "mxascii.h"
37 #include "menu.h"
38 
CreateUserInterface(Widget parent)39 void CreateUserInterface(Widget parent)
40 {
41     Widget
42         frameW,
43         main_formW,
44         menubarW,
45 
46         col1_rcW,
47         col2_rcW,
48 
49         col3_rcW,
50         col4_rcW,
51 
52         col5_rcW,
53         col6_rcW,
54 
55         col7_rcW,
56         col8_rcW,
57 
58         col9_rcW,
59         col10_rcW,
60 
61         col11_rcW,
62         col12_rcW,
63 
64         helpW;
65 
66     extern MenuItem
67         file_items[],
68         options_items[],
69         help_items[];
70 
71     Display
72         *display;
73 
74     XmFontList
75         fontlist;
76 
77     XFontStruct
78         *font;
79 
80     display=XtDisplay (parent);
81     font = XLoadQueryFont (display,
82    "-b&h-lucidatypewriter-medium-r-normal-sans-14-140-75-75-m-90-iso8859-1");
83 
84     if (font == (XFontStruct *) NULL)
85     {
86         (void) fprintf (stderr," Failed to load font,using fixed!\n");
87         font=XLoadQueryFont (display,"fixed");
88     }
89     else
90     {
91         fontlist=XmFontListCreate (font,"charset1");
92 
93     }
94 
95     /*
96     ** create the main window W
97     */
98     GmainwW=XtVaCreateManagedWidget("mainww",
99         xmMainWindowWidgetClass,parent,
100         NULL);
101 
102    /*
103    ** create the menubar
104    */
105    menubarW=XmCreateMenuBar(GmainwW,"menuBar",NULL,0);
106    (void) MBuildPulldownMenu(menubarW,"File",'F',file_items);
107    (void) MBuildPulldownMenu(menubarW,"Options",'p',options_items);
108 
109    helpW=MBuildPulldownMenu(menubarW,"Help",'e',help_items);
110    XtVaSetValues(menubarW,
111         XmNmenuHelpWidget, helpW,
112         NULL);
113 
114    XtManageChild(menubarW);
115 
116    /*
117    ** create a frame for ornamentatl reason
118    */
119    frameW=XtVaCreateManagedWidget ("framew",
120        xmFrameWidgetClass,GmainwW,
121        NULL);
122 
123    /*
124    ** create the main formW
125    */
126    main_formW=XtVaCreateWidget("mformw",
127         xmFormWidgetClass,frameW,
128         NULL);
129 
130     /*
131     ** create col1,2 rc widget
132     */
133     col1_rcW=XtVaCreateWidget ("lrcw",
134         xmRowColumnWidgetClass,main_formW,
135         XmNleftAttachment,XmATTACH_FORM,
136         XmNtopAttachment, XmATTACH_FORM,
137         XmNbottomAttachment, XmATTACH_FORM,
138         XmNorientation, XmVERTICAL,
139         NULL);
140 
141     col2_rcW=XtVaCreateWidget ("lrcw",
142         xmRowColumnWidgetClass,main_formW,
143         XmNleftAttachment,XmATTACH_WIDGET,
144         XmNleftWidget,col1_rcW,
145         XmNleftOffset,10,
146         XmNtopAttachment, XmATTACH_FORM,
147         XmNbottomAttachment, XmATTACH_FORM,
148         XmNorientation, XmVERTICAL,
149         NULL);
150 
151     /*
152     ** create the col1,2 labels
153     */
154     Gvalue_labelW[0]=XtVaCreateManagedWidget ("label",
155         xmLabelWidgetClass,col1_rcW,
156         XmNalignment, XmALIGNMENT_BEGINNING,
157         XmNfontList,fontlist,
158         NULL);
159 
160      Gascii_labelW[0]=XtVaCreateManagedWidget ("label2",
161         xmLabelWidgetClass,col2_rcW,
162         XmNalignment, XmALIGNMENT_BEGINNING,
163         XmNfontList,fontlist,
164         NULL);
165 
166     /*
167     ** create 3,4 rc widgets
168     */
169      col3_rcW=XtVaCreateWidget ("rcw",
170         xmRowColumnWidgetClass,main_formW,
171         XmNleftAttachment,XmATTACH_WIDGET,
172         XmNleftWidget,col2_rcW,
173         XmNleftOffset,15,
174         XmNtopAttachment, XmATTACH_FORM,
175         XmNbottomAttachment, XmATTACH_FORM,
176         XmNorientation, XmVERTICAL,
177         NULL);
178 
179      col4_rcW=XtVaCreateWidget ("rcw",
180         xmRowColumnWidgetClass,main_formW,
181         XmNleftAttachment,XmATTACH_WIDGET,
182         XmNleftWidget, col3_rcW,
183         XmNleftOffset,10,
184         XmNtopAttachment, XmATTACH_FORM,
185         XmNbottomAttachment, XmATTACH_FORM,
186         XmNorientation, XmVERTICAL,
187         NULL);
188 
189     /*
190     ** create the 3,4 labels
191     */
192 
193      Gvalue_labelW[1]=XtVaCreateManagedWidget ("label",
194         xmLabelWidgetClass,col3_rcW,
195         XmNalignment, XmALIGNMENT_BEGINNING,
196         XmNfontList,fontlist,
197         NULL);
198      Gascii_labelW[1]=XtVaCreateManagedWidget ("label2",
199         xmLabelWidgetClass,col4_rcW,
200         XmNalignment, XmALIGNMENT_BEGINNING,
201         XmNfontList,fontlist,
202         NULL);
203 
204     /*
205     ** create the 5,6 rc widgets
206     */
207      col5_rcW=XtVaCreateWidget ("rcw",
208         xmRowColumnWidgetClass,main_formW,
209         XmNleftAttachment,XmATTACH_WIDGET,
210         XmNleftWidget,col4_rcW,
211         XmNleftOffset,15,
212         XmNtopAttachment, XmATTACH_FORM,
213         XmNbottomAttachment, XmATTACH_FORM,
214         XmNorientation, XmVERTICAL,
215         NULL);
216 
217      col6_rcW=XtVaCreateWidget ("rcw",
218         xmRowColumnWidgetClass,main_formW,
219         XmNleftAttachment,XmATTACH_WIDGET,
220         XmNleftWidget, col5_rcW,
221         XmNleftOffset,10,
222         XmNtopAttachment, XmATTACH_FORM,
223         XmNbottomAttachment, XmATTACH_FORM,
224         XmNorientation, XmVERTICAL,
225         NULL);
226 
227     /*
228     ** create the 5,6 labels
229     */
230 
231     Gvalue_labelW[2]=XtVaCreateManagedWidget ("label",
232         xmLabelWidgetClass,col5_rcW,
233         XmNalignment, XmALIGNMENT_BEGINNING,
234         XmNfontList,fontlist,
235         NULL);
236      Gascii_labelW[2]=XtVaCreateManagedWidget ("label2",
237         xmLabelWidgetClass,col6_rcW,
238         XmNalignment, XmALIGNMENT_BEGINNING,
239         XmNfontList,fontlist,
240         NULL);
241 
242 
243     /*
244     ** create the col 7,8 rc widgets
245     */
246 
247      col7_rcW=XtVaCreateWidget ("rcw",
248         xmRowColumnWidgetClass,main_formW,
249         XmNleftAttachment,XmATTACH_WIDGET,
250         XmNleftWidget,col6_rcW,
251         XmNleftOffset,15,
252         XmNtopAttachment, XmATTACH_FORM,
253         XmNbottomAttachment, XmATTACH_FORM,
254         XmNorientation, XmVERTICAL,
255         NULL);
256 
257      col8_rcW=XtVaCreateWidget ("rcw",
258         xmRowColumnWidgetClass,main_formW,
259         XmNleftAttachment,XmATTACH_WIDGET,
260         XmNleftWidget, col7_rcW,
261         XmNleftOffset,10,
262         XmNtopAttachment, XmATTACH_FORM,
263         XmNorientation, XmVERTICAL,
264         NULL);
265 
266     /*
267     ** create col 7,8 labels
268     */
269     Gvalue_labelW[3]=XtVaCreateManagedWidget ("label",
270         xmLabelWidgetClass,col7_rcW,
271         XmNalignment, XmALIGNMENT_BEGINNING,
272         XmNfontList,fontlist,
273         NULL);
274      Gascii_labelW[3]=XtVaCreateManagedWidget ("label2",
275         xmLabelWidgetClass,col8_rcW,
276         XmNalignment, XmALIGNMENT_BEGINNING,
277         XmNfontList,fontlist,
278         NULL);
279 
280     /*
281     ** create the col 9,10 rc widgets
282     */
283 
284      col9_rcW=XtVaCreateWidget ("rcw",
285         xmRowColumnWidgetClass,main_formW,
286         XmNleftAttachment,XmATTACH_WIDGET,
287         XmNleftWidget,col8_rcW,
288         XmNleftOffset,15,
289         XmNtopAttachment, XmATTACH_FORM,
290         XmNbottomAttachment, XmATTACH_FORM,
291         XmNorientation, XmVERTICAL,
292         NULL);
293 
294      col10_rcW=XtVaCreateWidget ("rcw",
295         xmRowColumnWidgetClass,main_formW,
296         XmNleftAttachment,XmATTACH_WIDGET,
297         XmNleftWidget, col9_rcW,
298         XmNleftOffset,10,
299         XmNtopAttachment, XmATTACH_FORM,
300         XmNbottomAttachment, XmATTACH_FORM,
301         XmNorientation, XmVERTICAL,
302         NULL);
303 
304     /*
305     ** create col 9,10 labels
306     */
307     Gvalue_labelW[4]=XtVaCreateManagedWidget ("label",
308         xmLabelWidgetClass,col9_rcW,
309         XmNalignment, XmALIGNMENT_BEGINNING,
310         XmNfontList,fontlist,
311         NULL);
312      Gascii_labelW[4]=XtVaCreateManagedWidget ("label2",
313         xmLabelWidgetClass,col10_rcW,
314         XmNalignment, XmALIGNMENT_BEGINNING,
315         XmNfontList,fontlist,
316         NULL);
317 
318     /*
319     ** create the col 11,12 rc widgets
320     */
321 
322      col11_rcW=XtVaCreateWidget ("rcw",
323         xmRowColumnWidgetClass,main_formW,
324         XmNleftAttachment,XmATTACH_WIDGET,
325         XmNleftWidget,col10_rcW,
326         XmNleftOffset,15,
327         XmNtopAttachment, XmATTACH_FORM,
328         XmNbottomAttachment, XmATTACH_FORM,
329         XmNorientation, XmVERTICAL,
330         NULL);
331 
332      col12_rcW=XtVaCreateWidget ("rcw",
333         xmRowColumnWidgetClass,main_formW,
334         XmNleftAttachment,XmATTACH_WIDGET,
335         XmNleftWidget, col11_rcW,
336         XmNleftOffset,10,
337         XmNtopAttachment, XmATTACH_FORM,
338         XmNrightAttachment, XmATTACH_FORM,
339         XmNbottomAttachment, XmATTACH_FORM,
340         XmNorientation, XmVERTICAL,
341         NULL);
342 
343     /*
344     ** create col 11,12 labels
345     */
346     Gvalue_labelW[5]=XtVaCreateManagedWidget ("label",
347         xmLabelWidgetClass,col11_rcW,
348         XmNalignment, XmALIGNMENT_BEGINNING,
349         XmNfontList,fontlist,
350         NULL);
351      Gascii_labelW[5]=XtVaCreateManagedWidget ("label2",
352         xmLabelWidgetClass,col12_rcW,
353         XmNalignment, XmALIGNMENT_BEGINNING,
354         XmNfontList,fontlist,
355         NULL);
356 
357     /*
358     ** manage the widget not managed yet
359     */
360     XtManageChild (col12_rcW);
361     XtManageChild (col11_rcW);
362 
363     XtManageChild (col10_rcW);
364     XtManageChild (col9_rcW);
365 
366     XtManageChild (col8_rcW);
367     XtManageChild (col7_rcW);
368 
369     XtManageChild (col6_rcW);
370     XtManageChild (col5_rcW);
371 
372     XtManageChild (col4_rcW);
373     XtManageChild (col3_rcW);
374 
375     XtManageChild (col2_rcW);
376     XtManageChild (col1_rcW);
377 
378     XtManageChild (main_formW);
379 }
380 
381 /*
382 ** quit callback routine
383 */
384 
QuitCb(Widget w,XtPointer cli_data,XtPointer call_data)385 void QuitCb (Widget w, XtPointer cli_data,XtPointer call_data)
386 {
387     exit (0);
388 }
389 
390 /*
391 ** create the about dialog
392 */
393 
394 #include "converter.h"
395 
396 static Widget
397     aboutdW;
398 
CreateAboutD(Widget parent)399 void CreateAboutD(Widget parent)
400 {
401     Arg
402         args[10];
403 
404     int
405         n;
406 
407     XmString
408         xmstr;
409 
410     /****
411 
412     Pixmap
413         apix=(Pixmap) NULL;
414 
415     Pixel
416         fg,
417         bg;
418 
419     *******/
420 
421     XtAppContext app=XtWidgetToApplicationContext(GtoplevelW);
422     XitAddXmStringConverter(app);
423 
424     xmstr=XmStringCreateSimple("About mxascii");
425     n=0;
426     XtSetArg (args[n], XmNautoUnmanage, True); n++;
427     XtSetArg (args[n], XmNdialogStyle, XmDIALOG_MODELESS); n++;
428     XtSetArg (args[n], XmNdialogTitle, xmstr);      n++;
429 
430     aboutdW=XmCreateInformationDialog(parent,"aboutd",
431         args,n);
432 
433     XmStringFree(xmstr);
434 
435     XtUnmanageChild(XmMessageBoxGetChild(aboutdW,XmDIALOG_HELP_BUTTON));
436     XtUnmanageChild(XmMessageBoxGetChild(aboutdW,XmDIALOG_CANCEL_BUTTON));
437 
438 #ifdef DO_ICON
439     XtVaGetValues(aboutdW,
440         XmNforeground,&fg,
441         XmNbackground,&bg,
442         NULL);
443 
444     apix=XCreatePixmapFromBitmapData(Gdisplay,
445         Grootwindow,
446         mxkicon_bits,
447         mxkicon_width,
448         mxkicon_height,
449         bg,
450         fg,
451         Gdepth);
452 
453 
454     if (apix != (Pixmap) NULL)
455         XtVaSetValues(aboutdW,
456             XmNsymbolPixmap,apix,
457             NULL);
458 #endif
459 
460 }
461 
AboutdCb(widget,client_data,call_data)462 void AboutdCb(widget,client_data,call_data)
463 Widget
464     widget;
465 XtPointer
466     client_data,
467     call_data;
468 {
469         if (!XtIsManaged(aboutdW))
470             XtManageChild(aboutdW);
471 }
472 
473