Begin moving resource declarations into the fallback.
[super-star-trek.git] / src / xio.c
1 #include <stdlib.h>
2 #include <X11/Intrinsic.h>
3 #include <X11/StringDefs.h>
4 #include <X11/Shell.h>
5 #include <X11/Xaw/Form.h>
6 #include <X11/Xaw/Command.h>
7 #include <X11/Xaw/AsciiText.h>
8
9 XtAppContext app_context;
10 Widget toplevel, form, buttons, quit, destruct, text;
11
12 String fallback[] = {
13     "*destruct.fromHoriz: quit",
14     NULL,
15 };
16
17 static void quit_proc (Widget w, XtPointer client_data, XtPointer call_data)
18
19     XtDestroyApplicationContext (app_context);
20     exit (0);
21 }
22
23 int main (int argc, char **argv)
24
25     toplevel = XtVaOpenApplication (&app_context, "XThird", NULL, 0, &argc,
26                                     argv, fallback, 
27                                     applicationShellWidgetClass,
28                                     XtNallowShellResize, True, NULL);
29     form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL);
30     /* The button panel */
31     buttons  = XtVaCreateManagedWidget ("form", formWidgetClass, form, NULL); 
32     quit     = XtVaCreateManagedWidget("quit", 
33                                        commandWidgetClass, buttons, 
34                                        XtNlabel, "Quit", NULL);
35     XtAddCallback (quit, XtNcallback, quit_proc, NULL);
36     destruct = XtVaCreateManagedWidget("destruct", 
37                                        commandWidgetClass, buttons, 
38                                        XtNlabel, "Destruct", NULL);
39     /* the command window */
40     text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, 
41                                     XtNfromVert, buttons, 
42                                     XtNresize, XawtextResizeBoth, 
43                                     XtNresizable, True, NULL);
44
45     /* sample text so the widget will be identifiable */
46     XtVaSetValues (text, XtNtype, XawAsciiString, 
47                        XtNstring, "Command window", NULL); 
48     XtVaSetValues (text, XtNeditType, XawtextRead, XtNdisplayCaret, False, NULL);
49     XtRealizeWidget (toplevel);
50     XtAppMainLoop (app_context);
51     /* loop may be interrupted */
52     XtDestroyApplicationContext (app_context);
53     exit(0);
54 }