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