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));
|
173
|
63 return data->toolbar_buttons;
|
0
|
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));
|
173
|
84 return data->help_string;
|
0
|
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 {
|
173
|
112 return TOOLBAR_BUTTONP (object) ? Qt : Qnil;
|
0
|
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
|
173
|
132 return XTOOLBAR_BUTTON (button)->callback;
|
0
|
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
|
173
|
142 return XTOOLBAR_BUTTON (button)->help_string;
|
0
|
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
|
173
|
152 return XTOOLBAR_BUTTON (button)->enabled ? Qt : Qnil;
|
0
|
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;
|
173
|
198 }
|
0
|
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;
|
173
|
221
|
0
|
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);
|
173
|
251
|
2
|
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
|
173
|
307 elt = XVECTOR_DATA (desc);
|
0
|
308 buffer = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer;
|
|
309
|
|
310 if (!tb)
|
|
311 {
|
185
|
312 tb = alloc_lcrecord_type (struct toolbar_button, lrecord_toolbar_button);
|
0
|
313 tb->next = Qnil;
|
|
314 XSETFRAME (tb->frame, f);
|
|
315 tb->up_glyph = Qnil;
|
|
316 tb->down_glyph = Qnil;
|
|
317 tb->disabled_glyph = Qnil;
|
|
318 tb->cap_up_glyph = Qnil;
|
|
319 tb->cap_down_glyph = Qnil;
|
|
320 tb->cap_disabled_glyph = Qnil;
|
|
321 tb->callback = Qnil;
|
|
322 tb->enabled_p = Qnil;
|
|
323 tb->help_string = Qnil;
|
|
324
|
|
325 tb->enabled = 0;
|
|
326 tb->down = 0;
|
|
327 tb->pushright = pushright;
|
|
328 tb->blank = 0;
|
|
329 tb->x = tb->y = tb->width = tb->height = -1;
|
|
330 tb->dirty = 1;
|
|
331 }
|
|
332 XSETTOOLBAR_BUTTON (retval, tb);
|
|
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;
|
173
|
347 int len = XVECTOR_LENGTH (desc);
|
0
|
348
|
|
349 if (!tb->blank)
|
|
350 {
|
|
351 tb->blank = 1;
|
|
352 tb->dirty = 1;
|
|
353 }
|
|
354
|
173
|
355 for (pos = 0; pos < len; pos += 2)
|
0
|
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 {
|
185
|
716 struct toolbar_data *td = alloc_lcrecord_type (struct toolbar_data,
|
|
717 lrecord_toolbar_data);
|
0
|
718
|
|
719 td->last_toolbar_buffer = Qnil;
|
|
720 td->toolbar_buttons = Qnil;
|
|
721 XSETTOOLBAR_DATA (f->toolbar_data[pos], td);
|
|
722 }
|
|
723
|
185
|
724 buttons = visible ? compute_frame_toolbar_buttons (f, pos, toolbar) : Qnil;
|
0
|
725
|
|
726 FRAME_TOOLBAR_DATA (f, pos)->last_toolbar_buffer = buffer;
|
|
727 FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons = buttons;
|
|
728
|
173
|
729 return visible;
|
0
|
730 }
|
|
731
|
|
732 #define COMPUTE_TOOLBAR_DATA(position) \
|
|
733 do \
|
|
734 { \
|
|
735 local_toolbar_changed = \
|
|
736 (f->toolbar_changed \
|
|
737 || NILP (f->toolbar_data[position]) \
|
|
738 || (!EQ (FRAME_TOOLBAR_DATA (f, position)->last_toolbar_buffer, \
|
|
739 XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer))); \
|
|
740 \
|
|
741 toolbar_was_visible = \
|
|
742 (!NILP (f->toolbar_data[position]) \
|
|
743 && !NILP (FRAME_TOOLBAR_DATA (f, position)->toolbar_buttons)); \
|
|
744 toolbar_will_be_visible = toolbar_was_visible; \
|
|
745 \
|
|
746 if (local_toolbar_changed) \
|
|
747 toolbar_will_be_visible = \
|
|
748 set_frame_toolbar (f, position, first_time_p); \
|
|
749 \
|
|
750 toolbar_visibility_changed = \
|
|
751 (toolbar_was_visible != toolbar_will_be_visible); \
|
|
752 \
|
|
753 if (toolbar_visibility_changed) \
|
|
754 frame_changed_size = 1; \
|
|
755 } while (0)
|
|
756
|
|
757 static void
|
|
758 compute_frame_toolbars_data (struct frame *f, int first_time_p)
|
|
759 {
|
|
760 int local_toolbar_changed;
|
|
761 int toolbar_was_visible, toolbar_will_be_visible;
|
|
762 int toolbar_visibility_changed;
|
|
763 int frame_changed_size = 0;
|
|
764
|
|
765 COMPUTE_TOOLBAR_DATA (TOP_TOOLBAR);
|
|
766 COMPUTE_TOOLBAR_DATA (BOTTOM_TOOLBAR);
|
|
767 COMPUTE_TOOLBAR_DATA (LEFT_TOOLBAR);
|
|
768 COMPUTE_TOOLBAR_DATA (RIGHT_TOOLBAR);
|
|
769
|
|
770 /* The frame itself doesn't actually change size, but the usable
|
|
771 text area does. All we have to do is call change_frame_size with
|
|
772 the current height and width parameters and it will readjust for
|
|
773 all changes in the toolbars. */
|
|
774 if (frame_changed_size && !first_time_p)
|
|
775 change_frame_size (f, FRAME_HEIGHT (f), FRAME_WIDTH (f), 0);
|
|
776 }
|
|
777 #undef COMPUTE_TOOLBAR_DATA
|
|
778
|
|
779 void
|
|
780 update_frame_toolbars (struct frame *f)
|
|
781 {
|
|
782 struct device *d = XDEVICE (f->device);
|
|
783 Lisp_Object buffer = XWINDOW (FRAME_LAST_NONMINIBUF_WINDOW (f))->buffer;
|
|
784
|
|
785 /* If the buffer of the selected window is not equal to the
|
|
786 last_toolbar_buffer value for any of the toolbars, then the
|
|
787 toolbars need to be recomputed. */
|
|
788 if ((HAS_DEVMETH_P (d, output_frame_toolbars))
|
|
789 && (f->toolbar_changed
|
|
790 || !EQ (FRAME_TOOLBAR_BUFFER (f, TOP_TOOLBAR), buffer)
|
|
791 || !EQ (FRAME_TOOLBAR_BUFFER (f, BOTTOM_TOOLBAR), buffer)
|
|
792 || !EQ (FRAME_TOOLBAR_BUFFER (f, LEFT_TOOLBAR), buffer)
|
|
793 || !EQ (FRAME_TOOLBAR_BUFFER (f, RIGHT_TOOLBAR), buffer)))
|
|
794 {
|
|
795 /* Removed the check for the minibuffer here. We handle this
|
|
796 more correctly now by consistently using
|
|
797 FRAME_LAST_NONMINIBUF_WINDOW instead of FRAME_SELECTED_WINDOW
|
|
798 throughout the toolbar code. */
|
|
799 compute_frame_toolbars_data (f, 0);
|
|
800
|
|
801 DEVMETH (d, output_frame_toolbars, (f));
|
|
802 }
|
|
803
|
|
804 f->toolbar_changed = 0;
|
|
805 }
|
|
806
|
|
807 void
|
|
808 init_frame_toolbars (struct frame *f)
|
|
809 {
|
|
810 struct device *d = XDEVICE (f->device);
|
|
811
|
|
812 /* If there isn't any output routine, then this device type doesn't
|
|
813 support toolbars. */
|
|
814 if (HAS_DEVMETH_P (d, output_frame_toolbars))
|
|
815 {
|
|
816 Lisp_Object frame = Qnil;
|
|
817
|
|
818 compute_frame_toolbars_data (f, 1);
|
|
819 XSETFRAME (frame, f);
|
|
820 call_critical_lisp_code (XDEVICE (FRAME_DEVICE (f)),
|
|
821 Qinit_toolbar_from_resources,
|
|
822 frame);
|
|
823 MAYBE_DEVMETH (d, initialize_frame_toolbars, (f));
|
|
824 }
|
|
825 }
|
|
826
|
|
827 void
|
|
828 init_device_toolbars (struct device *d)
|
|
829 {
|
|
830 Lisp_Object device = Qnil;
|
|
831
|
|
832 XSETDEVICE (device, d);
|
|
833 if (HAS_DEVMETH_P (d, output_frame_toolbars))
|
|
834 call_critical_lisp_code (d,
|
|
835 Qinit_toolbar_from_resources,
|
|
836 device);
|
|
837 }
|
|
838
|
|
839 void
|
|
840 init_global_toolbars (struct device *d)
|
|
841 {
|
|
842 if (HAS_DEVMETH_P (d, output_frame_toolbars))
|
|
843 call_critical_lisp_code (d,
|
|
844 Qinit_toolbar_from_resources,
|
|
845 Qglobal);
|
|
846 }
|
|
847
|
|
848 void
|
|
849 free_frame_toolbars (struct frame *f)
|
|
850 {
|
|
851 /* If we had directly allocated any memory for the toolbars instead
|
|
852 of using all Lisp_Objects this is where we would now free it. */
|
|
853
|
|
854 MAYBE_FRAMEMETH (f, free_frame_toolbars, (f));
|
|
855 }
|
|
856
|
|
857 void
|
|
858 get_toolbar_coords (struct frame *f, enum toolbar_pos pos, int *x, int *y,
|
|
859 int *width, int *height, int *vert, int for_layout)
|
|
860 {
|
|
861 int visible_top_toolbar_height, visible_bottom_toolbar_height;
|
|
862 int adjust = (for_layout ? 1 : 0);
|
|
863
|
|
864 /* The top and bottom toolbars take precedence over the left and
|
|
865 right. */
|
|
866 visible_top_toolbar_height = (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f)
|
|
867 ? FRAME_REAL_TOP_TOOLBAR_HEIGHT (f)
|
|
868 : 0);
|
|
869 visible_bottom_toolbar_height = (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f)
|
|
870 ? FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f)
|
|
871 : 0);
|
|
872
|
|
873 /* We adjust the width and height by one to give us a narrow border
|
|
874 at the outside edges. However, when we are simply determining
|
|
875 toolbar location we don't want to do that. */
|
|
876
|
|
877 switch (pos)
|
|
878 {
|
|
879 case TOP_TOOLBAR:
|
|
880 *x = 1;
|
|
881 *y = 0; /* #### should be 1 if no menubar */
|
|
882 *width = FRAME_PIXWIDTH (f) - 2;
|
|
883 *height = FRAME_REAL_TOP_TOOLBAR_HEIGHT (f) - adjust;
|
|
884 *vert = 0;
|
|
885 break;
|
|
886 case BOTTOM_TOOLBAR:
|
|
887 *x = 1;
|
|
888 *y = FRAME_PIXHEIGHT (f) - FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f);
|
|
889 *width = FRAME_PIXWIDTH (f) - 2;
|
|
890 *height = FRAME_REAL_BOTTOM_TOOLBAR_HEIGHT (f) - adjust;
|
|
891 *vert = 0;
|
|
892 break;
|
|
893 case LEFT_TOOLBAR:
|
|
894 *x = 1;
|
|
895 *y = visible_top_toolbar_height;
|
|
896 *width = FRAME_REAL_LEFT_TOOLBAR_WIDTH (f) - adjust;
|
|
897 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height -
|
|
898 visible_bottom_toolbar_height - 1);
|
|
899 *vert = 1;
|
|
900 break;
|
|
901 case RIGHT_TOOLBAR:
|
|
902 *x = FRAME_PIXWIDTH (f) - FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f);
|
|
903 *y = visible_top_toolbar_height;
|
|
904 *width = FRAME_REAL_RIGHT_TOOLBAR_WIDTH (f) - adjust;
|
|
905 *height = (FRAME_PIXHEIGHT (f) - visible_top_toolbar_height -
|
|
906 visible_bottom_toolbar_height);
|
|
907 *vert = 1;
|
|
908 break;
|
|
909 default:
|
|
910 abort ();
|
|
911 }
|
|
912 }
|
|
913
|
|
914 #define CHECK_TOOLBAR(pos) \
|
|
915 do \
|
|
916 { \
|
|
917 get_toolbar_coords (f, pos, &x, &y, &width, &height, &vert, 0); \
|
|
918 if ((x_coord >= x) && (x_coord < (x + width))) \
|
|
919 { \
|
|
920 if ((y_coord >= y) && (y_coord < (y + height))) \
|
173
|
921 return FRAME_TOOLBAR_DATA (f, pos)->toolbar_buttons; \
|
0
|
922 } \
|
|
923 } while (0)
|
|
924
|
|
925 static Lisp_Object
|
|
926 toolbar_buttons_at_pixpos (struct frame *f, int x_coord, int y_coord)
|
|
927 {
|
|
928 int x, y, width, height, vert;
|
|
929
|
|
930 if (FRAME_REAL_TOP_TOOLBAR_VISIBLE (f))
|
|
931 CHECK_TOOLBAR (TOP_TOOLBAR);
|
|
932 if (FRAME_REAL_BOTTOM_TOOLBAR_VISIBLE (f))
|
|
933 CHECK_TOOLBAR (BOTTOM_TOOLBAR);
|
|
934 if (FRAME_REAL_LEFT_TOOLBAR_VISIBLE (f))
|
|
935 CHECK_TOOLBAR (LEFT_TOOLBAR);
|
|
936 if (FRAME_REAL_RIGHT_TOOLBAR_VISIBLE (f))
|
|
937 CHECK_TOOLBAR (RIGHT_TOOLBAR);
|
|
938
|
|
939 return Qnil;
|
|
940 }
|
|
941 #undef CHECK_TOOLBAR
|
|
942
|
|
943 /* The device dependent code actually does the work of positioning the
|
|
944 buttons, but we are free to access that information at this
|
|
945 level. */
|
|
946 Lisp_Object
|
|
947 toolbar_button_at_pixpos (struct frame *f, int x_coord, int y_coord)
|
|
948 {
|
|
949 Lisp_Object buttons = toolbar_buttons_at_pixpos (f, x_coord, y_coord);
|
|
950
|
|
951 if (NILP (buttons))
|
|
952 return Qnil;
|
|
953
|
|
954 while (!NILP (buttons))
|
|
955 {
|
|
956 struct toolbar_button *tb = XTOOLBAR_BUTTON (buttons);
|
|
957
|
|
958 if ((x_coord >= tb->x) && (x_coord < (tb->x + tb->width)))
|
|
959 {
|
|
960 if ((y_coord >= tb->y) && (y_coord < (tb->y + tb->height)))
|
|
961 {
|
|
962 /* If we are over a blank, return nil. */
|
|
963 if (tb->blank)
|
|
964 return Qnil;
|
|
965 else
|
|
966 return buttons;
|
|
967 }
|
|
968 }
|
|
969
|
|
970 buttons = tb->next;
|
|
971 }
|
|
972
|
|
973 /* We must be over a blank in the toolbar. */
|
|
974 return Qnil;
|
|
975 }
|
|
976
|
|
977
|
|
978 /************************************************************************/
|
|
979 /* Toolbar specifier type */
|
|
980 /************************************************************************/
|
|
981
|
|
982 DEFINE_SPECIFIER_TYPE (toolbar);
|
|
983
|
|
984 #define CTB_ERROR(msg) \
|
|
985 do \
|
|
986 { \
|
|
987 maybe_signal_simple_error (msg, button, Qtoolbar, errb); \
|
|
988 RETURN__ Qnil; \
|
|
989 } \
|
|
990 while (0)
|
|
991
|
|
992 /* Returns Q_style if key was :style, Qt if ok otherwise, Qnil if error. */
|
|
993 static Lisp_Object
|
|
994 check_toolbar_button_keywords (Lisp_Object button, Lisp_Object key,
|
|
995 Lisp_Object val, Error_behavior errb)
|
|
996 {
|
|
997 if (!KEYWORDP (key))
|
|
998 {
|
|
999 maybe_signal_simple_error_2 ("not a keyword", key, button, Qtoolbar,
|
|
1000 errb);
|
|
1001 return Qnil;
|
|
1002 }
|
|
1003
|
|
1004 if (EQ (key, Q_style))
|
|
1005 {
|
|
1006 if (!EQ (val, Q2D)
|
|
1007 && !EQ (val, Q3D)
|
|
1008 && !EQ (val, Q2d)
|
|
1009 && !EQ (val, Q3d))
|
|
1010 CTB_ERROR ("unrecognized toolbar blank style");
|
|
1011
|
|
1012 return Q_style;
|
|
1013 }
|
|
1014 else if (EQ (key, Q_size))
|
|
1015 {
|
|
1016 if (!NATNUMP (val))
|
|
1017 CTB_ERROR ("invalid toolbar blank size");
|
|
1018 }
|
|
1019 else
|
|
1020 {
|
|
1021 CTB_ERROR ("invalid toolbar blank keyword");
|
|
1022 }
|
|
1023
|
|
1024 return Qt;
|
|
1025 }
|
|
1026
|
|
1027 /* toolbar button spec is [pixmap-pair function enabled-p help]
|
|
1028 or [:style 2d-or-3d :size width-or-height] */
|
|
1029
|
20
|
1030 DEFUN ("check-toolbar-button-syntax", Fcheck_toolbar_button_syntax, 1, 2, 0, /*
|
0
|
1031 Verify the syntax of entry BUTTON in a toolbar description list.
|
|
1032 If you want to verify the syntax of a toolbar description list as a
|
|
1033 whole, use `check-valid-instantiator' with a specifier type of 'toolbar.
|
20
|
1034 */
|
|
1035 (button, no_error))
|
0
|
1036 {
|
|
1037 Lisp_Object *elt, glyphs, value;
|
|
1038 int len;
|
|
1039 Error_behavior errb = decode_error_behavior_flag (no_error);
|
|
1040
|
|
1041 if (!VECTORP (button))
|
|
1042 CTB_ERROR ("toolbar button descriptors must be vectors");
|
173
|
1043 elt = XVECTOR_DATA (button);
|
0
|
1044
|
173
|
1045 if (XVECTOR_LENGTH (button) == 2)
|
0
|
1046 {
|
|
1047 if (!EQ (Q_style, check_toolbar_button_keywords (button, elt[0],
|
|
1048 elt[1], errb)))
|
|
1049 CTB_ERROR ("must specify toolbar blank style");
|
|
1050
|
|
1051 return Qt;
|
|
1052 }
|
|
1053
|
173
|
1054 if (XVECTOR_LENGTH (button) != 4)
|
0
|
1055 CTB_ERROR ("toolbar button descriptors must be 2 or 4 long");
|
|
1056
|
|
1057 /* The first element must be a list of glyphs of length 1-6. The
|
|
1058 first entry is the pixmap for the up state, the second for the
|
|
1059 down state, the third for the disabled state, the fourth for the
|
|
1060 captioned up state, the fifth for the captioned down state and
|
|
1061 the sixth for the captioned disabled state. Only the up state is
|
|
1062 mandatory. */
|
|
1063 if (!CONSP (elt[0]))
|
|
1064 {
|
|
1065 /* We can't check the buffer-local here because we don't know
|
|
1066 which buffer to check in. #### I think this is a bad thing.
|
|
1067 See if we can't get enough information to this function so
|
|
1068 that it can check.
|
|
1069
|
|
1070 #### Wrong. We shouldn't be checking the value at all here.
|
|
1071 The user might set or change the value at any time. */
|
|
1072 value = Fsymbol_value (elt[0]);
|
|
1073
|
|
1074 if (!CONSP (value))
|
|
1075 {
|
|
1076 if (KEYWORDP (elt[0]))
|
|
1077 {
|
|
1078 int fsty = 0;
|
|
1079
|
|
1080 if (EQ (Q_style, check_toolbar_button_keywords (button, elt[0],
|
|
1081 elt[1],
|
|
1082 errb)))
|
|
1083 fsty++;
|
|
1084
|
|
1085 if (EQ (Q_style, check_toolbar_button_keywords (button, elt[2],
|
|
1086 elt[3],
|
|
1087 errb)))
|
|
1088 fsty++;
|
|
1089
|
|
1090 if (!fsty)
|
|
1091 CTB_ERROR ("must specify toolbar blank style");
|
|
1092 else if (EQ (elt[0], elt[2]))
|
|
1093 CTB_ERROR
|
|
1094 ("duplicate keywords in toolbar button blank description");
|
|
1095
|
|
1096 return Qt;
|
|
1097 }
|
|
1098 else
|
|
1099 CTB_ERROR ("first element of button must be a list (of glyphs)");
|
|
1100 }
|
|
1101 }
|
|
1102 else
|
|
1103 value = elt[0];
|
|
1104
|
|
1105 len = XINT (Flength (value));
|
|
1106 if (len < 1)
|
|
1107 CTB_ERROR ("toolbar button glyph list must have at least 1 entry");
|
173
|
1108
|
0
|
1109 if (len > 6)
|
|
1110 CTB_ERROR ("toolbar button glyph list can have at most 6 entries");
|
|
1111
|
|
1112 glyphs = value;
|
|
1113 while (!NILP (glyphs))
|
|
1114 {
|
|
1115 if (!GLYPHP (XCAR (glyphs)))
|
|
1116 {
|
|
1117 /* We allow nil for the down and disabled glyphs but not for
|
|
1118 the up glyph. */
|
|
1119 if (EQ (glyphs, value) || !NILP (XCAR (glyphs)))
|
|
1120 {
|
|
1121 CTB_ERROR
|
|
1122 ("all elements of toolbar button glyph list must be glyphs.");
|
|
1123 }
|
|
1124 }
|
|
1125 glyphs = XCDR (glyphs);
|
|
1126 }
|
|
1127
|
|
1128 /* The second element is the function to run when the button is
|
|
1129 activated. We do not do any checking on it because it is legal
|
|
1130 for the function to not be defined until after the toolbar is.
|
|
1131 It is the user's problem to get this right.
|
|
1132
|
|
1133 The third element is either a boolean indicating the enabled
|
|
1134 status or a function used to determine it. Again, it is the
|
|
1135 user's problem if this is wrong.
|
|
1136
|
|
1137 The fourth element, if not nil, must be a string which will be
|
|
1138 displayed as the help echo. */
|
|
1139
|
|
1140 /* #### This should be allowed to be a function returning a string
|
|
1141 as well as just a string. */
|
|
1142 if (!NILP (elt[3]) && !STRINGP (elt[3]))
|
|
1143 CTB_ERROR ("toolbar button help echo string must be a string");
|
|
1144
|
|
1145 return Qt;
|
|
1146 }
|
|
1147 #undef CTB_ERROR
|
|
1148
|
|
1149 static void
|
|
1150 toolbar_validate (Lisp_Object instantiator)
|
|
1151 {
|
|
1152 int pushright_seen = 0;
|
|
1153 Lisp_Object rest;
|
|
1154
|
|
1155 if (NILP (instantiator))
|
|
1156 return;
|
|
1157
|
|
1158 if (!CONSP (instantiator))
|
|
1159 signal_simple_error ("toolbar spec must be list or nil", instantiator);
|
|
1160
|
|
1161 for (rest = instantiator; !NILP (rest); rest = XCDR (rest))
|
|
1162 {
|
|
1163 if (!CONSP (rest))
|
|
1164 signal_simple_error ("bad list in toolbar spec", instantiator);
|
|
1165
|
|
1166 if (NILP (XCAR (rest)))
|
|
1167 {
|
|
1168 if (pushright_seen)
|
|
1169 error
|
|
1170 ("more than one partition (nil) in instantiator description");
|
|
1171 else
|
|
1172 pushright_seen = 1;
|
|
1173 }
|
|
1174 else
|
|
1175 Fcheck_toolbar_button_syntax (XCAR (rest), Qnil);
|
|
1176 }
|
|
1177 }
|
|
1178
|
|
1179 static void
|
|
1180 toolbar_after_change (Lisp_Object specifier, Lisp_Object locale)
|
|
1181 {
|
|
1182 /* #### This is overkill. I really need to rethink the after-change
|
|
1183 functions to make them easier to use. */
|
|
1184 MARK_TOOLBAR_CHANGED;
|
|
1185 }
|
|
1186
|
20
|
1187 DEFUN ("toolbar-specifier-p", Ftoolbar_specifier_p, 1, 1, 0, /*
|
0
|
1188 Return non-nil if OBJECT is a toolbar specifier.
|
|
1189 Toolbar specifiers are used to specify the format of a toolbar.
|
|
1190 The values of the variables `default-toolbar', `top-toolbar',
|
|
1191 `left-toolbar', `right-toolbar', and `bottom-toolbar' are always
|
|
1192 toolbar specifiers.
|
|
1193
|
185
|
1194 Valid toolbar instantiators are called "toolbar descriptors"
|
0
|
1195 and are lists of vectors. See `default-toolbar' for a description
|
|
1196 of the exact format.
|
20
|
1197 */
|
|
1198 (object))
|
0
|
1199 {
|
173
|
1200 return TOOLBAR_SPECIFIERP (object) ? Qt : Qnil;
|
0
|
1201 }
|
|
1202
|
|
1203
|
|
1204 static void
|
|
1205 toolbar_specs_changed (Lisp_Object specifier, struct window *w,
|
|
1206 Lisp_Object oldval)
|
|
1207 {
|
|
1208 /* This could be smarter but I doubt that it would make any
|
|
1209 noticable difference given the infrequency with which this is
|
|
1210 probably going to be called.
|
|
1211 */
|
|
1212 MARK_TOOLBAR_CHANGED;
|
|
1213 }
|
|
1214
|
|
1215 static void
|
|
1216 default_toolbar_specs_changed (Lisp_Object specifier, struct window *w,
|
|
1217 Lisp_Object oldval)
|
|
1218 {
|
|
1219 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position);
|
|
1220
|
|
1221 Fset_specifier_dirty_flag (Vtoolbar[pos]);
|
|
1222 }
|
|
1223
|
|
1224 static void
|
|
1225 toolbar_size_changed_in_frame (Lisp_Object specifier, struct frame *f,
|
|
1226 Lisp_Object oldval)
|
|
1227 {
|
2
|
1228 int pos;
|
0
|
1229
|
2
|
1230 for (pos = 0; pos < countof (Vtoolbar_size); pos++)
|
|
1231 if (EQ (specifier, Vtoolbar_size[(enum toolbar_pos) pos]))
|
0
|
1232 break;
|
|
1233
|
2
|
1234 assert (pos < countof (Vtoolbar_size));
|
0
|
1235
|
|
1236 MAYBE_FRAMEMETH (f, toolbar_size_changed_in_frame,
|
185
|
1237 (f, (enum toolbar_pos) pos, oldval));
|
0
|
1238
|
|
1239 /* Let redisplay know that something has possibly changed. */
|
|
1240 MARK_TOOLBAR_CHANGED;
|
|
1241 }
|
|
1242
|
|
1243 static void
|
|
1244 toolbar_visible_p_changed_in_frame (Lisp_Object specifier, struct frame *f,
|
|
1245 Lisp_Object oldval)
|
|
1246 {
|
2
|
1247 int pos;
|
0
|
1248
|
2
|
1249 for (pos = 0; pos < countof (Vtoolbar_visible_p); pos++)
|
|
1250 if (EQ (specifier, Vtoolbar_visible_p[(enum toolbar_pos) pos]))
|
0
|
1251 break;
|
|
1252
|
2
|
1253 assert (pos < countof (Vtoolbar_visible_p));
|
0
|
1254
|
|
1255 MAYBE_FRAMEMETH (f, toolbar_visible_p_changed_in_frame,
|
185
|
1256 (f, (enum toolbar_pos) pos, oldval));
|
0
|
1257
|
|
1258 /* Let redisplay know that something has possibly changed. */
|
|
1259 MARK_TOOLBAR_CHANGED;
|
|
1260 }
|
|
1261
|
|
1262 static void
|
|
1263 default_toolbar_size_changed_in_frame (Lisp_Object specifier, struct frame *f,
|
|
1264 Lisp_Object oldval)
|
|
1265 {
|
|
1266 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position);
|
|
1267
|
|
1268 Fset_specifier_dirty_flag (Vtoolbar_size[pos]);
|
|
1269
|
|
1270 /* Let redisplay know that something has possibly changed. */
|
|
1271 MARK_TOOLBAR_CHANGED;
|
|
1272 }
|
|
1273
|
|
1274 static void
|
|
1275 default_toolbar_visible_p_changed_in_frame (Lisp_Object specifier,
|
|
1276 struct frame *f,
|
|
1277 Lisp_Object oldval)
|
|
1278 {
|
|
1279 enum toolbar_pos pos = decode_toolbar_position (Vdefault_toolbar_position);
|
|
1280
|
|
1281 Fset_specifier_dirty_flag (Vtoolbar_visible_p[pos]);
|
|
1282
|
|
1283 /* Let redisplay know that something has possibly changed. */
|
|
1284 MARK_TOOLBAR_CHANGED;
|
|
1285 }
|
|
1286
|
|
1287
|
|
1288 static void
|
|
1289 toolbar_buttons_captioned_p_changed (Lisp_Object specifier, struct window *w,
|
|
1290 Lisp_Object oldval)
|
|
1291 {
|
|
1292 /* This could be smarter but I doubt that it would make any
|
|
1293 noticable difference given the infrequency with which this is
|
|
1294 probably going to be called. */
|
|
1295 MARK_TOOLBAR_CHANGED;
|
|
1296 }
|
|
1297
|
|
1298
|
|
1299 void
|
|
1300 syms_of_toolbar (void)
|
|
1301 {
|
|
1302 defsymbol (&Qtoolbar_buttonp, "toolbar-button-p");
|
|
1303 defsymbol (&Q2D, "2D");
|
|
1304 defsymbol (&Q3D, "3D");
|
|
1305 defsymbol (&Q2d, "2d");
|
|
1306 defsymbol (&Q3d, "3d");
|
|
1307 defsymbol (&Q_size, ":size"); Fset (Q_size, Q_size);
|
|
1308
|
|
1309 defsymbol (&Qinit_toolbar_from_resources, "init-toolbar-from-resources");
|
20
|
1310 DEFSUBR (Ftoolbar_button_p);
|
|
1311 DEFSUBR (Ftoolbar_button_callback);
|
|
1312 DEFSUBR (Ftoolbar_button_help_string);
|
|
1313 DEFSUBR (Ftoolbar_button_enabled_p);
|
|
1314 DEFSUBR (Fset_toolbar_button_down_flag);
|
|
1315 DEFSUBR (Fcheck_toolbar_button_syntax);
|
|
1316 DEFSUBR (Fset_default_toolbar_position);
|
|
1317 DEFSUBR (Fdefault_toolbar_position);
|
|
1318 DEFSUBR (Ftoolbar_specifier_p);
|
0
|
1319 }
|
|
1320
|
|
1321 void
|
|
1322 vars_of_toolbar (void)
|
|
1323 {
|
|
1324 staticpro (&Vdefault_toolbar_position);
|
|
1325 Vdefault_toolbar_position = Qtop;
|
|
1326
|
|
1327 #ifdef HAVE_WINDOW_SYSTEM
|
|
1328 Fprovide (Qtoolbar);
|
|
1329 #endif
|
|
1330 }
|
|
1331
|
|
1332 void
|
|
1333 specifier_type_create_toolbar (void)
|
|
1334 {
|
|
1335 INITIALIZE_SPECIFIER_TYPE (toolbar, "toolbar", "toolbar-specifier-p");
|
|
1336
|
|
1337 SPECIFIER_HAS_METHOD (toolbar, validate);
|
|
1338 SPECIFIER_HAS_METHOD (toolbar, after_change);
|
|
1339 }
|
|
1340
|
|
1341 void
|
|
1342 specifier_vars_of_toolbar (void)
|
|
1343 {
|
|
1344 Lisp_Object elt;
|
173
|
1345
|
0
|
1346 DEFVAR_SPECIFIER ("default-toolbar", &Vdefault_toolbar /*
|
|
1347 Specifier for a fallback toolbar.
|
|
1348 Use `set-specifier' to change this.
|
|
1349
|
|
1350 The position of this toolbar is specified in the function
|
|
1351 `default-toolbar-position'. If the corresponding position-specific
|
|
1352 toolbar (e.g. `top-toolbar' if `default-toolbar-position' is 'top)
|
|
1353 does not specify a toolbar in a particular domain (usually a window),
|
|
1354 then the value of `default-toolbar' in that domain, if any, will be
|
|
1355 used instead.
|
|
1356
|
|
1357 Note that the toolbar at any particular position will not be
|
|
1358 displayed unless its visibility flag is true and its thickness
|
|
1359 \(width or height, depending on orientation) is non-zero. The
|
|
1360 visibility is controlled by the specifiers `top-toolbar-visible-p',
|
|
1361 `bottom-toolbar-visible-p', `left-toolbar-visible-p', and
|
|
1362 `right-toolbar-visible-p', and the thickness is controlled by the
|
|
1363 specifiers `top-toolbar-height', `bottom-toolbar-height',
|
|
1364 `left-toolbar-width', and `right-toolbar-width'.
|
|
1365
|
|
1366 Note that one of the four visibility specifiers inherits from
|
|
1367 `default-toolbar-visibility' and one of the four thickness
|
|
1368 specifiers inherits from either `default-toolbar-width' or
|
|
1369 `default-toolbar-height' (depending on orientation), just
|
|
1370 like for the toolbar description specifiers (e.g. `top-toolbar')
|
|
1371 mentioned above.
|
|
1372
|
|
1373 Therefore, if you are setting `default-toolbar', you should control
|
|
1374 the visibility and thickness using `default-toolbar-visible-p',
|
|
1375 `default-toolbar-width', and `default-toolbar-height', rather than
|
|
1376 using position-specific specifiers. That way, you will get sane
|
|
1377 behavior if the user changes the default toolbar position.
|
|
1378
|
|
1379 The format of the instantiator for a toolbar is a list of
|
|
1380 toolbar-button-descriptors. Each toolbar-button-descriptor
|
|
1381 is a vector in one of the following formats:
|
|
1382
|
|
1383 [GLYPH-LIST FUNCTION ENABLED-P HELP] or
|
|
1384 [:style 2D-OR-3D] or
|
|
1385 [:style 2D-OR-3D :size WIDTH-OR-HEIGHT] or
|
|
1386 [:size WIDTH-OR-HEIGHT :style 2D-OR-3D]
|
|
1387
|
|
1388 Optionally, one of the toolbar-button-descriptors may be nil
|
|
1389 instead of a vector; this signifies the division between
|
|
1390 the toolbar buttons that are to be displayed flush-left,
|
|
1391 and the buttons to be displayed flush-right.
|
|
1392
|
|
1393 The first vector format above specifies a normal toolbar button;
|
|
1394 the others specify blank areas in the toolbar.
|
|
1395
|
|
1396 For the first vector format:
|
|
1397
|
|
1398 -- GLYPH-LIST should be a list of one to six glyphs (as created by
|
|
1399 `make-glyph') or a symbol whose value is such a list. The first
|
|
1400 glyph, which must be provided, is the glyph used to display the
|
185
|
1401 toolbar button when it is in the "up" (not pressed) state. The
|
0
|
1402 optional second glyph is for displaying the button when it is in
|
185
|
1403 the "down" (pressed) state. The optional third glyph is for when
|
0
|
1404 the button is disabled. The optional fourth, fifth and sixth glyphs
|
|
1405 are used to specify captioned versions for the up, down and disabled
|
|
1406 states respectively. The function `toolbar-make-button-list' is
|
|
1407 useful in creating these glyph lists. The specifier variable
|
|
1408 `toolbar-buttons-captioned-p' controls which glyphs are actually used.
|
|
1409
|
|
1410 -- Even if you do not provide separate down-state and disabled-state
|
|
1411 glyphs, the user will still get visual feedback to indicate which
|
|
1412 state the button is in. Buttons in the up-state are displayed
|
|
1413 with a shadowed border that gives a raised appearance to the
|
|
1414 button. Buttons in the down-state are displayed with shadows that
|
|
1415 give a recessed appearance. Buttons in the disabled state are
|
|
1416 displayed with no shadows, giving a 2-d effect.
|
|
1417
|
|
1418 -- If some of the toolbar glyphs are not provided, they inherit as follows:
|
|
1419
|
|
1420 UP: up
|
|
1421 DOWN: down -> up
|
|
1422 DISABLED: disabled -> up
|
|
1423 CAP-UP: cap-up -> up
|
|
1424 CAP-DOWN: cap-down -> cap-up -> down -> up
|
|
1425 CAP-DISABLED: cap-disabled -> cap-up -> disabled -> up
|
|
1426
|
|
1427 -- The second element FUNCTION is a function to be called when the
|
|
1428 toolbar button is activated (i.e. when the mouse is released over
|
|
1429 the toolbar button, if the press occurred in the toolbar). It
|
|
1430 can be any form accepted by `call-interactively', since this is
|
|
1431 how it is invoked.
|
|
1432
|
|
1433 -- The third element ENABLED-P specifies whether the toolbar button
|
|
1434 is enabled (disabled buttons do nothing when they are activated,
|
|
1435 and are displayed differently; see above). It should be either
|
|
1436 a boolean or a form that evaluates to a boolean.
|
|
1437
|
|
1438 -- The fourth element HELP, if non-nil, should be a string. This
|
|
1439 string is displayed in the echo area when the mouse passes over
|
|
1440 the toolbar button.
|
|
1441
|
|
1442 For the other vector formats (specifying blank areas of the toolbar):
|
|
1443
|
|
1444 -- 2D-OR-3D should be one of the symbols '2d or '3d, indicating
|
|
1445 whether the area is displayed with shadows (giving it a raised,
|
|
1446 3-d appearance) or without shadows (giving it a flat appearance).
|
|
1447
|
|
1448 -- WIDTH-OR-HEIGHT specifies the length, in pixels, of the blank
|
|
1449 area. If omitted, it defaults to a device-specific value
|
|
1450 (8 pixels for X devices).
|
|
1451 */ );
|
|
1452
|
|
1453 Vdefault_toolbar = Fmake_specifier (Qtoolbar);
|
|
1454 /* #### It would be even nicer if the specifier caching
|
|
1455 automatically knew about specifier fallbacks, so we didn't
|
|
1456 have to do it ourselves. */
|
|
1457 set_specifier_caching (Vdefault_toolbar,
|
|
1458 slot_offset (struct window,
|
|
1459 default_toolbar),
|
|
1460 default_toolbar_specs_changed,
|
|
1461 0, 0);
|
|
1462
|
|
1463 DEFVAR_SPECIFIER ("top-toolbar",
|
|
1464 &Vtoolbar[TOP_TOOLBAR] /*
|
|
1465 Specifier for the toolbar at the top of the frame.
|
|
1466 Use `set-specifier' to change this.
|
|
1467 See `default-toolbar' for a description of a valid toolbar instantiator.
|
|
1468 */ );
|
|
1469 Vtoolbar[TOP_TOOLBAR] = Fmake_specifier (Qtoolbar);
|
|
1470 set_specifier_caching (Vtoolbar[TOP_TOOLBAR],
|
|
1471 slot_offset (struct window,
|
|
1472 toolbar[TOP_TOOLBAR]),
|
|
1473 toolbar_specs_changed,
|
|
1474 0, 0);
|
|
1475
|
|
1476 DEFVAR_SPECIFIER ("bottom-toolbar",
|
|
1477 &Vtoolbar[BOTTOM_TOOLBAR] /*
|
|
1478 Specifier for the toolbar at the bottom of the frame.
|
|
1479 Use `set-specifier' to change this.
|
|
1480 See `default-toolbar' for a description of a valid toolbar instantiator.
|
|
1481
|
|
1482 Note that, unless the `default-toolbar-position' is `bottom', by
|
|
1483 default the height of the bottom toolbar (controlled by
|
|
1484 `bottom-toolbar-height') is 0; thus, a bottom toolbar will not be
|
|
1485 displayed even if you provide a value for `bottom-toolbar'.
|
|
1486 */ );
|
|
1487 Vtoolbar[BOTTOM_TOOLBAR] = Fmake_specifier (Qtoolbar);
|
|
1488 set_specifier_caching (Vtoolbar[BOTTOM_TOOLBAR],
|
|
1489 slot_offset (struct window,
|
|
1490 toolbar[BOTTOM_TOOLBAR]),
|
|
1491 toolbar_specs_changed,
|
|
1492 0, 0);
|
|
1493
|
|
1494 DEFVAR_SPECIFIER ("left-toolbar",
|
|
1495 &Vtoolbar[LEFT_TOOLBAR] /*
|
|
1496 Specifier for the toolbar at the left edge of the frame.
|
|
1497 Use `set-specifier' to change this.
|
|
1498 See `default-toolbar' for a description of a valid toolbar instantiator.
|
|
1499
|
|
1500 Note that, unless the `default-toolbar-position' is `left', by
|
|
1501 default the height of the left toolbar (controlled by
|
|
1502 `left-toolbar-width') is 0; thus, a left toolbar will not be
|
|
1503 displayed even if you provide a value for `left-toolbar'.
|
|
1504 */ );
|
|
1505 Vtoolbar[LEFT_TOOLBAR] = Fmake_specifier (Qtoolbar);
|
|
1506 set_specifier_caching (Vtoolbar[LEFT_TOOLBAR],
|
|
1507 slot_offset (struct window,
|
|
1508 toolbar[LEFT_TOOLBAR]),
|
|
1509 toolbar_specs_changed,
|
|
1510 0, 0);
|
|
1511
|
|
1512 DEFVAR_SPECIFIER ("right-toolbar",
|
|
1513 &Vtoolbar[RIGHT_TOOLBAR] /*
|
|
1514 Specifier for the toolbar at the right edge of the frame.
|
|
1515 Use `set-specifier' to change this.
|
|
1516 See `default-toolbar' for a description of a valid toolbar instantiator.
|
|
1517
|
|
1518 Note that, unless the `default-toolbar-position' is `right', by
|
|
1519 default the height of the right toolbar (controlled by
|
|
1520 `right-toolbar-width') is 0; thus, a right toolbar will not be
|
|
1521 displayed even if you provide a value for `right-toolbar'.
|
|
1522 */ );
|
|
1523 Vtoolbar[RIGHT_TOOLBAR] = Fmake_specifier (Qtoolbar);
|
|
1524 set_specifier_caching (Vtoolbar[RIGHT_TOOLBAR],
|
|
1525 slot_offset (struct window,
|
|
1526 toolbar[RIGHT_TOOLBAR]),
|
|
1527 toolbar_specs_changed,
|
|
1528 0, 0);
|
|
1529
|
|
1530 /* initially, top inherits from default; this can be
|
|
1531 changed with `set-default-toolbar-position'. */
|
|
1532 elt = list1 (Fcons (Qnil, Qnil));
|
|
1533 set_specifier_fallback (Vdefault_toolbar, elt);
|
|
1534 set_specifier_fallback (Vtoolbar[TOP_TOOLBAR], Vdefault_toolbar);
|
|
1535 set_specifier_fallback (Vtoolbar[BOTTOM_TOOLBAR], elt);
|
|
1536 set_specifier_fallback (Vtoolbar[LEFT_TOOLBAR], elt);
|
|
1537 set_specifier_fallback (Vtoolbar[RIGHT_TOOLBAR], elt);
|
|
1538
|
|
1539 DEFVAR_SPECIFIER ("default-toolbar-height", &Vdefault_toolbar_height /*
|
|
1540 *Height of the default toolbar, if it's oriented horizontally.
|
|
1541 This is a specifier; use `set-specifier' to change it.
|
|
1542
|
|
1543 The position of the default toolbar is specified by the function
|
|
1544 `set-default-toolbar-position'. If the corresponding position-specific
|
|
1545 toolbar thickness specifier (e.g. `top-toolbar-height' if
|
|
1546 `default-toolbar-position' is 'top) does not specify a thickness in a
|
|
1547 particular domain (a window or a frame), then the value of
|
|
1548 `default-toolbar-height' or `default-toolbar-width' (depending on the
|
|
1549 toolbar orientation) in that domain, if any, will be used instead.
|
|
1550
|
|
1551 Note that `default-toolbar-height' is only used when
|
|
1552 `default-toolbar-position' is 'top or 'bottom, and `default-toolbar-width'
|
|
1553 is only used when `default-toolbar-position' is 'left or 'right.
|
|
1554
|
|
1555 Note that all of the position-specific toolbar thickness specifiers
|
|
1556 have a fallback value of zero when they do not correspond to the
|
|
1557 default toolbar. Therefore, you will have to set a non-zero thickness
|
|
1558 value if you want a position-specific toolbar to be displayed.
|
|
1559
|
|
1560 Internally, toolbar thickness specifiers are instantiated in both
|
|
1561 window and frame domains, for different purposes. The value in the
|
|
1562 domain of a frame's selected window specifies the actual toolbar
|
|
1563 thickness that you will see in that frame. The value in the domain of
|
|
1564 a frame itself specifies the toolbar thickness that is used in frame
|
|
1565 geometry calculations.
|
|
1566
|
|
1567 Thus, for example, if you set the frame width to 80 characters and the
|
|
1568 left toolbar width for that frame to 68 pixels, then the frame will
|
|
1569 be sized to fit 80 characters plus a 68-pixel left toolbar. If you
|
|
1570 then set the left toolbar width to 0 for a particular buffer (or if
|
|
1571 that buffer does not specify a left toolbar or has a nil value
|
|
1572 specified for `left-toolbar-visible-p'), you will find that, when
|
|
1573 that buffer is displayed in the selected window, the window will have
|
|
1574 a width of 86 or 87 characters -- the frame is sized for a 68-pixel
|
|
1575 left toolbar but the selected window specifies that the left toolbar
|
|
1576 is not visible, so it is expanded to take up the slack.
|
|
1577 */ );
|
|
1578 Vdefault_toolbar_height = Fmake_specifier (Qnatnum);
|
|
1579 set_specifier_caching (Vdefault_toolbar_height,
|
|
1580 slot_offset (struct window,
|
|
1581 default_toolbar_height),
|
|
1582 some_window_value_changed,
|
|
1583 slot_offset (struct frame,
|
|
1584 default_toolbar_height),
|
|
1585 default_toolbar_size_changed_in_frame);
|
|
1586
|
|
1587 DEFVAR_SPECIFIER ("default-toolbar-width", &Vdefault_toolbar_width /*
|
|
1588 *Width of the default toolbar, if it's oriented vertically.
|
|
1589 This is a specifier; use `set-specifier' to change it.
|
|
1590
|
|
1591 See `default-toolbar-height' for more information.
|
|
1592 */ );
|
|
1593 Vdefault_toolbar_width = Fmake_specifier (Qnatnum);
|
|
1594 set_specifier_caching (Vdefault_toolbar_width,
|
|
1595 slot_offset (struct window,
|
|
1596 default_toolbar_width),
|
|
1597 some_window_value_changed,
|
|
1598 slot_offset (struct frame,
|
|
1599 default_toolbar_width),
|
|
1600 default_toolbar_size_changed_in_frame);
|
|
1601
|
|
1602 DEFVAR_SPECIFIER ("top-toolbar-height",
|
|
1603 &Vtoolbar_size[TOP_TOOLBAR] /*
|
|
1604 *Height of the top toolbar.
|
|
1605 This is a specifier; use `set-specifier' to change it.
|
|
1606
|
|
1607 See `default-toolbar-height' for more information.
|
|
1608 */ );
|
|
1609 Vtoolbar_size[TOP_TOOLBAR] = Fmake_specifier (Qnatnum);
|
|
1610 set_specifier_caching (Vtoolbar_size[TOP_TOOLBAR],
|
|
1611 slot_offset (struct window,
|
|
1612 toolbar_size[TOP_TOOLBAR]),
|
|
1613 some_window_value_changed,
|
|
1614 slot_offset (struct frame,
|
|
1615 toolbar_size[TOP_TOOLBAR]),
|
|
1616 toolbar_size_changed_in_frame);
|
|
1617
|
|
1618 DEFVAR_SPECIFIER ("bottom-toolbar-height",
|
|
1619 &Vtoolbar_size[BOTTOM_TOOLBAR] /*
|
|
1620 *Height of the bottom toolbar.
|
|
1621 This is a specifier; use `set-specifier' to change it.
|
|
1622
|
|
1623 See `default-toolbar-height' for more information.
|
|
1624 */ );
|
|
1625 Vtoolbar_size[BOTTOM_TOOLBAR] = Fmake_specifier (Qnatnum);
|
|
1626 set_specifier_caching (Vtoolbar_size[BOTTOM_TOOLBAR],
|
|
1627 slot_offset (struct window,
|
|
1628 toolbar_size[BOTTOM_TOOLBAR]),
|
|
1629 some_window_value_changed,
|
|
1630 slot_offset (struct frame,
|
|
1631 toolbar_size[BOTTOM_TOOLBAR]),
|
|
1632 toolbar_size_changed_in_frame);
|
|
1633
|
|
1634 DEFVAR_SPECIFIER ("left-toolbar-width",
|
|
1635 &Vtoolbar_size[LEFT_TOOLBAR] /*
|
|
1636 *Width of left toolbar.
|
|
1637 This is a specifier; use `set-specifier' to change it.
|
|
1638
|
|
1639 See `default-toolbar-height' for more information.
|
|
1640 */ );
|
|
1641 Vtoolbar_size[LEFT_TOOLBAR] = Fmake_specifier (Qnatnum);
|
|
1642 set_specifier_caching (Vtoolbar_size[LEFT_TOOLBAR],
|
|
1643 slot_offset (struct window,
|
|
1644 toolbar_size[LEFT_TOOLBAR]),
|
|
1645 some_window_value_changed,
|
|
1646 slot_offset (struct frame,
|
|
1647 toolbar_size[LEFT_TOOLBAR]),
|
|
1648 toolbar_size_changed_in_frame);
|
|
1649
|
|
1650 DEFVAR_SPECIFIER ("right-toolbar-width",
|
|
1651 &Vtoolbar_size[RIGHT_TOOLBAR] /*
|
|
1652 *Width of right toolbar.
|
|
1653 This is a specifier; use `set-specifier' to change it.
|
|
1654
|
|
1655 See `default-toolbar-height' for more information.
|
|
1656 */ );
|
|
1657 Vtoolbar_size[RIGHT_TOOLBAR] = Fmake_specifier (Qnatnum);
|
|
1658 set_specifier_caching (Vtoolbar_size[RIGHT_TOOLBAR],
|
|
1659 slot_offset (struct window,
|
|
1660 toolbar_size[RIGHT_TOOLBAR]),
|
|
1661 some_window_value_changed,
|
|
1662 slot_offset (struct frame,
|
|
1663 toolbar_size[RIGHT_TOOLBAR]),
|
|
1664 toolbar_size_changed_in_frame);
|
|
1665
|
|
1666 /* #### this is ugly. */
|
78
|
1667 /* sb - even uglier to make this work without console tty support, ugh. */
|
|
1668 elt = Qnil;
|
|
1669 #ifdef HAVE_TTY
|
0
|
1670 elt = list1 (Fcons (list1 (Qtty), Qzero));
|
78
|
1671 #endif
|
0
|
1672 #ifdef HAVE_X_WINDOWS
|
80
|
1673 if (!EQ(elt, Qnil))
|
78
|
1674 elt = Fcons (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_HEIGHT)), elt);
|
|
1675 else
|
|
1676 elt = list1 (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_HEIGHT)));
|
0
|
1677 #endif
|
80
|
1678 if (!EQ(elt, Qnil))
|
78
|
1679 set_specifier_fallback (Vdefault_toolbar_height, elt);
|
|
1680
|
|
1681 elt = Qnil;
|
|
1682 #ifdef HAVE_TTY
|
0
|
1683 elt = list1 (Fcons (list1 (Qtty), Qzero));
|
78
|
1684 #endif
|
0
|
1685 #ifdef HAVE_X_WINDOWS
|
80
|
1686 if (!EQ(elt, Qnil))
|
78
|
1687 elt = Fcons (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_WIDTH)), elt);
|
|
1688 else
|
|
1689 elt = list1 (Fcons (list1 (Qx), make_int (DEFAULT_TOOLBAR_WIDTH)));
|
0
|
1690 #endif
|
80
|
1691 if (!EQ(elt, Qnil))
|
78
|
1692 set_specifier_fallback (Vdefault_toolbar_width, elt);
|
0
|
1693
|
|
1694 set_specifier_fallback (Vtoolbar_size[TOP_TOOLBAR], Vdefault_toolbar_height);
|
|
1695 elt = list1 (Fcons (Qnil, Qzero));
|
|
1696 set_specifier_fallback (Vtoolbar_size[BOTTOM_TOOLBAR], elt);
|
|
1697 set_specifier_fallback (Vtoolbar_size[LEFT_TOOLBAR], elt);
|
|
1698 set_specifier_fallback (Vtoolbar_size[RIGHT_TOOLBAR], elt);
|
|
1699
|
|
1700 DEFVAR_SPECIFIER ("default-toolbar-visible-p", &Vdefault_toolbar_visible_p /*
|
|
1701 *Whether the default toolbar is visible.
|
|
1702 This is a specifier; use `set-specifier' to change it.
|
|
1703
|
|
1704 The position of the default toolbar is specified by the function
|
|
1705 `set-default-toolbar-position'. If the corresponding position-specific
|
|
1706 toolbar visibility specifier (e.g. `top-toolbar-visible-p' if
|
|
1707 `default-toolbar-position' is 'top) does not specify a visible-p value
|
|
1708 in a particular domain (a window or a frame), then the value of
|
|
1709 `default-toolbar-visible-p' in that domain, if any, will be used
|
|
1710 instead.
|
|
1711
|
|
1712 Both window domains and frame domains are used internally, for
|
|
1713 different purposes. The distinction here is exactly the same as
|
|
1714 for thickness specifiers; see `default-toolbar-height' for more
|
|
1715 information.
|
|
1716
|
|
1717 `default-toolbar-visible-p' and all of the position-specific toolbar
|
|
1718 visibility specifiers have a fallback value of true.
|
|
1719 */ );
|
|
1720 Vdefault_toolbar_visible_p = Fmake_specifier (Qboolean);
|
|
1721 set_specifier_caching (Vdefault_toolbar_visible_p,
|
|
1722 slot_offset (struct window,
|
|
1723 default_toolbar_visible_p),
|
|
1724 some_window_value_changed,
|
|
1725 slot_offset (struct frame,
|
|
1726 default_toolbar_visible_p),
|
|
1727 default_toolbar_visible_p_changed_in_frame);
|
|
1728
|
|
1729 DEFVAR_SPECIFIER ("top-toolbar-visible-p",
|
|
1730 &Vtoolbar_visible_p[TOP_TOOLBAR] /*
|
|
1731 *Whether the top toolbar is visible.
|
|
1732 This is a specifier; use `set-specifier' to change it.
|
|
1733
|
|
1734 See `default-toolbar-visible-p' for more information.
|
|
1735 */ );
|
|
1736 Vtoolbar_visible_p[TOP_TOOLBAR] = Fmake_specifier (Qboolean);
|
|
1737 set_specifier_caching (Vtoolbar_visible_p[TOP_TOOLBAR],
|
|
1738 slot_offset (struct window,
|
|
1739 toolbar_visible_p[TOP_TOOLBAR]),
|
|
1740 some_window_value_changed,
|
|
1741 slot_offset (struct frame,
|
|
1742 toolbar_visible_p[TOP_TOOLBAR]),
|
|
1743 toolbar_visible_p_changed_in_frame);
|
|
1744
|
|
1745 DEFVAR_SPECIFIER ("bottom-toolbar-visible-p",
|
|
1746 &Vtoolbar_visible_p[BOTTOM_TOOLBAR] /*
|
|
1747 *Whether the bottom toolbar is visible.
|
|
1748 This is a specifier; use `set-specifier' to change it.
|
|
1749
|
|
1750 See `default-toolbar-visible-p' for more information.
|
|
1751 */ );
|
|
1752 Vtoolbar_visible_p[BOTTOM_TOOLBAR] = Fmake_specifier (Qboolean);
|
|
1753 set_specifier_caching (Vtoolbar_visible_p[BOTTOM_TOOLBAR],
|
|
1754 slot_offset (struct window,
|
|
1755 toolbar_visible_p[BOTTOM_TOOLBAR]),
|
|
1756 some_window_value_changed,
|
|
1757 slot_offset (struct frame,
|
|
1758 toolbar_visible_p[BOTTOM_TOOLBAR]),
|
|
1759 toolbar_visible_p_changed_in_frame);
|
|
1760
|
|
1761 DEFVAR_SPECIFIER ("left-toolbar-visible-p",
|
|
1762 &Vtoolbar_visible_p[LEFT_TOOLBAR] /*
|
|
1763 *Whether the left toolbar is visible.
|
|
1764 This is a specifier; use `set-specifier' to change it.
|
|
1765
|
|
1766 See `default-toolbar-visible-p' for more information.
|
|
1767 */ );
|
|
1768 Vtoolbar_visible_p[LEFT_TOOLBAR] = Fmake_specifier (Qboolean);
|
|
1769 set_specifier_caching (Vtoolbar_visible_p[LEFT_TOOLBAR],
|
|
1770 slot_offset (struct window,
|
|
1771 toolbar_visible_p[LEFT_TOOLBAR]),
|
|
1772 some_window_value_changed,
|
|
1773 slot_offset (struct frame,
|
|
1774 toolbar_visible_p[LEFT_TOOLBAR]),
|
|
1775 toolbar_visible_p_changed_in_frame);
|
|
1776
|
|
1777 DEFVAR_SPECIFIER ("right-toolbar-visible-p",
|
|
1778 &Vtoolbar_visible_p[RIGHT_TOOLBAR] /*
|
|
1779 *Whether the right toolbar is visible.
|
|
1780 This is a specifier; use `set-specifier' to change it.
|
|
1781
|
|
1782 See `default-toolbar-visible-p' for more information.
|
|
1783 */ );
|
|
1784 Vtoolbar_visible_p[RIGHT_TOOLBAR] = Fmake_specifier (Qboolean);
|
|
1785 set_specifier_caching (Vtoolbar_visible_p[RIGHT_TOOLBAR],
|
|
1786 slot_offset (struct window,
|
|
1787 toolbar_visible_p[RIGHT_TOOLBAR]),
|
|
1788 some_window_value_changed,
|
|
1789 slot_offset (struct frame,
|
|
1790 toolbar_visible_p[RIGHT_TOOLBAR]),
|
|
1791 toolbar_visible_p_changed_in_frame);
|
|
1792
|
|
1793 /* initially, top inherits from default; this can be
|
|
1794 changed with `set-default-toolbar-position'. */
|
|
1795 elt = list1 (Fcons (Qnil, Qt));
|
|
1796 set_specifier_fallback (Vdefault_toolbar_visible_p, elt);
|
|
1797 set_specifier_fallback (Vtoolbar_visible_p[TOP_TOOLBAR],
|
|
1798 Vdefault_toolbar_visible_p);
|
|
1799 set_specifier_fallback (Vtoolbar_visible_p[BOTTOM_TOOLBAR], elt);
|
|
1800 set_specifier_fallback (Vtoolbar_visible_p[LEFT_TOOLBAR], elt);
|
|
1801 set_specifier_fallback (Vtoolbar_visible_p[RIGHT_TOOLBAR], elt);
|
|
1802
|
|
1803 DEFVAR_SPECIFIER ("toolbar-buttons-captioned-p",
|
|
1804 &Vtoolbar_buttons_captioned_p /*
|
|
1805 *Whether the toolbar buttons are captioned.
|
|
1806 This will only have a visible effect for those toolbar buttons which had
|
|
1807 captioned versions specified.
|
|
1808 This is a specifier; use `set-specifier' to change it.
|
|
1809 */ );
|
|
1810 Vtoolbar_buttons_captioned_p = Fmake_specifier (Qboolean);
|
|
1811 set_specifier_caching (Vtoolbar_buttons_captioned_p,
|
|
1812 slot_offset (struct window,
|
|
1813 toolbar_buttons_captioned_p),
|
|
1814 toolbar_buttons_captioned_p_changed,
|
|
1815 0, 0);
|
|
1816 set_specifier_fallback (Vtoolbar_buttons_captioned_p,
|
|
1817 list1 (Fcons (Qnil, Qt)));
|
|
1818 }
|