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