home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The World of Computer Software
/
World_Of_Computer_Software-02-385-Vol-1of3.iso
/
m
/
master12.zip
/
mastering
/
pathtest.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-21
|
4KB
|
125 lines
/**---------------------------------------------------------------------
***
*** file: pathtest.c
***
*** project: Motif Widgets example programs
***
*** description: This program creates a pushbutton widget and
*** three label widgets, all contained within a
*** bulletin board widget. The labels that are
*** displayed are dependent on the setting of certain
*** environment variables, LANG, XAPPLRESDIR,
*** XFILESEARCHPATH, and XUSERFILESEARCHPATH.
***
***-------------------------------------------------------------------*/
/* include files */
#include <stdio.h>
#include <Xm/PushB.h>
#include <Xm/Label.h>
#include <Xm/BulletinB.h>
/* Functions defined in this program */
void main();
void activateCB(); /* Callback for the PushButton */
/* Global variables */
XmString btn_text; /* button label pointer for compound string */
/*-------------------------------------------------------------
** main - Main logic for xmbutton
*/
void main (argc,argv)
unsigned int argc;
char **argv;
{
Widget toplevel; /* Shell widget */
Widget bboard; /* Bulletin board widget */
Widget button; /* PushButton widget */
Widget label1, label2, label3; /* Label widgets */
Arg args[10]; /* arg list */
register int n; /* arg count */
XtAppContext app_context; /* application context */
/* Initialize the toolkit, create application context, open display,
and create a toplevel shell. Note that Pathtest is the application
class name that is used as the file name for app-defaults files for
this application. */
toplevel = XtAppInitialize (&app_context, "Pathtest", NULL, 0, &argc,
argv, NULL, args, 0);
/* Create a bulletin board widget in which to place the pushbutton
and the three label widgets. */
n = 0;
bboard = XmCreateBulletinBoard (toplevel, "bboard", args, n);
/* Manage the bulletin board widget */
XtManageChild (bboard);
/* Create a compound string for the pushbutton text */
btn_text = XmStringCreateLtoR("Quit", XmFONTLIST_DEFAULT_TAG);
/* Set up an arglist for the pushbutton */
n = 0;
XtSetArg (args[n], XmNlabelString, btn_text); n++;
/* Create the pushbutton */
button = XmCreatePushButton (bboard, "button", args, n);
/* Manage the pushbutton */
XtManageChild (button);
/* Add a callback for the pushbutton */
XtAddCallback (button, XmNactivateCallback, activateCB, NULL);
/* Free the compound string memory */
XmStringFree (btn_text);
/* Create label1 */
n = 0;
label1 = XmCreateLabel (bboard, "label1", args, n);
/* Manage label1 */
XtManageChild (label1);
/* Create label2 */
n = 0;
label2 = XmCreateLabel (bboard, "label2", args, n);
/* Manage label2 */
XtManageChild (label2);
/* Create label3 */
n = 0;
label3 = XmCreateLabel (bboard, "label3", args, n);
/* Manage label3 */
XtManageChild (label3);
/* Realize widgets */
XtRealizeWidget (toplevel);
/* Process events */
XtAppMainLoop (app_context);
}
/*-------------------------------------------------------------
** activateCB - callback for button
*/
void activateCB (w, client_data, call_data)
Widget w; /* widget id */
XtPointer client_data; /* data from application */
XtPointer call_data; /* data from widget class */
{
/* Print message and terminate program */
printf ("Pushbutton Activated.\n");
exit (0);
}