annotate src/gui.c @ 424:11054d720c21 r21-2-20

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