2 #include <X11/Intrinsic.h>
3 #include <X11/StringDefs.h>
5 #include <X11/Xaw/Box.h>
6 #include <X11/Xaw/Form.h>
7 #include <X11/Xaw/Command.h>
8 #include <X11/Xaw/AsciiText.h>
11 static XtAppContext app_context;
12 static Widget toplevel, text, form;
13 static Widget navigation, weapons, planets, misc;
14 static Widget navlabel, weaplabel, planlabel, misclabel;
16 static String fallback[] = {
17 /* text window resources */
18 "*text.resizable: true",
19 "*text.resize: ResizeBoth",
25 void (*callback)(Widget, XtPointer, XtPointer);
32 static void quit_proc(Widget w, XtPointer client_data, XtPointer call_data)
34 XtDestroyApplicationContext (app_context);
38 static void noargs_proc(Widget w, XtPointer client_data, XtPointer call_data)
39 /* use this for commands that take no arguments */
41 /* currently a stub */
42 printf("Button %s pressed\n", XtName(w));
45 static struct cmd_t commands[] = {
46 {"Move", NULL, &navigation, 0},
47 {"Dock", noargs_proc, &navigation, 0},
48 {"Chart", noargs_proc, &navigation, 0},
49 {"Impulse", NULL, &navigation, 0},
50 {"Rest", NULL, &navigation, 0},
51 {"Warp", NULL, &navigation, 0},
52 {"Probe", NULL, &navigation, OPTION_PROBE},
54 {"Phasers", NULL, &weapons, 0},
55 {"Torpedo", NULL, &weapons, 0},
56 {"Shields", NULL, &weapons, 0},
57 {"Damages", noargs_proc, &weapons, 0},
58 {"Abandon", noargs_proc, &weapons, 0},
59 {"Destruct", noargs_proc, &weapons, 0},
60 {"Deathray", noargs_proc, &weapons, 0},
61 {"Mayday", noargs_proc, &weapons, 0},
63 {"Sensors", noargs_proc, &planets, OPTION_PLANETS},
64 {"Orbit", noargs_proc, &planets, OPTION_PLANETS},
65 {"Transport", noargs_proc, &planets, OPTION_PLANETS},
66 {"Mine", noargs_proc, &planets, OPTION_PLANETS},
67 {"Crystals", noargs_proc, &planets, OPTION_PLANETS},
68 {"Shuttle", noargs_proc, &planets, OPTION_PLANETS},
69 {"Planets", noargs_proc, &planets, OPTION_PLANETS},
71 {"Score", noargs_proc, &misc, 0},
72 {"Report", noargs_proc, &misc, 0},
73 {"Computer", noargs_proc, &misc, 0},
74 {"Save", NULL, &misc, 0},
75 {"Quit", quit_proc, &misc, 0},
76 {"Help", noargs_proc, &misc, 0},
80 #define TEXTHEIGHT 200
82 static void instantiate_main(int argc, char **argv)
86 toplevel = XtVaOpenApplication(&app_context, "sst2k", NULL, 0, &argc,
88 applicationShellWidgetClass,
89 XtNallowShellResize, True, NULL);
90 form = XtVaCreateManagedWidget("form", formWidgetClass, toplevel, NULL);
91 /* the command window */
92 text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, form,
93 XtNwidth, MAXWIDTH, XtNheight, TEXTHEIGHT,
95 XtVaSetValues(text, XtNeditType,XawtextRead, XtNdisplayCaret,False, NULL);
96 /* The button panels */
97 navigation = XtVaCreateManagedWidget("navigation",
101 XtNorientation, XtorientHorizontal,
103 navlabel = XtVaCreateManagedWidget("Navigation: ",
104 labelWidgetClass, navigation,
107 weapons = XtVaCreateManagedWidget("weapons",
108 boxWidgetClass, form,
110 XtNfromVert, navigation,
111 XtNorientation, XtorientHorizontal,
113 weaplabel = XtVaCreateManagedWidget("Weapons: ",
114 labelWidgetClass, weapons,
117 planets = XtVaCreateManagedWidget("planets",
118 boxWidgetClass, form,
120 XtNfromVert, weapons,
121 XtNorientation, XtorientHorizontal,
123 planlabel = XtVaCreateManagedWidget("Planets: ",
124 labelWidgetClass, planets,
127 misc = XtVaCreateManagedWidget("misc",
128 boxWidgetClass, form,
130 XtNfromVert, planets,
131 XtNorientation, XtorientHorizontal,
133 misclabel = XtVaCreateManagedWidget("Miscellaneous:",
134 labelWidgetClass, misc,
137 for (cp = commands; cp < commands + sizeof(commands)/sizeof(commands[0]); cp++) {
138 cp->widget = XtVaCreateManagedWidget(cp->name,
144 XtAddCallback (cp->widget, XtNcallback, cp->callback, NULL);
146 XtRealizeWidget(toplevel);
147 XtAppMainLoop(app_context);
148 /* loop may be interrupted */
149 XtDestroyApplicationContext(app_context);
152 int main(int argc, char **argv)
154 instantiate_main(argc, argv);