0
|
1 /* Generic toolbar implementation.
|
|
2 Copyright (C) 1995 Board of Trustees, University of Illinois.
|
|
3 Copyright (C) 1995 Sun Microsystems, Inc.
|
|
4 Copyright (C) 1995, 1996 Ben Wing.
|
|
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"
|
|
33 #include "frame.h"
|
|
34 #include "device.h"
|
|
35 #include "glyphs.h"
|
|
36 #include "redisplay.h"
|
|
37 #include "toolbar.h"
|
|
38 #include "window.h"
|
|
39
|
|
40 Lisp_Object Vtoolbar[4];
|
|
41 Lisp_Object Vtoolbar_size[4];
|
|
42 Lisp_Object Vtoolbar_visible_p[4];
|
|
43
|
|
44 Lisp_Object Vdefault_toolbar, Vdefault_toolbar_visible_p;
|
|
45 Lisp_Object Vdefault_toolbar_width, Vdefault_toolbar_height;
|
|
46
|
|
47 Lisp_Object Vdefault_toolbar_position;
|
|
48 Lisp_Object Vtoolbar_buttons_captioned_p;
|
|
49
|
|
50 Lisp_Object Qtoolbar_buttonp;
|
|
51 Lisp_Object Q2D, Q3D, Q2d, Q3d;
|
|
52 Lisp_Object Q_size;
|
|
53 extern Lisp_Object Q_style; /* defined in menubar.c */
|
|
54
|
|
55 Lisp_Object Qinit_toolbar_from_resources;
|
|
56
|
|
57
|
|
58 static Lisp_Object
|
|
59 mark_toolbar_data (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
60 {
|
|
61 struct toolbar_data *data = (struct toolbar_data *) XPNTR (obj);
|
|
62 ((markobj) (data->last_toolbar_buffer));
|
|
63 return (data->toolbar_buttons);
|
|
64 }
|
|
65
|
|
66 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-data", toolbar_data,
|
|
67 mark_toolbar_data, internal_object_printer,
|
|
68 0, 0, 0, struct toolbar_data);
|
|
69
|
|
70 static Lisp_Object
|
|
71 mark_toolbar_button (Lisp_Object obj, void (*markobj) (Lisp_Object))
|
|
72 {
|
|
73 struct toolbar_button *data = (struct toolbar_button *) XPNTR (obj);
|
|
74 ((markobj) (data->next));
|
|
75 ((markobj) (data->frame));
|
|
76 ((markobj) (data->up_glyph));
|
|
77 ((markobj) (data->down_glyph));
|
|
78 ((markobj) (data->disabled_glyph));
|
|
79 ((markobj) (data->cap_up_glyph));
|
|
80 ((markobj) (data->cap_down_glyph));
|
|
81 ((markobj) (data->cap_disabled_glyph));
|
|
82 ((markobj) (data->callback));
|
|
83 ((markobj) (data->enabled_p));
|
|
84 return (data->help_string);
|
|
85 }
|
|
86
|
|
87 static void
|
|
88 print_toolbar_button (Lisp_Object obj, Lisp_Object printcharfun,
|
|
89 int escapeflag)
|
|
90 {
|
|
91 struct toolbar_button *tb = XTOOLBAR_BUTTON (obj);
|
|
92 char buf[100];
|
|
93
|
|
94 if (print_readably)
|
|
95 error ("printing unreadable object #<toolbar-button 0x%x>",
|
|
96 tb->header.uid);
|
|
97
|
|
98 sprintf (buf, "#<toolbar-button 0x%x>", tb->header.uid);
|
|
99 write_c_string (buf, printcharfun);
|
|
100 }
|
|
101
|
|
102 DEFINE_LRECORD_IMPLEMENTATION ("toolbar-button", toolbar_button,
|
|
103 mark_toolbar_button, print_toolbar_button,
|
|
104 0, 0, 0,
|
|
105 struct toolbar_button);
|
|
106
|
20
|
107 DEFUN ("toolbar-button-p", Ftoolbar_button_p, 1, 1, 0, /*
|
0
|
108 Return non-nil if OBJECT is a toolbar button.
|
20
|
109 */
|
|
110 (object))
|
0
|
111 {
|
|
112 return (TOOLBAR_BUTTONP (object) ? Qt : Qnil);
|
|
113 }
|
|
114
|
|
115 /* Only query functions are provided for toolbar buttons. They are
|
|
116 generated and updated from a toolbar description list. Any
|
|
117 directly made changes would be wiped out the first time the toolbar
|
|
118 was marked as dirty and was regenerated. The exception to this is
|
|
119 set-toolbar-button-down-flag. Having this allows us to control the
|
|
120 toolbar from elisp. Since we only trigger the button callbacks on
|
|
121 up-mouse events and we reset the flag first, there shouldn't be any
|
|
122 way for this to get us in trouble (like if someone decides to
|
|
123 change the toolbar from a toolbar callback). */
|
|
124
|
20
|
125 DEFUN ("toolbar-button-callback", Ftoolbar_button_callback, 1, 1, 0, /*
|
0
|
126 Return the callback function associated with the toolbar BUTTON.
|
20
|
127 */
|
|
128 (button))
|
0
|
129 {
|
|
130 CHECK_TOOLBAR_BUTTON (button);
|
|
131
|
|
132 return (XTOOLBAR_BUTTON (button)->callback);
|
|
133 }
|
|
134
|
20
|
135 DEFUN ("toolbar-button-help-string", Ftoolbar_button_help_string, 1, 1, 0, /*
|
0
|
136 Return the help string function associated with the toolbar BUTTON.
|
20
|
137 */
|
|
138 (button))
|
0
|
139 {
|
|
140 CHECK_TOOLBAR_BUTTON (button);
|
|
141
|
|
142 return (XTOOLBAR_BUTTON (button)->help_string);
|
|
143 }
|
|
144
|
20
|
145 DEFUN ("toolbar-button-enabled-p", Ftoolbar_button_enabled_p, 1, 1, 0, /*
|
0
|
146 Return t if BUTTON is active.
|
20
|
147 */
|
|
148 (button))
|
0
|
149 {
|
|
150 CHECK_TOOLBAR_BUTTON (button);
|
|
151
|
|
152 return (XTOOLBAR_BUTTON (button)->enabled ? Qt : Qnil);
|
|
153 }
|
|
154
|
20
|
155 DEFUN ("set-toolbar-button-down-flag", Fset_toolbar_button_down_flag, 2, 2, 0, /*
|
0
|
156 Don't touch.
|
20
|
157 */
|
|
158 (button, flag))
|
0
|
159 {
|
|
160 struct toolbar_button *tb;
|
|
161 char old_flag;
|
|
162
|
|
163 CHECK_TOOLBAR_BUTTON (button);
|
|
164 tb = XTOOLBAR_BUTTON (button);
|
|
165 old_flag = tb->down;
|
|
166
|
|
167 /* If the button is ignored, don't do anything. */
|
|
168 if (!tb->enabled)
|
|
169 return Qnil;
|
|
170
|
|
171 /* If flag is nil, unset the down flag, otherwise set it to true.
|
|
172 This also triggers an immediate redraw of the button if the flag
|
|
173 does change. */
|
|
174
|
|
175 if (NILP (flag))
|
|
176 tb->down = 0;
|
|
177 else
|
|
178 tb->down = 1;
|
|
179
|
|
180 if (tb->down != old_flag)
|
|
181 {
|
|
182 struct frame *f = XFRAME (tb->frame);
|
|
183 struct device *d;
|
|
184
|
|
185 if (DEVICEP (f->device))
|
|
186 {
|
|
187 d = XDEVICE (f->device);
|
|
188
|
|
189 if (DEVICE_LIVE_P (XDEVICE (f->device)))
|
|
190 {
|
|
191 tb->dirty = 1;
|
|
192 MAYBE_DEVMETH (d, output_toolbar_button, (f, button));
|
|
193 }
|
|
194 }
|
|
195 }
|
|
196
|
|
197 return Qnil;
|
|
198 }
|
|
199
|
|
200 Lisp_Object
|
|
201 get_toolbar_button_glyph (struct window *w, struct toolbar_button *tb)
|
|
202 {
|
|
203 Lisp_Object glyph = Qnil;
|
|
204
|
|
205 /* The selected glyph logic:
|
|
206
|
|
207 UP: up
|
|
208 DOWN: down -> up
|
|
209 DISABLED: disabled -> up
|
|
210 CAP-UP: cap-up -> up
|
|
211 CAP-DOWN: cap-down -> cap-up -> down -> up
|
|
212 CAP-DISABLED: cap-disabled -> cap-up -> disabled -> up
|
|
213 */
|
|
214
|
|
215 if (!NILP (w->toolbar_buttons_captioned_p))
|
|
216 {
|
|
217 if (tb->enabled && tb->down)
|
|
218 glyph = tb->cap_down_glyph;
|
|
219 else if (!tb->enabled)
|
|
220 glyph = tb->cap_disabled_glyph;
|
|
221
|
|
222 if (NILP (glyph))
|
|
223 glyph = tb->cap_up_glyph;
|
|
224 }
|
|
225
|
|
226 if (NILP (glyph))
|
|
227 {
|
|
228 if (tb->enabled && tb->down)
|
|
229 glyph = tb->down_glyph;
|
|
230 else if (!tb->enabled)
|
|
231 glyph = tb->disabled_glyph;
|
|
232 }
|
|
233
|
|
234 /* The non-captioned up button is the ultimate fallback. It is
|
|
235 the only one we guarantee exists. */
|
|
236 if (NILP (glyph))
|
|
237 glyph = tb->up_glyph;
|
|
238
|
|
239 return glyph;
|
|
240 }
|
|
241
|
|
242
|
|
243 static enum toolbar_pos
|
|
244 decode_toolbar_position (Lisp_Object position)
|
|
245 {
|
2
|
246 if (EQ (position, Qtop)) return TOP_TOOLBAR;
|
|
247 if (EQ (position, Qbottom)) return BOTTOM_TOOLBAR;
|
|
248 if (EQ (position, Qleft)) return LEFT_TOOLBAR;
|
|
249 if (EQ (position, Qright)) return RIGHT_TOOLBAR;
|
0
|
250 signal_simple_error ("Invalid toolbar position", position);
|
2
|
251
|
|
252 return TOP_TOOLBAR; /* not reached */
|
0
|
253 }
|
|
254
|
20
|
255 DEFUN ("set-default-toolbar-position", Fset_default_toolbar_position, 1, 1, 0, /*
|
0
|
256 Set the position that the `default-toolbar' will be displayed at.
|
|
257 Valid positions are 'top, 'bottom, 'left and 'right.
|
|
258 See `default-toolbar-position'.
|
20
|
259 */
|
|
260 (position))
|
0
|
261 {
|
|
262 enum toolbar_pos cur = decode_toolbar_position (Vdefault_toolbar_position);
|
|
263 enum toolbar_pos new = decode_toolbar_position (position);
|
|
264
|
|
265 if (cur != new)
|
|
266 {
|
|
267 /* The following calls will automatically cause the dirty
|
|
268 flags to be set; we delay frame size changes to avoid
|
|
269 lots of frame flickering. */
|
|
270 hold_frame_size_changes ();
|
|
271 set_specifier_fallback (Vtoolbar[cur], list1 (Fcons (Qnil, Qnil)));
|
|
272 set_specifier_fallback (Vtoolbar[new], Vdefault_toolbar);
|
|
273 set_specifier_fallback (Vtoolbar_size[cur], list1 (Fcons (Qnil, Qzero)));
|
|
274 set_specifier_fallback (Vtoolbar_size[new],
|
|
275 new == TOP_TOOLBAR || new == BOTTOM_TOOLBAR
|
|
276 ? Vdefault_toolbar_height
|
|
277 : Vdefault_toolbar_width);
|
|
278 set_specifier_fallback (Vtoolbar_visible_p[cur],
|
|
279 list1 (Fcons (Qnil, Qt)));
|
|
280 set_specifier_fallback (Vtoolbar_visible_p[new],
|
|
281 Vdefault_toolbar_visible_p);
|
|
282 Vdefault_toolbar_position = position;
|
|
283 unhold_frame_size_changes ();
|
|
284 }
|
|
285
|
|
286 return position;
|
|
287 }
|
|
288
|
20
|
289 DEFUN ("default-toolbar-position", Fdefault_toolbar_position, 0, 0, 0, /*
|
0
|
290 Return the position that the `default-toolbar' will be displayed at.
|
|
291 The `default-toolbar' will only be displayed here if the corresponding
|
|
292 position-specific toolbar specifier does not provide a value.
|
20
|
293 */
|
|
294 ())
|
0
|
295 {
|
|
296 return Vdefault_toolbar_position;
|
|
297 }
|
|
298
|
|
299
|
|
300 static Lisp_Object
|
|
301 update_toolbar_button (struct frame *f, struct toolbar_button *tb,
|
|
302 Lisp_Object desc, int pushright)
|
|
303 {
|
|
304 Lisp_Object *elt, glyphs, retval, buffer;
|
|
305 struct gcpro gcpro1, gcpro2;
|
|
306
|
|
307 elt = vector_data (XVECTOR (desc));
|
|
308 buffer = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer;
|
|
309
|
|
310 if (!tb)
|
|
311 {
|
|
312 tb = alloc_lcrecord (sizeof (struct toolbar_button),
|
|
313 lrecord_toolbar_button);
|
|
314 tb->next = Qnil;
|
|
315 XSETFRAME (tb->frame, f);
|
|
316 tb->up_glyph = Qnil;
|
|
317 tb->down_glyph = Qnil;
|
|
318 tb->disabled_glyph = Qnil;
|
|
319 tb->cap_up_glyph = Qnil;
|
|
320 tb->cap_down_glyph = Qnil;
|
|
321 tb->cap_disabled_glyph = Qnil;
|
|
322 tb->callback = Qnil;
|
|
323 tb->enabled_p = Qnil;
|
|
324 tb->help_string = Qnil;
|
|
325
|
|
326 tb->enabled = 0;
|
|
327 tb->down = 0;
|
|
328 tb->pushright = pushright;
|
|
329 tb->blank = 0;
|
|
330 tb->x = tb->y = tb->width = tb->height = -1;
|
|
331 tb->dirty = 1;
|
|
332 }
|
|
333 XSETTOOLBAR_BUTTON (retval, tb);
|
|
334
|
|
335 /* Let's make sure nothing gets mucked up by the potential call to
|
|
336 eval farther down. */
|
|
337 GCPRO2 (retval, desc);
|
|
338
|
|
339 glyphs = (CONSP (elt[0]) ? elt[0] : symbol_value_in_buffer (elt[0], buffer));
|
|
340
|
|
341 /* If this is true we have a blank, otherwise it is an actual
|
|
342 button. */
|
|
343 if (KEYWORDP (glyphs))
|
|
344 {
|
|
345 int pos;
|
|
346 int style_seen = 0;
|
|
347 int size_seen = 0;
|
|
348
|
|
349 if (!tb->blank)
|
|
350 {
|
|
351 tb->blank = 1;
|
|
352 tb->dirty = 1;
|
|
353 }
|
|
354
|
|
355 for (pos = 0; pos < vector_length (XVECTOR (desc)); 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 (!NILP (glyphs) && 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 (!NILP (glyphs) && 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 (!NILP (glyphs) && 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 (!NILP (glyphs) && 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 (!NILP (glyphs) && 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 (!NILP (glyphs) && 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 {
|
|
551 Lisp_Object result =
|
|
552 eval_in_buffer_trapping_errors
|
|
553 ("Error in toolbar enabled-p form",
|
|
554 XBUFFER
|
|
555 (WINDOW_BUFFER
|
|
556 (XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f)))),
|
|
557 tb->enabled_p);
|
|
558 if (UNBOUNDP (result))
|
|
559 /* #### if there was an error in the enabled-p
|
|
560 form, should we pretend like it's enabled
|
|
561 or disabled? */
|
|
562 tb->enabled = 0;
|
|
563 else
|
|
564 tb->enabled = !NILP (result);
|
|
565 }
|
|
566 }
|
|
567
|
|
568 if (old_enabled != tb->enabled)
|
|
569 tb->dirty = 1;
|
|
570 }
|
|
571
|
|
572 /* Update the help echo string. */
|
|
573 if (!EQ (tb->help_string, elt[3]))
|
|
574 {
|
|
575 tb->help_string = elt[3];
|
|
576 /* This does not have an impact on the display properties of the
|
|
577 button so we do not mark it as dirty if it has changed. */
|
|
578 }
|
|
579 }
|
|
580
|
|
581 /* If this flag changes, the position is changing for sure unless
|
|
582 some very unlikely geometry occurs. */
|
|
583 if (tb->pushright != pushright)
|
|
584 {
|
|
585 tb->pushright = pushright;
|
|
586 tb->dirty = 1;
|
|
587 }
|
|
588
|
|
589 /* The position and size fields are only manipulated in the
|
|
590 device-dependent code. */
|
|
591 UNGCPRO;
|
|
592 return retval;
|
|
593 }
|
|
594
|
|
595 static Lisp_Object
|
|
596 compute_frame_toolbar_buttons (struct frame *f, enum toolbar_pos pos,
|
|
597 Lisp_Object toolbar)
|
|
598 {
|
|
599 Lisp_Object buttons, prev_button, first_button;
|
|
600 Lisp_Object orig_toolbar = toolbar;
|
|
601 int pushright_seen = 0;
|
|
602 struct gcpro gcpro1, gcpro2, gcpro3, gcpro4, gcpro5;
|
|
603
|
|
604 first_button = FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons;
|
|
605 buttons = prev_button = first_button;
|
|
606
|
|
607 /* Yes, we're being paranoid. */
|
|
608 GCPRO5 (toolbar, buttons, prev_button, first_button, orig_toolbar);
|
|
609
|
|
610 if (NILP (toolbar))
|
|
611 {
|
|
612 /* The output mechanisms will take care of clearing the former
|
|
613 toolbar. */
|
|
614 UNGCPRO;
|
|
615 return Qnil;
|
|
616 }
|
|
617
|
|
618 if (!CONSP (toolbar))
|
|
619 signal_simple_error ("toolbar description must be a list", toolbar);
|
|
620
|
|
621 /* First synchronize any existing buttons. */
|
|
622 while (!NILP (toolbar) && !NILP (buttons))
|
|
623 {
|
|
624 struct toolbar_button *tb;
|
|
625
|
|
626 if (NILP (XCAR (toolbar)))
|
|
627 {
|
|
628 if (pushright_seen)
|
|
629 signal_simple_error
|
|
630 ("more than one partition (nil) in toolbar description",
|
|
631 orig_toolbar);
|
|
632 else
|
|
633 pushright_seen = 1;
|
|
634 }
|
|
635 else
|
|
636 {
|
|
637 tb = XTOOLBAR_BUTTON (buttons);
|
|
638 update_toolbar_button (f, tb, XCAR (toolbar), pushright_seen);
|
|
639 prev_button = buttons;
|
|
640 buttons = tb->next;
|
|
641 }
|
|
642
|
|
643 toolbar = XCDR (toolbar);
|
|
644 }
|
|
645
|
|
646 /* If we hit the end of the toolbar, then clean up any excess
|
|
647 buttons and return. */
|
|
648 if (NILP (toolbar))
|
|
649 {
|
|
650 if (!NILP (buttons))
|
|
651 {
|
2
|
652 /* If this is the case the only thing we saw was a
|
0
|
653 pushright marker. */
|
|
654 if (EQ (buttons, first_button))
|
|
655 {
|
|
656 UNGCPRO;
|
|
657 return Qnil;
|
|
658 }
|
|
659 else
|
|
660 XTOOLBAR_BUTTON (prev_button)->next = Qnil;
|
|
661 }
|
|
662 UNGCPRO;
|
|
663 return first_button;
|
|
664 }
|
|
665
|
|
666 /* At this point there are more buttons on the toolbar than we
|
|
667 actually have in existence. */
|
|
668 while (!NILP (toolbar))
|
|
669 {
|
|
670 Lisp_Object new_button;
|
|
671
|
|
672 if (NILP (XCAR (toolbar)))
|
|
673 {
|
|
674 if (pushright_seen)
|
|
675 signal_simple_error
|
|
676 ("more than one partition (nil) in toolbar description",
|
|
677 orig_toolbar);
|
|
678 else
|
|
679 pushright_seen = 1;
|
|
680 }
|
|
681 else
|
|
682 {
|
|
683 new_button = update_toolbar_button (f, NULL, XCAR (toolbar),
|
|
684 pushright_seen);
|
|
685
|
|
686 if (NILP (first_button))
|
|
687 {
|
|
688 first_button = prev_button = new_button;
|
|
689 }
|
|
690 else
|
|
691 {
|
|
692 XTOOLBAR_BUTTON (prev_button)->next = new_button;
|
|
693 prev_button = new_button;
|
|
694 }
|
|
695 }
|
|
696
|
|
697 toolbar = XCDR (toolbar);
|
|
698 }
|
|
699
|
|
700 UNGCPRO;
|
|
701 return first_button;
|
|
702 }
|
|
703
|
|
704 static int
|
|
705 set_frame_toolbar (struct frame *f, enum toolbar_pos pos, int first_time_p)
|
|
706 {
|
|
707 Lisp_Object toolbar, buttons;
|
|
708 struct window *w = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f));
|
|
709 Lisp_Object buffer = w->buffer;
|
|
710 int visible = FRAME_THEORETICAL_TOOLBAR_SIZE (f, pos);
|
|
711
|
|
712 toolbar = w->toolbar[pos];
|
|
713
|
|
714 if (NILP (f->toolbar_data[pos]))
|
|
715 {
|
|
716 struct toolbar_data *td = alloc_lcrecord (sizeof (struct toolbar_data),
|
|
717 lrecord_toolbar_data);
|
|
718
|
|
719 td->last_toolbar_buffer = Qnil;
|
|
720 td->toolbar_buttons = Qnil;
|
|
721 XSETTOOLBAR_DATA (f->toolbar_data[pos], td);
|
|
722 }
|
|
723
|
|
724 if (visible)
|
|
725 buttons = compute_frame_toolbar_buttons (f, pos, toolbar);
|
|
726 else
|
|
727 buttons = Qnil;
|
|
728
|
|
729 FRAME_TOOLBAR_DATA (f, pos)->last_toolbar_buffer = buffer;
|
|
730 FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons = buttons;
|
|
731
|
|
732 return (visible);
|
|
733 }
|
|
734
|
|
735 #define COMPUTE_TOOLBAR_DATA(position) \
|
|
736 do \
|
|
737 { \
|
|
738 local_toolbar_changed = \
|
|
739 (f->toolbar_changed \
|
|
740 || NILP (f->toolbar_data[position]) \
|
|
741 || (!EQ (FRAME_TOOLBAR_DATA (f, position)->last_toolbar_buffer, \
|
|
742 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer))); \
|
|
743 \
|
|
744 toolbar_was_visible = \
|
|
745 (!NILP (f->toolbar_data[position]) \
|
|
746 && !NILP (FRAME_TOOLBAR_DATA (f, position)->toolbar_buttons)); \
|
|
747 toolbar_will_be_visible = toolbar_was_visible; \
|
|
748 \
|
|
749 if (local_toolbar_changed) \
|
|
750 toolbar_will_be_visible = \
|
|
751 set_frame_toolbar (f, position, first_time_p); \
|
|
752 \
|
|
753 toolbar_visibility_changed = \
|
|
754 (toolbar_was_visible != toolbar_will_be_visible); \
|
|
755 \
|
|
756 if (toolbar_visibility_changed) \
|
|
757 frame_changed_size = 1; \
|
|
758 } while (0)
|
|
759
|
|
760 static void
|
|
761 compute_frame_toolbars_data (struct frame *f, int first_time_p)
|
|
762 {
|
|
763 int local_toolbar_changed;
|
|
764 int toolbar_was_visible, toolbar_will_be_visible;
|
|
765 int toolbar_visibility_changed;
|
|
766 int frame_changed_size = 0;
|
|
767
|
|
768 COMPUTE_TOOLBAR_DATA (TOP_TOOLBAR);
|
|
769 COMPUTE_TOOLBAR_DATA (BOTTOM_TOOLBAR);
|
|
770 COMPUTE_TOOLBAR_DATA (LEFT_TOOLBAR);
|
|
771 COMPUTE_TOOLBAR_DATA (RIGHT_TOOLBAR);
|
|
772
|
|
773 /* The frame itself doesn't actually change size, but the usable
|
|
774 text area does. All we have to do is call change_frame_size with
|
|
775 the current height and width parameters and it will readjust for
|
|
776 all changes in the toolbars. */
|
|
777 if (frame_changed_size && !first_time_p)
|
|
778 change_frame_size (f, FRAME_HEIGHT (f), FRAME_WIDTH (f), 0);
|
|
779 }
|
|
780 #undef COMPUTE_TOOLBAR_DATA
|
|
781
|
|
782 void
|
|
783 update_frame_toolbars (struct frame *f)
|
|
784 {
|
|
785 struct device *d = XDEVICE (f->device);
|
|
786 Lisp_Object buffer = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer;
|
|
787
|
|
788 /* If the buffer of the selected window is not equal to the
|
|
789 last_toolbar_buffer value for any of the toolbars, then the
|
|
790 toolbars need to be recomputed. */
|
|
791 if ((HAS_DEVMETH_P (d, output_frame_toolbars))
|
|
792 && (f->toolbar_changed
|
|
793 || !EQ (FRAME_TOOLBAR_BUFFER (f, TOP_TOOLBAR), buffer)
|
|
794 || !EQ (FRAME_TOOLBAR_BUFFER (f, BOTTOM_TOOLBAR), buffer)
|
|
795 || !EQ (FRAME_TOOLBAR_BUFFER (f, LEFT_TOOLBAR), buffer)
|
|
796 || !EQ (FRAME_TOOLBAR_BUFFER (f, RIGHT_TOOLBAR), buffer)))
|
|
797 {
|
|
798 /* Removed the check for the minibuffer here. We handle this
|
|
799 more correctly now by consistently using
|
|
800 FRAME_LAST_NONMINIBUF_WINDOW instead of FRAME_SELECTED_WINDOW
|
|
801 throughout the toolbar code. */
|
|
802 compute_frame_toolbars_data (f, 0);
|
|
803
|
|
804 DEVMETH (d, output_frame_toolbars, (f));
|
|
805 }
|
|
806
|
|
807 f->toolbar_changed = 0;
|
|
808 }
|
|
809
|
|
810 void
|
|
811 init_frame_toolbars (struct frame *f)
|
|
812 {
|
|
813 struct device *d = XDEVICE (f->device);
|
|
814
|
|
815 /* If there isn't any output routine, then this device type doesn't
|
|
816 support toolbars. */
|
|
817 if (HAS_DEVMETH_P (d, output_frame_toolbars))
|
|
818 {
|
|
819 Lisp_Object frame = Qnil;
|
|
820
|
|
821 compute_frame_toolbars_data (f, 1);
|
|
822 XSETFRAME (frame, f);
|
|
823 call_critical_lisp_code (XDEVICE (FRAME_DEVICE (f)),
|
|
824 Qinit_toolbar_from_resources,
|
|
825 frame);
|
|
826 MAYBE_DEVMETH (d, initialize_frame_toolbars, (f));
|
|
827 }
|
|
828 }
|
|
829
|
|
830 void
|
|
831 init_device_toolbars (struct device *d)
|
|
832 {
|
|
833 Lisp_Object device = Qnil;
|
|
834
|
|
835 XSETDEVICE (device, d);
|
|
836 if (HAS_DEVMETH_P (d, output_frame_toolbars))
|
|
837 call_critical_lisp_code (d,
|
|
838 Qinit_toolbar_from_resources,
|
|
839 device);
|
|
840 }
|
|
841
|
|
842 void
|
|
843 init_global_toolbars (struct device *d)
|
|
844 {
|
|
845 if (HAS_DEVMETH_P (d, output_frame_toolbars))
|
|
846 call_critical_lisp_code (d,
|
|
847 Qinit_toolbar_from_resources,
|
|
848 Qglobal);
|
|
849 }
|
|
850
|
|
851 void
|
|
852 free_frame_toolbars (struct frame *f)
|
|
853 {
|
|
854 /* If we had directly allocated any memory for the toolbars instead
|
|
855 of using all Lisp_Objects this is where we would now free it. */
|
|
856
|
|
857 MAYBE_FRAMEMETH (f, free_frame_toolbars, (f));
|
|
858 }
|
|
859
|
|
860 void
|
|
861 get_toolbar_coords (struct frame *f, enum toolbar_pos pos, int *x, int *y,
|
|
862 int *width, int *height, int *vert, int for_layout)
|
|
863 {
|
|
864 int visible_top_toolbar_height, visible_bottom_toolbar_height;
|
|
865 int adjust = (for_layout ? 1 : 0);
|
|
866
|
|
867 /* The top and bottom toolbars take precedence over the left and
|
|
868 right. */
|
|
869 visible_top_toolbar_height = (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)
|
|
870 ? FRAME_REAL_TOP_TOOLBAR_HEIGHT (f)
|
|
871 : 0);
|
|
872 visible_bottom_toolbar_height = (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f)
|
|
873 ? FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f)
|
|
874 : 0);
|
|
875
|
|
876 /* We adjust the width and height by one to give us a narrow border
|
|
877 at the outside edges. However, when we are simply determining
|
|
878 toolbar location we don't want to do that. */
|
|
879
|
|
880 switch (pos)
|
|
881 {
|
|
882 case TOP_TOOLBAR:
|
|
883 *x = 1;
|
|
884 *y = 0; /* #### should be 1 if no menubar */
|
|
885 *width = FRAME_PIXWIDTH (f) - 2;
|
|
886 *height = FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) - adjust;
|
|
887 *vert = 0;
|
|
888 break;
|
|
889 case BOTTOM_TOOLBAR:
|
|
890 *x = 1;
|
|
891 *y = FRAME_PIXHEIGHT (f) - FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f);
|
|
892 *width = FRAME_PIXWIDTH (f) - 2;
|
|
893 *height = FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) - adjust;
|
|
894 *vert = 0;
|
|
895 break;
|
|
896 case LEFT_TOOLBAR:
|
|
897 *x = 1;
|
|
898 *y = visible_top_toolbar_height;
|
|
899 *width = FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) - adjust;
|
|
900 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height -
|
|
901 visible_bottom_toolbar_height - 1);
|
|
902 *vert = 1;
|
|
903 break;
|
|
904 case RIGHT_TOOLBAR:
|
|
905 *x = FRAME_PIXWIDTH (f) - FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f);
|
|
906 *y = visible_top_toolbar_height;
|
|
907 *width = FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) - adjust;
|
|
908 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height -
|
|
909 visible_bottom_toolbar_height);
|
|
910 *vert = 1;
|
|
911 break;
|
|
912 default:
|
|
913 abort ();
|
|
914 }
|
|
915 }
|
|
916
|
|
917 #define CHECK_TOOLBAR(pos) \
|
|
918 do \
|
|
919 { \
|
|
920 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 0); \
|
|
921 if ((x_coord >= x) && (x_coord < (x + width))) \
|
|
922 { \
|
|
923 if ((y_coord >= y) && (y_coord < (y + height))) \
|
|
924 { \
|
|
925 return (FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons); \
|
|
926 } \
|
|
927 } \
|
|
928 } while (0)
|
|
929
|
|
930 static Lisp_Object
|
|
931 toolbar_buttons_at_pixpos (struct frame *f, int x_coord, int y_coord)
|
|
932 {
|
|
933 int x, y, width, height, vert;
|
|
934
|
|
935 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
|
|
936 CHECK_TOOLBAR (TOP_TOOLBAR);
|
|
937 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
|
|
938 CHECK_TOOLBAR (BOTTOM_TOOLBAR);
|
|
939 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
|
|
940 CHECK_TOOLBAR (LEFT_TOOLBAR);
|
|
941 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
|
|
942 CHECK_TOOLBAR (RIGHT_TOOLBAR);
|
|
943
|
|
944 return Qnil;
|
|
945 }
|
|
946 #undef CHECK_TOOLBAR
|
|
947
|
|
948 /* The device dependent code actually does the work of positioning the
|
|
949 buttons, but we are free to access that information at this
|
|
950 level. */
|
|
951 Lisp_Object
|
|
952 toolbar_button_at_pixpos (struct frame *f, int x_coord, int y_coord)
|
|
953 {
|
|
954 Lisp_Object buttons = toolbar_buttons_at_pixpos (f, x_coord, y_coord);
|
|
955
|
|
956 if (NILP (buttons))
|
|
957 return Qnil;
|
|
958
|
|
959 while (!NILP (buttons))
|
|
960 {
|
|
961 struct toolbar_button *tb = XTOOLBAR_BUTTON (buttons);
|
|
962
|
|
963 if ((x_coord >= tb->x) && (x_coord < (tb->x + tb->width)))
|
|
964 {
|
|
965 if ((y_coord >= tb->y) && (y_coord < (tb->y + tb->height)))
|
|
966 {
|
|
967 /* If we are over a blank, return nil. */
|
|
968 if (tb->blank)
|
|
969 return Qnil;
|
|
970 else
|
|
971 return buttons;
|
|
972 }
|
|
973 }
|
|
974
|
|
975 buttons = tb->next;
|
|
976 }
|
|
977
|
|
978 /* We must be over a blank in the toolbar. */
|
|
979 return Qnil;
|
|
980 }
|
|
981
|
|
982
|
|
983 /************************************************************************/
|
|
984 /* Toolbar specifier type */
|
|
985 /************************************************************************/
|
|
986
|
|
987 DEFINE_SPECIFIER_TYPE (toolbar);
|
|
988
|
|
989 #define CTB_ERROR(msg) \
|
|
990 do \
|
|
991 { \
|
|
992 maybe_signal_simple_error (msg, button, Qtoolbar, errb); \
|
|
993 RETURN__ Qnil; \
|
|
994 } \
|
|
995 while (0)
|
|
996
|
|
997 /* Returns Q_style if key was :style, Qt if ok otherwise, Qnil if error. */
|
|
998 static Lisp_Object
|
|
999 check_toolbar_button_keywords (Lisp_Object button, Lisp_Object key,
|
|
1000 Lisp_Object val, Error_behavior errb)
|
|
1001 {
|
|
1002 if (!KEYWORDP (key))
|
|
1003 {
|
|
1004 maybe_signal_simple_error_2 ("not a keyword", key, button, Qtoolbar,
|
|
1005 errb);
|
|
1006 return Qnil;
|
|
1007 }
|
|
1008
|
|
1009 if (EQ (key, Q_style))
|
|
1010 {
|
|
1011 if (!EQ (val, Q2D)
|
|
1012 && !EQ (val, Q3D)
|
|
1013 && !EQ (val, Q2d)
|
|
1014 && !EQ (val, Q3d))
|
|
1015 CTB_ERROR ("unrecognized toolbar blank style");
|
|
1016
|
|
1017 return Q_style;
|
|
1018 }
|
|
1019 else if (EQ (key, Q_size))
|
|
1020 {
|
|
1021 if (!NATNUMP (val))
|
|
1022 CTB_ERROR ("invalid toolbar blank size");
|
|
1023 }
|
|
1024 else
|
|
1025 {
|
|
1026 CTB_ERROR ("invalid toolbar blank keyword");
|
|
1027 }
|
|
1028
|
|
1029 return Qt;
|
|
1030 }
|
|
1031
|
|
1032 /* toolbar button spec is [pixmap-pair function enabled-p help]
|
|
1033 or [:style 2d-or-3d :size width-or-height] */
|
|
1034
|
20
|
1035 DEFUN ("check-toolbar-button-syntax", Fcheck_toolbar_button_syntax, 1, 2, 0, /*
|
0
|
1036 Verify the syntax of entry BUTTON in a toolbar description list.
|
|
1037 If you want to verify the syntax of a toolbar description list as a
|
|
1038 whole, use `check-valid-instantiator' with a specifier type of 'toolbar.
|
20
|
1039 */
|
|
1040 (button, no_error))
|
0
|
1041 {
|
|
1042 Lisp_Object *elt, glyphs, value;
|
|
1043 int len;
|
|
1044 Error_behavior errb = decode_error_behavior_flag (no_error);
|
|
1045
|
|
1046 if (!VECTORP (button))
|
|
1047 CTB_ERROR ("toolbar button descriptors must be vectors");
|
|
1048 elt = vector_data (XVECTOR (button));
|
|
1049
|
|
1050 if (vector_length (XVECTOR (button)) == 2)
|
|
1051 {
|
|
1052 if (!EQ (Q_style, check_toolbar_button_keywords (button, elt[0],
|
|
1053 elt[1], errb)))
|
|
1054 CTB_ERROR ("must specify toolbar blank style");
|
|
1055
|
|
1056 return Qt;
|
|
1057 }
|
|
1058
|
|
1059 if (vector_length (XVECTOR (button)) != 4)
|
|
1060 CTB_ERROR ("toolbar button descriptors must be 2 or 4 long");
|
|
1061
|
|
1062 /* The first element must be a list of glyphs of length 1-6. The
|
|
1063 first entry is the pixmap for the up state, the second for the
|
|
1064 down state, the third for the disabled state, the fourth for the
|
|
1065 captioned up state, the fifth for the captioned down state and
|
|
1066 the sixth for the captioned disabled state. Only the up state is
|
|
1067 mandatory. */
|
|
1068 if (!CONSP (elt[0]))
|
|
1069 {
|
|
1070 /* We can't check the buffer-local here because we don't know
|
|
1071 which buffer to check in. #### I think this is a bad thing.
|
|
1072 See if we can't get enough information to this function so
|
|
1073 that it can check.
|
|
1074
|
|
1075 #### Wrong. We shouldn't be checking the value at all here.
|
|
1076 The user might set or change the value at any time. */
|
|
1077 value = Fsymbol_value (elt[0]);
|
|
1078
|
|
1079 if (!CONSP (value))
|
|
1080 {
|
|
1081 if (KEYWORDP (elt[0]))
|
|
1082 {
|
|
1083 int fsty = 0;
|
|
1084
|
|
1085 if (EQ (Q_style, check_toolbar_button_keywords (button, elt[0],
|
|
1086 elt[1],
|
|
1087 errb)))
|
|
1088 fsty++;
|
|
1089
|
|
1090 if (EQ (Q_style, check_toolbar_button_keywords (button, elt[2],
|
|
1091 elt[3],
|
|
1092 errb)))
|
|
1093 fsty++;
|
|
1094
|
|
1095 if (!fsty)
|
|
1096 CTB_ERROR ("must specify toolbar blank style");
|
|
1097 else if (EQ (elt[0], elt[2]))
|
|
1098 CTB_ERROR
|
|
1099 ("duplicate keywords in toolbar button blank description");
|
|
1100
|
|
1101 return Qt;
|
|
1102 }
|
|
1103 else
|
|
1104 CTB_ERROR ("first element of button must be a list (of glyphs)");
|
|
1105 }
|
|
1106 }
|
|
1107 else
|
|
1108 value = elt[0];
|
|
1109
|
|
1110 len = XINT (Flength (value));
|
|
1111 if (len < 1)
|
|
1112 CTB_ERROR ("toolbar button glyph list must have at least 1 entry");
|
|
1113
|
|
1114 if (len > 6)
|
|
1115 CTB_ERROR ("toolbar button glyph list can have at most 6 entries");
|
|
1116
|
|
1117 glyphs = value;
|
|
1118 while (!NILP (glyphs))
|
|
1119 {
|
|
1120 if (!GLYPHP (XCAR (glyphs)))
|
|
1121 {
|
|
1122 /* We allow nil for the down and disabled glyphs but not for
|
|
1123 the up glyph. */
|
|
1124 if (EQ (glyphs, value) || !NILP (XCAR (glyphs)))
|
|
1125 {
|
|
1126 CTB_ERROR
|
|
1127 ("all elements of toolbar button glyph list must be glyphs.");
|
|
1128 }
|
|
1129 }
|
|
1130 glyphs = XCDR (glyphs);
|
|
1131 }
|
|
1132
|
|
1133 /* The second element is the function to run when the button is
|
|
1134 activated. We do not do any checking on it because it is legal
|
|
1135 for the function to not be defined until after the toolbar is.
|
|
1136 It is the user's problem to get this right.
|
|
1137
|
|
1138 The third element is either a boolean indicating the enabled
|
|
1139 status or a function used to determine it. Again, it is the
|
|
1140 user's problem if this is wrong.
|
|
1141
|
|
1142 The fourth element, if not nil, must be a string which will be
|
|
1143 displayed as the help echo. */
|
|
1144
|
|
1145 /* #### This should be allowed to be a function returning a string
|
|
1146 as well as just a string. */
|
|
1147 if (!NILP (elt[3]) && !STRINGP (elt[3]))
|
|
1148 CTB_ERROR ("toolbar button help echo string must be a string");
|
|
1149
|
|
1150 return Qt;
|
|
1151 }
|
|
1152 #undef CTB_ERROR
|
|
1153
|
|
1154 static void
|
|
1155 toolbar_validate (Lisp_Object instantiator)
|
|
1156 {
|
|
1157 int pushright_seen = 0;
|
|
1158 Lisp_Object rest;
|
|
1159
|
|
1160 if (NILP (instantiator))
|
|
1161 return;
|
|
1162
|
|
1163 if (!CONSP (instantiator))
|
|
1164 signal_simple_error ("toolbar spec must be list or nil", instantiator);
|
|
1165
|
|
1166 for (rest = instantiator; !NILP (rest); rest = XCDR (rest))
|
|
1167 {
|
|
1168 if (!CONSP (rest))
|
|
1169 signal_simple_error ("bad list in toolbar spec", instantiator);
|
|
1170
|
|
1171 if (NILP (XCAR (rest)))
|
|
1172 {
|
|
1173 if (pushright_seen)
|
|
1174 error
|
|
1175 ("more than one partition (nil) in instantiator description");
|
|
1176 else
|
|
1177 pushright_seen = 1;
|
|
1178 }
|
|
1179 else
|
|
1180 Fcheck_toolbar_button_syntax (XCAR (rest), Qnil);
|
|
1181 }
|
|
1182 }
|
|
1183
|
|
1184 static void
|
|
1185 toolbar_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
1186 {
|
|
1187 /* #### This is overkill. I really need to rethink the after-change
|
|
1188 functions to make them easier to use. */
|
|
1189 MARK_TOOLBAR_CHANGED;
|
|
1190 }
|
|
1191
|
20
|
1192 DEFUN ("toolbar-specifier-p", Ftoolbar_specifier_p, 1, 1, 0, /*
|
0
|
1193 Return non-nil if OBJECT is a toolbar specifier.
|
|
1194 Toolbar specifiers are used to specify the format of a toolbar.
|
|
1195 The values of the variables `default-toolbar', `top-toolbar',
|
|
1196 `left-toolbar', `right-toolbar', and `bottom-toolbar' are always
|
|
1197 toolbar specifiers.
|
|
1198
|
|
1199 Valid toolbar instantiators are called \"toolbar descriptors\"
|
|
1200 and are lists of vectors. See `default-toolbar' for a description
|
|
1201 of the exact format.
|
20
|
1202 */
|
|
1203 (object))
|
0
|
1204 {
|
|
1205 return (TOOLBAR_SPECIFIERP (object) ? Qt : Qnil);
|
|
1206 }
|
|
1207
|
|
1208
|
|
1209 static void
|
|
1210 toolbar_specs_changed (Lisp_Object specifier, struct window *w,
|
|
1211 Lisp_Object oldval)
|
|
1212 {
|
|
1213 /* This could be smarter but I doubt that it would make any
|
|
1214 noticable difference given the infrequency with which this is
|
|
1215 probably going to be called.
|
|
1216 */
|
|
1217 MARK_TOOLBAR_CHANGED;
|
|
1218 }
|
|
1219
|
|
1220 static void
|
|
1221 default_toolbar_specs_changed (Lisp_Object specifier, struct window *w,
|
|
1222 Lisp_Object oldval)
|
|
1223 {
|
|
1224 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position);
|
|
1225
|
|
1226 Fset_specifier_dirty_flag (Vtoolbar[pos]);
|
|
1227 }
|
|
1228
|
|
1229 static void
|
|
1230 toolbar_size_changed_in_frame (Lisp_Object specifier, struct frame *f,
|
|
1231 Lisp_Object oldval)
|
|
1232 {
|
2
|
1233 int pos;
|
0
|
1234
|
2
|
1235 for (pos = 0; pos < countof (Vtoolbar_size); pos++)
|
|
1236 if (EQ (specifier, Vtoolbar_size[(enum toolbar_pos) pos]))
|
0
|
1237 break;
|
|
1238
|
2
|
1239 assert (pos < countof (Vtoolbar_size));
|
0
|
1240
|
|
1241 MAYBE_FRAMEMETH (f, toolbar_size_changed_in_frame,
|
|
1242 (f, pos, oldval));
|
|
1243
|
|
1244 /* Let redisplay know that something has possibly changed. */
|
|
1245 MARK_TOOLBAR_CHANGED;
|
|
1246 }
|
|
1247
|
|
1248 static void
|
|
1249 toolbar_visible_p_changed_in_frame (Lisp_Object specifier, struct frame *f,
|
|
1250 Lisp_Object oldval)
|
|
1251 {
|
2
|
1252 int pos;
|
0
|
1253
|
2
|
1254 for (pos = 0; pos < countof (Vtoolbar_visible_p); pos++)
|
|
1255 if (EQ (specifier, Vtoolbar_visible_p[(enum toolbar_pos) pos]))
|
0
|
1256 break;
|
|
1257
|
2
|
1258 assert (pos < countof (Vtoolbar_visible_p));
|
0
|
1259
|
|
1260 MAYBE_FRAMEMETH (f, toolbar_visible_p_changed_in_frame,
|
|
1261 (f, pos, oldval));
|
|
1262
|
|
1263 /* Let redisplay know that something has possibly changed. */
|
|
1264 MARK_TOOLBAR_CHANGED;
|
|
1265 }
|
|
1266
|
|
1267 static void
|
|
1268 default_toolbar_size_changed_in_frame (Lisp_Object specifier, struct frame *f,
|
|
1269 Lisp_Object oldval)
|
|
1270 {
|
|
1271 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position);
|
|
1272
|
|
1273 Fset_specifier_dirty_flag (Vtoolbar_size[pos]);
|
|
1274
|
|
1275 /* Let redisplay know that something has possibly changed. */
|
|
1276 MARK_TOOLBAR_CHANGED;
|
|
1277 }
|
|
1278
|
|
1279 static void
|
|
1280 default_toolbar_visible_p_changed_in_frame (Lisp_Object specifier,
|
|
1281 struct frame *f,
|
|
1282 Lisp_Object oldval)
|
|
1283 {
|
|
1284 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position);
|
|
1285
|
|
1286 Fset_specifier_dirty_flag (Vtoolbar_visible_p[pos]);
|
|
1287
|
|
1288 /* Let redisplay know that something has possibly changed. */
|
|
1289 MARK_TOOLBAR_CHANGED;
|
|
1290 }
|
|
1291
|
|
1292
|
|
1293 static void
|
|
1294 toolbar_buttons_captioned_p_changed (Lisp_Object specifier, struct window *w,
|
|
1295 Lisp_Object oldval)
|
|
1296 {
|
|
1297 /* This could be smarter but I doubt that it would make any
|
|
1298 noticable difference given the infrequency with which this is
|
|
1299 probably going to be called. */
|
|
1300 MARK_TOOLBAR_CHANGED;
|
|
1301 }
|
|
1302
|
|
1303
|
|
1304 void
|
|
1305 syms_of_toolbar (void)
|
|
1306 {
|
|
1307 defsymbol (&Qtoolbar_buttonp, "toolbar-button-p");
|
|
1308 defsymbol (&Q2D, "2D");
|
|
1309 defsymbol (&Q3D, "3D");
|
|
1310 defsymbol (&Q2d, "2d");
|
|
1311 defsymbol (&Q3d, "3d");
|
|
1312 defsymbol (&Q_size, ":size"); Fset (Q_size, Q_size);
|
|
1313
|
|
1314 defsymbol (&Qinit_toolbar_from_resources, "init-toolbar-from-resources");
|
20
|
1315 DEFSUBR (Ftoolbar_button_p);
|
|
1316 DEFSUBR (Ftoolbar_button_callback);
|
|
1317 DEFSUBR (Ftoolbar_button_help_string);
|
|
1318 DEFSUBR (Ftoolbar_button_enabled_p);
|
|
1319 DEFSUBR (Fset_toolbar_button_down_flag);
|
|
1320 DEFSUBR (Fcheck_toolbar_button_syntax);
|
|
1321 DEFSUBR (Fset_default_toolbar_position);
|
|
1322 DEFSUBR (Fdefault_toolbar_position);
|
|
1323 DEFSUBR (Ftoolbar_specifier_p);
|
0
|
1324 }
|
|
1325
|
|
1326 void
|
|
1327 vars_of_toolbar (void)
|
|
1328 {
|
|
1329 staticpro (&Vdefault_toolbar_position);
|
|
1330 Vdefault_toolbar_position = Qtop;
|
|
1331
|
|
1332 #ifdef HAVE_WINDOW_SYSTEM
|
|
1333 Fprovide (Qtoolbar);
|
|
1334 #endif
|
|
1335 }
|
|
1336
|
|
1337 void
|
|
1338 specifier_type_create_toolbar (void)
|
|
1339 {
|
|
1340 INITIALIZE_SPECIFIER_TYPE (toolbar, "toolbar", "toolbar-specifier-p");
|
|
1341
|
|
1342 SPECIFIER_HAS_METHOD (toolbar, validate);
|
|
1343 SPECIFIER_HAS_METHOD (toolbar, after_change);
|
|
1344 }
|
|
1345
|
|
1346 void
|
|
1347 specifier_vars_of_toolbar (void)
|
|
1348 {
|
|
1349 Lisp_Object elt;
|
|
1350
|
|
1351 DEFVAR_SPECIFIER ("default-toolbar", &Vdefault_toolbar /*
|
|
1352 Specifier for a fallback toolbar.
|
|
1353 Use `set-specifier' to change this.
|
|
1354
|
|
1355 The position of this toolbar is specified in the function
|
|
1356 `default-toolbar-position'. If the corresponding position-specific
|
|
1357 toolbar (e.g. `top-toolbar' if `default-toolbar-position' is 'top)
|
|
1358 does not specify a toolbar in a particular domain (usually a window),
|
|
1359 then the value of `default-toolbar' in that domain, if any, will be
|
|
1360 used instead.
|
|
1361
|
|
1362 Note that the toolbar at any particular position will not be
|
|
1363 displayed unless its visibility flag is true and its thickness
|
|
1364 \(width or height, depending on orientation) is non-zero. The
|
|
1365 visibility is controlled by the specifiers `top-toolbar-visible-p',
|
|
1366 `bottom-toolbar-visible-p', `left-toolbar-visible-p', and
|
|
1367 `right-toolbar-visible-p', and the thickness is controlled by the
|
|
1368 specifiers `top-toolbar-height', `bottom-toolbar-height',
|
|
1369 `left-toolbar-width', and `right-toolbar-width'.
|
|
1370
|
|
1371 Note that one of the four visibility specifiers inherits from
|
|
1372 `default-toolbar-visibility' and one of the four thickness
|
|
1373 specifiers inherits from either `default-toolbar-width' or
|
|
1374 `default-toolbar-height' (depending on orientation), just
|
|
1375 like for the toolbar description specifiers (e.g. `top-toolbar')
|
|
1376 mentioned above.
|
|
1377
|
|
1378 Therefore, if you are setting `default-toolbar', you should control
|
|
1379 the visibility and thickness using `default-toolbar-visible-p',
|
|
1380 `default-toolbar-width', and `default-toolbar-height', rather than
|
|
1381 using position-specific specifiers. That way, you will get sane
|
|
1382 behavior if the user changes the default toolbar position.
|
|
1383
|
|
1384 The format of the instantiator for a toolbar is a list of
|
|
1385 toolbar-button-descriptors. Each toolbar-button-descriptor
|
|
1386 is a vector in one of the following formats:
|
|
1387
|
|
1388 [GLYPH-LIST FUNCTION ENABLED-P HELP] or
|
|
1389 [:style 2D-OR-3D] or
|
|
1390 [:style 2D-OR-3D :size WIDTH-OR-HEIGHT] or
|
|
1391 [:size WIDTH-OR-HEIGHT :style 2D-OR-3D]
|
|
1392
|
|
1393 Optionally, one of the toolbar-button-descriptors may be nil
|
|
1394 instead of a vector; this signifies the division between
|
|
1395 the toolbar buttons that are to be displayed flush-left,
|
|
1396 and the buttons to be displayed flush-right.
|
|
1397
|
|
1398 The first vector format above specifies a normal toolbar button;
|
|
1399 the others specify blank areas in the toolbar.
|
|
1400
|
|
1401 For the first vector format:
|
|
1402
|
|
1403 -- GLYPH-LIST should be a list of one to six glyphs (as created by
|
|
1404 `make-glyph') or a symbol whose value is such a list. The first
|
|
1405 glyph, which must be provided, is the glyph used to display the
|
|
1406 toolbar button when it is in the \"up\" (not pressed) state. The
|
|
1407 optional second glyph is for displaying the button when it is in
|
|
1408 the \"down\" (pressed) state. The optional third glyph is for when
|
|
1409 the button is disabled. The optional fourth, fifth and sixth glyphs
|
|
1410 are used to specify captioned versions for the up, down and disabled
|
|
1411 states respectively. The function `toolbar-make-button-list' is
|
|
1412 useful in creating these glyph lists. The specifier variable
|
|
1413 `toolbar-buttons-captioned-p' controls which glyphs are actually used.
|
|
1414
|
|
1415 -- Even if you do not provide separate down-state and disabled-state
|
|
1416 glyphs, the user will still get visual feedback to indicate which
|
|
1417 state the button is in. Buttons in the up-state are displayed
|
|
1418 with a shadowed border that gives a raised appearance to the
|
|
1419 button. Buttons in the down-state are displayed with shadows that
|
|
1420 give a recessed appearance. Buttons in the disabled state are
|
|
1421 displayed with no shadows, giving a 2-d effect.
|
|
1422
|
|
1423 -- If some of the toolbar glyphs are not provided, they inherit as follows:
|
|
1424
|
|
1425 UP: up
|
|
1426 DOWN: down -> up
|
|
1427 DISABLED: disabled -> up
|
|
1428 CAP-UP: cap-up -> up
|
|
1429 CAP-DOWN: cap-down -> cap-up -> down -> up
|
|
1430 CAP-DISABLED: cap-disabled -> cap-up -> disabled -> up
|
|
1431
|
|
1432 -- The second element FUNCTION is a function to be called when the
|
|
1433 toolbar button is activated (i.e. when the mouse is released over
|
|
1434 the toolbar button, if the press occurred in the toolbar). It
|
|
1435 can be any form accepted by `call-interactively', since this is
|
|
1436 how it is invoked.
|
|
1437
|
|
1438 -- The third element ENABLED-P specifies whether the toolbar button
|
|
1439 is enabled (disabled buttons do nothing when they are activated,
|
|
1440 and are displayed differently; see above). It should be either
|
|
1441 a boolean or a form that evaluates to a boolean.
|
|
1442
|
|
1443 -- The fourth element HELP, if non-nil, should be a string. This
|
|
1444 string is displayed in the echo area when the mouse passes over
|
|
1445 the toolbar button.
|
|
1446
|
|
1447 For the other vector formats (specifying blank areas of the toolbar):
|
|
1448
|
|
1449 -- 2D-OR-3D should be one of the symbols '2d or '3d, indicating
|
|
1450 whether the area is displayed with shadows (giving it a raised,
|
|
1451 3-d appearance) or without shadows (giving it a flat appearance).
|
|
1452
|
|
1453 -- WIDTH-OR-HEIGHT specifies the length, in pixels, of the blank
|
|
1454 area. If omitted, it defaults to a device-specific value
|
|
1455 (8 pixels for X devices).
|
|
1456 */ );
|
|
1457
|
|
1458 Vdefault_toolbar = Fmake_specifier (Qtoolbar);
|
|
1459 /* #### It would be even nicer if the specifier caching
|
|
1460 automatically knew about specifier fallbacks, so we didn't
|
|
1461 have to do it ourselves. */
|
|
1462 set_specifier_caching (Vdefault_toolbar,
|
|
1463 slot_offset (struct window,
|
|
1464 default_toolbar),
|
|
1465 default_toolbar_specs_changed,
|
|
1466 0, 0);
|
|
1467
|
|
1468 DEFVAR_SPECIFIER ("top-toolbar",
|
|
1469 &Vtoolbar[TOP_TOOLBAR] /*
|
|
1470 Specifier for the toolbar at the top of the frame.
|
|
1471 Use `set-specifier' to change this.
|
|
1472 See `default-toolbar' for a description of a valid toolbar instantiator.
|
|
1473 */ );
|
|
1474 Vtoolbar[TOP_TOOLBAR] = Fmake_specifier (Qtoolbar);
|
|
1475 set_specifier_caching (Vtoolbar[TOP_TOOLBAR],
|
|
1476 slot_offset (struct window,
|
|
1477 toolbar[TOP_TOOLBAR]),
|
|
1478 toolbar_specs_changed,
|
|
1479 0, 0);
|
|
1480
|
|
1481 DEFVAR_SPECIFIER ("bottom-toolbar",
|
|
1482 &Vtoolbar[BOTTOM_TOOLBAR] /*
|
|
1483 Specifier for the toolbar at the bottom of the frame.
|
|
1484 Use `set-specifier' to change this.
|
|
1485 See `default-toolbar' for a description of a valid toolbar instantiator.
|
|
1486
|
|
1487 Note that, unless the `default-toolbar-position' is `bottom', by
|
|
1488 default the height of the bottom toolbar (controlled by
|
|
1489 `bottom-toolbar-height') is 0; thus, a bottom toolbar will not be
|
|
1490 displayed even if you provide a value for `bottom-toolbar'.
|
|
1491 */ );
|
|
1492 Vtoolbar[BOTTOM_TOOLBAR] = Fmake_specifier (Qtoolbar);
|
|
1493 set_specifier_caching (Vtoolbar[BOTTOM_TOOLBAR],
|
|
1494 slot_offset (struct window,
|
|
1495 toolbar[BOTTOM_TOOLBAR]),
|
|
1496 toolbar_specs_changed,
|
|
1497 0, 0);
|
|
1498
|
|
1499 DEFVAR_SPECIFIER ("left-toolbar",
|
|
1500 &Vtoolbar[LEFT_TOOLBAR] /*
|
|
1501 Specifier for the toolbar at the left edge of the frame.
|
|
1502 Use `set-specifier' to change this.
|
|
1503 See `default-toolbar' for a description of a valid toolbar instantiator.
|
|
1504
|
|
1505 Note that, unless the `default-toolbar-position' is `left', by
|
|
1506 default the height of the left toolbar (controlled by
|
|
1507 `left-toolbar-width') is 0; thus, a left toolbar will not be
|
|
1508 displayed even if you provide a value for `left-toolbar'.
|
|
1509 */ );
|
|
1510 Vtoolbar[LEFT_TOOLBAR] = Fmake_specifier (Qtoolbar);
|
|
1511 set_specifier_caching (Vtoolbar[LEFT_TOOLBAR],
|
|
1512 slot_offset (struct window,
|
|
1513 toolbar[LEFT_TOOLBAR]),
|
|
1514 toolbar_specs_changed,
|
|
1515 0, 0);
|
|
1516
|
|
1517 DEFVAR_SPECIFIER ("right-toolbar",
|
|
1518 &Vtoolbar[RIGHT_TOOLBAR] /*
|
|
1519 Specifier for the toolbar at the right edge of the frame.
|
|
1520 Use `set-specifier' to change this.
|
|
1521 See `default-toolbar' for a description of a valid toolbar instantiator.
|
|
1522
|
|
1523 Note that, unless the `default-toolbar-position' is `right', by
|
|
1524 default the height of the right toolbar (controlled by
|
|
1525 `right-toolbar-width') is 0; thus, a right toolbar will not be
|
|
1526 displayed even if you provide a value for `right-toolbar'.
|
|
1527 */ );
|
|
1528 Vtoolbar[RIGHT_TOOLBAR] = Fmake_specifier (Qtoolbar);
|
|
1529 set_specifier_caching (Vtoolbar[RIGHT_TOOLBAR],
|
|
1530 slot_offset (struct window,
|
|
1531 toolbar[RIGHT_TOOLBAR]),
|
|
1532 toolbar_specs_changed,
|
|
1533 0, 0);
|
|
1534
|
|
1535 /* initially, top inherits from default; this can be
|
|
1536 changed with `set-default-toolbar-position'. */
|
|
1537 elt = list1 (Fcons (Qnil, Qnil));
|
|
1538 set_specifier_fallback (Vdefault_toolbar, elt);
|
|
1539 set_specifier_fallback (Vtoolbar[TOP_TOOLBAR], Vdefault_toolbar);
|
|
1540 set_specifier_fallback (Vtoolbar[BOTTOM_TOOLBAR], elt);
|
|
1541 set_specifier_fallback (Vtoolbar[LEFT_TOOLBAR], elt);
|
|
1542 set_specifier_fallback (Vtoolbar[RIGHT_TOOLBAR], elt);
|
|
1543
|
|
1544 DEFVAR_SPECIFIER ("default-toolbar-height", &Vdefault_toolbar_height /*
|
|
1545 *Height of the default toolbar, if it's oriented horizontally.
|
|
1546 This is a specifier; use `set-specifier' to change it.
|
|
1547
|
|
1548 The position of the default toolbar is specified by the function
|
|
1549 `set-default-toolbar-position'. If the corresponding position-specific
|
|
1550 toolbar thickness specifier (e.g. `top-toolbar-height' if
|
|
1551 `default-toolbar-position' is 'top) does not specify a thickness in a
|
|
1552 particular domain (a window or a frame), then the value of
|
|
1553 `default-toolbar-height' or `default-toolbar-width' (depending on the
|
|
1554 toolbar orientation) in that domain, if any, will be used instead.
|
|
1555
|
|
1556 Note that `default-toolbar-height' is only used when
|
|
1557 `default-toolbar-position' is 'top or 'bottom, and `default-toolbar-width'
|
|
1558 is only used when `default-toolbar-position' is 'left or 'right.
|
|
1559
|
|
1560 Note that all of the position-specific toolbar thickness specifiers
|
|
1561 have a fallback value of zero when they do not correspond to the
|
|
1562 default toolbar. Therefore, you will have to set a non-zero thickness
|
|
1563 value if you want a position-specific toolbar to be displayed.
|
|
1564
|
|
1565 Internally, toolbar thickness specifiers are instantiated in both
|
|
1566 window and frame domains, for different purposes. The value in the
|
|
1567 domain of a frame's selected window specifies the actual toolbar
|
|
1568 thickness that you will see in that frame. The value in the domain of
|
|
1569 a frame itself specifies the toolbar thickness that is used in frame
|
|
1570 geometry calculations.
|
|
1571
|
|
1572 Thus, for example, if you set the frame width to 80 characters and the
|
|
1573 left toolbar width for that frame to 68 pixels, then the frame will
|
|
1574 be sized to fit 80 characters plus a 68-pixel left toolbar. If you
|
|
1575 then set the left toolbar width to 0 for a particular buffer (or if
|
|
1576 that buffer does not specify a left toolbar or has a nil value
|
|
1577 specified for `left-toolbar-visible-p'), you will find that, when
|
|
1578 that buffer is displayed in the selected window, the window will have
|
|
1579 a width of 86 or 87 characters -- the frame is sized for a 68-pixel
|
|
1580 left toolbar but the selected window specifies that the left toolbar
|
|
1581 is not visible, so it is expanded to take up the slack.
|
|
1582 */ );
|
|
1583 Vdefault_toolbar_height = Fmake_specifier (Qnatnum);
|
|
1584 set_specifier_caching (Vdefault_toolbar_height,
|
|
1585 slot_offset (struct window,
|
|
1586 default_toolbar_height),
|
|
1587 some_window_value_changed,
|
|
1588 slot_offset (struct frame,
|
|
1589 default_toolbar_height),
|
|
1590 default_toolbar_size_changed_in_frame);
|
|
1591
|
|
1592 DEFVAR_SPECIFIER ("default-toolbar-width", &Vdefault_toolbar_width /*
|
|
1593 *Width of the default toolbar, if it's oriented vertically.
|
|
1594 This is a specifier; use `set-specifier' to change it.
|
|
1595
|
|
1596 See `default-toolbar-height' for more information.
|
|
1597 */ );
|
|
1598 Vdefault_toolbar_width = Fmake_specifier (Qnatnum);
|
|
1599 set_specifier_caching (Vdefault_toolbar_width,
|
|
1600 slot_offset (struct window,
|
|
1601 default_toolbar_width),
|
|
1602 some_window_value_changed,
|
|
1603 slot_offset (struct frame,
|
|
1604 default_toolbar_width),
|
|
1605 default_toolbar_size_changed_in_frame);
|
|
1606
|
|
1607 DEFVAR_SPECIFIER ("top-toolbar-height",
|
|
1608 &Vtoolbar_size[TOP_TOOLBAR] /*
|
|
1609 *Height of the top toolbar.
|
|
1610 This is a specifier; use `set-specifier' to change it.
|
|
1611
|
|
1612 See `default-toolbar-height' for more information.
|
|
1613 */ );
|
|
1614 Vtoolbar_size[TOP_TOOLBAR] = Fmake_specifier (Qnatnum);
|
|
1615 set_specifier_caching (Vtoolbar_size[TOP_TOOLBAR],
|
|
1616 slot_offset (struct window,
|
|
1617 toolbar_size[TOP_TOOLBAR]),
|
|
1618 some_window_value_changed,
|
|
1619 slot_offset (struct frame,
|
|
1620 toolbar_size[TOP_TOOLBAR]),
|
|
1621 toolbar_size_changed_in_frame);
|
|
1622
|
|
1623 DEFVAR_SPECIFIER ("bottom-toolbar-height",
|
|
1624 &Vtoolbar_size[BOTTOM_TOOLBAR] /*
|
|
1625 *Height of the bottom toolbar.
|
|
1626 This is a specifier; use `set-specifier' to change it.
|
|
1627
|
|
1628 See `default-toolbar-height' for more information.
|
|
1629 */ );
|
|
1630 Vtoolbar_size[BOTTOM_TOOLBAR] = Fmake_specifier (Qnatnum);
|
|
1631 set_specifier_caching (Vtoolbar_size[BOTTOM_TOOLBAR],
|
|
1632 slot_offset (struct window,
|
|
1633 toolbar_size[BOTTOM_TOOLBAR]),
|
|
1634 some_window_value_changed,
|
|
1635 slot_offset (struct frame,
|
|
1636 toolbar_size[BOTTOM_TOOLBAR]),
|
|
1637 toolbar_size_changed_in_frame);
|
|
1638
|
|
1639 DEFVAR_SPECIFIER ("left-toolbar-width",
|
|
1640 &Vtoolbar_size[LEFT_TOOLBAR] /*
|
|
1641 *Width of left toolbar.
|
|
1642 This is a specifier; use `set-specifier' to change it.
|
|
1643
|
|
1644 See `default-toolbar-height' for more information.
|
|
1645 */ );
|
|
1646 Vtoolbar_size[LEFT_TOOLBAR] = Fmake_specifier (Qnatnum);
|
|
1647 set_specifier_caching (Vtoolbar_size[LEFT_TOOLBAR],
|
|
1648 slot_offset (struct window,
|
|
1649 toolbar_size[LEFT_TOOLBAR]),
|
|
1650 some_window_value_changed,
|
|
1651 slot_offset (struct frame,
|
|
1652 toolbar_size[LEFT_TOOLBAR]),
|
|
1653 toolbar_size_changed_in_frame);
|
|
1654
|
|
1655 DEFVAR_SPECIFIER ("right-toolbar-width",
|
|
1656 &Vtoolbar_size[RIGHT_TOOLBAR] /*
|
|
1657 *Width of right toolbar.
|
|
1658 This is a specifier; use `set-specifier' to change it.
|
|
1659
|
|
1660 See `default-toolbar-height' for more information.
|
|
1661 */ );
|
|
1662 Vtoolbar_size[RIGHT_TOOLBAR] = Fmake_specifier (Qnatnum);
|
|
1663 set_specifier_caching (Vtoolbar_size[RIGHT_TOOLBAR],
|
|
1664 slot_offset (struct window,
|
|
1665 toolbar_size[RIGHT_TOOLBAR]),
|
|
1666 some_window_value_changed,
|
|
1667 slot_offset (struct frame,
|
|
1668 toolbar_size[RIGHT_TOOLBAR]),
|
|
1669 toolbar_size_changed_in_frame);
|
|
1670
|
|
1671 /* #### this is ugly. */
|
78
|
1672 /* sb - even uglier to make this work without console tty support, ugh. */
|
|
1673 elt = Qnil;
|
|
1674 #ifdef HAVE_TTY
|
0
|
1675 elt = list1 (Fcons (list1 (Qtty), Qzero));
|
78
|
1676 #endif
|
0
|
1677 #ifdef HAVE_X_WINDOWS
|
80
|
1678 if (!EQ(elt, Qnil))
|
78
|
1679 elt = Fcons (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_HEIGHT)), elt);
|
|
1680 else
|
|
1681 elt = list1 (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_HEIGHT)));
|
0
|
1682 #endif
|
80
|
1683 if (!EQ(elt, Qnil))
|
78
|
1684 set_specifier_fallback (Vdefault_toolbar_height, elt);
|
|
1685
|
|
1686 elt = Qnil;
|
|
1687 #ifdef HAVE_TTY
|
0
|
1688 elt = list1 (Fcons (list1 (Qtty), Qzero));
|
78
|
1689 #endif
|
0
|
1690 #ifdef HAVE_X_WINDOWS
|
80
|
1691 if (!EQ(elt, Qnil))
|
78
|
1692 elt = Fcons (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_WIDTH)), elt);
|
|
1693 else
|
|
1694 elt = list1 (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_WIDTH)));
|
0
|
1695 #endif
|
80
|
1696 if (!EQ(elt, Qnil))
|
78
|
1697 set_specifier_fallback (Vdefault_toolbar_width, elt);
|
0
|
1698
|
|
1699 set_specifier_fallback (Vtoolbar_size[TOP_TOOLBAR], Vdefault_toolbar_height);
|
|
1700 elt = list1 (Fcons (Qnil, Qzero));
|
|
1701 set_specifier_fallback (Vtoolbar_size[BOTTOM_TOOLBAR], elt);
|
|
1702 set_specifier_fallback (Vtoolbar_size[LEFT_TOOLBAR], elt);
|
|
1703 set_specifier_fallback (Vtoolbar_size[RIGHT_TOOLBAR], elt);
|
|
1704
|
|
1705 DEFVAR_SPECIFIER ("default-toolbar-visible-p", &Vdefault_toolbar_visible_p /*
|
|
1706 *Whether the default toolbar is visible.
|
|
1707 This is a specifier; use `set-specifier' to change it.
|
|
1708
|
|
1709 The position of the default toolbar is specified by the function
|
|
1710 `set-default-toolbar-position'. If the corresponding position-specific
|
|
1711 toolbar visibility specifier (e.g. `top-toolbar-visible-p' if
|
|
1712 `default-toolbar-position' is 'top) does not specify a visible-p value
|
|
1713 in a particular domain (a window or a frame), then the value of
|
|
1714 `default-toolbar-visible-p' in that domain, if any, will be used
|
|
1715 instead.
|
|
1716
|
|
1717 Both window domains and frame domains are used internally, for
|
|
1718 different purposes. The distinction here is exactly the same as
|
|
1719 for thickness specifiers; see `default-toolbar-height' for more
|
|
1720 information.
|
|
1721
|
|
1722 `default-toolbar-visible-p' and all of the position-specific toolbar
|
|
1723 visibility specifiers have a fallback value of true.
|
|
1724 */ );
|
|
1725 Vdefault_toolbar_visible_p = Fmake_specifier (Qboolean);
|
|
1726 set_specifier_caching (Vdefault_toolbar_visible_p,
|
|
1727 slot_offset (struct window,
|
|
1728 default_toolbar_visible_p),
|
|
1729 some_window_value_changed,
|
|
1730 slot_offset (struct frame,
|
|
1731 default_toolbar_visible_p),
|
|
1732 default_toolbar_visible_p_changed_in_frame);
|
|
1733
|
|
1734 DEFVAR_SPECIFIER ("top-toolbar-visible-p",
|
|
1735 &Vtoolbar_visible_p[TOP_TOOLBAR] /*
|
|
1736 *Whether the top toolbar is visible.
|
|
1737 This is a specifier; use `set-specifier' to change it.
|
|
1738
|
|
1739 See `default-toolbar-visible-p' for more information.
|
|
1740 */ );
|
|
1741 Vtoolbar_visible_p[TOP_TOOLBAR] = Fmake_specifier (Qboolean);
|
|
1742 set_specifier_caching (Vtoolbar_visible_p[TOP_TOOLBAR],
|
|
1743 slot_offset (struct window,
|
|
1744 toolbar_visible_p[TOP_TOOLBAR]),
|
|
1745 some_window_value_changed,
|
|
1746 slot_offset (struct frame,
|
|
1747 toolbar_visible_p[TOP_TOOLBAR]),
|
|
1748 toolbar_visible_p_changed_in_frame);
|
|
1749
|
|
1750 DEFVAR_SPECIFIER ("bottom-toolbar-visible-p",
|
|
1751 &Vtoolbar_visible_p[BOTTOM_TOOLBAR] /*
|
|
1752 *Whether the bottom toolbar is visible.
|
|
1753 This is a specifier; use `set-specifier' to change it.
|
|
1754
|
|
1755 See `default-toolbar-visible-p' for more information.
|
|
1756 */ );
|
|
1757 Vtoolbar_visible_p[BOTTOM_TOOLBAR] = Fmake_specifier (Qboolean);
|
|
1758 set_specifier_caching (Vtoolbar_visible_p[BOTTOM_TOOLBAR],
|
|
1759 slot_offset (struct window,
|
|
1760 toolbar_visible_p[BOTTOM_TOOLBAR]),
|
|
1761 some_window_value_changed,
|
|
1762 slot_offset (struct frame,
|
|
1763 toolbar_visible_p[BOTTOM_TOOLBAR]),
|
|
1764 toolbar_visible_p_changed_in_frame);
|
|
1765
|
|
1766 DEFVAR_SPECIFIER ("left-toolbar-visible-p",
|
|
1767 &Vtoolbar_visible_p[LEFT_TOOLBAR] /*
|
|
1768 *Whether the left toolbar is visible.
|
|
1769 This is a specifier; use `set-specifier' to change it.
|
|
1770
|
|
1771 See `default-toolbar-visible-p' for more information.
|
|
1772 */ );
|
|
1773 Vtoolbar_visible_p[LEFT_TOOLBAR] = Fmake_specifier (Qboolean);
|
|
1774 set_specifier_caching (Vtoolbar_visible_p[LEFT_TOOLBAR],
|
|
1775 slot_offset (struct window,
|
|
1776 toolbar_visible_p[LEFT_TOOLBAR]),
|
|
1777 some_window_value_changed,
|
|
1778 slot_offset (struct frame,
|
|
1779 toolbar_visible_p[LEFT_TOOLBAR]),
|
|
1780 toolbar_visible_p_changed_in_frame);
|
|
1781
|
|
1782 DEFVAR_SPECIFIER ("right-toolbar-visible-p",
|
|
1783 &Vtoolbar_visible_p[RIGHT_TOOLBAR] /*
|
|
1784 *Whether the right toolbar is visible.
|
|
1785 This is a specifier; use `set-specifier' to change it.
|
|
1786
|
|
1787 See `default-toolbar-visible-p' for more information.
|
|
1788 */ );
|
|
1789 Vtoolbar_visible_p[RIGHT_TOOLBAR] = Fmake_specifier (Qboolean);
|
|
1790 set_specifier_caching (Vtoolbar_visible_p[RIGHT_TOOLBAR],
|
|
1791 slot_offset (struct window,
|
|
1792 toolbar_visible_p[RIGHT_TOOLBAR]),
|
|
1793 some_window_value_changed,
|
|
1794 slot_offset (struct frame,
|
|
1795 toolbar_visible_p[RIGHT_TOOLBAR]),
|
|
1796 toolbar_visible_p_changed_in_frame);
|
|
1797
|
|
1798 /* initially, top inherits from default; this can be
|
|
1799 changed with `set-default-toolbar-position'. */
|
|
1800 elt = list1 (Fcons (Qnil, Qt));
|
|
1801 set_specifier_fallback (Vdefault_toolbar_visible_p, elt);
|
|
1802 set_specifier_fallback (Vtoolbar_visible_p[TOP_TOOLBAR],
|
|
1803 Vdefault_toolbar_visible_p);
|
|
1804 set_specifier_fallback (Vtoolbar_visible_p[BOTTOM_TOOLBAR], elt);
|
|
1805 set_specifier_fallback (Vtoolbar_visible_p[LEFT_TOOLBAR], elt);
|
|
1806 set_specifier_fallback (Vtoolbar_visible_p[RIGHT_TOOLBAR], elt);
|
|
1807
|
|
1808 DEFVAR_SPECIFIER ("toolbar-buttons-captioned-p",
|
|
1809 &Vtoolbar_buttons_captioned_p /*
|
|
1810 *Whether the toolbar buttons are captioned.
|
|
1811 This will only have a visible effect for those toolbar buttons which had
|
|
1812 captioned versions specified.
|
|
1813 This is a specifier; use `set-specifier' to change it.
|
|
1814 */ );
|
|
1815 Vtoolbar_buttons_captioned_p = Fmake_specifier (Qboolean);
|
|
1816 set_specifier_caching (Vtoolbar_buttons_captioned_p,
|
|
1817 slot_offset (struct window,
|
|
1818 toolbar_buttons_captioned_p),
|
|
1819 toolbar_buttons_captioned_p_changed,
|
|
1820 0, 0);
|
|
1821 set_specifier_fallback (Vtoolbar_buttons_captioned_p,
|
|
1822 list1 (Fcons (Qnil, Qt)));
|
|
1823 }
|