0
|
1 /* A general interface to the widgets of different toolkits.
|
|
2 Copyright (C) 1992, 1993, 1994 Lucid, Inc.
|
|
3 Copyright (C) 1995 Tinker Systems and INS Engineering Corp.
|
|
4
|
|
5 This file is part of the Lucid Widget Library.
|
|
6
|
|
7 The Lucid Widget Library is free software; you can redistribute it and/or
|
|
8 modify it under the terms of the GNU General Public License as published by
|
|
9 the Free Software Foundation; either version 2, or (at your option)
|
|
10 any later version.
|
|
11
|
|
12 The Lucid Widget Library is distributed in the hope that it will be useful,
|
|
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
15 GNU General Public License for more details.
|
|
16
|
|
17 You should have received a copy of the GNU General Public License
|
80
|
18 along with XEmacs; see the file COPYING. If not, write to
|
|
19 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
|
|
20 Boston, MA 02111-1307, USA. */
|
0
|
21
|
|
22 #ifdef NeXT
|
|
23 #undef __STRICT_BSD__ /* ick */
|
|
24 #endif
|
|
25
|
149
|
26 #include <config.h>
|
0
|
27 #include <stdlib.h>
|
|
28 #include <unistd.h>
|
|
29 #include <sys/types.h>
|
|
30 #include <string.h>
|
|
31 #include <stdio.h>
|
|
32 #include <X11/StringDefs.h>
|
|
33 #include "lwlib-internal.h"
|
|
34 #include "lwlib-utils.h"
|
|
35
|
|
36 #ifdef NEED_LUCID
|
|
37 #include "lwlib-Xlw.h"
|
|
38 #endif
|
|
39 #ifdef NEED_MOTIF
|
|
40 #include "lwlib-Xm.h"
|
|
41 #endif
|
|
42 #ifdef NEED_ATHENA
|
|
43 #include "lwlib-Xaw.h"
|
|
44 #endif
|
|
45
|
|
46 /* #### Does a check need to be put back in here to make sure we have
|
|
47 sufficient defines to function properly or are the checks in the
|
|
48 makefile sufficient? */
|
|
49
|
|
50 /* List of all widgets managed by the library. Note that each "widget"
|
|
51 listed here may actually be a tree of widgets; for example, a
|
|
52 single entry here might represent a single menubar or popup menu,
|
|
53 each of which might be implemented with a tree of widgets.
|
|
54 */
|
|
55 static widget_info *all_widget_info = NULL;
|
|
56
|
|
57
|
|
58 /* Forward declarations */
|
|
59 static void
|
|
60 instantiate_widget_instance (widget_instance *instance);
|
|
61
|
|
62
|
|
63 /* utility functions for widget_instance and widget_info */
|
|
64 static char *
|
|
65 safe_strdup (CONST char *s)
|
|
66 {
|
|
67 char *result;
|
|
68 if (! s) return 0;
|
|
69 result = (char *) malloc (strlen (s) + 1);
|
|
70 if (! result)
|
|
71 return 0;
|
|
72 strcpy (result, s);
|
|
73 return result;
|
|
74 }
|
|
75
|
|
76 static void
|
|
77 safe_free_str (char *s)
|
|
78 {
|
|
79 if (s) free (s);
|
|
80 }
|
|
81
|
|
82 static widget_value *widget_value_free_list = 0;
|
|
83
|
|
84 widget_value *
|
|
85 malloc_widget_value (void)
|
|
86 {
|
|
87 widget_value *wv;
|
|
88 if (widget_value_free_list)
|
|
89 {
|
|
90 wv = widget_value_free_list;
|
|
91 widget_value_free_list = wv->free_list;
|
|
92 wv->free_list = 0;
|
|
93 }
|
|
94 else
|
|
95 {
|
|
96 wv = (widget_value *) malloc (sizeof (widget_value));
|
|
97 }
|
|
98 if (wv)
|
|
99 {
|
|
100 memset (wv, 0, sizeof (widget_value));
|
|
101 }
|
|
102 return wv;
|
|
103 }
|
|
104
|
|
105 /* this is analogous to free(). It frees only what was allocated
|
|
106 by malloc_widget_value(), and no substructures.
|
|
107 */
|
|
108 void
|
|
109 free_widget_value (widget_value *wv)
|
|
110 {
|
|
111 if (wv->free_list)
|
|
112 abort ();
|
|
113 wv->free_list = widget_value_free_list;
|
|
114 widget_value_free_list = wv;
|
|
115 }
|
|
116
|
|
117 static void free_widget_value_tree (widget_value *wv);
|
|
118
|
|
119 static void
|
|
120 free_widget_value_contents (widget_value *wv)
|
|
121 {
|
|
122 if (wv->name) free (wv->name);
|
|
123 if (wv->value) free (wv->value);
|
|
124 if (wv->key) free (wv->key);
|
|
125
|
|
126 /* #### - all of this 0xDEADBEEF stuff should be unnecessary
|
|
127 in production code... it should be conditionalized. */
|
|
128 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
|
|
129
|
|
130 if (wv->toolkit_data && wv->free_toolkit_data)
|
|
131 {
|
|
132 free (wv->toolkit_data);
|
|
133 wv->toolkit_data = (void *) 0xDEADBEEF;
|
|
134 }
|
|
135 #ifdef NEED_SCROLLBARS
|
|
136 if (wv->scrollbar_data)
|
|
137 {
|
|
138 free (wv->scrollbar_data);
|
|
139 wv->scrollbar_data = NULL;
|
|
140 }
|
|
141 #endif
|
|
142 if (wv->contents && (wv->contents != (widget_value*)1))
|
|
143 {
|
|
144 free_widget_value_tree (wv->contents);
|
|
145 wv->contents = (widget_value *) 0xDEADBEEF;
|
|
146 }
|
|
147 if (wv->next)
|
|
148 {
|
|
149 free_widget_value_tree (wv->next);
|
|
150 wv->next = (widget_value *) 0xDEADBEEF;
|
|
151 }
|
|
152 }
|
|
153
|
|
154 static void
|
|
155 free_widget_value_tree (widget_value *wv)
|
|
156 {
|
|
157 if (!wv)
|
|
158 return;
|
|
159
|
|
160 free_widget_value_contents (wv);
|
|
161 free_widget_value (wv);
|
|
162 }
|
|
163
|
|
164 #ifdef NEED_SCROLLBARS
|
|
165
|
|
166 static void
|
|
167 copy_scrollbar_values (widget_value *val, widget_value *copy)
|
|
168 {
|
|
169 if (!copy->scrollbar_data)
|
|
170 copy->scrollbar_data =
|
|
171 (scrollbar_values *) malloc (sizeof (scrollbar_values));
|
|
172
|
|
173 if (val->scrollbar_data)
|
|
174 *copy->scrollbar_data = *val->scrollbar_data;
|
|
175 else
|
|
176 memset (copy->scrollbar_data, 0, sizeof (scrollbar_values));
|
|
177 }
|
|
178
|
|
179 /*
|
|
180 * Return true if old->scrollbar_data were not equivalent
|
|
181 * to new->scrollbar_data.
|
|
182 */
|
|
183 static Boolean
|
|
184 merge_scrollbar_values (widget_value *old, widget_value *new)
|
|
185 {
|
|
186 Boolean changed = False;
|
|
187
|
|
188 if (new->scrollbar_data && !old->scrollbar_data)
|
|
189 {
|
|
190 copy_scrollbar_values (new, old);
|
|
191 changed = True;
|
|
192 }
|
|
193 else if (!new->scrollbar_data && old->scrollbar_data)
|
|
194 {
|
|
195 free (old->scrollbar_data);
|
|
196 old->scrollbar_data = NULL;
|
|
197 }
|
|
198 else if (new->scrollbar_data && old->scrollbar_data)
|
|
199 {
|
|
200 scrollbar_values *old_sb = old->scrollbar_data;
|
|
201 scrollbar_values *new_sb = new->scrollbar_data;
|
|
202 #define FROB(field) if (old_sb->field != new_sb->field) changed = True
|
|
203 FROB (line_increment);
|
|
204 FROB (page_increment);
|
|
205 FROB (minimum);
|
|
206 FROB (maximum);
|
|
207 FROB (slider_size);
|
|
208 FROB (slider_position);
|
|
209 FROB (scrollbar_width);
|
|
210 FROB (scrollbar_height);
|
|
211 FROB (scrollbar_x);
|
|
212 FROB (scrollbar_y);
|
|
213 #undef FROB
|
|
214 *old_sb = *new_sb;
|
|
215 }
|
|
216
|
|
217 return changed;
|
|
218 }
|
|
219
|
|
220 #endif /* NEED_SCROLLBARS */
|
|
221
|
|
222 /* Make a complete copy of a widget_value tree. Store CHANGE into
|
|
223 the widget_value tree's `change' field. */
|
|
224
|
|
225 static widget_value *
|
|
226 copy_widget_value_tree (widget_value *val, change_type change)
|
|
227 {
|
|
228 widget_value *copy;
|
|
229
|
|
230 if (!val)
|
|
231 return NULL;
|
|
232 if (val == (widget_value *) 1)
|
|
233 return val;
|
|
234
|
|
235 copy = malloc_widget_value ();
|
|
236 if (copy)
|
|
237 {
|
|
238 /* #### - don't seg fault *here* if out of memory. Menus will be
|
|
239 truncated inexplicably. */
|
|
240 copy->type = val->type;
|
|
241 copy->name = safe_strdup (val->name);
|
|
242 copy->value = safe_strdup (val->value);
|
|
243 copy->key = safe_strdup (val->key);
|
|
244 copy->enabled = val->enabled;
|
|
245 copy->selected = val->selected;
|
|
246 copy->edited = False;
|
|
247 copy->change = change;
|
|
248 copy->contents = copy_widget_value_tree (val->contents, change);
|
|
249 copy->call_data = val->call_data;
|
|
250 copy->next = copy_widget_value_tree (val->next, change);
|
|
251 copy->toolkit_data = NULL;
|
|
252 copy->free_toolkit_data = False;
|
|
253 #ifdef NEED_SCROLLBARS
|
|
254 copy_scrollbar_values (val, copy);
|
|
255 #endif
|
|
256 }
|
|
257 return copy;
|
|
258 }
|
|
259
|
|
260 /* This function is used to implement incremental menu construction. */
|
|
261
|
|
262 widget_value *
|
|
263 replace_widget_value_tree (widget_value *node, widget_value *newtree)
|
|
264 {
|
|
265 widget_value *copy;
|
|
266
|
|
267 if (!node || !newtree)
|
|
268 abort ();
|
|
269
|
|
270 copy = copy_widget_value_tree (newtree, STRUCTURAL_CHANGE);
|
|
271
|
|
272 free_widget_value_contents (node);
|
|
273 *node = *copy;
|
|
274 free_widget_value (copy); /* free the node, but not its contents. */
|
|
275 return node;
|
|
276 }
|
|
277
|
|
278 static widget_info *
|
|
279 allocate_widget_info (CONST char *type, CONST char *name,
|
|
280 LWLIB_ID id, widget_value *val,
|
|
281 lw_callback pre_activate_cb, lw_callback selection_cb,
|
|
282 lw_callback post_activate_cb)
|
|
283 {
|
|
284 widget_info *info = (widget_info *) malloc (sizeof (widget_info));
|
|
285 info->type = safe_strdup (type);
|
|
286 info->name = safe_strdup (name);
|
|
287 info->id = id;
|
|
288 info->val = copy_widget_value_tree (val, STRUCTURAL_CHANGE);
|
|
289 info->busy = False;
|
|
290 info->pre_activate_cb = pre_activate_cb;
|
|
291 info->selection_cb = selection_cb;
|
|
292 info->post_activate_cb = post_activate_cb;
|
|
293 info->instances = NULL;
|
|
294
|
|
295 info->next = all_widget_info;
|
|
296 all_widget_info = info;
|
|
297
|
|
298 return info;
|
|
299 }
|
|
300
|
|
301 static void
|
|
302 free_widget_info (widget_info *info)
|
|
303 {
|
|
304 safe_free_str (info->type);
|
|
305 safe_free_str (info->name);
|
|
306 free_widget_value_tree (info->val);
|
|
307 memset ((void*)info, 0xDEADBEEF, sizeof (widget_info));
|
|
308 free (info);
|
|
309 }
|
|
310
|
|
311 static void
|
|
312 mark_widget_destroyed (Widget widget, XtPointer closure, XtPointer call_data)
|
|
313 {
|
|
314 widget_instance *instance = (widget_instance*)closure;
|
|
315
|
|
316 /* be very conservative */
|
|
317 if (instance->widget == widget)
|
|
318 instance->widget = NULL;
|
|
319 }
|
|
320
|
|
321 static widget_instance *
|
|
322 allocate_widget_instance (widget_info *info, Widget parent, Boolean pop_up_p)
|
|
323 {
|
|
324 widget_instance *instance =
|
|
325 (widget_instance *) malloc (sizeof (widget_instance));
|
|
326 instance->parent = parent;
|
|
327 instance->pop_up_p = pop_up_p;
|
|
328 instance->info = info;
|
|
329 instance->next = info->instances;
|
|
330 info->instances = instance;
|
|
331
|
|
332 instantiate_widget_instance (instance);
|
|
333
|
|
334 XtAddCallback (instance->widget, XtNdestroyCallback,
|
|
335 mark_widget_destroyed, (XtPointer)instance);
|
|
336 return instance;
|
|
337 }
|
|
338
|
|
339 static void
|
|
340 free_widget_instance (widget_instance *instance)
|
|
341 {
|
|
342 memset ((void *) instance, 0xDEADBEEF, sizeof (widget_instance));
|
|
343 free (instance);
|
|
344 }
|
|
345
|
|
346 static widget_info *
|
|
347 get_widget_info (LWLIB_ID id, Boolean remove_p)
|
|
348 {
|
|
349 widget_info *info;
|
|
350 widget_info *prev;
|
|
351 for (prev = NULL, info = all_widget_info;
|
|
352 info;
|
|
353 prev = info, info = info->next)
|
|
354 if (info->id == id)
|
|
355 {
|
|
356 if (remove_p)
|
|
357 {
|
|
358 if (prev)
|
|
359 prev->next = info->next;
|
|
360 else
|
|
361 all_widget_info = info->next;
|
|
362 }
|
|
363 return info;
|
|
364 }
|
|
365 return NULL;
|
|
366 }
|
|
367
|
|
368 /* Internal function used by the library dependent implementation to get the
|
|
369 widget_value for a given widget in an instance */
|
|
370 widget_info *
|
|
371 lw_get_widget_info (LWLIB_ID id)
|
|
372 {
|
|
373 return get_widget_info (id, 0);
|
|
374 }
|
|
375
|
|
376 static int
|
|
377 map_widget_values (widget_value *value, int (*mapfunc) (widget_value *value,
|
|
378 void *closure),
|
|
379 void *closure)
|
|
380 {
|
|
381 int retval = 0;
|
|
382
|
|
383 if (value->contents)
|
|
384 retval = map_widget_values (value->contents, mapfunc, closure);
|
|
385 if (retval)
|
|
386 return retval;
|
|
387
|
|
388 if (value->next)
|
|
389 retval = map_widget_values (value->next, mapfunc, closure);
|
|
390 if (retval)
|
|
391 return retval;
|
|
392
|
|
393 return (mapfunc) (value, closure);
|
|
394 }
|
|
395
|
|
396 int
|
|
397 lw_map_widget_values (LWLIB_ID id, int (*mapfunc) (widget_value *value,
|
|
398 void *closure),
|
|
399 void *closure)
|
|
400 {
|
|
401 widget_info *info = get_widget_info (id, 0);
|
|
402
|
|
403 if (!info)
|
|
404 abort ();
|
|
405
|
|
406 if (info->val)
|
|
407 return map_widget_values (info->val, mapfunc, closure);
|
|
408 return 0;
|
|
409 }
|
|
410
|
|
411 static widget_instance *
|
|
412 get_widget_instance (Widget widget, Boolean remove_p)
|
|
413 {
|
|
414 widget_info *info;
|
|
415 widget_instance *instance;
|
|
416 widget_instance *prev;
|
|
417 for (info = all_widget_info; info; info = info->next)
|
|
418 for (prev = NULL, instance = info->instances;
|
|
419 instance;
|
|
420 prev = instance, instance = instance->next)
|
|
421 if (instance->widget == widget)
|
|
422 {
|
|
423 if (remove_p)
|
|
424 {
|
|
425 if (prev)
|
|
426 prev->next = instance->next;
|
|
427 else
|
|
428 info->instances = instance->next;
|
|
429 }
|
|
430 return instance;
|
|
431 }
|
|
432 return (widget_instance *) 0;
|
|
433 }
|
|
434
|
|
435 static widget_instance*
|
|
436 find_instance (LWLIB_ID id, Widget parent, Boolean pop_up_p)
|
|
437 {
|
|
438 widget_info *info = get_widget_info (id, False);
|
|
439 widget_instance *instance;
|
|
440
|
|
441 if (info)
|
|
442 for (instance = info->instances; instance; instance = instance->next)
|
|
443 if (instance->parent == parent && instance->pop_up_p == pop_up_p)
|
|
444 return instance;
|
|
445
|
|
446 return NULL;
|
|
447 }
|
|
448
|
|
449
|
|
450 /* utility function for widget_value */
|
|
451 static Boolean
|
|
452 safe_strcmp (CONST char *s1, CONST char *s2)
|
|
453 {
|
|
454 if (!!s1 ^ !!s2) return True;
|
|
455 return (s1 && s2) ? strcmp (s1, s2) : s1 ? False : !!s2;
|
|
456 }
|
|
457
|
118
|
458 #ifndef WINDOWSNT
|
2
|
459 static change_type
|
|
460 max (change_type i1, change_type i2)
|
0
|
461 {
|
2
|
462 return (int)i1 > (int)i2 ? i1 : i2;
|
0
|
463 }
|
118
|
464 #endif
|
0
|
465
|
|
466
|
|
467 #if 0
|
|
468 # define EXPLAIN(name, oc, nc, desc, a1, a2) \
|
|
469 printf ("Change: \"%s\"\tmax(%s=%d,%s=%d)\t%s %d %d\n", \
|
|
470 name, \
|
|
471 (oc == NO_CHANGE ? "none" : \
|
|
472 (oc == INVISIBLE_CHANGE ? "invisible" : \
|
|
473 (oc == VISIBLE_CHANGE ? "visible" : \
|
|
474 (oc == STRUCTURAL_CHANGE ? "structural" : "???")))), \
|
|
475 oc, \
|
|
476 (nc == NO_CHANGE ? "none" : \
|
|
477 (nc == INVISIBLE_CHANGE ? "invisible" : \
|
|
478 (nc == VISIBLE_CHANGE ? "visible" : \
|
|
479 (nc == STRUCTURAL_CHANGE ? "structural" : "???")))), \
|
|
480 nc, desc, a1, a2)
|
|
481 #else
|
|
482 # define EXPLAIN(name, oc, nc, desc, a1, a2)
|
|
483 #endif
|
|
484
|
|
485
|
|
486 static widget_value *
|
|
487 merge_widget_value (widget_value *val1, widget_value *val2, int level)
|
|
488 {
|
|
489 change_type change;
|
|
490 widget_value *merged_next;
|
|
491 widget_value *merged_contents;
|
|
492
|
|
493 if (!val1)
|
|
494 {
|
|
495 if (val2)
|
|
496 return copy_widget_value_tree (val2, STRUCTURAL_CHANGE);
|
|
497 else
|
|
498 return NULL;
|
|
499 }
|
|
500 if (!val2)
|
|
501 {
|
|
502 free_widget_value_tree (val1);
|
|
503 return NULL;
|
|
504 }
|
|
505
|
|
506 change = NO_CHANGE;
|
|
507
|
|
508 if (val1->type != val2->type)
|
|
509 {
|
|
510 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "type change",
|
|
511 val1->type, val2->type);
|
|
512 change = max (change, STRUCTURAL_CHANGE);
|
|
513 val1->type = val2->type;
|
|
514 }
|
|
515 if (safe_strcmp (val1->name, val2->name))
|
|
516 {
|
|
517 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "name change",
|
|
518 val1->name, val2->name);
|
|
519 change = max (change, STRUCTURAL_CHANGE);
|
|
520 safe_free_str (val1->name);
|
|
521 val1->name = safe_strdup (val2->name);
|
|
522 }
|
|
523 if (safe_strcmp (val1->value, val2->value))
|
|
524 {
|
|
525 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "value change",
|
|
526 val1->value, val2->value);
|
|
527 change = max (change, VISIBLE_CHANGE);
|
|
528 safe_free_str (val1->value);
|
|
529 val1->value = safe_strdup (val2->value);
|
|
530 }
|
|
531 if (safe_strcmp (val1->key, val2->key))
|
|
532 {
|
|
533 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "key change",
|
|
534 val1->key, val2->key);
|
|
535 change = max (change, VISIBLE_CHANGE);
|
|
536 safe_free_str (val1->key);
|
|
537 val1->key = safe_strdup (val2->key);
|
|
538 }
|
|
539 if (val1->enabled != val2->enabled)
|
|
540 {
|
|
541 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "enablement change",
|
|
542 val1->enabled, val2->enabled);
|
|
543 change = max (change, VISIBLE_CHANGE);
|
|
544 val1->enabled = val2->enabled;
|
|
545 }
|
|
546 if (val1->selected != val2->selected)
|
|
547 {
|
|
548 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "selection change",
|
|
549 val1->selected, val2->selected);
|
|
550 change = max (change, VISIBLE_CHANGE);
|
|
551 val1->selected = val2->selected;
|
|
552 }
|
|
553 if (val1->call_data != val2->call_data)
|
|
554 {
|
|
555 EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "call-data change",
|
|
556 val1->call_data, val2->call_data);
|
|
557 change = max (change, INVISIBLE_CHANGE);
|
|
558 val1->call_data = val2->call_data;
|
|
559 }
|
|
560 #ifdef NEED_SCROLLBARS
|
|
561 if (merge_scrollbar_values (val1, val2))
|
|
562 {
|
|
563 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "scrollbar change", 0, 0);
|
|
564 change = max (change, VISIBLE_CHANGE);
|
|
565 }
|
|
566 #endif
|
|
567
|
|
568 if (level > 0)
|
|
569 {
|
|
570 merged_contents =
|
|
571 merge_widget_value (val1->contents, val2->contents, level - 1);
|
|
572
|
|
573 if (val1->contents && !merged_contents)
|
|
574 {
|
|
575 EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "(contents gone)",
|
|
576 0, 0);
|
|
577 change = max (change, INVISIBLE_CHANGE);
|
|
578 }
|
|
579 else if (merged_contents && merged_contents->change != NO_CHANGE)
|
|
580 {
|
|
581 EXPLAIN (val1->name, change, INVISIBLE_CHANGE, "(contents change)",
|
|
582 0, 0);
|
|
583 change = max (change, INVISIBLE_CHANGE);
|
|
584 }
|
|
585
|
|
586 val1->contents = merged_contents;
|
|
587 }
|
|
588
|
|
589 merged_next = merge_widget_value (val1->next, val2->next, level);
|
|
590
|
|
591 if (val1->next && !merged_next)
|
|
592 {
|
|
593 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "(following gone)",
|
|
594 0, 0);
|
|
595 change = max (change, STRUCTURAL_CHANGE);
|
|
596 }
|
|
597 else if (merged_next)
|
|
598 {
|
|
599 if (merged_next->change)
|
|
600 {
|
|
601 EXPLAIN (val1->name, change, merged_next->change, "(following change)",
|
|
602 0, 0);
|
|
603 }
|
|
604 change = max (change, merged_next->change);
|
|
605 }
|
|
606
|
|
607 val1->next = merged_next;
|
|
608
|
|
609 val1->change = change;
|
|
610
|
|
611 if (change > NO_CHANGE && val1->toolkit_data)
|
|
612 {
|
|
613 if (val1->free_toolkit_data)
|
|
614 free (val1->toolkit_data);
|
|
615 val1->toolkit_data = NULL;
|
|
616 }
|
|
617
|
|
618 return val1;
|
|
619 }
|
|
620
|
|
621
|
|
622 /* modifying the widgets */
|
|
623 static Widget
|
|
624 name_to_widget (widget_instance *instance, CONST char *name)
|
|
625 {
|
|
626 Widget widget = NULL;
|
|
627
|
|
628 if (!instance->widget)
|
|
629 return NULL;
|
|
630
|
|
631 if (!strcmp (XtName (instance->widget), name))
|
|
632 widget = instance->widget;
|
|
633 else
|
|
634 {
|
|
635 int length = strlen (name) + 2;
|
|
636 char *real_name = (char *) alloca (length);
|
|
637 real_name [0] = '*';
|
|
638 strcpy (real_name + 1, name);
|
|
639
|
|
640 widget = XtNameToWidget (instance->widget, real_name);
|
|
641 }
|
|
642 return widget;
|
|
643 }
|
|
644
|
|
645 static void
|
|
646 set_one_value (widget_instance *instance, widget_value *val, Boolean deep_p)
|
|
647 {
|
|
648 Widget widget = name_to_widget (instance, val->name);
|
|
649
|
|
650 if (widget)
|
|
651 {
|
|
652 #ifdef NEED_LUCID
|
|
653 if (lw_lucid_widget_p (instance->widget))
|
|
654 xlw_update_one_widget (instance, widget, val, deep_p);
|
|
655 #endif
|
|
656 #ifdef NEED_MOTIF
|
|
657 if (lw_motif_widget_p (instance->widget))
|
|
658 xm_update_one_widget (instance, widget, val, deep_p);
|
|
659 #endif
|
|
660 #ifdef NEED_ATHENA
|
|
661 if (lw_xaw_widget_p (instance->widget))
|
|
662 xaw_update_one_widget (instance, widget, val, deep_p);
|
|
663 #endif
|
|
664 }
|
|
665 }
|
|
666
|
|
667 static void
|
|
668 update_one_widget_instance (widget_instance *instance, Boolean deep_p)
|
|
669 {
|
|
670 widget_value *val;
|
|
671
|
|
672 if (!instance->widget)
|
|
673 /* the widget was destroyed */
|
|
674 return;
|
|
675
|
|
676 for (val = instance->info->val; val; val = val->next)
|
|
677 if (val->change != NO_CHANGE)
|
|
678 set_one_value (instance, val, deep_p);
|
|
679 }
|
|
680
|
|
681 static void
|
|
682 update_all_widget_values (widget_info *info, Boolean deep_p)
|
|
683 {
|
|
684 widget_instance *instance;
|
|
685 widget_value *val;
|
|
686
|
|
687 for (instance = info->instances; instance; instance = instance->next)
|
|
688 update_one_widget_instance (instance, deep_p);
|
|
689
|
|
690 for (val = info->val; val; val = val->next)
|
|
691 val->change = NO_CHANGE;
|
|
692 }
|
|
693
|
|
694 void
|
|
695 lw_modify_all_widgets (LWLIB_ID id, widget_value *val, Boolean deep_p)
|
|
696 {
|
|
697 widget_info *info = get_widget_info (id, False);
|
|
698 widget_value *new_val;
|
|
699 widget_value *next_new_val;
|
|
700 widget_value *cur;
|
|
701 widget_value *prev;
|
|
702 widget_value *next;
|
|
703 int found;
|
|
704
|
|
705 if (!info)
|
|
706 return;
|
|
707
|
|
708 for (new_val = val; new_val; new_val = new_val->next)
|
|
709 {
|
|
710 next_new_val = new_val->next;
|
|
711 new_val->next = NULL;
|
|
712 found = False;
|
|
713 for (prev = NULL, cur = info->val; cur; prev = cur, cur = cur->next)
|
|
714 if (!strcmp (cur->name, new_val->name))
|
|
715 {
|
|
716 found = True;
|
|
717 next = cur->next;
|
|
718 cur->next = NULL;
|
|
719 cur = merge_widget_value (cur, new_val, deep_p ? 1000 : 1);
|
|
720 if (prev)
|
|
721 prev->next = cur ? cur : next;
|
|
722 else
|
|
723 info->val = cur ? cur : next;
|
|
724 if (cur)
|
|
725 cur->next = next;
|
|
726 break;
|
|
727 }
|
|
728 if (!found)
|
|
729 {
|
|
730 /* Could not find it, add it */
|
|
731 if (prev)
|
|
732 prev->next = copy_widget_value_tree (new_val, STRUCTURAL_CHANGE);
|
|
733 else
|
|
734 info->val = copy_widget_value_tree (new_val, STRUCTURAL_CHANGE);
|
|
735 }
|
|
736 new_val->next = next_new_val;
|
|
737 }
|
|
738
|
|
739 update_all_widget_values (info, deep_p);
|
|
740 }
|
|
741
|
|
742
|
|
743 /* creating the widgets */
|
|
744
|
|
745 static void
|
|
746 initialize_widget_instance (widget_instance *instance)
|
|
747 {
|
|
748 widget_value *val;
|
|
749
|
|
750 for (val = instance->info->val; val; val = val->next)
|
|
751 val->change = STRUCTURAL_CHANGE;
|
|
752
|
|
753 update_one_widget_instance (instance, True);
|
|
754
|
|
755 for (val = instance->info->val; val; val = val->next)
|
|
756 val->change = NO_CHANGE;
|
|
757 }
|
|
758
|
|
759
|
|
760 static widget_creation_function
|
|
761 find_in_table (CONST char *type, widget_creation_entry *table)
|
|
762 {
|
|
763 widget_creation_entry *cur;
|
|
764 for (cur = table; cur->type; cur++)
|
|
765 if (!strcasecmp (type, cur->type))
|
|
766 return cur->function;
|
|
767 return NULL;
|
|
768 }
|
|
769
|
|
770 static Boolean
|
|
771 dialog_spec_p (CONST char *name)
|
|
772 {
|
|
773 /* return True if name matches [EILPQeilpq][1-9][Bb] or
|
|
774 [EILPQeilpq][1-9][Bb][Rr][1-9] */
|
|
775 if (!name)
|
|
776 return False;
|
|
777
|
|
778 switch (name [0])
|
|
779 {
|
|
780 case 'E': case 'I': case 'L': case 'P': case 'Q':
|
|
781 case 'e': case 'i': case 'l': case 'p': case 'q':
|
|
782 if (name [1] >= '0' && name [1] <= '9')
|
|
783 {
|
|
784 if (name [2] != 'B' && name [2] != 'b')
|
|
785 return False;
|
|
786 if (!name [3])
|
|
787 return True;
|
|
788 if ((name [3] == 'T' || name [3] == 't') && !name [4])
|
|
789 return True;
|
|
790 if ((name [3] == 'R' || name [3] == 'r')
|
|
791 && name [4] >= '0' && name [4] <= '9' && !name [5])
|
|
792 return True;
|
|
793 return False;
|
|
794 }
|
|
795 else
|
|
796 return False;
|
|
797
|
|
798 default:
|
|
799 return False;
|
|
800 }
|
|
801 }
|
|
802
|
|
803 static void
|
|
804 instantiate_widget_instance (widget_instance *instance)
|
|
805 {
|
|
806 widget_creation_function function = NULL;
|
|
807
|
|
808 #ifdef NEED_LUCID
|
|
809 if (!function)
|
|
810 function = find_in_table (instance->info->type, xlw_creation_table);
|
|
811 #endif
|
|
812 #ifdef NEED_MOTIF
|
|
813 if (!function)
|
|
814 function = find_in_table (instance->info->type, xm_creation_table);
|
|
815 #endif
|
|
816 #ifdef NEED_ATHENA
|
|
817 if (!function)
|
|
818 function = find_in_table (instance->info->type, xaw_creation_table);
|
|
819 #endif
|
|
820
|
|
821 if (!function)
|
|
822 {
|
|
823 if (dialog_spec_p (instance->info->type))
|
|
824 {
|
|
825 #ifdef DIALOGS_MOTIF
|
|
826 if (!function)
|
|
827 function = xm_create_dialog;
|
|
828 #endif
|
|
829 #ifdef DIALOGS_ATHENA
|
|
830 if (!function)
|
|
831 function = xaw_create_dialog;
|
|
832 #endif
|
|
833 #ifdef DIALOGS_LUCID
|
|
834 /* not yet (not ever?) */
|
|
835 #endif
|
|
836 }
|
|
837 }
|
|
838
|
|
839 if (!function)
|
|
840 {
|
|
841 fprintf (stderr, "No creation function for widget type %s\n",
|
|
842 instance->info->type);
|
|
843 abort ();
|
|
844 }
|
|
845
|
|
846 instance->widget = (*function) (instance);
|
|
847
|
|
848 if (!instance->widget)
|
|
849 abort ();
|
|
850
|
|
851 /* XtRealizeWidget (instance->widget);*/
|
|
852 }
|
|
853
|
|
854 void
|
|
855 lw_register_widget (CONST char *type, CONST char *name,
|
|
856 LWLIB_ID id, widget_value *val,
|
|
857 lw_callback pre_activate_cb, lw_callback selection_cb,
|
|
858 lw_callback post_activate_cb)
|
|
859 {
|
|
860 if (!get_widget_info (id, False))
|
|
861 allocate_widget_info (type, name, id, val, pre_activate_cb, selection_cb,
|
|
862 post_activate_cb);
|
|
863 }
|
|
864
|
|
865 Widget
|
|
866 lw_get_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p)
|
|
867 {
|
|
868 widget_instance *instance;
|
|
869
|
|
870 instance = find_instance (id, parent, pop_up_p);
|
|
871 return instance ? instance->widget : NULL;
|
|
872 }
|
|
873
|
|
874 Widget
|
|
875 lw_make_widget (LWLIB_ID id, Widget parent, Boolean pop_up_p)
|
|
876 {
|
|
877 widget_instance *instance;
|
|
878 widget_info *info;
|
|
879
|
|
880 instance = find_instance (id, parent, pop_up_p);
|
|
881 if (!instance)
|
|
882 {
|
|
883 info = get_widget_info (id, False);
|
|
884 if (!info)
|
|
885 return NULL;
|
|
886 instance = allocate_widget_instance (info, parent, pop_up_p);
|
|
887 initialize_widget_instance (instance);
|
|
888 }
|
|
889 if (!instance->widget)
|
|
890 abort ();
|
|
891 return instance->widget;
|
|
892 }
|
|
893
|
|
894 Widget
|
|
895 lw_create_widget (CONST char *type, CONST char *name,
|
|
896 LWLIB_ID id, widget_value *val,
|
|
897 Widget parent, Boolean pop_up_p, lw_callback pre_activate_cb,
|
|
898 lw_callback selection_cb, lw_callback post_activate_cb)
|
|
899 {
|
|
900 lw_register_widget (type, name, id, val, pre_activate_cb, selection_cb,
|
|
901 post_activate_cb);
|
|
902 return lw_make_widget (id, parent, pop_up_p);
|
|
903 }
|
|
904
|
|
905
|
|
906 /* destroying the widgets */
|
|
907 static void
|
|
908 destroy_one_instance (widget_instance *instance)
|
|
909 {
|
|
910 /* Remove the destroy callback on the widget; that callback will try to
|
|
911 dereference the instance object (to set its widget slot to 0, since the
|
|
912 widget is dead.) Since the instance is now dead, we don't have to worry
|
|
913 about the fact that its widget is dead too.
|
|
914
|
|
915 This happens in the Phase2Destroy of the widget, so this callback would
|
|
916 not have been run until arbitrarily long after the instance was freed.
|
|
917 */
|
|
918 if (instance->widget)
|
|
919 XtRemoveCallback (instance->widget, XtNdestroyCallback,
|
|
920 mark_widget_destroyed, (XtPointer)instance);
|
|
921
|
|
922 if (instance->widget)
|
|
923 {
|
|
924 /* The else are pretty tricky here, including the empty statement
|
|
925 at the end because it would be very bad to destroy a widget
|
|
926 twice. */
|
|
927 #ifdef NEED_LUCID
|
|
928 if (lw_lucid_widget_p (instance->widget))
|
|
929 xlw_destroy_instance (instance);
|
|
930 else
|
|
931 #endif
|
|
932 #ifdef NEED_MOTIF
|
|
933 if (lw_motif_widget_p (instance->widget))
|
|
934 xm_destroy_instance (instance);
|
|
935 else
|
|
936 #endif
|
|
937 #ifdef NEED_ATHENA
|
|
938 if (lw_xaw_widget_p (instance->widget))
|
|
939 xaw_destroy_instance (instance);
|
|
940 else
|
|
941 #endif
|
|
942 {
|
|
943 /* do not remove the empty statement */
|
|
944 ;
|
|
945 }
|
|
946 }
|
|
947
|
|
948 free_widget_instance (instance);
|
|
949 }
|
|
950
|
|
951 void
|
|
952 lw_destroy_widget (Widget w)
|
|
953 {
|
|
954 widget_instance *instance = get_widget_instance (w, True);
|
|
955
|
|
956 if (instance)
|
|
957 {
|
|
958 widget_info *info = instance->info;
|
|
959 /* instance has already been removed from the list; free it */
|
|
960 destroy_one_instance (instance);
|
|
961 /* if there are no instances left, free the info too */
|
|
962 if (!info->instances)
|
|
963 lw_destroy_all_widgets (info->id);
|
|
964 }
|
|
965 }
|
|
966
|
|
967 void
|
|
968 lw_destroy_all_widgets (LWLIB_ID id)
|
|
969 {
|
|
970 widget_info *info = get_widget_info (id, True);
|
|
971 widget_instance *instance;
|
|
972 widget_instance *next;
|
|
973
|
|
974 if (info)
|
|
975 {
|
|
976 for (instance = info->instances; instance; )
|
|
977 {
|
|
978 next = instance->next;
|
|
979 destroy_one_instance (instance);
|
|
980 instance = next;
|
|
981 }
|
|
982 free_widget_info (info);
|
|
983 }
|
|
984 }
|
|
985
|
|
986 void
|
|
987 lw_destroy_everything ()
|
|
988 {
|
|
989 while (all_widget_info)
|
|
990 lw_destroy_all_widgets (all_widget_info->id);
|
|
991 }
|
|
992
|
|
993 void
|
|
994 lw_destroy_all_pop_ups ()
|
|
995 {
|
|
996 widget_info *info;
|
|
997 widget_info *next;
|
|
998 widget_instance *instance;
|
|
999
|
|
1000 for (info = all_widget_info; info; info = next)
|
|
1001 {
|
|
1002 next = info->next;
|
|
1003 instance = info->instances;
|
|
1004 if (instance && instance->pop_up_p)
|
|
1005 lw_destroy_all_widgets (info->id);
|
|
1006 }
|
|
1007 }
|
|
1008
|
|
1009 Widget
|
|
1010 lw_raise_all_pop_up_widgets (void)
|
|
1011 {
|
|
1012 widget_info *info;
|
|
1013 widget_instance *instance;
|
|
1014 Widget result = NULL;
|
|
1015
|
|
1016 for (info = all_widget_info; info; info = info->next)
|
|
1017 for (instance = info->instances; instance; instance = instance->next)
|
|
1018 if (instance->pop_up_p)
|
|
1019 {
|
|
1020 Widget widget = instance->widget;
|
|
1021 if (widget)
|
|
1022 {
|
|
1023 if (XtIsManaged (widget)
|
|
1024 #ifdef NEED_MOTIF
|
|
1025 /* What a complete load of crap!!!!
|
|
1026 When a dialogShell is on the screen, it is not managed!
|
|
1027 */
|
|
1028 || (lw_motif_widget_p (instance->widget) &&
|
|
1029 XtIsManaged (first_child (widget)))
|
|
1030 #endif
|
|
1031 )
|
|
1032 {
|
|
1033 if (!result)
|
|
1034 result = widget;
|
|
1035 XMapRaised (XtDisplay (widget), XtWindow (widget));
|
|
1036 }
|
|
1037 }
|
|
1038 }
|
|
1039 return result;
|
|
1040 }
|
|
1041
|
|
1042 static void
|
|
1043 lw_pop_all_widgets (LWLIB_ID id, Boolean up)
|
|
1044 {
|
|
1045 widget_info *info = get_widget_info (id, False);
|
|
1046 widget_instance *instance;
|
|
1047
|
|
1048 if (info)
|
|
1049 for (instance = info->instances; instance; instance = instance->next)
|
|
1050 if (instance->pop_up_p && instance->widget)
|
|
1051 {
|
|
1052 #ifdef NEED_LUCID
|
|
1053 if (lw_lucid_widget_p (instance->widget))
|
|
1054 {
|
|
1055 XtRealizeWidget (instance->widget);
|
|
1056 xlw_pop_instance (instance, up);
|
|
1057 }
|
|
1058 #endif
|
|
1059 #ifdef NEED_MOTIF
|
|
1060 if (lw_motif_widget_p (instance->widget))
|
|
1061 {
|
|
1062 XtRealizeWidget (instance->widget);
|
|
1063 xm_pop_instance (instance, up);
|
|
1064 }
|
|
1065 #endif
|
|
1066 #ifdef NEED_ATHENA
|
|
1067 if (lw_xaw_widget_p (instance->widget))
|
|
1068 {
|
|
1069 XtRealizeWidget (XtParent (instance->widget));
|
|
1070 XtRealizeWidget (instance->widget);
|
|
1071 xaw_pop_instance (instance, up);
|
|
1072 }
|
|
1073 #endif
|
|
1074 }
|
|
1075 }
|
|
1076
|
|
1077 void
|
|
1078 lw_pop_up_all_widgets (LWLIB_ID id)
|
|
1079 {
|
|
1080 lw_pop_all_widgets (id, True);
|
|
1081 }
|
|
1082
|
|
1083 void
|
|
1084 lw_pop_down_all_widgets (LWLIB_ID id)
|
|
1085 {
|
|
1086 lw_pop_all_widgets (id, False);
|
|
1087 }
|
|
1088
|
|
1089 void
|
|
1090 lw_popup_menu (Widget widget, XEvent *event)
|
|
1091 {
|
|
1092 #ifdef MENUBARS_LUCID
|
|
1093 if (lw_lucid_widget_p (widget))
|
|
1094 xlw_popup_menu (widget, event);
|
|
1095 #endif
|
|
1096 #ifdef MENUBARS_MOTIF
|
|
1097 if (lw_motif_widget_p (widget))
|
|
1098 xm_popup_menu (widget, event);
|
|
1099 #endif
|
|
1100 #ifdef MENUBARS_ATHENA
|
|
1101 if (lw_xaw_widget_p (widget))
|
|
1102 xaw_popup_menu (widget, event); /* not implemented */
|
|
1103 #endif
|
|
1104 }
|
|
1105
|
|
1106 /* get the values back */
|
|
1107 static Boolean
|
|
1108 get_one_value (widget_instance *instance, widget_value *val)
|
|
1109 {
|
|
1110 Widget widget = name_to_widget (instance, val->name);
|
|
1111
|
|
1112 if (widget)
|
|
1113 {
|
|
1114 #ifdef NEED_LUCID
|
|
1115 if (lw_lucid_widget_p (instance->widget))
|
|
1116 xlw_update_one_value (instance, widget, val);
|
|
1117 #endif
|
|
1118 #ifdef NEED_MOTIF
|
|
1119 if (lw_motif_widget_p (instance->widget))
|
|
1120 xm_update_one_value (instance, widget, val);
|
|
1121 #endif
|
|
1122 #ifdef NEED_ATHENA
|
|
1123 if (lw_xaw_widget_p (instance->widget))
|
|
1124 xaw_update_one_value (instance, widget, val);
|
|
1125 #endif
|
|
1126 return True;
|
|
1127 }
|
|
1128 else
|
|
1129 return False;
|
|
1130 }
|
|
1131
|
|
1132 Boolean
|
|
1133 lw_get_some_values (LWLIB_ID id, widget_value *val_out)
|
|
1134 {
|
|
1135 widget_info *info = get_widget_info (id, False);
|
|
1136 widget_instance *instance;
|
|
1137 widget_value *val;
|
|
1138 Boolean result = False;
|
|
1139
|
|
1140 if (!info)
|
|
1141 return False;
|
|
1142
|
|
1143 instance = info->instances;
|
|
1144 if (!instance)
|
|
1145 return False;
|
|
1146
|
|
1147 for (val = val_out; val; val = val->next)
|
|
1148 if (get_one_value (instance, val))
|
|
1149 result = True;
|
|
1150
|
|
1151 return result;
|
|
1152 }
|
|
1153
|
|
1154 widget_value*
|
|
1155 lw_get_all_values (LWLIB_ID id)
|
|
1156 {
|
|
1157 widget_info *info = get_widget_info (id, False);
|
|
1158 widget_value *val = info->val;
|
|
1159 if (lw_get_some_values (id, val))
|
|
1160 return val;
|
|
1161 else
|
|
1162 return NULL;
|
|
1163 }
|
|
1164
|
|
1165 /* internal function used by the library dependent implementation to get the
|
|
1166 widget_value for a given widget in an instance */
|
|
1167 widget_value*
|
|
1168 lw_get_widget_value_for_widget (widget_instance *instance, Widget w)
|
|
1169 {
|
|
1170 char *name = XtName (w);
|
|
1171 widget_value *cur;
|
|
1172 for (cur = instance->info->val; cur; cur = cur->next)
|
|
1173 if (!strcmp (cur->name, name))
|
|
1174 return cur;
|
|
1175 return NULL;
|
|
1176 }
|
|
1177
|
|
1178
|
|
1179 /* update other instances value when one thing changed */
|
|
1180 /* This function can be used as a an XtCallback for the widgets that get
|
|
1181 modified to update other instances of the widgets. Closure should be the
|
|
1182 widget_instance. */
|
|
1183 void
|
|
1184 lw_internal_update_other_instances (Widget widget, XtPointer closure,
|
|
1185 XtPointer call_data)
|
|
1186 {
|
|
1187 /* To forbid recursive calls */
|
|
1188 static Boolean updating;
|
|
1189
|
|
1190 widget_instance *instance = (widget_instance*)closure;
|
|
1191 char *name = XtName (widget);
|
|
1192 widget_info *info;
|
|
1193 widget_instance *cur;
|
|
1194 widget_value *val;
|
|
1195
|
|
1196 /* never recurse as this could cause infinite recursions. */
|
|
1197 if (updating)
|
|
1198 return;
|
|
1199
|
|
1200 /* protect against the widget being destroyed */
|
|
1201 if (XtWidgetBeingDestroyedP (widget))
|
|
1202 return;
|
|
1203
|
|
1204 /* Return immediately if there are no other instances */
|
|
1205 info = instance->info;
|
|
1206 if (!info->instances->next)
|
|
1207 return;
|
|
1208
|
|
1209 updating = True;
|
|
1210
|
|
1211 for (val = info->val; val && strcmp (val->name, name); val = val->next);
|
|
1212
|
|
1213 if (val && get_one_value (instance, val))
|
|
1214 for (cur = info->instances; cur; cur = cur->next)
|
|
1215 if (cur != instance)
|
|
1216 set_one_value (cur, val, True);
|
|
1217
|
|
1218 updating = False;
|
|
1219 }
|
|
1220
|
|
1221
|
|
1222
|
|
1223 /* get the id */
|
|
1224
|
|
1225 LWLIB_ID
|
|
1226 lw_get_widget_id (Widget w)
|
|
1227 {
|
|
1228 widget_instance *instance = get_widget_instance (w, False);
|
|
1229
|
|
1230 return instance ? instance->info->id : 0;
|
|
1231 }
|
|
1232
|
|
1233
|
|
1234 /* set the keyboard focus */
|
|
1235 void
|
|
1236 lw_set_keyboard_focus (Widget parent, Widget w)
|
|
1237 {
|
78
|
1238 #if defined(NEED_MOTIF) && !defined(LESSTIF_VERSION)
|
|
1239 /* This loses with Lesstif v0.75a */
|
0
|
1240 xm_set_keyboard_focus (parent, w);
|
|
1241 #else
|
|
1242 XtSetKeyboardFocus (parent, w);
|
|
1243 #endif
|
|
1244 }
|
|
1245
|
|
1246
|
|
1247 /* Show busy */
|
|
1248 static void
|
|
1249 show_one_widget_busy (Widget w, Boolean flag)
|
|
1250 {
|
|
1251 Pixel foreground = 0;
|
|
1252 Pixel background = 1;
|
|
1253 Widget widget_to_invert = XtNameToWidget (w, "*sheet");
|
|
1254 if (!widget_to_invert)
|
|
1255 widget_to_invert = w;
|
|
1256
|
|
1257 XtVaGetValues (widget_to_invert,
|
|
1258 XtNforeground, &foreground,
|
|
1259 XtNbackground, &background,
|
|
1260 0);
|
|
1261 XtVaSetValues (widget_to_invert,
|
|
1262 XtNforeground, background,
|
|
1263 XtNbackground, foreground,
|
|
1264 0);
|
|
1265 }
|
|
1266
|
|
1267 void
|
|
1268 lw_show_busy (Widget w, Boolean busy)
|
|
1269 {
|
|
1270 widget_instance *instance = get_widget_instance (w, False);
|
|
1271 widget_info *info;
|
|
1272 widget_instance *next;
|
|
1273
|
|
1274 if (instance)
|
|
1275 {
|
|
1276 info = instance->info;
|
|
1277 if (info->busy != busy)
|
|
1278 {
|
|
1279 for (next = info->instances; next; next = next->next)
|
|
1280 if (next->widget)
|
|
1281 show_one_widget_busy (next->widget, busy);
|
|
1282 info->busy = busy;
|
|
1283 }
|
|
1284 }
|
|
1285 }
|