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
|
175
|
59 /* boolean flag indicating that the menubar is active */
|
|
60 int lw_menu_active = 0;
|
|
61
|
|
62 /* X11 menubar widget */
|
|
63 Widget lw_menubar_widget = NULL;
|
|
64
|
|
65 /* whether the last menu operation was a keyboard accelerator */
|
|
66 int lw_menu_accelerate = False;
|
|
67
|
0
|
68
|
|
69 /* Forward declarations */
|
|
70 static void
|
|
71 instantiate_widget_instance (widget_instance *instance);
|
|
72
|
|
73
|
|
74 /* utility functions for widget_instance and widget_info */
|
|
75 static char *
|
|
76 safe_strdup (CONST char *s)
|
|
77 {
|
|
78 char *result;
|
|
79 if (! s) return 0;
|
|
80 result = (char *) malloc (strlen (s) + 1);
|
|
81 if (! result)
|
|
82 return 0;
|
|
83 strcpy (result, s);
|
|
84 return result;
|
|
85 }
|
|
86
|
|
87 static void
|
|
88 safe_free_str (char *s)
|
|
89 {
|
|
90 if (s) free (s);
|
|
91 }
|
|
92
|
|
93 static widget_value *widget_value_free_list = 0;
|
|
94
|
|
95 widget_value *
|
|
96 malloc_widget_value (void)
|
|
97 {
|
|
98 widget_value *wv;
|
|
99 if (widget_value_free_list)
|
|
100 {
|
|
101 wv = widget_value_free_list;
|
|
102 widget_value_free_list = wv->free_list;
|
|
103 wv->free_list = 0;
|
|
104 }
|
|
105 else
|
|
106 {
|
|
107 wv = (widget_value *) malloc (sizeof (widget_value));
|
|
108 }
|
|
109 if (wv)
|
|
110 {
|
|
111 memset (wv, 0, sizeof (widget_value));
|
|
112 }
|
|
113 return wv;
|
|
114 }
|
|
115
|
|
116 /* this is analogous to free(). It frees only what was allocated
|
|
117 by malloc_widget_value(), and no substructures.
|
|
118 */
|
|
119 void
|
|
120 free_widget_value (widget_value *wv)
|
|
121 {
|
|
122 if (wv->free_list)
|
|
123 abort ();
|
|
124 wv->free_list = widget_value_free_list;
|
|
125 widget_value_free_list = wv;
|
|
126 }
|
|
127
|
|
128 static void free_widget_value_tree (widget_value *wv);
|
|
129
|
|
130 static void
|
|
131 free_widget_value_contents (widget_value *wv)
|
|
132 {
|
|
133 if (wv->name) free (wv->name);
|
|
134 if (wv->value) free (wv->value);
|
|
135 if (wv->key) free (wv->key);
|
|
136
|
|
137 /* #### - all of this 0xDEADBEEF stuff should be unnecessary
|
|
138 in production code... it should be conditionalized. */
|
|
139 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
|
|
140
|
|
141 if (wv->toolkit_data && wv->free_toolkit_data)
|
|
142 {
|
|
143 free (wv->toolkit_data);
|
|
144 wv->toolkit_data = (void *) 0xDEADBEEF;
|
|
145 }
|
|
146 #ifdef NEED_SCROLLBARS
|
|
147 if (wv->scrollbar_data)
|
|
148 {
|
|
149 free (wv->scrollbar_data);
|
|
150 wv->scrollbar_data = NULL;
|
|
151 }
|
|
152 #endif
|
|
153 if (wv->contents && (wv->contents != (widget_value*)1))
|
|
154 {
|
|
155 free_widget_value_tree (wv->contents);
|
|
156 wv->contents = (widget_value *) 0xDEADBEEF;
|
|
157 }
|
|
158 if (wv->next)
|
|
159 {
|
|
160 free_widget_value_tree (wv->next);
|
|
161 wv->next = (widget_value *) 0xDEADBEEF;
|
|
162 }
|
|
163 }
|
|
164
|
|
165 static void
|
|
166 free_widget_value_tree (widget_value *wv)
|
|
167 {
|
|
168 if (!wv)
|
|
169 return;
|
|
170
|
|
171 free_widget_value_contents (wv);
|
|
172 free_widget_value (wv);
|
|
173 }
|
|
174
|
|
175 #ifdef NEED_SCROLLBARS
|
|
176
|
|
177 static void
|
|
178 copy_scrollbar_values (widget_value *val, widget_value *copy)
|
|
179 {
|
|
180 if (!copy->scrollbar_data)
|
|
181 copy->scrollbar_data =
|
|
182 (scrollbar_values *) malloc (sizeof (scrollbar_values));
|
|
183
|
|
184 if (val->scrollbar_data)
|
|
185 *copy->scrollbar_data = *val->scrollbar_data;
|
|
186 else
|
|
187 memset (copy->scrollbar_data, 0, sizeof (scrollbar_values));
|
|
188 }
|
|
189
|
|
190 /*
|
|
191 * Return true if old->scrollbar_data were not equivalent
|
|
192 * to new->scrollbar_data.
|
|
193 */
|
|
194 static Boolean
|
|
195 merge_scrollbar_values (widget_value *old, widget_value *new)
|
|
196 {
|
|
197 Boolean changed = False;
|
|
198
|
|
199 if (new->scrollbar_data && !old->scrollbar_data)
|
|
200 {
|
|
201 copy_scrollbar_values (new, old);
|
|
202 changed = True;
|
|
203 }
|
|
204 else if (!new->scrollbar_data && old->scrollbar_data)
|
|
205 {
|
|
206 free (old->scrollbar_data);
|
|
207 old->scrollbar_data = NULL;
|
|
208 }
|
|
209 else if (new->scrollbar_data && old->scrollbar_data)
|
|
210 {
|
|
211 scrollbar_values *old_sb = old->scrollbar_data;
|
|
212 scrollbar_values *new_sb = new->scrollbar_data;
|
|
213 #define FROB(field) if (old_sb->field != new_sb->field) changed = True
|
|
214 FROB (line_increment);
|
|
215 FROB (page_increment);
|
|
216 FROB (minimum);
|
|
217 FROB (maximum);
|
|
218 FROB (slider_size);
|
|
219 FROB (slider_position);
|
|
220 FROB (scrollbar_width);
|
|
221 FROB (scrollbar_height);
|
|
222 FROB (scrollbar_x);
|
|
223 FROB (scrollbar_y);
|
|
224 #undef FROB
|
|
225 *old_sb = *new_sb;
|
|
226 }
|
|
227
|
|
228 return changed;
|
|
229 }
|
|
230
|
|
231 #endif /* NEED_SCROLLBARS */
|
|
232
|
|
233 /* Make a complete copy of a widget_value tree. Store CHANGE into
|
|
234 the widget_value tree's `change' field. */
|
|
235
|
|
236 static widget_value *
|
|
237 copy_widget_value_tree (widget_value *val, change_type change)
|
|
238 {
|
|
239 widget_value *copy;
|
|
240
|
|
241 if (!val)
|
|
242 return NULL;
|
|
243 if (val == (widget_value *) 1)
|
|
244 return val;
|
|
245
|
|
246 copy = malloc_widget_value ();
|
|
247 if (copy)
|
|
248 {
|
|
249 /* #### - don't seg fault *here* if out of memory. Menus will be
|
|
250 truncated inexplicably. */
|
|
251 copy->type = val->type;
|
|
252 copy->name = safe_strdup (val->name);
|
|
253 copy->value = safe_strdup (val->value);
|
|
254 copy->key = safe_strdup (val->key);
|
175
|
255 copy->accel = val->accel;
|
0
|
256 copy->enabled = val->enabled;
|
|
257 copy->selected = val->selected;
|
|
258 copy->edited = False;
|
|
259 copy->change = change;
|
|
260 copy->contents = copy_widget_value_tree (val->contents, change);
|
|
261 copy->call_data = val->call_data;
|
|
262 copy->next = copy_widget_value_tree (val->next, change);
|
|
263 copy->toolkit_data = NULL;
|
|
264 copy->free_toolkit_data = False;
|
|
265 #ifdef NEED_SCROLLBARS
|
|
266 copy_scrollbar_values (val, copy);
|
|
267 #endif
|
|
268 }
|
|
269 return copy;
|
|
270 }
|
|
271
|
|
272 /* This function is used to implement incremental menu construction. */
|
|
273
|
|
274 widget_value *
|
|
275 replace_widget_value_tree (widget_value *node, widget_value *newtree)
|
|
276 {
|
|
277 widget_value *copy;
|
|
278
|
|
279 if (!node || !newtree)
|
|
280 abort ();
|
|
281
|
|
282 copy = copy_widget_value_tree (newtree, STRUCTURAL_CHANGE);
|
|
283
|
|
284 free_widget_value_contents (node);
|
|
285 *node = *copy;
|
|
286 free_widget_value (copy); /* free the node, but not its contents. */
|
|
287 return node;
|
|
288 }
|
|
289
|
|
290 static widget_info *
|
|
291 allocate_widget_info (CONST char *type, CONST char *name,
|
|
292 LWLIB_ID id, widget_value *val,
|
|
293 lw_callback pre_activate_cb, lw_callback selection_cb,
|
|
294 lw_callback post_activate_cb)
|
|
295 {
|
|
296 widget_info *info = (widget_info *) malloc (sizeof (widget_info));
|
|
297 info->type = safe_strdup (type);
|
|
298 info->name = safe_strdup (name);
|
|
299 info->id = id;
|
|
300 info->val = copy_widget_value_tree (val, STRUCTURAL_CHANGE);
|
|
301 info->busy = False;
|
|
302 info->pre_activate_cb = pre_activate_cb;
|
|
303 info->selection_cb = selection_cb;
|
|
304 info->post_activate_cb = post_activate_cb;
|
|
305 info->instances = NULL;
|
|
306
|
|
307 info->next = all_widget_info;
|
|
308 all_widget_info = info;
|
|
309
|
|
310 return info;
|
|
311 }
|
|
312
|
|
313 static void
|
|
314 free_widget_info (widget_info *info)
|
|
315 {
|
|
316 safe_free_str (info->type);
|
|
317 safe_free_str (info->name);
|
|
318 free_widget_value_tree (info->val);
|
|
319 memset ((void*)info, 0xDEADBEEF, sizeof (widget_info));
|
|
320 free (info);
|
|
321 }
|
|
322
|
|
323 static void
|
|
324 mark_widget_destroyed (Widget widget, XtPointer closure, XtPointer call_data)
|
|
325 {
|
|
326 widget_instance *instance = (widget_instance*)closure;
|
|
327
|
|
328 /* be very conservative */
|
|
329 if (instance->widget == widget)
|
|
330 instance->widget = NULL;
|
|
331 }
|
|
332
|
|
333 static widget_instance *
|
|
334 allocate_widget_instance (widget_info *info, Widget parent, Boolean pop_up_p)
|
|
335 {
|
|
336 widget_instance *instance =
|
|
337 (widget_instance *) malloc (sizeof (widget_instance));
|
|
338 instance->parent = parent;
|
|
339 instance->pop_up_p = pop_up_p;
|
|
340 instance->info = info;
|
|
341 instance->next = info->instances;
|
|
342 info->instances = instance;
|
|
343
|
|
344 instantiate_widget_instance (instance);
|
|
345
|
|
346 XtAddCallback (instance->widget, XtNdestroyCallback,
|
|
347 mark_widget_destroyed, (XtPointer)instance);
|
|
348 return instance;
|
|
349 }
|
|
350
|
|
351 static void
|
|
352 free_widget_instance (widget_instance *instance)
|
|
353 {
|
|
354 memset ((void *) instance, 0xDEADBEEF, sizeof (widget_instance));
|
|
355 free (instance);
|
|
356 }
|
|
357
|
|
358 static widget_info *
|
|
359 get_widget_info (LWLIB_ID id, Boolean remove_p)
|
|
360 {
|
|
361 widget_info *info;
|
|
362 widget_info *prev;
|
|
363 for (prev = NULL, info = all_widget_info;
|
|
364 info;
|
|
365 prev = info, info = info->next)
|
|
366 if (info->id == id)
|
|
367 {
|
|
368 if (remove_p)
|
|
369 {
|
|
370 if (prev)
|
|
371 prev->next = info->next;
|
|
372 else
|
|
373 all_widget_info = info->next;
|
|
374 }
|
|
375 return info;
|
|
376 }
|
|
377 return NULL;
|
|
378 }
|
|
379
|
|
380 /* Internal function used by the library dependent implementation to get the
|
|
381 widget_value for a given widget in an instance */
|
|
382 widget_info *
|
|
383 lw_get_widget_info (LWLIB_ID id)
|
|
384 {
|
|
385 return get_widget_info (id, 0);
|
|
386 }
|
|
387
|
|
388 static int
|
|
389 map_widget_values (widget_value *value, int (*mapfunc) (widget_value *value,
|
|
390 void *closure),
|
|
391 void *closure)
|
|
392 {
|
|
393 int retval = 0;
|
|
394
|
|
395 if (value->contents)
|
|
396 retval = map_widget_values (value->contents, mapfunc, closure);
|
|
397 if (retval)
|
|
398 return retval;
|
|
399
|
|
400 if (value->next)
|
|
401 retval = map_widget_values (value->next, mapfunc, closure);
|
|
402 if (retval)
|
|
403 return retval;
|
|
404
|
|
405 return (mapfunc) (value, closure);
|
|
406 }
|
|
407
|
|
408 int
|
|
409 lw_map_widget_values (LWLIB_ID id, int (*mapfunc) (widget_value *value,
|
|
410 void *closure),
|
|
411 void *closure)
|
|
412 {
|
|
413 widget_info *info = get_widget_info (id, 0);
|
|
414
|
|
415 if (!info)
|
|
416 abort ();
|
|
417
|
|
418 if (info->val)
|
|
419 return map_widget_values (info->val, mapfunc, closure);
|
|
420 return 0;
|
|
421 }
|
|
422
|
|
423 static widget_instance *
|
|
424 get_widget_instance (Widget widget, Boolean remove_p)
|
|
425 {
|
|
426 widget_info *info;
|
|
427 widget_instance *instance;
|
|
428 widget_instance *prev;
|
|
429 for (info = all_widget_info; info; info = info->next)
|
|
430 for (prev = NULL, instance = info->instances;
|
|
431 instance;
|
|
432 prev = instance, instance = instance->next)
|
|
433 if (instance->widget == widget)
|
|
434 {
|
|
435 if (remove_p)
|
|
436 {
|
|
437 if (prev)
|
|
438 prev->next = instance->next;
|
|
439 else
|
|
440 info->instances = instance->next;
|
|
441 }
|
|
442 return instance;
|
|
443 }
|
|
444 return (widget_instance *) 0;
|
|
445 }
|
|
446
|
|
447 static widget_instance*
|
|
448 find_instance (LWLIB_ID id, Widget parent, Boolean pop_up_p)
|
|
449 {
|
|
450 widget_info *info = get_widget_info (id, False);
|
|
451 widget_instance *instance;
|
|
452
|
|
453 if (info)
|
|
454 for (instance = info->instances; instance; instance = instance->next)
|
|
455 if (instance->parent == parent && instance->pop_up_p == pop_up_p)
|
|
456 return instance;
|
|
457
|
|
458 return NULL;
|
|
459 }
|
|
460
|
|
461
|
|
462 /* utility function for widget_value */
|
|
463 static Boolean
|
|
464 safe_strcmp (CONST char *s1, CONST char *s2)
|
|
465 {
|
|
466 if (!!s1 ^ !!s2) return True;
|
|
467 return (s1 && s2) ? strcmp (s1, s2) : s1 ? False : !!s2;
|
|
468 }
|
|
469
|
118
|
470 #ifndef WINDOWSNT
|
2
|
471 static change_type
|
|
472 max (change_type i1, change_type i2)
|
0
|
473 {
|
2
|
474 return (int)i1 > (int)i2 ? i1 : i2;
|
0
|
475 }
|
118
|
476 #endif
|
0
|
477
|
|
478
|
|
479 #if 0
|
|
480 # define EXPLAIN(name, oc, nc, desc, a1, a2) \
|
|
481 printf ("Change: \"%s\"\tmax(%s=%d,%s=%d)\t%s %d %d\n", \
|
|
482 name, \
|
|
483 (oc == NO_CHANGE ? "none" : \
|
|
484 (oc == INVISIBLE_CHANGE ? "invisible" : \
|
|
485 (oc == VISIBLE_CHANGE ? "visible" : \
|
|
486 (oc == STRUCTURAL_CHANGE ? "structural" : "???")))), \
|
|
487 oc, \
|
|
488 (nc == NO_CHANGE ? "none" : \
|
|
489 (nc == INVISIBLE_CHANGE ? "invisible" : \
|
|
490 (nc == VISIBLE_CHANGE ? "visible" : \
|
|
491 (nc == STRUCTURAL_CHANGE ? "structural" : "???")))), \
|
|
492 nc, desc, a1, a2)
|
|
493 #else
|
|
494 # define EXPLAIN(name, oc, nc, desc, a1, a2)
|
|
495 #endif
|
|
496
|
|
497
|
|
498 static widget_value *
|
|
499 merge_widget_value (widget_value *val1, widget_value *val2, int level)
|
|
500 {
|
|
501 change_type change;
|
|
502 widget_value *merged_next;
|
|
503 widget_value *merged_contents;
|
|
504
|
|
505 if (!val1)
|
|
506 {
|
|
507 if (val2)
|
|
508 return copy_widget_value_tree (val2, STRUCTURAL_CHANGE);
|
|
509 else
|
|
510 return NULL;
|
|
511 }
|
|
512 if (!val2)
|
|
513 {
|
|
514 free_widget_value_tree (val1);
|
|
515 return NULL;
|
|
516 }
|
|
517
|
|
518 change = NO_CHANGE;
|
|
519
|
|
520 if (val1->type != val2->type)
|
|
521 {
|
|
522 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "type change",
|
|
523 val1->type, val2->type);
|
|
524 change = max (change, STRUCTURAL_CHANGE);
|
|
525 val1->type = val2->type;
|
|
526 }
|
|
527 if (safe_strcmp (val1->name, val2->name))
|
|
528 {
|
|
529 EXPLAIN (val1->name, change, STRUCTURAL_CHANGE, "name change",
|
|
530 val1->name, val2->name);
|
|
531 change = max (change, STRUCTURAL_CHANGE);
|
|
532 safe_free_str (val1->name);
|
|
533 val1->name = safe_strdup (val2->name);
|
|
534 }
|
|
535 if (safe_strcmp (val1->value, val2->value))
|
|
536 {
|
|
537 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "value change",
|
|
538 val1->value, val2->value);
|
|
539 change = max (change, VISIBLE_CHANGE);
|
|
540 safe_free_str (val1->value);
|
|
541 val1->value = safe_strdup (val2->value);
|
|
542 }
|
|
543 if (safe_strcmp (val1->key, val2->key))
|
|
544 {
|
|
545 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "key change",
|
|
546 val1->key, val2->key);
|
|
547 change = max (change, VISIBLE_CHANGE);
|
|
548 safe_free_str (val1->key);
|
|
549 val1->key = safe_strdup (val2->key);
|
|
550 }
|
175
|
551 if (val1->accel != val2->accel)
|
|
552 {
|
|
553 EXPLAIN (val1->name, change, VISIBLE_CHANGE, "accelerator change",
|
|
554 val1->accel, val2->accel);
|
|
555 change = max (change, VISIBLE_CHANGE);
|
|
556 val1->accel = val2->accel;
|
|
557 }
|
0
|
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 {
|
78
|
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");
|
165
|
1273 Arg al [2];
|
|
1274
|
0
|
1275 if (!widget_to_invert)
|
|
1276 widget_to_invert = w;
|
165
|
1277
|
|
1278 XtSetArg (al [0], XtNforeground, &foreground);
|
|
1279 XtSetArg (al [1], XtNbackground, &background);
|
|
1280 XtGetValues (widget_to_invert, al, 2);
|
|
1281
|
|
1282 XtSetArg (al [0], XtNforeground, background);
|
|
1283 XtSetArg (al [1], XtNbackground, foreground);
|
|
1284 XtSetValues (widget_to_invert, al, 2);
|
0
|
1285 }
|
|
1286
|
|
1287 void
|
|
1288 lw_show_busy (Widget w, Boolean busy)
|
|
1289 {
|
|
1290 widget_instance *instance = get_widget_instance (w, False);
|
|
1291 widget_info *info;
|
|
1292 widget_instance *next;
|
|
1293
|
|
1294 if (instance)
|
|
1295 {
|
|
1296 info = instance->info;
|
|
1297 if (info->busy != busy)
|
|
1298 {
|
|
1299 for (next = info->instances; next; next = next->next)
|
|
1300 if (next->widget)
|
|
1301 show_one_widget_busy (next->widget, busy);
|
|
1302 info->busy = busy;
|
|
1303 }
|
|
1304 }
|
|
1305 }
|