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
/
csbutton.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-08-18
|
2KB
|
83 lines
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/PushB.h>
#include <Xm/BulletinB.h>
/* Functions defined in this program */
void main();
void activateCB(); /* Callback for the PushButton */
/*-------------------------------------------------------------
** main - Main logic for csbutton
*/
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 */
XmString dir1, text1, var1;
char *text = "Push Here";
/* Initialize the toolkit, create application context, open display,
and create a toplevel shell */
toplevel = XtAppInitialize (&app_context, "Csbutton", 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 */
dir1 = XmStringDirectionCreate (XmSTRING_DIRECTION_R_TO_L);
text1 = XmStringCreate (text,"chset1");
var1 = XmStringConcat (dir1, text1);
/* Set up an arglist for the push button */
n = 0;
XtSetArg (args[n], XmNlabelString, var1); n++;
/* Create the push button */
button = XtCreateManagedWidget ("button", xmPushButtonWidgetClass, bboard,
args, n);
/* Free the memory used by the compound strings */
XmStringFree(dir1);
XmStringFree(text1);
XmStringFree(var1);
/* 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 selected.\n");
exit (0);
}