Mercurial > hg > xemacs-beta
annotate src/toolbar.c @ 5595:391d809fa4e9
Update tests that have started failing because of changed design decisions.
2011-11-09 Aidan Kehoe <kehoea@parhasard.net>
Update some tests that have started failing because of some
changed design decisions.
* automated/lisp-tests.el (eq):
(type-of 42) now returns the symbol fixnum.
* automated/lisp-tests.el (needs-lexical-context):
(function ...) doesn't create a lexical context, and this is now the
case in interpreted as well as in compiled code.
* automated/mule-tests.el (featurep):
Silence messages when byte-compiling files; if a file doesn't have
the escape-quoted coding cookie, it will now have the
raw-text-unix coding cookie, look for that instead of looking for
the absence of the escape-quoted coding cookie.
author | Aidan Kehoe <kehoea@parhasard.net> |
---|---|
date | Wed, 09 Nov 2011 13:16:19 +0000 |
parents | 56144c8593a8 |
children |
rev | line source |
---|---|
428 | 1 /* Generic toolbar implementation. |
2 Copyright (C) 1995 Board of Trustees, University of Illinois. | |
3 Copyright (C) 1995 Sun Microsystems, Inc. | |
5043 | 4 Copyright (C) 1995, 1996, 2003, 2004, 2010 Ben Wing. |
428 | 5 Copyright (C) 1996 Chuck Thompson. |
6 | |
7 This file is part of XEmacs. | |
8 | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5128
diff
changeset
|
9 XEmacs is free software: you can redistribute it and/or modify it |
428 | 10 under the terms of the GNU General Public License as published by the |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5128
diff
changeset
|
11 Free Software Foundation, either version 3 of the License, or (at your |
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5128
diff
changeset
|
12 option) any later version. |
428 | 13 |
14 XEmacs is distributed in the hope that it will be useful, but WITHOUT | |
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | |
16 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | |
17 for more details. | |
18 | |
19 You should have received a copy of the GNU General Public License | |
5402
308d34e9f07d
Changed bulk of GPLv2 or later files identified by script
Mats Lidell <matsl@xemacs.org>
parents:
5128
diff
changeset
|
20 along with XEmacs. If not, see <http://www.gnu.org/licenses/>. */ |
428 | 21 |
22 /* Synched up with: Not in FSF. */ | |
23 | |
24 /* Original implementation by Chuck Thompson for 19.12. | |
25 Default-toolbar-position and specifier-related stuff by Ben Wing. */ | |
26 | |
27 #include <config.h> | |
28 #include "lisp.h" | |
29 | |
30 #include "buffer.h" | |
872 | 31 #include "frame-impl.h" |
32 #include "device-impl.h" | |
428 | 33 #include "glyphs.h" |
34 #include "redisplay.h" | |
35 #include "toolbar.h" | |
36 #include "window.h" | |
37 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
38 Lisp_Object Vtoolbar[NUM_EDGES]; |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
39 Lisp_Object Vtoolbar_size[NUM_EDGES]; |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
40 Lisp_Object Vtoolbar_visible_p[NUM_EDGES]; |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
41 Lisp_Object Vtoolbar_border_width[NUM_EDGES]; |
428 | 42 |
43 Lisp_Object Vdefault_toolbar, Vdefault_toolbar_visible_p; | |
44 Lisp_Object Vdefault_toolbar_width, Vdefault_toolbar_height; | |
45 Lisp_Object Vdefault_toolbar_border_width; | |
744 | 46 Lisp_Object Vtoolbar_shadow_thickness; |
428 | 47 |
48 Lisp_Object Vdefault_toolbar_position; | |
49 Lisp_Object Vtoolbar_buttons_captioned_p; | |
50 | |
51 Lisp_Object Qtoolbar_buttonp; | |
52 Lisp_Object Q2D, Q3D, Q2d, Q3d; | |
53 Lisp_Object Q_size; | |
54 | |
55 Lisp_Object Qinit_toolbar_from_resources; | |
56 | |
1204 | 57 static const struct memory_description toolbar_button_description [] = { |
934 | 58 { XD_LISP_OBJECT, offsetof (struct toolbar_button, next) }, |
59 { XD_LISP_OBJECT, offsetof (struct toolbar_button, frame) }, | |
60 { XD_LISP_OBJECT, offsetof (struct toolbar_button, up_glyph) }, | |
61 { XD_LISP_OBJECT, offsetof (struct toolbar_button, down_glyph) }, | |
62 { XD_LISP_OBJECT, offsetof (struct toolbar_button, disabled_glyph) }, | |
63 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_up_glyph) }, | |
64 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_down_glyph) }, | |
65 { XD_LISP_OBJECT, offsetof (struct toolbar_button, cap_disabled_glyph) }, | |
66 { XD_LISP_OBJECT, offsetof (struct toolbar_button, callback) }, | |
67 { XD_LISP_OBJECT, offsetof (struct toolbar_button, enabled_p) }, | |
68 { XD_LISP_OBJECT, offsetof (struct toolbar_button, help_string) }, | |
69 { XD_END } | |
70 }; | |
428 | 71 |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
72 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
73 static Lisp_Object |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
74 allocate_toolbar_button (struct frame *f, int pushright) |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
75 { |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
76 struct toolbar_button *tb; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
77 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
78 tb = XTOOLBAR_BUTTON (ALLOC_NORMAL_LISP_OBJECT (toolbar_button)); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
79 tb->next = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
80 tb->frame = wrap_frame (f); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
81 tb->up_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
82 tb->down_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
83 tb->disabled_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
84 tb->cap_up_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
85 tb->cap_down_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
86 tb->cap_disabled_glyph = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
87 tb->callback = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
88 tb->enabled_p = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
89 tb->help_string = Qnil; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
90 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
91 tb->pushright = pushright; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
92 tb->x = tb->y = tb->width = tb->height = -1; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
93 tb->dirty = 1; |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
94 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
95 return wrap_toolbar_button (tb); |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
96 } |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
97 |
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
98 |
428 | 99 static Lisp_Object |
100 mark_toolbar_button (Lisp_Object obj) | |
101 { | |
102 struct toolbar_button *data = XTOOLBAR_BUTTON (obj); | |
103 mark_object (data->next); | |
104 mark_object (data->frame); | |
105 mark_object (data->up_glyph); | |
106 mark_object (data->down_glyph); | |
107 mark_object (data->disabled_glyph); | |
108 mark_object (data->cap_up_glyph); | |
109 mark_object (data->cap_down_glyph); | |
110 mark_object (data->cap_disabled_glyph); | |
111 mark_object (data->callback); | |
112 mark_object (data->enabled_p); | |
113 return data->help_string; | |
114 } | |
115 | |
5124
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
116 DEFINE_NODUMP_INTERNAL_LISP_OBJECT ("toolbar-button", toolbar_button, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
117 mark_toolbar_button, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
118 toolbar_button_description, |
623d57b7fbe8
separate regular and disksave finalization, print method fixes.
Ben Wing <ben@xemacs.org>
parents:
5118
diff
changeset
|
119 struct toolbar_button); |
428 | 120 |
121 DEFUN ("toolbar-button-p", Ftoolbar_button_p, 1, 1, 0, /* | |
122 Return non-nil if OBJECT is a toolbar button. | |
123 */ | |
124 (object)) | |
125 { | |
126 return TOOLBAR_BUTTONP (object) ? Qt : Qnil; | |
127 } | |
128 | |
129 /* Only query functions are provided for toolbar buttons. They are | |
130 generated and updated from a toolbar description list. Any | |
131 directly made changes would be wiped out the first time the toolbar | |
132 was marked as dirty and was regenerated. The exception to this is | |
133 set-toolbar-button-down-flag. Having this allows us to control the | |
134 toolbar from elisp. Since we only trigger the button callbacks on | |
135 up-mouse events and we reset the flag first, there shouldn't be any | |
136 way for this to get us in trouble (like if someone decides to | |
137 change the toolbar from a toolbar callback). */ | |
138 | |
139 DEFUN ("toolbar-button-callback", Ftoolbar_button_callback, 1, 1, 0, /* | |
140 Return the callback function associated with the toolbar BUTTON. | |
141 */ | |
142 (button)) | |
143 { | |
144 CHECK_TOOLBAR_BUTTON (button); | |
145 | |
146 return XTOOLBAR_BUTTON (button)->callback; | |
147 } | |
148 | |
149 DEFUN ("toolbar-button-help-string", Ftoolbar_button_help_string, 1, 1, 0, /* | |
150 Return the help string function associated with the toolbar BUTTON. | |
151 */ | |
152 (button)) | |
153 { | |
154 CHECK_TOOLBAR_BUTTON (button); | |
155 | |
156 return XTOOLBAR_BUTTON (button)->help_string; | |
157 } | |
158 | |
159 DEFUN ("toolbar-button-enabled-p", Ftoolbar_button_enabled_p, 1, 1, 0, /* | |
160 Return t if BUTTON is active. | |
161 */ | |
162 (button)) | |
163 { | |
164 CHECK_TOOLBAR_BUTTON (button); | |
165 | |
166 return XTOOLBAR_BUTTON (button)->enabled ? Qt : Qnil; | |
167 } | |
168 | |
169 DEFUN ("set-toolbar-button-down-flag", Fset_toolbar_button_down_flag, 2, 2, 0, /* | |
170 Don't touch. | |
171 */ | |
172 (button, flag)) | |
173 { | |
174 struct toolbar_button *tb; | |
175 char old_flag; | |
176 | |
177 CHECK_TOOLBAR_BUTTON (button); | |
178 tb = XTOOLBAR_BUTTON (button); | |
179 old_flag = tb->down; | |
180 | |
181 /* If the button is ignored, don't do anything. */ | |
182 if (!tb->enabled) | |
183 return Qnil; | |
184 | |
185 /* If flag is nil, unset the down flag, otherwise set it to true. | |
186 This also triggers an immediate redraw of the button if the flag | |
187 does change. */ | |
188 | |
189 if (NILP (flag)) | |
190 tb->down = 0; | |
191 else | |
192 tb->down = 1; | |
193 | |
194 if (tb->down != old_flag) | |
195 { | |
196 struct frame *f = XFRAME (tb->frame); | |
197 struct device *d; | |
198 | |
199 if (DEVICEP (f->device)) | |
200 { | |
201 d = XDEVICE (f->device); | |
202 | |
203 if (DEVICE_LIVE_P (XDEVICE (f->device))) | |
204 { | |
205 tb->dirty = 1; | |
206 MAYBE_DEVMETH (d, output_toolbar_button, (f, button)); | |
207 } | |
208 } | |
209 } | |
210 | |
211 return Qnil; | |
212 } | |
213 | |
214 Lisp_Object | |
215 get_toolbar_button_glyph (struct window *w, struct toolbar_button *tb) | |
216 { | |
217 Lisp_Object glyph = Qnil; | |
218 | |
219 /* The selected glyph logic: | |
220 | |
221 UP: up | |
222 DOWN: down -> up | |
223 DISABLED: disabled -> up | |
224 CAP-UP: cap-up -> up | |
225 CAP-DOWN: cap-down -> cap-up -> down -> up | |
226 CAP-DISABLED: cap-disabled -> cap-up -> disabled -> up | |
227 */ | |
228 | |
229 if (!NILP (w->toolbar_buttons_captioned_p)) | |
230 { | |
231 if (tb->enabled && tb->down) | |
232 glyph = tb->cap_down_glyph; | |
233 else if (!tb->enabled) | |
234 glyph = tb->cap_disabled_glyph; | |
235 | |
236 if (NILP (glyph)) | |
237 glyph = tb->cap_up_glyph; | |
238 } | |
239 | |
240 if (NILP (glyph)) | |
241 { | |
242 if (tb->enabled && tb->down) | |
243 glyph = tb->down_glyph; | |
244 else if (!tb->enabled) | |
245 glyph = tb->disabled_glyph; | |
246 } | |
247 | |
248 /* The non-captioned up button is the ultimate fallback. It is | |
249 the only one we guarantee exists. */ | |
250 if (NILP (glyph)) | |
251 glyph = tb->up_glyph; | |
252 | |
253 return glyph; | |
254 } | |
255 | |
256 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
257 static enum edge_pos |
428 | 258 decode_toolbar_position (Lisp_Object position) |
259 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
260 if (EQ (position, Qtop)) return TOP_EDGE; |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
261 if (EQ (position, Qbottom)) return BOTTOM_EDGE; |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
262 if (EQ (position, Qleft)) return LEFT_EDGE; |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
263 if (EQ (position, Qright)) return RIGHT_EDGE; |
563 | 264 invalid_constant ("Invalid toolbar position", position); |
428 | 265 |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
266 RETURN_NOT_REACHED (TOP_EDGE); |
428 | 267 } |
268 | |
269 DEFUN ("set-default-toolbar-position", Fset_default_toolbar_position, 1, 1, 0, /* | |
270 Set the position that the `default-toolbar' will be displayed at. | |
3025 | 271 Valid positions are `top', `bottom', `left' and `right'. |
428 | 272 See `default-toolbar-position'. |
273 */ | |
274 (position)) | |
275 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
276 enum edge_pos cur = decode_toolbar_position (Vdefault_toolbar_position); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
277 enum edge_pos new_ = decode_toolbar_position (position); |
428 | 278 |
3025 | 279 if (cur != new_) |
428 | 280 { |
281 /* The following calls will automatically cause the dirty | |
282 flags to be set; we delay frame size changes to avoid | |
283 lots of frame flickering. */ | |
1318 | 284 int depth = begin_hold_frame_size_changes (); |
428 | 285 set_specifier_fallback (Vtoolbar[cur], list1 (Fcons (Qnil, Qnil))); |
3025 | 286 set_specifier_fallback (Vtoolbar[new_], Vdefault_toolbar); |
428 | 287 set_specifier_fallback (Vtoolbar_size[cur], list1 (Fcons (Qnil, Qzero))); |
3025 | 288 set_specifier_fallback (Vtoolbar_size[new_], |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
289 new_ == TOP_EDGE || new_ == BOTTOM_EDGE |
428 | 290 ? Vdefault_toolbar_height |
291 : Vdefault_toolbar_width); | |
292 set_specifier_fallback (Vtoolbar_border_width[cur], | |
293 list1 (Fcons (Qnil, Qzero))); | |
3025 | 294 set_specifier_fallback (Vtoolbar_border_width[new_], |
428 | 295 Vdefault_toolbar_border_width); |
296 set_specifier_fallback (Vtoolbar_visible_p[cur], | |
297 list1 (Fcons (Qnil, Qt))); | |
3025 | 298 set_specifier_fallback (Vtoolbar_visible_p[new_], |
428 | 299 Vdefault_toolbar_visible_p); |
300 Vdefault_toolbar_position = position; | |
1318 | 301 unbind_to (depth); |
428 | 302 } |
303 | |
304 return position; | |
305 } | |
306 | |
307 DEFUN ("default-toolbar-position", Fdefault_toolbar_position, 0, 0, 0, /* | |
308 Return the position that the `default-toolbar' will be displayed at. | |
309 The `default-toolbar' will only be displayed here if the corresponding | |
310 position-specific toolbar specifier does not provide a value. | |
311 */ | |
312 ()) | |
313 { | |
314 return Vdefault_toolbar_position; | |
315 } | |
316 | |
317 | |
318 static Lisp_Object | |
319 update_toolbar_button (struct frame *f, struct toolbar_button *tb, | |
320 Lisp_Object desc, int pushright) | |
321 { | |
322 Lisp_Object *elt, glyphs, retval, buffer; | |
323 struct gcpro gcpro1, gcpro2; | |
324 | |
325 elt = XVECTOR_DATA (desc); | |
326 buffer = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer; | |
327 | |
328 if (!tb) | |
5127
a9c41067dd88
more cleanups, terminology clarification, lots of doc work
Ben Wing <ben@xemacs.org>
parents:
5126
diff
changeset
|
329 tb = XTOOLBAR_BUTTON (allocate_toolbar_button (f, pushright)); |
793 | 330 retval = wrap_toolbar_button (tb); |
428 | 331 |
332 /* Let's make sure nothing gets mucked up by the potential call to | |
333 eval farther down. */ | |
334 GCPRO2 (retval, desc); | |
335 | |
336 glyphs = (CONSP (elt[0]) ? elt[0] : symbol_value_in_buffer (elt[0], buffer)); | |
337 | |
338 /* If this is true we have a blank, otherwise it is an actual | |
339 button. */ | |
340 if (KEYWORDP (glyphs)) | |
341 { | |
342 int pos; | |
343 int style_seen = 0; | |
344 int size_seen = 0; | |
345 int len = XVECTOR_LENGTH (desc); | |
346 | |
347 if (!tb->blank) | |
348 { | |
349 tb->blank = 1; | |
350 tb->dirty = 1; | |
351 } | |
352 | |
353 for (pos = 0; pos < len; pos += 2) | |
354 { | |
355 Lisp_Object key = elt[pos]; | |
356 Lisp_Object val = elt[pos + 1]; | |
357 | |
358 if (EQ (key, Q_style)) | |
359 { | |
360 style_seen = 1; | |
361 | |
362 if (EQ (val, Q2D) || EQ (val, Q2d)) | |
363 { | |
364 if (!EQ (Qnil, tb->up_glyph) || !EQ (Qt, tb->disabled_glyph)) | |
365 { | |
366 tb->up_glyph = Qnil; | |
367 tb->disabled_glyph = Qt; | |
368 tb->dirty = 1; | |
369 } | |
370 } | |
371 else if (EQ (val, Q3D) || (EQ (val, Q3d))) | |
372 { | |
373 if (!EQ (Qt, tb->up_glyph) || !EQ (Qnil, tb->disabled_glyph)) | |
374 { | |
375 tb->up_glyph = Qt; | |
376 tb->disabled_glyph = Qnil; | |
377 tb->dirty = 1; | |
378 } | |
379 } | |
380 } | |
381 else if (EQ (key, Q_size)) | |
382 { | |
383 size_seen = 1; | |
384 | |
385 if (!EQ (val, tb->down_glyph)) | |
386 { | |
387 tb->down_glyph = val; | |
388 tb->dirty = 1; | |
389 } | |
390 } | |
391 } | |
392 | |
393 if (!style_seen) | |
394 { | |
395 /* The default style is 3D. */ | |
396 if (!EQ (Qt, tb->up_glyph) || !EQ (Qnil, tb->disabled_glyph)) | |
397 { | |
398 tb->up_glyph = Qt; | |
399 tb->disabled_glyph = Qnil; | |
400 tb->dirty = 1; | |
401 } | |
402 } | |
403 | |
404 if (!size_seen) | |
405 { | |
406 /* The default width is set to nil. The device specific | |
407 code will fill it in at its discretion. */ | |
408 if (!NILP (tb->down_glyph)) | |
409 { | |
410 tb->down_glyph = Qnil; | |
411 tb->dirty = 1; | |
412 } | |
413 } | |
414 | |
415 /* The rest of these fields are not used by blanks. We make | |
416 sure they are nulled out in case this button object formerly | |
417 represented a real button. */ | |
418 if (!NILP (tb->callback) | |
419 || !NILP (tb->enabled_p) | |
420 || !NILP (tb->help_string)) | |
421 { | |
422 tb->cap_up_glyph = Qnil; | |
423 tb->cap_down_glyph = Qnil; | |
424 tb->cap_disabled_glyph = Qnil; | |
425 tb->callback = Qnil; | |
426 tb->enabled_p = Qnil; | |
427 tb->help_string = Qnil; | |
428 tb->dirty = 1; | |
429 } | |
430 } | |
431 else | |
432 { | |
433 if (tb->blank) | |
434 { | |
435 tb->blank = 0; | |
436 tb->dirty = 1; | |
437 } | |
438 | |
439 /* We know that we at least have an up_glyph. Well, no, we | |
440 don't. The user may have changed the button glyph on us. */ | |
441 if (CONSP (glyphs)) | |
442 { | |
443 if (!EQ (XCAR (glyphs), tb->up_glyph)) | |
444 { | |
445 tb->up_glyph = XCAR (glyphs); | |
446 tb->dirty = 1; | |
447 } | |
448 glyphs = XCDR (glyphs); | |
449 } | |
450 else | |
451 tb->up_glyph = Qnil; | |
452 | |
453 /* We might have a down_glyph. */ | |
454 if (CONSP (glyphs)) | |
455 { | |
456 if (!EQ (XCAR (glyphs), tb->down_glyph)) | |
457 { | |
458 tb->down_glyph = XCAR (glyphs); | |
459 tb->dirty = 1; | |
460 } | |
461 glyphs = XCDR (glyphs); | |
462 } | |
463 else | |
464 tb->down_glyph = Qnil; | |
465 | |
466 /* We might have a disabled_glyph. */ | |
467 if (CONSP (glyphs)) | |
468 { | |
469 if (!EQ (XCAR (glyphs), tb->disabled_glyph)) | |
470 { | |
471 tb->disabled_glyph = XCAR (glyphs); | |
472 tb->dirty = 1; | |
473 } | |
474 glyphs = XCDR (glyphs); | |
475 } | |
476 else | |
477 tb->disabled_glyph = Qnil; | |
478 | |
479 /* We might have a cap_up_glyph. */ | |
480 if (CONSP (glyphs)) | |
481 { | |
482 if (!EQ (XCAR (glyphs), tb->cap_up_glyph)) | |
483 { | |
484 tb->cap_up_glyph = XCAR (glyphs); | |
485 tb->dirty = 1; | |
486 } | |
487 glyphs = XCDR (glyphs); | |
488 } | |
489 else | |
490 tb->cap_up_glyph = Qnil; | |
491 | |
492 /* We might have a cap_down_glyph. */ | |
493 if (CONSP (glyphs)) | |
494 { | |
495 if (!EQ (XCAR (glyphs), tb->cap_down_glyph)) | |
496 { | |
497 tb->cap_down_glyph = XCAR (glyphs); | |
498 tb->dirty = 1; | |
499 } | |
500 glyphs = XCDR (glyphs); | |
501 } | |
502 else | |
503 tb->cap_down_glyph = Qnil; | |
504 | |
505 /* We might have a cap_disabled_glyph. */ | |
506 if (CONSP (glyphs)) | |
507 { | |
508 if (!EQ (XCAR (glyphs), tb->cap_disabled_glyph)) | |
509 { | |
510 tb->cap_disabled_glyph = XCAR (glyphs); | |
511 tb->dirty = 1; | |
512 } | |
513 } | |
514 else | |
515 tb->cap_disabled_glyph = Qnil; | |
516 | |
517 /* Update the callback. */ | |
518 if (!EQ (tb->callback, elt[1])) | |
519 { | |
520 tb->callback = elt[1]; | |
521 /* This does not have an impact on the display properties of the | |
522 button so we do not mark it as dirty if it has changed. */ | |
523 } | |
524 | |
525 /* Update the enabled field. */ | |
526 if (!EQ (tb->enabled_p, elt[2])) | |
527 { | |
528 tb->enabled_p = elt[2]; | |
529 tb->dirty = 1; | |
530 } | |
531 | |
532 /* We always do the following because if the enabled status is | |
533 determined by a function its decision may change without us being | |
534 able to detect it. */ | |
535 { | |
536 int old_enabled = tb->enabled; | |
537 | |
538 if (NILP (tb->enabled_p)) | |
539 tb->enabled = 0; | |
540 else if (EQ (tb->enabled_p, Qt)) | |
541 tb->enabled = 1; | |
542 else | |
543 { | |
544 if (NILP (tb->enabled_p) || EQ (tb->enabled_p, Qt)) | |
545 /* short-circuit the common case for speed */ | |
546 tb->enabled = !NILP (tb->enabled_p); | |
547 else | |
548 { | |
853 | 549 /* #### do we really need to protect this call? */ |
428 | 550 Lisp_Object result = |
853 | 551 eval_in_buffer_trapping_problems |
428 | 552 ("Error in toolbar enabled-p form", |
553 XBUFFER | |
554 (WINDOW_BUFFER | |
555 (XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)))), | |
853 | 556 tb->enabled_p, 0); |
428 | 557 if (UNBOUNDP (result)) |
558 /* #### if there was an error in the enabled-p | |
559 form, should we pretend like it's enabled | |
560 or disabled? */ | |
561 tb->enabled = 0; | |
562 else | |
563 tb->enabled = !NILP (result); | |
564 } | |
565 } | |
566 | |
567 if (old_enabled != tb->enabled) | |
568 tb->dirty = 1; | |
569 } | |
570 | |
571 /* Update the help echo string. */ | |
572 if (!EQ (tb->help_string, elt[3])) | |
573 { | |
574 tb->help_string = elt[3]; | |
575 /* This does not have an impact on the display properties of the | |
576 button so we do not mark it as dirty if it has changed. */ | |
577 } | |
578 } | |
579 | |
580 /* If this flag changes, the position is changing for sure unless | |
581 some very unlikely geometry occurs. */ | |
582 if (tb->pushright != pushright) | |
583 { | |
584 tb->pushright = pushright; | |
585 tb->dirty = 1; | |
586 } | |
587 | |
588 /* The position and size fields are only manipulated in the | |
589 device-dependent code. */ | |
590 UNGCPRO; | |
591 return retval; | |
592 } | |
593 | |
594 void | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
595 mark_frame_toolbar_buttons_dirty (struct frame *f, enum edge_pos pos) |
428 | 596 { |
597 Lisp_Object button = FRAME_TOOLBAR_BUTTONS (f, pos); | |
598 | |
599 while (!NILP (button)) | |
600 { | |
601 struct toolbar_button *tb = XTOOLBAR_BUTTON (button); | |
602 tb->dirty = 1; | |
603 button = tb->next; | |
604 } | |
605 return; | |
606 } | |
607 | |
608 static Lisp_Object | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
609 compute_frame_toolbar_buttons (struct frame *f, enum edge_pos pos, |
428 | 610 Lisp_Object toolbar) |
611 { | |
612 Lisp_Object buttons, prev_button, first_button; | |
613 Lisp_Object orig_toolbar = toolbar; | |
614 int pushright_seen = 0; | |
615 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5; | |
616 | |
617 first_button = FRAME_TOOLBAR_BUTTONS (f, pos); | |
618 buttons = prev_button = first_button; | |
619 | |
620 /* Yes, we're being paranoid. */ | |
621 GCPRO5 (toolbar, buttons, prev_button, first_button, orig_toolbar); | |
622 | |
623 if (NILP (toolbar)) | |
624 { | |
625 /* The output mechanisms will take care of clearing the former | |
626 toolbar. */ | |
627 UNGCPRO; | |
628 return Qnil; | |
629 } | |
630 | |
631 if (!CONSP (toolbar)) | |
563 | 632 sferror ("toolbar description must be a list", toolbar); |
428 | 633 |
634 /* First synchronize any existing buttons. */ | |
635 while (!NILP (toolbar) && !NILP (buttons)) | |
636 { | |
637 struct toolbar_button *tb; | |
638 | |
639 if (NILP (XCAR (toolbar))) | |
640 { | |
641 if (pushright_seen) | |
563 | 642 sferror |
428 | 643 ("more than one partition (nil) in toolbar description", |
644 orig_toolbar); | |
645 else | |
646 pushright_seen = 1; | |
647 } | |
648 else | |
649 { | |
650 tb = XTOOLBAR_BUTTON (buttons); | |
651 update_toolbar_button (f, tb, XCAR (toolbar), pushright_seen); | |
652 prev_button = buttons; | |
653 buttons = tb->next; | |
654 } | |
655 | |
656 toolbar = XCDR (toolbar); | |
657 } | |
658 | |
659 /* If we hit the end of the toolbar, then clean up any excess | |
660 buttons and return. */ | |
661 if (NILP (toolbar)) | |
662 { | |
663 if (!NILP (buttons)) | |
664 { | |
665 /* If this is the case the only thing we saw was a | |
666 pushright marker. */ | |
667 if (EQ (buttons, first_button)) | |
668 { | |
669 UNGCPRO; | |
670 return Qnil; | |
671 } | |
672 else | |
673 XTOOLBAR_BUTTON (prev_button)->next = Qnil; | |
674 } | |
675 UNGCPRO; | |
676 return first_button; | |
677 } | |
678 | |
679 /* At this point there are more buttons on the toolbar than we | |
680 actually have in existence. */ | |
681 while (!NILP (toolbar)) | |
682 { | |
683 Lisp_Object new_button; | |
684 | |
685 if (NILP (XCAR (toolbar))) | |
686 { | |
687 if (pushright_seen) | |
563 | 688 sferror |
428 | 689 ("more than one partition (nil) in toolbar description", |
690 orig_toolbar); | |
691 else | |
692 pushright_seen = 1; | |
693 } | |
694 else | |
695 { | |
696 new_button = update_toolbar_button (f, NULL, XCAR (toolbar), | |
697 pushright_seen); | |
698 | |
699 if (NILP (first_button)) | |
700 { | |
701 first_button = prev_button = new_button; | |
702 } | |
703 else | |
704 { | |
705 XTOOLBAR_BUTTON (prev_button)->next = new_button; | |
706 prev_button = new_button; | |
707 } | |
708 } | |
709 | |
710 toolbar = XCDR (toolbar); | |
711 } | |
712 | |
713 UNGCPRO; | |
714 return first_button; | |
715 } | |
716 | |
717 static void | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
718 set_frame_toolbar (struct frame *f, enum edge_pos pos) |
428 | 719 { |
720 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)); | |
721 Lisp_Object toolbar = w->toolbar[pos]; | |
722 f->toolbar_buttons[pos] = (FRAME_REAL_TOOLBAR_VISIBLE (f, pos) | |
723 ? compute_frame_toolbar_buttons (f, pos, toolbar) | |
724 : Qnil); | |
725 } | |
726 | |
727 static void | |
728 compute_frame_toolbars_data (struct frame *f) | |
729 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
730 set_frame_toolbar (f, TOP_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
731 set_frame_toolbar (f, BOTTOM_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
732 set_frame_toolbar (f, LEFT_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
733 set_frame_toolbar (f, RIGHT_EDGE); |
428 | 734 } |
735 | |
905 | 736 /* Update the toolbar geometry separately from actually displaying the |
737 toolbar. This is necessary because both the gutter and the toolbar | |
738 are competing for redisplay cycles and, unfortunately, gutter | |
739 updates happen late in the game. Firstly they are done inside of | |
740 redisplay proper and secondly subcontrols may not get moved until | |
741 the next screen refresh. Only after subcontrols have been moved to | |
742 their final destinations can we be certain of updating the | |
743 toolbar. Under X this probably is exacerbated by the toolbar button | |
744 dirty flags which prevent updates happening when they possibly | |
745 should. */ | |
428 | 746 void |
905 | 747 update_frame_toolbars_geometry (struct frame *f) |
428 | 748 { |
749 struct device *d = XDEVICE (f->device); | |
750 | |
751 if (DEVICE_SUPPORTS_TOOLBARS_P (d) | |
905 | 752 && (f->toolbar_changed |
753 || f->frame_layout_changed | |
754 || f->frame_changed | |
755 || f->clear)) | |
428 | 756 { |
1559 | 757 int pos, frame_size_changed = 0; |
442 | 758 |
428 | 759 /* We're not officially "in redisplay", so we still have a |
760 chance to re-layout toolbars and windows. This is done here, | |
761 because toolbar is the only thing which currently might | |
762 necessitate this layout, as it is outside any windows. We | |
763 take care not to change size if toolbar geometry is really | |
764 unchanged, as it will hose windows whose pixsizes are not | |
765 multiple of character sizes. */ | |
766 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
767 EDGE_POS_LOOP (pos) |
428 | 768 if (FRAME_REAL_TOOLBAR_SIZE (f, pos) |
769 != FRAME_CURRENT_TOOLBAR_SIZE (f, pos)) | |
1559 | 770 frame_size_changed = 1; |
428 | 771 |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
772 EDGE_POS_LOOP (pos) |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
773 { |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
774 f->current_toolbar_size[pos] = FRAME_REAL_TOOLBAR_SIZE (f, pos); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
775 } |
428 | 776 |
777 /* Removed the check for the minibuffer here. We handle this | |
778 more correctly now by consistently using | |
779 FRAME_LAST_NONMINIBUF_WINDOW instead of FRAME_SELECTED_WINDOW | |
780 throughout the toolbar code. */ | |
781 compute_frame_toolbars_data (f); | |
1559 | 782 |
5090 | 783 /* #### GEOM! Turning the toolbar on and off repeatedly causes the |
784 frame to steadily shrink. Basically, turning it on doesn't | |
785 increase the frame size, while turning it off does reduce the | |
786 frame size. The cause has something to do with the combination | |
787 of this maybe questionable code here, plus the fact that toolbars | |
788 are included in the displayable area, and the difference between | |
789 real and theoretical toolbar sizes, and exactly when the various | |
790 computations happen w.r.t. the specifiers or whatever that control | |
791 whether toolbars are visible and hence whether their thickness is | |
792 greater than zero. --ben */ | |
793 | |
1559 | 794 if (frame_size_changed) |
795 { | |
796 int width, height; | |
5043 | 797 pixel_to_frame_unit_size (f, FRAME_PIXWIDTH (f), FRAME_PIXHEIGHT (f), |
798 &width, &height); | |
799 internal_set_frame_size (f, width, height, 0); | |
1559 | 800 MARK_FRAME_LAYOUT_CHANGED (f); |
801 } | |
905 | 802 |
803 /* Clear the previous toolbar locations. If we do it later | |
804 (after redisplay) we end up clearing what we have just | |
805 displayed. */ | |
806 MAYBE_DEVMETH (d, clear_frame_toolbars, (f)); | |
1559 | 807 |
905 | 808 } |
809 } | |
428 | 810 |
905 | 811 /* Actually redisplay the toolbar buttons. */ |
812 void | |
813 update_frame_toolbars (struct frame *f) | |
814 { | |
815 struct device *d = XDEVICE (f->device); | |
816 | |
817 if (DEVICE_SUPPORTS_TOOLBARS_P (d) | |
818 && (f->toolbar_changed | |
819 || f->frame_layout_changed | |
820 || f->frame_changed | |
821 || f->clear)) | |
822 { | |
428 | 823 DEVMETH (d, output_frame_toolbars, (f)); |
824 } | |
825 | |
826 f->toolbar_changed = 0; | |
827 } | |
828 | |
829 void | |
830 init_frame_toolbars (struct frame *f) | |
831 { | |
832 struct device *d = XDEVICE (f->device); | |
833 | |
834 if (DEVICE_SUPPORTS_TOOLBARS_P (d)) | |
835 { | |
836 Lisp_Object frame; | |
837 int pos; | |
838 | |
839 compute_frame_toolbars_data (f); | |
793 | 840 frame = wrap_frame (f); |
428 | 841 call_critical_lisp_code (XDEVICE (FRAME_DEVICE (f)), |
842 Qinit_toolbar_from_resources, | |
843 frame); | |
844 MAYBE_DEVMETH (d, initialize_frame_toolbars, (f)); | |
845 | |
846 /* We are here as far in frame creation so cached specifiers are | |
847 already recomputed, and possibly modified by resource | |
848 initialization. Remember current toolbar geometry so next | |
849 redisplay will not needlessly relayout toolbars. */ | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
850 EDGE_POS_LOOP (pos) |
428 | 851 f->current_toolbar_size[pos] = FRAME_REAL_TOOLBAR_SIZE (f, pos); |
852 } | |
853 } | |
854 | |
855 void | |
856 init_device_toolbars (struct device *d) | |
857 { | |
793 | 858 Lisp_Object device = wrap_device (d); |
428 | 859 |
860 if (DEVICE_SUPPORTS_TOOLBARS_P (d)) | |
861 call_critical_lisp_code (d, | |
862 Qinit_toolbar_from_resources, | |
863 device); | |
864 } | |
865 | |
866 void | |
867 init_global_toolbars (struct device *d) | |
868 { | |
869 if (DEVICE_SUPPORTS_TOOLBARS_P (d)) | |
870 call_critical_lisp_code (d, | |
871 Qinit_toolbar_from_resources, | |
872 Qglobal); | |
873 } | |
874 | |
875 void | |
876 free_frame_toolbars (struct frame *f) | |
877 { | |
878 /* If we had directly allocated any memory for the toolbars instead | |
879 of using all Lisp_Objects this is where we would now free it. */ | |
880 | |
881 MAYBE_FRAMEMETH (f, free_frame_toolbars, (f)); | |
882 } | |
883 | |
884 void | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
885 get_toolbar_coords (struct frame *f, enum edge_pos pos, int *x, int *y, |
428 | 886 int *width, int *height, int *vert, int for_layout) |
887 { | |
888 int visible_top_toolbar_height, visible_bottom_toolbar_height; | |
889 int adjust = (for_layout ? 1 : 0); | |
890 | |
891 /* The top and bottom toolbars take precedence over the left and | |
892 right. */ | |
893 visible_top_toolbar_height = (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f) | |
894 ? FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) + | |
895 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f) | |
896 : 0); | |
897 visible_bottom_toolbar_height = (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f) | |
898 ? FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) + | |
899 2 * | |
900 FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f) | |
901 : 0); | |
902 | |
903 /* We adjust the width and height by one to give us a narrow border | |
904 at the outside edges. However, when we are simply determining | |
905 toolbar location we don't want to do that. */ | |
906 | |
907 switch (pos) | |
908 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
909 case TOP_EDGE: |
428 | 910 *x = 1; |
911 *y = 0; /* #### should be 1 if no menubar */ | |
912 *width = FRAME_PIXWIDTH (f) - 2; | |
913 *height = FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) + | |
914 2 * FRAME_REAL_TOP_TOOLBAR_BORDER_WIDTH (f) - adjust; | |
915 *vert = 0; | |
916 break; | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
917 case BOTTOM_EDGE: |
428 | 918 *x = 1; |
919 *y = FRAME_PIXHEIGHT (f) - FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) - | |
920 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f); | |
921 *width = FRAME_PIXWIDTH (f) - 2; | |
922 *height = FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) + | |
923 2 * FRAME_REAL_BOTTOM_TOOLBAR_BORDER_WIDTH (f) - adjust; | |
924 *vert = 0; | |
925 break; | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
926 case LEFT_EDGE: |
428 | 927 *x = 1; |
928 *y = visible_top_toolbar_height; | |
929 *width = FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) + | |
930 2 * FRAME_REAL_LEFT_TOOLBAR_BORDER_WIDTH (f) - adjust; | |
931 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height - | |
932 visible_bottom_toolbar_height - 1); | |
933 *vert = 1; | |
934 break; | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
935 case RIGHT_EDGE: |
428 | 936 *x = FRAME_PIXWIDTH (f) - FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) - |
937 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f); | |
938 *y = visible_top_toolbar_height; | |
939 *width = FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) + | |
940 2 * FRAME_REAL_RIGHT_TOOLBAR_BORDER_WIDTH (f) - adjust; | |
941 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height - | |
942 visible_bottom_toolbar_height); | |
943 *vert = 1; | |
944 break; | |
945 default: | |
2500 | 946 ABORT (); |
428 | 947 } |
948 } | |
949 | |
950 #define CHECK_TOOLBAR(pos) do { \ | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
951 if (FRAME_REAL_TOOLBAR_VISIBLE (f, pos)) \ |
428 | 952 { \ |
953 int x, y, width, height, vert; \ | |
954 \ | |
955 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 0); \ | |
956 if ((x_coord >= x) && (x_coord < (x + width))) \ | |
957 { \ | |
958 if ((y_coord >= y) && (y_coord < (y + height))) \ | |
959 return FRAME_TOOLBAR_BUTTONS (f, pos); \ | |
960 } \ | |
961 } \ | |
962 } while (0) | |
963 | |
964 static Lisp_Object | |
965 toolbar_buttons_at_pixpos (struct frame *f, int x_coord, int y_coord) | |
966 { | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
967 CHECK_TOOLBAR (TOP_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
968 CHECK_TOOLBAR (BOTTOM_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
969 CHECK_TOOLBAR (LEFT_EDGE); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
970 CHECK_TOOLBAR (RIGHT_EDGE); |
428 | 971 |
972 return Qnil; | |
973 } | |
974 #undef CHECK_TOOLBAR | |
975 | |
976 /* The device dependent code actually does the work of positioning the | |
977 buttons, but we are free to access that information at this | |
978 level. */ | |
979 Lisp_Object | |
980 toolbar_button_at_pixpos (struct frame *f, int x_coord, int y_coord) | |
981 { | |
982 Lisp_Object buttons = toolbar_buttons_at_pixpos (f, x_coord, y_coord); | |
983 | |
984 while (!NILP (buttons)) | |
985 { | |
986 struct toolbar_button *tb = XTOOLBAR_BUTTON (buttons); | |
987 | |
988 if ((x_coord >= tb->x) && (x_coord < (tb->x + tb->width))) | |
989 { | |
990 if ((y_coord >= tb->y) && (y_coord < (tb->y + tb->height))) | |
991 { | |
992 /* If we are over a blank, return nil. */ | |
993 if (tb->blank) | |
994 return Qnil; | |
995 else | |
996 return buttons; | |
997 } | |
998 } | |
999 | |
1000 buttons = tb->next; | |
1001 } | |
1002 | |
1003 /* We are not over a toolbar or we are over a blank in the toolbar. */ | |
1004 return Qnil; | |
1005 } | |
1006 | |
1007 | |
1008 /************************************************************************/ | |
1009 /* Toolbar specifier type */ | |
1010 /************************************************************************/ | |
1011 | |
1012 DEFINE_SPECIFIER_TYPE (toolbar); | |
1013 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1014 #define CTB_ERROR(msg) do { \ |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1015 maybe_signal_error (Qinvalid_argument, msg, button, Qtoolbar, errb); \ |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1016 RETURN_SANS_WARNINGS Qnil; \ |
428 | 1017 } while (0) |
1018 | |
1019 /* Returns Q_style if key was :style, Qt if ok otherwise, Qnil if error. */ | |
1020 static Lisp_Object | |
1021 check_toolbar_button_keywords (Lisp_Object button, Lisp_Object key, | |
578 | 1022 Lisp_Object val, Error_Behavior errb) |
428 | 1023 { |
1024 if (!KEYWORDP (key)) | |
1025 { | |
563 | 1026 maybe_signal_error_2 (Qinvalid_argument, "Not a keyword", key, button, |
1027 Qtoolbar, errb); | |
428 | 1028 return Qnil; |
1029 } | |
1030 | |
1031 if (EQ (key, Q_style)) | |
1032 { | |
1033 if (!EQ (val, Q2D) | |
1034 && !EQ (val, Q3D) | |
1035 && !EQ (val, Q2d) | |
1036 && !EQ (val, Q3d)) | |
1037 CTB_ERROR ("Unrecognized toolbar blank style"); | |
1038 | |
1039 return Q_style; | |
1040 } | |
1041 else if (EQ (key, Q_size)) | |
1042 { | |
1043 if (!NATNUMP (val)) | |
1044 CTB_ERROR ("invalid toolbar blank size"); | |
1045 } | |
1046 else | |
1047 { | |
1048 CTB_ERROR ("invalid toolbar blank keyword"); | |
1049 } | |
1050 | |
1051 return Qt; | |
1052 } | |
1053 | |
1054 /* toolbar button spec is [pixmap-pair function enabled-p help] | |
1055 or [:style 2d-or-3d :size width-or-height] */ | |
1056 | |
1057 DEFUN ("check-toolbar-button-syntax", Fcheck_toolbar_button_syntax, 1, 2, 0, /* | |
1058 Verify the syntax of entry BUTTON in a toolbar description list. | |
1059 If you want to verify the syntax of a toolbar description list as a | |
3025 | 1060 whole, use `check-valid-instantiator' with a specifier type of `toolbar'. |
428 | 1061 */ |
444 | 1062 (button, noerror)) |
428 | 1063 { |
1064 Lisp_Object *elt, glyphs, value; | |
1065 int len; | |
578 | 1066 Error_Behavior errb = decode_error_behavior_flag (noerror); |
428 | 1067 |
1068 if (!VECTORP (button)) | |
1069 CTB_ERROR ("toolbar button descriptors must be vectors"); | |
1070 elt = XVECTOR_DATA (button); | |
1071 | |
1072 if (XVECTOR_LENGTH (button) == 2) | |
1073 { | |
1074 if (!EQ (Q_style, check_toolbar_button_keywords (button, elt[0], | |
1075 elt[1], errb))) | |
1076 CTB_ERROR ("must specify toolbar blank style"); | |
1077 | |
1078 return Qt; | |
1079 } | |
1080 | |
1081 if (XVECTOR_LENGTH (button) != 4) | |
1082 CTB_ERROR ("toolbar button descriptors must be 2 or 4 long"); | |
1083 | |
1084 /* The first element must be a list of glyphs of length 1-6. The | |
1085 first entry is the pixmap for the up state, the second for the | |
1086 down state, the third for the disabled state, the fourth for the | |
1087 captioned up state, the fifth for the captioned down state and | |
1088 the sixth for the captioned disabled state. Only the up state is | |
1089 mandatory. */ | |
1090 if (!CONSP (elt[0])) | |
1091 { | |
1092 /* We can't check the buffer-local here because we don't know | |
442 | 1093 which buffer to check in. #### I think this is a bad thing. |
1094 See if we can't get enough information to this function so | |
1095 that it can check. | |
428 | 1096 |
1097 #### Wrong. We shouldn't be checking the value at all here. | |
1098 The user might set or change the value at any time. */ | |
1099 value = Fsymbol_value (elt[0]); | |
1100 | |
1101 if (!CONSP (value)) | |
1102 { | |
1103 if (KEYWORDP (elt[0])) | |
1104 { | |
1105 int fsty = 0; | |
1106 | |
1107 if (EQ (Q_style, check_toolbar_button_keywords (button, elt[0], | |
1108 elt[1], | |
1109 errb))) | |
1110 fsty++; | |
1111 | |
1112 if (EQ (Q_style, check_toolbar_button_keywords (button, elt[2], | |
1113 elt[3], | |
1114 errb))) | |
1115 fsty++; | |
1116 | |
1117 if (!fsty) | |
1118 CTB_ERROR ("must specify toolbar blank style"); | |
1119 else if (EQ (elt[0], elt[2])) | |
1120 CTB_ERROR | |
1121 ("duplicate keywords in toolbar button blank description"); | |
1122 | |
1123 return Qt; | |
1124 } | |
1125 else | |
1126 CTB_ERROR ("first element of button must be a list (of glyphs)"); | |
1127 } | |
1128 } | |
1129 else | |
1130 value = elt[0]; | |
1131 | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1132 len = XFIXNUM (Flength (value)); |
428 | 1133 if (len < 1) |
1134 CTB_ERROR ("toolbar button glyph list must have at least 1 entry"); | |
1135 | |
1136 if (len > 6) | |
1137 CTB_ERROR ("toolbar button glyph list can have at most 6 entries"); | |
1138 | |
1139 glyphs = value; | |
1140 while (!NILP (glyphs)) | |
1141 { | |
1142 if (!GLYPHP (XCAR (glyphs))) | |
1143 { | |
1144 /* We allow nil for the down and disabled glyphs but not for | |
1145 the up glyph. */ | |
1146 if (EQ (glyphs, value) || !NILP (XCAR (glyphs))) | |
1147 { | |
1148 CTB_ERROR | |
1149 ("all elements of toolbar button glyph list must be glyphs."); | |
1150 } | |
1151 } | |
1152 glyphs = XCDR (glyphs); | |
1153 } | |
1154 | |
1155 /* The second element is the function to run when the button is | |
1156 activated. We do not do any checking on it because it is legal | |
1157 for the function to not be defined until after the toolbar is. | |
1158 It is the user's problem to get this right. | |
1159 | |
1160 The third element is either a boolean indicating the enabled | |
1161 status or a function used to determine it. Again, it is the | |
1162 user's problem if this is wrong. | |
1163 | |
1164 The fourth element, if not nil, must be a string which will be | |
1165 displayed as the help echo. */ | |
1166 | |
1167 /* #### This should be allowed to be a function returning a string | |
1168 as well as just a string. */ | |
1169 if (!NILP (elt[3]) && !STRINGP (elt[3])) | |
1170 CTB_ERROR ("toolbar button help echo string must be a string"); | |
1171 | |
1172 return Qt; | |
1173 } | |
1174 #undef CTB_ERROR | |
1175 | |
1176 static void | |
1177 toolbar_validate (Lisp_Object instantiator) | |
1178 { | |
1179 int pushright_seen = 0; | |
1180 Lisp_Object rest; | |
1181 | |
1182 if (NILP (instantiator)) | |
1183 return; | |
1184 | |
1185 if (!CONSP (instantiator)) | |
563 | 1186 sferror ("Toolbar spec must be list or nil", instantiator); |
428 | 1187 |
1188 for (rest = instantiator; !NILP (rest); rest = XCDR (rest)) | |
1189 { | |
1190 if (!CONSP (rest)) | |
563 | 1191 sferror ("Bad list in toolbar spec", instantiator); |
428 | 1192 |
1193 if (NILP (XCAR (rest))) | |
1194 { | |
1195 if (pushright_seen) | |
563 | 1196 sferror |
1197 ("More than one partition (nil) in instantiator description", | |
1198 instantiator); | |
428 | 1199 else |
1200 pushright_seen = 1; | |
1201 } | |
1202 else | |
1203 Fcheck_toolbar_button_syntax (XCAR (rest), Qnil); | |
1204 } | |
1205 } | |
1206 | |
1207 static void | |
2286 | 1208 toolbar_after_change (Lisp_Object UNUSED (specifier), |
1209 Lisp_Object UNUSED (locale)) | |
428 | 1210 { |
1211 /* #### This is overkill. I really need to rethink the after-change | |
1212 functions to make them easier to use. */ | |
1213 MARK_TOOLBAR_CHANGED; | |
1214 } | |
1215 | |
1216 DEFUN ("toolbar-specifier-p", Ftoolbar_specifier_p, 1, 1, 0, /* | |
1217 Return non-nil if OBJECT is a toolbar specifier. | |
1218 | |
442 | 1219 See `make-toolbar-specifier' for a description of possible toolbar |
1220 instantiators. | |
428 | 1221 */ |
1222 (object)) | |
1223 { | |
1224 return TOOLBAR_SPECIFIERP (object) ? Qt : Qnil; | |
1225 } | |
1226 | |
1227 | |
1228 /* | |
1229 Helper for invalidating the real specifier when default | |
1230 specifier caching changes | |
1231 */ | |
1232 static void | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1233 recompute_overlaying_specifier (Lisp_Object real_one[NUM_EDGES]) |
428 | 1234 { |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1235 enum edge_pos pos = decode_toolbar_position (Vdefault_toolbar_position); |
428 | 1236 Fset_specifier_dirty_flag (real_one[pos]); |
1237 } | |
1238 | |
1239 static void | |
2286 | 1240 toolbar_specs_changed (Lisp_Object UNUSED (specifier), |
1241 struct window *UNUSED (w), | |
1242 Lisp_Object UNUSED (oldval)) | |
428 | 1243 { |
1244 /* This could be smarter but I doubt that it would make any | |
1245 noticeable difference given the infrequency with which this is | |
1246 probably going to be called. | |
1247 */ | |
1248 MARK_TOOLBAR_CHANGED; | |
1249 } | |
1250 | |
1251 static void | |
2286 | 1252 default_toolbar_specs_changed (Lisp_Object UNUSED (specifier), |
1253 struct window *UNUSED (w), | |
1254 Lisp_Object UNUSED (oldval)) | |
428 | 1255 { |
1256 recompute_overlaying_specifier (Vtoolbar); | |
1257 } | |
1258 | |
1259 static void | |
2286 | 1260 default_toolbar_size_changed_in_frame (Lisp_Object UNUSED (specifier), |
1261 struct frame *UNUSED (f), | |
1262 Lisp_Object UNUSED (oldval)) | |
428 | 1263 { |
1264 recompute_overlaying_specifier (Vtoolbar_size); | |
1265 } | |
1266 | |
1267 static void | |
2286 | 1268 default_toolbar_border_width_changed_in_frame (Lisp_Object UNUSED (specifier), |
1269 struct frame *UNUSED (f), | |
1270 Lisp_Object UNUSED (oldval)) | |
428 | 1271 { |
1272 recompute_overlaying_specifier (Vtoolbar_border_width); | |
1273 } | |
1274 | |
1275 static void | |
2286 | 1276 default_toolbar_visible_p_changed_in_frame (Lisp_Object UNUSED (specifier), |
1277 struct frame *UNUSED (f), | |
1278 Lisp_Object UNUSED (oldval)) | |
428 | 1279 { |
1280 recompute_overlaying_specifier (Vtoolbar_visible_p); | |
1281 } | |
1282 | |
1283 static void | |
2286 | 1284 toolbar_geometry_changed_in_window (Lisp_Object UNUSED (specifier), |
1285 struct window *w, | |
1286 Lisp_Object UNUSED (oldval)) | |
428 | 1287 { |
1288 MARK_TOOLBAR_CHANGED; | |
1289 MARK_WINDOWS_CHANGED (w); | |
1290 } | |
1291 | |
1292 static void | |
2286 | 1293 default_toolbar_size_changed_in_window (Lisp_Object UNUSED (specifier), |
1294 struct window *UNUSED (w), | |
1295 Lisp_Object UNUSED (oldval)) | |
428 | 1296 { |
1297 recompute_overlaying_specifier (Vtoolbar_size); | |
1298 } | |
1299 | |
1300 static void | |
2286 | 1301 default_toolbar_border_width_changed_in_window (Lisp_Object UNUSED (specifier), |
1302 struct window *UNUSED (w), | |
1303 Lisp_Object UNUSED (oldval)) | |
428 | 1304 { |
1305 recompute_overlaying_specifier (Vtoolbar_border_width); | |
1306 } | |
1307 | |
1308 static void | |
2286 | 1309 default_toolbar_visible_p_changed_in_window (Lisp_Object UNUSED (specifier), |
1310 struct window *UNUSED (w), | |
1311 Lisp_Object UNUSED (oldval)) | |
428 | 1312 { |
1313 recompute_overlaying_specifier (Vtoolbar_visible_p); | |
1314 } | |
1315 | |
1316 static void | |
2286 | 1317 toolbar_buttons_captioned_p_changed (Lisp_Object UNUSED (specifier), |
1318 struct window *UNUSED (w), | |
1319 Lisp_Object UNUSED (oldval)) | |
428 | 1320 { |
1321 /* This could be smarter but I doubt that it would make any | |
1322 noticeable difference given the infrequency with which this is | |
1323 probably going to be called. */ | |
1324 MARK_TOOLBAR_CHANGED; | |
1325 } | |
1326 | |
744 | 1327 static void |
2286 | 1328 toolbar_shadows_changed (Lisp_Object UNUSED (specifier), |
1329 struct window *w, | |
1330 Lisp_Object UNUSED (oldval)) | |
744 | 1331 { |
1332 struct frame *f = XFRAME (w->frame); | |
1333 | |
1334 if (!f->frame_data) | |
1335 { | |
1336 /* If there is not frame data yet, we need to get the hell out | |
1337 ** of here. This can happen when the initial frame is being | |
1338 ** created and we set our specifiers internally. | |
1339 */ | |
1340 return; | |
1341 } | |
1342 MAYBE_DEVMETH (XDEVICE (f->device), redraw_frame_toolbars, (f)); | |
1343 } | |
1344 | |
428 | 1345 |
1346 void | |
1347 syms_of_toolbar (void) | |
1348 { | |
5117
3742ea8250b5
Checking in final CVS version of workspace 'ben-lisp-object'
Ben Wing <ben@xemacs.org>
parents:
3025
diff
changeset
|
1349 INIT_LISP_OBJECT (toolbar_button); |
442 | 1350 |
563 | 1351 DEFSYMBOL_MULTIWORD_PREDICATE (Qtoolbar_buttonp); |
1352 DEFSYMBOL (Q2D); | |
1353 DEFSYMBOL (Q3D); | |
1354 DEFSYMBOL (Q2d); | |
1355 DEFSYMBOL (Q3d); | |
1356 DEFKEYWORD (Q_size); | |
428 | 1357 |
563 | 1358 DEFSYMBOL (Qinit_toolbar_from_resources); |
428 | 1359 DEFSUBR (Ftoolbar_button_p); |
1360 DEFSUBR (Ftoolbar_button_callback); | |
1361 DEFSUBR (Ftoolbar_button_help_string); | |
1362 DEFSUBR (Ftoolbar_button_enabled_p); | |
1363 DEFSUBR (Fset_toolbar_button_down_flag); | |
1364 DEFSUBR (Fcheck_toolbar_button_syntax); | |
1365 DEFSUBR (Fset_default_toolbar_position); | |
1366 DEFSUBR (Fdefault_toolbar_position); | |
1367 DEFSUBR (Ftoolbar_specifier_p); | |
1368 } | |
1369 | |
1370 void | |
1371 vars_of_toolbar (void) | |
1372 { | |
1373 staticpro (&Vdefault_toolbar_position); | |
1374 Vdefault_toolbar_position = Qtop; | |
1375 | |
1376 #ifdef HAVE_WINDOW_SYSTEM | |
1377 Fprovide (Qtoolbar); | |
1378 #endif | |
1379 } | |
1380 | |
1381 void | |
1382 specifier_type_create_toolbar (void) | |
1383 { | |
1384 INITIALIZE_SPECIFIER_TYPE (toolbar, "toolbar", "toolbar-specifier-p"); | |
1385 | |
1386 SPECIFIER_HAS_METHOD (toolbar, validate); | |
1387 SPECIFIER_HAS_METHOD (toolbar, after_change); | |
1388 } | |
1389 | |
1390 void | |
1391 reinit_specifier_type_create_toolbar (void) | |
1392 { | |
1393 REINITIALIZE_SPECIFIER_TYPE (toolbar); | |
1394 } | |
1395 | |
1396 void | |
1397 specifier_vars_of_toolbar (void) | |
1398 { | |
1399 Lisp_Object fb; | |
1400 | |
1401 DEFVAR_SPECIFIER ("default-toolbar", &Vdefault_toolbar /* | |
1402 Specifier for a fallback toolbar. | |
1403 Use `set-specifier' to change this. | |
1404 | |
1405 The position of this toolbar is specified in the function | |
1406 `default-toolbar-position'. If the corresponding position-specific | |
3025 | 1407 toolbar (e.g. `top-toolbar' if `default-toolbar-position' is `top') |
428 | 1408 does not specify a toolbar in a particular domain (usually a window), |
1409 then the value of `default-toolbar' in that domain, if any, will be | |
1410 used instead. | |
1411 | |
1412 Note that the toolbar at any particular position will not be | |
1413 displayed unless its visibility flag is true and its thickness | |
1414 \(width or height, depending on orientation) is non-zero. The | |
1415 visibility is controlled by the specifiers `top-toolbar-visible-p', | |
1416 `bottom-toolbar-visible-p', `left-toolbar-visible-p', and | |
1417 `right-toolbar-visible-p', and the thickness is controlled by the | |
1418 specifiers `top-toolbar-height', `bottom-toolbar-height', | |
1419 `left-toolbar-width', and `right-toolbar-width'. | |
1420 | |
1421 Note that one of the four visibility specifiers inherits from | |
1422 `default-toolbar-visibility' and one of the four thickness | |
1423 specifiers inherits from either `default-toolbar-width' or | |
1424 `default-toolbar-height' (depending on orientation), just | |
1425 like for the toolbar description specifiers (e.g. `top-toolbar') | |
1426 mentioned above. | |
1427 | |
1428 Therefore, if you are setting `default-toolbar', you should control | |
1429 the visibility and thickness using `default-toolbar-visible-p', | |
1430 `default-toolbar-width', and `default-toolbar-height', rather than | |
1431 using position-specific specifiers. That way, you will get sane | |
1432 behavior if the user changes the default toolbar position. | |
1433 | |
1434 The format of the instantiator for a toolbar is a list of | |
1435 toolbar-button-descriptors. Each toolbar-button-descriptor | |
1436 is a vector in one of the following formats: | |
1437 | |
1438 [GLYPH-LIST FUNCTION ENABLED-P HELP] or | |
1439 [:style 2D-OR-3D] or | |
1440 [:style 2D-OR-3D :size WIDTH-OR-HEIGHT] or | |
1441 [:size WIDTH-OR-HEIGHT :style 2D-OR-3D] | |
1442 | |
1443 Optionally, one of the toolbar-button-descriptors may be nil | |
1444 instead of a vector; this signifies the division between | |
1445 the toolbar buttons that are to be displayed flush-left, | |
1446 and the buttons to be displayed flush-right. | |
1447 | |
1448 The first vector format above specifies a normal toolbar button; | |
1449 the others specify blank areas in the toolbar. | |
1450 | |
1451 For the first vector format: | |
1452 | |
1453 -- GLYPH-LIST should be a list of one to six glyphs (as created by | |
1454 `make-glyph') or a symbol whose value is such a list. The first | |
1455 glyph, which must be provided, is the glyph used to display the | |
1456 toolbar button when it is in the "up" (not pressed) state. The | |
1457 optional second glyph is for displaying the button when it is in | |
1458 the "down" (pressed) state. The optional third glyph is for when | |
1459 the button is disabled. The optional fourth, fifth and sixth glyphs | |
1460 are used to specify captioned versions for the up, down and disabled | |
1461 states respectively. The function `toolbar-make-button-list' is | |
1462 useful in creating these glyph lists. The specifier variable | |
1463 `toolbar-buttons-captioned-p' controls which glyphs are actually used. | |
1464 | |
1465 -- Even if you do not provide separate down-state and disabled-state | |
1466 glyphs, the user will still get visual feedback to indicate which | |
1467 state the button is in. Buttons in the up-state are displayed | |
1468 with a shadowed border that gives a raised appearance to the | |
1469 button. Buttons in the down-state are displayed with shadows that | |
1470 give a recessed appearance. Buttons in the disabled state are | |
1471 displayed with no shadows, giving a 2-d effect. | |
1472 | |
1473 -- If some of the toolbar glyphs are not provided, they inherit as follows: | |
1474 | |
1475 UP: up | |
1476 DOWN: down -> up | |
1477 DISABLED: disabled -> up | |
1478 CAP-UP: cap-up -> up | |
1479 CAP-DOWN: cap-down -> cap-up -> down -> up | |
1480 CAP-DISABLED: cap-disabled -> cap-up -> disabled -> up | |
1481 | |
1482 -- The second element FUNCTION is a function to be called when the | |
1483 toolbar button is activated (i.e. when the mouse is released over | |
1484 the toolbar button, if the press occurred in the toolbar). It | |
1485 can be any form accepted by `call-interactively', since this is | |
1486 how it is invoked. | |
1487 | |
1488 -- The third element ENABLED-P specifies whether the toolbar button | |
1489 is enabled (disabled buttons do nothing when they are activated, | |
1490 and are displayed differently; see above). It should be either | |
1491 a boolean or a form that evaluates to a boolean. | |
1492 | |
1493 -- The fourth element HELP, if non-nil, should be a string. This | |
1494 string is displayed in the echo area when the mouse passes over | |
1495 the toolbar button. | |
1496 | |
1497 For the other vector formats (specifying blank areas of the toolbar): | |
1498 | |
3025 | 1499 -- 2D-OR-3D should be one of the symbols `2d' or `3d', indicating |
428 | 1500 whether the area is displayed with shadows (giving it a raised, |
1501 3-d appearance) or without shadows (giving it a flat appearance). | |
1502 | |
1503 -- WIDTH-OR-HEIGHT specifies the length, in pixels, of the blank | |
1504 area. If omitted, it defaults to a device-specific value | |
1505 (8 pixels for X devices). | |
1506 */ ); | |
1507 | |
1508 Vdefault_toolbar = Fmake_specifier (Qtoolbar); | |
1509 /* #### It would be even nicer if the specifier caching | |
1510 automatically knew about specifier fallbacks, so we didn't | |
1511 have to do it ourselves. */ | |
1512 set_specifier_caching (Vdefault_toolbar, | |
438 | 1513 offsetof (struct window, default_toolbar), |
428 | 1514 default_toolbar_specs_changed, |
444 | 1515 0, 0, 0); |
428 | 1516 |
1517 DEFVAR_SPECIFIER ("top-toolbar", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1518 &Vtoolbar[TOP_EDGE] /* |
428 | 1519 Specifier for the toolbar at the top of the frame. |
1520 Use `set-specifier' to change this. | |
1521 See `default-toolbar' for a description of a valid toolbar instantiator. | |
1522 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1523 Vtoolbar[TOP_EDGE] = Fmake_specifier (Qtoolbar); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1524 set_specifier_caching (Vtoolbar[TOP_EDGE], |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1525 offsetof (struct window, toolbar[TOP_EDGE]), |
428 | 1526 toolbar_specs_changed, |
444 | 1527 0, 0, 0); |
428 | 1528 |
1529 DEFVAR_SPECIFIER ("bottom-toolbar", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1530 &Vtoolbar[BOTTOM_EDGE] /* |
428 | 1531 Specifier for the toolbar at the bottom of the frame. |
1532 Use `set-specifier' to change this. | |
1533 See `default-toolbar' for a description of a valid toolbar instantiator. | |
1534 | |
1535 Note that, unless the `default-toolbar-position' is `bottom', by | |
1536 default the height of the bottom toolbar (controlled by | |
1537 `bottom-toolbar-height') is 0; thus, a bottom toolbar will not be | |
1538 displayed even if you provide a value for `bottom-toolbar'. | |
1539 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1540 Vtoolbar[BOTTOM_EDGE] = Fmake_specifier (Qtoolbar); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1541 set_specifier_caching (Vtoolbar[BOTTOM_EDGE], |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1542 offsetof (struct window, toolbar[BOTTOM_EDGE]), |
428 | 1543 toolbar_specs_changed, |
444 | 1544 0, 0, 0); |
428 | 1545 |
1546 DEFVAR_SPECIFIER ("left-toolbar", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1547 &Vtoolbar[LEFT_EDGE] /* |
428 | 1548 Specifier for the toolbar at the left edge of the frame. |
1549 Use `set-specifier' to change this. | |
1550 See `default-toolbar' for a description of a valid toolbar instantiator. | |
1551 | |
1552 Note that, unless the `default-toolbar-position' is `left', by | |
1553 default the height of the left toolbar (controlled by | |
1554 `left-toolbar-width') is 0; thus, a left toolbar will not be | |
1555 displayed even if you provide a value for `left-toolbar'. | |
1556 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1557 Vtoolbar[LEFT_EDGE] = Fmake_specifier (Qtoolbar); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1558 set_specifier_caching (Vtoolbar[LEFT_EDGE], |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1559 offsetof (struct window, toolbar[LEFT_EDGE]), |
428 | 1560 toolbar_specs_changed, |
444 | 1561 0, 0, 0); |
428 | 1562 |
1563 DEFVAR_SPECIFIER ("right-toolbar", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1564 &Vtoolbar[RIGHT_EDGE] /* |
428 | 1565 Specifier for the toolbar at the right edge of the frame. |
1566 Use `set-specifier' to change this. | |
1567 See `default-toolbar' for a description of a valid toolbar instantiator. | |
1568 | |
1569 Note that, unless the `default-toolbar-position' is `right', by | |
1570 default the height of the right toolbar (controlled by | |
1571 `right-toolbar-width') is 0; thus, a right toolbar will not be | |
1572 displayed even if you provide a value for `right-toolbar'. | |
1573 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1574 Vtoolbar[RIGHT_EDGE] = Fmake_specifier (Qtoolbar); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1575 set_specifier_caching (Vtoolbar[RIGHT_EDGE], |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1576 offsetof (struct window, toolbar[RIGHT_EDGE]), |
428 | 1577 toolbar_specs_changed, |
444 | 1578 0, 0, 0); |
428 | 1579 |
1580 /* initially, top inherits from default; this can be | |
1581 changed with `set-default-toolbar-position'. */ | |
1582 fb = list1 (Fcons (Qnil, Qnil)); | |
1583 set_specifier_fallback (Vdefault_toolbar, fb); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1584 set_specifier_fallback (Vtoolbar[TOP_EDGE], Vdefault_toolbar); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1585 set_specifier_fallback (Vtoolbar[BOTTOM_EDGE], fb); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1586 set_specifier_fallback (Vtoolbar[LEFT_EDGE], fb); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1587 set_specifier_fallback (Vtoolbar[RIGHT_EDGE], fb); |
428 | 1588 |
1589 DEFVAR_SPECIFIER ("default-toolbar-height", &Vdefault_toolbar_height /* | |
1590 *Height of the default toolbar, if it's oriented horizontally. | |
1591 This is a specifier; use `set-specifier' to change it. | |
1592 | |
1593 The position of the default toolbar is specified by the function | |
1594 `set-default-toolbar-position'. If the corresponding position-specific | |
1595 toolbar thickness specifier (e.g. `top-toolbar-height' if | |
3025 | 1596 `default-toolbar-position' is `top') does not specify a thickness in a |
428 | 1597 particular domain (a window or a frame), then the value of |
1598 `default-toolbar-height' or `default-toolbar-width' (depending on the | |
1599 toolbar orientation) in that domain, if any, will be used instead. | |
1600 | |
1601 Note that `default-toolbar-height' is only used when | |
3025 | 1602 `default-toolbar-position' is `top' or `bottom', and `default-toolbar-width' |
1603 is only used when `default-toolbar-position' is `left' or `right'. | |
428 | 1604 |
1605 Note that all of the position-specific toolbar thickness specifiers | |
1606 have a fallback value of zero when they do not correspond to the | |
1607 default toolbar. Therefore, you will have to set a non-zero thickness | |
1608 value if you want a position-specific toolbar to be displayed. | |
1609 | |
1610 Internally, toolbar thickness specifiers are instantiated in both | |
1611 window and frame domains, for different purposes. The value in the | |
1612 domain of a frame's selected window specifies the actual toolbar | |
1613 thickness that you will see in that frame. The value in the domain of | |
1614 a frame itself specifies the toolbar thickness that is used in frame | |
1615 geometry calculations. | |
1616 | |
1617 Thus, for example, if you set the frame width to 80 characters and the | |
1618 left toolbar width for that frame to 68 pixels, then the frame will | |
1619 be sized to fit 80 characters plus a 68-pixel left toolbar. If you | |
1620 then set the left toolbar width to 0 for a particular buffer (or if | |
1621 that buffer does not specify a left toolbar or has a nil value | |
1622 specified for `left-toolbar-visible-p'), you will find that, when | |
1623 that buffer is displayed in the selected window, the window will have | |
1624 a width of 86 or 87 characters -- the frame is sized for a 68-pixel | |
1625 left toolbar but the selected window specifies that the left toolbar | |
1626 is not visible, so it is expanded to take up the slack. | |
1627 */ ); | |
1628 Vdefault_toolbar_height = Fmake_specifier (Qnatnum); | |
1629 set_specifier_caching (Vdefault_toolbar_height, | |
438 | 1630 offsetof (struct window, default_toolbar_height), |
428 | 1631 default_toolbar_size_changed_in_window, |
438 | 1632 offsetof (struct frame, default_toolbar_height), |
444 | 1633 default_toolbar_size_changed_in_frame, 0); |
428 | 1634 |
1635 DEFVAR_SPECIFIER ("default-toolbar-width", &Vdefault_toolbar_width /* | |
1636 *Width of the default toolbar, if it's oriented vertically. | |
1637 This is a specifier; use `set-specifier' to change it. | |
1638 | |
1639 See `default-toolbar-height' for more information. | |
1640 */ ); | |
1641 Vdefault_toolbar_width = Fmake_specifier (Qnatnum); | |
1642 set_specifier_caching (Vdefault_toolbar_width, | |
438 | 1643 offsetof (struct window, default_toolbar_width), |
428 | 1644 default_toolbar_size_changed_in_window, |
438 | 1645 offsetof (struct frame, default_toolbar_width), |
444 | 1646 default_toolbar_size_changed_in_frame, 0); |
428 | 1647 |
1648 DEFVAR_SPECIFIER ("top-toolbar-height", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1649 &Vtoolbar_size[TOP_EDGE] /* |
428 | 1650 *Height of the top toolbar. |
1651 This is a specifier; use `set-specifier' to change it. | |
1652 | |
1653 See `default-toolbar-height' for more information. | |
1654 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1655 Vtoolbar_size[TOP_EDGE] = Fmake_specifier (Qnatnum); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1656 set_specifier_caching (Vtoolbar_size[TOP_EDGE], |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1657 offsetof (struct window, toolbar_size[TOP_EDGE]), |
428 | 1658 toolbar_geometry_changed_in_window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1659 offsetof (struct frame, toolbar_size[TOP_EDGE]), |
444 | 1660 frame_size_slipped, 0); |
428 | 1661 |
1662 DEFVAR_SPECIFIER ("bottom-toolbar-height", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1663 &Vtoolbar_size[BOTTOM_EDGE] /* |
428 | 1664 *Height of the bottom toolbar. |
1665 This is a specifier; use `set-specifier' to change it. | |
1666 | |
1667 See `default-toolbar-height' for more information. | |
1668 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1669 Vtoolbar_size[BOTTOM_EDGE] = Fmake_specifier (Qnatnum); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1670 set_specifier_caching (Vtoolbar_size[BOTTOM_EDGE], |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1671 offsetof (struct window, toolbar_size[BOTTOM_EDGE]), |
428 | 1672 toolbar_geometry_changed_in_window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1673 offsetof (struct frame, toolbar_size[BOTTOM_EDGE]), |
444 | 1674 frame_size_slipped, 0); |
428 | 1675 |
1676 DEFVAR_SPECIFIER ("left-toolbar-width", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1677 &Vtoolbar_size[LEFT_EDGE] /* |
428 | 1678 *Width of left toolbar. |
1679 This is a specifier; use `set-specifier' to change it. | |
1680 | |
1681 See `default-toolbar-height' for more information. | |
1682 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1683 Vtoolbar_size[LEFT_EDGE] = Fmake_specifier (Qnatnum); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1684 set_specifier_caching (Vtoolbar_size[LEFT_EDGE], |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1685 offsetof (struct window, toolbar_size[LEFT_EDGE]), |
428 | 1686 toolbar_geometry_changed_in_window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1687 offsetof (struct frame, toolbar_size[LEFT_EDGE]), |
444 | 1688 frame_size_slipped, 0); |
428 | 1689 |
1690 DEFVAR_SPECIFIER ("right-toolbar-width", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1691 &Vtoolbar_size[RIGHT_EDGE] /* |
428 | 1692 *Width of right toolbar. |
1693 This is a specifier; use `set-specifier' to change it. | |
1694 | |
1695 See `default-toolbar-height' for more information. | |
1696 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1697 Vtoolbar_size[RIGHT_EDGE] = Fmake_specifier (Qnatnum); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1698 set_specifier_caching (Vtoolbar_size[RIGHT_EDGE], |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1699 offsetof (struct window, toolbar_size[RIGHT_EDGE]), |
428 | 1700 toolbar_geometry_changed_in_window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1701 offsetof (struct frame, toolbar_size[RIGHT_EDGE]), |
444 | 1702 frame_size_slipped, 0); |
428 | 1703 |
744 | 1704 DEFVAR_SPECIFIER ("toolbar-shadow-thickness", |
1705 &Vtoolbar_shadow_thickness /* | |
1706 *Width of shadows around toolbar buttons. | |
1707 This is a specifier; use `set-specifier' to change it. | |
1708 */ ); | |
1709 Vtoolbar_shadow_thickness = Fmake_specifier (Qnatnum); | |
1710 set_specifier_caching(Vtoolbar_shadow_thickness, | |
1711 offsetof (struct window, toolbar_shadow_thickness), | |
1712 toolbar_shadows_changed, | |
1713 0,0, 0); | |
1714 | |
1715 fb = Qnil; | |
1716 | |
1717 #ifdef HAVE_TTY | |
1718 fb = Fcons (Fcons (list1 (Qtty), Qzero), fb); | |
1719 #endif | |
1720 #ifdef HAVE_GTK | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1721 fb = Fcons (Fcons (list1 (Qgtk), make_fixnum (2)), fb); |
744 | 1722 #endif |
1723 #ifdef HAVE_X_WINDOWS | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1724 fb = Fcons (Fcons (list1 (Qx), make_fixnum (2)), fb); |
744 | 1725 #endif |
1726 #ifdef HAVE_MS_WINDOWS | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1727 fb = Fcons (Fcons (list1 (Qmswindows), make_fixnum (2)), fb); |
744 | 1728 #endif |
1729 | |
1730 if (!NILP (fb)) | |
1731 set_specifier_fallback (Vtoolbar_shadow_thickness, fb); | |
1732 | |
428 | 1733 fb = Qnil; |
1734 #ifdef HAVE_TTY | |
1735 fb = Fcons (Fcons (list1 (Qtty), Qzero), fb); | |
1736 #endif | |
462 | 1737 #ifdef HAVE_GTK |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1738 fb = Fcons (Fcons (list1 (Qgtk), make_fixnum (DEFAULT_TOOLBAR_HEIGHT)), fb); |
462 | 1739 #endif |
428 | 1740 #ifdef HAVE_X_WINDOWS |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1741 fb = Fcons (Fcons (list1 (Qx), make_fixnum (DEFAULT_TOOLBAR_HEIGHT)), fb); |
428 | 1742 #endif |
1743 #ifdef HAVE_MS_WINDOWS | |
442 | 1744 fb = Fcons (Fcons (list1 (Qmswindows), |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1745 make_fixnum (MSWINDOWS_DEFAULT_TOOLBAR_HEIGHT)), fb); |
428 | 1746 #endif |
1747 if (!NILP (fb)) | |
1748 set_specifier_fallback (Vdefault_toolbar_height, fb); | |
1749 | |
1750 fb = Qnil; | |
1751 #ifdef HAVE_TTY | |
1752 fb = Fcons (Fcons (list1 (Qtty), Qzero), fb); | |
1753 #endif | |
462 | 1754 #ifdef HAVE_GTK |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1755 fb = Fcons (Fcons (list1 (Qgtk), make_fixnum (DEFAULT_TOOLBAR_WIDTH)), fb); |
462 | 1756 #endif |
428 | 1757 #ifdef HAVE_X_WINDOWS |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1758 fb = Fcons (Fcons (list1 (Qx), make_fixnum (DEFAULT_TOOLBAR_WIDTH)), fb); |
428 | 1759 #endif |
1760 #ifdef HAVE_MS_WINDOWS | |
442 | 1761 fb = Fcons (Fcons (list1 (Qmswindows), |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1762 make_fixnum (MSWINDOWS_DEFAULT_TOOLBAR_WIDTH)), fb); |
428 | 1763 #endif |
1764 if (!NILP (fb)) | |
1765 set_specifier_fallback (Vdefault_toolbar_width, fb); | |
1766 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1767 set_specifier_fallback (Vtoolbar_size[TOP_EDGE], Vdefault_toolbar_height); |
428 | 1768 fb = list1 (Fcons (Qnil, Qzero)); |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1769 set_specifier_fallback (Vtoolbar_size[BOTTOM_EDGE], fb); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1770 set_specifier_fallback (Vtoolbar_size[LEFT_EDGE], fb); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1771 set_specifier_fallback (Vtoolbar_size[RIGHT_EDGE], fb); |
428 | 1772 |
1773 DEFVAR_SPECIFIER ("default-toolbar-border-width", | |
1774 &Vdefault_toolbar_border_width /* | |
1775 *Width of the border around the default toolbar. | |
1776 This is a specifier; use `set-specifier' to change it. | |
1777 | |
1778 The position of the default toolbar is specified by the function | |
1779 `set-default-toolbar-position'. If the corresponding position-specific | |
1780 toolbar border width specifier (e.g. `top-toolbar-border-width' if | |
3025 | 1781 `default-toolbar-position' is `top') does not specify a border width in a |
428 | 1782 particular domain (a window or a frame), then the value of |
1783 `default-toolbar-border-width' in that domain, if any, will be used | |
1784 instead. | |
1785 | |
1786 Internally, toolbar border width specifiers are instantiated in both | |
1787 window and frame domains, for different purposes. The value in the | |
1788 domain of a frame's selected window specifies the actual toolbar border | |
1789 width that you will see in that frame. The value in the domain of a | |
1790 frame itself specifies the toolbar border width that is used in frame | |
1791 geometry calculations. Changing the border width value in the frame | |
1792 domain will result in a size change in the frame itself, while changing | |
1793 the value in a window domain will not. | |
1794 */ ); | |
1795 Vdefault_toolbar_border_width = Fmake_specifier (Qnatnum); | |
1796 set_specifier_caching (Vdefault_toolbar_border_width, | |
438 | 1797 offsetof (struct window, default_toolbar_border_width), |
428 | 1798 default_toolbar_border_width_changed_in_window, |
438 | 1799 offsetof (struct frame, default_toolbar_border_width), |
444 | 1800 default_toolbar_border_width_changed_in_frame, 0); |
428 | 1801 |
1802 DEFVAR_SPECIFIER ("top-toolbar-border-width", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1803 &Vtoolbar_border_width[TOP_EDGE] /* |
428 | 1804 *Border width of the top toolbar. |
1805 This is a specifier; use `set-specifier' to change it. | |
1806 | |
1807 See `default-toolbar-height' for more information. | |
1808 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1809 Vtoolbar_border_width[TOP_EDGE] = Fmake_specifier (Qnatnum); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1810 set_specifier_caching (Vtoolbar_border_width[TOP_EDGE], |
438 | 1811 offsetof (struct window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1812 toolbar_border_width[TOP_EDGE]), |
428 | 1813 toolbar_geometry_changed_in_window, |
438 | 1814 offsetof (struct frame, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1815 toolbar_border_width[TOP_EDGE]), |
444 | 1816 frame_size_slipped, 0); |
428 | 1817 |
1818 DEFVAR_SPECIFIER ("bottom-toolbar-border-width", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1819 &Vtoolbar_border_width[BOTTOM_EDGE] /* |
428 | 1820 *Border width of the bottom toolbar. |
1821 This is a specifier; use `set-specifier' to change it. | |
1822 | |
1823 See `default-toolbar-height' for more information. | |
1824 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1825 Vtoolbar_border_width[BOTTOM_EDGE] = Fmake_specifier (Qnatnum); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1826 set_specifier_caching (Vtoolbar_border_width[BOTTOM_EDGE], |
438 | 1827 offsetof (struct window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1828 toolbar_border_width[BOTTOM_EDGE]), |
428 | 1829 toolbar_geometry_changed_in_window, |
438 | 1830 offsetof (struct frame, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1831 toolbar_border_width[BOTTOM_EDGE]), |
444 | 1832 frame_size_slipped, 0); |
428 | 1833 |
1834 DEFVAR_SPECIFIER ("left-toolbar-border-width", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1835 &Vtoolbar_border_width[LEFT_EDGE] /* |
428 | 1836 *Border width of left toolbar. |
1837 This is a specifier; use `set-specifier' to change it. | |
1838 | |
1839 See `default-toolbar-height' for more information. | |
1840 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1841 Vtoolbar_border_width[LEFT_EDGE] = Fmake_specifier (Qnatnum); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1842 set_specifier_caching (Vtoolbar_border_width[LEFT_EDGE], |
438 | 1843 offsetof (struct window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1844 toolbar_border_width[LEFT_EDGE]), |
428 | 1845 toolbar_geometry_changed_in_window, |
438 | 1846 offsetof (struct frame, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1847 toolbar_border_width[LEFT_EDGE]), |
444 | 1848 frame_size_slipped, 0); |
428 | 1849 |
1850 DEFVAR_SPECIFIER ("right-toolbar-border-width", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1851 &Vtoolbar_border_width[RIGHT_EDGE] /* |
428 | 1852 *Border width of right toolbar. |
1853 This is a specifier; use `set-specifier' to change it. | |
1854 | |
1855 See `default-toolbar-height' for more information. | |
1856 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1857 Vtoolbar_border_width[RIGHT_EDGE] = Fmake_specifier (Qnatnum); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1858 set_specifier_caching (Vtoolbar_border_width[RIGHT_EDGE], |
438 | 1859 offsetof (struct window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1860 toolbar_border_width[RIGHT_EDGE]), |
428 | 1861 toolbar_geometry_changed_in_window, |
438 | 1862 offsetof (struct frame, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1863 toolbar_border_width[RIGHT_EDGE]), |
444 | 1864 frame_size_slipped, 0); |
428 | 1865 |
1866 fb = Qnil; | |
1867 #ifdef HAVE_TTY | |
1868 fb = Fcons (Fcons (list1 (Qtty), Qzero), fb); | |
1869 #endif | |
1870 #ifdef HAVE_X_WINDOWS | |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1871 fb = Fcons (Fcons (list1 (Qx), make_fixnum (DEFAULT_TOOLBAR_BORDER_WIDTH)), fb); |
428 | 1872 #endif |
462 | 1873 #ifdef HAVE_GTK |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1874 fb = Fcons (Fcons (list1 (Qgtk), make_fixnum (DEFAULT_TOOLBAR_BORDER_WIDTH)), fb); |
462 | 1875 #endif |
428 | 1876 #ifdef HAVE_MS_WINDOWS |
5581
56144c8593a8
Mechanically change INT to FIXNUM in our sources.
Aidan Kehoe <kehoea@parhasard.net>
parents:
5402
diff
changeset
|
1877 fb = Fcons (Fcons (list1 (Qmswindows), make_fixnum (MSWINDOWS_DEFAULT_TOOLBAR_BORDER_WIDTH)), fb); |
428 | 1878 #endif |
1879 if (!NILP (fb)) | |
1880 set_specifier_fallback (Vdefault_toolbar_border_width, fb); | |
1881 | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1882 set_specifier_fallback (Vtoolbar_border_width[TOP_EDGE], Vdefault_toolbar_border_width); |
428 | 1883 fb = list1 (Fcons (Qnil, Qzero)); |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1884 set_specifier_fallback (Vtoolbar_border_width[BOTTOM_EDGE], fb); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1885 set_specifier_fallback (Vtoolbar_border_width[LEFT_EDGE], fb); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1886 set_specifier_fallback (Vtoolbar_border_width[RIGHT_EDGE], fb); |
428 | 1887 |
1888 DEFVAR_SPECIFIER ("default-toolbar-visible-p", &Vdefault_toolbar_visible_p /* | |
1889 *Whether the default toolbar is visible. | |
1890 This is a specifier; use `set-specifier' to change it. | |
1891 | |
1892 The position of the default toolbar is specified by the function | |
1893 `set-default-toolbar-position'. If the corresponding position-specific | |
1894 toolbar visibility specifier (e.g. `top-toolbar-visible-p' if | |
3025 | 1895 `default-toolbar-position' is `top') does not specify a visible-p value |
428 | 1896 in a particular domain (a window or a frame), then the value of |
1897 `default-toolbar-visible-p' in that domain, if any, will be used | |
1898 instead. | |
1899 | |
1900 Both window domains and frame domains are used internally, for | |
1901 different purposes. The distinction here is exactly the same as | |
1902 for thickness specifiers; see `default-toolbar-height' for more | |
1903 information. | |
1904 | |
1905 `default-toolbar-visible-p' and all of the position-specific toolbar | |
1906 visibility specifiers have a fallback value of true. | |
1907 */ ); | |
1908 Vdefault_toolbar_visible_p = Fmake_specifier (Qboolean); | |
1909 set_specifier_caching (Vdefault_toolbar_visible_p, | |
438 | 1910 offsetof (struct window, default_toolbar_visible_p), |
428 | 1911 default_toolbar_visible_p_changed_in_window, |
438 | 1912 offsetof (struct frame, default_toolbar_visible_p), |
444 | 1913 default_toolbar_visible_p_changed_in_frame, 0); |
428 | 1914 |
1915 DEFVAR_SPECIFIER ("top-toolbar-visible-p", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1916 &Vtoolbar_visible_p[TOP_EDGE] /* |
428 | 1917 *Whether the top toolbar is visible. |
1918 This is a specifier; use `set-specifier' to change it. | |
1919 | |
1920 See `default-toolbar-visible-p' for more information. | |
1921 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1922 Vtoolbar_visible_p[TOP_EDGE] = Fmake_specifier (Qboolean); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1923 set_specifier_caching (Vtoolbar_visible_p[TOP_EDGE], |
438 | 1924 offsetof (struct window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1925 toolbar_visible_p[TOP_EDGE]), |
428 | 1926 toolbar_geometry_changed_in_window, |
438 | 1927 offsetof (struct frame, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1928 toolbar_visible_p[TOP_EDGE]), |
444 | 1929 frame_size_slipped, 0); |
428 | 1930 |
1931 DEFVAR_SPECIFIER ("bottom-toolbar-visible-p", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1932 &Vtoolbar_visible_p[BOTTOM_EDGE] /* |
428 | 1933 *Whether the bottom toolbar is visible. |
1934 This is a specifier; use `set-specifier' to change it. | |
1935 | |
1936 See `default-toolbar-visible-p' for more information. | |
1937 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1938 Vtoolbar_visible_p[BOTTOM_EDGE] = Fmake_specifier (Qboolean); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1939 set_specifier_caching (Vtoolbar_visible_p[BOTTOM_EDGE], |
438 | 1940 offsetof (struct window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1941 toolbar_visible_p[BOTTOM_EDGE]), |
428 | 1942 toolbar_geometry_changed_in_window, |
438 | 1943 offsetof (struct frame, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1944 toolbar_visible_p[BOTTOM_EDGE]), |
444 | 1945 frame_size_slipped, 0); |
428 | 1946 |
1947 DEFVAR_SPECIFIER ("left-toolbar-visible-p", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1948 &Vtoolbar_visible_p[LEFT_EDGE] /* |
428 | 1949 *Whether the left toolbar is visible. |
1950 This is a specifier; use `set-specifier' to change it. | |
1951 | |
1952 See `default-toolbar-visible-p' for more information. | |
1953 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1954 Vtoolbar_visible_p[LEFT_EDGE] = Fmake_specifier (Qboolean); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1955 set_specifier_caching (Vtoolbar_visible_p[LEFT_EDGE], |
438 | 1956 offsetof (struct window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1957 toolbar_visible_p[LEFT_EDGE]), |
428 | 1958 toolbar_geometry_changed_in_window, |
438 | 1959 offsetof (struct frame, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1960 toolbar_visible_p[LEFT_EDGE]), |
444 | 1961 frame_size_slipped, 0); |
428 | 1962 |
1963 DEFVAR_SPECIFIER ("right-toolbar-visible-p", | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1964 &Vtoolbar_visible_p[RIGHT_EDGE] /* |
428 | 1965 *Whether the right toolbar is visible. |
1966 This is a specifier; use `set-specifier' to change it. | |
1967 | |
1968 See `default-toolbar-visible-p' for more information. | |
1969 */ ); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1970 Vtoolbar_visible_p[RIGHT_EDGE] = Fmake_specifier (Qboolean); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1971 set_specifier_caching (Vtoolbar_visible_p[RIGHT_EDGE], |
438 | 1972 offsetof (struct window, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1973 toolbar_visible_p[RIGHT_EDGE]), |
428 | 1974 toolbar_geometry_changed_in_window, |
438 | 1975 offsetof (struct frame, |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1976 toolbar_visible_p[RIGHT_EDGE]), |
444 | 1977 frame_size_slipped, 0); |
428 | 1978 |
1979 /* initially, top inherits from default; this can be | |
1980 changed with `set-default-toolbar-position'. */ | |
1981 fb = list1 (Fcons (Qnil, Qt)); | |
1982 set_specifier_fallback (Vdefault_toolbar_visible_p, fb); | |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1983 set_specifier_fallback (Vtoolbar_visible_p[TOP_EDGE], |
428 | 1984 Vdefault_toolbar_visible_p); |
5077
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1985 set_specifier_fallback (Vtoolbar_visible_p[BOTTOM_EDGE], fb); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1986 set_specifier_fallback (Vtoolbar_visible_p[LEFT_EDGE], fb); |
d372b17f63ce
clean up toolbar/gutter edge geometry
Ben Wing <ben@xemacs.org>
parents:
5043
diff
changeset
|
1987 set_specifier_fallback (Vtoolbar_visible_p[RIGHT_EDGE], fb); |
428 | 1988 |
1989 DEFVAR_SPECIFIER ("toolbar-buttons-captioned-p", | |
1990 &Vtoolbar_buttons_captioned_p /* | |
1991 *Whether the toolbar buttons are captioned. | |
1992 This will only have a visible effect for those toolbar buttons which had | |
1993 captioned versions specified. | |
1994 This is a specifier; use `set-specifier' to change it. | |
1995 */ ); | |
1996 Vtoolbar_buttons_captioned_p = Fmake_specifier (Qboolean); | |
1997 set_specifier_caching (Vtoolbar_buttons_captioned_p, | |
438 | 1998 offsetof (struct window, toolbar_buttons_captioned_p), |
428 | 1999 toolbar_buttons_captioned_p_changed, |
444 | 2000 0, 0, 0); |
428 | 2001 set_specifier_fallback (Vtoolbar_buttons_captioned_p, |
2002 list1 (Fcons (Qnil, Qt))); | |
2003 } |