-
Notifications
You must be signed in to change notification settings - Fork 0
/
XmWarn.cc
50 lines (35 loc) · 1.56 KB
/
XmWarn.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
-------------------------------------------------------------------------
OBJECT NAME: XmWarn.c
FULL NAME: Show Warning Box with Message
DESCRIPTION: CreateWarn should be called once where you initialize
your X stuff. To use just call WarnUser(ErrMsg, callBack)
INPUT: String to Display. Callback to call if user hits OK.
OUTPUT: Warning message in its own tidy little window.
AUTHOR: websterc@ncar
-------------------------------------------------------------------------
*/
#include "XmWarn.h"
/* -------------------------------------------------------------------- */
XmWarn::XmWarn(Widget parent, const char warning[], XtCallbackProc okCB, XtCallbackProc cancelCB)
{
Widget label;
Arg args[5];
XmString xStr;
warnBox = XmCreateWarningDialog(parent, const_cast<char *>("warnBox"), NULL, 0);
XtSetSensitive(XmMessageBoxGetChild(warnBox, XmDIALOG_HELP_BUTTON), false);
label = XmMessageBoxGetChild(warnBox, XmDIALOG_MESSAGE_LABEL);
xStr = XmStringCreateLtoR(const_cast<char *>(warning), XmSTRING_DEFAULT_CHARSET);
XtSetArg(args[0], XmNlabelString, xStr);
XtSetValues(label, args, 1);
XmStringFree(xStr);
if (okCB)
XtAddCallback(warnBox, XmNokCallback, (XtCallbackProc)okCB, NULL);
if (cancelCB)
XtAddCallback(warnBox, XmNcancelCallback, (XtCallbackProc)cancelCB, NULL);
XtAddCallback(warnBox,XmNokCallback,(XtCallbackProc)XtDestroyWidget, NULL);
XtAddCallback(warnBox,XmNcancelCallback,(XtCallbackProc)XtDestroyWidget,NULL);
XtManageChild(warnBox);
XtPopup(XtParent(warnBox), XtGrabNone);
} /* END CONTRUCTOR */
/* END XMWARN.C */