494ea7a41a8286df77e63601a9a89fc67c1d7d9c
[super-star-trek.git] / xio.c
1 #include <X11/Intrinsic.h>
2 #include <X11/StringDefs.h>
3 #include <X11/Shell.h>
4 #include <X11/Xaw/Form.h>
5 #include <X11/Xaw/Command.h>
6 #include <X11/Xaw/AsciiText.h>
7
8 XtAppContext app_context;
9 Widget toplevel, form, quit, text;
10
11 void quit_proc (Widget w, XtPointer client_data, XtPointer call_data)
12 { XtDestroyApplicationContext (app_context);
13   exit (0);
14 }
15
16 int main (int argc, char **argv)
17 { toplevel = XtVaOpenApplication (&app_context, "XThird", NULL, 0, &argc,
18                                   argv, NULL, applicationShellWidgetClass,
19                                   XtNallowShellResize, True, NULL);
20   form = XtVaCreateManagedWidget ("form", formWidgetClass, toplevel, NULL); 
21   quit = XtVaCreateManagedWidget ("quit", commandWidgetClass, form, XtNlabel,
22                                   "Quit", NULL);
23   text = XtVaCreateManagedWidget ("text", asciiTextWidgetClass, form, 
24                                   XtNfromHoriz, quit, XtNresize,
25                                   XawtextResizeBoth, XtNresizable, True, NULL);
26   XtAddCallback (quit, XtNcallback, quit_proc, NULL);
27   if (argc <= 1)
28     XtVaSetValues (text, XtNtype, XawAsciiString, XtNstring, "Fool! You should"
29                    " supply a file name!", NULL); 
30   else
31     XtVaSetValues (text, XtNtype, XawAsciiFile, XtNstring, argv [1], NULL);
32   XtVaSetValues (text, XtNeditType, XawtextRead, XtNdisplayCaret, False, NULL);
33   XtRealizeWidget (toplevel);
34   XtAppMainLoop (app_context);
35 }