annotate lisp/toolbar.el @ 5313:5ed261fd2bd9

Unrool a load-time loop at macro expansion time, cl-macs.el 2010-12-29 Aidan Kehoe <kehoea@parhasard.net> * cl-macs.el (inline-side-effect-free-compiler-macros): Unroll a loop here at macro-expansion time, so these compiler macros are compiled. Use #'eql instead of #'eq in a couple of places for better style.
author Aidan Kehoe <kehoea@parhasard.net>
date Wed, 29 Dec 2010 23:43:10 +0000
parents 5efbd1253905
children 308d34e9f07d
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
1 ;;; toolbar.el --- Toolbar support for XEmacs
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
2
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
3 ;; Copyright (C) 1995, 1997 Free Software Foundation, Inc.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 767
diff changeset
4 ;; Copyright (C) 2002 Ben Wing.
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
5
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
6 ;; Maintainer: XEmacs Development Team
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
7 ;; Keywords: extensions, internal, dumped
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
8
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
9 ;; This file is part of XEmacs.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
10
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
11 ;; XEmacs is free software; you can redistribute it and/or modify it
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
12 ;; under the terms of the GNU General Public License as published by
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
13 ;; the Free Software Foundation; either version 2, or (at your option)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
14 ;; any later version.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
15
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
16 ;; XEmacs is distributed in the hope that it will be useful, but
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
17 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
18 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
19 ;; General Public License for more details.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
20
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
21 ;; You should have received a copy of the GNU General Public License
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
22 ;; along with XEmacs; see the file COPYING. If not, write to the
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
23 ;; Free Software Foundation, 59 Temple Place - Suite 330,
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
24 ;; Boston, MA 02111-1307, USA.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
25
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
26 ;;; Synched up with: Not in FSF.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
27
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
28 ;;; Commentary:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
29
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
30 ;; This file is dumped with XEmacs (when toolbar support is compiled in).
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
31
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
32 ;;; Code:
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
33
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
34 (defcustom toolbar-visible-p ;; added for the options menu - dverna apr. 98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
35 (specifier-instance default-toolbar-visible-p)
763
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
36 "*Whether the default toolbar is globally visible.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 767
diff changeset
37 This option only has an effect when set using `customize-set-variable',
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 767
diff changeset
38 or through the Options menu."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
39 :group 'display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
40 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
41 :set #'(lambda (var val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
42 (set-specifier default-toolbar-visible-p val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
43 (setq toolbar-visible-p val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
44 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
45
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
46 (defcustom toolbar-captioned-p ;; added for the options menu - dverna apr. 98
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
47 (specifier-instance toolbar-buttons-captioned-p)
763
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
48 "*Whether the toolbars buttons are globally captioned.
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 767
diff changeset
49 This option only has an effect when set using `customize-set-variable',
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 767
diff changeset
50 or through the Options menu."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
51 :group 'display
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
52 :type 'boolean
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
53 :set #'(lambda (var val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
54 (set-specifier toolbar-buttons-captioned-p val)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
55 (setq toolbar-captioned-p val))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
56 )
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
57
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
58 (defcustom default-toolbar-position ;; added for the options menu - dverna
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
59 (default-toolbar-position)
771
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 767
diff changeset
60 "*The location of the default toolbar: 'top, 'bottom, 'left or 'right.
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 767
diff changeset
61 This option only has an effect when set using `customize-set-variable',
943eaba38521 [xemacs-hg @ 2002-03-13 08:51:24 by ben]
ben
parents: 767
diff changeset
62 or through the Options menu."
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
63 :group 'display
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
64 :type '(choice (const :tag "top" top)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
65 (const :tag "bottom" bottom)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
66 (const :tag "left" left)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
67 (const :tag "right" right))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
68 :set #'(lambda (var val)
763
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
69 (let* ((height (window-height))
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
70 (hdiff (- (frame-height) height))
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
71 (width (window-width)))
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
72 (set-default-toolbar-position val)
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
73 (setq default-toolbar-position val)
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
74 ;; needed or dimensions don't update?
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
75 (redisplay-frame)
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
76 ;; This probably only works correctly if there is only one
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
77 ;; Emacs window. If windows are split, it probably results in
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
78 ;; small adjustments in their sizes.
47ae55dda777 [xemacs-hg @ 2002-03-05 12:53:10 by stephent]
stephent
parents: 502
diff changeset
79 (set-frame-size (selected-frame) width (+ height hdiff))
767
af0baad5ba14 [xemacs-hg @ 2002-03-05 14:15:05 by stephent]
stephent
parents: 763
diff changeset
80 )))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
81
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
82 (defvar toolbar-help-enabled t
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
83 "If non-nil help is echoed for toolbar buttons.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
84
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
85 (defvar toolbar-icon-directory nil
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
86 "Location of standard toolbar icon bitmaps.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
87
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
88 (defun toolbar-make-button-list (up &optional down disabled cap-up cap-down cap-disabled)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
89 "Call make-glyph on each arg and return a list of the results."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
90 (let ((up-glyph (make-glyph up))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
91 (down-glyph (and down (make-glyph down)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
92 (disabled-glyph (and disabled (make-glyph disabled)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
93 (cap-up-glyph (and cap-up (make-glyph cap-up)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
94 (cap-down-glyph (and cap-down (make-glyph cap-down)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
95 (cap-disabled-glyph (and cap-disabled (make-glyph cap-disabled))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
96 (if cap-disabled
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
97 (list up-glyph down-glyph disabled-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
98 cap-up-glyph cap-down-glyph cap-disabled-glyph)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
99 (if cap-down
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
100 (list up-glyph down-glyph disabled-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
101 cap-up-glyph cap-down-glyph)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
102 (if cap-up
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
103 (list up-glyph down-glyph disabled-glyph cap-up-glyph)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
104 (if disabled-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
105 (list up-glyph down-glyph disabled-glyph)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
106 (if down-glyph
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
107 (list up-glyph down-glyph)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
108 (list up-glyph))))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
109
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
110 (defun init-toolbar-location ()
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
111 (if (not toolbar-icon-directory)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
112 (let ((name (locate-data-directory "toolbar")))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
113 (if name
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
114 (setq toolbar-icon-directory
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
115 (file-name-as-directory name))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
116
487
54fa1a5c2d12 [xemacs-hg @ 2001-04-28 07:48:36 by ben]
ben
parents: 442
diff changeset
117 ;; called from toolbar.c during device and frame initialization
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
118 (defun init-toolbar-from-resources (locale)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
119 (if (and (featurep 'x)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
120 (or (eq locale 'global)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
121 (eq 'x (device-or-frame-type locale))))
502
7039e6323819 [xemacs-hg @ 2001-05-04 22:41:46 by ben]
ben
parents: 487
diff changeset
122 (declare-fboundp (x-init-toolbar-from-resources locale))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
123
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
124
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
125 ;; #### Is this actually needed or will the code in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
126 ;; default-mouse-motion-handler suffice?
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
127 (define-key global-map 'button1up 'release-toolbar-button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
128
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
129 (defvar toolbar-map (let ((m (make-sparse-keymap)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
130 (set-keymap-name m 'toolbar-map)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
131 m)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
132 "Keymap consulted for mouse-clicks over a toolbar.")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
133
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
134 (define-key toolbar-map 'button1 'press-toolbar-button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
135 (define-key toolbar-map 'button1up 'release-and-activate-toolbar-button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
136 (defvar last-pressed-toolbar-button nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
137 (defvar toolbar-active nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
138
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
139 (defvar toolbar-blank-press-function nil
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
140 "Function to call if a blank area of the toolbar is pressed.")
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
141
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
142 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
143 ;; It really sucks that we also have to tie onto
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
144 ;; default-mouse-motion-handler to make sliding buttons work right.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
145 ;;
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
146 (defun press-toolbar-button (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
147 "Press a toolbar button. This only changes its appearance.
3061
fd1acd2f457a [xemacs-hg @ 2005-11-13 07:39:26 by ben]
ben
parents: 771
diff changeset
148 Call function stored in `toolbar-blank-press-function', if any, with EVENT as
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
149 an argument if press is over a blank area of the toolbar."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
150 (interactive "_e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
151 (setq this-command last-command)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
152 (let ((button (event-toolbar-button event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
153 ;; We silently ignore non-buttons. This most likely means we are
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
154 ;; over a blank part of the toolbar.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
155 (setq toolbar-active t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
156 (if (toolbar-button-p button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
157 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
158 (set-toolbar-button-down-flag button t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
159 (setq last-pressed-toolbar-button button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
160 ;; Added by Bob Weiner, Motorola Inc., 10/6/95, to handle
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
161 ;; presses on blank portions of toolbars.
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
162 (when (functionp toolbar-blank-press-function)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
163 (funcall toolbar-blank-press-function event)))))
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
164
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
165 (defun release-and-activate-toolbar-button (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
166 "Release a toolbar button and activate its callback.
3061
fd1acd2f457a [xemacs-hg @ 2005-11-13 07:39:26 by ben]
ben
parents: 771
diff changeset
167 Call function stored in `toolbar-blank-release-function', if any, with EVENT
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
168 as an argument if release is over a blank area of the toolbar."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
169 (interactive "_e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
170 (or (button-release-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
171 (error "%s must be invoked by a mouse-release" this-command))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
172 (release-toolbar-button event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
173 (let ((button (event-toolbar-button event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
174 (if (and (toolbar-button-p button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
175 (toolbar-button-enabled-p button)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
176 (toolbar-button-callback button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
177 (let ((callback (toolbar-button-callback button)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
178 (setq this-command callback)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
179 ;; Handle arbitrary functions.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
180 (if (functionp callback)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
181 (if (commandp callback)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
182 (call-interactively callback)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
183 (funcall callback))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
184 (eval callback))))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
185
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
186 ;; If current is not t, then only release the toolbar button stored in
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
187 ;; last-pressed-toolbar-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
188 (defun release-toolbar-button-internal (event current)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
189 (let ((button (event-toolbar-button event)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
190 (setq zmacs-region-stays t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
191 (if (and last-pressed-toolbar-button
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
192 (not (eq last-pressed-toolbar-button button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
193 (toolbar-button-p last-pressed-toolbar-button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
194 (progn
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
195 (set-toolbar-button-down-flag last-pressed-toolbar-button nil)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
196 (setq last-pressed-toolbar-button nil)))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
197 (if (and current (toolbar-button-p button))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
198 (set-toolbar-button-down-flag button nil))))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
199
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
200 (defun release-toolbar-button (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
201 "Release all pressed toolbar buttons."
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
202 (interactive "_e")
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
203 (or (button-release-event-p event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
204 (error "%s must be invoked by a mouse-release" this-command))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
205 (release-toolbar-button-internal event t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
206 ;; Don't set this-command if we're being called
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
207 ;; from release-and-activate-toolbar-button.
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
208 (if (interactive-p)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
209 (setq this-command last-command))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
210 (setq toolbar-active nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
211
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
212 (defun release-previous-toolbar-button (event)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
213 (setq zmacs-region-stays t)
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
214 (release-toolbar-button-internal event nil))
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
215
442
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
216 (defun make-toolbar-specifier (spec-list)
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
217 "Return a new `toolbar' specifier object with the given specification list.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
218 SPEC-LIST can be a list of specifications (each of which is a cons of a
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
219 locale and a list of instantiators), a single instantiator, or a list
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
220 of instantiators. See `make-specifier' for more information about
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
221 specifiers.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
222
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
223 Toolbar specifiers are used to specify the format of a toolbar.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
224 The values of the variables `default-toolbar', `top-toolbar',
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
225 `left-toolbar', `right-toolbar', and `bottom-toolbar' are always
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
226 toolbar specifiers.
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
227
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
228 Valid toolbar instantiators are called \"toolbar descriptors\"
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
229 and are lists of vectors. See `default-toolbar' for a description
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
230 of the exact format."
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
231 (make-specifier-and-init 'toolbar spec-list))
abe6d1db359e Import from CVS: tag r21-2-36
cvs
parents: 428
diff changeset
232
428
3ecd8885ac67 Import from CVS: tag r21-2-22
cvs
parents:
diff changeset
233 ;;; toolbar.el ends here