annotate lwlib/lwlib.c @ 151:59463afc5666 r20-3b2

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