hajadi@goofy.csd.sgi.com (Ivan Hajadi) (04/17/91)
Can someone tell me what I did wrong ? I want to be able to call the program like this foo -label SOMETHING and have a label widget with string SOMETHING. Thanks. -- ivan #ifdef ATHENA #include <X11/Intrinsic.h> #include <X11/StringDefs.h> #include <Xaw/Label.h> #else #include <Xm/Xm.h> #include <Xm/Label.h> #endif /* resources to use when there is no app-defaults file */ static char *fallback_resources[] = { #ifdef ATHENA "Foo*font: -adobe-helvetica-bold-r-normal--*-80-*-*-*-*-iso*-*", "Foo*Label.label: This is Athena label widget (no app-defaults)", #else "Foo*fontList: -adobe-helvetica-bold-r-normal--*-80-*-*-*-*-iso*-*", "Foo*XmLabel.labelString: This is Motif label widget (no app-defaults)", #endif NULL }; /* define command line option and resource file option */ static XrmOptionDescRec options[] = { #ifdef ATHENA {"-label", "*label.label", XrmoptionSepArg, NULL} #else {"-labelString", "*label.labelString", XrmoptionSepArg, NULL} #endif }; /* 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); #ifdef ATHENA w = XtCreateManagedWidget("label", labelWidgetClass, toplevel, NULL, 0); #else w = XtCreateManagedWidget("label", xmLabelWidgetClass, toplevel, NULL, 0); #endif XtRealizeWidget(toplevel); /* Convenient function is XtMainLoop */ XtAppMainLoop(app_context); } -- Ivan M. Hajadi, Widget - any small, unspecified hajadi@csd.sgi.com gadget or device (Webster)