63faceada62e4320fc425ff2f14af61b19a22360
[super-star-trek.git] / src / xio.c
1 #include <stdlib.h>
2 #include <X11/Intrinsic.h>
3 #include <X11/StringDefs.h>
4 #include <X11/Shell.h>
5 #include <X11/Xaw/Form.h>
6 #include <X11/Xaw/Command.h>
7 #include <X11/Xaw/AsciiText.h>
8
9 XtAppContext app_context;
10 Widget toplevel, form, buttons, quit, destruct, text;
11
12 void quit_proc (Widget w, XtPointer client_data, XtPointer call_data)
13
14     XtDestroyApplicationContext (app_context);
15     exit (0);
16 }
17
18 int main (int argc, char **argv)
19
20     toplevel = XtVaOpenApplication (&app_context, "XThird", NULL, 0, &argc,
21                                     argv, NULL, applicationShellWidgetClass,
22                                     XtNallowShellResize, True, NULL);
23     form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL); 
24     buttons = XtVaCreateManagedWidget ("form", formWidgetClass, form, NULL); 
25     quit     = XtVaCreateManagedWidget("quit", 
26                                        commandWidgetClass, buttons, 
27                                        XtNlabel, "Quit", NULL);
28     destruct = XtVaCreateManagedWidget("destruct", 
29                                        commandWidgetClass, buttons, 
30                                        XtNfromHoriz, quit,
31                                        XtNlabel, "Destruct", NULL);
32     text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, 
33                                     XtNfromVert, buttons, XtNresize,
34                                     XawtextResizeBoth, XtNresizable, True, NULL);
35     XtAddCallback (quit, XtNcallback, quit_proc, NULL);
36
37     /* sample text so the widget will be identifiable */
38     XtVaSetValues (text, XtNtype, XawAsciiString, 
39                        XtNstring, "Command window", NULL); 
40     XtVaSetValues (text, XtNeditType, XawtextRead, XtNdisplayCaret, False, NULL);
41     XtRealizeWidget (toplevel);
42     XtAppMainLoop (app_context);
43     exit(0);
44 }