XmDIALOG_OK_BUTTON : XmDIALOG_CANCEL_BUTTON,
NULL);
XmStringFree (text);
XmStringFree (yes);
XmStringFree (no);
XtManageChild (dialog);
XtPopup (XtParent (dialog), XtGrabNone);
while (answer == 0)
XtAppProcessEvent (app, XtIMAll);
XtPopdown (XtParent (dialog));
/* make sure the dialog goes away before returning. Sync with server
* and update the display.
*/
XSync (XtDisplay (dialog), 0);
XmUpdateDisplay (parent);
return answer;
}
/* response() −−The user made some sort of response to the
* question posed in AskUser(). Set the answer (client_data)
* accordingly.
*/
void
response(widget, client_data, call_data)
Widget widget;
XtPointer client_data;
XtPointer call_data;
{
int *answer = (int *) client_data;
XmAnyCallbackStruct *cbs = (XmAnyCallbackStruct *) call_data;
if (cbs−>reason == XmCR_OK)
*answer = YES;
else if (cbs−>reason == XmCR_CANCEL)
*answer = NO;
}
The new version of AskUser() is more dynamic than before, since more of the dialog is configurable upon each
invocation of the function. The routine now allows you to specify the message, the labels for the OK and Cancel
buttons, and the default button for the dialog. The flexibility of the routine is achieved at the cost of a few more lines
of source code and additional parameters to the function. The performance of the function is completely unaffected.
One case that the new version of AskUser() does not deal with is the need for additional buttons in the action area
of the dialog. For example, what if you need to provide a ...