99 |
function will first try to use ICON.xpm, then ICON.pbm, and finally |
function will first try to use ICON.xpm, then ICON.pbm, and finally |
100 |
ICON.xbm, using `find-image'. |
ICON.xbm, using `find-image'. |
101 |
|
|
102 |
Keybindings are made in the map `tool-bar-map'. To define items in |
Use this function only to make bindings in the global value of `tool-bar-map'. |
103 |
some local map, bind `tool-bar-map' with `let' around calls of this |
To define items in any other map, use `tool-bar-local-item'." |
104 |
function." |
(apply 'tool-bar-local-item icon def key tool-bar-map props)) |
105 |
|
|
106 |
|
;;;###autoload |
107 |
|
(defun tool-bar-local-item (icon def key map &rest props) |
108 |
|
"Add an item to the tool bar in map MAP. |
109 |
|
ICON names the image, DEF is the key definition and KEY is a symbol |
110 |
|
for the fake function key in the menu keymap. Remaining arguments |
111 |
|
PROPS are additional items to add to the menu item specification. See |
112 |
|
Info node `(elisp)Tool Bar'. Items are added from left to right. |
113 |
|
|
114 |
|
ICON is the base name of a file containing the image to use. The |
115 |
|
function will first try to use ICON.xpm, then ICON.pbm, and finally |
116 |
|
ICON.xbm, using `find-image'." |
117 |
(let* ((fg (face-attribute 'tool-bar :foreground)) |
(let* ((fg (face-attribute 'tool-bar :foreground)) |
118 |
(bg (face-attribute 'tool-bar :background)) |
(bg (face-attribute 'tool-bar :background)) |
119 |
(colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg)) |
(colors (nconc (if (eq fg 'unspecified) nil (list :foreground fg)) |
133 |
(when (and (display-images-p) image) |
(when (and (display-images-p) image) |
134 |
(unless (image-mask-p image) |
(unless (image-mask-p image) |
135 |
(setq image (append image '(:mask heuristic)))) |
(setq image (append image '(:mask heuristic)))) |
136 |
(define-key-after tool-bar-map (vector key) |
(define-key-after map (vector key) |
137 |
`(menu-item ,(symbol-name key) ,def :image ,image ,@props))))) |
`(menu-item ,(symbol-name key) ,def :image ,image ,@props))))) |
138 |
|
|
139 |
;;;###autoload |
;;;###autoload |
140 |
(defun tool-bar-add-item-from-menu (command icon &optional map &rest props) |
(defun tool-bar-add-item-from-menu (command icon &optional map &rest props) |
141 |
"Define tool bar binding for COMMAND using the given ICON in keymap MAP. |
"Define tool bar binding for COMMAND using the given ICON in keymap MAP. |
142 |
The binding of COMMAND is looked up in the menu bar in MAP (default |
This makes a binding for COMMAND in `tool-bar-map', copying its |
143 |
`global-map') and modified to add an image specification for ICON, which |
binding from the menu bar in MAP (which defaults to `global-map'), but |
144 |
is looked for as by `tool-bar-add-item'. |
modifies the binding by adding an image specification for ICON. It |
145 |
MAP must contain an appropriate keymap bound to `[menu-bar]'. |
finds ICON just like `tool-bar-add-item'. PROPS are additional |
146 |
PROPS is a list of additional properties to add to the binding. |
properties to add to the binding. |
147 |
|
|
148 |
Keybindings are made in the map `tool-bar-map'. To define items in |
MAP must contain appropriate binding for `[menu-bar]' which holds a keymap. |
149 |
some local map, bind `tool-bar-map' with `let' around calls of this |
|
150 |
function." |
Use this function only to make bindings in the global value of `tool-bar-map'. |
151 |
(unless map |
To define items in any other map, use `tool-bar-local-item'." |
152 |
(setq map global-map)) |
(apply 'tool-bar-local-item-from-menu command icon tool-bar-map map props)) |
153 |
(let* ((menu-bar-map (lookup-key map [menu-bar])) |
|
154 |
|
;;;###autoload |
155 |
|
(defun tool-bar-local-item-from-menu (command icon in-map &optional from-map &rest props) |
156 |
|
"Define tool bar binding for COMMAND using the given ICON in keymap MAP. |
157 |
|
This makes a binding for COMMAND in IN-MAP, copying its binding from |
158 |
|
the menu bar in FROM-MAP (which defaults to `global-map'), but |
159 |
|
modifies the binding by adding an image specification for ICON. It |
160 |
|
finds ICON just like `tool-bar-add-item'. PROPS are additional |
161 |
|
properties to add to the binding. |
162 |
|
|
163 |
|
MAP must contain appropriate binding for `[menu-bar]' which holds a keymap." |
164 |
|
(unless from-map |
165 |
|
(setq from-map global-map)) |
166 |
|
(let* ((menu-bar-map (lookup-key from-map [menu-bar])) |
167 |
(keys (where-is-internal command menu-bar-map)) |
(keys (where-is-internal command menu-bar-map)) |
168 |
(fg (face-attribute 'tool-bar :foreground)) |
(fg (face-attribute 'tool-bar :foreground)) |
169 |
(bg (face-attribute 'tool-bar :background)) |
(bg (face-attribute 'tool-bar :background)) |
204 |
(setq image (append image '(:mask heuristic)))) |
(setq image (append image '(:mask heuristic)))) |
205 |
(let ((defn (assq key (cdr submap)))) |
(let ((defn (assq key (cdr submap)))) |
206 |
(if (eq (cadr defn) 'menu-item) |
(if (eq (cadr defn) 'menu-item) |
207 |
(define-key-after tool-bar-map (vector key) |
(define-key-after in-map (vector key) |
208 |
(append (cdr defn) (list :image image) props)) |
(append (cdr defn) (list :image image) props)) |
209 |
(setq defn (cdr defn)) |
(setq defn (cdr defn)) |
210 |
(define-key-after tool-bar-map (vector key) |
(define-key-after in-map (vector key) |
211 |
(append `(menu-item ,(car defn) ,(cddr defn)) |
(append `(menu-item ,(car defn) ,(cddr defn)) |
212 |
(list :image image) props))))))) |
(list :image image) props))))))) |
213 |
|
|