Next: Calling MotifXt and Xlib functions Up: A First MOTIF Program Previous: What will we learn from this program?

The push.c program


/* push.c -- Use ctrl-c or window manager quit to terminate prog */

#include <Xm/Xm.h>
#include <Xm/PushB.h>

main(int argc, char **argv)
{   Widget top_wid, button;
    XtAppContext  app;
    void pushed_fn();

    top_wid = XtVaAppInitialize(&app, "Push", NULL, 0,
        &argc, argv, NULL, NULL);

    button = XmCreatePushButton(top_wid, "Push_me", NULL, 0);

    /* tell Xt to manage button */
				XtManageChild(button);
   
				/* attach fn to widget */
    XtAddCallback(button, XmNactivateCallback, pushed_fn, NULL);

    XtRealizeWidget(top_wid); /* display widget hierarchy */
    XtAppMainLoop(app); /* enter processing loop */
}

void pushed_fn(Widget w, XtPointer client_data, 
               XmPushButtonCallbackStruct *cbs)
{   printf("Don't Push Me!!\n"); }

Dave.Marshall@cm.cf.ac.uk
Tue May 24 16:52:56 BST 1994