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