annotate src/gui.c @ 404:2f8bb876ab1d r21-2-32

Import from CVS: tag r21-2-32
author cvs
date Mon, 13 Aug 2007 11:16:07 +0200
parents a86b2b5e0111
children b8cc9ab3f761
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 /* Generic GUI code. (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: 251
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>
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
27 #include "lisp.h"
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
28 #include "gui.h"
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
29 #include "elhash.h"
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
30 #include "buffer.h"
380
8626e4521993 Import from CVS: tag r21-2-5
cvs
parents: 377
diff changeset
31 #include "bytecode.h"
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
32
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
33 Lisp_Object Q_active, Q_suffix, Q_keys, Q_style, Q_selected;
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 371
diff changeset
34 Lisp_Object Q_filter, Q_config, Q_included, Q_key_sequence;
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
35 Lisp_Object Q_accelerator, Q_label, Q_callback;
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
36 Lisp_Object Qtoggle, Qradio;
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
37
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
38 static Lisp_Object parse_gui_item_tree_list (Lisp_Object list);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
39
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
40 #ifdef HAVE_POPUPS
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
41
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
42 /* count of menus/dboxes currently up */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
43 int popup_up_p;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
44
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
45 DEFUN ("popup-up-p", Fpopup_up_p, 0, 0, 0, /*
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
46 Return t if a popup menu or dialog box is up, nil otherwise.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
47 See `popup-menu' and `popup-dialog-box'.
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
48 */
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
49 ())
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
50 {
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
51 return popup_up_p ? Qt : Qnil;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
52 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
53 #endif /* HAVE_POPUPS */
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
54
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
55 int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
56 separator_string_p (const char *s)
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
57 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
58 const char *p;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
59 char first;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
60
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
61 if (!s || s[0] == '\0')
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
62 return 0;
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
63 first = s[0];
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
64 if (first != '-' && first != '=')
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
65 return 0;
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
66 for (p = s; *p == first; p++)
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
67 ;
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
68
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
69 return (*p == '!' || *p == ':' || *p == '\0');
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
70 }
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
71
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
72 /* Massage DATA to find the correct function and argument. Used by
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
73 popup_selection_callback() and the msw code. */
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
74 void
288
e11d67e05968 Import from CVS: tag r21-0b42
cvs
parents: 286
diff changeset
75 get_gui_callback (Lisp_Object data, Lisp_Object *fn, Lisp_Object *arg)
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
76 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
77 if (SYMBOLP (data)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
78 || (COMPILED_FUNCTIONP (data)
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
79 && XCOMPILED_FUNCTION (data)->flags.interactivep)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
80 || (CONSP (data) && (EQ (XCAR (data), Qlambda))
286
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
81 && !NILP (Fassq (Qinteractive, Fcdr (Fcdr (data))))))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
82 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
83 *fn = Qcall_interactively;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
84 *arg = data;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
85 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
86 else if (CONSP (data))
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
87 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
88 *fn = Qeval;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
89 *arg = data;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
90 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
91 else
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
92 {
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
93 *fn = Qeval;
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
94 *arg = list3 (Qsignal,
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
95 list2 (Qquote, Qerror),
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
96 list2 (Qquote, list2 (build_translated_string
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
97 ("illegal callback"),
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
98 data)));
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
99 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
100 }
57709be46d1b Import from CVS: tag r21-0b41
cvs
parents: 272
diff changeset
101
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
102 /*
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
103 * Add a value VAL associated with keyword KEY into PGUI_ITEM
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
104 * structure. If KEY is not a keyword, or is an unknown keyword, then
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
105 * error is signaled.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
106 */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
107 void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
108 gui_item_add_keyval_pair (Lisp_Object gui_item,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
109 Lisp_Object key, Lisp_Object val,
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
110 Error_behavior errb)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
111 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
112 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
113
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
114 if (!KEYWORDP (key))
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
115 signal_simple_error_2 ("Non-keyword in gui item", key, pgui_item->name);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
116
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
117 if (EQ (key, Q_suffix)) pgui_item->suffix = val;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
118 else if (EQ (key, Q_active)) pgui_item->active = val;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
119 else if (EQ (key, Q_included)) pgui_item->included = val;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
120 else if (EQ (key, Q_config)) pgui_item->config = val;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
121 else if (EQ (key, Q_filter)) pgui_item->filter = val;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
122 else if (EQ (key, Q_style)) pgui_item->style = val;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
123 else if (EQ (key, Q_selected)) pgui_item->selected = val;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
124 else if (EQ (key, Q_keys)) pgui_item->keys = val;
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
125 else if (EQ (key, Q_callback)) pgui_item->callback = val;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
126 else if (EQ (key, Q_key_sequence)) ; /* ignored for FSF compatibility */
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 371
diff changeset
127 else if (EQ (key, Q_label)) ; /* ignored for 21.0 implement in 21.2 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
128 else if (EQ (key, Q_accelerator))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
129 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
130 if (SYMBOLP (val) || CHARP (val))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
131 pgui_item->accelerator = val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
132 else if (ERRB_EQ (errb, ERROR_ME))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
133 signal_simple_error ("Bad keyboard accelerator", val);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
134 }
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
135 else if (ERRB_EQ (errb, ERROR_ME))
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
136 signal_simple_error_2 ("Unknown keyword in gui item", key,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
137 pgui_item->name);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
138 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
139
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
140 void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
141 gui_item_init (Lisp_Object gui_item)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
142 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
143 Lisp_Gui_Item *lp = XGUI_ITEM (gui_item);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
144
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
145 lp->name = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
146 lp->callback = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
147 lp->suffix = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
148 lp->active = Qt;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
149 lp->included = Qt;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
150 lp->config = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
151 lp->filter = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
152 lp->style = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
153 lp->selected = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
154 lp->keys = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
155 lp->accelerator = Qnil;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
156 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
157
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
158 Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
159 allocate_gui_item (void)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
160 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
161 Lisp_Gui_Item *lp = alloc_lcrecord_type (Lisp_Gui_Item, &lrecord_gui_item);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
162 Lisp_Object val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
163
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
164 zero_lcrecord (lp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
165 XSETGUI_ITEM (val, lp);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
166
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
167 gui_item_init (val);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
168
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
169 return val;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
170 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
171
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
172 /*
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
173 * ITEM is a lisp vector, describing a menu item or a button. The
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
174 * function extracts the description of the item into the PGUI_ITEM
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
175 * structure.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
176 */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
177 static Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
178 make_gui_item_from_keywords_internal (Lisp_Object item,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
179 Error_behavior errb)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
180 {
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
181 int length, plist_p, start;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
182 Lisp_Object *contents;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
183 Lisp_Object gui_item = allocate_gui_item ();
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
184 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
185
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
186 CHECK_VECTOR (item);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
187 length = XVECTOR_LENGTH (item);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
188 contents = XVECTOR_DATA (item);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
189
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
190 if (length < 1)
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
191 signal_simple_error ("GUI item descriptors must be at least 1 elts long", item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
192
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
193 /* length 1: [ "name" ]
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
194 length 2: [ "name" callback ]
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
195 length 3: [ "name" callback active-p ]
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
196 or [ "name" keyword value ]
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
197 length 4: [ "name" callback active-p suffix ]
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
198 or [ "name" callback keyword value ]
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
199 length 5+: [ "name" callback [ keyword value ]+ ]
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
200 or [ "name" [ keyword value ]+ ]
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
201 */
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
202 plist_p = (length > 2 && (KEYWORDP (contents [1])
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
203 || KEYWORDP (contents [2])));
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
204
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
205 pgui_item->name = contents [0];
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
206 if (length > 1 && !KEYWORDP (contents [1]))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
207 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
208 pgui_item->callback = contents [1];
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
209 start = 2;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
210 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
211 else
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
212 start =1;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
213
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
214 if (!plist_p && length > 2)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
215 /* the old way */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
216 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
217 pgui_item->active = contents [2];
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
218 if (length == 4)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
219 pgui_item->suffix = contents [3];
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
220 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
221 else
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
222 /* the new way */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
223 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
224 int i;
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
225 if ((length - start) & 1)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
226 signal_simple_error (
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
227 "GUI item descriptor has an odd number of keywords and values",
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
228 item);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
229
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
230 for (i = start; i < length;)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
231 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
232 Lisp_Object key = contents [i++];
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
233 Lisp_Object val = contents [i++];
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
234 gui_item_add_keyval_pair (gui_item, key, val, errb);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
235 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
236 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
237 return gui_item;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
238 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
239
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
240 Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
241 gui_parse_item_keywords (Lisp_Object item)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
242 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
243 return make_gui_item_from_keywords_internal (item, ERROR_ME);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
244 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
245
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
246 Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
247 gui_parse_item_keywords_no_errors (Lisp_Object item)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
248 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
249 return make_gui_item_from_keywords_internal (item, ERROR_ME_NOT);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
250 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
251
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
252 /* convert a gui item into plist properties */
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
253 void
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
254 gui_add_item_keywords_to_plist (Lisp_Object plist, Lisp_Object gui_item)
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
255 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
256 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
257
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
258 if (!NILP (pgui_item->callback))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
259 Fplist_put (plist, Q_callback, pgui_item->callback);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
260 if (!NILP (pgui_item->suffix))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
261 Fplist_put (plist, Q_suffix, pgui_item->suffix);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
262 if (!NILP (pgui_item->active))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
263 Fplist_put (plist, Q_active, pgui_item->active);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
264 if (!NILP (pgui_item->included))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
265 Fplist_put (plist, Q_included, pgui_item->included);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
266 if (!NILP (pgui_item->config))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
267 Fplist_put (plist, Q_config, pgui_item->config);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
268 if (!NILP (pgui_item->filter))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
269 Fplist_put (plist, Q_filter, pgui_item->filter);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
270 if (!NILP (pgui_item->style))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
271 Fplist_put (plist, Q_style, pgui_item->style);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
272 if (!NILP (pgui_item->selected))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
273 Fplist_put (plist, Q_selected, pgui_item->selected);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
274 if (!NILP (pgui_item->keys))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
275 Fplist_put (plist, Q_keys, pgui_item->keys);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
276 if (!NILP (pgui_item->accelerator))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
277 Fplist_put (plist, Q_accelerator, pgui_item->accelerator);
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
278 }
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
279
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
280 /*
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
281 * Decide whether a GUI item is active by evaluating its :active form
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
282 * if any
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
283 */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
284 int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
285 gui_item_active_p (Lisp_Object gui_item)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
286 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
287 /* This function can call lisp */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
288
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
289 /* Shortcut to avoid evaluating Qt each time */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
290 return (EQ (XGUI_ITEM (gui_item)->active, Qt)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
291 || !NILP (Feval (XGUI_ITEM (gui_item)->active)));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
292 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
293
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
294 /* set menu accelerator key to first underlined character in menu name */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
295 Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
296 gui_item_accelerator (Lisp_Object gui_item)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
297 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
298 Lisp_Gui_Item *pgui = XGUI_ITEM (gui_item);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
299
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
300 if (!NILP (pgui->accelerator))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
301 return pgui->accelerator;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
302
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
303 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
304 return gui_name_accelerator (pgui->name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
305 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
306
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
307 Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
308 gui_name_accelerator (Lisp_Object nm)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
309 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
310 Bufbyte *name = XSTRING_DATA (nm);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
311
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
312 while (*name)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
313 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
314 if (*name == '%')
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
315 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
316 ++name;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
317 if (!(*name))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
318 return Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
319 if (*name == '_' && *(name + 1))
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
320 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
321 Emchar accelerator = charptr_emchar (name + 1);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
322 /* #### bogus current_buffer dependency */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
323 return make_char (DOWNCASE (current_buffer, accelerator));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
324 }
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
325 }
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
326 INC_CHARPTR (name);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
327 }
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
328 return make_char (DOWNCASE (current_buffer,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
329 charptr_emchar (XSTRING_DATA (nm))));
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
330 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
331
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
332 /*
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
333 * Decide whether a GUI item is selected by evaluating its :selected form
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
334 * if any
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
335 */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
336 int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
337 gui_item_selected_p (Lisp_Object gui_item)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
338 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
339 /* This function can call lisp */
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
340
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
341 /* Shortcut to avoid evaluating Qt each time */
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
342 return (EQ (XGUI_ITEM (gui_item)->selected, Qt)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
343 || !NILP (Feval (XGUI_ITEM (gui_item)->selected)));
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
344 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
345
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
346 /*
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
347 * Decide whether a GUI item is included by evaluating its :included
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
348 * form if given, and testing its :config form against supplied CONFLIST
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
349 * configuration variable
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
350 */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
351 int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
352 gui_item_included_p (Lisp_Object gui_item, Lisp_Object conflist)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
353 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
354 /* This function can call lisp */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
355 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
356
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
357 /* Evaluate :included first. Shortcut to avoid evaluating Qt each time */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
358 if (!EQ (pgui_item->included, Qt)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
359 && NILP (Feval (pgui_item->included)))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
360 return 0;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
361
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
362 /* Do :config if conflist is given */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
363 if (!NILP (conflist) && !NILP (pgui_item->config)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
364 && NILP (Fmemq (pgui_item->config, conflist)))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
365 return 0;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
366
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
367 return 1;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
368 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
369
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
370 static DOESNT_RETURN
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
371 signal_too_long_error (Lisp_Object name)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
372 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
373 signal_simple_error ("GUI item produces too long displayable string", name);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
374 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
375
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
376 #ifdef HAVE_WINDOW_SYSTEM
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
377 /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
378 * Format "left flush" display portion of an item into BUF, guarded by
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
379 * maximum buffer size BUF_LEN. BUF_LEN does not count for terminating
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
380 * null character, so actual maximum size of buffer consumed is
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
381 * BUF_LEN + 1 bytes. If buffer is not big enough, then error is
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
382 * signaled.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
383 * Return value is the offset to the terminating null character into the
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
384 * buffer.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
385 */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
386 unsigned int
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
387 gui_item_display_flush_left (Lisp_Object gui_item,
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
388 char *buf, Bytecount buf_len)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
389 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
390 /* This function can call lisp */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
391 char *p = buf;
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
392 Bytecount len;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
393 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
394
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
395 /* Copy item name first */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
396 CHECK_STRING (pgui_item->name);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
397 len = XSTRING_LENGTH (pgui_item->name);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
398 if (len > buf_len)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
399 signal_too_long_error (pgui_item->name);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
400 memcpy (p, XSTRING_DATA (pgui_item->name), len);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
401 p += len;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
402
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
403 /* Add space and suffix, if there is a suffix.
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
404 * If suffix is not string evaluate it */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
405 if (!NILP (pgui_item->suffix))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
406 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
407 Lisp_Object suffix = pgui_item->suffix;
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
408 /* Shortcut to avoid evaluating suffix each time */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
409 if (!STRINGP (suffix))
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
410 {
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
411 suffix = Feval (suffix);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
412 CHECK_STRING (suffix);
259
11cf20601dec Import from CVS: tag r20-5b28
cvs
parents: 251
diff changeset
413 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
414
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
415 len = XSTRING_LENGTH (suffix);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
416 if (p + len + 1 > buf + buf_len)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
417 signal_too_long_error (pgui_item->name);
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
418 *(p++) = ' ';
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
419 memcpy (p, XSTRING_DATA (suffix), len);
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
420 p += len;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
421 }
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
422 *p = '\0';
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
423 return p - buf;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
424 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
425
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
426 /*
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
427 * Format "right flush" display portion of an item into BUF, guarded by
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
428 * maximum buffer size BUF_LEN. BUF_LEN does not count for terminating
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
429 * null character, so actual maximum size of buffer consumed is
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
430 * BUF_LEN + 1 bytes. If buffer is not big enough, then error is
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
431 * signaled.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
432 * Return value is the offset to the terminating null character into the
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
433 * buffer.
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
434 */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
435 unsigned int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
436 gui_item_display_flush_right (Lisp_Object gui_item,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
437 char *buf, Bytecount buf_len)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
438 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
439 Lisp_Gui_Item *pgui_item = XGUI_ITEM (gui_item);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
440 *buf = 0;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
441
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
442 #ifdef HAVE_MENUBARS
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
443 /* Have keys? */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
444 if (!menubar_show_keybindings)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
445 return 0;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
446 #endif
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
447
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
448 /* Try :keys first */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
449 if (!NILP (pgui_item->keys))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
450 {
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
451 CHECK_STRING (pgui_item->keys);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
452 if (XSTRING_LENGTH (pgui_item->keys) + 1 > buf_len)
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
453 signal_too_long_error (pgui_item->name);
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
454 memcpy (buf, XSTRING_DATA (pgui_item->keys),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
455 XSTRING_LENGTH (pgui_item->keys) + 1);
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
456 return XSTRING_LENGTH (pgui_item->keys);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
457 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
458
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
459 /* See if we can derive keys out of callback symbol */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
460 if (SYMBOLP (pgui_item->callback))
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
461 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
462 char buf2[1024]; /* #### */
272
c5d627a313b1 Import from CVS: tag r21-0b34
cvs
parents: 259
diff changeset
463 Bytecount len;
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
464
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
465 where_is_to_char (pgui_item->callback, buf2);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
466 len = strlen (buf2);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
467 if (len > buf_len)
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
468 signal_too_long_error (pgui_item->name);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
469 strcpy (buf, buf2);
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
470 return len;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
471 }
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
472
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
473 /* No keys - no right flush display */
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
474 return 0;
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
475 }
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
476 #endif /* HAVE_WINDOW_SYSTEM */
251
677f6a0ee643 Import from CVS: tag r20-5b24
cvs
parents: 231
diff changeset
477
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
478 static Lisp_Object
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
479 mark_gui_item (Lisp_Object obj)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
480 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
481 Lisp_Gui_Item *p = XGUI_ITEM (obj);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
482
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
483 mark_object (p->name);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
484 mark_object (p->callback);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
485 mark_object (p->config);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
486 mark_object (p->suffix);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
487 mark_object (p->active);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
488 mark_object (p->included);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
489 mark_object (p->config);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
490 mark_object (p->filter);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
491 mark_object (p->style);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
492 mark_object (p->selected);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
493 mark_object (p->keys);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
494 mark_object (p->accelerator);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
495
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
496 return Qnil;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
497 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
498
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
499 static unsigned long
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
500 gui_item_hash_internal (Lisp_Object obj, int depth)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
501 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
502 Lisp_Gui_Item *p = XGUI_ITEM (obj);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
503
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
504 return HASH2 (HASH5 (internal_hash (p->name, depth + 1),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
505 internal_hash (p->callback, depth + 1),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
506 internal_hash (p->suffix, depth + 1),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
507 internal_hash (p->active, depth + 1),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
508 internal_hash (p->included, depth + 1)),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
509 HASH5 (internal_hash (p->config, depth + 1),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
510 internal_hash (p->filter, depth + 1),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
511 internal_hash (p->style, depth + 1),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
512 internal_hash (p->selected, depth + 1),
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
513 internal_hash (p->keys, depth + 1)));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
514 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
515
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
516 static unsigned long
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
517 gui_item_hash (Lisp_Object obj, int depth)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
518 {
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
519 Lisp_Gui_Item *p = XGUI_ITEM (obj);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
520
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
521 /* Note that this evaluates the active and selected slots so that
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
522 the hash changes when the result of these changes. */
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
523 return HASH2 (HASH5 (internal_hash (p->name, depth + 1),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
524 internal_hash (p->callback, depth + 1),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
525 internal_hash (p->suffix, depth + 1),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
526 gui_item_active_p (obj),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
527 internal_hash (p->included, depth + 1)),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
528 HASH5 (internal_hash (p->config, depth + 1),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
529 internal_hash (p->filter, depth + 1),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
530 internal_hash (p->style, depth + 1),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
531 gui_item_selected_p (obj),
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
532 internal_hash (p->keys, depth + 1)));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
533 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
534
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
535 int
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
536 gui_item_id_hash (Lisp_Object hashtable, Lisp_Object gitem, int slot)
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
537 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
538 int hashid = gui_item_hash_internal (gitem, 0);
384
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
539 int id = GUI_ITEM_ID_BITS (hashid, slot);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
540 while (!NILP (Fgethash (make_int (id),
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
541 hashtable, Qnil)))
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
542 {
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
543 id = GUI_ITEM_ID_BITS (id + 1, slot);
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
544 }
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
545 return id;
bbff43aa5eb7 Import from CVS: tag r21-2-7
cvs
parents: 380
diff changeset
546 }
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
547
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
548 static int
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
549 gui_item_equal (Lisp_Object obj1, Lisp_Object obj2, int depth)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
550 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
551 Lisp_Gui_Item *p1 = XGUI_ITEM (obj1);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
552 Lisp_Gui_Item *p2 = XGUI_ITEM (obj2);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
553
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
554 if (!(internal_equal (p1->name, p2->name, depth + 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
555 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
556 internal_equal (p1->callback, p2->callback, depth + 1)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
557 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
558 EQ (p1->suffix, p2->suffix)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
559 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
560 EQ (p1->active, p2->active)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
561 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
562 EQ (p1->included, p2->included)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
563 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
564 EQ (p1->config, p2->config)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
565 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
566 EQ (p1->filter, p2->filter)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
567 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
568 EQ (p1->style, p2->style)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
569 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
570 EQ (p1->selected, p2->selected)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
571 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
572 EQ (p1->accelerator, p2->accelerator)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
573 &&
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
574 EQ (p1->keys, p2->keys)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
575 return 0;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
576 return 1;
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
577 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
578
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
579 static void
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
580 print_gui_item (Lisp_Object obj, Lisp_Object printcharfun, int escapeflag)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
581 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
582 Lisp_Gui_Item *g = XGUI_ITEM (obj);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
583 char buf[20];
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
584
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
585 if (print_readably)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
586 error ("printing unreadable object #<gui-item 0x%x>", g->header.uid);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
587
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
588 write_c_string ("#<gui-item ", printcharfun);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
589 sprintf (buf, "0x%x>", g->header.uid);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
590 write_c_string (buf, printcharfun);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
591 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
592
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
593 /* parse a glyph descriptor into a tree of gui items.
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
594
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
595 The gui_item slot of an image instance can be a single item or an
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
596 arbitrarily nested hierarchy of item lists. */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
597
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
598 static Lisp_Object
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
599 parse_gui_item_tree_item (Lisp_Object entry)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
600 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
601 Lisp_Object ret = entry;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
602 struct gcpro gcpro1;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
603
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
604 GCPRO1 (ret);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
605
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
606 if (VECTORP (entry))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
607 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
608 ret = gui_parse_item_keywords_no_errors (entry);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
609 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
610 else if (STRINGP (entry))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
611 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
612 CHECK_STRING (entry);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
613 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
614 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
615 signal_simple_error ("item must be a vector or a string", entry);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
616
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
617 RETURN_UNGCPRO (ret);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
618 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
619
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
620 Lisp_Object
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
621 parse_gui_item_tree_children (Lisp_Object list)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
622 {
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
623 Lisp_Object rest, ret = Qnil, sub = Qnil;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
624 struct gcpro gcpro1, gcpro2;
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
625
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
626 GCPRO2 (ret, sub);
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
627 CHECK_CONS (list);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
628 /* recursively add items to the tree view */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
629 LIST_LOOP (rest, list)
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
630 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
631 if (CONSP (XCAR (rest)))
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
632 sub = parse_gui_item_tree_list (XCAR (rest));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
633 else
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
634 sub = parse_gui_item_tree_item (XCAR (rest));
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
635
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
636 ret = Fcons (sub, ret);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
637 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
638 /* make the order the same as the items we have parsed */
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
639 RETURN_UNGCPRO (Fnreverse (ret));
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
640 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
641
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
642 static Lisp_Object
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
643 parse_gui_item_tree_list (Lisp_Object list)
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
644 {
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
645 Lisp_Object ret;
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
646 struct gcpro gcpro1;
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
647 CHECK_CONS (list);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
648 /* first one can never be a list */
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
649 ret = parse_gui_item_tree_item (XCAR (list));
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
650 GCPRO1 (ret);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
651 ret = Fcons (ret, parse_gui_item_tree_children (XCDR (list)));
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
652 RETURN_UNGCPRO (ret);
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
653 }
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
654
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
655 static void
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
656 finalize_gui_item (void* header, int for_disksave)
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
657 {
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
658 }
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
659
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
660 DEFINE_LRECORD_IMPLEMENTATION ("gui-item", gui_item,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
661 mark_gui_item, print_gui_item,
404
2f8bb876ab1d Import from CVS: tag r21-2-32
cvs
parents: 400
diff changeset
662 finalize_gui_item, gui_item_equal,
398
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
663 gui_item_hash,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
664 0,
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
665 Lisp_Gui_Item);
74fd4e045ea6 Import from CVS: tag r21-2-29
cvs
parents: 388
diff changeset
666
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
667 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
668 syms_of_gui (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
669 {
400
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
670 INIT_LRECORD_IMPLEMENTATION (gui_item);
a86b2b5e0111 Import from CVS: tag r21-2-30
cvs
parents: 398
diff changeset
671
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
672 defkeyword (&Q_active, ":active");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
673 defkeyword (&Q_suffix, ":suffix");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
674 defkeyword (&Q_keys, ":keys");
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 371
diff changeset
675 defkeyword (&Q_key_sequence,":key-sequence");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
676 defkeyword (&Q_style, ":style");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
677 defkeyword (&Q_selected, ":selected");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
678 defkeyword (&Q_filter, ":filter");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
679 defkeyword (&Q_config, ":config");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
680 defkeyword (&Q_included, ":included");
175
2d532a89d707 Import from CVS: tag r20-3b14
cvs
parents: 0
diff changeset
681 defkeyword (&Q_accelerator, ":accelerator");
377
d883f39b8495 Import from CVS: tag r21-2b4
cvs
parents: 371
diff changeset
682 defkeyword (&Q_label, ":label");
388
aabb7f5b1c81 Import from CVS: tag r21-2-9
cvs
parents: 384
diff changeset
683 defkeyword (&Q_callback, ":callback");
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
684
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
685 defsymbol (&Qtoggle, "toggle");
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
686 defsymbol (&Qradio, "radio");
231
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
687
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
688 #ifdef HAVE_POPUPS
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
689 DEFSUBR (Fpopup_up_p);
557eaa0339bf Import from CVS: tag r20-5b14
cvs
parents: 175
diff changeset
690 #endif
0
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
691 }
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
692
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
693 void
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
694 vars_of_gui (void)
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
695 {
376386a54a3c Import from CVS: tag r19-14
cvs
parents:
diff changeset
696 }