-
Notifications
You must be signed in to change notification settings - Fork 0
/
Xerror.c
61 lines (43 loc) · 1.67 KB
/
Xerror.c
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
51
52
53
54
55
56
57
58
59
60
61
/*
-------------------------------------------------------------------------
OBJECT NAME: Xerror.c
FULL NAME: Show Error Box with Message
DESCRIPTION: CreateError should be called once where you initialize
your X stuff. To use just call ShowError(ErrMsg)
INPUT: String to Display.
OUTPUT: Error message in its own tidy little window.
COPYRIGHT: University Corporation for Atmospheric Research, 1991
-------------------------------------------------------------------------
*/
#include <Xm/Xm.h>
#include <Xm/MessageB.h>
static Widget errorBox;
/* -------------------------------------------------------------------- */
void ShowError(char str[])
{
Widget label;
Arg args[5];
XmString xStr;
label = XmMessageBoxGetChild(errorBox, XmDIALOG_MESSAGE_LABEL);
xStr = XmStringCreateLocalized(str);
XtSetArg(args[0], XmNlabelString, xStr);
XtSetValues(label, args, 1);
XmStringFree(xStr);
XtManageChild(errorBox);
XtPopup(XtParent(errorBox), XtGrabNonexclusive);
} /* END SHOWERROR */
/* -------------------------------------------------------------------- */
void ErrorOK(Widget w, XtPointer clientData, XtPointer callData)
{
XtPopdown(XtParent(errorBox));
XtUnmanageChild(errorBox);
} /* END ERROROK */
/* -------------------------------------------------------------------- */
void CreateErrorBox(Widget parent)
{
errorBox = XmCreateErrorDialog(parent, "errorBox", NULL, 0);
XtSetSensitive(XmMessageBoxGetChild(errorBox, XmDIALOG_CANCEL_BUTTON), FALSE);
XtSetSensitive(XmMessageBoxGetChild(errorBox, XmDIALOG_HELP_BUTTON), FALSE);
XtAddCallback(errorBox, XmNokCallback, (XtCallbackProc)ErrorOK, (XtPointer)NULL);
} /* END CREATEERRORBOX */
/* END XERROR.C */