Mercurial > emacs
comparison lisp/image.el @ 28721:b4ea18c92e38
(find-image): New function.
(defimage): Rewritten to find image at load time.
author | Gerd Moellmann <gerd@gnu.org> |
---|---|
date | Wed, 26 Apr 2000 17:34:09 +0000 |
parents | ea0a2a4f20b7 |
children | 56c76b64f321 |
comparison
equal
deleted
inserted
replaced
28720:f8379b011476 | 28721:b4ea18c92e38 |
---|---|
174 (delete-overlay overlay))) | 174 (delete-overlay overlay))) |
175 (setq overlays (cdr overlays))))) | 175 (setq overlays (cdr overlays))))) |
176 | 176 |
177 | 177 |
178 ;;;###autoload | 178 ;;;###autoload |
179 (defmacro defimage (symbol specs &optional doc) | 179 (defun find-image (specs) |
180 "Define SYMBOL as an image. | 180 "Find an image, choosing one of a list of image specifications. |
181 | 181 |
182 SPECS is a list of image specifications. DOC is an optional | 182 SPECS is a list of image specifications. DOC is an optional |
183 documentation string. | 183 documentation string. |
184 | 184 |
185 Each image specification in SPECS is a property list. The contents of | 185 Each image specification in SPECS is a property list. The contents of |
187 least contain the properties `:type TYPE' and either `:file FILE' or | 187 least contain the properties `:type TYPE' and either `:file FILE' or |
188 `:data DATA', where TYPE is a symbol specifying the image type, | 188 `:data DATA', where TYPE is a symbol specifying the image type, |
189 e.g. `xbm', FILE is the file to load the image from, and DATA is a | 189 e.g. `xbm', FILE is the file to load the image from, and DATA is a |
190 string containing the actual image data. The first image | 190 string containing the actual image data. The first image |
191 specification whose TYPE is supported, and FILE exists, is used to | 191 specification whose TYPE is supported, and FILE exists, is used to |
192 define SYMBOL. | 192 define SYMBOL." |
193 | |
194 Example: | |
195 | |
196 (defimage test-image ((:type xpm :file \"~/test1.xpm\") | |
197 (:type xbm :file \"~/test1.xbm\")))" | |
198 (let (image) | 193 (let (image) |
199 (while (and specs (null image)) | 194 (while (and specs (null image)) |
200 (let* ((spec (car specs)) | 195 (let* ((spec (car specs)) |
201 (type (plist-get spec :type)) | 196 (type (plist-get spec :type)) |
202 (data (plist-get spec :data)) | 197 (data (plist-get spec :data)) |
214 (setq found (expand-file-name file data-directory))) | 209 (setq found (expand-file-name file data-directory))) |
215 (setq image (cons 'image (plist-put spec :file found))))) | 210 (setq image (cons 'image (plist-put spec :file found))))) |
216 ((not (null data)) | 211 ((not (null data)) |
217 (setq image (cons 'image spec))))) | 212 (setq image (cons 'image spec))))) |
218 (setq specs (cdr specs)))) | 213 (setq specs (cdr specs)))) |
219 `(defvar ,symbol ',image ,doc))) | 214 image)) |
215 | |
216 | |
217 ;;;###autoload | |
218 (defmacro defimage (symbol specs &optional doc) | |
219 "Define SYMBOL as an image. | |
220 | |
221 SPECS is a list of image specifications. DOC is an optional | |
222 documentation string. | |
223 | |
224 Each image specification in SPECS is a property list. The contents of | |
225 a specification are image type dependent. All specifications must at | |
226 least contain the properties `:type TYPE' and either `:file FILE' or | |
227 `:data DATA', where TYPE is a symbol specifying the image type, | |
228 e.g. `xbm', FILE is the file to load the image from, and DATA is a | |
229 string containing the actual image data. The first image | |
230 specification whose TYPE is supported, and FILE exists, is used to | |
231 define SYMBOL. | |
232 | |
233 Example: | |
234 | |
235 (defimage test-image ((:type xpm :file \"~/test1.xpm\") | |
236 (:type xbm :file \"~/test1.xbm\")))" | |
237 `(defvar ,symbol (find-image ',specs) ,doc)) | |
220 | 238 |
221 | 239 |
222 (provide 'image) | 240 (provide 'image) |
223 | 241 |
224 ;;; image.el ends here | 242 ;;; image.el ends here |