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