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, status, planets, misc;
15 static String fallback[] = {
16 /* text window resources */
17 "*text.resizable: true",
18 "*text.resize: ResizeBoth",
24 void (*callback)(Widget, XtPointer, XtPointer);
31 static void quit_proc(Widget w, XtPointer client_data, XtPointer call_data)
33 XtDestroyApplicationContext (app_context);
37 static void noargs_proc(Widget w, XtPointer client_data, XtPointer call_data)
38 /* use this for commands that take no arguments */
40 /* currently a stub */
43 static struct cmd_t commands[] = {
44 {"Move", NULL, &navigation, 0},
45 {"Dock", noargs_proc, &navigation, 0},
46 {"Chart", noargs_proc, &navigation, 0},
47 {"Impulse", NULL, &navigation, 0},
48 {"Rest", NULL, &navigation, 0},
49 {"Warp", NULL, &navigation, 0},
50 {"Probe", NULL, &navigation, OPTION_PROBE},
52 {"Phasers", NULL, &weapons, 0},
53 {"Torpedo", NULL, &weapons, 0},
54 {"Shields", NULL, &weapons, 0},
55 {"Damages", noargs_proc, &weapons, 0},
56 {"Abandon", noargs_proc, &weapons, 0},
57 {"Destruct", noargs_proc, &weapons, 0},
58 {"Deathray", noargs_proc, &weapons, 0},
59 {"Mayday", noargs_proc, &weapons, 0},
61 {"Score", noargs_proc, &status, 0},
62 {"Report", noargs_proc, &status, 0},
63 {"Computer", noargs_proc, &status, 0},
65 {"Sensors", noargs_proc, &planets, OPTION_PLANETS},
66 {"Orbit", noargs_proc, &planets, OPTION_PLANETS},
67 {"Transport", noargs_proc, &planets, OPTION_PLANETS},
68 {"Mine", noargs_proc, &planets, OPTION_PLANETS},
69 {"Crystals", noargs_proc, &planets, OPTION_PLANETS},
70 {"Shuttle", noargs_proc, &planets, OPTION_PLANETS},
71 {"Planets", noargs_proc, &planets, OPTION_PLANETS},
73 {"Emexit", noargs_proc, &misc, 0},
74 {"Save", NULL, &misc, 0},
75 {"Quit", quit_proc, &misc, 0},
76 {"Help", noargs_proc, &misc, 0},
79 int main(int argc, char **argv)
83 toplevel = XtVaOpenApplication(&app_context, "sst2k", NULL, 0, &argc,
85 applicationShellWidgetClass,
86 XtNallowShellResize, True, NULL);
87 form = XtVaCreateManagedWidget("form", formWidgetClass, toplevel, NULL);
88 /* the command window */
89 text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, form,
90 XtNwidth, 400, XtNheight, 200,
92 XtVaSetValues(text, XtNeditType,XawtextRead, XtNdisplayCaret,False, NULL);
93 /* The button panels */
94 navigation = XtVaCreateManagedWidget("navigation",
97 XtNorientation, XtorientHorizontal,
99 weapons = XtVaCreateManagedWidget("weapons",
100 boxWidgetClass, form,
101 XtNfromVert, navigation,
102 XtNorientation, XtorientHorizontal,
104 status = XtVaCreateManagedWidget("status",
105 boxWidgetClass, form,
106 XtNfromVert, weapons,
107 XtNorientation, XtorientHorizontal,
109 planets = XtVaCreateManagedWidget("planets",
110 boxWidgetClass, form,
112 XtNorientation, XtorientHorizontal,
114 misc = XtVaCreateManagedWidget("misc",
115 boxWidgetClass, form,
116 XtNfromVert, planets,
117 XtNorientation, XtorientHorizontal,
119 for (cp = commands; cp < commands + sizeof(commands)/sizeof(commands[0]); cp++) {
120 cp->widget = XtVaCreateManagedWidget(cp->name,
126 XtAddCallback (cp->widget, XtNcallback, cp->callback, NULL);
128 XtRealizeWidget(toplevel);
129 XtAppMainLoop(app_context);
130 /* loop may be interrupted */
131 XtDestroyApplicationContext(app_context);