More resources into 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, text; 
11 Widget buttons, phasers, photons, destruct, quit;
12
13 String fallback[] = {
14     /* button labels */
15     "*phasers.label: Phasers",
16     "*photons.label: Torps",
17     "*destruct.label: Destruct",
18     "*quit.label: Quit",
19     /* text window resources */
20     "*text.resizable: true",
21     "*text.resize: ResizeBoth",
22     /* layout constraints */
23     "*photons.fromHoriz: phasers",
24     "*destruct.fromHoriz: photons",
25     "*quit.fromHoriz: destruct",
26     NULL,
27 };
28
29 static void quit_proc (Widget w, XtPointer client_data, XtPointer call_data)
30
31     XtDestroyApplicationContext (app_context);
32     exit (0);
33 }
34
35 int main (int argc, char **argv)
36
37     toplevel = XtVaOpenApplication (&app_context, "sst2k", NULL, 0, &argc,
38                                     argv, fallback, 
39                                     applicationShellWidgetClass,
40                                     XtNallowShellResize, True, NULL);
41     form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL);
42     /* The button panel */
43     buttons  = XtVaCreateManagedWidget ("form", formWidgetClass, form, NULL); 
44     phasers  = XtVaCreateManagedWidget("phasers", 
45                                        commandWidgetClass, buttons, 
46                                        NULL);
47     photons  = XtVaCreateManagedWidget("photons", 
48                                        commandWidgetClass, buttons, 
49                                        NULL);
50     destruct = XtVaCreateManagedWidget("destruct", 
51                                        commandWidgetClass, buttons, 
52                                        NULL);
53     quit     = XtVaCreateManagedWidget("quit", 
54                                        commandWidgetClass, buttons, 
55                                        NULL);
56     XtAddCallback (quit, XtNcallback, quit_proc, NULL);
57     /* the command window */
58     text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, 
59                                     XtNfromVert, buttons, 
60                                     NULL);
61
62     /* sample text so the widget will be identifiable */
63     XtVaSetValues (text, XtNtype, XawAsciiString, 
64                        XtNstring, "Command window", NULL); 
65     XtVaSetValues (text, XtNeditType, XawtextRead, XtNdisplayCaret, False, NULL);
66     XtRealizeWidget (toplevel);
67     XtAppMainLoop (app_context);
68     /* loop may be interrupted */
69     XtDestroyApplicationContext (app_context);
70     exit(0);
71 }