annotate src/gui-x.c @ 407:ed6218a7d4d3

Added tag r21-2-33 for changeset b8cc9ab3f761
author cvs
date Mon, 13 Aug 2007 11:17:10 +0200
parents b8cc9ab3f761
children 501cfd01ee6d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
1 /* General GUI code -- X-specific. (menubars, scrollbars, toolbars, dialogs)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
3 Copyright (C) 1995, 1996 Ben Wing.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
4 Copyright (C) 1995 Sun Microsystems, Inc.
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 231
diff changeset
5 Copyright (C) 1998 Free Software Foundation, Inc.
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
6
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
7 This file is part of XEmacs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
8
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
9 XEmacs is free software; you can redistribute it and/or modify it
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
10 under the terms of the GNU General Public License as published by the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
11 Free Software Foundation; either version 2, or (at your option) any
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
12 later version.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
13
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
17 for more details.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
18
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
19 You should have received a copy of the GNU General Public License
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
20 along with XEmacs; see the file COPYING. If not, write to
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
21 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
22 Boston, MA 02111-1307, USA. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
23
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
24 /* Synched up with: Not in FSF. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
25
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
26 #include <config.h>
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
27 #include "lisp.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
28
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
29 #include "console-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
30 #ifdef LWLIB_USES_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
31 #include <Xm/Xm.h> /* for XmVersion */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 #include "gui-x.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
34 #include "buffer.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
35 #include "device.h"
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
36 #include "events.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37 #include "frame.h"
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 217
diff changeset
38 #include "gui.h"
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
39 #include "glyphs.h"
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
40 #include "redisplay.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
41 #include "opaque.h"
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
42
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
43 Lisp_Object Qmenu_no_selection_hook;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
44
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
45 /* we need a unique id for each popup menu, dialog box, and scrollbar */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
46 static unsigned int lwlib_id_tick;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
47
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
48 LWLIB_ID
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
49 new_lwlib_id (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
50 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
51 return ++lwlib_id_tick;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
52 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
53
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
54 widget_value *
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
55 xmalloc_widget_value (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
56 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
57 widget_value *tmp = malloc_widget_value ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
58 if (!tmp) memory_full ();
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
59 return tmp;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
60 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
61
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
62
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
63 static int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
64 mark_widget_value_mapper (widget_value *val, void *closure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
65 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
66 Lisp_Object markee;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
67 if (val->call_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
68 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
69 VOID_TO_LISP (markee, val->call_data);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
70 mark_object (markee);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
71 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
72
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
73 if (val->accel)
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
74 {
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
75 VOID_TO_LISP (markee, val->accel);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
76 mark_object (markee);
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
77 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
78 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
79 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
80
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
81 static Lisp_Object
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
82 mark_popup_data (Lisp_Object obj)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
83 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
84 struct popup_data *data = (struct popup_data *) XPOPUP_DATA (obj);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
85
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
86 /* Now mark the callbacks and such that are hidden in the lwlib
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
87 call-data */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
88
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
89 if (data->id)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
90 lw_map_widget_values (data->id, mark_widget_value_mapper, 0);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 20
diff changeset
91
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 20
diff changeset
92 return data->last_menubar_buffer;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
93 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
94
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
95 DEFINE_LRECORD_IMPLEMENTATION ("popup-data", popup_data,
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
96 mark_popup_data, internal_object_printer,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
97 0, 0, 0, 0, struct popup_data);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
98
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
99 /* This is like FRAME_MENUBAR_DATA (f), but contains an alist of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
100 (id . popup-data) for GCPRO'ing the callbacks of the popup menus
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
101 and dialog boxes. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
102 static Lisp_Object Vpopup_callbacks;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
103
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
104 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
105 gcpro_popup_callbacks (LWLIB_ID id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
106 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
107 struct popup_data *pdata;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
108 Lisp_Object lid = make_int (id);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
109 Lisp_Object lpdata;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
110
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
111 assert (NILP (assq_no_quit (lid, Vpopup_callbacks)));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
112 pdata = alloc_lcrecord_type (struct popup_data, &lrecord_popup_data);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
113 pdata->id = id;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
114 pdata->last_menubar_buffer = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
115 pdata->menubar_contents_up_to_date = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
116 XSETPOPUP_DATA (lpdata, pdata);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
117 Vpopup_callbacks = Fcons (Fcons (lid, lpdata), Vpopup_callbacks);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
118 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
119
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
120 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
121 ungcpro_popup_callbacks (LWLIB_ID id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
122 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
123 Lisp_Object lid = make_int (id);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
124 Lisp_Object this = assq_no_quit (lid, Vpopup_callbacks);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
125 assert (!NILP (this));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
126 Vpopup_callbacks = delq_no_quit (this, Vpopup_callbacks);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
127 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
128
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
129 int
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
130 popup_handled_p (LWLIB_ID id)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
131 {
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 20
diff changeset
132 return NILP (assq_no_quit (make_int (id), Vpopup_callbacks));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
133 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
134
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
135 /* menu_item_descriptor_to_widget_value() et al. mallocs a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
136 widget_value, but then may signal lisp errors. If an error does
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
137 not occur, the opaque ptr we have here has had its pointer set to 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
138 to tell us not to do anything. Otherwise we free the widget value.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
139 (This has nothing to do with GC, it's just about not dropping
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
140 pointers to malloc'd data when errors happen.) */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
141
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
142 Lisp_Object
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
143 widget_value_unwind (Lisp_Object closure)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
144 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
145 widget_value *wv = (widget_value *) get_opaque_ptr (closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
146 free_opaque_ptr (closure);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
147 if (wv)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
148 free_widget_value_tree (wv);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
149 return Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
150 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
151
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
152 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
153 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
154 print_widget_value (widget_value *wv, int depth)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
155 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
156 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
157 char d [200];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
158 int i;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
159 for (i = 0; i < depth; i++) d[i] = ' ';
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
160 d[depth]=0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
161 /* #### - print type field */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
162 printf ("%sname: %s\n", d, (wv->name ? wv->name : "(null)"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
163 if (wv->value) printf ("%svalue: %s\n", d, wv->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
164 if (wv->key) printf ("%skey: %s\n", d, wv->key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
165 printf ("%senabled: %d\n", d, wv->enabled);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
166 if (wv->contents)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
167 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
168 printf ("\n%scontents: \n", d);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
169 print_widget_value (wv->contents, depth + 5);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
170 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
171 if (wv->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
172 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
173 printf ("\n");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
174 print_widget_value (wv->next, depth);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
175 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
176 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
177 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
178
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
179 /* This recursively calls free_widget_value() on the tree of widgets.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
180 It must free all data that was malloc'ed for these widget_values.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
181
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
182 It used to be that emacs only allocated new storage for the `key' slot.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
183 All other slots are pointers into the data of Lisp_Strings, and must be
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
184 left alone. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
185 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
186 free_popup_widget_value_tree (widget_value *wv)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
187 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
188 if (! wv) return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
189 if (wv->key) xfree (wv->key);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
190 if (wv->value) xfree (wv->value);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
191 if (wv->name) xfree (wv->name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
192
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
193 wv->name = wv->value = wv->key = (char *) 0xDEADBEEF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
194
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
195 if (wv->contents && (wv->contents != (widget_value*)1))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
196 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
197 free_popup_widget_value_tree (wv->contents);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
198 wv->contents = (widget_value *) 0xDEADBEEF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
199 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
200 if (wv->next)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
201 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
202 free_popup_widget_value_tree (wv->next);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
203 wv->next = (widget_value *) 0xDEADBEEF;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
204 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
205 free_widget_value (wv);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
206 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
207
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
208 /* The following is actually called from somewhere within XtDispatchEvent(),
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
209 called from XtAppProcessEvent() in event-Xt.c */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
210
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
211 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
212 popup_selection_callback (Widget widget, LWLIB_ID ignored_id,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
213 XtPointer client_data)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
214 {
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
215 Lisp_Object data, image_instance, callback, callback_ex;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
216 Lisp_Object frame, event;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
217 int update_subwindows_p = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
218 struct device *d = get_device_from_display (XtDisplay (widget));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
219 struct frame *f = x_any_widget_or_parent_to_frame (d, widget);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
220
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
221 /* set in lwlib to the time stamp associated with the most recent menu
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
222 operation */
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
223 extern Time x_focus_timestamp_really_sucks_fix_me_better;
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
224
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
225 if (!f)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
226 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
227 if (((EMACS_INT) client_data) == 0)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
228 return;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
229 VOID_TO_LISP (data, client_data);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
230 XSETFRAME (frame, f);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
231
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
232 image_instance = XCAR (data);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
233 callback = XCAR (XCDR (data));
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
234 callback_ex = XCDR (XCDR (data));
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
235
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
236 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
237 /* #### What the hell? I can't understand why this call is here,
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
238 and doing it is really courting disaster in the new event
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
239 model, since popup_selection_callback is called from
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
240 within next_event_internal() and Faccept_process_output()
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
241 itself calls next_event_internal(). --Ben */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
242
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
243 /* Flush the X and process input */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
244 Faccept_process_output (Qnil, Qnil, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
245 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
246
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
247 if (((EMACS_INT) client_data) == -1)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
248 {
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
249 event = Fmake_event (Qnil, Qnil);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
250
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
251 XEVENT (event)->event_type = misc_user_event;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
252 XEVENT (event)->channel = frame;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
253 XEVENT (event)->event.eval.function = Qrun_hooks;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
254 XEVENT (event)->event.eval.object = Qmenu_no_selection_hook;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
255 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
256 else
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
257 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
258 update_subwindows_p = 1;
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
259
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
260 if (!NILP (callback_ex) && !UNBOUNDP (callback_ex))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
261 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
262 event = Fmake_event (Qnil, Qnil);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
263
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
264 XEVENT (event)->event_type = misc_user_event;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
265 XEVENT (event)->channel = frame;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
266 XEVENT (event)->event.eval.function = Qeval;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
267 XEVENT (event)->event.eval.object =
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
268 list4 (Qfuncall, callback_ex, image_instance, event);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
269 }
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
270 else if (NILP (callback) || UNBOUNDP (callback))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
271 event = Qnil;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
272 else
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
273 {
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
274 Lisp_Object fn, arg;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
275
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
276 event = Fmake_event (Qnil, Qnil);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
277
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
278 get_gui_callback (callback, &fn, &arg);
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
279 XEVENT (event)->event_type = misc_user_event;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
280 XEVENT (event)->channel = frame;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
281 XEVENT (event)->event.eval.function = fn;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
282 XEVENT (event)->event.eval.object = arg;
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
283 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
284 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
285
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
286 /* This is the timestamp used for asserting focus so we need to get an
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
287 up-to-date value event if no events has been dispatched to emacs
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
288 */
179
9ad43877534d Import from CVS: tag r20-3b16
cvs
parents: 177
diff changeset
289 #if defined(HAVE_MENUBARS)
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
290 DEVICE_X_MOUSE_TIMESTAMP (d) = x_focus_timestamp_really_sucks_fix_me_better;
177
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
291 #else
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
292 DEVICE_X_MOUSE_TIMESTAMP (d) = DEVICE_X_GLOBAL_MOUSE_TIMESTAMP (d);
6075d714658b Import from CVS: tag r20-3b15
cvs
parents: 175
diff changeset
293 #endif
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
294 if (!NILP (event))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
295 enqueue_Xt_dispatch_event (event);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
296 /* The result of this evaluation could cause other instances to change so
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
297 enqueue an update callback to check this. We also have to make sure that
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
298 the function does not appear in the command history.
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
299 #### I'm sure someone can tell me how to optimize this. */
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
300 if (update_subwindows_p && !NILP (event))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
301 signal_special_Xt_user_event (frame, Qeval,
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
302 list3 (Qlet,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
303 list2 (Qthis_command,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
304 Qlast_command),
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
305 list2 (Qupdate_widget_instances,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
306 frame)));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
307 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
308
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
309 #if 1
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
310 /* Eval the activep slot of the menu item */
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
311 # define wv_set_evalable_slot(slot,form) do { \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
312 Lisp_Object wses_form = (form); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
313 (slot) = (NILP (wses_form) ? 0 : \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
314 EQ (wses_form, Qt) ? 1 : \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
315 !NILP (Feval (wses_form))); \
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
316 } while (0)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
317 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
318 /* Treat the activep slot of the menu item as a boolean */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
319 # define wv_set_evalable_slot(slot,form) \
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
320 ((void) (slot = (!NILP (form))))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
321 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
322
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
323 char *
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
324 menu_separator_style (const char *s)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
325 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
326 const char *p;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
327 char first;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
328
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
329 if (!s || s[0] == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
330 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
331 first = s[0];
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
332 if (first != '-' && first != '=')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
333 return NULL;
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
334 for (p = s; *p == first; p++)
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 373
diff changeset
335 DO_NOTHING;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
336
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
337 /* #### - cannot currently specify a separator tag "--!tag" and a
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
338 separator style "--:style" at the same time. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
339 /* #### - Also, the motif menubar code doesn't deal with the
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
340 double etched style yet, so it's not good to get into the habit of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
341 using "===" in menubars to get double-etched lines */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
342 if (*p == '!' || *p == '\0')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
343 return ((first == '-')
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
344 ? NULL /* single etched is the default */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
345 : xstrdup ("shadowDoubleEtchedIn"));
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
346 else if (*p == ':')
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
347 return xstrdup (p+1);
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 20
diff changeset
348
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
349 return NULL;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
350 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
351
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
352 char *
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
353 strdup_and_add_accel (char *name)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
354 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
355 int i;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
356 int found_accel = 0;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
357
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
358 for (i=0; name[i]; ++i)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
359 if (name[i] == '%' && name[i+1] == '_')
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
360 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
361 found_accel = 1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
362 break;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
363 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
364
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
365 if (found_accel)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
366 return xstrdup (name);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
367 else
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
368 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
369 char *chars = (char *) alloca (strlen (name) + 3);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
370 chars[0] = '%';
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
371 chars[1] = '_';
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
372 memcpy (chars+2, name, strlen (name) + 1);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
373 return xstrdup (chars);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
374 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
375 }
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 173
diff changeset
376
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
377 /* This does the dirty work. gc_currently_forbidden is 1 when this is called.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
378 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
379 int
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
380 button_item_to_widget_value (Lisp_Object gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
381 Lisp_Object gui_item, widget_value *wv,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
382 int allow_text_field_p, int no_keys_p,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
383 int menu_entry_p)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
384 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
385 /* !!#### This function has not been Mule-ized */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
386 /* This function cannot GC because gc_currently_forbidden is set when
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
387 it's called */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
388 Lisp_Gui_Item* pgui = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
389
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
390 /* degenerate case */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
391 if (STRINGP (gui_item))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
392 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
393 wv->type = TEXT_TYPE;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
394 wv->name = (char *) XSTRING_DATA (gui_item);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
395 wv->name = strdup_and_add_accel (wv->name);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
396 return 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
397 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
398 else if (!GUI_ITEMP (gui_item))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
399 signal_simple_error("need a string or a gui_item here", gui_item);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
400
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
401 pgui = XGUI_ITEM (gui_item);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
402
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
403 if (!NILP (pgui->filter))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
404 signal_simple_error(":filter keyword not permitted on leaf nodes", gui_item);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
405
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
406 #ifdef HAVE_MENUBARS
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
407 if (menu_entry_p && !gui_item_included_p (gui_item, Vmenubar_configuration))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
408 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
409 /* the include specification says to ignore this item. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
410 return 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
411 }
16
0293115a14e9 Import from CVS: tag r19-15b91
cvs
parents: 14
diff changeset
412 #endif /* HAVE_MENUBARS */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
413
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
414 if (!STRINGP (pgui->name))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
415 pgui->name = Feval (pgui->name);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
416
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
417 CHECK_STRING (pgui->name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
418 wv->name = (char *) XSTRING_DATA (pgui->name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
419 wv->name = xstrdup (wv->name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
420 wv->accel = LISP_TO_VOID (gui_item_accelerator (gui_item));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
421
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
422 if (!NILP (pgui->suffix))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
423 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
424 const char *const_bogosity;
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 231
diff changeset
425 Lisp_Object suffix2;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
426
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 231
diff changeset
427 /* Shortcut to avoid evaluating suffix each time */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
428 if (STRINGP (pgui->suffix))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
429 suffix2 = pgui->suffix;
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 231
diff changeset
430 else
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 231
diff changeset
431 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
432 suffix2 = Feval (pgui->suffix);
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 231
diff changeset
433 CHECK_STRING (suffix2);
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 231
diff changeset
434 }
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 231
diff changeset
435
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
436 TO_EXTERNAL_FORMAT (LISP_STRING, suffix2,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
437 C_STRING_ALLOCA, const_bogosity,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
438 Qfile_name);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
439 wv->value = (char *) const_bogosity;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
440 wv->value = xstrdup (wv->value);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
441 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
442
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
443 wv_set_evalable_slot (wv->enabled, pgui->active);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
444 wv_set_evalable_slot (wv->selected, pgui->selected);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
445
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
446 if (!NILP (pgui->callback) || !NILP (pgui->callback_ex))
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
447 wv->call_data = LISP_TO_VOID (cons3 (gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
448 pgui->callback,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
449 pgui->callback_ex));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
450
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
451 if (no_keys_p
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
452 #ifdef HAVE_MENUBARS
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
453 || (menu_entry_p && !menubar_show_keybindings)
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
454 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
455 )
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
456 wv->key = 0;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
457 else if (!NILP (pgui->keys)) /* Use this string to generate key bindings */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
458 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
459 CHECK_STRING (pgui->keys);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
460 pgui->keys = Fsubstitute_command_keys (pgui->keys);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
461 if (XSTRING_LENGTH (pgui->keys) > 0)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
462 wv->key = xstrdup ((char *) XSTRING_DATA (pgui->keys));
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
463 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
464 wv->key = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
465 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
466 else if (SYMBOLP (pgui->callback)) /* Show the binding of this command. */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
467 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
468 char buf[1024]; /* #### */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
469 /* #### Warning, dependency here on current_buffer and point */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
470 where_is_to_char (pgui->callback, buf);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
471 if (buf [0])
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
472 wv->key = xstrdup (buf);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
473 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
474 wv->key = 0;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
475 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
476
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
477 CHECK_SYMBOL (pgui->style);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
478 if (NILP (pgui->style))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
479 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
480 /* If the callback is nil, treat this item like unselectable text.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
481 This way, dashes will show up as a separator. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
482 if (!wv->enabled)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
483 wv->type = BUTTON_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
484 if (separator_string_p (wv->name))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
485 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
486 wv->type = SEPARATOR_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
487 wv->value = menu_separator_style (wv->name);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
488 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
489 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
490 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
491 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
492 /* #### - this is generally desirable for menubars, but it breaks
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
493 a package that uses dialog boxes and next_command_event magic
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
494 to use the callback slot in dialog buttons for data instead of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
495 a real callback.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
496
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
497 Code is data, right? The beauty of LISP abuse. --Stig */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
498 if (NILP (callback))
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
499 wv->type = TEXT_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
500 else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
501 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
502 wv->type = BUTTON_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
503 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
504 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
505 else if (EQ (pgui->style, Qbutton))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
506 wv->type = BUTTON_TYPE;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
507 else if (EQ (pgui->style, Qtoggle))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
508 wv->type = TOGGLE_TYPE;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
509 else if (EQ (pgui->style, Qradio))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
510 wv->type = RADIO_TYPE;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
511 else if (EQ (pgui->style, Qtext))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
512 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
513 wv->type = TEXT_TYPE;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
514 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
515 wv->value = wv->name;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
516 wv->name = "value";
173
8eaf7971accc Import from CVS: tag r20-3b13
cvs
parents: 20
diff changeset
517 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
518 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
519 else
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
520 signal_simple_error_2 ("Unknown style", pgui->style, gui_item);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
521
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
522 if (!allow_text_field_p && (wv->type == TEXT_TYPE))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
523 signal_simple_error ("Text field not allowed in this context", gui_item);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
524
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
525 if (!NILP (pgui->selected) && EQ (pgui->style, Qtext))
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
526 signal_simple_error (
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
527 ":selected only makes sense with :style toggle, radio or button",
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
528 gui_item);
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
529 return 1;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
530 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
531
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
532 /* parse tree's of gui items into widget_value hierarchies */
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
533 static void gui_item_children_to_widget_values (Lisp_Object gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
534 Lisp_Object items,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
535 widget_value* parent);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
536
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
537 static widget_value *
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
538 gui_items_to_widget_values_1 (Lisp_Object gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
539 Lisp_Object items, widget_value* parent,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
540 widget_value* prev)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
541 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
542 widget_value* wv = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
543
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
544 assert ((parent || prev) && !(parent && prev));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
545 /* now walk the tree creating widget_values as appropriate */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
546 if (!CONSP (items))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
547 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
548 wv = xmalloc_widget_value();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
549 if (parent)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
550 parent->contents = wv;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
551 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
552 prev->next = wv;
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
553 if (!button_item_to_widget_value (gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
554 items, wv, 0, 1, 0))
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
555 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
556 free_widget_value_tree (wv);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
557 if (parent)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
558 parent->contents = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
559 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
560 prev->next = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
561 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
562 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
563 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
564 wv->value = xstrdup (wv->name); /* what a mess... */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
565 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
566 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
567 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
568 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
569 /* first one is the parent */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
570 if (CONSP (XCAR (items)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
571 signal_simple_error ("parent item must not be a list", XCAR (items));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
572
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
573 if (parent)
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
574 wv = gui_items_to_widget_values_1 (gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
575 XCAR (items), parent, 0);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
576 else
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
577 wv = gui_items_to_widget_values_1 (gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
578 XCAR (items), 0, prev);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
579 /* the rest are the children */
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
580 gui_item_children_to_widget_values (gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
581 XCDR (items), wv);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
582 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
583 return wv;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
584 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
585
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
586 static void
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
587 gui_item_children_to_widget_values (Lisp_Object gui_object_instance,
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
588 Lisp_Object items, widget_value* parent)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
589 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
590 widget_value* wv = 0, *prev = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
591 Lisp_Object rest;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
592 CHECK_CONS (items);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
593
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
594 /* first one is master */
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
595 prev = gui_items_to_widget_values_1 (gui_object_instance, XCAR (items),
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
596 parent, 0);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
597 /* the rest are the children */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
598 LIST_LOOP (rest, XCDR (items))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
599 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
600 Lisp_Object tab = XCAR (rest);
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
601 wv = gui_items_to_widget_values_1 (gui_object_instance, tab, 0, prev);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
602 prev = wv;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
603 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
604 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
605
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
606 widget_value *
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
607 gui_items_to_widget_values (Lisp_Object gui_object_instance, Lisp_Object items)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
608 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
609 /* !!#### This function has not been Mule-ized */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
610 /* This function can GC */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
611 widget_value *control = 0, *tmp = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
612 int count = specpdl_depth ();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
613 Lisp_Object wv_closure;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
614
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
615 if (NILP (items))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
616 signal_simple_error ("must have some items", items);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
617
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
618 /* Inhibit GC during this conversion. The reasons for this are
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
619 the same as in menu_item_descriptor_to_widget_value(); see
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
620 the large comment above that function. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
621 record_unwind_protect (restore_gc_inhibit,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
622 make_int (gc_currently_forbidden));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
623 gc_currently_forbidden = 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
624
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
625 /* Also make sure that we free the partially-created widget_value
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
626 tree on Lisp error. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
627 control = xmalloc_widget_value();
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
628 wv_closure = make_opaque_ptr (control);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
629 record_unwind_protect (widget_value_unwind, wv_closure);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
630
406
b8cc9ab3f761 Import from CVS: tag r21-2-33
cvs
parents: 404
diff changeset
631 gui_items_to_widget_values_1 (gui_object_instance, items, control, 0);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
632
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
633 /* mess about getting the data we really want */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
634 tmp = control;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
635 control = control->contents;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
636 tmp->next = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
637 tmp->contents = 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
638 free_widget_value_tree (tmp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
639
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
640 /* No more need to free the half-filled-in structures. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
641 set_opaque_ptr (wv_closure, 0);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
642 unbind_to (count, Qnil);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
643
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
644 return control;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
645 }
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
646
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
647 /* This is a kludge to make sure emacs can only link against a version of
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
648 lwlib that was compiled in the right way. Emacs references symbols which
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
649 correspond to the way it thinks lwlib was compiled, and if lwlib wasn't
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
650 compiled in that way, then somewhat meaningful link errors will result.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
651 The alternatives to this range from obscure link errors, to obscure
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
652 runtime errors that look a lot like bugs.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
653 */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
654
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
655 static void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
656 sanity_check_lwlib (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
657 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
658 #define MACROLET(v) { extern int v; v = 1; }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
659
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
660 #if (XlibSpecificationRelease == 4)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
661 MACROLET (lwlib_uses_x11r4);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
662 #elif (XlibSpecificationRelease == 5)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
663 MACROLET (lwlib_uses_x11r5);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
664 #elif (XlibSpecificationRelease == 6)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
665 MACROLET (lwlib_uses_x11r6);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
666 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 MACROLET (lwlib_uses_unknown_x11);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 #ifdef LWLIB_USES_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
670 MACROLET (lwlib_uses_motif);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
671 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 MACROLET (lwlib_does_not_use_motif);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 #if (XmVersion >= 1002)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
675 MACROLET (lwlib_uses_motif_1_2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 #else
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 MACROLET (lwlib_does_not_use_motif_1_2);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 #ifdef LWLIB_MENUBARS_LUCID
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 MACROLET (lwlib_menubars_lucid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
681 #elif defined (HAVE_MENUBARS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
682 MACROLET (lwlib_menubars_motif);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
683 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684 #ifdef LWLIB_SCROLLBARS_LUCID
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 MACROLET (lwlib_scrollbars_lucid);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 #elif defined (LWLIB_SCROLLBARS_MOTIF)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
687 MACROLET (lwlib_scrollbars_motif);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
688 #elif defined (HAVE_SCROLLBARS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
689 MACROLET (lwlib_scrollbars_athena);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
690 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 #ifdef LWLIB_DIALOGS_MOTIF
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692 MACROLET (lwlib_dialogs_motif);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 #elif defined (HAVE_DIALOGS)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 MACROLET (lwlib_dialogs_athena);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 #endif
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
696 #ifdef LWLIB_WIDGETS_MOTIF
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
697 MACROLET (lwlib_widgets_motif);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
698 #elif defined (HAVE_WIDGETS)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
699 MACROLET (lwlib_widgets_athena);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
700 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
701
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
702 #undef MACROLET
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
703 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
704
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
705 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
706 syms_of_gui_x (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
707 {
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
708 INIT_LRECORD_IMPLEMENTATION (popup_data);
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
709
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
710 defsymbol (&Qmenu_no_selection_hook, "menu-no-selection-hook");
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
711 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
712
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
713 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
714 reinit_vars_of_gui_x (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
715 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
716 lwlib_id_tick = (1<<16); /* start big, to not conflict with Energize */
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
717 #ifdef HAVE_POPUPS
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
718 popup_up_p = 0;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
719 #endif
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
720
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
721 /* this makes only safe calls as in emacs.c */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
722 sanity_check_lwlib ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
723 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
724
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
725 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
726 vars_of_gui_x (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
727 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 380
diff changeset
728 reinit_vars_of_gui_x ();
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
729
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
730 Vpopup_callbacks = Qnil;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
731 staticpro (&Vpopup_callbacks);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
732
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
733 #if 0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
734 /* This DEFVAR_LISP is just for the benefit of make-docfile. */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
735 /* #### misnamed */
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
736 DEFVAR_LISP ("menu-no-selection-hook", &Vmenu_no_selection_hook /*
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
737 Function or functions to call when a menu or dialog box is dismissed
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
738 without a selection having been made.
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
739 */ );
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
740 #endif
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
741 Fset (Qmenu_no_selection_hook, Qnil);
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
742 }