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