annotate lwlib/lwlib.c @ 2789:34dfe93cc396

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