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