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