Mercurial > hg > xemacs-beta
annotate lwlib/lwlib-Xm.c @ 5809:2f22818d92d4
#'x-store-cutbuffer-internal, correct order of type checks vs. member accesses
src/ChangeLog addition:
2014-09-06 Aidan Kehoe <kehoea@parhasard.net>
* select-x.c (Fx_store_cutbuffer_internal):
Correct the order of XSTRING_{DATA,LENGTH} vs. CHECK_STRING, make
sure the former is after the latter, avoiding crashes when passing
in arguments of the wrong type, or when ERROR_CHECK_STRUCTURES is
defined.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Sat, 06 Sep 2014 14:30:15 +0100 |
parents | ade4c7e2c6cb |
children |
rev | line source |
---|---|
428 | 1 /* The lwlib interface to Motif widgets. |
2 Copyright (C) 1992, 1993, 1994 Lucid, Inc. | |
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp. | |
4 | |
5 This file is part of the Lucid Widget Library. | |
6 | |
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
7 The Lucid Widget Library is free software: you can redistribute it |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
8 and/or modify it under the terms of the GNU General Public License as |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
9 published by the Free Software Foundation, either version 3 of the |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
10 License, or (at your option) any later version. |
428 | 11 |
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
12 The Lucid Widget Library is distributed in the hope that it will be |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
13 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
15 General Public License for more details. |
428 | 16 |
17 You should have received a copy of the GNU General Public License | |
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
18 along with the Lucid Widget Library. If not, see |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4528
diff
changeset
|
19 <http://www.gnu.org/licenses/>. */ |
428 | 20 |
21 #include <config.h> | |
22 #include <stdlib.h> | |
23 #include <string.h> | |
24 #include <stdio.h> | |
25 #include <limits.h> | |
26 #ifdef HAVE_UNISTD_H | |
27 #include <unistd.h> | |
28 #endif | |
29 | |
30 #include <X11/StringDefs.h> | |
31 #include <X11/IntrinsicP.h> | |
32 #include <X11/ObjectP.h> | |
33 #include <X11/CoreP.h> | |
34 #include <X11/CompositeP.h> | |
35 | |
36 #include "lwlib-Xm.h" | |
37 #include "lwlib-utils.h" | |
38 | |
39 #include <Xm/Xm.h> | |
40 #include <Xm/BulletinB.h> | |
41 #include <Xm/CascadeB.h> | |
42 #include <Xm/DrawingA.h> | |
43 #include <Xm/FileSB.h> | |
44 #include <Xm/Label.h> | |
45 #include <Xm/List.h> | |
46 #include <Xm/MenuShell.h> | |
47 #include <Xm/MessageB.h> | |
48 #include <Xm/PushB.h> | |
49 #include <Xm/PushBG.h> | |
50 #include <Xm/ArrowB.h> | |
51 #include <Xm/ScrollBar.h> | |
52 #include <Xm/SelectioB.h> | |
53 #include <Xm/Text.h> | |
54 #include <Xm/TextF.h> | |
55 #include <Xm/ToggleB.h> | |
56 #include <Xm/ToggleBG.h> | |
57 #include <Xm/RowColumn.h> | |
58 #include <Xm/ScrolledW.h> | |
59 #include <Xm/Separator.h> | |
60 #include <Xm/DialogS.h> | |
61 #include <Xm/Form.h> | |
62 #ifdef LWLIB_WIDGETS_MOTIF | |
63 #include <Xm/Scale.h> | |
64 #if XmVERSION > 1 | |
65 #include <Xm/ComboBoxP.h> | |
66 #endif | |
67 #endif | |
68 | |
69 #ifdef LWLIB_MENUBARS_MOTIF | |
70 static void xm_pull_down_callback (Widget, XtPointer, XtPointer); | |
71 #endif | |
72 static void xm_internal_update_other_instances (Widget, XtPointer, | |
73 XtPointer); | |
1261 | 74 /* static void xm_pop_down_callback (Widget, XtPointer, XtPointer); */ |
428 | 75 static void xm_generic_callback (Widget, XtPointer, XtPointer); |
2286 | 76 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_WIDGETS_MOTIF) |
428 | 77 static void mark_dead_instance_destroyed (Widget widget, XtPointer closure, |
78 XtPointer call_data); | |
79 static void xm_nosel_callback (Widget, XtPointer, XtPointer); | |
80 #endif | |
81 #ifdef LWLIB_SCROLLBARS_MOTIF | |
82 static void xm_scrollbar_callback (Widget, XtPointer, XtPointer); | |
83 #endif | |
84 | |
85 #ifdef LWLIB_MENUBARS_MOTIF | |
86 static void | |
87 xm_update_menu (widget_instance* instance, Widget widget, widget_value* val, | |
88 Boolean deep_p); | |
89 #endif | |
90 | |
91 /* Structures to keep destroyed instances */ | |
92 typedef struct _destroyed_instance | |
93 { | |
94 char* name; | |
95 char* type; | |
96 Widget widget; | |
97 Widget parent; | |
98 Boolean pop_up_p; | |
99 struct _destroyed_instance* next; | |
100 } destroyed_instance; | |
101 | |
102 static destroyed_instance* | |
103 all_destroyed_instances = NULL; | |
104 | |
105 /* Utility function. */ | |
106 static char * | |
107 safe_strdup (char* s) | |
108 { | |
109 char *result; | |
110 if (! s) return 0; | |
111 result = (char *) malloc (strlen (s) + 1); | |
112 if (! result) | |
113 return 0; | |
114 strcpy (result, s); | |
115 return result; | |
116 } | |
117 | |
118 static destroyed_instance* | |
119 make_destroyed_instance (char* name, char* type, Widget widget, Widget parent, | |
120 Boolean pop_up_p) | |
121 { | |
122 destroyed_instance* instance = | |
123 (destroyed_instance*) malloc (sizeof (destroyed_instance)); | |
124 instance->name = safe_strdup (name); | |
125 instance->type = safe_strdup (type); | |
126 instance->widget = widget; | |
127 instance->parent = parent; | |
128 instance->pop_up_p = pop_up_p; | |
129 instance->next = NULL; | |
130 return instance; | |
131 } | |
132 | |
1330 | 133 #ifdef LWLIB_DIALOGS_MOTIF |
134 | |
428 | 135 static void |
136 free_destroyed_instance (destroyed_instance* instance) | |
137 { | |
138 free (instance->name); | |
139 free (instance->type); | |
140 free (instance); | |
141 } | |
142 | |
1330 | 143 #endif /* LWLIB_DIALOGS_MOTIF */ |
144 | |
428 | 145 /* motif utility functions */ |
146 Widget | |
147 first_child (Widget widget) | |
148 { | |
149 return ((CompositeWidget)widget)->composite.children [0]; | |
150 } | |
151 | |
152 Boolean | |
153 lw_motif_widget_p (Widget widget) | |
154 { | |
155 return | |
156 #ifdef LWLIB_DIALOGS_MOTIF | |
157 XtClass (widget) == xmDialogShellWidgetClass || | |
158 #endif | |
159 XmIsPrimitive (widget) || XmIsManager (widget) || XmIsGadget (widget); | |
160 } | |
161 | |
162 static char * | |
163 resource_string (Widget widget, char *name) | |
164 { | |
165 XtResource resource; | |
166 char *result = NULL; | |
167 | |
168 resource.resource_name = "labelString"; | |
169 resource.resource_class = "LabelString"; /* #### should be Xmsomething... */ | |
170 resource.resource_type = XtRString; | |
171 resource.resource_size = sizeof (String); | |
172 resource.resource_offset = 0; | |
173 resource.default_type = XtRImmediate; | |
174 resource.default_addr = 0; | |
175 | |
176 XtGetSubresources (widget, (XtPointer)&result, name, | |
177 name, &resource, 1, NULL, 0); | |
178 return result; | |
179 } | |
180 | |
181 | |
182 | |
183 #ifdef LWLIB_DIALOGS_MOTIF | |
184 | |
185 static Boolean | |
186 is_in_dialog_box (Widget w) | |
187 { | |
188 Widget wmshell; | |
189 | |
190 wmshell = XtParent (w); | |
191 while (wmshell && (XtClass (wmshell) != xmDialogShellWidgetClass)) | |
192 wmshell = XtParent (wmshell); | |
193 | |
194 if (wmshell && XtClass (wmshell) == xmDialogShellWidgetClass) | |
195 return True; | |
196 else | |
197 return False; | |
198 } | |
199 | |
200 #endif /* LWLIB_DIALOGS_MOTIF */ | |
201 | |
202 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF) || defined (LWLIB_WIDGETS_MOTIF) | |
203 | |
204 /* update the label of anything subclass of a label */ | |
205 static void | |
2311 | 206 xm_update_label (widget_instance* UNUSED (instance), Widget widget, |
207 widget_value* val) | |
428 | 208 { |
209 XmString built_string = NULL; | |
210 XmString key_string = NULL; | |
211 XmString val_string = NULL; | |
212 XmString name_string = NULL; | |
213 Arg al [20]; | |
214 int ac = 0; | |
215 int type; | |
216 | |
217 /* Don't clobber pixmap types. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
218 Xt_GET_VALUE (widget, XmNlabelType, &type); |
428 | 219 |
220 if (type == XmPIXMAP) | |
221 return; | |
222 | |
223 if (val->value) | |
224 { | |
446 | 225 /* #### Temporary fix. I though Motif was supposed to grok %_ |
226 type things. */ | |
227 lw_remove_accelerator_spec (val->value); | |
228 | |
428 | 229 #ifdef LWLIB_DIALOGS_MOTIF |
230 /* | |
231 * Sigh. The main text of a label is the name field for menubar | |
232 * entries. The value field is a possible additional field to be | |
233 * concatenated on to the name field. HOWEVER, with dialog boxes | |
234 * the value field is the complete text which is supposed to be | |
235 * displayed as the label. Yuck. | |
236 */ | |
237 if (is_in_dialog_box (widget)) | |
238 { | |
239 char *value_name = NULL; | |
240 | |
241 value_name = resource_string (widget, val->value); | |
242 if (!value_name) | |
243 value_name = val->value; | |
244 | |
245 built_string = | |
246 XmStringCreateLtoR (value_name, XmSTRING_DEFAULT_CHARSET); | |
247 } | |
248 else | |
249 #endif /* LWLIB_DIALOGS_MOTIF */ | |
250 { | |
251 char *value_name = NULL; | |
252 char *res_name = NULL; | |
253 | |
254 res_name = resource_string (widget, val->name); | |
255 /* Concatenating the value with itself seems just plain daft. */ | |
256 if (!res_name) | |
257 { | |
258 built_string = | |
259 XmStringCreateLtoR (val->value, XmSTRING_DEFAULT_CHARSET); | |
260 } | |
261 else | |
262 { | |
263 name_string = | |
264 XmStringCreateLtoR (res_name, XmSTRING_DEFAULT_CHARSET); | |
442 | 265 |
428 | 266 value_name = XtMalloc (strlen (val->value) + 2); |
267 *value_name = 0; | |
268 strcat (value_name, " "); | |
269 strcat (value_name, val->value); | |
442 | 270 |
428 | 271 val_string = |
272 XmStringCreateLtoR (value_name, XmSTRING_DEFAULT_CHARSET); | |
442 | 273 |
428 | 274 built_string = |
275 XmStringConcat (name_string, val_string); | |
442 | 276 |
428 | 277 XtFree (value_name); |
278 } | |
279 } | |
280 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
281 Xt_SET_ARG (al [ac], XmNlabelString, built_string); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
282 Xt_SET_ARG (al [ac], XmNlabelType, XmSTRING); ac++; |
428 | 283 } |
284 | |
285 if (val->key) | |
286 { | |
287 key_string = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET); | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
288 Xt_SET_ARG (al [ac], XmNacceleratorText, key_string); ac++; |
428 | 289 } |
290 | |
291 if (ac) | |
292 XtSetValues (widget, al, ac); | |
293 | |
294 if (built_string) | |
295 XmStringFree (built_string); | |
296 | |
297 if (key_string) | |
298 XmStringFree (key_string); | |
299 | |
300 if (name_string) | |
301 XmStringFree (name_string); | |
302 | |
303 if (val_string) | |
304 XmStringFree (val_string); | |
305 } | |
306 | |
903 | 307 static void |
308 xm_safe_update_label (widget_instance* instance, Widget widget, widget_value* val) | |
309 { | |
310 /* Don't clobber non-labels. */ | |
311 if (XtIsSubclass (widget, xmLabelWidgetClass)) | |
312 xm_update_label (instance, widget, val); | |
313 } | |
314 | |
428 | 315 #endif /* defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF) */ |
316 | |
317 /* update of list */ | |
318 static void | |
319 xm_update_list (widget_instance* instance, Widget widget, widget_value* val) | |
320 { | |
321 widget_value* cur; | |
322 int i; | |
323 XtRemoveAllCallbacks (widget, XmNsingleSelectionCallback); | |
324 XtAddCallback (widget, XmNsingleSelectionCallback, xm_generic_callback, | |
325 instance); | |
326 for (cur = val->contents, i = 0; cur; cur = cur->next) | |
327 if (cur->value) | |
328 { | |
329 XmString xmstr = XmStringCreate (cur->value, XmSTRING_DEFAULT_CHARSET); | |
330 i += 1; | |
331 XmListAddItem (widget, xmstr, 0); | |
332 if (cur->selected) | |
333 XmListSelectPos (widget, i, False); | |
334 XmStringFree (xmstr); | |
335 } | |
336 } | |
337 | |
338 /* update of buttons */ | |
339 static void | |
340 xm_update_pushbutton (widget_instance* instance, Widget widget, | |
2286 | 341 widget_value* UNUSED (val)) |
428 | 342 { |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
343 Xt_SET_VALUE (widget, XmNalignment, XmALIGNMENT_CENTER); |
428 | 344 XtRemoveAllCallbacks (widget, XmNactivateCallback); |
345 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance); | |
346 } | |
347 | |
1281 | 348 #ifdef LWLIB_WIDGETS_MOTIF |
639 | 349 static void |
2311 | 350 xm_update_progress (widget_instance* UNUSED (instance), Widget scale, |
351 widget_value* val) | |
639 | 352 { |
353 Arg al[20]; | |
354 int ac = 0; | |
355 Dimension height = 0; | |
356 Dimension width = 0; | |
357 if (!val->call_data) | |
358 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
359 Xt_SET_ARG (al [ac], XmNeditable, False); ac++; |
639 | 360 } |
361 else | |
362 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
363 Xt_SET_ARG (al [ac], XmNeditable, val->enabled); ac++; |
639 | 364 } |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
365 height = (Dimension) lw_get_value_arg (val, XtNheight); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
366 width = (Dimension) lw_get_value_arg (val, XtNwidth); |
639 | 367 if (height > 0) |
368 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
369 Xt_SET_ARG (al [ac], XmNscaleHeight, height); ac++; |
639 | 370 } |
371 if (width > 0) | |
372 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
373 Xt_SET_ARG (al [ac], XmNscaleWidth, width); ac++; |
639 | 374 } |
375 | |
4515
bbce7f6de2d6
Fix typo in XtSetValues in xm_update_progress().
Stephen J. Turnbull <stephen@xemacs.org>
parents:
2311
diff
changeset
|
376 XtSetValues (scale, al, ac); |
639 | 377 } |
1281 | 378 #endif /* LWLIB_WIDGETS_MOTIF */ |
639 | 379 |
428 | 380 #ifdef LWLIB_MENUBARS_MOTIF |
381 | |
382 static void | |
383 xm_update_cascadebutton (widget_instance* instance, Widget widget, | |
384 widget_value* val) | |
385 { | |
386 /* Should also rebuild the menu by calling ...update_menu... */ | |
387 if (val | |
388 && val->type == CASCADE_TYPE | |
389 && val->contents | |
390 && val->contents->type == INCREMENTAL_TYPE) | |
391 { | |
392 /* okay, we're now doing a lisp callback to incrementally generate | |
393 more of the menu. */ | |
394 XtRemoveAllCallbacks (widget, XmNcascadingCallback); | |
395 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback, | |
396 instance); | |
397 XtCallCallbacks ((Widget)widget, | |
398 XmNcascadingCallback, | |
399 (XtPointer)val->contents); | |
400 | |
401 } else { | |
402 XtRemoveAllCallbacks (widget, XmNcascadingCallback); | |
403 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback, | |
404 instance); | |
405 } | |
406 } | |
407 | |
408 #endif /* LWLIB_MENUBARS_MOTIF */ | |
409 | |
410 /* update toggle and radiobox */ | |
411 static void | |
412 xm_update_toggle (widget_instance* instance, Widget widget, widget_value* val) | |
413 { | |
414 Arg al [2]; | |
415 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback); | |
416 XtAddCallback (widget, XmNvalueChangedCallback, xm_generic_callback, | |
417 instance); | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
418 Xt_SET_ARG (al [0], XmNset, val->selected); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
419 Xt_SET_ARG (al [1], XmNalignment, XmALIGNMENT_BEGINNING); |
428 | 420 XtSetValues (widget, al, 1); |
421 } | |
422 | |
423 static void | |
424 xm_update_radiobox (widget_instance* instance, Widget widget, | |
425 widget_value* val) | |
426 { | |
427 Widget toggle; | |
428 widget_value* cur; | |
429 | |
430 /* update the callback */ | |
431 XtRemoveAllCallbacks (widget, XmNentryCallback); | |
432 XtAddCallback (widget, XmNentryCallback, xm_generic_callback, instance); | |
433 | |
434 /* first update all the toggles */ | |
435 /* Energize kernel interface is currently bad. It sets the selected widget | |
436 with the selected flag but returns it by its name. So we currently | |
437 have to support both setting the selection with the selected slot | |
438 of val contents and setting it with the "value" slot of val. The latter | |
439 has a higher priority. This to be removed when the kernel is fixed. */ | |
440 for (cur = val->contents; cur; cur = cur->next) | |
441 { | |
442 toggle = XtNameToWidget (widget, cur->value); | |
443 if (toggle) | |
444 { | |
445 Arg al [2]; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
446 Xt_SET_ARG (al [0], XmNsensitive, cur->enabled); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
447 Xt_SET_ARG (al [1], XmNset, (!val->value && cur->selected ? cur->selected : False)); |
428 | 448 XtSetValues (toggle, al, 2); |
449 } | |
450 } | |
451 | |
452 /* The selected was specified by the value slot */ | |
453 if (val->value) | |
454 { | |
455 toggle = XtNameToWidget (widget, val->value); | |
456 if (toggle) | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
457 Xt_SET_VALUE (toggle, XmNset, True); |
428 | 458 } |
459 } | |
460 | |
461 #if defined (LWLIB_WIDGETS_MOTIF) && XmVERSION > 1 | |
462 /* update of combo box */ | |
463 static void | |
464 xm_update_combo_box (widget_instance* instance, Widget widget, widget_value* val) | |
465 { | |
466 widget_value* cur; | |
467 int i; | |
468 XtRemoveAllCallbacks (widget, XmNselectionCallback); | |
469 XtAddCallback (widget, XmNselectionCallback, xm_generic_callback, | |
470 instance); | |
471 for (cur = val->contents, i = 0; cur; cur = cur->next) | |
472 if (cur->value) | |
473 { | |
474 XmString xmstr = XmStringCreate (cur->value, XmSTRING_DEFAULT_CHARSET); | |
475 i += 1; | |
476 XmListAddItem (CB_List (widget), xmstr, 0); | |
477 if (cur->selected) | |
478 XmListSelectPos (CB_List (widget), i, False); | |
479 XmStringFree (xmstr); | |
480 } | |
481 } | |
482 #endif | |
483 | |
484 #ifdef LWLIB_MENUBARS_MOTIF | |
485 | |
486 /* update a popup menu, pulldown menu or a menubar */ | |
487 static void | |
488 make_menu_in_widget (widget_instance* instance, Widget widget, | |
489 widget_value* val) | |
490 { | |
491 Widget* children = 0; | |
492 int num_children; | |
493 int child_index; | |
494 widget_value* cur; | |
495 Widget button = 0; | |
496 Widget menu; | |
497 Arg al [256]; | |
498 int ac; | |
499 Boolean menubar_p = False; | |
500 | |
501 /* Allocate the children array */ | |
502 for (num_children = 0, cur = val; cur; num_children++, cur = cur->next); | |
503 children = (Widget*)XtMalloc (num_children * sizeof (Widget)); | |
504 | |
505 /* tricky way to know if this RowColumn is a menubar or a pulldown... */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
506 Xt_GET_VALUE (widget, XmNisHomogeneous, &menubar_p); |
428 | 507 |
508 /* add the unmap callback for popups and pulldowns */ | |
509 /*** this sounds bogus ***/ | |
510 /* probably because it is -- cet */ | |
511 /* | |
512 if (!menubar_p) | |
513 XtAddCallback (XtParent (widget), XmNpopdownCallback, | |
514 xm_pop_down_callback, (XtPointer)instance); | |
515 */ | |
516 | |
517 num_children = 0; | |
518 for (child_index = 0, cur = val; cur; child_index++, cur = cur->next) | |
519 { | |
520 ac = 0; | |
521 button = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
522 Xt_SET_ARG (al [ac], XmNsensitive, cur->enabled); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
523 Xt_SET_ARG (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
524 Xt_SET_ARG (al [ac], XmNuserData, cur->call_data); ac++; |
428 | 525 |
526 switch (cur->type) | |
527 { | |
528 case PUSHRIGHT_TYPE: | |
529 /* A pushright marker which is not needed for the real Motif | |
530 menubar. */ | |
531 break; | |
532 case SEPARATOR_TYPE: | |
533 ac = 0; | |
534 if (cur->value) | |
535 { | |
536 /* #### - xlwmenu.h supports several types that motif does | |
537 not. Also, motif supports pixmaps w/ type NO_LINE and | |
538 lwlib provides no way to access that functionality. --Stig */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
539 Xt_SET_ARG (al [ac], XmNseparatorType, cur->value); ac++; |
428 | 540 } |
541 button = XmCreateSeparator (widget, "separator", al, ac); | |
542 break; | |
543 case CASCADE_TYPE: | |
544 menu = XmCreatePulldownMenu (widget, "pulldown", NULL, 0); | |
545 make_menu_in_widget (instance, menu, cur->contents); | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
546 Xt_SET_ARG (al [ac], XmNsubMenuId, menu); ac++; |
428 | 547 button = XmCreateCascadeButton (widget, cur->name, al, ac); |
548 | |
903 | 549 xm_safe_update_label (instance, button, cur); |
428 | 550 |
551 XtAddCallback (button, XmNcascadingCallback, xm_pull_down_callback, | |
552 (XtPointer)instance); | |
553 break; | |
554 default: | |
555 if (menubar_p) | |
556 button = XmCreateCascadeButton (widget, cur->name, al, ac); | |
557 else if (!cur->call_data) | |
558 button = XmCreateLabel (widget, cur->name, al, ac); | |
559 else if (cur->type == TOGGLE_TYPE || cur->type == RADIO_TYPE) | |
560 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
561 Xt_SET_ARG (al [ac], XmNindicatorType, |
428 | 562 (cur->type == TOGGLE_TYPE ? |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
563 XmN_OF_MANY : XmONE_OF_MANY)); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
564 Xt_SET_ARG (al [ac], XmNvisibleWhenOff, True); ac++; |
428 | 565 button = XmCreateToggleButtonGadget (widget, cur->name, al, ac); |
566 } | |
567 else | |
568 button = XmCreatePushButtonGadget (widget, cur->name, al, ac); | |
569 | |
903 | 570 xm_safe_update_label (instance, button, cur); |
428 | 571 |
572 /* don't add a callback to a simple label */ | |
573 if (cur->type == TOGGLE_TYPE || cur->type == RADIO_TYPE) | |
574 xm_update_toggle (instance, button, cur); | |
575 else if (cur->call_data) | |
576 XtAddCallback (button, XmNactivateCallback, xm_generic_callback, | |
577 (XtPointer)instance); | |
578 } /* switch (cur->type) */ | |
579 | |
580 if (button) | |
581 children [num_children++] = button; | |
582 } | |
583 | |
584 /* Last entry is the help button. This used be done after managing | |
585 the buttons. The comment claimed that it had to be done this way | |
586 otherwise the menubar ended up only 4 pixels high. That must | |
587 have been in the Old World. In the New World it stays the proper | |
588 height if you don't manage them until after you set this and as a | |
589 bonus the Help menu ends up where it is supposed to. */ | |
590 if (button) | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
591 Xt_SET_VALUE (widget, XmNmenuHelpWidget, button); |
428 | 592 |
593 if (num_children) | |
594 XtManageChildren (children, num_children); | |
595 | |
596 XtFree ((char *) children); | |
597 } | |
598 | |
599 static void | |
600 update_one_menu_entry (widget_instance* instance, Widget widget, | |
601 widget_value* val, Boolean deep_p) | |
602 { | |
603 Arg al [2]; | |
604 int ac; | |
605 Widget menu; | |
606 widget_value* contents; | |
607 | |
608 if (val->change == NO_CHANGE) | |
609 return; | |
610 | |
611 /* update the sensitivity and userdata */ | |
612 /* Common to all widget types */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
613 Xt_SET_ARG (al [0], XmNsensitive, val->enabled); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
614 Xt_SET_ARG (al [1], XmNuserData, val->call_data); |
428 | 615 XtSetValues (widget, al, 2); |
616 | |
617 /* update the menu button as a label. */ | |
618 if (val->change >= VISIBLE_CHANGE) | |
619 { | |
903 | 620 xm_safe_update_label (instance, widget, val); |
621 | |
428 | 622 if (XtClass (widget) == xmToggleButtonWidgetClass |
623 || XtClass (widget) == xmToggleButtonGadgetClass) | |
624 { | |
625 xm_update_toggle (instance, widget, val); | |
626 } | |
627 } | |
628 | |
629 | |
630 /* update the pulldown/pullaside as needed */ | |
631 menu = NULL; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
632 Xt_GET_VALUE (widget, XmNsubMenuId, &menu); |
428 | 633 |
634 contents = val->contents; | |
635 | |
636 if (!menu) | |
637 { | |
638 if (contents) | |
639 { | |
640 menu = XmCreatePulldownMenu (widget, "pulldown", NULL, 0); | |
641 make_menu_in_widget (instance, menu, contents); | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
642 Xt_SET_VALUE (widget, XmNsubMenuId, menu); |
428 | 643 } |
644 } | |
645 else if (!contents) | |
646 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
647 Xt_SET_VALUE (widget, XmNsubMenuId, NULL); |
428 | 648 XtDestroyWidget (menu); |
649 } | |
650 else if (deep_p && contents->change != NO_CHANGE) | |
651 xm_update_menu (instance, menu, val, 1); | |
652 } | |
653 | |
654 static void | |
655 xm_update_menu (widget_instance* instance, Widget widget, widget_value* val, | |
656 Boolean deep_p) | |
657 { | |
658 /* Widget is a RowColumn widget whose contents have to be updated | |
659 * to reflect the list of items in val->contents */ | |
660 if (val->contents->change == STRUCTURAL_CHANGE) | |
661 { | |
662 destroy_all_children (widget); | |
663 make_menu_in_widget (instance, widget, val->contents); | |
664 } | |
665 else | |
666 { | |
667 /* Update all the buttons of the RowColumn in order. */ | |
668 Widget* children; | |
669 unsigned int num_children; | |
670 int i; | |
671 widget_value *cur = 0; | |
672 | |
673 children = XtCompositeChildren (widget, &num_children); | |
674 if (children) | |
675 { | |
676 for (i = 0, cur = val->contents; i < num_children; i++) | |
677 { | |
678 if (!cur) | |
679 abort (); | |
680 /* skip if this is a pushright marker or a separator */ | |
681 if (cur->type == PUSHRIGHT_TYPE || cur->type == SEPARATOR_TYPE) | |
682 { | |
683 cur = cur->next; | |
684 #if 0 | |
685 /* #### - this could puke if you have a separator as the | |
686 last item on a pullright menu. */ | |
687 if (!cur) | |
688 abort (); | |
689 #else | |
690 if (!cur) | |
691 continue; | |
692 #endif | |
693 } | |
694 if (children [i]->core.being_destroyed | |
695 || strcmp (XtName (children [i]), cur->name)) | |
696 continue; | |
697 update_one_menu_entry (instance, children [i], cur, deep_p); | |
698 cur = cur->next; | |
699 } | |
700 XtFree ((char *) children); | |
701 } | |
702 if (cur) | |
703 abort (); | |
704 } | |
705 } | |
706 | |
707 #endif /* LWLIB_MENUBARS_MOTIF */ | |
708 | |
709 | |
710 /* update text widgets */ | |
711 | |
712 static void | |
713 xm_update_text (widget_instance* instance, Widget widget, widget_value* val) | |
714 { | |
438 | 715 XmTextSetString (widget, val->value ? val->value : (char *) ""); |
428 | 716 XtRemoveAllCallbacks (widget, XmNactivateCallback); |
717 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance); | |
718 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback); | |
719 XtAddCallback (widget, XmNvalueChangedCallback, | |
720 xm_internal_update_other_instances, instance); | |
721 } | |
722 | |
723 static void | |
724 xm_update_text_field (widget_instance* instance, Widget widget, | |
725 widget_value* val) | |
726 { | |
438 | 727 XmTextFieldSetString (widget, val->value ? val->value : (char *) ""); |
428 | 728 XtRemoveAllCallbacks (widget, XmNactivateCallback); |
729 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance); | |
730 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback); | |
731 XtAddCallback (widget, XmNvalueChangedCallback, | |
732 xm_internal_update_other_instances, instance); | |
733 } | |
734 | |
735 | |
736 #ifdef LWLIB_SCROLLBARS_MOTIF | |
737 | |
738 /* | |
739 * If this function looks like it does a lot more work than it needs to, | |
740 * you're right. Blame the Motif scrollbar for not being smart about | |
741 * updating its appearance. | |
742 */ | |
743 static void | |
744 xm_update_scrollbar (widget_instance *instance, Widget widget, | |
745 widget_value *val) | |
746 { | |
747 if (val->scrollbar_data) | |
748 { | |
749 scrollbar_values *data = val->scrollbar_data; | |
750 int widget_sliderSize, widget_val; | |
751 int new_sliderSize, new_value; | |
752 double percent; | |
753 double h_water, l_water; | |
754 Arg al [4]; | |
755 | |
756 /* First size and position the scrollbar widget. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
757 Xt_SET_ARG (al [0], XtNx, data->scrollbar_x); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
758 Xt_SET_ARG (al [1], XtNy, data->scrollbar_y); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
759 Xt_SET_ARG (al [2], XtNwidth, data->scrollbar_width); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
760 Xt_SET_ARG (al [3], XtNheight, data->scrollbar_height); |
428 | 761 XtSetValues (widget, al, 4); |
762 | |
763 /* Now size the scrollbar's slider. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
764 Xt_SET_ARG (al [0], XmNsliderSize, &widget_sliderSize); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
765 Xt_SET_ARG (al [1], XmNvalue, &widget_val); |
428 | 766 XtGetValues (widget, al, 2); |
767 | |
768 percent = (double) data->slider_size / | |
769 (double) (data->maximum - data->minimum); | |
770 new_sliderSize = (int) ((double) (INT_MAX - 1) * percent); | |
771 | |
772 percent = (double) (data->slider_position - data->minimum) / | |
773 (double) (data->maximum - data->minimum); | |
774 new_value = (int) ((double) (INT_MAX - 1) * percent); | |
775 | |
776 if (new_sliderSize > (INT_MAX - 1)) | |
777 new_sliderSize = INT_MAX - 1; | |
778 else if (new_sliderSize < 1) | |
779 new_sliderSize = 1; | |
780 | |
781 if (new_value > (INT_MAX - new_sliderSize)) | |
782 new_value = INT_MAX - new_sliderSize; | |
783 else if (new_value < 1) | |
784 new_value = 1; | |
785 | |
786 h_water = 1.05; | |
787 l_water = 0.95; | |
788 if (new_sliderSize != widget_sliderSize || new_value != widget_val) | |
789 { | |
790 int force = ((INT_MAX - widget_sliderSize - widget_val) | |
791 ? 0 | |
792 : (INT_MAX - new_sliderSize - new_value)); | |
793 | |
794 if (force | |
795 || (double)new_sliderSize < (l_water * (double)widget_sliderSize) | |
796 || (double)new_sliderSize > (h_water * (double)widget_sliderSize) | |
797 || (double)new_value < (l_water * (double)widget_val) | |
798 || (double)new_value > (h_water * (double)widget_val)) | |
799 { | |
800 XmScrollBarSetValues (widget, new_value, new_sliderSize, 1, 1, | |
801 False); | |
802 } | |
803 } | |
804 } | |
805 } | |
806 | |
807 #endif /* LWLIB_SCROLLBARS_MOTIF */ | |
808 | |
809 | |
810 /* update a motif widget */ | |
811 | |
812 void | |
813 xm_update_one_widget (widget_instance* instance, Widget widget, | |
2286 | 814 widget_value* val, |
815 #ifdef LWLIB_MENUBARS_MOTIF | |
816 Boolean deep_p | |
817 #else | |
818 Boolean UNUSED (deep_p) | |
819 #endif | |
820 ) | |
428 | 821 { |
1201 | 822 WidgetClass class_; |
428 | 823 Arg al [20]; |
824 int ac = 0; | |
825 | |
826 /* Mark as not edited */ | |
827 val->edited = False; | |
828 | |
829 /* Common to all widget types */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
830 Xt_SET_ARG (al [ac], XmNsensitive, val->enabled); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
831 Xt_SET_ARG (al [ac], XmNuserData, val->call_data); ac++; |
428 | 832 XtSetValues (widget, al, ac); |
833 | |
834 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_MENUBARS_MOTIF) || defined (LWLIB_WIDGETS_MOTIF) | |
835 /* Common to all label like widgets */ | |
903 | 836 xm_safe_update_label (instance, widget, val); |
428 | 837 #endif |
1201 | 838 class_ = XtClass (widget); |
428 | 839 /* Class specific things */ |
1201 | 840 if (class_ == xmPushButtonWidgetClass || |
841 class_ == xmArrowButtonWidgetClass) | |
428 | 842 { |
843 xm_update_pushbutton (instance, widget, val); | |
844 } | |
845 #ifdef LWLIB_MENUBARS_MOTIF | |
1201 | 846 else if (class_ == xmCascadeButtonWidgetClass) |
428 | 847 { |
848 xm_update_cascadebutton (instance, widget, val); | |
849 } | |
850 #endif | |
1201 | 851 else if (class_ == xmToggleButtonWidgetClass |
852 || class_ == xmToggleButtonGadgetClass) | |
428 | 853 { |
854 xm_update_toggle (instance, widget, val); | |
855 } | |
1201 | 856 else if (class_ == xmRowColumnWidgetClass) |
428 | 857 { |
858 Boolean radiobox = 0; | |
859 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
860 Xt_GET_VALUE (widget, XmNradioBehavior, &radiobox); |
428 | 861 |
862 if (radiobox) | |
863 xm_update_radiobox (instance, widget, val); | |
864 #ifdef LWLIB_MENUBARS_MOTIF | |
865 else | |
866 xm_update_menu (instance, widget, val, deep_p); | |
867 #endif | |
868 } | |
1201 | 869 else if (class_ == xmTextWidgetClass) |
428 | 870 { |
871 xm_update_text (instance, widget, val); | |
872 } | |
1201 | 873 else if (class_ == xmTextFieldWidgetClass) |
428 | 874 { |
875 xm_update_text_field (instance, widget, val); | |
876 } | |
1201 | 877 else if (class_ == xmListWidgetClass) |
428 | 878 { |
879 xm_update_list (instance, widget, val); | |
880 } | |
881 #if defined (LWLIB_WIDGETS_MOTIF) && XmVERSION > 1 | |
1201 | 882 else if (class_ == xmComboBoxWidgetClass) |
428 | 883 { |
884 xm_update_combo_box (instance, widget, val); | |
885 } | |
886 #endif | |
887 #ifdef LWLIB_SCROLLBARS_MOTIF | |
1201 | 888 else if (class_ == xmScrollBarWidgetClass) |
428 | 889 { |
890 xm_update_scrollbar (instance, widget, val); | |
891 } | |
892 #endif | |
1458 | 893 #ifdef LWLIB_WIDGETS_MOTIF |
1201 | 894 else if (class_ == xmScaleWidgetClass) |
639 | 895 { |
896 xm_update_progress (instance, widget, val); | |
897 } | |
1458 | 898 #endif |
442 | 899 /* Lastly update our global arg values. */ |
900 if (val->args && val->args->nargs) | |
901 XtSetValues (widget, val->args->args, val->args->nargs); | |
428 | 902 } |
903 | |
904 /* getting the value back */ | |
905 void | |
906 xm_update_one_value (widget_instance* instance, Widget widget, | |
907 widget_value* val) | |
908 { | |
1201 | 909 WidgetClass class_ = XtClass (widget); |
428 | 910 widget_value *old_wv; |
911 | |
912 /* copy the call_data slot into the "return" widget_value */ | |
913 for (old_wv = instance->info->val->contents; old_wv; old_wv = old_wv->next) | |
914 if (!strcmp (val->name, old_wv->name)) | |
915 { | |
916 val->call_data = old_wv->call_data; | |
917 break; | |
918 } | |
919 | |
1201 | 920 if (class_ == xmToggleButtonWidgetClass || class_ == xmToggleButtonGadgetClass) |
428 | 921 { |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
922 Xt_GET_VALUE (widget, XmNset, &val->selected); |
428 | 923 val->edited = True; |
924 } | |
1201 | 925 else if (class_ == xmTextWidgetClass) |
428 | 926 { |
927 if (val->value) | |
458 | 928 XtFree (val->value); |
428 | 929 val->value = XmTextGetString (widget); |
930 val->edited = True; | |
931 } | |
1201 | 932 else if (class_ == xmTextFieldWidgetClass) |
428 | 933 { |
934 if (val->value) | |
458 | 935 XtFree (val->value); |
428 | 936 val->value = XmTextFieldGetString (widget); |
937 val->edited = True; | |
938 } | |
1201 | 939 else if (class_ == xmRowColumnWidgetClass) |
428 | 940 { |
941 Boolean radiobox = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
942 |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
943 Xt_GET_VALUE (widget, XmNradioBehavior, &radiobox); |
428 | 944 |
945 if (radiobox) | |
946 { | |
947 CompositeWidget radio = (CompositeWidget)widget; | |
639 | 948 unsigned int i; |
428 | 949 for (i = 0; i < radio->composite.num_children; i++) |
950 { | |
951 int set = False; | |
952 Widget toggle = radio->composite.children [i]; | |
953 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
954 Xt_GET_VALUE (toggle, XmNset, &set); |
428 | 955 if (set) |
956 { | |
957 if (val->value) | |
958 free (val->value); | |
959 val->value = safe_strdup (XtName (toggle)); | |
960 } | |
961 } | |
962 val->edited = True; | |
963 } | |
964 } | |
1201 | 965 else if (class_ == xmListWidgetClass |
428 | 966 #if defined (LWLIB_WIDGETS_MOTIF) && XmVERSION > 1 |
1201 | 967 || class_ == xmComboBoxWidgetClass |
428 | 968 #endif |
969 ) | |
970 { | |
971 int pos_cnt; | |
972 int* pos_list; | |
973 Widget list = widget; | |
974 #if defined (LWLIB_WIDGETS_MOTIF) && XmVERSION > 1 | |
1201 | 975 if (class_ == xmComboBoxWidgetClass) |
428 | 976 list = CB_List (widget); |
977 #endif | |
978 if (XmListGetSelectedPos (list, &pos_list, &pos_cnt)) | |
979 { | |
980 int i; | |
981 widget_value* cur; | |
982 for (cur = val->contents, i = 0; cur; cur = cur->next) | |
983 if (cur->value) | |
984 { | |
985 int j; | |
986 cur->selected = False; | |
987 i += 1; | |
988 for (j = 0; j < pos_cnt; j++) | |
989 if (pos_list [j] == i) | |
990 { | |
991 cur->selected = True; | |
992 val->value = safe_strdup (cur->name); | |
993 } | |
994 } | |
995 val->edited = 1; | |
996 XtFree ((char *) pos_list); | |
997 } | |
998 } | |
999 #ifdef LWLIB_SCROLLBARS_MOTIF | |
1201 | 1000 else if (class_ == xmScrollBarWidgetClass) |
428 | 1001 { |
1002 /* This function is not used by the scrollbar. */ | |
1003 return; | |
1004 } | |
1005 #endif | |
1006 } | |
1007 | |
1008 | |
1330 | 1009 #ifdef LWLIB_DIALOGS_MOTIF |
1010 | |
428 | 1011 /* This function is for activating a button from a program. It's wrong because |
1012 we pass a NULL argument in the call_data which is not Motif compatible. | |
1013 This is used from the XmNdefaultAction callback of the List widgets to | |
1014 have a double-click put down a dialog box like the button would do. | |
1015 I could not find a way to do that with accelerators. | |
1016 */ | |
1017 static void | |
2311 | 1018 activate_button (Widget UNUSED (widget), XtPointer closure, |
1019 XtPointer UNUSED (call_data)) | |
428 | 1020 { |
1021 Widget button = (Widget)closure; | |
1022 XtCallCallbacks (button, XmNactivateCallback, NULL); | |
1023 } | |
1024 | |
1025 /* creation functions */ | |
1026 | |
1027 /* dialogs */ | |
1028 | |
1029 #if (XmVersion >= 1002) | |
1030 # define ARMANDACTIVATE_KLUDGE | |
1031 # define DND_KLUDGE | |
1032 #endif | |
1033 | |
1034 #ifdef ARMANDACTIVATE_KLUDGE | |
1035 /* We want typing Return at a dialog box to select the default button; but | |
1036 we're satisfied with having it select the leftmost button instead. | |
1037 | |
1038 In Motif 1.1.5 we could do this by putting this resource in the | |
1039 app-defaults file: | |
1040 | |
1041 *dialog*button1.accelerators:#override\ | |
1042 <KeyPress>Return: ArmAndActivate()\n\ | |
1043 <KeyPress>KP_Enter: ArmAndActivate()\n\ | |
1044 Ctrl<KeyPress>m: ArmAndActivate()\n | |
1045 | |
1046 but that doesn't work with 1.2.1 and I don't understand why. However, | |
1047 doing the equivalent C code does work, with the notable disadvantage that | |
1048 the user can't override it. So that's what we do until we figure out | |
1049 something better.... | |
1050 */ | |
1051 static char button_trans[] = "\ | |
1052 <KeyPress>Return: ArmAndActivate()\n\ | |
1053 <KeyPress>KP_Enter: ArmAndActivate()\n\ | |
1054 Ctrl<KeyPress>m: ArmAndActivate()\n"; | |
1055 | |
1056 #endif /* ARMANDACTIVATE_KLUDGE */ | |
1057 | |
1058 | |
1059 #ifdef DND_KLUDGE | |
1060 /* This is a kludge to disable drag-and-drop in dialog boxes. The symptom | |
1061 was a segv down in libXm somewhere if you used the middle button on a | |
1062 dialog box to begin a drag; when you released the button to make a drop | |
1063 things would lose if you were not over the button where you started the | |
1064 drag (canceling the operation). This was probably due to the fact that | |
1065 the dialog boxes were not set up to handle a drag but were trying to do | |
1066 so anyway for some reason. | |
1067 | |
1068 So we disable drag-and-drop in dialog boxes by turning off the binding for | |
1069 Btn2Down which, by default, initiates a drag. Clearly this is a shitty | |
1070 solution as it only works in default configurations, but... | |
1071 */ | |
1072 static char disable_dnd_trans[] = "<Btn2Down>: "; | |
1073 #endif /* DND_KLUDGE */ | |
1074 | |
1075 | |
1076 static Widget | |
2311 | 1077 make_dialog (char* UNUSED (name), Widget parent, Boolean pop_up_p, |
442 | 1078 const char* shell_title, const char* icon_name, |
428 | 1079 Boolean text_input_slot, Boolean radio_box, Boolean list, |
1080 int left_buttons, int right_buttons) | |
1081 { | |
1082 Widget result; | |
1083 Widget form; | |
1084 Widget row; | |
1085 Widget icon; | |
1086 Widget icon_separator; | |
1087 Widget message; | |
1088 Widget value = 0; | |
1089 Widget separator; | |
1090 Widget button = 0; | |
1091 Widget children [16]; /* for the final XtManageChildren */ | |
1092 int n_children; | |
1093 Arg al[64]; /* Arg List */ | |
1094 int ac; /* Arg Count */ | |
1095 int i; | |
1096 | |
1097 #ifdef DND_KLUDGE | |
1098 XtTranslations dnd_override = XtParseTranslationTable (disable_dnd_trans); | |
1099 # define DO_DND_KLUDGE(widget) XtOverrideTranslations ((widget), dnd_override) | |
1100 #else /* ! DND_KLUDGE */ | |
1101 # define DO_DND_KLUDGE(widget) | |
1102 #endif /* ! DND_KLUDGE */ | |
1103 | |
1104 if (pop_up_p) | |
1105 { | |
1106 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1107 Xt_SET_ARG(al[ac], XmNtitle, shell_title); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1108 Xt_SET_ARG(al[ac], XtNallowShellResize, True); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1109 Xt_SET_ARG(al[ac], XmNdeleteResponse, XmUNMAP); ac++; |
428 | 1110 result = XmCreateDialogShell (parent, "dialog", al, ac); |
1111 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1112 Xt_SET_ARG(al[ac], XmNautoUnmanage, FALSE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1113 /* Xt_SET_ARG(al[ac], XmNautoUnmanage, TRUE); ac++; */ /* ####is this ok? */ |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1114 Xt_SET_ARG(al[ac], XmNnavigationType, XmTAB_GROUP); ac++; |
428 | 1115 form = XmCreateForm (result, (char *) shell_title, al, ac); |
1116 } | |
1117 else | |
1118 { | |
1119 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1120 Xt_SET_ARG(al[ac], XmNautoUnmanage, FALSE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1121 Xt_SET_ARG(al[ac], XmNnavigationType, XmTAB_GROUP); ac++; |
428 | 1122 form = XmCreateForm (parent, (char *) shell_title, al, ac); |
1123 result = form; | |
1124 } | |
1125 | |
1126 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1127 Xt_SET_ARG(al[ac], XmNpacking, XmPACK_COLUMN); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1128 Xt_SET_ARG(al[ac], XmNorientation, XmVERTICAL); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1129 Xt_SET_ARG(al[ac], XmNnumColumns, left_buttons + right_buttons + 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1130 Xt_SET_ARG(al[ac], XmNmarginWidth, 0); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1131 Xt_SET_ARG(al[ac], XmNmarginHeight, 0); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1132 Xt_SET_ARG(al[ac], XmNspacing, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1133 Xt_SET_ARG(al[ac], XmNadjustLast, False); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1134 Xt_SET_ARG(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1135 Xt_SET_ARG(al[ac], XmNisAligned, True); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1136 Xt_SET_ARG(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1137 Xt_SET_ARG(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1138 Xt_SET_ARG(al[ac], XmNbottomOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1139 Xt_SET_ARG(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1140 Xt_SET_ARG(al[ac], XmNleftOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1141 Xt_SET_ARG(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1142 Xt_SET_ARG(al[ac], XmNrightOffset, 13); ac++; |
428 | 1143 row = XmCreateRowColumn (form, "row", al, ac); |
1144 | |
1145 n_children = 0; | |
1146 for (i = 0; i < left_buttons; i++) | |
1147 { | |
1148 char button_name [16]; | |
1149 sprintf (button_name, "button%d", i + 1); | |
1150 ac = 0; | |
1151 if (i == 0) | |
1152 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1153 Xt_SET_ARG(al[ac], XmNhighlightThickness, 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1154 Xt_SET_ARG(al[ac], XmNshowAsDefault, TRUE); ac++; |
428 | 1155 } |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1156 Xt_SET_ARG(al[ac], XmNnavigationType, XmTAB_GROUP); ac++; |
428 | 1157 children [n_children] = XmCreatePushButton (row, button_name, al, ac); |
1158 DO_DND_KLUDGE (children [n_children]); | |
1159 | |
1160 if (i == 0) | |
1161 { | |
1162 button = children [n_children]; | |
1163 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1164 Xt_SET_ARG(al[ac], XmNdefaultButton, button); ac++; |
428 | 1165 XtSetValues (row, al, ac); |
1166 | |
1167 #ifdef ARMANDACTIVATE_KLUDGE /* See comment above */ | |
1168 { | |
1169 XtTranslations losers = XtParseTranslationTable (button_trans); | |
1170 XtOverrideTranslations (button, losers); | |
1171 XtFree ((char *) losers); | |
1172 } | |
1173 #endif /* ARMANDACTIVATE_KLUDGE */ | |
1174 } | |
1175 | |
1176 n_children++; | |
1177 } | |
1178 | |
442 | 1179 /* invisible separator button */ |
428 | 1180 ac = 0; |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1181 Xt_SET_ARG (al[ac], XmNmappedWhenManaged, FALSE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1182 children [n_children] = XmCreateLabel (row, "separator_button", al, ac); |
428 | 1183 DO_DND_KLUDGE (children [n_children]); |
1184 n_children++; | |
1185 | |
1186 for (i = 0; i < right_buttons; i++) | |
1187 { | |
1188 char button_name [16]; | |
1189 sprintf (button_name, "button%d", left_buttons + i + 1); | |
1190 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1191 Xt_SET_ARG(al[ac], XmNnavigationType, XmTAB_GROUP); ac++; |
428 | 1192 children [n_children] = XmCreatePushButton (row, button_name, al, ac); |
1193 DO_DND_KLUDGE (children [n_children]); | |
1194 if (! button) button = children [n_children]; | |
1195 n_children++; | |
1196 } | |
1197 | |
1198 XtManageChildren (children, n_children); | |
1199 | |
1200 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1201 Xt_SET_ARG(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1202 Xt_SET_ARG(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1203 Xt_SET_ARG(al[ac], XmNbottomOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1204 Xt_SET_ARG(al[ac], XmNbottomWidget, row); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1205 Xt_SET_ARG(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1206 Xt_SET_ARG(al[ac], XmNleftOffset, 0); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1207 Xt_SET_ARG(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1208 Xt_SET_ARG(al[ac], XmNrightOffset, 0); ac++; |
428 | 1209 separator = XmCreateSeparator (form, "", al, ac); |
1210 | |
1211 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1212 Xt_SET_ARG(al[ac], XmNlabelType, XmPIXMAP); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1213 Xt_SET_ARG(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1214 Xt_SET_ARG(al[ac], XmNtopOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1215 Xt_SET_ARG(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1216 Xt_SET_ARG(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1217 Xt_SET_ARG(al[ac], XmNleftOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1218 Xt_SET_ARG(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++; |
428 | 1219 icon = XmCreateLabel (form, (char *) icon_name, al, ac); |
1220 DO_DND_KLUDGE (icon); | |
1221 | |
1222 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1223 Xt_SET_ARG(al[ac], XmNmappedWhenManaged, FALSE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1224 Xt_SET_ARG(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1225 Xt_SET_ARG(al[ac], XmNtopOffset, 6); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1226 Xt_SET_ARG(al[ac], XmNtopWidget, icon); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1227 Xt_SET_ARG(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1228 Xt_SET_ARG(al[ac], XmNbottomOffset, 6); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1229 Xt_SET_ARG(al[ac], XmNbottomWidget, separator); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1230 Xt_SET_ARG(al[ac], XmNleftAttachment, XmATTACH_NONE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1231 Xt_SET_ARG(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++; |
428 | 1232 icon_separator = XmCreateLabel (form, "", al, ac); |
1233 DO_DND_KLUDGE (icon_separator); | |
1234 | |
1235 if (text_input_slot) | |
1236 { | |
1237 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1238 Xt_SET_ARG(al[ac], XmNcolumns, 50); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1239 Xt_SET_ARG(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1240 Xt_SET_ARG(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1241 Xt_SET_ARG(al[ac], XmNbottomOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1242 Xt_SET_ARG(al[ac], XmNbottomWidget, separator); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1243 Xt_SET_ARG(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1244 Xt_SET_ARG(al[ac], XmNleftOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1245 Xt_SET_ARG(al[ac], XmNleftWidget, icon); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1246 Xt_SET_ARG(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1247 Xt_SET_ARG(al[ac], XmNrightOffset, 13); ac++; |
428 | 1248 value = XmCreateTextField (form, "value", al, ac); |
1249 DO_DND_KLUDGE (value); | |
1250 } | |
1251 else if (radio_box) | |
1252 { | |
1253 Widget radio_butt; | |
1254 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1255 Xt_SET_ARG(al[ac], XmNmarginWidth, 0); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1256 Xt_SET_ARG(al[ac], XmNmarginHeight, 0); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1257 Xt_SET_ARG(al[ac], XmNspacing, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1258 Xt_SET_ARG(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1259 Xt_SET_ARG(al[ac], XmNorientation, XmHORIZONTAL); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1260 Xt_SET_ARG(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1261 Xt_SET_ARG(al[ac], XmNbottomOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1262 Xt_SET_ARG(al[ac], XmNbottomWidget, separator); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1263 Xt_SET_ARG(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1264 Xt_SET_ARG(al[ac], XmNleftOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1265 Xt_SET_ARG(al[ac], XmNleftWidget, icon); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1266 Xt_SET_ARG(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1267 Xt_SET_ARG(al[ac], XmNrightOffset, 13); ac++; |
428 | 1268 value = XmCreateRadioBox (form, "radiobutton1", al, ac); |
1269 ac = 0; | |
1270 i = 0; | |
1271 radio_butt = XmCreateToggleButtonGadget (value, "radio1", al, ac); | |
1272 children [i++] = radio_butt; | |
1273 radio_butt = XmCreateToggleButtonGadget (value, "radio2", al, ac); | |
1274 children [i++] = radio_butt; | |
1275 radio_butt = XmCreateToggleButtonGadget (value, "radio3", al, ac); | |
1276 children [i++] = radio_butt; | |
1277 XtManageChildren (children, i); | |
1278 } | |
1279 else if (list) | |
1280 { | |
1281 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1282 Xt_SET_ARG(al[ac], XmNvisibleItemCount, 5); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1283 Xt_SET_ARG(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1284 Xt_SET_ARG(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1285 Xt_SET_ARG(al[ac], XmNbottomOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1286 Xt_SET_ARG(al[ac], XmNbottomWidget, separator); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1287 Xt_SET_ARG(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1288 Xt_SET_ARG(al[ac], XmNleftOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1289 Xt_SET_ARG(al[ac], XmNleftWidget, icon); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1290 Xt_SET_ARG(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1291 Xt_SET_ARG(al[ac], XmNrightOffset, 13); ac++; |
428 | 1292 value = XmCreateScrolledList (form, "list", al, ac); |
1293 | |
442 | 1294 /* this is the easiest way I found to have the double click in the |
428 | 1295 list activate the default button */ |
1296 XtAddCallback (value, XmNdefaultActionCallback, activate_button, button); | |
1297 } | |
805 | 1298 /* else add nothing; it's a separator */ |
428 | 1299 |
1300 ac = 0; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1301 Xt_SET_ARG(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1302 Xt_SET_ARG(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1303 Xt_SET_ARG(al[ac], XmNtopOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1304 Xt_SET_ARG(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1305 Xt_SET_ARG(al[ac], XmNbottomOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1306 Xt_SET_ARG(al[ac], XmNbottomWidget, |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1307 text_input_slot || radio_box || list ? value : separator); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1308 Xt_SET_ARG(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1309 Xt_SET_ARG(al[ac], XmNleftOffset, 13); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1310 Xt_SET_ARG(al[ac], XmNleftWidget, icon); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1311 Xt_SET_ARG(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1312 Xt_SET_ARG(al[ac], XmNrightOffset, 13); ac++; |
428 | 1313 message = XmCreateLabel (form, "message", al, ac); |
1314 DO_DND_KLUDGE (message); | |
1315 | |
1316 if (list) | |
1317 XtManageChild (value); | |
1318 | |
1319 i = 0; | |
1320 children [i] = row; i++; | |
1321 children [i] = separator; i++; | |
1322 if (text_input_slot || radio_box) | |
1323 { | |
1324 children [i] = value; i++; | |
1325 } | |
1326 children [i] = message; i++; | |
1327 children [i] = icon; i++; | |
1328 children [i] = icon_separator; i++; | |
1329 XtManageChildren (children, i); | |
1330 | |
1331 if (text_input_slot || list) | |
1332 { | |
1333 XtInstallAccelerators (value, button); | |
1334 XmProcessTraversal(value, XmTRAVERSE_CURRENT); | |
1335 } | |
805 | 1336 else if (radio_box) |
428 | 1337 { |
1338 XtInstallAccelerators (form, button); | |
1339 XmProcessTraversal(value, XmTRAVERSE_CURRENT); | |
1340 } | |
805 | 1341 /* else we don' need no STEENKIN' assellerators. */ |
428 | 1342 |
1343 #ifdef DND_KLUDGE | |
1344 XtFree ((char *) dnd_override); | |
1345 #endif | |
1346 #undef DO_DND_KLUDGE | |
1347 | |
1348 return result; | |
1349 } | |
1350 | |
1351 static destroyed_instance* | |
1352 find_matching_instance (widget_instance* instance) | |
1353 { | |
1354 destroyed_instance* cur; | |
1355 destroyed_instance* prev; | |
1356 char* type = instance->info->type; | |
1357 char* name = instance->info->name; | |
1358 | |
1359 for (prev = NULL, cur = all_destroyed_instances; | |
1360 cur; | |
1361 prev = cur, cur = cur->next) | |
1362 { | |
1363 if (!strcmp (cur->name, name) | |
1364 && !strcmp (cur->type, type) | |
1365 && cur->parent == instance->parent | |
1366 && cur->pop_up_p == instance->pop_up_p) | |
1367 { | |
1368 if (prev) | |
1369 prev->next = cur->next; | |
1370 else | |
1371 all_destroyed_instances = cur->next; | |
1372 return cur; | |
1373 } | |
1374 /* do some cleanup */ | |
1375 else if (!cur->widget) | |
1376 { | |
1377 if (prev) | |
1378 prev->next = cur->next; | |
1379 else | |
1380 all_destroyed_instances = cur->next; | |
1381 free_destroyed_instance (cur); | |
1382 cur = prev ? prev : all_destroyed_instances; | |
1383 } | |
1384 } | |
1385 return NULL; | |
1386 } | |
1387 | |
1388 static void | |
1389 recenter_widget (Widget widget) | |
1390 { | |
1391 Widget parent = XtParent (widget); | |
1392 Screen* screen = XtScreen (widget); | |
1393 Dimension screen_width = WidthOfScreen (screen); | |
1394 Dimension screen_height = HeightOfScreen (screen); | |
1395 Dimension parent_width = 0; | |
1396 Dimension parent_height = 0; | |
1397 Dimension child_width = 0; | |
1398 Dimension child_height = 0; | |
1399 Position x; | |
1400 Position y; | |
1401 Arg al [2]; | |
1402 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1403 Xt_SET_ARG (al [0], XtNwidth, &child_width); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1404 Xt_SET_ARG (al [1], XtNheight, &child_height); |
428 | 1405 XtGetValues (widget, al, 2); |
1406 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1407 Xt_SET_ARG (al [0], XtNwidth, &parent_width); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1408 Xt_SET_ARG (al [1], XtNheight, &parent_height); |
428 | 1409 XtGetValues (parent, al, 2); |
1410 | |
1411 x = (Position) ((parent_width - child_width) / 2); | |
1412 y = (Position) ((parent_height - child_height) / 2); | |
1413 | |
1414 XtTranslateCoords (parent, x, y, &x, &y); | |
1415 | |
1416 if ((Dimension) (x + child_width) > screen_width) | |
1417 x = screen_width - child_width; | |
1418 if (x < 0) | |
1419 x = 0; | |
1420 | |
1421 if ((Dimension) (y + child_height) > screen_height) | |
1422 y = screen_height - child_height; | |
1423 if (y < 0) | |
1424 y = 0; | |
1425 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1426 Xt_SET_ARG (al [0], XtNx, x); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1427 Xt_SET_ARG (al [1], XtNy, y); |
428 | 1428 XtSetValues (widget, al, 2); |
1429 } | |
1430 | |
1431 static Widget | |
1432 recycle_instance (destroyed_instance* instance) | |
1433 { | |
1434 Widget widget = instance->widget; | |
1435 | |
1436 /* widget is NULL if the parent was destroyed. */ | |
1437 if (widget) | |
1438 { | |
1439 Widget focus; | |
1440 Widget separator; | |
1441 | |
1442 /* Remove the destroy callback as the instance is not in the list | |
1443 anymore */ | |
1444 XtRemoveCallback (instance->parent, XtNdestroyCallback, | |
1445 mark_dead_instance_destroyed, | |
1446 (XtPointer)instance); | |
1447 | |
1448 /* Give the focus to the initial item */ | |
1449 focus = XtNameToWidget (widget, "*value"); | |
1450 if (!focus) | |
1451 focus = XtNameToWidget (widget, "*button1"); | |
1452 if (focus) | |
1453 XmProcessTraversal(focus, XmTRAVERSE_CURRENT); | |
1454 | |
1455 /* shrink the separator label back to their original size */ | |
1456 separator = XtNameToWidget (widget, "*separator_button"); | |
1457 if (separator) | |
1458 { | |
1459 Arg al [2]; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1460 Xt_SET_ARG (al [0], XtNwidth, 5); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1461 Xt_SET_ARG (al [1], XtNheight, 5); |
428 | 1462 XtSetValues (separator, al, 2); |
1463 } | |
1464 | |
1465 /* Center the dialog in its parent */ | |
1466 recenter_widget (widget); | |
1467 } | |
1468 free_destroyed_instance (instance); | |
1469 return widget; | |
1470 } | |
1471 | |
1472 Widget | |
1473 xm_create_dialog (widget_instance* instance) | |
1474 { | |
1475 char* name = instance->info->type; | |
1476 Widget parent = instance->parent; | |
1477 Widget widget; | |
1478 Boolean pop_up_p = instance->pop_up_p; | |
442 | 1479 const char* shell_name = 0; |
1480 const char* icon_name = 0; | |
428 | 1481 Boolean text_input_slot = False; |
1482 Boolean radio_box = False; | |
1483 Boolean list = False; | |
1484 int total_buttons; | |
1485 int left_buttons = 0; | |
1486 int right_buttons = 1; | |
1487 destroyed_instance* dead_one; | |
1488 | |
1489 /* try to find a widget to recycle */ | |
1490 dead_one = find_matching_instance (instance); | |
1491 if (dead_one) | |
1492 { | |
1493 Widget recycled_widget = recycle_instance (dead_one); | |
1494 if (recycled_widget) | |
1495 return recycled_widget; | |
1496 } | |
1497 | |
1498 switch (name [0]){ | |
1499 case 'E': case 'e': | |
1500 icon_name = "dbox-error"; | |
1501 shell_name = "Error"; | |
1502 break; | |
1503 | |
1504 case 'I': case 'i': | |
1505 icon_name = "dbox-info"; | |
1506 shell_name = "Information"; | |
1507 break; | |
1508 | |
1509 case 'L': case 'l': | |
1510 list = True; | |
1511 icon_name = "dbox-question"; | |
1512 shell_name = "Prompt"; | |
1513 break; | |
1514 | |
1515 case 'P': case 'p': | |
1516 text_input_slot = True; | |
1517 icon_name = "dbox-question"; | |
1518 shell_name = "Prompt"; | |
1519 break; | |
1520 | |
1521 case 'Q': case 'q': | |
1522 icon_name = "dbox-question"; | |
1523 shell_name = "Question"; | |
1524 break; | |
1525 } | |
1526 | |
1527 total_buttons = name [1] - '0'; | |
1528 | |
1529 if (name [3] == 'T' || name [3] == 't') | |
1530 { | |
1531 text_input_slot = False; | |
1532 radio_box = True; | |
1533 } | |
1534 else if (name [3]) | |
1535 right_buttons = name [4] - '0'; | |
1536 | |
1537 left_buttons = total_buttons - right_buttons; | |
1538 | |
1539 widget = make_dialog (name, parent, pop_up_p, | |
1540 shell_name, icon_name, text_input_slot, radio_box, | |
1541 list, left_buttons, right_buttons); | |
1542 | |
1543 XtAddCallback (widget, XmNpopdownCallback, xm_nosel_callback, | |
1544 (XtPointer) instance); | |
1545 return widget; | |
1546 } | |
1547 | |
1548 #endif /* LWLIB_DIALOGS_MOTIF */ | |
1549 | |
1550 #ifdef LWLIB_MENUBARS_MOTIF | |
1551 static Widget | |
1552 make_menubar (widget_instance* instance) | |
1553 { | |
1554 Arg al[10]; | |
1555 int ac = 0; | |
1556 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1557 Xt_SET_ARG(al[ac], XmNmarginHeight, 0); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1558 Xt_SET_ARG(al[ac], XmNshadowThickness, 3); ac++; |
428 | 1559 |
1560 return XmCreateMenuBar (instance->parent, instance->info->name, al, ac); | |
1561 } | |
1562 | |
1563 static void | |
1564 remove_grabs (Widget shell, XtPointer closure, XtPointer call_data) | |
1565 { | |
1566 Widget menu = (Widget) closure; | |
1567 XmRemoveFromPostFromList (menu, XtParent (XtParent ((Widget) menu))); | |
1568 } | |
1569 | |
1570 static Widget | |
1571 make_popup_menu (widget_instance* instance) | |
1572 { | |
1573 Widget parent = instance->parent; | |
1574 Window parent_window = parent->core.window; | |
1575 Widget result; | |
1576 | |
1577 /* sets the parent window to 0 to fool Motif into not generating a grab */ | |
1578 parent->core.window = 0; | |
1579 result = XmCreatePopupMenu (parent, instance->info->name, NULL, 0); | |
1580 XtAddCallback (XtParent (result), XmNpopdownCallback, remove_grabs, | |
1581 (XtPointer)result); | |
1582 parent->core.window = parent_window; | |
1583 return result; | |
1584 } | |
1585 #endif /* LWLIB_MENUBARS_MOTIF */ | |
1586 | |
1587 #ifdef LWLIB_SCROLLBARS_MOTIF | |
1588 static Widget | |
1589 make_scrollbar (widget_instance *instance, int vertical) | |
1590 { | |
1591 Arg al[20]; | |
1592 int ac = 0; | |
1593 static XtCallbackRec callbacks[2] = | |
1594 { {xm_scrollbar_callback, NULL}, {NULL, NULL} }; | |
1595 | |
1596 callbacks[0].closure = (XtPointer) instance; | |
1597 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1598 Xt_SET_ARG (al[ac], XmNminimum, 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1599 Xt_SET_ARG (al[ac], XmNmaximum, INT_MAX); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1600 Xt_SET_ARG (al[ac], XmNincrement, 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1601 Xt_SET_ARG (al[ac], XmNpageIncrement, 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1602 Xt_SET_ARG (al[ac], XmNborderWidth, 0); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1603 Xt_SET_ARG (al[ac], XmNorientation, |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1604 vertical ? XmVERTICAL : XmHORIZONTAL); ac++; |
428 | 1605 |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1606 Xt_SET_ARG (al[ac], XmNdecrementCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1607 Xt_SET_ARG (al[ac], XmNdragCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1608 Xt_SET_ARG (al[ac], XmNincrementCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1609 Xt_SET_ARG (al[ac], XmNpageDecrementCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1610 Xt_SET_ARG (al[ac], XmNpageIncrementCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1611 Xt_SET_ARG (al[ac], XmNtoBottomCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1612 Xt_SET_ARG (al[ac], XmNtoTopCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1613 Xt_SET_ARG (al[ac], XmNvalueChangedCallback, callbacks); ac++; |
428 | 1614 |
1615 return XmCreateScrollBar (instance->parent, instance->info->name, al, ac); | |
1616 } | |
1617 | |
1618 static Widget | |
1619 make_vertical_scrollbar (widget_instance *instance) | |
1620 { | |
1621 return make_scrollbar (instance, 1); | |
1622 } | |
1623 | |
1624 static Widget | |
1625 make_horizontal_scrollbar (widget_instance *instance) | |
1626 { | |
1627 return make_scrollbar (instance, 0); | |
1628 } | |
1629 | |
1630 #endif /* LWLIB_SCROLLBARS_MOTIF */ | |
1631 | |
1632 #ifdef LWLIB_WIDGETS_MOTIF | |
1633 /* glyph widgets */ | |
1634 static Widget | |
1635 xm_create_button (widget_instance *instance) | |
1636 { | |
1637 Arg al[20]; | |
1638 int ac = 0; | |
1639 Widget button = 0; | |
1640 widget_value* val = instance->info->val; | |
1641 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1642 Xt_SET_ARG (al [ac], XmNsensitive, val->enabled); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1643 Xt_SET_ARG (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1644 Xt_SET_ARG (al [ac], XmNuserData, val->call_data); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1645 Xt_SET_ARG (al [ac], XmNmappedWhenManaged, FALSE); ac++; |
428 | 1646 /* The highlight doesn't appear to be dynamically set which makes it |
1647 look ugly. I think this may be a LessTif bug but for now we just | |
1648 get rid of it. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1649 Xt_SET_ARG (al [ac], XmNhighlightThickness, (Dimension)0); ac++; |
428 | 1650 |
1651 /* add any args the user supplied for creation time */ | |
1652 lw_add_value_args_to_args (val, al, &ac); | |
1653 | |
1654 if (!val->call_data) | |
1655 button = XmCreateLabel (instance->parent, val->name, al, ac); | |
1656 | |
1657 else if (val->type == TOGGLE_TYPE || val->type == RADIO_TYPE) | |
1658 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1659 Xt_SET_ARG (al [ac], XmNset, val->selected); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1660 Xt_SET_ARG (al [ac], XmNindicatorType, |
428 | 1661 (val->type == TOGGLE_TYPE ? |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1662 XmN_OF_MANY : XmONE_OF_MANY)); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1663 Xt_SET_ARG (al [ac], XmNvisibleWhenOff, True); ac++; |
428 | 1664 button = XmCreateToggleButton (instance->parent, val->name, al, ac); |
1665 XtRemoveAllCallbacks (button, XmNvalueChangedCallback); | |
1666 XtAddCallback (button, XmNvalueChangedCallback, xm_generic_callback, | |
1667 (XtPointer)instance); | |
1668 } | |
1669 else | |
1670 { | |
1671 button = XmCreatePushButton (instance->parent, val->name, al, ac); | |
1672 XtAddCallback (button, XmNactivateCallback, xm_generic_callback, | |
1673 (XtPointer)instance); | |
1674 } | |
1675 | |
1676 XtManageChild (button); | |
1677 | |
1678 return button; | |
1679 } | |
1680 | |
1681 static Widget | |
1682 xm_create_progress (widget_instance *instance) | |
1683 { | |
1684 Arg al[20]; | |
1685 int ac = 0; | |
639 | 1686 Dimension height = 0; |
1687 Dimension width = 0; | |
428 | 1688 Widget scale = 0; |
1689 widget_value* val = instance->info->val; | |
1690 if (!val->call_data) | |
1691 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1692 Xt_SET_ARG (al [ac], XmNeditable, False); ac++; |
428 | 1693 } |
1694 else | |
1695 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1696 Xt_SET_ARG (al [ac], XmNeditable, val->enabled); ac++; |
428 | 1697 } |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1698 Xt_SET_ARG (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1699 Xt_SET_ARG (al [ac], XmNuserData, val->call_data); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1700 Xt_SET_ARG (al [ac], XmNmappedWhenManaged, FALSE); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1701 Xt_SET_ARG (al [ac], XmNorientation, XmHORIZONTAL); ac++; |
428 | 1702 /* The highlight doesn't appear to be dynamically set which makes it |
1703 look ugly. I think this may be a LessTif bug but for now we just | |
1704 get rid of it. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1705 Xt_SET_ARG (al [ac], XmNhighlightThickness, (Dimension)0); ac++; |
639 | 1706 |
1707 height = (Dimension)lw_get_value_arg (val, XtNheight); | |
1708 width = (Dimension)lw_get_value_arg (val, XtNwidth); | |
1709 if (height > 0) | |
1710 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1711 Xt_SET_ARG (al [ac], XmNscaleHeight, height); ac++; |
639 | 1712 } |
1713 if (width > 0) | |
1714 { | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1715 Xt_SET_ARG (al [ac], XmNscaleWidth, width); ac++; |
639 | 1716 } |
1717 | |
428 | 1718 /* add any args the user supplied for creation time */ |
1719 lw_add_value_args_to_args (val, al, &ac); | |
1720 | |
1721 scale = XmCreateScale (instance->parent, val->name, al, ac); | |
1722 if (val->call_data) | |
1723 XtAddCallback (scale, XmNvalueChangedCallback, xm_generic_callback, | |
1724 (XtPointer)instance); | |
1725 | |
1726 XtManageChild (scale); | |
1727 | |
1728 return scale; | |
1729 } | |
1730 | |
1731 static Widget | |
1732 xm_create_text_field (widget_instance *instance) | |
1733 { | |
1734 Arg al[20]; | |
1735 int ac = 0; | |
1736 Widget text = 0; | |
1737 widget_value* val = instance->info->val; | |
1738 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1739 Xt_SET_ARG (al [ac], XmNsensitive, val->enabled); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1740 Xt_SET_ARG (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1741 Xt_SET_ARG (al [ac], XmNuserData, val->call_data); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1742 Xt_SET_ARG (al [ac], XmNmappedWhenManaged, FALSE); ac++; |
428 | 1743 /* The highlight doesn't appear to be dynamically set which makes it |
1744 look ugly. I think this may be a LessTif bug but for now we just | |
1745 get rid of it. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1746 Xt_SET_ARG (al [ac], XmNhighlightThickness, (Dimension)0); ac++; |
428 | 1747 |
1748 /* add any args the user supplied for creation time */ | |
1749 lw_add_value_args_to_args (val, al, &ac); | |
1750 | |
1751 text = XmCreateTextField (instance->parent, val->name, al, ac); | |
1752 if (val->call_data) | |
1753 XtAddCallback (text, XmNvalueChangedCallback, xm_generic_callback, | |
1754 (XtPointer)instance); | |
1755 | |
1756 XtManageChild (text); | |
1757 | |
1758 return text; | |
1759 } | |
1760 | |
1761 static Widget | |
1762 xm_create_label_field (widget_instance *instance) | |
1763 { | |
1764 return xm_create_label (instance->parent, instance->info->val); | |
1765 } | |
1766 | |
1767 Widget | |
1768 xm_create_label (Widget parent, widget_value* val) | |
1769 { | |
1770 Arg al[20]; | |
1771 int ac = 0; | |
1772 Widget label = 0; | |
1773 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1774 Xt_SET_ARG (al [ac], XmNsensitive, val->enabled); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1775 Xt_SET_ARG (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1776 Xt_SET_ARG (al [ac], XmNmappedWhenManaged, FALSE); ac++; |
428 | 1777 /* The highlight doesn't appear to be dynamically set which makes it |
1778 look ugly. I think this may be a LessTif bug but for now we just | |
1779 get rid of it. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1780 Xt_SET_ARG (al [ac], XmNhighlightThickness, (Dimension)0); ac++; |
428 | 1781 |
1782 /* add any args the user supplied for creation time */ | |
1783 lw_add_value_args_to_args (val, al, &ac); | |
1784 | |
1785 label = XmCreateLabel (parent, val->name, al, ac); | |
1786 | |
1787 XtManageChild (label); | |
1788 | |
1789 /* Do it again for arguments that have no effect until the widget is realized. */ | |
1790 ac = 0; | |
1791 lw_add_value_args_to_args (val, al, &ac); | |
1792 XtSetValues (label, al, ac); | |
1793 | |
1794 return label; | |
1795 } | |
1796 | |
1797 #if XmVERSION > 1 | |
1798 static Widget | |
1799 xm_create_combo_box (widget_instance *instance) | |
1800 { | |
1801 Arg al[20]; | |
1802 int ac = 0; | |
1803 Widget combo = 0; | |
1804 widget_value* val = instance->info->val; | |
1805 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1806 Xt_SET_ARG (al [ac], XmNsensitive, val->enabled); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1807 Xt_SET_ARG (al [ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1808 Xt_SET_ARG (al [ac], XmNuserData, val->call_data); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1809 Xt_SET_ARG (al [ac], XmNmappedWhenManaged, FALSE); ac++; |
428 | 1810 /* The highlight doesn't appear to be dynamically set which makes it |
1811 look ugly. I think this may be a LessTif bug but for now we just | |
1812 get rid of it. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1813 Xt_SET_ARG (al [ac], XmNhighlightThickness, (Dimension)0); ac++; |
428 | 1814 |
1815 /* add any args the user supplied for creation time */ | |
1816 lw_add_value_args_to_args (val, al, &ac); | |
1817 | |
1818 combo = XmCreateDropDownComboBox (instance->parent, val->name, al, ac); | |
1819 if (val->call_data) | |
1820 XtAddCallback (combo, XmNselectionCallback, xm_generic_callback, | |
1821 (XtPointer)instance); | |
1822 | |
1823 XtManageChild (combo); | |
1824 | |
1825 return combo; | |
1826 } | |
1827 #endif | |
1828 #endif /* LWLIB_WIDGETS_MOTIF */ | |
1829 | |
1830 | |
1831 /* Table of functions to create widgets */ | |
1832 | |
450 | 1833 const widget_creation_entry |
428 | 1834 xm_creation_table [] = |
1835 { | |
1836 #ifdef LWLIB_MENUBARS_MOTIF | |
1837 {"menubar", make_menubar}, | |
1838 {"popup", make_popup_menu}, | |
1839 #endif | |
1840 #ifdef LWLIB_SCROLLBARS_MOTIF | |
1841 {"vertical-scrollbar", make_vertical_scrollbar}, | |
1842 {"horizontal-scrollbar", make_horizontal_scrollbar}, | |
1843 #endif | |
1844 #ifdef LWLIB_WIDGETS_MOTIF | |
1845 {"button", xm_create_button}, | |
1846 {"progress", xm_create_progress}, | |
1847 {"text-field", xm_create_text_field}, | |
1848 {"label", xm_create_label_field}, | |
1849 #if XmVERSION > 1 | |
1850 {"combo-box", xm_create_combo_box}, | |
1851 #endif | |
1852 #endif | |
1853 {NULL, NULL} | |
1854 }; | |
1855 | |
1856 /* Destruction of instances */ | |
1857 void | |
2286 | 1858 xm_destroy_instance ( |
1859 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_WIDGETS_MOTIF) | |
1860 widget_instance* instance | |
1861 #else | |
1862 widget_instance* UNUSED (instance) | |
1863 #endif | |
1864 ) | |
428 | 1865 { |
1866 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_WIDGETS_MOTIF) | |
1867 /* It appears that this is used only for dialog boxes. */ | |
1868 Widget widget = instance->widget; | |
1869 /* recycle the dialog boxes */ | |
1870 /* Disable the recycling until we can find a way to have the dialog box | |
1871 get reasonable layout after we modify its contents. */ | |
1872 if (0 | |
1873 && XtClass (widget) == xmDialogShellWidgetClass) | |
1874 { | |
1875 destroyed_instance* dead_instance = | |
1876 make_destroyed_instance (instance->info->name, | |
1877 instance->info->type, | |
1878 instance->widget, | |
1879 instance->parent, | |
1880 instance->pop_up_p); | |
1881 dead_instance->next = all_destroyed_instances; | |
1882 all_destroyed_instances = dead_instance; | |
1883 XtUnmanageChild (first_child (instance->widget)); | |
1884 XFlush (XtDisplay (instance->widget)); | |
1885 XtAddCallback (instance->parent, XtNdestroyCallback, | |
1886 mark_dead_instance_destroyed, (XtPointer)dead_instance); | |
1887 } | |
1888 else | |
1889 { | |
1890 /* This might not be necessary now that the nosel is attached to | |
1891 popdown instead of destroy, but it can't hurt. */ | |
1892 XtRemoveCallback (instance->widget, XtNdestroyCallback, | |
1893 xm_nosel_callback, (XtPointer)instance); | |
1894 | |
1895 XtDestroyWidget (instance->widget); | |
1896 } | |
1897 #endif /* LWLIB_DIALOGS_MOTIF || LWLIB_WIDGETS_MOTIF */ | |
1898 } | |
1899 | |
1900 /* popup utility */ | |
1901 #ifdef LWLIB_MENUBARS_MOTIF | |
1902 | |
1903 void | |
1904 xm_popup_menu (Widget widget, XEvent *event) | |
1905 { | |
1906 if (event->type == ButtonPress || event->type == ButtonRelease) | |
1907 { | |
1908 /* This is so totally ridiculous: there's NO WAY to tell Motif | |
1909 that *any* button can select a menu item. Only one button | |
1910 can have that honor. | |
1911 */ | |
1912 char *trans = 0; | |
1913 if (event->xbutton.state & Button5Mask) trans = "<Btn5Down>"; | |
1914 else if (event->xbutton.state & Button4Mask) trans = "<Btn4Down>"; | |
1915 else if (event->xbutton.state & Button3Mask) trans = "<Btn3Down>"; | |
1916 else if (event->xbutton.state & Button2Mask) trans = "<Btn2Down>"; | |
1917 else if (event->xbutton.state & Button1Mask) trans = "<Btn1Down>"; | |
1918 if (trans) | |
1919 { | |
1920 Arg al [1]; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1921 Xt_SET_ARG (al [0], XmNmenuPost, trans); |
428 | 1922 XtSetValues (widget, al, 1); |
1923 } | |
1924 XmMenuPosition (widget, (XButtonPressedEvent *) event); | |
1925 } | |
1926 XtManageChild (widget); | |
1927 } | |
1928 | |
1929 #endif | |
1930 | |
1931 #ifdef LWLIB_DIALOGS_MOTIF | |
1932 | |
1933 static void | |
1934 set_min_dialog_size (Widget w) | |
1935 { | |
1936 short width; | |
1937 short height; | |
1938 Arg al [2]; | |
1939 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1940 Xt_SET_ARG (al [0], XmNwidth, &width); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1941 Xt_SET_ARG (al [1], XmNheight, &height); |
428 | 1942 XtGetValues (w, al, 2); |
1943 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1944 Xt_SET_ARG (al [0], XmNminWidth, width); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
1945 Xt_SET_ARG (al [1], XmNminHeight, height); |
428 | 1946 XtSetValues (w, al, 2); |
1947 } | |
1948 | |
1949 #endif | |
1950 | |
1951 void | |
1952 xm_pop_instance (widget_instance* instance, Boolean up) | |
1953 { | |
1954 Widget widget = instance->widget; | |
1955 | |
1956 #ifdef LWLIB_DIALOGS_MOTIF | |
1957 if (XtClass (widget) == xmDialogShellWidgetClass) | |
1958 { | |
1959 Widget widget_to_manage = first_child (widget); | |
1960 if (up) | |
1961 { | |
1962 XtManageChild (widget_to_manage); | |
1963 set_min_dialog_size (widget); | |
1964 XmProcessTraversal(widget, XmTRAVERSE_CURRENT); | |
1965 } | |
1966 else | |
1967 XtUnmanageChild (widget_to_manage); | |
1968 } | |
1969 else | |
1970 #endif | |
1971 { | |
1972 if (up) | |
1973 XtManageChild (widget); | |
1974 else | |
1975 XtUnmanageChild (widget); | |
1976 } | |
1977 } | |
1978 | |
1979 | |
1980 /* motif callback */ | |
1981 | |
1982 enum do_call_type { pre_activate, selection, no_selection, post_activate }; | |
1983 | |
1984 static void | |
1985 do_call (Widget widget, XtPointer closure, enum do_call_type type) | |
1986 { | |
1987 XtPointer user_data; | |
1988 widget_instance* instance = (widget_instance*)closure; | |
1989 Widget instance_widget; | |
1990 LWLIB_ID id; | |
1991 | |
1992 if (!instance) | |
1993 return; | |
1994 if (widget->core.being_destroyed) | |
1995 return; | |
1996 | |
1997 instance_widget = instance->widget; | |
1998 if (!instance_widget) | |
1999 return; | |
2000 | |
2001 id = instance->info->id; | |
2002 user_data = NULL; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2003 Xt_GET_VALUE (widget, XmNuserData, &user_data); |
428 | 2004 switch (type) |
2005 { | |
2006 case pre_activate: | |
2007 if (instance->info->pre_activate_cb) | |
2008 instance->info->pre_activate_cb (widget, id, user_data); | |
2009 break; | |
2010 case selection: | |
2011 if (instance->info->selection_cb) | |
2012 instance->info->selection_cb (widget, id, user_data); | |
2013 break; | |
2014 case no_selection: | |
2015 if (instance->info->selection_cb) | |
2016 instance->info->selection_cb (widget, id, (XtPointer) -1); | |
2017 break; | |
2018 case post_activate: | |
2019 if (instance->info->post_activate_cb) | |
2020 instance->info->post_activate_cb (widget, id, user_data); | |
2021 break; | |
2022 default: | |
2023 abort (); | |
2024 } | |
2025 } | |
2026 | |
2027 /* Like lw_internal_update_other_instances except that it does not do | |
2028 anything if its shell parent is not managed. This is to protect | |
2029 lw_internal_update_other_instances to dereference freed memory | |
2030 if the widget was ``destroyed'' by caching it in the all_destroyed_instances | |
2031 list */ | |
2032 static void | |
2033 xm_internal_update_other_instances (Widget widget, XtPointer closure, | |
2034 XtPointer call_data) | |
2035 { | |
2036 Widget parent; | |
2037 for (parent = widget; parent; parent = XtParent (parent)) | |
2038 if (XtIsShell (parent)) | |
2039 break; | |
2040 else if (!XtIsManaged (parent)) | |
2041 return; | |
2042 lw_internal_update_other_instances (widget, closure, call_data); | |
2043 } | |
2044 | |
2045 static void | |
2046 xm_generic_callback (Widget widget, XtPointer closure, XtPointer call_data) | |
2047 { | |
2048 #if (defined (LWLIB_MENUBARS_MOTIF) || defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_WIDGETS_MOTIF)) | |
2049 /* We want the selected status to change only when we decide it | |
2050 should change. Yuck but correct. */ | |
2051 if (XtClass (widget) == xmToggleButtonWidgetClass | |
2052 || XtClass (widget) == xmToggleButtonGadgetClass) | |
2053 { | |
2054 Boolean check; | |
2055 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2056 Xt_GET_VALUE (widget, XmNset, &check); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
2057 Xt_SET_VALUE (widget, XmNset, !check); |
428 | 2058 } |
2059 #endif | |
2060 lw_internal_update_other_instances (widget, closure, call_data); | |
2061 do_call (widget, closure, selection); | |
2062 } | |
2063 | |
1261 | 2064 #if 0 /* Caller above is commented out */ |
428 | 2065 static void |
2066 xm_pop_down_callback (Widget widget, XtPointer closure, XtPointer call_data) | |
2067 { | |
2068 do_call (widget, closure, post_activate); | |
2069 } | |
1261 | 2070 #endif /* 0 */ |
428 | 2071 |
2072 #ifdef LWLIB_MENUBARS_MOTIF | |
2073 | |
2074 static void | |
2075 xm_pull_down_callback (Widget widget, XtPointer closure, XtPointer call_data) | |
2076 { | |
2077 #if 0 | |
2078 if (call_data) | |
2079 { | |
2080 /* new behavior for incremental menu construction */ | |
2081 | |
2082 } | |
2083 else | |
2084 #endif | |
2085 do_call (widget, closure, pre_activate); | |
2086 } | |
2087 | |
2088 #endif /* LWLIB_MENUBARS_MOTIF */ | |
2089 | |
2090 #ifdef LWLIB_SCROLLBARS_MOTIF | |
2091 static void | |
2092 xm_scrollbar_callback (Widget widget, XtPointer closure, XtPointer call_data) | |
2093 { | |
2094 widget_instance *instance = (widget_instance *) closure; | |
2095 LWLIB_ID id; | |
2096 XmScrollBarCallbackStruct *data = | |
2097 (XmScrollBarCallbackStruct *) call_data; | |
2098 scroll_event event_data; | |
2099 scrollbar_values *val = | |
2100 (scrollbar_values *) instance->info->val->scrollbar_data; | |
2101 double percent; | |
2102 | |
2103 if (!instance || widget->core.being_destroyed) | |
2104 return; | |
2105 | |
2106 id = instance->info->id; | |
2107 | |
2108 percent = (double) (data->value - 1) / (double) (INT_MAX - 1); | |
2109 event_data.slider_value = | |
2110 (int) (percent * (double) (val->maximum - val->minimum)) + val->minimum; | |
2111 | |
2112 if (event_data.slider_value > (val->maximum - val->slider_size)) | |
2113 event_data.slider_value = val->maximum - val->slider_size; | |
2114 else if (event_data.slider_value < 1) | |
2115 event_data.slider_value = 1; | |
2116 | |
2117 if (data->event) | |
2118 { | |
2119 switch (data->event->xany.type) | |
2120 { | |
2121 case KeyPress: | |
2122 case KeyRelease: | |
2123 event_data.time = data->event->xkey.time; | |
2124 break; | |
2125 case ButtonPress: | |
2126 case ButtonRelease: | |
2127 event_data.time = data->event->xbutton.time; | |
2128 break; | |
2129 case MotionNotify: | |
2130 event_data.time = data->event->xmotion.time; | |
2131 break; | |
2132 case EnterNotify: | |
2133 case LeaveNotify: | |
2134 event_data.time = data->event->xcrossing.time; | |
2135 break; | |
2136 default: | |
2137 event_data.time = 0; | |
2138 break; | |
2139 } | |
2140 } | |
2141 else | |
2142 event_data.time = 0; | |
2143 | |
2144 switch (data->reason) | |
2145 { | |
2146 case XmCR_DECREMENT: | |
2147 event_data.action = SCROLLBAR_LINE_UP; | |
2148 break; | |
2149 case XmCR_INCREMENT: | |
2150 event_data.action = SCROLLBAR_LINE_DOWN; | |
2151 break; | |
2152 case XmCR_PAGE_DECREMENT: | |
2153 event_data.action = SCROLLBAR_PAGE_UP; | |
2154 break; | |
2155 case XmCR_PAGE_INCREMENT: | |
2156 event_data.action = SCROLLBAR_PAGE_DOWN; | |
2157 break; | |
2158 case XmCR_TO_TOP: | |
2159 event_data.action = SCROLLBAR_TOP; | |
2160 break; | |
2161 case XmCR_TO_BOTTOM: | |
2162 event_data.action = SCROLLBAR_BOTTOM; | |
2163 break; | |
2164 case XmCR_DRAG: | |
2165 event_data.action = SCROLLBAR_DRAG; | |
2166 break; | |
2167 case XmCR_VALUE_CHANGED: | |
2168 event_data.action = SCROLLBAR_CHANGE; | |
2169 break; | |
2170 default: | |
2171 event_data.action = SCROLLBAR_CHANGE; | |
2172 break; | |
2173 } | |
2174 | |
2175 if (instance->info->pre_activate_cb) | |
2176 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data); | |
2177 } | |
2178 #endif /* LWLIB_SCROLLBARS_MOTIF */ | |
2179 | |
2180 #if defined (LWLIB_DIALOGS_MOTIF) || defined (LWLIB_WIDGETS_MOTIF) | |
2181 static void | |
2311 | 2182 mark_dead_instance_destroyed (Widget UNUSED (widget), XtPointer closure, |
2183 XtPointer UNUSED (call_data)) | |
428 | 2184 { |
2185 destroyed_instance* instance = (destroyed_instance*)closure; | |
2186 instance->widget = NULL; | |
2187 } | |
2188 | |
2189 static void | |
2311 | 2190 xm_nosel_callback (Widget widget, XtPointer closure, |
2191 XtPointer UNUSED (call_data)) | |
428 | 2192 { |
2193 /* This callback is only called when a dialog box is dismissed with the wm's | |
2194 destroy button (WM_DELETE_WINDOW.) We want the dialog box to be destroyed | |
2195 in that case, not just unmapped, so that it releases its keyboard grabs. | |
2196 But there are problems with running our callbacks while the widget is in | |
2197 the process of being destroyed, so we set XmNdeleteResponse to XmUNMAP | |
2198 instead of XmDESTROY and then destroy it ourself after having run the | |
2199 callback. | |
2200 */ | |
2201 do_call (widget, closure, no_selection); | |
2202 XtDestroyWidget (widget); | |
2203 } | |
2204 #endif | |
2205 | |
2206 | |
2207 /* set the keyboard focus */ | |
2208 void | |
2286 | 2209 xm_set_keyboard_focus (Widget UNUSED (parent), Widget w) |
428 | 2210 { |
2211 XmProcessTraversal (w, XmTRAVERSE_CURRENT); | |
2212 /* At some point we believed that it was necessary to use XtSetKeyboardFocus | |
2213 instead of XmProcessTraversal when using Motif >= 1.2.1, but that's bogus. | |
2214 Presumably the problem was elsewhere, and is now gone... | |
2215 */ | |
2216 } |