1 | /* |
---|
2 | * $Id: warn.c,v 1.3 1999-02-22 18:16:34 danw Exp $ |
---|
3 | * |
---|
4 | * Copyright 1990, 1991 by the Massachusetts Institute of Technology. |
---|
5 | * |
---|
6 | * For copying and distribution information, please see the file |
---|
7 | * <mit-copyright.h>. |
---|
8 | * |
---|
9 | */ |
---|
10 | |
---|
11 | #if (!defined(lint)) && (!defined(SABER)) |
---|
12 | static char *rcsid = |
---|
13 | "$Id: warn.c,v 1.3 1999-02-22 18:16:34 danw Exp $"; |
---|
14 | #endif |
---|
15 | |
---|
16 | #include "mit-copyright.h" |
---|
17 | #include "Jets.h" |
---|
18 | #include "Window.h" |
---|
19 | #include "Button.h" |
---|
20 | #include "Label.h" |
---|
21 | #include "Form.h" |
---|
22 | #include "warn.h" |
---|
23 | |
---|
24 | static int ok(who, w, data) |
---|
25 | Jet who; |
---|
26 | Warning *w; |
---|
27 | caddr_t data; |
---|
28 | { |
---|
29 | Display *dpy; |
---|
30 | |
---|
31 | dpy = w->top->core.display; /* save off the display before */ |
---|
32 | /* destroying the Jet */ |
---|
33 | XjDestroyJet(w->top); |
---|
34 | XFlush(dpy); |
---|
35 | |
---|
36 | XjFree(w->l1); |
---|
37 | XjFree(w->l2); |
---|
38 | XjFree((char *) w); |
---|
39 | return 0; |
---|
40 | } |
---|
41 | |
---|
42 | Warning *XjUserWarning(root, okProc, realize, line1, line2) |
---|
43 | Jet root; |
---|
44 | Warning *okProc; |
---|
45 | Boolean realize; |
---|
46 | char *line1, *line2; |
---|
47 | { |
---|
48 | Jet warnTop, warnForm, warn1label, warn2label, warn1icon, |
---|
49 | warnokwindow, warnoklabel; |
---|
50 | ButtonJet warnokbutton; |
---|
51 | Warning *w; |
---|
52 | |
---|
53 | if (okProc) |
---|
54 | w = okProc; |
---|
55 | else |
---|
56 | { |
---|
57 | w = (Warning *)XjMalloc((unsigned) sizeof(Warning)); |
---|
58 | |
---|
59 | w->me.next = NULL; |
---|
60 | w->me.argType = argPtr; |
---|
61 | w->me.passPtr = w; |
---|
62 | w->me.proc = ok; |
---|
63 | |
---|
64 | w->l1 = XjNewString(line1); |
---|
65 | w->l2 = XjNewString(line2); |
---|
66 | } |
---|
67 | |
---|
68 | warnTop = XjVaCreateJet("warnWindow", windowJetClass, root, NULL, NULL); |
---|
69 | warnForm = XjVaCreateJet("warnForm", formJetClass, warnTop, NULL, NULL); |
---|
70 | |
---|
71 | warn1label = XjVaCreateJet("warn1Label", labelJetClass, warnForm, |
---|
72 | XjNlabel, w->l1, NULL, NULL); |
---|
73 | warn2label = XjVaCreateJet("warn2Label", labelJetClass, warnForm, |
---|
74 | XjNlabel, w->l2, NULL, NULL); |
---|
75 | warn1icon = XjVaCreateJet("dashLogo", labelJetClass, warnForm, |
---|
76 | NULL, NULL); |
---|
77 | warnokwindow = XjVaCreateJet("warnOKWindow", windowJetClass, warnForm, |
---|
78 | NULL, NULL); |
---|
79 | warnokbutton = (ButtonJet) XjVaCreateJet("warnOKButton", buttonJetClass, |
---|
80 | warnokwindow, |
---|
81 | XjNactivateProc, &(w->me), NULL, NULL); |
---|
82 | warnoklabel = XjVaCreateJet("warnOKLabel", labelJetClass, warnokbutton, |
---|
83 | NULL, NULL); |
---|
84 | |
---|
85 | w->top = warnTop; |
---|
86 | w->button = warnokbutton; |
---|
87 | |
---|
88 | if (realize) |
---|
89 | XjRealizeJet(warnTop); |
---|
90 | |
---|
91 | return w; |
---|
92 | } |
---|