annotate src/gui.c @ 400:a86b2b5e0111 r21-2-30

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