X-Git-Url: https://jxself.org/git/?p=super-star-trek.git;a=blobdiff_plain;f=src%2Fxio.c;h=65098bff143e10b05708bff793cb5f15501034e2;hp=95670993dfea867fbb5f70b2db7e1cfd29caf9c8;hb=0bc4964e6bcf3a3ee3b383ee79a97f69ffa48b46;hpb=63531cb25c72858ed465453c6ead096a8c9a1d20 diff --git a/src/xio.c b/src/xio.c index 9567099..65098bf 100644 --- a/src/xio.c +++ b/src/xio.c @@ -2,61 +2,48 @@ #include #include #include +#include #include #include #include #include "sst.h" static XtAppContext app_context; -static Widget toplevel, form, text, buttons; +static Widget toplevel, text, form; +static Widget navigation, weapons, planets, misc; +static Widget navlabel, weaplabel, planlabel, misclabel; -String fallback[] = { - /* text window resources */ +static String fallback[] = { "*text.resizable: true", "*text.resize: ResizeBoth", - /* layout constraints */ - /* navigation row */ - //"*Move.fromHoriz:", - "*Impulse.fromHoriz: Move", - "*Rest.fromHoriz: Impulse", - "*Warp.fromHoriz: Rest", - "*Dock.fromHoriz: Warp", - "*Chart.fromHoriz: Dock", - // Weapons row - "*Phasers.fromVert: Move", - "*Torpedo.fromHoriz: Phasers", - "*Shields.fromHoriz: Torpedo", - "*Damages.fromHoriz: Shields", - "*Crystals.fromHoriz: Damages", - "*Deathray.fromHoriz: Crystals", - "*Mayday.fromHoriz: Deathray", - "*Abandon.fromHoriz: Mayday", - // Planet row - "*Sensors.fromVert: Phasers", - "*Orbit.fromHoriz: Sensors", - "*Transport.fromHoriz: Orbit", - "*Mine.fromHoriz: Transport", - "*Shuttle.fromHoriz: Transport", - "*Planets.fromHoriz: Shuttle", - // Miscellany row - "*Report.fromVert: Sensors", - "*Computer.fromHoriz: Report", - "*Probe.fromHoriz: Computer", - "*Help.fromHoriz: Computer", - // Ending it all - "*Score.fromVert: Report", - "*Destruct.fromHoriz: Score", - "*Quit.fromHoriz: Destruct", - "*Emexit.fromHoriz: Quit", - "*Save.fromHoriz: Emexit", + "*text.width: 640", + "*text.height: 200", + "*navigation.fromVert: text", + "*navigation.borderWidth: 0", + "*navlabel.label: Navigation: ", + "*navlabel.borderWidth: 0", + "*weapons.fromVert: navigation", + "*weapons.borderWidth: 0", + "*weaplabel.label: Weapons: ", + "*weaplabel.borderWidth: 0", + "*planets.fromVert: weapons", + "*planets.borderWidth: 0", + "*planlabel.label: Planets: ", + "*planlabel.borderWidth: 0", + "*misc.fromVert: planets", + "*misc.borderWidth: 0", + "*misclabel.label: Miscellaneous:", + "*misclabel.borderWidth: 0", NULL, }; struct cmd_t { char *name; void (*callback)(Widget, XtPointer, XtPointer); + Widget *parent; int enable; Widget widget; + }; static void quit_proc(Widget w, XtPointer client_data, XtPointer call_data) @@ -65,39 +52,48 @@ static void quit_proc(Widget w, XtPointer client_data, XtPointer call_data) exit (0); } +static void noargs_proc(Widget w, XtPointer client_data, XtPointer call_data) +/* use this for commands that take no arguments */ +{ + /* currently a stub */ + printf("Button %s pressed\n", XtName(w)); +} + static struct cmd_t commands[] = { - {"Phasers", NULL, 0}, - {"Torpedo", NULL, 0}, - {"Move", NULL, 0}, - {"Shields", NULL, 0}, - {"Dock", NULL, 0}, - {"Damages", NULL, 0}, - {"Chart", NULL, 0}, - {"Impulse", NULL, 0}, - {"Rest", NULL, 0}, - {"Warp", NULL, 0}, - {"Score", NULL, 0}, - {"Sensors", NULL, OPTION_PLANETS}, - {"Orbit", NULL, OPTION_PLANETS}, - {"Transport", NULL, OPTION_PLANETS}, - {"Mine", NULL, OPTION_PLANETS}, - {"Crystals", NULL, OPTION_PLANETS}, - {"Shuttle", NULL, OPTION_PLANETS}, - {"Planets", NULL, OPTION_PLANETS}, - {"Report", NULL, 0}, - {"Computer", NULL, 0}, - {"Emexit", NULL, 0}, - {"Probe", NULL, OPTION_PROBE}, - {"Save", NULL, 0}, - {"Abandon", NULL, 0}, - {"Destruct", NULL, 0}, - {"Deathray", NULL, 0}, - {"Mayday", NULL, 0}, - {"Quit", quit_proc, 0}, - {"Help", NULL, 0}, + {"Move", NULL, &navigation, 0}, + {"Dock", noargs_proc, &navigation, 0}, + {"Chart", noargs_proc, &navigation, 0}, + {"Impulse", NULL, &navigation, 0}, + {"Rest", NULL, &navigation, 0}, + {"Warp", NULL, &navigation, 0}, + {"Probe", NULL, &navigation, OPTION_PROBE}, + + {"Phasers", NULL, &weapons, 0}, + {"Torpedo", NULL, &weapons, 0}, + {"Shields", NULL, &weapons, 0}, + {"Damages", noargs_proc, &weapons, 0}, + {"Abandon", noargs_proc, &weapons, 0}, + {"Destruct", noargs_proc, &weapons, 0}, + {"Deathray", noargs_proc, &weapons, 0}, + {"Mayday", noargs_proc, &weapons, 0}, + + {"Sensors", noargs_proc, &planets, OPTION_PLANETS}, + {"Orbit", noargs_proc, &planets, OPTION_PLANETS}, + {"Transport", noargs_proc, &planets, OPTION_PLANETS}, + {"Mine", noargs_proc, &planets, OPTION_PLANETS}, + {"Crystals", noargs_proc, &planets, OPTION_PLANETS}, + {"Shuttle", noargs_proc, &planets, OPTION_PLANETS}, + {"Planets", noargs_proc, &planets, OPTION_PLANETS}, + + {"Score", noargs_proc, &misc, 0}, + {"Report", noargs_proc, &misc, 0}, + {"Computer", noargs_proc, &misc, 0}, + {"Save", NULL, &misc, 0}, + {"Quit", quit_proc, &misc, 0}, + {"Help", noargs_proc, &misc, 0}, }; -int main(int argc, char **argv) +static void instantiate_main(int argc, char **argv) { struct cmd_t *cp; @@ -107,17 +103,45 @@ int main(int argc, char **argv) XtNallowShellResize, True, NULL); form = XtVaCreateManagedWidget("form", formWidgetClass, toplevel, NULL); /* the command window */ - text = XtVaCreateManagedWidget("text", asciiTextWidgetClass, form, - NULL); - XtVaSetValues(text, XtNeditType,XawtextRead, XtNdisplayCaret,False, NULL); - /* The button panel */ - buttons = XtVaCreateManagedWidget("form", - formWidgetClass, form, - XtNfromVert, text, + text = XtVaCreateManagedWidget("text", + asciiTextWidgetClass, form, + XtNeditType, XawtextEdit, + XtNdisplayCaret,False, + NULL); + /* The button panels */ + navigation = XtVaCreateManagedWidget("navigation", + boxWidgetClass, form, + XtNorientation, XtorientHorizontal, + NULL); + navlabel = XtVaCreateManagedWidget("navlabel", + labelWidgetClass, navigation, NULL); + weapons = XtVaCreateManagedWidget("weapons", + boxWidgetClass, form, + XtNorientation, XtorientHorizontal, + NULL); + weaplabel = XtVaCreateManagedWidget("weaplabel", + labelWidgetClass, weapons, + NULL); + planets = XtVaCreateManagedWidget("planets", + boxWidgetClass, form, + XtNorientation, XtorientHorizontal, + NULL); + planlabel = XtVaCreateManagedWidget("planlabel", + labelWidgetClass, planets, + XtNborderWidth, 0, + NULL); + misc = XtVaCreateManagedWidget("misc", + boxWidgetClass, form, + XtNorientation, XtorientHorizontal, + NULL); + misclabel = XtVaCreateManagedWidget("misclabel", + labelWidgetClass, misc, + NULL); for (cp = commands; cp < commands + sizeof(commands)/sizeof(commands[0]); cp++) { cp->widget = XtVaCreateManagedWidget(cp->name, - commandWidgetClass, buttons, + commandWidgetClass, + *cp->parent, XtNlabel, cp->name, NULL); if (cp->callback) @@ -127,5 +151,10 @@ int main(int argc, char **argv) XtAppMainLoop(app_context); /* loop may be interrupted */ XtDestroyApplicationContext(app_context); +} + +int main(int argc, char **argv) +{ + instantiate_main(argc, argv); exit(0); }