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