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.resizable: true",
18 "*text.resize: ResizeBoth",
21 "*navigation.fromVert: text",
22 "*navigation.borderWidth: 0",
23 "*navlabel.label: Navigation: ",
24 "*navlabel.borderWidth: 0",
25 "*weapons.fromVert: navigation",
26 "*weapons.borderWidth: 0",
27 "*weaplabel.label: Weapons: ",
28 "*weaplabel.borderWidth: 0",
29 "*planets.fromVert: weapons",
30 "*planets.borderWidth: 0",
31 "*planlabel.label: Planets: ",
32 "*planlabel.borderWidth: 0",
33 "*misc.fromVert: planets",
34 "*misc.borderWidth: 0",
35 "*misclabel.label: Miscellaneous:",
36 "*misclabel.borderWidth: 0",
42 void (*callback)(Widget, XtPointer, XtPointer);
49 static void quit_proc(Widget w, XtPointer client_data, XtPointer call_data)
51 XtDestroyApplicationContext (app_context);
55 static void noargs_proc(Widget w, XtPointer client_data, XtPointer call_data)
56 /* use this for commands that take no arguments */
58 /* currently a stub */
59 printf("Button %s pressed\n", XtName(w));
62 static struct cmd_t commands[] = {
63 {"Move", NULL, &navigation, 0},
64 {"Dock", noargs_proc, &navigation, 0},
65 {"Chart", noargs_proc, &navigation, 0},
66 {"Impulse", NULL, &navigation, 0},
67 {"Rest", NULL, &navigation, 0},
68 {"Warp", NULL, &navigation, 0},
69 {"Probe", NULL, &navigation, OPTION_PROBE},
71 {"Phasers", NULL, &weapons, 0},
72 {"Torpedo", NULL, &weapons, 0},
73 {"Shields", NULL, &weapons, 0},
74 {"Damages", noargs_proc, &weapons, 0},
75 {"Abandon", noargs_proc, &weapons, 0},
76 {"Destruct", noargs_proc, &weapons, 0},
77 {"Deathray", noargs_proc, &weapons, 0},
78 {"Mayday", noargs_proc, &weapons, 0},
80 {"Sensors", noargs_proc, &planets, OPTION_PLANETS},
81 {"Orbit", noargs_proc, &planets, OPTION_PLANETS},
82 {"Transport", noargs_proc, &planets, OPTION_PLANETS},
83 {"Mine", noargs_proc, &planets, OPTION_PLANETS},
84 {"Crystals", noargs_proc, &planets, OPTION_PLANETS},
85 {"Shuttle", noargs_proc, &planets, OPTION_PLANETS},
86 {"Planets", noargs_proc, &planets, OPTION_PLANETS},
88 {"Score", noargs_proc, &misc, 0},
89 {"Report", noargs_proc, &misc, 0},
90 {"Computer", noargs_proc, &misc, 0},
91 {"Save", NULL, &misc, 0},
92 {"Quit", quit_proc, &misc, 0},
93 {"Help", noargs_proc, &misc, 0},
96 static void instantiate_main(int argc, char **argv)
100 toplevel = XtVaOpenApplication(&app_context, "sst2k", NULL, 0, &argc,
102 applicationShellWidgetClass,
103 XtNallowShellResize, True, NULL);
104 form = XtVaCreateManagedWidget("form", formWidgetClass, toplevel, NULL);
105 /* the command window */
106 text = XtVaCreateManagedWidget("text",
107 asciiTextWidgetClass, form,
108 XtNeditType, XawtextEdit,
109 XtNdisplayCaret,False,
111 /* The button panels */
112 navigation = XtVaCreateManagedWidget("navigation",
113 boxWidgetClass, form,
114 XtNorientation, XtorientHorizontal,
116 navlabel = XtVaCreateManagedWidget("navlabel",
117 labelWidgetClass, navigation,
119 weapons = XtVaCreateManagedWidget("weapons",
120 boxWidgetClass, form,
121 XtNorientation, XtorientHorizontal,
123 weaplabel = XtVaCreateManagedWidget("weaplabel",
124 labelWidgetClass, weapons,
126 planets = XtVaCreateManagedWidget("planets",
127 boxWidgetClass, form,
128 XtNorientation, XtorientHorizontal,
130 planlabel = XtVaCreateManagedWidget("planlabel",
131 labelWidgetClass, planets,
134 misc = XtVaCreateManagedWidget("misc",
135 boxWidgetClass, form,
136 XtNorientation, XtorientHorizontal,
138 misclabel = XtVaCreateManagedWidget("misclabel",
139 labelWidgetClass, misc,
141 for (cp = commands; cp < commands + sizeof(commands)/sizeof(commands[0]); cp++) {
142 cp->widget = XtVaCreateManagedWidget(cp->name,
148 XtAddCallback (cp->widget, XtNcallback, cp->callback, NULL);
150 XtRealizeWidget(toplevel);
151 XtAppMainLoop(app_context);
152 /* loop may be interrupted */
153 XtDestroyApplicationContext(app_context);
156 int main(int argc, char **argv)
158 instantiate_main(argc, argv);