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
/
xmbutton.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-27
|
2KB
|
83 lines
/* include files */
#include <stdio.h>
#include <Xm/PushB.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 */
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 */
toplevel = XtAppInitialize (&app_context, "XMbutton", NULL, 0, &argc,
argv, NULL, args, 0);
/* Create a bulletin board widget in which to place the pushbutton */
n = 0;
bboard = XmCreateBulletinBoard (toplevel, "bboard", args, n);
/* Manage the bulletin board widget */
XtManageChild (bboard);
/* Create a compound string for the button text */
btn_text = XmStringCreateLtoR("Push Here", XmFONTLIST_DEFAULT_TAG);
/* Set up an arglist for the pushbutton */
n = 0;
XtSetArg (args[n], XmNlabelString, btn_text); n++;
/* Create the pushbutton */
button = XtCreateManagedWidget ("button", xmPushButtonWidgetClass, bboard,
args, n);
/* Free the compound string memory */
XmStringFree (btn_text);
/* Add a callback */
XtAddCallback (button, XmNactivateCallback, activateCB, NULL);
/* 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);
}