annotate lwlib/lwlib.c @ 453:270b05afd845

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