1 ;;; wl-demo.el --- Opening demo on Wanderlust
3 ;; Copyright (C) 1998,1999,2000,2001 Yuuichi Teranishi <teranisi@gohome.org>
4 ;; Copyright (C) 2000,2001 Katsumi Yamaoka <yamaoka@jpl.org>
6 ;; Author: Yuuichi Teranishi <teranisi@gohome.org>
7 ;; Katsumi Yamaoka <yamaoka@jpl.org>
8 ;; Keywords: mail, net news
10 ;; This file is part of Wanderlust (Yet Another Message Interface on Emacsen).
12 ;; This program is free software; you can redistribute it and/or modify
13 ;; it under the terms of the GNU General Public License as published by
14 ;; the Free Software Foundation; either version 2, or (at your option)
17 ;; This program is distributed in the hope that it will be useful,
18 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 ;; GNU General Public License for more details.
22 ;; You should have received a copy of the GNU General Public License
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
25 ;; Boston, MA 02111-1307, USA.
31 (defconst wl-demo-copyright-notice
32 "Copyright (C) 1998-2001 Yuuichi Teranishi <teranisi@gohome.org>"
33 "A declaration of the copyright on Wanderlust.")
40 (require 'wl-highlight)
42 (defconst wl-demo-icon-name
43 (concat "wl-" (wl-version-status)
44 (if (string-match "^... Dec \\([ 1][0-9]\\|2[0-4]\\)"
45 (current-time-string))
48 "Basename of the logo file.")
50 (defvar wl-logo-ascii "\
52 oo$$$ o$$ o$$$\"\"\"\"\"\"$$$$$o
53 $$$$$$\" o$$$\" o$\"\" \"$$$
57 o$$ oo$\" \"$$$o $ o$$
58 $$$$\"\" \"$$oo$ o o$\"
59 \"$$o \"$$$o oooo$\"\"
63 Yet Another Message Interface On Emacsen"
64 "Ascii picture used to splash the startup screen.")
68 ;; `display-images-p' has not been available in Emacs versions
69 ;; prior to Emacs 21.0.105.
70 (defalias-maybe 'display-images-p 'display-graphic-p)))
72 ;; Avoid byte compile warnings.
74 (autoload 'bitmap-insert-xbm-file "bitmap" nil t)
75 (autoload 'create-image "image")
76 (autoload 'device-on-window-system-p "device")
77 (autoload 'image-type-available-p "image")
78 (autoload 'insert-image "image")
79 (autoload 'make-glyph "glyphs")
80 (autoload 'set-glyph-face "glyphs")
81 (autoload 'set-specifier "specifier")
82 (defalias-maybe 'frame-char-height 'ignore)
83 (defalias-maybe 'frame-char-width 'ignore)
84 (defalias-maybe 'glyph-height 'ignore)
85 (defalias-maybe 'glyph-width 'ignore)
86 (defalias-maybe 'image-size 'ignore)
87 (defalias-maybe 'make-extent 'ignore)
88 (defalias-maybe 'propertize 'ignore)
89 (defalias-maybe 'set-extent-end-glyph 'ignore)
90 (defalias-maybe 'window-pixel-height 'ignore)
91 (defalias-maybe 'window-pixel-width 'ignore))
93 (defvar wl-demo-bitmap-mule-available-p 'unknown
94 "Internal variable to say whether the BITMAP-MULE package is available.")
96 (defun wl-demo-image-type-alist ()
97 "Return an alist of available logo image types on the current frame."
98 (if (or (and (featurep 'xemacs)
99 (device-on-window-system-p))
102 (when (or (and (featurep 'xemacs)
106 (image-type-available-p 'xpm)))
108 (when (and (not (or (featurep 'xemacs)
109 ;; *.img files won't fit for Emacs 21.
111 (or (eq t wl-demo-bitmap-mule-available-p)
112 (and (eq 'unknown wl-demo-bitmap-mule-available-p)
113 (module-installed-p 'bitmap)
114 (setq wl-demo-bitmap-mule-available-p t))))
115 '(("bitmap" . bitmap)))
116 (when (or (featurep 'xemacs)
119 (image-type-available-p 'xbm))
120 (eq t wl-demo-bitmap-mule-available-p)
121 (and (eq 'unknown wl-demo-bitmap-mule-available-p)
122 (module-installed-p 'bitmap)
123 (setq wl-demo-bitmap-mule-available-p t)))
128 (defun wl-demo-insert-image (image-type)
129 "Insert a logo image at the point and position it to be centered.
130 IMAGE-TYPE specifies what a type of image should be displayed.
131 Return a number of lines that an image occupies in the buffer."
132 (let ((file (cond ((eq 'xpm image-type)
133 (concat wl-demo-icon-name ".xpm"))
134 ((eq 'bitmap image-type)
135 (concat wl-demo-icon-name ".img"))
136 ((eq 'xbm image-type)
137 (concat wl-demo-icon-name ".xbm"))))
139 (when (featurep 'xemacs)
140 (when (boundp 'default-gutter-visible-p)
141 (set-specifier (symbol-value 'default-gutter-visible-p)
142 nil (current-buffer)))
143 (set-specifier (symbol-value 'scrollbar-height) 0 (current-buffer))
144 (set-specifier (symbol-value 'scrollbar-width) 0 (current-buffer)))
146 (if (and wl-icon-directory
147 (file-directory-p wl-icon-directory))
148 (setq file (expand-file-name file wl-icon-directory))
149 (message "You have to specify the value of `wl-icon-directory'")
151 (if (file-exists-p file)
152 (if (file-readable-p file)
154 (message "Permission denied: %s" file)
156 (message "File not found: %s" file)
159 (cond ((featurep 'xemacs)
160 (setq width (window-pixel-width)
161 height (window-pixel-height)
162 image (make-glyph (vector image-type ':file file)))
163 (when (eq 'xbm image-type)
164 (set-glyph-face image 'wl-highlight-logo-face))
165 (insert-char ?\ (max 0 (/ (+ (* (- width (glyph-width image))
166 (window-width)) width)
168 (set-extent-end-glyph (make-extent (point) (point)) image)
170 (/ (+ (* 2 (glyph-height image) (window-height)) height)
172 ((eq 'bitmap image-type)
174 (let ((coding-system-for-read 'iso-2022-7bit)
175 (input-coding-system '*iso-2022-jp*))
176 (insert-file-contents file))
178 (indent-rigidly (point-min) (point-max)
179 (max 0 (/ (1+ (- (window-width)
182 (put-text-property (point-min) (point-max)
183 'face 'wl-highlight-logo-face)
184 (count-lines (point-min) (goto-char (point-max))))
185 ((>= emacs-major-version 21)
186 (setq image (create-image file image-type)
187 width (image-size image)
190 (when (eq 'xbm image-type)
191 (let ((bg (face-background 'wl-highlight-demo-face))
192 (fg (face-foreground 'wl-highlight-demo-face)))
194 (plist-put (cdr image) ':background bg))
196 (plist-put (cdr image) ':foreground fg))))
197 (insert (propertize " " 'display
198 (list 'space ':align-to
199 (max 0 (round (- (window-width)
205 ((eq 'xbm image-type)
206 (message "Composing a bitmap image...")
208 (bitmap-insert-xbm-file file)
210 (indent-rigidly (point-min) (point-max)
211 (max 0 (/ (1+ (- (window-width)
214 (put-text-property (point-min) (point-max)
215 'face 'wl-highlight-logo-face)
216 (message "Composing a bitmap image...done")
217 (count-lines (point-min) (goto-char (point-max))))))
218 (insert wl-logo-ascii)
219 (put-text-property (point-min) (point) 'face 'wl-highlight-logo-face)
226 (setq width (max width (current-column))))
227 (indent-rigidly (point-min) (point-max)
228 (max 0 (/ (1+ (- (window-width) width)) 2)))
229 (count-lines (point-min) (goto-char (point-max))))))
231 (defun wl-demo-insert-text (height)
232 "Insert a version and the copyright message after a logo image. HEIGHT
233 should be a number of lines that an image occupies in the buffer."
234 (let* ((height (- (window-height) height 1))
235 (text (format (cond ((<= height 2)
236 "version %s - \"%s\"\n%s")
238 "version %s - \"%s\"\n\n%s")
240 "\nversion %s - \"%s\"\n\n%s"))
241 (product-version-string (product-find 'wl-version))
242 (product-code-name (product-find 'wl-version))
243 wl-demo-copyright-notice))
245 (goto-char (point-min))
246 (insert-char ?\n (max 0 (/ (- height 4) 2)))
247 (setq start (goto-char (point-max)))
249 (let ((bg (face-background 'wl-highlight-demo-face))
250 (fg (face-foreground 'wl-highlight-demo-face)))
251 (insert (propertize text
252 'face (nconc '(variable-pitch :slant oblique)
254 (list ':background bg))
256 (list ':foreground fg))))))
258 (put-text-property start (point) 'face 'wl-highlight-demo-face))
259 (let ((fill-column (window-width)))
260 (center-region start (point)))))
262 (defun wl-demo (&optional image-type)
263 "Demo on the startup screen. IMAGE-TYPE should be a symbol which
264 overrides the variable `wl-demo-display-logo'. It will prompt user
265 for the type of image when it is called interactively with a prefix
268 (let ((selection (wl-demo-image-type-alist))
270 (if (and image-type (interactive-p))
271 (setq type (completing-read "Image type: " selection nil t)
272 image-type (when (assoc type selection)
273 (cdr (assoc type selection))))
274 (if (setq type (assoc (format "%s" (or image-type wl-demo-display-logo))
276 (setq image-type (cdr type))
277 (setq image-type (when wl-demo-display-logo
278 (cdr (car selection)))))))
279 (let ((buffer (let ((default-enable-multibyte-characters t)
281 (default-line-spacing 0))
282 (get-buffer-create "*WL Demo*"))))
283 (switch-to-buffer buffer)
284 (setq buffer-read-only nil)
286 (setq truncate-lines t
288 (set (make-local-variable 'tab-stop-list)
289 '(8 16 24 32 40 48 56 64 72 80 88 96 104 112 120))
290 (wl-demo-insert-text (wl-demo-insert-image image-type))
291 (set-buffer-modified-p nil)
292 (goto-char (point-min))
293 (sit-for (if (featurep 'lisp-float-type)
294 (/ (float 5) (float 10))
299 (product-provide (provide 'wl-demo) (require 'wl-version))
301 ;;; wl-demo.el ends here