2 #include <X11/Intrinsic.h>
3 #include <X11/StringDefs.h>
5 #include <X11/Xaw/Form.h>
6 #include <X11/Xaw/Command.h>
7 #include <X11/Xaw/AsciiText.h>
10 static XtAppContext app_context;
11 static Widget toplevel, form, text, buttons;
14 /* text window resources */
15 "*text.resizable: true",
16 "*text.resize: ResizeBoth",
17 /* layout constraints */
20 "*Impulse.fromHoriz: Move",
21 "*Rest.fromHoriz: Impulse",
22 "*Warp.fromHoriz: Rest",
23 "*Dock.fromHoriz: Warp",
24 "*Chart.fromHoriz: Dock",
26 "*Phasers.fromVert: Move",
27 "*Torpedo.fromHoriz: Phasers",
28 "*Shields.fromHoriz: Torpedo",
29 "*Damages.fromHoriz: Shields",
30 "*Crystals.fromHoriz: Damages",
31 "*Deathray.fromHoriz: Crystals",
32 "*Mayday.fromHoriz: Deathray",
33 "*Abandon.fromHoriz: Mayday",
35 "*Sensors.fromVert: Phasers",
36 "*Orbit.fromHoriz: Sensors",
37 "*Transport.fromHoriz: Orbit",
38 "*Mine.fromHoriz: Transport",
39 "*Shuttle.fromHoriz: Transport",
40 "*Planets.fromHoriz: Shuttle",
42 "*Report.fromVert: Sensors",
43 "*Computer.fromHoriz: Report",
44 "*Probe.fromHoriz: Computer",
45 "*Help.fromHoriz: Computer",
47 "*Score.fromVert: Report",
48 "*Destruct.fromHoriz: Score",
49 "*Quit.fromHoriz: Destruct",
50 "*Emexit.fromHoriz: Quit",
51 "*Save.fromHoriz: Emexit",
57 void (*callback)(Widget, XtPointer, XtPointer);
62 static void quit_proc(Widget w, XtPointer client_data, XtPointer call_data)
64 XtDestroyApplicationContext (app_context);
68 static struct cmd_t commands[] = {
80 {"Sensors", NULL, OPTION_PLANETS},
81 {"Orbit", NULL, OPTION_PLANETS},
82 {"Transport", NULL, OPTION_PLANETS},
83 {"Mine", NULL, OPTION_PLANETS},
84 {"Crystals", NULL, OPTION_PLANETS},
85 {"Shuttle", NULL, OPTION_PLANETS},
86 {"Planets", NULL, OPTION_PLANETS},
88 {"Computer", NULL, 0},
90 {"Probe", NULL, OPTION_PROBE},
93 {"Destruct", NULL, 0},
94 {"Deathray", NULL, 0},
96 {"Quit", quit_proc, 0},
100 int main(int argc, char **argv)
104 toplevel = XtVaOpenApplication(&app_context, "sst2k", NULL, 0, &argc,
106 applicationShellWidgetClass,
107 XtNallowShellResize, True, NULL);
108 form = XtVaCreateManagedWidget("form", formWidgetClass, toplevel, NULL);
109 /* the command window */
110 text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, form,
112 XtVaSetValues(text, XtNeditType,XawtextRead, XtNdisplayCaret,False, NULL);
113 /* The button panel */
114 buttons = XtVaCreateManagedWidget("form",
115 formWidgetClass, form,
118 for (cp = commands; cp < commands + sizeof(commands)/sizeof(commands[0]); cp++) {
119 cp->widget = XtVaCreateManagedWidget(cp->name,
120 commandWidgetClass, buttons,
124 XtAddCallback (cp->widget, XtNcallback, cp->callback, NULL);
126 XtRealizeWidget(toplevel);
127 XtAppMainLoop(app_context);
128 /* loop may be interrupted */
129 XtDestroyApplicationContext(app_context);