/* * Include files required by all Xt (X Toolkit Intrinsics) applications */ #include <X11/Intrinsic.h> #include <X11/StringDefs.h> /* * Include files for widgets used by this program */ #include <X11/Xaw/Command.h> #include <X11/Xaw/Toggle.h> #include <X11/Xaw/Box.h> /* Global because subroutines depend on it */ XtAppContext appcontext; /* * ARGSUSED comment keeps lint from complaining... */ /* ARGSUSED */ void Quit( Widget w, /* widget triggering callback */ XtPointer client_data, /* last arg of XtAddCallback() */ XtPointer call_data ) /* data passed by widget */ { exit( 0 ); } /* ARGSUSED */ void Change( Widget w, XtPointer client_data, XtPointer call_data ) { Arg arglist[] = { XtNwidth, 180, XtNbackground, (XtArgVal)"red", XtNlabel, (XtArgVal)"HardCoded Resource" }; XtSetValues( (Widget)client_data, arglist, XtNumber( arglist ) ); } int main( int argc, char *argv[] ) { Widget topwidget, container, quitButton, changeButton; static String fallbackResources[] = { ".xsample.*font: lucidasans-bold-12", NULL }; /* Initialize the toolkit */ topwidget = XtVaAppInitialize( &appcontext, /* application context */ "XSample", /* application class */ NULL, 0, /* command line option list */ &argc, argv, /* command line arguments */ fallbackResources, /* fallback resource settings */ NULL ); /* terminate varags list */ /* Create widget */ container = XtVaCreateManagedWidget( "container", /* widget name */ boxWidgetClass, /* widget class */ topwidget, /* widget parent */ NULL ); /* terminate varags list */ /* Create widget */ quitButton = XtVaCreateManagedWidget( "quitButton", commandWidgetClass, container, XtNwidth, 180, /* hard coded X resource */ NULL ); /* Create widget */ changeButton = XtVaCreateManagedWidget( "changeButton", commandWidgetClass, container, NULL ); /* Add quitButton callback functions */ XtAddCallback( quitButton, XtNcallback, Quit, NULL ); /* Add changeButton callback functions */ XtAddCallback( changeButton, XtNcallback, Change, quitButton ); /* Map windows to the screen */ XtRealizeWidget( topwidget ); /* Loop for events */ XtAppMainLoop( appcontext ); }
Last Modified: 13 June 1997
St. Louis Unix Users Group - Linux SIG