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