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