Mercurial > hg > xemacs-beta
annotate lwlib/lwlib-Xaw.c @ 4522:fc7067b7f407
Backout last patch; forgot to specify file.
author | Stephen J. Turnbull <stephen@xemacs.org> |
---|---|
date | Wed, 29 Oct 2008 03:37:16 +0900 |
parents | 383ab474a241 |
children | 726060ee587c |
rev | line source |
---|---|
428 | 1 /* The lwlib interface to Athena widgets. |
2 Copyright (C) 1993, 1994 Free Software Foundation, Inc. | |
3 | |
4 This file is part of the Lucid Widget Library. | |
5 | |
6 The Lucid Widget Library is free software; you can redistribute it and/or | |
7 modify it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 The Lucid Widget Library is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with XEmacs; see the file COPYING. If not, write to | |
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | |
19 Boston, MA 02111-1307, USA. */ | |
20 | |
21 #include <config.h> | |
22 #include <stdio.h> | |
23 | |
24 #ifdef STDC_HEADERS | |
25 #include <stdlib.h> | |
26 #endif | |
27 | |
28 #include "lwlib-Xaw.h" | |
29 | |
30 #include <X11/StringDefs.h> | |
31 #include <X11/IntrinsicP.h> | |
32 #include <X11/CoreP.h> | |
33 #include <X11/Shell.h> | |
34 | |
35 #ifdef LWLIB_SCROLLBARS_ATHENA | |
442 | 36 #include ATHENA_Scrollbar_h_ |
428 | 37 #endif |
38 #ifdef LWLIB_DIALOGS_ATHENA | |
442 | 39 #include ATHENA_Dialog_h_ |
40 #include ATHENA_Form_h_ | |
41 #include ATHENA_Command_h_ | |
42 #include ATHENA_Label_h_ | |
428 | 43 #endif |
44 #ifdef LWLIB_WIDGETS_ATHENA | |
442 | 45 #include ATHENA_Toggle_h_ |
428 | 46 #include "xlwradio.h" |
47 #include "xlwcheckbox.h" | |
48 #include "xlwgauge.h" | |
442 | 49 #include ATHENA_AsciiText_h_ |
428 | 50 #endif |
51 #include <X11/Xatom.h> | |
52 | |
53 static void xaw_generic_callback (Widget, XtPointer, XtPointer); | |
54 | |
3094 | 55 extern int debug_xft; |
428 | 56 |
57 Boolean | |
58 lw_xaw_widget_p (Widget widget) | |
59 { | |
60 return (0 | |
61 #ifdef LWLIB_SCROLLBARS_ATHENA | |
62 || XtIsSubclass (widget, scrollbarWidgetClass) | |
63 #endif | |
64 #ifdef LWLIB_DIALOGS_ATHENA | |
65 || XtIsSubclass (widget, dialogWidgetClass) | |
66 #endif | |
67 #ifdef LWLIB_WIDGETS_ATHENA | |
68 || XtIsSubclass (widget, labelWidgetClass) | |
69 || XtIsSubclass (widget, toggleWidgetClass) | |
70 || XtIsSubclass (widget, gaugeWidgetClass) | |
442 | 71 #ifndef NEED_MOTIF |
72 || XtIsSubclass (widget, asciiTextWidgetClass) | |
428 | 73 #endif |
74 #endif | |
75 ); | |
76 } | |
77 | |
78 #ifdef LWLIB_SCROLLBARS_ATHENA | |
79 static void | |
80 xaw_update_scrollbar (widget_instance *instance, Widget widget, | |
81 widget_value *val) | |
82 { | |
83 if (val->scrollbar_data) | |
84 { | |
85 scrollbar_values *data = val->scrollbar_data; | |
86 float widget_shown, widget_topOfThumb; | |
87 float new_shown, new_topOfThumb; | |
88 Arg al [10]; | |
89 | |
90 /* First size and position the scrollbar widget. */ | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
91 XtSetArg (al [0], XtNx, data->scrollbar_x); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
92 XtSetArg (al [1], XtNy, data->scrollbar_y); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
93 XtSetArg (al [2], XtNwidth, data->scrollbar_width); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
94 XtSetArg (al [3], XtNheight, data->scrollbar_height); |
428 | 95 XtSetValues (widget, al, 4); |
96 | |
97 /* Now size the scrollbar's slider. */ | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
98 XtSetArg (al [0], XtNtopOfThumb, &widget_topOfThumb); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
99 XtSetArg (al [1], XtNshown, &widget_shown); |
428 | 100 XtGetValues (widget, al, 2); |
101 | |
102 new_shown = (double) data->slider_size / | |
103 (double) (data->maximum - data->minimum); | |
104 | |
105 new_topOfThumb = (double) (data->slider_position - data->minimum) / | |
106 (double) (data->maximum - data->minimum); | |
107 | |
108 if (new_shown > 1.0) | |
109 new_shown = 1.0; | |
110 else if (new_shown < 0) | |
111 new_shown = 0; | |
112 | |
113 if (new_topOfThumb > 1.0) | |
114 new_topOfThumb = 1.0; | |
115 else if (new_topOfThumb < 0) | |
116 new_topOfThumb = 0; | |
117 | |
118 if (new_shown != widget_shown || new_topOfThumb != widget_topOfThumb) | |
119 XawScrollbarSetThumb (widget, new_topOfThumb, new_shown); | |
120 } | |
121 } | |
122 #endif /* LWLIB_SCROLLBARS_ATHENA */ | |
123 | |
124 void | |
125 xaw_update_one_widget (widget_instance *instance, Widget widget, | |
2286 | 126 widget_value *val, Boolean UNUSED (deep_p)) |
428 | 127 { |
128 if (0) | |
129 ; | |
130 #ifdef LWLIB_SCROLLBARS_ATHENA | |
131 else if (XtIsSubclass (widget, scrollbarWidgetClass)) | |
132 { | |
133 xaw_update_scrollbar (instance, widget, val); | |
134 } | |
135 #endif | |
442 | 136 #ifdef LWLIB_WIDGETS_ATHENA |
137 #ifndef NEED_MOTIF | |
138 else if (XtIsSubclass (widget, asciiTextWidgetClass)) | |
139 { | |
140 } | |
141 #endif | |
142 #endif | |
428 | 143 #ifdef LWLIB_DIALOGS_ATHENA |
144 else if (XtIsSubclass (widget, dialogWidgetClass)) | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
145 { |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
146 Arg al [1]; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
147 XtSetArg (al [0], XtNlabel, val->contents->value); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
148 XtSetValues (widget, al, 1); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
149 } |
428 | 150 #endif /* LWLIB_DIALOGS_ATHENA */ |
151 #ifdef LWLIB_WIDGETS_ATHENA | |
438 | 152 else if (XtClass (widget) == labelWidgetClass) |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
153 { |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
154 Arg al [1]; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
155 XtSetArg (al [0], XtNlabel, val->value); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
156 XtSetValues (widget, al, 1); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
157 } |
428 | 158 #endif /* LWLIB_WIDGETS_ATHENA */ |
159 #if defined (LWLIB_DIALOGS_ATHENA) || defined (LWLIB_WIDGETS_ATHENA) | |
160 else if (XtIsSubclass (widget, commandWidgetClass)) | |
161 { | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
162 Dimension bw = 0; |
428 | 163 Arg al [3]; |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
164 XtSetArg (al [0], XtNborderWidth, &bw); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
165 XtGetValues (widget, al, 1); |
428 | 166 |
167 #ifndef LWLIB_DIALOGS_ATHENA3D | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
168 if (bw == 0) |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
169 /* Don't let buttons end up with 0 borderwidth, that's ugly... |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
170 Yeah, all this should really be done through app-defaults files |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
171 or fallback resources, but that's a whole different can of worms |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
172 that I don't feel like opening right now. Making Athena widgets |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
173 not look like shit is just entirely too much work. |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
174 */ |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
175 { |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
176 XtSetArg (al [0], XtNborderWidth, 1); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
177 XtSetValues (widget, al, 1); |
428 | 178 } |
179 #endif /* ! LWLIB_DIALOGS_ATHENA3D */ | |
180 | |
442 | 181 lw_remove_accelerator_spec (val->value); |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
182 XtSetArg (al [0], XtNlabel, val->value); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
183 XtSetArg (al [1], XtNsensitive, val->enabled); |
428 | 184 /* Force centered button text. See above. */ |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
185 XtSetArg (al [2], XtNjustify, XtJustifyCenter); |
428 | 186 XtSetValues (widget, al, 3); |
187 | |
188 XtRemoveAllCallbacks (widget, XtNcallback); | |
189 XtAddCallback (widget, XtNcallback, xaw_generic_callback, instance); | |
190 #ifdef LWLIB_WIDGETS_ATHENA | |
191 /* set the selected state */ | |
192 if (XtIsSubclass (widget, toggleWidgetClass)) | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
193 { |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
194 XtSetArg (al [0], XtNstate, val->selected); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
195 XtSetValues (widget, al, 1); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
196 } |
428 | 197 #endif /* LWLIB_WIDGETS_ATHENA */ |
198 } | |
199 #endif /* LWLIB_DIALOGS_ATHENA */ | |
442 | 200 /* Lastly update our global arg values. */ |
201 if (val->args && val->args->nargs) | |
202 XtSetValues (widget, val->args->args, val->args->nargs); | |
428 | 203 } |
204 | |
205 void | |
206 xaw_update_one_value (widget_instance *instance, Widget widget, | |
207 widget_value *val) | |
208 { | |
209 #ifdef LWLIB_WIDGETS_ATHENA | |
210 widget_value *old_wv; | |
211 | |
212 /* copy the call_data slot into the "return" widget_value */ | |
213 for (old_wv = instance->info->val->contents; old_wv; old_wv = old_wv->next) | |
214 if (!strcmp (val->name, old_wv->name)) | |
215 { | |
216 val->call_data = old_wv->call_data; | |
217 break; | |
218 } | |
219 | |
220 if (XtIsSubclass (widget, toggleWidgetClass)) | |
221 { | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
222 Arg al [1]; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
223 XtSetArg (al [0], XtNstate, &val->selected); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
224 XtGetValues (widget, al, 1); |
428 | 225 val->edited = True; |
226 } | |
227 #ifndef NEED_MOTIF | |
228 else if (XtIsSubclass (widget, asciiTextWidgetClass)) | |
229 { | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
230 Arg al [2]; |
442 | 231 String buf = 0; |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
232 XtSetArg (al [0], XtNstring, &buf); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
233 XtGetValues (widget, al, 1); |
442 | 234 |
428 | 235 if (val->value) |
442 | 236 { |
237 free (val->value); | |
238 val->value = 0; | |
239 } | |
240 /* I don't think this causes a leak. */ | |
241 if (buf) | |
242 val->value = strdup (buf); | |
428 | 243 val->edited = True; |
244 } | |
245 #endif | |
246 #endif /* LWLIB_WIDGETS_ATHENA */ | |
247 } | |
248 | |
249 void | |
250 xaw_destroy_instance (widget_instance *instance) | |
251 { | |
252 #ifdef LWLIB_DIALOGS_ATHENA | |
253 if (XtIsSubclass (instance->widget, dialogWidgetClass)) | |
254 /* Need to destroy the Shell too. */ | |
255 XtDestroyWidget (XtParent (instance->widget)); | |
256 else | |
257 #endif | |
258 XtDestroyWidget (instance->widget); | |
259 } | |
260 | |
261 void | |
2286 | 262 xaw_popup_menu (Widget UNUSED (widget), XEvent *UNUSED (event)) |
428 | 263 { |
264 /* An Athena menubar has not been implemented. */ | |
265 return; | |
266 } | |
267 | |
268 void | |
269 xaw_pop_instance (widget_instance *instance, Boolean up) | |
270 { | |
271 Widget widget = instance->widget; | |
272 | |
273 if (up) | |
274 { | |
275 #ifdef LWLIB_DIALOGS_ATHENA | |
276 if (XtIsSubclass (widget, dialogWidgetClass)) | |
277 { | |
278 /* For dialogs, we need to call XtPopup on the parent instead | |
279 of calling XtManageChild on the widget. | |
280 Also we need to hack the shell's WM_PROTOCOLS to get it to | |
281 understand what the close box is supposed to do!! | |
282 */ | |
283 Display *dpy = XtDisplay (widget); | |
284 Widget shell = XtParent (widget); | |
285 Atom props [2]; | |
286 int i = 0; | |
287 props [i++] = XInternAtom (dpy, "WM_DELETE_WINDOW", False); | |
288 XChangeProperty (dpy, XtWindow (shell), | |
289 XInternAtom (dpy, "WM_PROTOCOLS", False), | |
290 XA_ATOM, 32, PropModeAppend, | |
291 (unsigned char *) props, i); | |
292 | |
293 /* Center the widget in its parent. Why isn't this kind of crap | |
294 done automatically? I thought toolkits were supposed to make | |
295 life easier? | |
296 */ | |
297 { | |
298 unsigned int x, y, w, h; | |
299 Widget topmost = instance->parent; | |
300 w = shell->core.width; | |
301 h = shell->core.height; | |
302 while (topmost->core.parent && | |
303 XtIsRealized (topmost->core.parent) && | |
304 /* HAVE_SESSION adds an unmapped parent widget that | |
305 we should ignore here. */ | |
306 topmost->core.parent->core.mapped_when_managed) | |
307 topmost = topmost->core.parent; | |
308 if (topmost->core.width < w) x = topmost->core.x; | |
309 else x = topmost->core.x + ((topmost->core.width - w) / 2); | |
310 if (topmost->core.height < h) y = topmost->core.y; | |
311 else y = topmost->core.y + ((topmost->core.height - h) / 2); | |
312 XtMoveWidget (shell, x, y); | |
313 } | |
314 | |
315 /* Finally, pop it up. */ | |
316 XtPopup (shell, XtGrabNonexclusive); | |
317 } | |
318 else | |
319 #endif /* LWLIB_DIALOGS_ATHENA */ | |
320 XtManageChild (widget); | |
321 } | |
322 else | |
323 { | |
324 #ifdef LWLIB_DIALOGS_ATHENA | |
325 if (XtIsSubclass (widget, dialogWidgetClass)) | |
326 XtUnmanageChild (XtParent (widget)); | |
327 else | |
328 #endif | |
329 XtUnmanageChild (widget); | |
330 } | |
331 } | |
332 | |
333 | |
334 #ifdef LWLIB_DIALOGS_ATHENA | |
335 /* Dialog boxes */ | |
336 | |
337 static char overrideTrans[] = | |
338 "<Message>WM_PROTOCOLS: lwlib_delete_dialog()"; | |
339 static XtActionProc wm_delete_window (Widget shell, XtPointer closure, | |
340 XtPointer call_data); | |
341 static XtActionsRec xaw_actions [] = { | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
342 {"lwlib_delete_dialog", (XtActionProc) wm_delete_window} |
428 | 343 }; |
344 static Boolean actions_initted = False; | |
345 | |
346 static Widget | |
442 | 347 make_dialog (const char* name, Widget parent, Boolean pop_up_p, |
2286 | 348 const char* shell_title, const char* UNUSED (icon_name), |
428 | 349 Boolean text_input_slot, |
350 Boolean radio_box, Boolean list, | |
351 int left_buttons, int right_buttons) | |
352 { | |
353 Arg av [20]; | |
354 int ac = 0; | |
355 int i, bc; | |
356 char button_name [255]; | |
357 Widget shell; | |
358 Widget dialog; | |
359 Widget button; | |
360 XtTranslations override; | |
361 | |
362 if (! pop_up_p) abort (); /* not implemented */ | |
363 if (text_input_slot) abort (); /* not implemented */ | |
364 if (radio_box) abort (); /* not implemented */ | |
365 if (list) abort (); /* not implemented */ | |
366 | |
367 if (! actions_initted) | |
368 { | |
369 XtAppContext app = XtWidgetToApplicationContext (parent); | |
370 XtAppAddActions (app, xaw_actions, | |
371 sizeof (xaw_actions) / sizeof (xaw_actions[0])); | |
372 actions_initted = True; | |
373 } | |
374 | |
375 override = XtParseTranslationTable (overrideTrans); | |
376 | |
377 ac = 0; | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
378 XtSetArg (av[ac], XtNtitle, shell_title); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
379 XtSetArg (av[ac], XtNallowShellResize, True); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
380 XtSetArg (av[ac], XtNtransientFor, parent); ac++; |
428 | 381 shell = XtCreatePopupShell ("dialog", transientShellWidgetClass, |
382 parent, av, ac); | |
383 XtOverrideTranslations (shell, override); | |
384 | |
385 ac = 0; | |
386 dialog = XtCreateManagedWidget (name, dialogWidgetClass, shell, av, ac); | |
387 | |
388 bc = 0; | |
389 button = 0; | |
390 for (i = 0; i < left_buttons; i++) | |
391 { | |
392 ac = 0; | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
393 XtSetArg (av [ac], XtNfromHoriz, button); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
394 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
395 XtSetArg (av [ac], XtNright, XtChainLeft); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
396 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
397 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
398 XtSetArg (av [ac], XtNresizable, True); ac++; |
428 | 399 sprintf (button_name, "button%d", ++bc); |
400 button = XtCreateManagedWidget (button_name, commandWidgetClass, | |
401 dialog, av, ac); | |
402 } | |
403 if (right_buttons) | |
404 { | |
405 /* Create a separator | |
406 | |
407 I want the separator to take up the slack between the buttons on | |
408 the right and the buttons on the left (that is I want the buttons | |
409 after the separator to be packed against the right edge of the | |
410 window) but I can't seem to make it do it. | |
411 */ | |
412 ac = 0; | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
413 XtSetArg (av [ac], XtNfromHoriz, button); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
414 /* XtSetArg (av [ac], XtNfromVert, XtNameToWidget (dialog, "label")); ac++; */ |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
415 XtSetArg (av [ac], XtNleft, XtChainLeft); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
416 XtSetArg (av [ac], XtNright, XtChainRight); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
417 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
418 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
419 XtSetArg (av [ac], XtNlabel, ""); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
420 XtSetArg (av [ac], XtNwidth, 30); ac++; /* #### aaack!! */ |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
421 XtSetArg (av [ac], XtNborderWidth, 0); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
422 XtSetArg (av [ac], XtNshapeStyle, XmuShapeRectangle); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
423 XtSetArg (av [ac], XtNresizable, False); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
424 XtSetArg (av [ac], XtNsensitive, False); ac++; |
428 | 425 button = XtCreateManagedWidget ("separator", |
426 /* labelWidgetClass, */ | |
427 /* This has to be Command to fake out | |
428 the Dialog widget... */ | |
429 commandWidgetClass, | |
430 dialog, av, ac); | |
431 } | |
432 for (i = 0; i < right_buttons; i++) | |
433 { | |
434 ac = 0; | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
435 XtSetArg (av [ac], XtNfromHoriz, button); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
436 XtSetArg (av [ac], XtNleft, XtChainRight); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
437 XtSetArg (av [ac], XtNright, XtChainRight); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
438 XtSetArg (av [ac], XtNtop, XtChainBottom); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
439 XtSetArg (av [ac], XtNbottom, XtChainBottom); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
440 XtSetArg (av [ac], XtNresizable, True); ac++; |
428 | 441 sprintf (button_name, "button%d", ++bc); |
442 button = XtCreateManagedWidget (button_name, commandWidgetClass, | |
443 dialog, av, ac); | |
444 } | |
445 | |
446 return dialog; | |
447 } | |
448 | |
449 Widget | |
450 xaw_create_dialog (widget_instance* instance) | |
451 { | |
452 char *name = instance->info->type; | |
453 Widget parent = instance->parent; | |
454 Widget widget; | |
455 Boolean pop_up_p = instance->pop_up_p; | |
442 | 456 const char *shell_name = 0; |
457 const char *icon_name = 0; | |
428 | 458 Boolean text_input_slot = False; |
459 Boolean radio_box = False; | |
460 Boolean list = False; | |
461 int total_buttons; | |
462 int left_buttons = 0; | |
463 int right_buttons = 1; | |
464 | |
465 switch (name [0]) { | |
466 case 'E': case 'e': | |
467 icon_name = "dbox-error"; | |
468 shell_name = "Error"; | |
469 break; | |
470 | |
471 case 'I': case 'i': | |
472 icon_name = "dbox-info"; | |
473 shell_name = "Information"; | |
474 break; | |
475 | |
476 case 'L': case 'l': | |
477 list = True; | |
478 icon_name = "dbox-question"; | |
479 shell_name = "Prompt"; | |
480 break; | |
481 | |
482 case 'P': case 'p': | |
483 text_input_slot = True; | |
484 icon_name = "dbox-question"; | |
485 shell_name = "Prompt"; | |
486 break; | |
487 | |
488 case 'Q': case 'q': | |
489 icon_name = "dbox-question"; | |
490 shell_name = "Question"; | |
491 break; | |
492 } | |
493 | |
494 total_buttons = name [1] - '0'; | |
495 | |
496 if (name [3] == 'T' || name [3] == 't') | |
497 { | |
498 text_input_slot = False; | |
499 radio_box = True; | |
500 } | |
501 else if (name [3]) | |
502 right_buttons = name [4] - '0'; | |
503 | |
504 left_buttons = total_buttons - right_buttons; | |
505 | |
506 widget = make_dialog (name, parent, pop_up_p, | |
507 shell_name, icon_name, text_input_slot, radio_box, | |
508 list, left_buttons, right_buttons); | |
509 | |
510 return widget; | |
511 } | |
512 #endif /* LWLIB_DIALOGS_ATHENA */ | |
513 | |
514 | |
515 static void | |
516 xaw_generic_callback (Widget widget, XtPointer closure, XtPointer call_data) | |
517 { | |
518 widget_instance *instance = (widget_instance *) closure; | |
519 Widget instance_widget; | |
520 LWLIB_ID id; | |
521 XtPointer user_data; | |
522 #ifdef LWLIB_WIDGETS_ATHENA | |
523 /* We want the selected status to change only when we decide it | |
524 should change. Yuck but correct. */ | |
525 if (XtIsSubclass (widget, toggleWidgetClass)) | |
526 { | |
527 Boolean check; | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
528 Arg al [1]; |
428 | 529 |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
530 XtSetArg (al [0], XtNstate, &check); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
531 XtGetValues (widget, al, 1); |
428 | 532 |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
533 XtSetArg (al [0], XtNstate, !check); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
534 XtSetValues (widget, al, 1); |
428 | 535 } |
536 #endif /* LWLIB_WIDGETS_ATHENA */ | |
537 lw_internal_update_other_instances (widget, closure, call_data); | |
538 | |
539 if (! instance) | |
540 return; | |
541 if (widget->core.being_destroyed) | |
542 return; | |
543 | |
544 instance_widget = instance->widget; | |
545 if (!instance_widget) | |
546 return; | |
547 | |
548 id = instance->info->id; | |
549 | |
550 #if 0 | |
551 user_data = NULL; | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
552 { |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
553 Arg al [1]; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
554 XtSetArg (al [0], XtNuserData, &user_data); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
555 XtGetValues (widget, al, 1); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
556 } |
428 | 557 #else |
558 /* Damn! Athena doesn't give us a way to hang our own data on the | |
559 buttons, so we have to go find it... I guess this assumes that | |
560 all instances of a button have the same call data. | |
561 | |
562 ... Which is a totally bogus assumption --andyp */ | |
563 { | |
564 widget_value *val = instance->info->val; | |
565 /* If the widget is a buffer/gutter widget then we already have | |
566 the one we are looking for, so don't try and descend the widget | |
567 tree. */ | |
568 if (val->contents) | |
569 { | |
570 char *name = XtName (widget); | |
571 val = val->contents; | |
572 while (val) | |
573 { | |
574 if (val->name && !strcmp (val->name, name)) | |
575 break; | |
576 val = val->next; | |
577 } | |
578 if (! val) abort (); | |
579 } | |
580 user_data = val->call_data; | |
581 } | |
582 #endif | |
583 | |
584 if (instance->info->selection_cb) | |
585 instance->info->selection_cb (widget, id, user_data); | |
586 } | |
587 | |
588 #ifdef LWLIB_DIALOGS_ATHENA | |
589 | |
590 static XtActionProc | |
2286 | 591 wm_delete_window (Widget shell, XtPointer UNUSED (closure), |
592 XtPointer UNUSED (call_data)) | |
428 | 593 { |
594 LWLIB_ID id; | |
595 Widget *kids = 0; | |
596 Widget widget; | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
597 Arg al [1]; |
428 | 598 if (! XtIsSubclass (shell, shellWidgetClass)) |
599 abort (); | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
600 XtSetArg (al [0], XtNchildren, &kids); |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
601 XtGetValues (shell, al, 1); |
3958 | 602 if (!kids || !*kids) abort (); |
603 | |
604 for (widget = *kids; | |
605 widget && ! XtIsSubclass (widget, dialogWidgetClass); | |
606 widget = *++kids) | |
607 ; | |
608 if (!widget) abort (); | |
609 | |
428 | 610 id = lw_get_widget_id (widget); |
611 if (! id) abort (); | |
612 | |
613 { | |
614 widget_info *info = lw_get_widget_info (id); | |
615 if (! info) abort (); | |
616 if (info->selection_cb) | |
617 info->selection_cb (widget, id, (XtPointer) -1); | |
618 } | |
619 | |
620 lw_destroy_all_widgets (id); | |
621 return NULL; | |
622 } | |
623 | |
624 #endif /* LWLIB_DIALOGS_ATHENA */ | |
625 | |
626 | |
627 /* Scrollbars */ | |
628 | |
629 #ifdef LWLIB_SCROLLBARS_ATHENA | |
630 static void | |
631 xaw_scrollbar_scroll (Widget widget, XtPointer closure, XtPointer call_data) | |
632 { | |
633 widget_instance *instance = (widget_instance *) closure; | |
634 LWLIB_ID id; | |
635 scroll_event event_data; | |
636 | |
637 if (!instance || widget->core.being_destroyed) | |
638 return; | |
639 | |
640 id = instance->info->id; | |
641 event_data.slider_value = (int) call_data; | |
642 event_data.time = 0; | |
643 | |
644 if ((int) call_data > 0) | |
645 /* event_data.action = SCROLLBAR_PAGE_DOWN;*/ | |
646 event_data.action = SCROLLBAR_LINE_DOWN; | |
647 else | |
648 /* event_data.action = SCROLLBAR_PAGE_UP;*/ | |
649 event_data.action = SCROLLBAR_LINE_UP; | |
650 | |
651 if (instance->info->pre_activate_cb) | |
652 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data); | |
653 } | |
654 | |
655 static void | |
656 xaw_scrollbar_jump (Widget widget, XtPointer closure, XtPointer call_data) | |
657 { | |
658 widget_instance *instance = (widget_instance *) closure; | |
659 LWLIB_ID id; | |
660 scroll_event event_data; | |
661 scrollbar_values *val = | |
662 (scrollbar_values *) instance->info->val->scrollbar_data; | |
663 float percent; | |
664 | |
665 if (!instance || widget->core.being_destroyed) | |
666 return; | |
667 | |
668 id = instance->info->id; | |
669 | |
670 percent = * (float *) call_data; | |
671 event_data.slider_value = | |
672 (int) (percent * (float) (val->maximum - val->minimum)) + val->minimum; | |
673 | |
674 event_data.time = 0; | |
675 event_data.action = SCROLLBAR_DRAG; | |
676 | |
677 if (instance->info->pre_activate_cb) | |
678 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data); | |
679 } | |
680 | |
681 static Widget | |
682 xaw_create_scrollbar (widget_instance *instance, int vertical) | |
683 { | |
684 Arg av[10]; | |
685 int ac = 0; | |
686 | |
687 static XtCallbackRec jumpCallbacks[2] = | |
688 { {xaw_scrollbar_jump, NULL}, {NULL, NULL} }; | |
689 | |
690 static XtCallbackRec scrollCallbacks[2] = | |
691 { {xaw_scrollbar_scroll, NULL}, {NULL, NULL} }; | |
692 | |
693 jumpCallbacks[0].closure = scrollCallbacks[0].closure = (XtPointer) instance; | |
694 | |
695 /* #### This is tacked onto the with and height and completely | |
696 screws our geometry management. We should probably make the | |
697 top-level aware of this so that people could have a border but so | |
698 few people use the Athena scrollbar now that it really isn't | |
699 worth the effort, at least not at the moment. */ | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
700 XtSetArg (av [ac], XtNborderWidth, 0); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
701 XtSetArg (av [ac], XtNorientation, |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
702 vertical ? XtorientVertical : XtorientHorizontal); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
703 XtSetArg (av [ac], "jumpProc", jumpCallbacks); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
704 XtSetArg (av [ac], "scrollProc", scrollCallbacks); ac++; |
428 | 705 |
706 return XtCreateWidget (instance->info->name, scrollbarWidgetClass, | |
707 instance->parent, av, ac); | |
708 } | |
709 | |
710 static Widget | |
711 xaw_create_vertical_scrollbar (widget_instance *instance) | |
712 { | |
713 return xaw_create_scrollbar (instance, 1); | |
714 } | |
715 | |
716 static Widget | |
717 xaw_create_horizontal_scrollbar (widget_instance *instance) | |
718 { | |
719 return xaw_create_scrollbar (instance, 0); | |
720 } | |
721 #endif /* LWLIB_SCROLLBARS_ATHENA */ | |
722 | |
723 #ifdef LWLIB_WIDGETS_ATHENA | |
724 /* glyph widgets */ | |
725 static Widget | |
726 xaw_create_button (widget_instance *instance) | |
727 { | |
728 Arg al[20]; | |
729 int ac = 0; | |
730 Widget button = 0; | |
731 widget_value* val = instance->info->val; | |
732 | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
733 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
734 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
735 XtSetArg (al [ac], XtNjustify, XtJustifyCenter); ac++; |
428 | 736 /* The highlight doesn't appear to be dynamically set which makes it |
737 look ugly. I think this may be a LessTif bug but for now we just | |
738 get rid of it. */ | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
739 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);ac++; |
428 | 740 |
741 /* add any args the user supplied for creation time */ | |
742 lw_add_value_args_to_args (val, al, &ac); | |
743 | |
744 if (!val->call_data) | |
3094 | 745 button = XtCreateWidget (val->name, labelWidgetClass, |
428 | 746 instance->parent, al, ac); |
747 | |
748 else | |
749 { | |
750 if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE) | |
751 { | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
752 XtSetArg (al [ac], XtNstate, val->selected); ac++; |
3094 | 753 button = XtCreateWidget |
428 | 754 (val->name, |
755 val->type == TOGGLE_TYPE ? checkboxWidgetClass : radioWidgetClass, | |
756 instance->parent, al, ac); | |
757 } | |
758 else | |
759 { | |
3094 | 760 button = XtCreateWidget (val->name, commandWidgetClass, |
428 | 761 instance->parent, al, ac); |
762 } | |
763 XtRemoveAllCallbacks (button, XtNcallback); | |
764 XtAddCallback (button, XtNcallback, xaw_generic_callback, (XtPointer)instance); | |
765 } | |
766 | |
3094 | 767 /* #### this maybe can be folded into the XtCreateWidget calls above */ |
428 | 768 XtManageChild (button); |
769 | |
770 return button; | |
771 } | |
772 | |
773 static Widget | |
774 xaw_create_label_field (widget_instance *instance) | |
775 { | |
776 return xaw_create_label (instance->parent, instance->info->val); | |
777 } | |
778 | |
779 Widget | |
780 xaw_create_label (Widget parent, widget_value* val) | |
781 { | |
782 Arg al[20]; | |
783 int ac = 0; | |
784 Widget label = 0; | |
785 | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
786 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
787 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
788 XtSetArg (al [ac], XtNjustify, XtJustifyCenter); ac++; |
428 | 789 |
790 /* add any args the user supplied for creation time */ | |
791 lw_add_value_args_to_args (val, al, &ac); | |
792 | |
793 label = XtCreateManagedWidget (val->name, labelWidgetClass, | |
794 parent, al, ac); | |
795 | |
3094 | 796 /* Do it again for arguments that have no effect until the widget is realized. |
797 #### Uh, but the widget isn't realized until later? Do we mean "created"? */ | |
428 | 798 ac = 0; |
799 lw_add_value_args_to_args (val, al, &ac); | |
442 | 800 if (ac > 20) |
801 abort (); /* #### need assert macro in lwlib */ | |
428 | 802 XtSetValues (label, al, ac); |
803 | |
804 return label; | |
805 } | |
806 | |
3094 | 807 static int debug_gauge = 0; |
808 | |
809 static void | |
810 lw_debug_print_xt_arglist (ArgList al, int ac) | |
811 { | |
812 int i; | |
813 for (i = 0; i < ac; i++) | |
814 fprintf (stderr, "Widget has arg %s with value %lu.\n", | |
815 al[i].name, (unsigned long) al[i].value); | |
816 } | |
817 | |
818 static void | |
819 lw_debug_print_class_resources (WidgetClass class_) | |
820 { | |
821 Cardinal i; | |
822 do { | |
823 Cardinal m, n = class_->core_class.num_resources; | |
824 XtResourceList rl; | |
825 fprintf (stderr, "Class is %s (%p/%p) with %d resources.\n", | |
826 class_->core_class.class_name, class_, &(class_->core_class), n); | |
827 fprintf (stderr, " Class's resources are at %p. Converting...\n", | |
828 class_->core_class.resources); | |
829 /* resources may be compiled to an internal format */ | |
830 XtGetResourceList (class_, &rl, &m); | |
831 for (i = 0; i < m; i++) | |
832 fprintf (stderr, | |
833 " Class has a %s resource of type %s initialized from %s.\n", | |
834 rl[i].resource_class, rl[i].resource_type, rl[i].default_type); | |
835 /* special cases for commonly problematic resources */ | |
836 for (i = 0; i < m; i++) | |
837 { | |
838 if (!strcmp (rl[i].resource_class, "Font")) | |
839 { | |
840 fprintf (stderr, " Class has a Font resource.\n"); | |
841 fprintf (stderr, " Font resource is %s.\n", | |
842 (char *) rl[i].default_addr); | |
843 } | |
844 if (!strcmp (rl[i].resource_class, "FontSet")) | |
845 { | |
846 fprintf (stderr, " Class has a FontSet resource.\n"); | |
847 fprintf (stderr, " FontSet resource is %s.\n", | |
848 (char *) rl[i].default_addr); | |
849 } | |
850 if (!strcmp (rl[i].resource_class, "International")) | |
851 { | |
852 fprintf (stderr, " Class has an International resource.\n"); | |
3374 | 853 fprintf (stderr, " International resource is %p.\n", |
854 rl[i].default_addr); | |
3094 | 855 } |
856 } | |
857 class_ = class_->core_class.superclass; | |
858 } while (class_ != NULL); | |
859 } | |
860 | |
428 | 861 static Widget |
862 xaw_create_progress (widget_instance *instance) | |
863 { | |
864 Arg al[20]; | |
865 int ac = 0; | |
866 Widget scale = 0; | |
867 widget_value* val = instance->info->val; | |
442 | 868 #if 0 /* This looks too awful, although more correct. */ |
428 | 869 if (!val->call_data) |
870 { | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
871 XtSetArg (al [ac], XtNsensitive, False); ac++; |
428 | 872 } |
873 else | |
874 { | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
875 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++; |
428 | 876 } |
442 | 877 #else |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
878 XtSetArg (al [ac], XtNsensitive, True); ac++; |
442 | 879 #endif |
880 | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
881 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
882 XtSetArg (al [ac], XtNorientation, XtorientHorizontal); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
883 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0);ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
884 XtSetArg (al [ac], XtNntics, (Cardinal)10);ac++; |
428 | 885 |
886 /* add any args the user supplied for creation time */ | |
887 lw_add_value_args_to_args (val, al, &ac); | |
888 | |
3094 | 889 if (debug_gauge > 1) |
890 lw_debug_print_class_resources (gaugeWidgetClass); | |
891 if (debug_gauge > 0) | |
892 lw_debug_print_xt_arglist (al, ac); | |
893 | |
894 scale = XtCreateWidget (val->name, gaugeWidgetClass, | |
895 instance->parent, al, ac); | |
896 | |
428 | 897 /* add the callback */ |
898 if (val->call_data) | |
3094 | 899 XtAddCallback (scale, XtNgetValue, xaw_generic_callback, |
900 (XtPointer) instance); | |
428 | 901 |
3094 | 902 /* #### this maybe can be folded into the XtCreateWidget call above */ |
428 | 903 XtManageChild (scale); |
904 | |
905 return scale; | |
906 } | |
907 | |
460 | 908 #if defined(LWLIB_WIDGETS_ATHENA) |
442 | 909 #define TEXT_BUFFER_SIZE 128 |
428 | 910 static Widget |
911 xaw_create_text_field (widget_instance *instance) | |
912 { | |
913 Arg al[20]; | |
914 int ac = 0; | |
915 Widget text = 0; | |
916 widget_value* val = instance->info->val; | |
917 | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
918 XtSetArg (al [ac], XtNsensitive, val->enabled); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
919 XtSetArg (al [ac], XtNmappedWhenManaged, FALSE); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
920 XtSetArg (al [ac], XtNhighlightThickness, (Dimension)0); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
921 XtSetArg (al [ac], XtNtype, XawAsciiString); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
922 XtSetArg (al [ac], XtNeditType, XawtextEdit); ac++; |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
923 XtSetArg (al [ac], XtNuseStringInPlace, False); ac++; |
442 | 924 #if 0 |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
925 XtSetArg (al [ac], XtNlength, TEXT_BUFFER_SIZE); ac++; |
442 | 926 #endif |
927 if (val->value) | |
928 { | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
929 XtSetArg (al [ac], XtNstring, val->value); ac++; |
442 | 930 } |
428 | 931 |
932 /* add any args the user supplied for creation time */ | |
933 lw_add_value_args_to_args (val, al, &ac); | |
934 | |
3094 | 935 text = XtCreateWidget (val->name, asciiTextWidgetClass, |
428 | 936 instance->parent, al, ac); |
442 | 937 |
938 /* add the callback */ | |
939 if (val->call_data) | |
940 XtAddCallback (text, XtNgetValue, xaw_generic_callback, (XtPointer)instance); | |
941 | |
428 | 942 XtManageChild (text); |
943 | |
944 return text; | |
945 } | |
946 #endif | |
442 | 947 |
428 | 948 #endif /* LWLIB_WIDGETS_ATHENA */ |
949 | |
450 | 950 const widget_creation_entry |
428 | 951 xaw_creation_table [] = |
952 { | |
953 #ifdef LWLIB_SCROLLBARS_ATHENA | |
954 {"vertical-scrollbar", xaw_create_vertical_scrollbar }, | |
955 {"horizontal-scrollbar", xaw_create_horizontal_scrollbar }, | |
956 #endif | |
957 #ifdef LWLIB_WIDGETS_ATHENA | |
958 {"button", xaw_create_button }, | |
4522
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
959 { "label", xaw_create_label_field }, |
fc7067b7f407
Backout last patch; forgot to specify file.
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4521
diff
changeset
|
960 {"text-field", xaw_create_text_field }, |
428 | 961 {"progress", xaw_create_progress }, |
962 #endif | |
963 {NULL, NULL} | |
964 }; | |
965 |