XtPopup (XtParent (dialog), XtGrabNone);
}
/* callback() −−One of the dialog buttons was selected.
* Determine which one by examining the "reason" parameter.
*/
void
callback(widget, client_data, call_data)
Widget widget;
XtPointer client_data;
XtPointer call_data;
{
char *button;
char *message = (char *) client_data;
XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
switch (cbs−>reason) {
case XmCR_OK : button = "OK"; break;
case XmCR_CANCEL : button = "Cancel"; break;
case XmCR_HELP : button = "Help";
}
printf ("%s was selected: %s0, button, message);
if (cbs−>reason != XmCR_HELP) {
/* the ok and cancel buttons "close" the widget */
XtPopdown (XtParent (widget));
}
}
Another interesting change in this application is the way pushed() determines if the dialog has already been
created. By making the dialog widget handle static to the pushed() callback function, we retain a handle to this
object across multiple button presses. For each invocation of the callback, the dialog's message is reset and it is
popped up again.
Considering style guide issues again, it is important to know when it is appropriate to dismiss a dialog. As noted
earlier, the toolkit automatically unmanages a dialog whenever any of the action area buttons are activated, except for
the Help button. This behavior is controlled by XmNautoUnmanage, which defaults to True. However, if you set
this resource to False, the callback routines for the buttons in the action area have to control the behavior on their ...