Mercurial > emacs
annotate lwlib/lwlib-Xm.c @ 27091:fc4fd4d41cc7
*** empty log message ***
author | Eli Zaretskii <eliz@gnu.org> |
---|---|
date | Sun, 02 Jan 2000 14:13:48 +0000 |
parents | e0d966fb548f |
children | a5bceda5d689 |
rev | line source |
---|---|
5626 | 1 /* The lwlib interface to Motif widgets. |
2 Copyright (C) 1992 Lucid, Inc. | |
3 | |
4 This file is part of the Lucid Widget Library. | |
5 | |
6 The Lucid Widget Library is free software; you can redistribute it and/or | |
7 modify it under the terms of the GNU General Public License as published by | |
8 the Free Software Foundation; either version 1, or (at your option) | |
9 any later version. | |
10 | |
11 The Lucid Widget Library is distributed in the hope that it will be useful, | |
12 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 GNU General Public License for more details. | |
15 | |
16 You should have received a copy of the GNU General Public License | |
17 along with GNU Emacs; see the file COPYING. If not, write to | |
14186
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14018
diff
changeset
|
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
ee40177f6c68
Update FSF's address in the preamble.
Erik Naggum <erik@naggum.no>
parents:
14018
diff
changeset
|
19 Boston, MA 02111-1307, USA. */ |
5626 | 20 |
26087
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25885
diff
changeset
|
21 #ifdef HAVE_CONFIG_H |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25885
diff
changeset
|
22 #include <config.h> |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25885
diff
changeset
|
23 #endif |
e0d966fb548f
Add support for large files, plus some locale improvements.
Paul Eggert <eggert@twinsun.com>
parents:
25885
diff
changeset
|
24 |
5626 | 25 #include <unistd.h> |
26 #include <stdio.h> | |
27 | |
28 #include <X11/StringDefs.h> | |
29 #include <X11/IntrinsicP.h> | |
30 #include <X11/ObjectP.h> | |
31 #include <X11/CoreP.h> | |
32 #include <X11/CompositeP.h> | |
33 | |
34 #include "lwlib-Xm.h" | |
35 #include "lwlib-utils.h" | |
36 | |
37 #include <Xm/BulletinB.h> | |
38 #include <Xm/CascadeB.h> | |
14931
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
39 #include <Xm/CascadeBG.h> |
5626 | 40 #include <Xm/DrawingA.h> |
41 #include <Xm/FileSB.h> | |
42 #include <Xm/Label.h> | |
43 #include <Xm/List.h> | |
8784 | 44 #include <Xm/MainW.h> |
5626 | 45 #include <Xm/MenuShell.h> |
46 #include <Xm/MessageB.h> | |
8784 | 47 #include <Xm/PanedW.h> |
5626 | 48 #include <Xm/PushB.h> |
49 #include <Xm/PushBG.h> | |
50 #include <Xm/ArrowB.h> | |
51 #include <Xm/SelectioB.h> | |
52 #include <Xm/Text.h> | |
53 #include <Xm/TextF.h> | |
54 #include <Xm/ToggleB.h> | |
55 #include <Xm/ToggleBG.h> | |
56 #include <Xm/RowColumn.h> | |
57 #include <Xm/ScrolledW.h> | |
58 #include <Xm/Separator.h> | |
59 #include <Xm/DialogS.h> | |
60 #include <Xm/Form.h> | |
61 | |
25037 | 62 #ifdef __STDC__ |
63 #define P_(X) X | |
64 #else | |
65 #define P_(X) () | |
66 #endif | |
5626 | 67 |
25037 | 68 enum do_call_type { pre_activate, selection, no_selection, post_activate }; |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
69 |
5626 | 70 |
71 /* Structures to keep destroyed instances */ | |
72 typedef struct _destroyed_instance | |
73 { | |
74 char* name; | |
75 char* type; | |
76 Widget widget; | |
77 Widget parent; | |
78 Boolean pop_up_p; | |
79 struct _destroyed_instance* next; | |
80 } destroyed_instance; | |
81 | |
25037 | 82 static destroyed_instance *make_destroyed_instance P_ ((char *, char *, |
83 Widget, Widget, | |
84 Boolean)); | |
85 static void free_destroyed_instance P_ ((destroyed_instance*)); | |
86 Widget first_child P_ ((Widget)); | |
87 Boolean lw_motif_widget_p P_ ((Widget)); | |
88 static XmString resource_motif_string P_ ((Widget, char *)); | |
89 static void destroy_all_children P_ ((Widget, int)); | |
90 static void xm_update_label P_ ((widget_instance *, Widget, widget_value *)); | |
91 static void xm_update_list P_ ((widget_instance *, Widget, widget_value *)); | |
92 static void xm_update_pushbutton P_ ((widget_instance *, Widget, | |
93 widget_value *)); | |
94 static void xm_update_cascadebutton P_ ((widget_instance *, Widget, | |
95 widget_value *)); | |
96 static void xm_update_toggle P_ ((widget_instance *, Widget, widget_value *)); | |
97 static void xm_update_radiobox P_ ((widget_instance *, Widget, widget_value *)); | |
98 static void make_menu_in_widget P_ ((widget_instance *, Widget, | |
99 widget_value *, int)); | |
100 static void update_one_menu_entry P_ ((widget_instance *, Widget, | |
101 widget_value *, Boolean)); | |
102 static void xm_update_menu P_ ((widget_instance *, Widget, widget_value *, | |
103 Boolean)); | |
104 static void xm_update_text P_ ((widget_instance *, Widget, widget_value *)); | |
105 static void xm_update_text_field P_ ((widget_instance *, Widget, | |
106 widget_value *)); | |
107 void xm_update_one_value P_ ((widget_instance *, Widget, widget_value *)); | |
108 static void activate_button P_ ((Widget, XtPointer, XtPointer)); | |
109 static Widget make_dialog P_ ((char *, Widget, Boolean, char *, char *, | |
110 Boolean, Boolean, Boolean, int, int)); | |
111 static destroyed_instance* find_matching_instance P_ ((widget_instance*)); | |
112 static void mark_dead_instance_destroyed P_ ((Widget, XtPointer, XtPointer)); | |
113 static void recenter_widget P_ ((Widget)); | |
114 static Widget recycle_instance P_ ((destroyed_instance*)); | |
115 Widget xm_create_dialog P_ ((widget_instance*)); | |
116 static Widget make_menubar P_ ((widget_instance*)); | |
117 static void remove_grabs P_ ((Widget, XtPointer, XtPointer)); | |
118 static Widget make_popup_menu P_ ((widget_instance*)); | |
119 static Widget make_main P_ ((widget_instance*)); | |
120 void xm_destroy_instance P_ ((widget_instance*)); | |
121 void xm_popup_menu P_ ((Widget, XEvent *)); | |
122 static void set_min_dialog_size P_ ((Widget)); | |
123 static void do_call P_ ((Widget, XtPointer, enum do_call_type)); | |
124 static void xm_generic_callback P_ ((Widget, XtPointer, XtPointer)); | |
125 static void xm_nosel_callback P_ ((Widget, XtPointer, XtPointer)); | |
126 static void xm_pull_down_callback P_ ((Widget, XtPointer, XtPointer)); | |
127 static void xm_pop_down_callback P_ ((Widget, XtPointer, XtPointer)); | |
128 void xm_set_keyboard_focus P_ ((Widget, Widget)); | |
129 void xm_set_main_areas P_ ((Widget, Widget, Widget)); | |
130 static void xm_internal_update_other_instances P_ ((Widget, XtPointer, | |
131 XtPointer)); | |
132 | |
133 #if 0 | |
134 void xm_update_one_widget P_ ((widget_instance *, Widget, widget_value *, | |
135 Boolean)); | |
136 void xm_pop_instance P_ ((widget_instance*, Boolean)); | |
137 void xm_manage_resizing P_ ((Widget, Boolean)); | |
138 #endif | |
139 | |
140 | |
5626 | 141 static destroyed_instance* |
142 all_destroyed_instances = NULL; | |
143 | |
144 static destroyed_instance* | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
145 make_destroyed_instance (name, type, widget, parent, pop_up_p) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
146 char* name; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
147 char* type; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
148 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
149 Widget parent; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
150 Boolean pop_up_p; |
5626 | 151 { |
152 destroyed_instance* instance = | |
153 (destroyed_instance*)malloc (sizeof (destroyed_instance)); | |
8784 | 154 instance->name = safe_strdup (name); |
155 instance->type = safe_strdup (type); | |
5626 | 156 instance->widget = widget; |
157 instance->parent = parent; | |
158 instance->pop_up_p = pop_up_p; | |
159 instance->next = NULL; | |
160 return instance; | |
161 } | |
162 | |
163 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
164 free_destroyed_instance (instance) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
165 destroyed_instance* instance; |
5626 | 166 { |
167 free (instance->name); | |
168 free (instance->type); | |
169 free (instance); | |
170 } | |
171 | |
172 /* motif utility functions */ | |
173 Widget | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
174 first_child (widget) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
175 Widget widget; |
5626 | 176 { |
177 return ((CompositeWidget)widget)->composite.children [0]; | |
178 } | |
179 | |
180 Boolean | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
181 lw_motif_widget_p (widget) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
182 Widget widget; |
5626 | 183 { |
184 return | |
185 XtClass (widget) == xmDialogShellWidgetClass | |
186 || XmIsPrimitive (widget) || XmIsManager (widget) || XmIsGadget (widget); | |
187 } | |
188 | |
189 static XmString | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
190 resource_motif_string (widget, name) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
191 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
192 char* name; |
5626 | 193 { |
194 XtResource resource; | |
195 XmString result = 0; | |
196 | |
197 resource.resource_name = name; | |
198 resource.resource_class = XmCXmString; | |
199 resource.resource_type = XmRXmString; | |
200 resource.resource_size = sizeof (XmString); | |
201 resource.resource_offset = 0; | |
202 resource.default_type = XtRImmediate; | |
203 resource.default_addr = 0; | |
204 | |
205 XtGetSubresources (widget, (XtPointer)&result, "dialogString", | |
206 "DialogString", &resource, 1, NULL, 0); | |
207 return result; | |
208 } | |
209 | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
210 /* Destroy all of the children of WIDGET |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
211 starting with number FIRST_CHILD_TO_DESTROY. */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
212 |
5626 | 213 static void |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
214 destroy_all_children (widget, first_child_to_destroy) |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
215 Widget widget; |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
216 int first_child_to_destroy; |
5626 | 217 { |
218 Widget* children; | |
219 unsigned int number; | |
220 int i; | |
221 | |
222 children = XtCompositeChildren (widget, &number); | |
223 if (children) | |
224 { | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
225 XtUnmanageChildren (children + first_child_to_destroy, |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
226 number - first_child_to_destroy); |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
227 |
5626 | 228 /* Unmanage all children and destroy them. They will only be |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
229 really destroyed when we get out of DispatchEvent. */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
230 for (i = first_child_to_destroy; i < number; i++) |
14931
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
231 { |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
232 Arg al[2]; |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
233 Widget submenu = 0; |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
234 /* Cascade buttons have submenus,and these submenus |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
235 need to be freed. But they are not included in |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
236 XtCompositeChildren. So get it out of the cascade button |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
237 and free it. If this child is not a cascade button, |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
238 then submenu should remain unchanged. */ |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
239 XtSetArg (al[0], XmNsubMenuId, &submenu); |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
240 XtGetValues (children[i], al, 1); |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
241 if (submenu) |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
242 XtDestroyWidget (submenu); |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
243 XtDestroyWidget (children[i]); |
0706926a11cb
(destroy_all_children): When freeing a cascade button, free its submenu too.
Richard M. Stallman <rms@gnu.org>
parents:
14877
diff
changeset
|
244 } |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
245 |
5626 | 246 XtFree ((char *) children); |
247 } | |
248 } | |
249 | |
25037 | 250 |
251 /* Update the label of widget WIDGET. WIDGET must be a Label widget | |
252 or a subclass of Label. WIDGET_INSTANCE is unused. VAL contains | |
253 the value to update. | |
254 | |
255 Menus: | |
256 | |
257 Emacs fills VAL->name with the text to display in the menu, and | |
258 sets VAL->value to null. Function make_menu_in_widget creates | |
259 widgets with VAL->name as resource name. This works because the | |
260 Label widget uses its resource name for display if no | |
261 XmNlabelString is set. | |
262 | |
263 Dialogs: | |
264 | |
265 VAL->name is again set to the resource name, but VAL->value is | |
266 not null, and contains the label string to display. */ | |
267 | |
5626 | 268 static void |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
269 xm_update_label (instance, widget, val) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
270 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
271 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
272 widget_value* val; |
5626 | 273 { |
274 XmString res_string = 0; | |
275 XmString built_string = 0; | |
276 XmString key_string = 0; | |
277 Arg al [256]; | |
278 int ac; | |
25037 | 279 |
5626 | 280 ac = 0; |
281 | |
282 if (val->value) | |
283 { | |
25037 | 284 /* A label string is specified, i.e. we are in a dialog. First |
285 see if it is overridden by something from the resource file. */ | |
5626 | 286 res_string = resource_motif_string (widget, val->value); |
287 | |
288 if (res_string) | |
289 { | |
290 XtSetArg (al [ac], XmNlabelString, res_string); ac++; | |
291 } | |
292 else | |
293 { | |
294 built_string = | |
295 XmStringCreateLtoR (val->value, XmSTRING_DEFAULT_CHARSET); | |
296 XtSetArg (al [ac], XmNlabelString, built_string); ac++; | |
297 } | |
25037 | 298 |
5626 | 299 XtSetArg (al [ac], XmNlabelType, XmSTRING); ac++; |
300 } | |
301 | |
302 if (val->key) | |
303 { | |
304 key_string = XmStringCreateLtoR (val->key, XmSTRING_DEFAULT_CHARSET); | |
305 XtSetArg (al [ac], XmNacceleratorText, key_string); ac++; | |
306 } | |
307 | |
308 if (ac) | |
309 XtSetValues (widget, al, ac); | |
310 | |
311 if (built_string) | |
312 XmStringFree (built_string); | |
313 | |
314 if (key_string) | |
315 XmStringFree (key_string); | |
316 } | |
317 | |
318 /* update of list */ | |
319 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
320 xm_update_list (instance, widget, val) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
321 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
322 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
323 widget_value* val; |
5626 | 324 { |
325 widget_value* cur; | |
326 int i; | |
327 XtRemoveAllCallbacks (widget, XmNsingleSelectionCallback); | |
328 XtAddCallback (widget, XmNsingleSelectionCallback, xm_generic_callback, | |
329 instance); | |
330 for (cur = val->contents, i = 0; cur; cur = cur->next) | |
331 if (cur->value) | |
332 { | |
333 XmString xmstr = XmStringCreate (cur->value, XmSTRING_DEFAULT_CHARSET); | |
334 i += 1; | |
335 XmListAddItem (widget, xmstr, 0); | |
336 if (cur->selected) | |
337 XmListSelectPos (widget, i, False); | |
338 XmStringFree (xmstr); | |
339 } | |
340 } | |
341 | |
342 /* update of buttons */ | |
343 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
344 xm_update_pushbutton (instance, widget, val) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
345 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
346 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
347 widget_value* val; |
5626 | 348 { |
349 XtVaSetValues (widget, XmNalignment, XmALIGNMENT_CENTER, 0); | |
350 XtRemoveAllCallbacks (widget, XmNactivateCallback); | |
351 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance); | |
352 } | |
353 | |
354 static void | |
11862
10a973a88e87
(activate_button, xm_update_cascadebutton): Don't use prototype.
Karl Heuer <kwzh@gnu.org>
parents:
11435
diff
changeset
|
355 xm_update_cascadebutton (instance, widget, val) |
10a973a88e87
(activate_button, xm_update_cascadebutton): Don't use prototype.
Karl Heuer <kwzh@gnu.org>
parents:
11435
diff
changeset
|
356 widget_instance* instance; |
10a973a88e87
(activate_button, xm_update_cascadebutton): Don't use prototype.
Karl Heuer <kwzh@gnu.org>
parents:
11435
diff
changeset
|
357 Widget widget; |
10a973a88e87
(activate_button, xm_update_cascadebutton): Don't use prototype.
Karl Heuer <kwzh@gnu.org>
parents:
11435
diff
changeset
|
358 widget_value* val; |
5626 | 359 { |
360 /* Should also rebuild the menu by calling ...update_menu... */ | |
361 XtRemoveAllCallbacks (widget, XmNcascadingCallback); | |
362 XtAddCallback (widget, XmNcascadingCallback, xm_pull_down_callback, | |
363 instance); | |
364 } | |
365 | |
366 /* update toggle and radiobox */ | |
367 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
368 xm_update_toggle (instance, widget, val) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
369 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
370 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
371 widget_value* val; |
5626 | 372 { |
373 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback); | |
374 XtAddCallback (widget, XmNvalueChangedCallback, | |
25037 | 375 xm_generic_callback, instance); |
5626 | 376 XtVaSetValues (widget, XmNset, val->selected, |
377 XmNalignment, XmALIGNMENT_BEGINNING, 0); | |
378 } | |
379 | |
380 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
381 xm_update_radiobox (instance, widget, val) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
382 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
383 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
384 widget_value* val; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
385 |
5626 | 386 { |
387 Widget toggle; | |
388 widget_value* cur; | |
389 | |
390 /* update the callback */ | |
391 XtRemoveAllCallbacks (widget, XmNentryCallback); | |
392 XtAddCallback (widget, XmNentryCallback, xm_generic_callback, instance); | |
393 | |
394 /* first update all the toggles */ | |
395 /* Energize kernel interface is currently bad. It sets the selected widget | |
396 with the selected flag but returns it by its name. So we currently | |
397 have to support both setting the selection with the selected slot | |
398 of val contents and setting it with the "value" slot of val. The latter | |
399 has a higher priority. This to be removed when the kernel is fixed. */ | |
400 for (cur = val->contents; cur; cur = cur->next) | |
401 { | |
402 toggle = XtNameToWidget (widget, cur->value); | |
403 if (toggle) | |
404 { | |
405 XtVaSetValues (toggle, XmNsensitive, cur->enabled, 0); | |
406 if (!val->value && cur->selected) | |
407 XtVaSetValues (toggle, XmNset, cur->selected, 0); | |
408 if (val->value && strcmp (val->value, cur->value)) | |
409 XtVaSetValues (toggle, XmNset, False, 0); | |
410 } | |
411 } | |
412 | |
413 /* The selected was specified by the value slot */ | |
414 if (val->value) | |
415 { | |
416 toggle = XtNameToWidget (widget, val->value); | |
417 if (toggle) | |
418 XtVaSetValues (toggle, XmNset, True, 0); | |
419 } | |
420 } | |
421 | |
25037 | 422 |
423 /* update a popup menu, pulldown menu or a menubar */ | |
5626 | 424 |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
425 /* KEEP_FIRST_CHILDREN gives the number of initial children to keep. */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
426 |
5626 | 427 static void |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
428 make_menu_in_widget (instance, widget, val, keep_first_children) |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
429 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
430 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
431 widget_value* val; |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
432 int keep_first_children; |
5626 | 433 { |
434 Widget* children = 0; | |
435 int num_children; | |
436 int child_index; | |
437 widget_value* cur; | |
438 Widget button = 0; | |
25037 | 439 Widget title = 0; |
5626 | 440 Widget menu; |
441 Arg al [256]; | |
442 int ac; | |
443 Boolean menubar_p; | |
25037 | 444 unsigned char type; |
5626 | 445 |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
446 Widget* old_children; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
447 unsigned int old_num_children; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
448 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
449 old_children = XtCompositeChildren (widget, &old_num_children); |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
450 |
5626 | 451 /* Allocate the children array */ |
452 for (num_children = 0, cur = val; cur; num_children++, cur = cur->next); | |
453 children = (Widget*)XtMalloc (num_children * sizeof (Widget)); | |
454 | |
25037 | 455 /* WIDGET should be a RowColumn. */ |
456 if (!XmIsRowColumn (widget)) | |
457 abort (); | |
458 | |
459 /* Determine whether WIDGET is a menu bar. */ | |
460 type = -1; | |
461 XtSetArg (al[0], XmNrowColumnType, &type); | |
5626 | 462 XtGetValues (widget, al, 1); |
25037 | 463 if (type != XmMENU_BAR && type != XmMENU_PULLDOWN && type != XmMENU_POPUP) |
464 abort (); | |
465 menubar_p = type == XmMENU_BAR; | |
5626 | 466 |
25037 | 467 /* Add a callback to popups and pulldowns that is called when |
468 it is made invisible again. */ | |
5626 | 469 if (!menubar_p) |
470 XtAddCallback (XtParent (widget), XmNpopdownCallback, | |
471 xm_pop_down_callback, (XtPointer)instance); | |
472 | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
473 /* Preserve the first KEEP_FIRST_CHILDREN old children. */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
474 for (child_index = 0, cur = val; child_index < keep_first_children; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
475 child_index++, cur = cur->next) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
476 children[child_index] = old_children[child_index]; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
477 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
478 /* Check that those are all we have |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
479 (the caller should have deleted the rest). */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
480 if (old_num_children != keep_first_children) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
481 abort (); |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
482 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
483 /* Create the rest. */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
484 for (child_index = keep_first_children; cur; child_index++, cur = cur->next) |
25037 | 485 { |
486 enum menu_separator separator; | |
487 | |
5626 | 488 ac = 0; |
25037 | 489 XtSetArg (al[ac], XmNsensitive, cur->enabled); ac++; |
490 XtSetArg (al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; | |
491 XtSetArg (al[ac], XmNuserData, cur->call_data); ac++; | |
5626 | 492 |
9835
d2250d1b0f48
(make_menu_in_widget): Differentiate a separator entry ("--") from a
Paul Reilly <pmr@pajato.com>
parents:
9825
diff
changeset
|
493 if (instance->pop_up_p && !cur->contents && !cur->call_data |
25037 | 494 && !lw_separator_p (cur->name, &separator, 1)) |
9224
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
495 { |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
496 ac = 0; |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
497 XtSetArg (al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++; |
25037 | 498 title = button = XmCreateLabel (widget, cur->name, al, ac); |
9224
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
499 } |
25037 | 500 else if (lw_separator_p (cur->name, &separator, 1)) |
5626 | 501 { |
25037 | 502 ac = 0; |
503 XtSetArg (al[ac], XmNseparatorType, separator); ++ac; | |
504 button = XmCreateSeparator (widget, cur->name, al, ac); | |
5626 | 505 } |
506 else if (!cur->contents) | |
507 { | |
508 if (menubar_p) | |
509 button = XmCreateCascadeButton (widget, cur->name, al, ac); | |
510 else if (!cur->call_data) | |
511 button = XmCreateLabel (widget, cur->name, al, ac); | |
25037 | 512 else if (cur->button_type == BUTTON_TYPE_TOGGLE |
513 || cur->button_type == BUTTON_TYPE_RADIO) | |
514 { | |
515 XtSetArg (al[ac], XmNset, cur->selected); ++ac; | |
516 XtSetArg (al[ac], XmNvisibleWhenOff, True); ++ac; | |
517 XtSetArg (al[ac], XmNindicatorType, | |
518 (cur->button_type == BUTTON_TYPE_TOGGLE | |
519 ? XmN_OF_MANY : XmONE_OF_MANY)); | |
520 ++ac; | |
25885
6a0fe1278e4d
(make_menu_in_widget, update_one_menu_entry): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25037
diff
changeset
|
521 button = XmCreateToggleButton (widget, cur->name, al, ac); |
25037 | 522 } |
5626 | 523 else |
25885
6a0fe1278e4d
(make_menu_in_widget, update_one_menu_entry): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25037
diff
changeset
|
524 button = XmCreatePushButton (widget, cur->name, al, ac); |
5626 | 525 |
526 xm_update_label (instance, button, cur); | |
25037 | 527 |
528 /* Add a callback that is called when the button is | |
529 selected. Toggle buttons don't support | |
530 XmNactivateCallback, we use XmNvalueChangedCallback in | |
531 that case. Don't add a callback to a simple label. */ | |
532 if (cur->button_type) | |
533 xm_update_toggle (instance, button, cur); | |
534 else if (cur->call_data) | |
5626 | 535 XtAddCallback (button, XmNactivateCallback, xm_generic_callback, |
536 (XtPointer)instance); | |
537 } | |
538 else | |
539 { | |
11435
efaaecd960ae
(update_one_menu_entry, make_menu_in_widget):
Richard M. Stallman <rms@gnu.org>
parents:
11299
diff
changeset
|
540 menu = XmCreatePulldownMenu (widget, cur->name, NULL, 0); |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
541 make_menu_in_widget (instance, menu, cur->contents, 0); |
15375
1beabd8b78a1
(make_menu_in_widget): Set mapping delay
Richard M. Stallman <rms@gnu.org>
parents:
14931
diff
changeset
|
542 XtSetArg (al [ac], XmNsubMenuId, menu); ac++; |
25037 | 543 /* Non-zero values don't work reliably in conjunction with |
544 Emacs' event loop */ | |
15375
1beabd8b78a1
(make_menu_in_widget): Set mapping delay
Richard M. Stallman <rms@gnu.org>
parents:
14931
diff
changeset
|
545 XtSetArg (al [ac], XmNmappingDelay, 0); ac++; |
25885
6a0fe1278e4d
(make_menu_in_widget, update_one_menu_entry): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25037
diff
changeset
|
546 button = XmCreateCascadeButton (widget, cur->name, al, ac); |
5626 | 547 |
548 xm_update_label (instance, button, cur); | |
549 | |
550 XtAddCallback (button, XmNcascadingCallback, xm_pull_down_callback, | |
551 (XtPointer)instance); | |
552 } | |
553 | |
25037 | 554 children[child_index] = button; |
5626 | 555 } |
556 | |
25037 | 557 /* Last entry is the help button. The original comment read "Has to |
558 be done after managing the buttons otherwise the menubar is only | |
559 4 pixels high." This is no longer true, and to make | |
560 XmNmenuHelpWidget work, we need to set it before managing the | |
561 children.. --gerd. */ | |
5626 | 562 if (button) |
25037 | 563 XtVaSetValues (widget, XmNmenuHelpWidget, button, 0); |
564 | |
565 /* LessTif apparently doesn't recompute centered text when more | |
566 widgets are added. So, do it after all widgets have been | |
567 created. */ | |
568 if (title) | |
569 XtVaSetValues (title, XmNalignment, XmALIGNMENT_CENTER, 0); | |
570 | |
571 if (num_children) | |
572 XtManageChildren (children, num_children); | |
5626 | 573 |
574 XtFree ((char *) children); | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
575 if (old_children) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
576 XtFree ((char *) old_children); |
5626 | 577 } |
578 | |
579 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
580 update_one_menu_entry (instance, widget, val, deep_p) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
581 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
582 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
583 widget_value* val; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
584 Boolean deep_p; |
5626 | 585 { |
586 Arg al [256]; | |
587 int ac; | |
588 Widget menu; | |
589 widget_value* contents; | |
590 | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
591 if (val->this_one_change == NO_CHANGE) |
5626 | 592 return; |
593 | |
594 /* update the sensitivity and userdata */ | |
595 /* Common to all widget types */ | |
596 XtVaSetValues (widget, | |
597 XmNsensitive, val->enabled, | |
598 XmNuserData, val->call_data, | |
599 0); | |
600 | |
601 /* update the menu button as a label. */ | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
602 if (val->this_one_change >= VISIBLE_CHANGE) |
25037 | 603 { |
604 xm_update_label (instance, widget, val); | |
605 if (val->button_type) | |
606 xm_update_toggle (instance, widget, val); | |
607 } | |
5626 | 608 |
609 /* update the pulldown/pullaside as needed */ | |
610 ac = 0; | |
611 menu = NULL; | |
612 XtSetArg (al [ac], XmNsubMenuId, &menu); ac++; | |
613 XtGetValues (widget, al, ac); | |
614 | |
615 contents = val->contents; | |
616 | |
617 if (!menu) | |
618 { | |
619 if (contents) | |
620 { | |
15853
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
621 unsigned int old_num_children, i; |
15859
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
622 Widget parent; |
15853
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
623 Widget *widget_list; |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
624 |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
625 parent = XtParent (widget); |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
626 widget_list = XtCompositeChildren (parent, &old_num_children); |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
627 |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
628 /* Find the widget position within the parent's widget list. */ |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
629 for (i = 0; i < old_num_children; i++) |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
630 if (strcmp (XtName (widget_list[i]), XtName (widget)) == 0) |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
631 break; |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
632 if (i == old_num_children) |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
633 abort (); |
15859
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
634 if (XmIsCascadeButton (widget_list[i])) |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
635 { |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
636 menu = XmCreatePulldownMenu (parent, XtName(widget), NULL, 0); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
637 make_menu_in_widget (instance, menu, contents, 0); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
638 ac = 0; |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
639 XtSetArg (al [ac], XmNsubMenuId, menu); ac++; |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
640 XtSetValues (widget, al, ac); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
641 } |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
642 else |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
643 { |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
644 Widget button; |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
645 |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
646 /* The current menuitem is a XmPushButtonGadget, it |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
647 needs to be replaced by a CascadeButtonGadget */ |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
648 XtDestroyWidget (widget_list[i]); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
649 menu = XmCreatePulldownMenu (parent, val->name, NULL, 0); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
650 make_menu_in_widget (instance, menu, contents, 0); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
651 ac = 0; |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
652 XtSetArg (al [ac], XmNsubMenuId, menu); ac++; |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
653 /* Non-zero values don't work reliably in |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
654 conjunction with Emacs' event loop */ |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
655 XtSetArg (al [ac], XmNmappingDelay, 0); ac++; |
20471
d4e514328333
(update_one_menu_entry): Add conditional in case XmNpositionIndex is missing.
Richard M. Stallman <rms@gnu.org>
parents:
15859
diff
changeset
|
656 #ifdef XmNpositionIndex /* This is undefined on SCO ODT 2.0. */ |
15859
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
657 /* Tell Motif to put it in the right place */ |
20471
d4e514328333
(update_one_menu_entry): Add conditional in case XmNpositionIndex is missing.
Richard M. Stallman <rms@gnu.org>
parents:
15859
diff
changeset
|
658 XtSetArg (al [ac], XmNpositionIndex , i); ac++; |
d4e514328333
(update_one_menu_entry): Add conditional in case XmNpositionIndex is missing.
Richard M. Stallman <rms@gnu.org>
parents:
15859
diff
changeset
|
659 #endif |
25885
6a0fe1278e4d
(make_menu_in_widget, update_one_menu_entry): Use
Gerd Moellmann <gerd@gnu.org>
parents:
25037
diff
changeset
|
660 button = XmCreateCascadeButton (parent, val->name, al, ac); |
15859
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
661 xm_update_label (instance, button, val); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
662 |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
663 XtAddCallback (button, XmNcascadingCallback, xm_pull_down_callback, |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
664 (XtPointer)instance); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
665 XtManageChild (button); |
2cb422e2d16c
(update_one_menu_entry): Fix previous change:
Richard M. Stallman <rms@gnu.org>
parents:
15853
diff
changeset
|
666 } |
5626 | 667 } |
668 } | |
669 else if (!contents) | |
670 { | |
671 ac = 0; | |
672 XtSetArg (al [ac], XmNsubMenuId, NULL); ac++; | |
673 XtSetValues (widget, al, ac); | |
674 XtDestroyWidget (menu); | |
675 } | |
676 else if (deep_p && contents->change != NO_CHANGE) | |
677 xm_update_menu (instance, menu, val, 1); | |
678 } | |
679 | |
680 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
681 xm_update_menu (instance, widget, val, deep_p) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
682 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
683 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
684 widget_value* val; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
685 Boolean deep_p; |
5626 | 686 { |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
687 Widget* children; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
688 unsigned int num_children; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
689 int num_children_to_keep = 0; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
690 int i; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
691 widget_value* cur; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
692 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
693 children = XtCompositeChildren (widget, &num_children); |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
694 |
5626 | 695 /* Widget is a RowColumn widget whose contents have to be updated |
696 * to reflect the list of items in val->contents */ | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
697 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
698 /* See how many buttons we can keep, and how many we |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
699 must completely replace. */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
700 if (val->contents == 0) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
701 num_children_to_keep = 0; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
702 else if (val->contents->change == STRUCTURAL_CHANGE) |
5626 | 703 { |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
704 if (children) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
705 { |
15665
432750098147
(xm_update_menu): Fix loop termination test.
Karl Heuer <kwzh@gnu.org>
parents:
15630
diff
changeset
|
706 for (i = 0, cur = val->contents; |
432750098147
(xm_update_menu): Fix loop termination test.
Karl Heuer <kwzh@gnu.org>
parents:
15630
diff
changeset
|
707 (i < num_children |
432750098147
(xm_update_menu): Fix loop termination test.
Karl Heuer <kwzh@gnu.org>
parents:
15630
diff
changeset
|
708 && cur); /* how else to ditch unwanted children ?? - mgd */ |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
709 i++, cur = cur->next) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
710 { |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
711 if (cur->this_one_change == STRUCTURAL_CHANGE) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
712 break; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
713 } |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
714 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
715 num_children_to_keep = i; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
716 } |
5626 | 717 } |
718 else | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
719 num_children_to_keep = num_children; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
720 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
721 /* Update all the buttons of the RowColumn, in order, |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
722 except for those we are going to replace entirely. */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
723 if (children) |
5626 | 724 { |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
725 for (i = 0, cur = val->contents; i < num_children_to_keep; i++) |
5626 | 726 { |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
727 if (!cur) |
15853
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
728 { |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
729 num_children_to_keep = i; |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
730 break; |
1ca5c3c9853a
(update_one_menu_entry): When creating a pulldown
Richard M. Stallman <rms@gnu.org>
parents:
15816
diff
changeset
|
731 } |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
732 if (children [i]->core.being_destroyed |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
733 || strcmp (XtName (children [i]), cur->name)) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
734 continue; |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
735 update_one_menu_entry (instance, children [i], cur, deep_p); |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
736 cur = cur->next; |
5626 | 737 } |
738 } | |
14877
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
739 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
740 /* Now replace from scratch all the buttons after the last |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
741 place that the top-level structure changed. */ |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
742 if (val->contents->change == STRUCTURAL_CHANGE) |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
743 { |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
744 destroy_all_children (widget, num_children_to_keep); |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
745 make_menu_in_widget (instance, widget, val->contents, |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
746 num_children_to_keep); |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
747 } |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
748 |
62fc4d7a846f
(destroy_all_children): New arg first_child_to_destroy.
Richard M. Stallman <rms@gnu.org>
parents:
14186
diff
changeset
|
749 XtFree ((char *) children); |
5626 | 750 } |
751 | |
752 | |
753 /* update text widgets */ | |
754 | |
755 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
756 xm_update_text (instance, widget, val) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
757 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
758 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
759 widget_value* val; |
5626 | 760 { |
761 XmTextSetString (widget, val->value ? val->value : ""); | |
762 XtRemoveAllCallbacks (widget, XmNactivateCallback); | |
763 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance); | |
764 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback); | |
765 XtAddCallback (widget, XmNvalueChangedCallback, | |
766 xm_internal_update_other_instances, instance); | |
767 } | |
768 | |
769 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
770 xm_update_text_field (instance, widget, val) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
771 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
772 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
773 widget_value* val; |
5626 | 774 { |
775 XmTextFieldSetString (widget, val->value ? val->value : ""); | |
776 XtRemoveAllCallbacks (widget, XmNactivateCallback); | |
777 XtAddCallback (widget, XmNactivateCallback, xm_generic_callback, instance); | |
778 XtRemoveAllCallbacks (widget, XmNvalueChangedCallback); | |
779 XtAddCallback (widget, XmNvalueChangedCallback, | |
780 xm_internal_update_other_instances, instance); | |
781 } | |
782 | |
783 | |
784 /* update a motif widget */ | |
785 | |
786 void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
787 xm_update_one_widget (instance, widget, val, deep_p) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
788 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
789 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
790 widget_value* val; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
791 Boolean deep_p; |
5626 | 792 { |
793 WidgetClass class; | |
794 | |
795 /* Mark as not edited */ | |
796 val->edited = False; | |
797 | |
798 /* Common to all widget types */ | |
799 XtVaSetValues (widget, | |
800 XmNsensitive, val->enabled, | |
801 XmNuserData, val->call_data, | |
802 0); | |
803 | |
804 /* Common to all label like widgets */ | |
805 if (XtIsSubclass (widget, xmLabelWidgetClass)) | |
806 xm_update_label (instance, widget, val); | |
807 | |
808 class = XtClass (widget); | |
809 /* Class specific things */ | |
810 if (class == xmPushButtonWidgetClass || | |
811 class == xmArrowButtonWidgetClass) | |
812 { | |
813 xm_update_pushbutton (instance, widget, val); | |
814 } | |
815 else if (class == xmCascadeButtonWidgetClass) | |
816 { | |
817 xm_update_cascadebutton (instance, widget, val); | |
818 } | |
819 else if (class == xmToggleButtonWidgetClass | |
820 || class == xmToggleButtonGadgetClass) | |
821 { | |
822 xm_update_toggle (instance, widget, val); | |
823 } | |
824 else if (class == xmRowColumnWidgetClass) | |
825 { | |
826 Boolean radiobox = 0; | |
827 int ac = 0; | |
828 Arg al [1]; | |
829 | |
830 XtSetArg (al [ac], XmNradioBehavior, &radiobox); ac++; | |
831 XtGetValues (widget, al, ac); | |
832 | |
833 if (radiobox) | |
834 xm_update_radiobox (instance, widget, val); | |
835 else | |
836 xm_update_menu (instance, widget, val, deep_p); | |
837 } | |
838 else if (class == xmTextWidgetClass) | |
839 { | |
840 xm_update_text (instance, widget, val); | |
841 } | |
842 else if (class == xmTextFieldWidgetClass) | |
843 { | |
844 xm_update_text_field (instance, widget, val); | |
845 } | |
846 else if (class == xmListWidgetClass) | |
847 { | |
848 xm_update_list (instance, widget, val); | |
849 } | |
850 } | |
851 | |
852 /* getting the value back */ | |
853 void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
854 xm_update_one_value (instance, widget, val) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
855 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
856 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
857 widget_value* val; |
5626 | 858 { |
859 WidgetClass class = XtClass (widget); | |
860 widget_value *old_wv; | |
861 | |
862 /* copy the call_data slot into the "return" widget_value */ | |
863 for (old_wv = instance->info->val->contents; old_wv; old_wv = old_wv->next) | |
864 if (!strcmp (val->name, old_wv->name)) | |
865 { | |
866 val->call_data = old_wv->call_data; | |
867 break; | |
868 } | |
869 | |
870 if (class == xmToggleButtonWidgetClass || class == xmToggleButtonGadgetClass) | |
871 { | |
872 XtVaGetValues (widget, XmNset, &val->selected, 0); | |
873 val->edited = True; | |
874 } | |
875 else if (class == xmTextWidgetClass) | |
876 { | |
877 if (val->value) | |
878 free (val->value); | |
879 val->value = XmTextGetString (widget); | |
880 val->edited = True; | |
881 } | |
882 else if (class == xmTextFieldWidgetClass) | |
883 { | |
884 if (val->value) | |
885 free (val->value); | |
886 val->value = XmTextFieldGetString (widget); | |
887 val->edited = True; | |
888 } | |
889 else if (class == xmRowColumnWidgetClass) | |
890 { | |
891 Boolean radiobox = 0; | |
892 int ac = 0; | |
893 Arg al [1]; | |
894 | |
895 XtSetArg (al [ac], XmNradioBehavior, &radiobox); ac++; | |
896 XtGetValues (widget, al, ac); | |
897 | |
898 if (radiobox) | |
899 { | |
900 CompositeWidget radio = (CompositeWidget)widget; | |
901 int i; | |
902 for (i = 0; i < radio->composite.num_children; i++) | |
903 { | |
904 int set = False; | |
905 Widget toggle = radio->composite.children [i]; | |
906 | |
907 XtVaGetValues (toggle, XmNset, &set, 0); | |
908 if (set) | |
909 { | |
910 if (val->value) | |
911 free (val->value); | |
8784 | 912 val->value = safe_strdup (XtName (toggle)); |
5626 | 913 } |
914 } | |
915 val->edited = True; | |
916 } | |
917 } | |
918 else if (class == xmListWidgetClass) | |
919 { | |
920 int pos_cnt; | |
921 int* pos_list; | |
922 if (XmListGetSelectedPos (widget, &pos_list, &pos_cnt)) | |
923 { | |
924 int i; | |
925 widget_value* cur; | |
926 for (cur = val->contents, i = 0; cur; cur = cur->next) | |
927 if (cur->value) | |
928 { | |
929 int j; | |
930 cur->selected = False; | |
931 i += 1; | |
932 for (j = 0; j < pos_cnt; j++) | |
933 if (pos_list [j] == i) | |
934 { | |
935 cur->selected = True; | |
8784 | 936 val->value = safe_strdup (cur->name); |
5626 | 937 } |
938 } | |
939 val->edited = 1; | |
940 XtFree ((char *) pos_list); | |
941 } | |
942 } | |
943 } | |
944 | |
945 | |
946 /* This function is for activating a button from a program. It's wrong because | |
947 we pass a NULL argument in the call_data which is not Motif compatible. | |
948 This is used from the XmNdefaultAction callback of the List widgets to | |
14018 | 949 have a double-click put down a dialog box like the button would do. |
5626 | 950 I could not find a way to do that with accelerators. |
951 */ | |
952 static void | |
11862
10a973a88e87
(activate_button, xm_update_cascadebutton): Don't use prototype.
Karl Heuer <kwzh@gnu.org>
parents:
11435
diff
changeset
|
953 activate_button (widget, closure, call_data) |
10a973a88e87
(activate_button, xm_update_cascadebutton): Don't use prototype.
Karl Heuer <kwzh@gnu.org>
parents:
11435
diff
changeset
|
954 Widget widget; |
10a973a88e87
(activate_button, xm_update_cascadebutton): Don't use prototype.
Karl Heuer <kwzh@gnu.org>
parents:
11435
diff
changeset
|
955 XtPointer closure; |
10a973a88e87
(activate_button, xm_update_cascadebutton): Don't use prototype.
Karl Heuer <kwzh@gnu.org>
parents:
11435
diff
changeset
|
956 XtPointer call_data; |
5626 | 957 { |
958 Widget button = (Widget)closure; | |
959 XtCallCallbacks (button, XmNactivateCallback, NULL); | |
960 } | |
961 | |
962 /* creation functions */ | |
963 | |
964 /* dialogs */ | |
965 static Widget | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
966 make_dialog (name, parent, pop_up_p, shell_title, icon_name, text_input_slot, |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
967 radio_box, list, left_buttons, right_buttons) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
968 char* name; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
969 Widget parent; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
970 Boolean pop_up_p; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
971 char* shell_title; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
972 char* icon_name; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
973 Boolean text_input_slot; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
974 Boolean radio_box; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
975 Boolean list; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
976 int left_buttons; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
977 int right_buttons; |
5626 | 978 { |
979 Widget result; | |
980 Widget form; | |
981 Widget row; | |
982 Widget icon; | |
983 Widget icon_separator; | |
984 Widget message; | |
985 Widget value = 0; | |
986 Widget separator; | |
987 Widget button = 0; | |
988 Widget children [16]; /* for the final XtManageChildren */ | |
989 int n_children; | |
990 Arg al[64]; /* Arg List */ | |
991 int ac; /* Arg Count */ | |
992 int i; | |
993 | |
994 if (pop_up_p) | |
995 { | |
996 ac = 0; | |
997 XtSetArg(al[ac], XmNtitle, shell_title); ac++; | |
998 XtSetArg(al[ac], XtNallowShellResize, True); ac++; | |
999 XtSetArg(al[ac], XmNdeleteResponse, XmUNMAP); ac++; | |
1000 result = XmCreateDialogShell (parent, "dialog", al, ac); | |
1001 ac = 0; | |
1002 XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++; | |
1003 /* XtSetArg(al[ac], XmNautoUnmanage, TRUE); ac++; */ /* ####is this ok? */ | |
1004 XtSetArg(al[ac], XmNnavigationType, XmTAB_GROUP); ac++; | |
1005 form = XmCreateForm (result, shell_title, al, ac); | |
1006 } | |
1007 else | |
1008 { | |
1009 ac = 0; | |
1010 XtSetArg(al[ac], XmNautoUnmanage, FALSE); ac++; | |
1011 XtSetArg(al[ac], XmNnavigationType, XmTAB_GROUP); ac++; | |
1012 form = XmCreateForm (parent, shell_title, al, ac); | |
1013 result = form; | |
1014 } | |
1015 | |
8884 | 1016 n_children = left_buttons + right_buttons + 1; |
5626 | 1017 ac = 0; |
8884 | 1018 XtSetArg(al[ac], XmNpacking, n_children == 3? |
1019 XmPACK_COLUMN: XmPACK_TIGHT); ac++; | |
1020 XtSetArg(al[ac], XmNorientation, n_children == 3? | |
1021 XmVERTICAL: XmHORIZONTAL); ac++; | |
5626 | 1022 XtSetArg(al[ac], XmNnumColumns, left_buttons + right_buttons + 1); ac++; |
1023 XtSetArg(al[ac], XmNmarginWidth, 0); ac++; | |
1024 XtSetArg(al[ac], XmNmarginHeight, 0); ac++; | |
1025 XtSetArg(al[ac], XmNspacing, 13); ac++; | |
1026 XtSetArg(al[ac], XmNadjustLast, False); ac++; | |
1027 XtSetArg(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++; | |
1028 XtSetArg(al[ac], XmNisAligned, True); ac++; | |
1029 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; | |
1030 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_FORM); ac++; | |
1031 XtSetArg(al[ac], XmNbottomOffset, 13); ac++; | |
1032 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; | |
1033 XtSetArg(al[ac], XmNleftOffset, 13); ac++; | |
1034 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; | |
1035 XtSetArg(al[ac], XmNrightOffset, 13); ac++; | |
1036 row = XmCreateRowColumn (form, "row", al, ac); | |
1037 | |
1038 n_children = 0; | |
1039 for (i = 0; i < left_buttons; i++) | |
1040 { | |
1041 char button_name [16]; | |
1042 sprintf (button_name, "button%d", i + 1); | |
1043 ac = 0; | |
1044 if (i == 0) | |
1045 { | |
1046 XtSetArg(al[ac], XmNhighlightThickness, 1); ac++; | |
1047 XtSetArg(al[ac], XmNshowAsDefault, TRUE); ac++; | |
1048 } | |
8884 | 1049 XtSetArg(al[ac], XmNmarginWidth, 10); ac++; |
5626 | 1050 XtSetArg(al[ac], XmNnavigationType, XmTAB_GROUP); ac++; |
1051 children [n_children] = XmCreatePushButton (row, button_name, al, ac); | |
1052 | |
1053 if (i == 0) | |
1054 { | |
1055 button = children [n_children]; | |
1056 ac = 0; | |
1057 XtSetArg(al[ac], XmNdefaultButton, button); ac++; | |
1058 XtSetValues (row, al, ac); | |
1059 } | |
1060 | |
1061 n_children++; | |
1062 } | |
1063 | |
14018 | 1064 /* invisible separator button */ |
5626 | 1065 ac = 0; |
1066 XtSetArg (al[ac], XmNmappedWhenManaged, FALSE); ac++; | |
1067 children [n_children] = XmCreateLabel (row, "separator_button", al, ac); | |
1068 n_children++; | |
1069 | |
1070 for (i = 0; i < right_buttons; i++) | |
1071 { | |
1072 char button_name [16]; | |
1073 sprintf (button_name, "button%d", left_buttons + i + 1); | |
1074 ac = 0; | |
8884 | 1075 XtSetArg(al[ac], XmNmarginWidth, 10); ac++; |
5626 | 1076 XtSetArg(al[ac], XmNnavigationType, XmTAB_GROUP); ac++; |
1077 children [n_children] = XmCreatePushButton (row, button_name, al, ac); | |
1078 if (! button) button = children [n_children]; | |
1079 n_children++; | |
1080 } | |
1081 | |
1082 XtManageChildren (children, n_children); | |
1083 | |
1084 ac = 0; | |
1085 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; | |
1086 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; | |
1087 XtSetArg(al[ac], XmNbottomOffset, 13); ac++; | |
1088 XtSetArg(al[ac], XmNbottomWidget, row); ac++; | |
1089 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; | |
1090 XtSetArg(al[ac], XmNleftOffset, 0); ac++; | |
1091 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; | |
1092 XtSetArg(al[ac], XmNrightOffset, 0); ac++; | |
1093 separator = XmCreateSeparator (form, "", al, ac); | |
1094 | |
1095 ac = 0; | |
1096 XtSetArg(al[ac], XmNlabelType, XmPIXMAP); ac++; | |
1097 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; | |
1098 XtSetArg(al[ac], XmNtopOffset, 13); ac++; | |
1099 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_NONE); ac++; | |
1100 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_FORM); ac++; | |
1101 XtSetArg(al[ac], XmNleftOffset, 13); ac++; | |
1102 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++; | |
1103 icon = XmCreateLabel (form, icon_name, al, ac); | |
1104 | |
1105 ac = 0; | |
1106 XtSetArg(al[ac], XmNmappedWhenManaged, FALSE); ac++; | |
1107 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_WIDGET); ac++; | |
1108 XtSetArg(al[ac], XmNtopOffset, 6); ac++; | |
1109 XtSetArg(al[ac], XmNtopWidget, icon); ac++; | |
1110 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; | |
1111 XtSetArg(al[ac], XmNbottomOffset, 6); ac++; | |
1112 XtSetArg(al[ac], XmNbottomWidget, separator); ac++; | |
1113 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_NONE); ac++; | |
1114 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_NONE); ac++; | |
1115 icon_separator = XmCreateLabel (form, "", al, ac); | |
1116 | |
1117 if (text_input_slot) | |
1118 { | |
1119 ac = 0; | |
1120 XtSetArg(al[ac], XmNcolumns, 50); ac++; | |
1121 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; | |
1122 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; | |
1123 XtSetArg(al[ac], XmNbottomOffset, 13); ac++; | |
1124 XtSetArg(al[ac], XmNbottomWidget, separator); ac++; | |
1125 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; | |
1126 XtSetArg(al[ac], XmNleftOffset, 13); ac++; | |
1127 XtSetArg(al[ac], XmNleftWidget, icon); ac++; | |
1128 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; | |
1129 XtSetArg(al[ac], XmNrightOffset, 13); ac++; | |
1130 value = XmCreateTextField (form, "value", al, ac); | |
1131 } | |
1132 else if (radio_box) | |
1133 { | |
1134 Widget radio_butt; | |
1135 ac = 0; | |
1136 XtSetArg(al[ac], XmNmarginWidth, 0); ac++; | |
1137 XtSetArg(al[ac], XmNmarginHeight, 0); ac++; | |
1138 XtSetArg(al[ac], XmNspacing, 13); ac++; | |
1139 XtSetArg(al[ac], XmNalignment, XmALIGNMENT_CENTER); ac++; | |
1140 XtSetArg(al[ac], XmNorientation, XmHORIZONTAL); ac++; | |
1141 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; | |
1142 XtSetArg(al[ac], XmNbottomOffset, 13); ac++; | |
1143 XtSetArg(al[ac], XmNbottomWidget, separator); ac++; | |
1144 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; | |
1145 XtSetArg(al[ac], XmNleftOffset, 13); ac++; | |
1146 XtSetArg(al[ac], XmNleftWidget, icon); ac++; | |
1147 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; | |
1148 XtSetArg(al[ac], XmNrightOffset, 13); ac++; | |
1149 value = XmCreateRadioBox (form, "radiobutton1", al, ac); | |
1150 ac = 0; | |
1151 i = 0; | |
1152 radio_butt = XmCreateToggleButtonGadget (value, "radio1", al, ac); | |
1153 children [i++] = radio_butt; | |
1154 radio_butt = XmCreateToggleButtonGadget (value, "radio2", al, ac); | |
1155 children [i++] = radio_butt; | |
1156 radio_butt = XmCreateToggleButtonGadget (value, "radio3", al, ac); | |
1157 children [i++] = radio_butt; | |
1158 XtManageChildren (children, i); | |
1159 } | |
1160 else if (list) | |
1161 { | |
1162 ac = 0; | |
1163 XtSetArg(al[ac], XmNvisibleItemCount, 5); ac++; | |
1164 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_NONE); ac++; | |
1165 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; | |
1166 XtSetArg(al[ac], XmNbottomOffset, 13); ac++; | |
1167 XtSetArg(al[ac], XmNbottomWidget, separator); ac++; | |
1168 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; | |
1169 XtSetArg(al[ac], XmNleftOffset, 13); ac++; | |
1170 XtSetArg(al[ac], XmNleftWidget, icon); ac++; | |
1171 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; | |
1172 XtSetArg(al[ac], XmNrightOffset, 13); ac++; | |
1173 value = XmCreateScrolledList (form, "list", al, ac); | |
1174 | |
1175 /* this is the easiest way I found to have the dble click in the | |
1176 list activate the default button */ | |
1177 XtAddCallback (value, XmNdefaultActionCallback, activate_button, button); | |
1178 } | |
1179 | |
1180 ac = 0; | |
1181 XtSetArg(al[ac], XmNalignment, XmALIGNMENT_BEGINNING); ac++; | |
1182 XtSetArg(al[ac], XmNtopAttachment, XmATTACH_FORM); ac++; | |
1183 XtSetArg(al[ac], XmNtopOffset, 13); ac++; | |
1184 XtSetArg(al[ac], XmNbottomAttachment, XmATTACH_WIDGET); ac++; | |
1185 XtSetArg(al[ac], XmNbottomOffset, 13); ac++; | |
1186 XtSetArg(al[ac], XmNbottomWidget, | |
1187 text_input_slot || radio_box || list ? value : separator); ac++; | |
1188 XtSetArg(al[ac], XmNleftAttachment, XmATTACH_WIDGET); ac++; | |
1189 XtSetArg(al[ac], XmNleftOffset, 13); ac++; | |
1190 XtSetArg(al[ac], XmNleftWidget, icon); ac++; | |
1191 XtSetArg(al[ac], XmNrightAttachment, XmATTACH_FORM); ac++; | |
1192 XtSetArg(al[ac], XmNrightOffset, 13); ac++; | |
1193 message = XmCreateLabel (form, "message", al, ac); | |
1194 | |
1195 if (list) | |
1196 XtManageChild (value); | |
1197 | |
1198 i = 0; | |
1199 children [i] = row; i++; | |
1200 children [i] = separator; i++; | |
1201 if (text_input_slot || radio_box) | |
1202 { | |
1203 children [i] = value; i++; | |
1204 } | |
1205 children [i] = message; i++; | |
1206 children [i] = icon; i++; | |
1207 children [i] = icon_separator; i++; | |
1208 XtManageChildren (children, i); | |
1209 | |
1210 if (text_input_slot || list) | |
1211 { | |
1212 XtInstallAccelerators (value, button); | |
1213 XtSetKeyboardFocus (result, value); | |
1214 } | |
1215 else | |
1216 { | |
1217 XtInstallAccelerators (form, button); | |
1218 XtSetKeyboardFocus (result, button); | |
1219 } | |
1220 | |
1221 return result; | |
1222 } | |
1223 | |
1224 static destroyed_instance* | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1225 find_matching_instance (instance) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1226 widget_instance* instance; |
5626 | 1227 { |
1228 destroyed_instance* cur; | |
1229 destroyed_instance* prev; | |
1230 char* type = instance->info->type; | |
1231 char* name = instance->info->name; | |
1232 | |
1233 for (prev = NULL, cur = all_destroyed_instances; | |
1234 cur; | |
1235 prev = cur, cur = cur->next) | |
1236 { | |
1237 if (!strcmp (cur->name, name) | |
1238 && !strcmp (cur->type, type) | |
1239 && cur->parent == instance->parent | |
1240 && cur->pop_up_p == instance->pop_up_p) | |
1241 { | |
1242 if (prev) | |
1243 prev->next = cur->next; | |
1244 else | |
1245 all_destroyed_instances = cur->next; | |
1246 return cur; | |
1247 } | |
1248 /* do some cleanup */ | |
1249 else if (!cur->widget) | |
1250 { | |
1251 if (prev) | |
1252 prev->next = cur->next; | |
1253 else | |
1254 all_destroyed_instances = cur->next; | |
1255 free_destroyed_instance (cur); | |
1256 cur = prev ? prev : all_destroyed_instances; | |
1257 } | |
1258 } | |
1259 return NULL; | |
1260 } | |
1261 | |
1262 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1263 mark_dead_instance_destroyed (widget, closure, call_data) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1264 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1265 XtPointer closure; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1266 XtPointer call_data; |
5626 | 1267 { |
1268 destroyed_instance* instance = (destroyed_instance*)closure; | |
1269 instance->widget = NULL; | |
1270 } | |
1271 | |
1272 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1273 recenter_widget (widget) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1274 Widget widget; |
5626 | 1275 { |
1276 Widget parent = XtParent (widget); | |
1277 Screen* screen = XtScreen (widget); | |
1278 Dimension screen_width = WidthOfScreen (screen); | |
1279 Dimension screen_height = HeightOfScreen (screen); | |
1280 Dimension parent_width = 0; | |
1281 Dimension parent_height = 0; | |
1282 Dimension child_width = 0; | |
1283 Dimension child_height = 0; | |
1284 Position x; | |
1285 Position y; | |
1286 | |
1287 XtVaGetValues (widget, XtNwidth, &child_width, XtNheight, &child_height, 0); | |
1288 XtVaGetValues (parent, XtNwidth, &parent_width, XtNheight, &parent_height, | |
1289 0); | |
1290 | |
1291 x = (((Position)parent_width) - ((Position)child_width)) / 2; | |
1292 y = (((Position)parent_height) - ((Position)child_height)) / 2; | |
1293 | |
1294 XtTranslateCoords (parent, x, y, &x, &y); | |
1295 | |
1296 if (x + child_width > screen_width) | |
1297 x = screen_width - child_width; | |
1298 if (x < 0) | |
1299 x = 0; | |
1300 | |
1301 if (y + child_height > screen_height) | |
1302 y = screen_height - child_height; | |
1303 if (y < 0) | |
1304 y = 0; | |
1305 | |
1306 XtVaSetValues (widget, XtNx, x, XtNy, y, 0); | |
1307 } | |
1308 | |
1309 static Widget | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1310 recycle_instance (instance) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1311 destroyed_instance* instance; |
5626 | 1312 { |
1313 Widget widget = instance->widget; | |
1314 | |
1315 /* widget is NULL if the parent was destroyed. */ | |
1316 if (widget) | |
1317 { | |
1318 Widget focus; | |
1319 Widget separator; | |
1320 | |
1321 /* Remove the destroy callback as the instance is not in the list | |
1322 anymore */ | |
1323 XtRemoveCallback (instance->parent, XtNdestroyCallback, | |
1324 mark_dead_instance_destroyed, | |
1325 (XtPointer)instance); | |
1326 | |
1327 /* Give the focus to the initial item */ | |
1328 focus = XtNameToWidget (widget, "*value"); | |
1329 if (!focus) | |
1330 focus = XtNameToWidget (widget, "*button1"); | |
1331 if (focus) | |
1332 XtSetKeyboardFocus (widget, focus); | |
1333 | |
1334 /* shrink the separator label back to their original size */ | |
1335 separator = XtNameToWidget (widget, "*separator_button"); | |
1336 if (separator) | |
1337 XtVaSetValues (separator, XtNwidth, 5, XtNheight, 5, 0); | |
1338 | |
1339 /* Center the dialog in its parent */ | |
1340 recenter_widget (widget); | |
1341 } | |
1342 free_destroyed_instance (instance); | |
1343 return widget; | |
1344 } | |
1345 | |
1346 Widget | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1347 xm_create_dialog (instance) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1348 widget_instance* instance; |
5626 | 1349 { |
1350 char* name = instance->info->type; | |
1351 Widget parent = instance->parent; | |
1352 Widget widget; | |
1353 Boolean pop_up_p = instance->pop_up_p; | |
1354 char* shell_name = 0; | |
1355 char* icon_name; | |
1356 Boolean text_input_slot = False; | |
1357 Boolean radio_box = False; | |
1358 Boolean list = False; | |
1359 int total_buttons; | |
1360 int left_buttons = 0; | |
1361 int right_buttons = 1; | |
1362 destroyed_instance* dead_one; | |
1363 | |
1364 /* try to find a widget to recycle */ | |
1365 dead_one = find_matching_instance (instance); | |
1366 if (dead_one) | |
1367 { | |
1368 Widget recycled_widget = recycle_instance (dead_one); | |
1369 if (recycled_widget) | |
1370 return recycled_widget; | |
1371 } | |
1372 | |
1373 switch (name [0]){ | |
1374 case 'E': case 'e': | |
1375 icon_name = "dbox-error"; | |
1376 shell_name = "Error"; | |
1377 break; | |
1378 | |
1379 case 'I': case 'i': | |
1380 icon_name = "dbox-info"; | |
1381 shell_name = "Information"; | |
1382 break; | |
1383 | |
1384 case 'L': case 'l': | |
1385 list = True; | |
1386 icon_name = "dbox-question"; | |
1387 shell_name = "Prompt"; | |
1388 break; | |
1389 | |
1390 case 'P': case 'p': | |
1391 text_input_slot = True; | |
1392 icon_name = "dbox-question"; | |
1393 shell_name = "Prompt"; | |
1394 break; | |
1395 | |
1396 case 'Q': case 'q': | |
1397 icon_name = "dbox-question"; | |
1398 shell_name = "Question"; | |
1399 break; | |
1400 } | |
1401 | |
1402 total_buttons = name [1] - '0'; | |
1403 | |
1404 if (name [3] == 'T' || name [3] == 't') | |
1405 { | |
1406 text_input_slot = False; | |
1407 radio_box = True; | |
1408 } | |
1409 else if (name [3]) | |
1410 right_buttons = name [4] - '0'; | |
1411 | |
1412 left_buttons = total_buttons - right_buttons; | |
1413 | |
1414 widget = make_dialog (name, parent, pop_up_p, | |
1415 shell_name, icon_name, text_input_slot, radio_box, | |
1416 list, left_buttons, right_buttons); | |
1417 | |
1418 XtAddCallback (widget, XmNpopdownCallback, xm_nosel_callback, | |
1419 (XtPointer) instance); | |
1420 return widget; | |
1421 } | |
1422 | |
15816
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1423 /* Create a menu bar. We turn off the f10 key |
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1424 because we have not yet managed to make it work right in Motif. */ |
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1425 |
5626 | 1426 static Widget |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1427 make_menubar (instance) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1428 widget_instance* instance; |
5626 | 1429 { |
15816
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1430 Arg al[1]; |
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1431 int ac; |
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1432 |
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1433 ac = 0; |
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1434 XtSetArg(al[0], XmNmenuAccelerator, 0); |
e1e9df8a862e
(make_menubar): Turn off menu accelerator.
Richard M. Stallman <rms@gnu.org>
parents:
15665
diff
changeset
|
1435 return XmCreateMenuBar (instance->parent, instance->info->name, al, 1); |
5626 | 1436 } |
1437 | |
1438 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1439 remove_grabs (shell, closure, call_data) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1440 Widget shell; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1441 XtPointer closure; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1442 XtPointer call_data; |
5626 | 1443 { |
11245
5fdf816307c6
(remove_grabs): Use type Widget for `menu'.
Richard M. Stallman <rms@gnu.org>
parents:
9835
diff
changeset
|
1444 Widget menu = (Widget) closure; |
5fdf816307c6
(remove_grabs): Use type Widget for `menu'.
Richard M. Stallman <rms@gnu.org>
parents:
9835
diff
changeset
|
1445 XmRemoveFromPostFromList (menu, XtParent (XtParent (menu))); |
5626 | 1446 } |
1447 | |
1448 static Widget | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1449 make_popup_menu (instance) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1450 widget_instance* instance; |
5626 | 1451 { |
1452 Widget parent = instance->parent; | |
1453 Window parent_window = parent->core.window; | |
1454 Widget result; | |
1455 | |
1456 /* sets the parent window to 0 to fool Motif into not generating a grab */ | |
1457 parent->core.window = 0; | |
1458 result = XmCreatePopupMenu (parent, instance->info->name, NULL, 0); | |
1459 XtAddCallback (XtParent (result), XmNpopdownCallback, remove_grabs, | |
1460 (XtPointer)result); | |
1461 parent->core.window = parent_window; | |
1462 return result; | |
1463 } | |
25037 | 1464 |
8784 | 1465 static Widget |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1466 make_main (instance) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1467 widget_instance* instance; |
8784 | 1468 { |
1469 Widget parent = instance->parent; | |
1470 Widget result; | |
1471 Arg al[2]; | |
1472 int ac; | |
1473 | |
1474 ac = 0; | |
1475 XtSetArg (al[ac], XtNborderWidth, 0); ac++; | |
1476 XtSetArg (al[ac], XmNspacing, 0); ac++; | |
1477 result = XmCreateMainWindow (parent, instance->info->name, al, ac); | |
1478 return result; | |
1479 } | |
5626 | 1480 |
1481 /* Table of functions to create widgets */ | |
1482 | |
1483 #ifdef ENERGIZE | |
1484 | |
1485 /* interface with the XDesigner generated functions */ | |
1486 typedef Widget (*widget_maker) (Widget); | |
1487 extern Widget create_project_p_sheet (Widget parent); | |
1488 extern Widget create_debugger_p_sheet (Widget parent); | |
1489 extern Widget create_breaklist_p_sheet (Widget parent); | |
1490 extern Widget create_le_browser_p_sheet (Widget parent); | |
1491 extern Widget create_class_browser_p_sheet (Widget parent); | |
1492 extern Widget create_call_browser_p_sheet (Widget parent); | |
1493 extern Widget create_build_dialog (Widget parent); | |
1494 extern Widget create_editmode_dialog (Widget parent); | |
1495 extern Widget create_search_dialog (Widget parent); | |
1496 extern Widget create_project_display_dialog (Widget parent); | |
1497 | |
1498 static Widget | |
1499 make_one (widget_instance* instance, widget_maker fn) | |
1500 { | |
1501 Widget result; | |
1502 Arg al [64]; | |
1503 int ac = 0; | |
1504 | |
1505 if (instance->pop_up_p) | |
1506 { | |
1507 XtSetArg (al [ac], XmNallowShellResize, TRUE); ac++; | |
1508 result = XmCreateDialogShell (instance->parent, "dialog", NULL, 0); | |
1509 XtAddCallback (result, XmNpopdownCallback, &xm_nosel_callback, | |
1510 (XtPointer) instance); | |
1511 (*fn) (result); | |
1512 } | |
1513 else | |
1514 { | |
1515 result = (*fn) (instance->parent); | |
1516 XtRealizeWidget (result); | |
1517 } | |
1518 return result; | |
1519 } | |
1520 | |
1521 static Widget | |
1522 make_project_p_sheet (widget_instance* instance) | |
1523 { | |
1524 return make_one (instance, create_project_p_sheet); | |
1525 } | |
1526 | |
1527 static Widget | |
1528 make_debugger_p_sheet (widget_instance* instance) | |
1529 { | |
1530 return make_one (instance, create_debugger_p_sheet); | |
1531 } | |
1532 | |
1533 static Widget | |
1534 make_breaklist_p_sheet (widget_instance* instance) | |
1535 { | |
1536 return make_one (instance, create_breaklist_p_sheet); | |
1537 } | |
1538 | |
1539 static Widget | |
1540 make_le_browser_p_sheet (widget_instance* instance) | |
1541 { | |
1542 return make_one (instance, create_le_browser_p_sheet); | |
1543 } | |
1544 | |
1545 static Widget | |
1546 make_class_browser_p_sheet (widget_instance* instance) | |
1547 { | |
1548 return make_one (instance, create_class_browser_p_sheet); | |
1549 } | |
1550 | |
1551 static Widget | |
1552 make_call_browser_p_sheet (widget_instance* instance) | |
1553 { | |
1554 return make_one (instance, create_call_browser_p_sheet); | |
1555 } | |
1556 | |
1557 static Widget | |
1558 make_build_dialog (widget_instance* instance) | |
1559 { | |
1560 return make_one (instance, create_build_dialog); | |
1561 } | |
1562 | |
1563 static Widget | |
1564 make_editmode_dialog (widget_instance* instance) | |
1565 { | |
1566 return make_one (instance, create_editmode_dialog); | |
1567 } | |
1568 | |
1569 static Widget | |
1570 make_search_dialog (widget_instance* instance) | |
1571 { | |
1572 return make_one (instance, create_search_dialog); | |
1573 } | |
1574 | |
1575 static Widget | |
1576 make_project_display_dialog (widget_instance* instance) | |
1577 { | |
1578 return make_one (instance, create_project_display_dialog); | |
1579 } | |
1580 | |
1581 #endif /* ENERGIZE */ | |
1582 | |
1583 widget_creation_entry | |
1584 xm_creation_table [] = | |
1585 { | |
1586 {"menubar", make_menubar}, | |
1587 {"popup", make_popup_menu}, | |
8784 | 1588 {"main", make_main}, |
5626 | 1589 #ifdef ENERGIZE |
1590 {"project_p_sheet", make_project_p_sheet}, | |
1591 {"debugger_p_sheet", make_debugger_p_sheet}, | |
1592 {"breaklist_psheet", make_breaklist_p_sheet}, | |
1593 {"leb_psheet", make_le_browser_p_sheet}, | |
1594 {"class_browser_psheet", make_class_browser_p_sheet}, | |
1595 {"ctree_browser_psheet", make_call_browser_p_sheet}, | |
1596 {"build", make_build_dialog}, | |
1597 {"editmode", make_editmode_dialog}, | |
1598 {"search", make_search_dialog}, | |
1599 {"project_display", make_project_display_dialog}, | |
1600 #endif /* ENERGIZE */ | |
1601 {NULL, NULL} | |
1602 }; | |
1603 | |
1604 /* Destruction of instances */ | |
1605 void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1606 xm_destroy_instance (instance) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1607 widget_instance* instance; |
5626 | 1608 { |
1609 Widget widget = instance->widget; | |
1610 /* recycle the dialog boxes */ | |
1611 /* Disable the recycling until we can find a way to have the dialog box | |
1612 get reasonable layout after we modify its contents. */ | |
1613 if (0 | |
1614 && XtClass (widget) == xmDialogShellWidgetClass) | |
1615 { | |
1616 destroyed_instance* dead_instance = | |
1617 make_destroyed_instance (instance->info->name, | |
1618 instance->info->type, | |
1619 instance->widget, | |
1620 instance->parent, | |
1621 instance->pop_up_p); | |
1622 dead_instance->next = all_destroyed_instances; | |
1623 all_destroyed_instances = dead_instance; | |
1624 XtUnmanageChild (first_child (instance->widget)); | |
1625 XFlush (XtDisplay (instance->widget)); | |
1626 XtAddCallback (instance->parent, XtNdestroyCallback, | |
1627 mark_dead_instance_destroyed, (XtPointer)dead_instance); | |
1628 } | |
1629 else | |
1630 { | |
1631 /* This might not be necessary now that the nosel is attached to | |
1632 popdown instead of destroy, but it can't hurt. */ | |
1633 XtRemoveCallback (instance->widget, XtNdestroyCallback, | |
1634 xm_nosel_callback, (XtPointer)instance); | |
1635 XtDestroyWidget (instance->widget); | |
1636 } | |
1637 } | |
1638 | |
1639 /* popup utility */ | |
1640 void | |
12746
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1641 xm_popup_menu (widget, event) |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1642 Widget widget; |
12746
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1643 XEvent *event; |
5626 | 1644 { |
1645 XButtonPressedEvent dummy; | |
1646 | |
12746
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1647 if (event == 0) |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1648 { |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1649 dummy.type = ButtonPress; |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1650 dummy.serial = 0; |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1651 dummy.send_event = 0; |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1652 dummy.display = XtDisplay (widget); |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1653 dummy.window = XtWindow (XtParent (widget)); |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1654 dummy.time = 0; |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1655 dummy.button = 0; |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1656 XQueryPointer (dummy.display, dummy.window, &dummy.root, |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1657 &dummy.subwindow, &dummy.x_root, &dummy.y_root, |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1658 &dummy.x, &dummy.y, &dummy.state); |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1659 event = (XEvent *) &dummy; |
23cd08c6dd2a
(xm_popup_menu): New arg `event'.
Richard M. Stallman <rms@gnu.org>
parents:
11862
diff
changeset
|
1660 } |
5626 | 1661 |
1662 if (event->type == ButtonPress || event->type == ButtonRelease) | |
1663 { | |
1664 /* This is so totally ridiculous: there's NO WAY to tell Motif | |
1665 that *any* button can select a menu item. Only one button | |
1666 can have that honor. | |
1667 */ | |
1668 char *trans = 0; | |
1669 if (event->xbutton.state & Button5Mask) trans = "<Btn5Down>"; | |
1670 else if (event->xbutton.state & Button4Mask) trans = "<Btn4Down>"; | |
1671 else if (event->xbutton.state & Button3Mask) trans = "<Btn3Down>"; | |
1672 else if (event->xbutton.state & Button2Mask) trans = "<Btn2Down>"; | |
1673 else if (event->xbutton.state & Button1Mask) trans = "<Btn1Down>"; | |
1674 if (trans) XtVaSetValues (widget, XmNmenuPost, trans, 0); | |
1675 XmMenuPosition (widget, (XButtonPressedEvent *) event); | |
1676 } | |
1677 XtManageChild (widget); | |
1678 } | |
1679 | |
1680 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1681 set_min_dialog_size (w) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1682 Widget w; |
5626 | 1683 { |
1684 short width; | |
1685 short height; | |
1686 XtVaGetValues (w, XmNwidth, &width, XmNheight, &height, 0); | |
1687 XtVaSetValues (w, XmNminWidth, width, XmNminHeight, height, 0); | |
1688 } | |
1689 | |
1690 void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1691 xm_pop_instance (instance, up) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1692 widget_instance* instance; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1693 Boolean up; |
5626 | 1694 { |
1695 Widget widget = instance->widget; | |
1696 | |
1697 if (XtClass (widget) == xmDialogShellWidgetClass) | |
1698 { | |
1699 Widget widget_to_manage = first_child (widget); | |
1700 if (up) | |
1701 { | |
1702 XtManageChild (widget_to_manage); | |
1703 set_min_dialog_size (widget); | |
1704 XtSetKeyboardFocus (instance->parent, widget); | |
1705 } | |
1706 else | |
1707 XtUnmanageChild (widget_to_manage); | |
1708 } | |
1709 else | |
1710 { | |
1711 if (up) | |
1712 XtManageChild (widget); | |
1713 else | |
1714 XtUnmanageChild (widget); | |
1715 } | |
1716 } | |
1717 | |
1718 | |
1719 /* motif callback */ | |
1720 | |
1721 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1722 do_call (widget, closure, type) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1723 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1724 XtPointer closure; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1725 enum do_call_type type; |
5626 | 1726 { |
1727 Arg al [256]; | |
1728 int ac; | |
1729 XtPointer user_data; | |
1730 widget_instance* instance = (widget_instance*)closure; | |
1731 Widget instance_widget; | |
1732 LWLIB_ID id; | |
1733 | |
1734 if (!instance) | |
1735 return; | |
1736 if (widget->core.being_destroyed) | |
1737 return; | |
1738 | |
1739 instance_widget = instance->widget; | |
1740 if (!instance_widget) | |
1741 return; | |
1742 | |
1743 id = instance->info->id; | |
1744 ac = 0; | |
1745 user_data = NULL; | |
1746 XtSetArg (al [ac], XmNuserData, &user_data); ac++; | |
1747 XtGetValues (widget, al, ac); | |
1748 switch (type) | |
1749 { | |
1750 case pre_activate: | |
1751 if (instance->info->pre_activate_cb) | |
1752 instance->info->pre_activate_cb (widget, id, user_data); | |
1753 break; | |
1754 case selection: | |
1755 if (instance->info->selection_cb) | |
1756 instance->info->selection_cb (widget, id, user_data); | |
1757 break; | |
1758 case no_selection: | |
1759 if (instance->info->selection_cb) | |
1760 instance->info->selection_cb (widget, id, (XtPointer) -1); | |
1761 break; | |
1762 case post_activate: | |
1763 if (instance->info->post_activate_cb) | |
1764 instance->info->post_activate_cb (widget, id, user_data); | |
1765 break; | |
1766 default: | |
1767 abort (); | |
1768 } | |
1769 } | |
1770 | |
1771 /* Like lw_internal_update_other_instances except that it does not do | |
1772 anything if its shell parent is not managed. This is to protect | |
1773 lw_internal_update_other_instances to dereference freed memory | |
1774 if the widget was ``destroyed'' by caching it in the all_destroyed_instances | |
1775 list */ | |
1776 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1777 xm_internal_update_other_instances (widget, closure, call_data) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1778 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1779 XtPointer closure; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1780 XtPointer call_data; |
5626 | 1781 { |
1782 Widget parent; | |
1783 for (parent = widget; parent; parent = XtParent (parent)) | |
1784 if (XtIsShell (parent)) | |
1785 break; | |
1786 else if (!XtIsManaged (parent)) | |
1787 return; | |
1788 lw_internal_update_other_instances (widget, closure, call_data); | |
1789 } | |
1790 | |
1791 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1792 xm_generic_callback (widget, closure, call_data) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1793 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1794 XtPointer closure; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1795 XtPointer call_data; |
5626 | 1796 { |
1797 lw_internal_update_other_instances (widget, closure, call_data); | |
1798 do_call (widget, closure, selection); | |
1799 } | |
1800 | |
1801 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1802 xm_nosel_callback (widget, closure, call_data) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1803 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1804 XtPointer closure; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1805 XtPointer call_data; |
5626 | 1806 { |
1807 /* This callback is only called when a dialog box is dismissed with the wm's | |
1808 destroy button (WM_DELETE_WINDOW.) We want the dialog box to be destroyed | |
1809 in that case, not just unmapped, so that it releases its keyboard grabs. | |
1810 But there are problems with running our callbacks while the widget is in | |
1811 the process of being destroyed, so we set XmNdeleteResponse to XmUNMAP | |
1812 instead of XmDESTROY and then destroy it ourself after having run the | |
1813 callback. | |
1814 */ | |
1815 do_call (widget, closure, no_selection); | |
1816 XtDestroyWidget (widget); | |
1817 } | |
1818 | |
1819 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1820 xm_pull_down_callback (widget, closure, call_data) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1821 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1822 XtPointer closure; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1823 XtPointer call_data; |
5626 | 1824 { |
1825 do_call (widget, closure, pre_activate); | |
1826 } | |
1827 | |
1828 static void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1829 xm_pop_down_callback (widget, closure, call_data) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1830 Widget widget; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1831 XtPointer closure; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1832 XtPointer call_data; |
5626 | 1833 { |
9835
d2250d1b0f48
(make_menu_in_widget): Differentiate a separator entry ("--") from a
Paul Reilly <pmr@pajato.com>
parents:
9825
diff
changeset
|
1834 widget_instance *instance = (widget_instance *) closure; |
d2250d1b0f48
(make_menu_in_widget): Differentiate a separator entry ("--") from a
Paul Reilly <pmr@pajato.com>
parents:
9825
diff
changeset
|
1835 |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1836 if ((!instance->pop_up_p && (XtParent (widget) == instance->widget)) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1837 || (XtParent (widget) == instance->parent)) |
9835
d2250d1b0f48
(make_menu_in_widget): Differentiate a separator entry ("--") from a
Paul Reilly <pmr@pajato.com>
parents:
9825
diff
changeset
|
1838 do_call (widget, closure, post_activate); |
5626 | 1839 } |
1840 | |
1841 | |
1842 /* set the keyboard focus */ | |
1843 void | |
11299
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1844 xm_set_keyboard_focus (parent, w) |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1845 Widget parent; |
f82f4e93e523
(*): remove function prototypes.
Paul Reilly <pmr@pajato.com>
parents:
11245
diff
changeset
|
1846 Widget w; |
5626 | 1847 { |
1848 XmProcessTraversal (w, 0); | |
1849 XtSetKeyboardFocus (parent, w); | |
1850 } | |
9224
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1851 |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1852 /* Motif hack to set the main window areas. */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1853 void |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1854 xm_set_main_areas (parent, menubar, work_area) |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1855 Widget parent; |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1856 Widget menubar; |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1857 Widget work_area; |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1858 { |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1859 XmMainWindowSetAreas (parent, |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1860 menubar, /* menubar (maybe 0) */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1861 0, /* command area (psheets) */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1862 0, /* horizontal scroll */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1863 0, /* vertical scroll */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1864 work_area); /* work area */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1865 } |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1866 |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1867 /* Motif hack to control resizing on the menubar. */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1868 void |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1869 xm_manage_resizing (w, flag) |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1870 Widget w; |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1871 Boolean flag; |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1872 { |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1873 if (flag) |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1874 { |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1875 /* Enable the edit widget for resizing. */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1876 Arg al[1]; |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1877 |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1878 XtSetArg (al[0], XtNallowShellResize, 0); |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1879 XtSetValues (w, al, 1); |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1880 } |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1881 else |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1882 { |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1883 /* Disable the edit widget from resizing. */ |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1884 Arg al[1]; |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1885 |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1886 XtSetArg (al[0], XtNallowShellResize, 0); |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1887 XtSetValues (w, al, 1); |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1888 } |
b4563001d783
(make_menu_in_widget): Add support for displaying a title in pop up
Paul Reilly <pmr@pajato.com>
parents:
8884
diff
changeset
|
1889 } |