e78e5141039267a65908244a9ff945c5e5832074
[super-star-trek.git] / 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, quit, 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     quit = XtVaCreateManagedWidget ("quit", commandWidgetClass, form, XtNlabel,
25                                     "Quit", NULL);
26     text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, 
27                                     XtNfromHoriz, quit, XtNresize,
28                                     XawtextResizeBoth, XtNresizable, True, NULL);
29     XtAddCallback (quit, XtNcallback, quit_proc, NULL);
30     if (argc <= 1)
31         XtVaSetValues (text, XtNtype, XawAsciiString, 
32                        XtNstring, "Fool! You should"
33                        " supply a file name!", NULL); 
34     else
35         XtVaSetValues (text, XtNtype, XawAsciiFile, XtNstring, argv [1], NULL);
36     XtVaSetValues (text, XtNeditType, XawtextRead, XtNdisplayCaret, False, NULL);
37     XtRealizeWidget (toplevel);
38     XtAppMainLoop (app_context);
39     exit(0);
40 }