Mercurial > hg > xemacs-beta
annotate lwlib/lwlib-Xlw.c @ 5906:4d5a5a80aba2
chartab.h, #define get_char_table_mirrors_ok correctly sans ERROR_CHECK_TYPES
src/ChangeLog addition:
2015-05-08 Aidan Kehoe <kehoea@parhasard.net>
* chartab.h (get_char_table_mirrors_ok):
#define this correctly without ERROR_CHECK_TYPES.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Fri, 08 May 2015 20:02:06 +0100 |
parents | ade4c7e2c6cb |
children |
rev | line source |
---|---|
428 | 1 /* The lwlib interface to "xlwmenu" menus. |
2 Copyright (C) 1992, 1994 Lucid, Inc. | |
3 | |
4 This file is part of the Lucid Widget Library. | |
5 | |
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
6 The Lucid Widget Library is free software: you can redistribute it |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
7 and/or modify it under the terms of the GNU General Public License as |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
8 published by the Free Software Foundation, either version 3 of the |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
9 License, or (at your option) any later version. |
428 | 10 |
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
11 The Lucid Widget Library is distributed in the hope that it will be |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
12 useful, but WITHOUT ANY WARRANTY; without even the implied warranty of |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
14 General Public License for more details. |
428 | 15 |
16 You should have received a copy of the GNU General Public License | |
5422
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
17 along with the Lucid Widget Library. If not, see |
ade4c7e2c6cb
Migrate lwlib/ to GPLv3.
Mike Sperber <sperber@deinprogramm.de>
parents:
4769
diff
changeset
|
18 <http://www.gnu.org/licenses/>. */ |
428 | 19 |
20 #include <config.h> | |
21 #include <stdlib.h> /* for abort () */ | |
22 #include <stdio.h> /* for abort () */ | |
23 #include <limits.h> | |
24 | |
25 #include "lwlib-Xlw.h" | |
26 #include "lwlib-utils.h" | |
27 #include <X11/StringDefs.h> | |
28 #include <X11/IntrinsicP.h> | |
29 #include <X11/ObjectP.h> | |
30 #include <X11/CompositeP.h> | |
31 #include <X11/Shell.h> | |
4769
5460287a3327
Remove support for pre-X11R5 systems, including systems without Xmu. See
Jerry James <james@xemacs.org>
parents:
4528
diff
changeset
|
32 #include <X11/Xmu/Converters.h> |
771 | 33 #ifdef HAVE_X_WIDGETS |
428 | 34 #include "../src/EmacsManager.h" |
35 #endif | |
36 #ifdef LWLIB_MENUBARS_LUCID | |
37 #include "xlwmenu.h" | |
38 #endif | |
39 #ifdef LWLIB_SCROLLBARS_LUCID | |
40 #include "xlwscrollbar.h" | |
41 #endif | |
42 #ifdef LWLIB_TABS_LUCID | |
43 #ifdef NEED_MOTIF | |
44 #include "lwlib-Xm.h" | |
45 #endif | |
46 #ifdef NEED_ATHENA | |
47 #include "lwlib-Xaw.h" | |
48 #endif | |
49 #include "xlwtabs.h" | |
50 #endif | |
51 | |
52 | |
53 | |
54 #ifdef LWLIB_MENUBARS_LUCID | |
55 | |
56 /* Menu callbacks */ | |
57 | |
58 static void | |
59 pre_hook (Widget w, XtPointer client_data, XtPointer call_data) | |
60 { | |
61 widget_instance* instance = (widget_instance*)client_data; | |
62 widget_value* val; | |
63 | |
64 if (w->core.being_destroyed) | |
65 return; | |
66 | |
67 val = lw_get_widget_value_for_widget (instance, w); | |
68 #if 0 | |
69 /* #### - this code used to (for some random back_asswards reason) pass | |
70 the expression below in the call_data slot. For incremental menu | |
71 construction, this needs to go. I can't even figure out why it was done | |
72 this way in the first place...it's just a historical weirdism. --Stig */ | |
73 call_data = (val ? val->call_data : NULL); | |
74 #endif | |
75 if (val && val->call_data) | |
76 abort(); /* #### - the call_data for the top_level | |
77 "menubar" widget_value used to be passed | |
78 back to the pre_hook. */ | |
79 | |
80 if (instance->info->pre_activate_cb) | |
81 instance->info->pre_activate_cb (w, instance->info->id, call_data); | |
82 } | |
83 | |
84 static void | |
85 pick_hook (Widget w, XtPointer client_data, XtPointer call_data) | |
86 { | |
87 widget_instance* instance = (widget_instance*)client_data; | |
88 widget_value* contents_val = (widget_value*)call_data; | |
89 widget_value* widget_val; | |
90 XtPointer widget_arg; | |
91 LWLIB_ID id; | |
92 lw_callback post_activate_cb; | |
93 | |
94 if (w->core.being_destroyed) | |
95 return; | |
96 | |
97 /* Grab these values before running any functions, in case running | |
98 the selection_cb causes the widget to be destroyed. */ | |
99 id = instance->info->id; | |
100 post_activate_cb = instance->info->post_activate_cb; | |
101 | |
102 widget_val = lw_get_widget_value_for_widget (instance, w); | |
103 widget_arg = widget_val ? widget_val->call_data : NULL; | |
104 | |
105 if (instance->info->selection_cb && | |
106 contents_val && | |
107 contents_val->enabled && | |
108 !contents_val->contents) | |
109 instance->info->selection_cb (w, id, contents_val->call_data); | |
110 | |
111 if (post_activate_cb) | |
112 post_activate_cb (w, id, widget_arg); | |
113 } | |
114 | |
115 | |
116 | |
117 /* creation functions */ | |
118 static Widget | |
119 xlw_create_menubar (widget_instance* instance) | |
120 { | |
121 Arg al [1]; | |
122 Widget widget; | |
123 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
124 Xt_SET_ARG (al [0], XtNmenu, instance->info->val); |
428 | 125 widget = XtCreateWidget (instance->info->name, xlwMenuWidgetClass, |
126 instance->parent, al, 1); | |
127 XtAddCallback (widget, XtNopen, pre_hook, (XtPointer)instance); | |
128 XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); | |
129 return widget; | |
130 } | |
131 | |
132 static Widget | |
133 xlw_create_popup_menu (widget_instance* instance) | |
134 { | |
135 Arg al [2]; | |
136 Widget popup_shell, widget; | |
137 | |
138 popup_shell = XtCreatePopupShell (instance->info->name, | |
139 overrideShellWidgetClass, | |
140 instance->parent, NULL, 0); | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
141 Xt_SET_ARG (al [0], XtNmenu, instance->info->val); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
142 Xt_SET_ARG (al [1], XtNhorizontal, False); |
428 | 143 widget = XtCreateManagedWidget ("popup", xlwMenuWidgetClass, |
144 popup_shell, al, 2); | |
145 XtAddCallback (widget, XtNselect, pick_hook, (XtPointer)instance); | |
146 | |
147 return popup_shell; | |
148 } | |
149 #endif /* LWLIB_MENUBARS_LUCID */ | |
150 | |
151 #ifdef LWLIB_SCROLLBARS_LUCID | |
152 static void | |
153 xlw_scrollbar_callback (Widget widget, XtPointer closure, XtPointer call_data) | |
154 { | |
155 widget_instance *instance = (widget_instance *) closure; | |
156 LWLIB_ID id; | |
157 XlwScrollBarCallbackStruct *data = | |
158 (XlwScrollBarCallbackStruct *) call_data; | |
159 scroll_event event_data; | |
3462 | 160 scrollbar_values *val; |
428 | 161 double percent; |
162 | |
163 if (!instance || widget->core.being_destroyed) | |
164 return; | |
165 | |
3462 | 166 val = (scrollbar_values *) instance->info->val->scrollbar_data; |
428 | 167 id = instance->info->id; |
168 | |
169 percent = (double) (data->value - 1) / (double) (INT_MAX - 1); | |
170 event_data.slider_value = | |
171 (int) (percent * (double) (val->maximum - val->minimum)) + val->minimum; | |
172 | |
173 if (event_data.slider_value > val->maximum - val->slider_size) | |
174 event_data.slider_value = val->maximum - val->slider_size; | |
175 else if (event_data.slider_value < val->minimum) | |
176 event_data.slider_value = val->minimum; | |
177 | |
178 if (data->event) | |
179 { | |
180 switch (data->event->type) | |
181 { | |
182 case KeyPress: | |
183 case KeyRelease: | |
184 event_data.time = data->event->xkey.time; | |
185 break; | |
186 case ButtonPress: | |
187 case ButtonRelease: | |
188 event_data.time = data->event->xbutton.time; | |
189 break; | |
190 case MotionNotify: | |
191 event_data.time = data->event->xmotion.time; | |
192 break; | |
193 case EnterNotify: | |
194 case LeaveNotify: | |
195 event_data.time = data->event->xcrossing.time; | |
196 break; | |
197 default: | |
198 event_data.time = 0; | |
199 break; | |
200 } | |
201 } | |
202 else | |
203 event_data.time = 0; | |
204 | |
205 switch (data->reason) | |
206 { | |
207 case XmCR_DECREMENT: event_data.action = SCROLLBAR_LINE_UP; break; | |
208 case XmCR_INCREMENT: event_data.action = SCROLLBAR_LINE_DOWN; break; | |
209 case XmCR_PAGE_DECREMENT: event_data.action = SCROLLBAR_PAGE_UP; break; | |
210 case XmCR_PAGE_INCREMENT: event_data.action = SCROLLBAR_PAGE_DOWN; break; | |
211 case XmCR_TO_TOP: event_data.action = SCROLLBAR_TOP; break; | |
212 case XmCR_TO_BOTTOM: event_data.action = SCROLLBAR_BOTTOM; break; | |
213 case XmCR_DRAG: event_data.action = SCROLLBAR_DRAG; break; | |
214 case XmCR_VALUE_CHANGED: event_data.action = SCROLLBAR_CHANGE; break; | |
215 default: event_data.action = SCROLLBAR_CHANGE; break; | |
216 } | |
217 | |
218 if (instance->info->pre_activate_cb) | |
219 instance->info->pre_activate_cb (widget, id, (XtPointer) &event_data); | |
220 } | |
221 | |
222 #define add_scrollbar_callback(resource) \ | |
223 XtAddCallback (scrollbar, resource, xlw_scrollbar_callback, (XtPointer) instance) | |
224 | |
225 /* #### Does not yet support horizontal scrollbars. */ | |
226 static Widget | |
227 xlw_create_scrollbar (widget_instance *instance, int vertical) | |
228 { | |
229 Arg al[20]; | |
230 int ac = 0; | |
231 static XtCallbackRec callbacks[2] = | |
232 { {xlw_scrollbar_callback, NULL}, {NULL, NULL} }; | |
233 | |
234 callbacks[0].closure = (XtPointer) instance; | |
235 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
236 Xt_SET_ARG (al[ac], XmNminimum, 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
237 Xt_SET_ARG (al[ac], XmNmaximum, INT_MAX); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
238 Xt_SET_ARG (al[ac], XmNincrement, 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
239 Xt_SET_ARG (al[ac], XmNpageIncrement, 1); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
240 Xt_SET_ARG (al[ac], XmNorientation, (vertical ? XmVERTICAL : XmHORIZONTAL)); ac++; |
428 | 241 |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
242 Xt_SET_ARG (al[ac], XmNdecrementCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
243 Xt_SET_ARG (al[ac], XmNdragCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
244 Xt_SET_ARG (al[ac], XmNincrementCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
245 Xt_SET_ARG (al[ac], XmNpageDecrementCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
246 Xt_SET_ARG (al[ac], XmNpageIncrementCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
247 Xt_SET_ARG (al[ac], XmNtoBottomCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
248 Xt_SET_ARG (al[ac], XmNtoTopCallback, callbacks); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
249 Xt_SET_ARG (al[ac], XmNvalueChangedCallback, callbacks); ac++; |
428 | 250 |
251 return XtCreateWidget (instance->info->name, xlwScrollBarWidgetClass, | |
252 instance->parent, al, ac); | |
253 } | |
254 | |
255 static Widget | |
256 xlw_create_vertical_scrollbar (widget_instance *instance) | |
257 { | |
258 return xlw_create_scrollbar (instance, 1); | |
259 } | |
260 | |
261 static Widget | |
262 xlw_create_horizontal_scrollbar (widget_instance *instance) | |
263 { | |
264 return xlw_create_scrollbar (instance, 0); | |
265 } | |
266 | |
267 static void | |
2286 | 268 xlw_update_scrollbar (widget_instance *UNUSED (instance), Widget widget, |
428 | 269 widget_value *val) |
270 { | |
271 if (val->scrollbar_data) | |
272 { | |
273 scrollbar_values *data = val->scrollbar_data; | |
274 int widget_sliderSize, widget_val; | |
275 int new_sliderSize, new_value; | |
276 double percent; | |
277 Arg al [4]; | |
278 | |
279 /* First size and position the scrollbar widget. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
280 Xt_SET_ARG (al [0], XtNx, data->scrollbar_x); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
281 Xt_SET_ARG (al [1], XtNy, data->scrollbar_y); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
282 Xt_SET_ARG (al [2], XtNwidth, data->scrollbar_width); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
283 Xt_SET_ARG (al [3], XtNheight, data->scrollbar_height); |
428 | 284 XtSetValues (widget, al, 4); |
285 | |
286 /* Now size the scrollbar's slider. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
287 Xt_SET_ARG (al [0], XmNsliderSize, &widget_sliderSize); |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
288 Xt_SET_ARG (al [1], XmNvalue, &widget_val); |
428 | 289 XtGetValues (widget, al, 2); |
290 | |
291 percent = (double) data->slider_size / | |
292 (double) (data->maximum - data->minimum); | |
293 percent = (percent > 1.0 ? 1.0 : percent); | |
294 new_sliderSize = (int) ((double) (INT_MAX - 1) * percent); | |
295 | |
296 percent = (double) (data->slider_position - data->minimum) / | |
297 (double) (data->maximum - data->minimum); | |
298 percent = (percent > 1.0 ? 1.0 : percent); | |
299 new_value = (int) ((double) (INT_MAX - 1) * percent); | |
300 | |
301 if (new_sliderSize > INT_MAX - 1) | |
302 new_sliderSize = INT_MAX - 1; | |
303 else if (new_sliderSize < 1) | |
304 new_sliderSize = 1; | |
305 | |
306 if (new_value > (INT_MAX - new_sliderSize)) | |
307 new_value = INT_MAX - new_sliderSize; | |
308 else if (new_value < 1) | |
309 new_value = 1; | |
310 | |
311 if (new_sliderSize != widget_sliderSize || new_value != widget_val) | |
312 XlwScrollBarSetValues (widget, new_value, new_sliderSize, 1, 1, False); | |
313 } | |
314 } | |
315 | |
316 #endif /* LWLIB_SCROLLBARS_LUCID */ | |
317 | |
318 #ifdef LWLIB_TABS_LUCID | |
319 /* tab control | |
320 | |
2641 | 321 [[ lwlib is such an incredible hairy crock. I just cannot believe |
428 | 322 it! There are random dependencies between functions, there is a |
323 total lack of genericity, even though it initially appears to be | |
324 generic. It should all be junked and begun again. Building tabs are | |
325 an example - in theory we should be able to reuse a lot of the | |
326 general stuff because we want to put labels of whatever toolkit we | |
2641 | 327 are using in the tab. Instead we have to hack it by hand. ]] |
328 While lwlib is a hairy crock, whoever wrote that seems to misunderstand | |
329 Falk's tab control widget. The tab control widget has *two* kinds of | |
330 children: *widgets*, which all occupy a *single* pane below the row of | |
331 tabs---this is where the labels created in build_tabs_in_widget go, and | |
332 *gadgets*, the tabs themselves, which do *not* draw themselves, but | |
333 rather are drawn by the control. In fact, in XEmacs the true widget | |
334 children are *never* visible! So this case is not a problem in the | |
335 design of lwlib, but rather of Falk's widget. -- sjt */ | |
428 | 336 static void |
337 xlw_tab_control_callback (Widget w, XtPointer client_data, XtPointer call_data) | |
338 { | |
339 /* call data is the topmost widget */ | |
340 widget_instance* instance = (widget_instance*)client_data; | |
341 Widget top = (Widget)call_data; | |
342 char *name = XtName (top); | |
343 widget_value* widget_val; | |
344 XtPointer widget_arg; | |
345 LWLIB_ID id; | |
346 lw_callback post_activate_cb; | |
347 | |
348 if (w->core.being_destroyed) | |
349 return; | |
350 | |
351 /* Grab these values before running any functions, in case running | |
352 the selection_cb causes the widget to be destroyed. */ | |
353 id = instance->info->id; | |
354 post_activate_cb = instance->info->post_activate_cb; | |
355 | |
356 /* search for the widget_val for the selected tab */ | |
357 for (widget_val = instance->info->val->contents; widget_val; | |
358 widget_val = widget_val->next) | |
359 { | |
360 if (!strcmp (widget_val->name, name)) | |
361 break; | |
362 } | |
363 | |
364 widget_arg = widget_val ? widget_val->call_data : NULL; | |
365 | |
366 if (instance->info->selection_cb && | |
367 widget_val && | |
368 widget_val->enabled && | |
369 !widget_val->contents) | |
370 instance->info->selection_cb (w, id, widget_arg); | |
371 | |
372 if (post_activate_cb) | |
373 post_activate_cb (w, id, widget_arg); | |
374 } | |
375 | |
376 static Widget | |
377 xlw_create_tab_control (widget_instance *instance) | |
378 { | |
379 Arg al[20]; | |
380 int ac = 0; | |
381 Widget tab = 0; | |
382 widget_value* val = instance->info->val; | |
383 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
384 Xt_SET_ARG (al [ac], XtNsensitive, val->enabled); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
385 Xt_SET_ARG (al [ac], XtNmappedWhenManaged, False); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
386 Xt_SET_ARG (al [ac], XtNorientation, XtorientHorizontal); ac++; |
428 | 387 |
388 /* add any args the user supplied for creation time */ | |
389 lw_add_value_args_to_args (val, al, &ac); | |
390 | |
391 tab = XtCreateManagedWidget (val->name, tabsWidgetClass, | |
392 instance->parent, al, ac); | |
393 XtRemoveAllCallbacks (tab, XtNcallback); | |
394 XtAddCallback (tab, XtNcallback, xlw_tab_control_callback, (XtPointer)instance); | |
395 | |
396 XtManageChild (tab); | |
397 | |
398 return tab; | |
399 } | |
400 | |
2286 | 401 static void build_tabs_in_widget (widget_instance* UNUSED (instance), |
402 Widget widget, widget_value* val) | |
428 | 403 { |
404 widget_value* cur = val; | |
2641 | 405 Arg al[1]; |
406 | |
407 /* Children are always invisible, don't permit resizing. */ | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
408 Xt_SET_ARG (al[0], XtNresizable, False); |
2641 | 409 |
428 | 410 for (cur = val; cur; cur = cur->next) |
411 { | |
412 if (cur->value) | |
413 { | |
2641 | 414 Widget w; |
428 | 415 #ifdef LWLIB_WIDGETS_MOTIF |
2641 | 416 w = xm_create_label (widget, cur); |
428 | 417 #else |
2641 | 418 w = xaw_create_label (widget, cur); |
428 | 419 #endif |
2641 | 420 XtSetValues (w, al, 1); |
428 | 421 } |
422 cur->change = NO_CHANGE; | |
423 } | |
424 } | |
425 | |
426 static void | |
427 xlw_update_tab_control (widget_instance* instance, Widget widget, widget_value* val) | |
428 { | |
429 Widget* children; | |
430 unsigned int num_children; | |
639 | 431 Dimension i; |
428 | 432 widget_value *cur = 0; |
433 | |
434 XtRemoveAllCallbacks (widget, XtNcallback); | |
435 XtAddCallback (widget, XtNcallback, xlw_tab_control_callback, (XtPointer)instance); | |
436 | |
437 if (val->change == STRUCTURAL_CHANGE | |
438 || | |
439 (val->contents && val->contents->change == STRUCTURAL_CHANGE)) | |
440 { | |
441 destroy_all_children (widget); | |
442 build_tabs_in_widget (instance, widget, val->contents); | |
443 } | |
444 | |
445 children = XtCompositeChildren (widget, &num_children); | |
446 if (children) | |
447 { | |
647 | 448 for (i = 0, cur = val->contents; i < (int) num_children; i++) |
428 | 449 { |
450 if (!cur) | |
451 abort (); | |
452 if (children [i]->core.being_destroyed | |
453 || strcmp (XtName (children [i]), cur->name)) | |
454 continue; | |
455 #ifdef NEED_MOTIF | |
456 if (lw_motif_widget_p (children [i])) | |
457 xm_update_one_widget (instance, children [i], cur, False); | |
458 #endif | |
459 #ifdef NEED_ATHENA | |
460 if (lw_xaw_widget_p (children [i])) | |
461 xaw_update_one_widget (instance, children [i], cur, False); | |
462 #endif | |
463 cur = cur->next; | |
464 } | |
465 XtFree ((char *) children); | |
466 } | |
467 if (cur) | |
468 abort (); | |
469 } | |
470 #endif /* LWLIB_TABS_LUCID */ | |
471 | |
771 | 472 #ifdef HAVE_X_WIDGETS |
428 | 473 static Widget |
474 xlw_create_clip_window (widget_instance *instance) | |
475 { | |
476 Arg al[20]; | |
477 int ac = 0; | |
478 Widget clip = 0; | |
479 widget_value* val = instance->info->val; | |
480 | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
481 Xt_SET_ARG (al [ac], XtNmappedWhenManaged, False); ac++; |
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
482 Xt_SET_ARG (al [ac], XtNsensitive, True); ac++; |
428 | 483 /* add any args the user supplied for creation time */ |
484 lw_add_value_args_to_args (val, al, &ac); | |
485 | |
486 /* Create a clip window to contain the subwidget. Incredibly the | |
487 XEmacs manager seems to be the most appropriate widget for | |
488 this. Nothing else is simple enough and yet does what is | |
489 required. */ | |
490 clip = XtCreateManagedWidget (val->name, | |
491 emacsManagerWidgetClass, | |
492 instance->parent, al, ac); | |
493 | |
494 return clip; | |
495 } | |
496 #endif | |
497 | |
450 | 498 const widget_creation_entry |
428 | 499 xlw_creation_table [] = |
500 { | |
501 #ifdef LWLIB_MENUBARS_LUCID | |
502 {"menubar", xlw_create_menubar}, | |
503 {"popup", xlw_create_popup_menu}, | |
504 #endif | |
505 #ifdef LWLIB_SCROLLBARS_LUCID | |
506 {"vertical-scrollbar", xlw_create_vertical_scrollbar}, | |
507 {"horizontal-scrollbar", xlw_create_horizontal_scrollbar}, | |
508 #endif | |
509 #ifdef LWLIB_TABS_LUCID | |
510 {"tab-control", xlw_create_tab_control}, | |
511 #endif | |
771 | 512 #ifdef HAVE_X_WIDGETS |
428 | 513 {"clip-window", xlw_create_clip_window}, |
514 #endif | |
515 {NULL, NULL} | |
516 }; | |
517 | |
518 Boolean | |
519 lw_lucid_widget_p (Widget widget) | |
520 { | |
521 WidgetClass the_class = XtClass (widget); | |
522 #ifdef LWLIB_MENUBARS_LUCID | |
523 if (the_class == xlwMenuWidgetClass) | |
524 return True; | |
525 #endif | |
526 #ifdef LWLIB_SCROLLBARS_LUCID | |
527 if (the_class == xlwScrollBarWidgetClass) | |
528 return True; | |
529 #endif | |
530 #ifdef LWLIB_TABS_LUCID | |
531 if (the_class == tabsWidgetClass) | |
532 return True; | |
533 #endif | |
534 #ifdef LWLIB_MENUBARS_LUCID | |
535 if (the_class == overrideShellWidgetClass) | |
536 return | |
537 XtClass (((CompositeWidget)widget)->composite.children [0]) | |
538 == xlwMenuWidgetClass; | |
539 #endif | |
771 | 540 #ifdef HAVE_X_WIDGETS |
432 | 541 if (the_class == emacsManagerWidgetClass) |
542 return True; | |
543 #endif | |
428 | 544 return False; |
545 } | |
546 | |
547 void | |
548 xlw_update_one_widget (widget_instance* instance, Widget widget, | |
2286 | 549 widget_value* val, Boolean UNUSED (deep_p)) |
428 | 550 { |
1201 | 551 WidgetClass class_ = XtClass (widget); |
428 | 552 |
553 if (0) | |
554 ; | |
555 #ifdef LWLIB_MENUBARS_LUCID | |
1201 | 556 else if (class_ == xlwMenuWidgetClass) |
428 | 557 { |
558 XlwMenuWidget mw; | |
559 if (XtIsShell (widget)) | |
560 mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0]; | |
561 else | |
562 mw = (XlwMenuWidget)widget; | |
4528
726060ee587c
First draft of g++ 4.3 warning removal patch. Builds. *Needs ChangeLogs.*
Stephen J. Turnbull <stephen@xemacs.org>
parents:
4522
diff
changeset
|
563 Xt_SET_VALUE (widget, XtNmenu, val); /* #### mw unused! */ |
428 | 564 } |
565 #endif | |
566 #ifdef LWLIB_SCROLLBARS_LUCID | |
1201 | 567 else if (class_ == xlwScrollBarWidgetClass) |
428 | 568 { |
569 xlw_update_scrollbar (instance, widget, val); | |
570 } | |
571 #endif | |
572 #ifdef LWLIB_TABS_LUCID | |
1201 | 573 else if (class_ == tabsWidgetClass) |
428 | 574 { |
575 xlw_update_tab_control (instance, widget, val); | |
576 } | |
577 #endif | |
442 | 578 /* Lastly update our global arg values. */ |
579 if (val->args && val->args->nargs) | |
580 XtSetValues (widget, val->args->args, val->args->nargs); | |
428 | 581 } |
582 | |
583 void | |
2286 | 584 xlw_update_one_value (widget_instance* UNUSED (instance), |
585 Widget UNUSED (widget), widget_value* UNUSED (val)) | |
428 | 586 { |
587 } | |
588 | |
589 void | |
2286 | 590 xlw_pop_instance (widget_instance* UNUSED (instance), Boolean UNUSED (up)) |
428 | 591 { |
592 } | |
593 | |
594 #ifdef LWLIB_MENUBARS_LUCID | |
595 void | |
596 xlw_popup_menu (Widget widget, XEvent *event) | |
597 { | |
598 XlwMenuWidget mw; | |
599 | |
600 if (!XtIsShell (widget)) | |
601 return; | |
602 | |
603 if (event->type == ButtonPress || event->type == ButtonRelease) | |
604 { | |
605 mw = (XlwMenuWidget)((CompositeWidget)widget)->composite.children [0]; | |
606 xlw_pop_up_menu (mw, (XButtonPressedEvent *)event); | |
607 } | |
608 else | |
609 abort (); | |
610 } | |
611 #endif /* LWLIB_MENUBARS_LUCID */ | |
612 | |
613 /* Destruction of instances */ | |
614 void | |
615 xlw_destroy_instance (widget_instance* instance) | |
616 { | |
617 if (instance->widget) | |
618 XtDestroyWidget (instance->widget); | |
619 } |