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