]>
Commit | Line | Data |
---|---|---|
c34403d7 | 1 | /* |
2 | ** Stub functions | |
3 | */ | |
4 | ||
892c98b2 | 5 | #include <X11/StringDefs.h> |
c34403d7 | 6 | #include <X11/Intrinsic.h> |
892c98b2 | 7 | #include <X11/IntrinsicP.h> |
8 | #include <X11/Core.h> | |
9 | #include <X11/CoreP.h> | |
10 | #include <X11/CompositeP.h> | |
4fa286c6 | 11 | #include <X11/cursorfont.h> |
892c98b2 | 12 | #include "data.h" |
c34403d7 | 13 | #include <Xm/Text.h> |
14 | ||
4fa286c6 | 15 | static char rcsid[] = "$Header$"; |
16 | ||
892c98b2 | 17 | void extra_help_callback(); |
18 | ||
c34403d7 | 19 | static Widget logwidget = NULL; |
20 | ||
21 | Widget | |
22 | SetupLogWidget(parent) | |
23 | Widget parent; | |
24 | { | |
892c98b2 | 25 | Arg wargs[10]; |
26 | int n; | |
27 | ||
c34403d7 | 28 | if (logwidget) |
29 | return (logwidget); | |
30 | ||
892c98b2 | 31 | n = 0; |
32 | XtSetArg(wargs[n], XmNeditMode, XmMULTI_LINE_EDIT); n++; | |
33 | XtSetArg(wargs[n], XmNeditable, False); n++; | |
34 | ||
35 | logwidget = XmCreateScrolledText( parent, | |
36 | "logwidget", | |
37 | wargs, n); | |
38 | XtManageChild(logwidget); | |
39 | ||
c34403d7 | 40 | return (logwidget); |
41 | } | |
42 | ||
43 | /* | |
44 | ** PopupErrorMessage(text) | |
45 | ** | |
46 | ** Given a char* pointing to an error message, possibly with imbedded | |
47 | ** newlines, display the text in a popup window and put two buttons | |
892c98b2 | 48 | ** at the bottom of the window, labelled "OK" and "Cancel." Pop down |
c34403d7 | 49 | ** when one of the buttons is pressed. |
50 | ** | |
892c98b2 | 51 | ** Return 0 if "OK" is pressed, 1 for "Cancel." |
c34403d7 | 52 | */ |
53 | ||
892c98b2 | 54 | Boolean |
55 | PopupErrorMessage(text, extrahelp) | |
c34403d7 | 56 | char *text; |
892c98b2 | 57 | char *extrahelp; |
c34403d7 | 58 | { |
b2d21e59 | 59 | static Widget child; |
892c98b2 | 60 | Arg wargs[10]; |
61 | int n; | |
b2d21e59 | 62 | static XmString label; |
63 | ||
64 | if (label) { | |
65 | XtFree(label); | |
66 | XtDestroyWidget(child); | |
67 | } | |
892c98b2 | 68 | |
69 | ||
70 | label = XmStringCreateLtoR( text, XmSTRING_DEFAULT_CHARSET); | |
71 | ||
72 | n = 0; | |
73 | XtSetArg(wargs[n], XmNmessageString, label); n++; | |
74 | ||
75 | child = (Widget) XmCreateErrorDialog(logwidget, "errormessage", wargs, n); | |
76 | if (extrahelp) | |
77 | XtAddCallback (child, XmNhelpCallback, extra_help_callback, extrahelp); | |
78 | else | |
79 | XtUnmanageChild(XmMessageBoxGetChild (child, XmDIALOG_HELP_BUTTON)); | |
80 | XtUnmanageChild(XmMessageBoxGetChild (child, XmDIALOG_CANCEL_BUTTON)); | |
81 | XtManageChild(child); | |
c34403d7 | 82 | } |
83 | ||
84 | /* | |
85 | ** PopupHelpWindow(text) | |
86 | ** | |
87 | ** Given a char* pointing to an help message, possibly with imbedded | |
88 | ** newlines, display the text in a popup window and put a single button | |
89 | ** at the bottom of the window, labelled "OK." Pop down when the | |
90 | ** the buttons is pressed. | |
91 | */ | |
92 | ||
93 | void | |
94 | PopupHelpWindow(text) | |
95 | char *text; | |
96 | { | |
b2d21e59 | 97 | static Widget child; |
892c98b2 | 98 | Arg wargs[10]; |
99 | int n; | |
892c98b2 | 100 | |
b2d21e59 | 101 | static XmString label; |
102 | if (label) { | |
103 | XtFree(label); | |
104 | XtDestroyWidget(child); | |
105 | } | |
892c98b2 | 106 | |
107 | label = XmStringCreateLtoR( text, XmSTRING_DEFAULT_CHARSET); | |
108 | ||
109 | n = 0; | |
110 | XtSetArg(wargs[n], XmNmessageString, label); n++; | |
111 | ||
112 | child = (Widget) XmCreateMessageDialog(logwidget, "helpmessage", wargs, n); | |
113 | XtUnmanageChild(XmMessageBoxGetChild (child, XmDIALOG_CANCEL_BUTTON)); | |
114 | XtUnmanageChild(XmMessageBoxGetChild (child, XmDIALOG_HELP_BUTTON)); | |
115 | ||
116 | XtManageChild(child); | |
c34403d7 | 117 | } |
118 | ||
119 | /* | |
120 | ** Given a char* to a single line of text, append this line at the bottom | |
121 | ** of the log window. Return 0 of the append was sucessful, non-zero | |
122 | ** for an error condition. | |
123 | */ | |
124 | ||
125 | int | |
126 | AppendToLog(text) | |
127 | char *text; | |
128 | { | |
129 | XmTextPosition pos; | |
130 | char *string; | |
131 | ||
132 | string = XmTextGetString(logwidget); | |
133 | pos = strlen(string); | |
134 | XtFree(string); | |
135 | ||
136 | XmTextReplace(logwidget, pos, pos, text); | |
892c98b2 | 137 | XmTextSetCursorPosition(logwidget, pos + strlen(text)); |
c34403d7 | 138 | } |
139 | ||
892c98b2 | 140 | void |
4fa286c6 | 141 | MakeWatchCursor(topW) |
142 | Widget topW; | |
892c98b2 | 143 | { |
4fa286c6 | 144 | Cursor mycursor; |
145 | ||
146 | if (!topW) | |
147 | return; | |
148 | ||
149 | mycursor = XCreateFontCursor (XtDisplay(topW), XC_watch); | |
150 | XDefineCursor(XtDisplay(topW), XtWindow(topW), mycursor); | |
892c98b2 | 151 | } |
c34403d7 | 152 | |
153 | void | |
4fa286c6 | 154 | MakeNormalCursor(topW) |
155 | Widget topW; | |
c34403d7 | 156 | { |
4fa286c6 | 157 | if (!topW) |
158 | return; | |
159 | ||
160 | XUndefineCursor(XtDisplay(topW), XtWindow(topW)); | |
c34403d7 | 161 | } |
162 | ||
892c98b2 | 163 | /* |
164 | ** Move through the fields of the spec and make certain that the | |
165 | ** form's widgets actually reflect the current values. | |
166 | */ | |
167 | ||
c34403d7 | 168 | void |
892c98b2 | 169 | UpdateForm(spec) |
170 | EntryForm *spec; | |
c34403d7 | 171 | { |
892c98b2 | 172 | UserPrompt **myinputlines = spec->inputlines; |
173 | UserPrompt *current; | |
174 | Arg wargs[10]; | |
175 | int n, kidcount; | |
176 | Widget kid; | |
177 | ||
178 | for ( current = (*myinputlines); | |
179 | current; | |
180 | myinputlines++, current = (*myinputlines)) { | |
181 | ||
182 | ||
183 | switch (current->type) { | |
184 | case FT_STRING: | |
185 | if (current->returnvalue.stringvalue) { | |
186 | XmTextSetString (current->mywidget, current->returnvalue.stringvalue); | |
187 | } | |
188 | break; | |
189 | ||
190 | case FT_BOOLEAN: | |
191 | n = 0; | |
b2d21e59 | 192 | XtSetArg(wargs[n], XmNset, |
193 | current->returnvalue.booleanvalue ? True : False); n++; | |
892c98b2 | 194 | XtSetValues (current->mywidget, wargs, n); |
195 | break; | |
196 | ||
197 | case FT_KEYWORD: | |
198 | kidcount = ((CompositeRec *)(current->mywidget))-> | |
199 | composite.num_children; | |
892c98b2 | 200 | |
201 | while(kidcount--) { | |
202 | n = 0; | |
203 | kid = ((CompositeRec *)(current->mywidget))-> | |
204 | composite.children[kidcount]; | |
b2d21e59 | 205 | if (current->returnvalue.stringvalue && |
206 | (!strcmp (XtName(kid), current->returnvalue.stringvalue))) { | |
892c98b2 | 207 | XtSetArg(wargs[n], XmNset, True); |
208 | n++; | |
209 | } | |
210 | else { | |
211 | XtSetArg(wargs[n], XmNset, False); | |
212 | n++; | |
213 | } | |
214 | XtSetValues (kid, wargs, n); | |
215 | } | |
216 | break; | |
217 | ||
218 | case FT_NUMBER: | |
219 | break; | |
220 | } | |
221 | n = 0; | |
222 | XtSetArg(wargs[n], XtNsensitive, !(current->insensitive)); n++; | |
223 | XtSetValues (current->mywidget, wargs, n); | |
224 | } | |
c34403d7 | 225 | } |
226 | ||
227 | void | |
892c98b2 | 228 | extra_help_callback(w, client_data, call_data) |
229 | Widget w; | |
230 | char *client_data; | |
231 | XmAnyCallbackStruct *call_data; | |
c34403d7 | 232 | { |
892c98b2 | 233 | PopupHelpWindow(client_data); |
c34403d7 | 234 | } |