hajadi@goofy.csd.sgi.com (Ivan Hajadi) (04/17/91)
/* * xappinit.c * * Example program to show how to use XtAppInitialize instead of the * convenient routine XtInitialize. It also shows how to use fallback * resources, and option description record. * * If the program cannot find /usr/lib/X11/app-defaults/Foo resource * file, then it will use what ever specified in fallback_resources. * Usually this fallback resource list contains crucial resource values * that are needed to run the program successfully. * * Options describes the form of command line option that this program * can handle. See p. 340 Vol One of the O'Reilly book for more * examples. * This program has this syntax: xappinit -labelString "<something>". * * Ivan M. Hajadi, Silicon Graphics, Inc., 15-April-91 */ #include <Xm/Xm.h> #include <Xm/Label.h> /* resources to use when there is no app-defaults file */ static char *fallback_resources[] = { "Foo*fontList: -adobe-helvetica-bold-r-normal--*-80-*-*-*-*-iso*-*", /* "Foo*XmLabel.labelString: This is Motif label widget (no app-defaults)", */ NULL }; /* define command line option and resource file option */ static XrmOptionDescRec options[] = { {"-labelString", "*label.labelString", XrmoptionSepArg, NULL} }; /* Application context takes care of the book-keeping necessary to */ /* maintain one or more connections to X servers. Every application */ /* must have at least one (default) application context. Application */ /* context is an opaque type, that is passed to other Xt functions. */ XtAppContext app_context; main(unsigned int argc, char **argv) { Widget toplevel, w; /* Convenient routine is XtInitialize */ toplevel = XtAppInitialize( &app_context /* returns application context */, "Foo" /* application class */, options /* command line option table */, XtNumber(options) /* number of options */, &argc, argv, fallback_resources /* resources to use when there is no app-defaults file */, NULL /* argument list used to override default values */, 0); w = XtCreateManagedWidget("label", xmLabelWidgetClass, toplevel, NULL, 0); XtRealizeWidget(toplevel); /* Convenient function is XtMainLoop */ XtAppMainLoop(app_context); } -- Ivan M. Hajadi, Widget - any small, unspecified hajadi@csd.sgi.com gadget or device (Webster)