annotate lisp/xpm-button.el @ 369:1d62742628b6 r21-1-14

Import from CVS: tag r21-1-14
author cvs
date Mon, 13 Aug 2007 11:01:51 +0200
parents 182f72e8cd0d
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
355
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
1 ;;; xpm-button.el --- create XPM buttons
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
2
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
3 ;; Copyright (C) 1997 Free Software Foundation, Inc.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
4 ;; Copyright (C) 1995 Kyle E. Jones
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
5
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
6 ;; Author: Kyle Jones
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
7 ;; Maintainer: XEmacs Development Team
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
8 ;; Keywords: frames, internal
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
9
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
10 ;; This file is part of XEmacs.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
11
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
12 ;; XEmacs is free software; you can redistribute it and/or modify it
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
13 ;; under the terms of the GNU General Public License as published by
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
14 ;; the Free Software Foundation; either version 1, or (at your option)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
15 ;; any later version.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
16
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
17 ;; XEmacs is distributed in the hope that it will be useful, but
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
18 ;; WITHOUT ANY WARRANTY; without even the implied warranty of
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
19 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
20 ;; General Public License for more details.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
21
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
22 ;; You should have received a copy of the GNU General Public License
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
23 ;; along with GNU Emacs; see the file COPYING. If not, write to the
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
24 ;; Free Software Foundation, Inc., 59 Temple Place - Suite 330,
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
25 ;; Boston, MA 02111-1307, USA.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
26
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
27 ;;; Synched up with: Not in FSF.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
28
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
29 ;;; Commentary:
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
30
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
31 ;; Create XPM text buttons under XEmacs (requires 19.12 or beyond)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
32
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
33 ;; Send bug reports to kyle@wonderworks.com
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
34
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
35 ;; Sample use of this package.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
36 ;;(progn
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
37 ;; (setq b (xpm-button-create "Test button" 2 "yellow" "#a0a0d0"))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
38 ;; (setq e (make-extent (point-max) (point-max)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
39 ;; (setq g (make-glyph (nth 0 b)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
40 ;; (set-extent-begin-glyph e g)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
41 ;; (setq g2 (make-glyph (nth 1 b)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
42 ;; (setq k (make-sparse-keymap))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
43 ;; (define-key k 'button1 '(lambda (ev)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
44 ;; (interactive "e")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
45 ;; (set-extent-begin-glyph e g2)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
46 ;; (define-key k 'button1up '(lambda (ev)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
47 ;; (interactive "e")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
48 ;; (set-extent-begin-glyph e g)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
49 ;; (set-extent-property e 'keymap k))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
50
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
51 ;; The sole interface function is xpm-button-create.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
52
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
53 ;;; Code:
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
54
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
55 (provide 'xpm-button)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
56
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
57 (defvar xpm-button-version "1.02"
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
58 "Version string for xpm-button.")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
59
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
60 (defvar xpm-button-vertical-padding 3
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
61 "Number of pixels between the text and the top/bottom of the button.")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
62
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
63 (defvar xpm-button-horizontal-padding 3
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
64 "Number of pixels between the text and the left/right edges of the button.")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
65
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
66 (defvar xpm-button-font-pixel-lines
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
67 '(
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
68 " xx xxxxxx xxxx x xxxxxxx xxxxxxxx xxxxxxxx xxxx x xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxxx xxx xxx xxxxx xxxxxxx xxxxx xxxxxxx xxxx x xxxxxxxx xxxx xxx xxxx xxx xxxx xxxx xxx xxxx xxxx xxxx xxx xxxxxxxx xxx xxx xxx xxx xx xx xxx xxx x xx x xxxx xxxx xxx xxxxx xxx xxxxxx xxxx xxxx x xx xxxx x x xxxx xx x x xxx x x x xxxx xx xxxx xx xx x x x xxxx x x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
69 " xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx x xx xxx xxx xxx x xx xx xx xx xx xx xx xx xx xx xx xx xx xx x xx x xx xx x xx x xx x xx xxx xx xx xx x xx xx xx xx xx xx x x xxx xx xx xx xx xxx xxxx x xx xxxxxx xx xx xx xx x xx xx x x x xx xxx xx xxxx x xx x x x x x x xx xx xx xx xx x x x xx xx xx x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
70 " x xx xx xx xx x xx xx xx x xx x xx x xx xx xx xx xx x xx xxx xxx xxxx x xx xx xx xx xx xx xx xx xx x x xx x xx x xx x xx xx x xxx x xx x x xxx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx x xx x xx xx x x xx x xx xx xx xx x xxxx x xxxxxx x x xx x x xxx xx x xxx xx xx x xx xx xx xx x x x x xx xx x x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
71 " x xx xx xx xx x xx xx xx x xx x x xx x xx xx xx xx xx x xx x xx x xx x xxx x xx xx xx xx xx xx xx xx xxxx x xx x xx x xx x xx x xx x xxxx xx x xxx xxxx xx xx xxx xx xx xxx xxxxx xxxx xx xx xxx xxx xx xxx xx xxx xx xx xxx xx xxx xxx xx xx xx xxx xx xxxx xxxxx xxx xxx xxxx xxx xxx xxxx xxx xxx xxx xxxx xxx xxxxxx xx xx xx xx xx x xx xxxx xx xx xx x xx xx xx xx x x xx x x x xx x xx x x xx x x xx xxx x x x x x x xx xx xx xx xx xx x xx xx xx xx xx x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
72 " x xx xxxxx xx xx xx xxxxx xxxxx xx xxxxxxxx xx xx xxxxx xx x xx x xx x xxx x xx xx xx xx xx xx xxxxx xxxxx xx xx x xx x xx x xx x xxx xx x xx x xx xxx xxx xxx xx xxx xxx xxx xx xx xx xx xxx xx xx xx xx xx xx xxx xxx xx xxx xx xxx xxx xxx xxx xxx xxx xxxxx x x xx xx xx xx x xx xx x xx x xx x x xxx xx xx xx xx xx x xx x xx xxxxx xx xxxx xxxxx xx x xx x xx xx x x x xxxx xx x x xx x xx xx xxxx x x xx xx xxxxxx x xx x xx x xx xx xxx xxx x xx x x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
73 " xxxxxx xx xx xx xx xx xx x xx x xx xxxx xx xx xx xx xx xxx xx x xx x xx x xxxx xx xx xxxxx xx xx xx xx xx xxxx xx xx x xx x xx x xx x x xxx xx xxx xxxx xx xx xx xx xx xxxxxx xx xx xx xx xx xx xx xxxx xx xx xx xx xx xx xx xx xx xx xx xx xx xxxx xx xx xx xx x xx xxx x xxx xx x xxx xx xx xx xx xx x xx xx xx xx xx x xxx xx xxxxxx xx x xx xx x xxxxxx xxx xx x xx x x x x xxxx xx xx xxxxxx xxxxxxx xx x xx x xxx xxx xx x xx x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
74 " x xx xx xx xx x xx xx xx x xx xx xx xx xx xx xx xx xx xx xx x x xx xx x xxx xx xx xx xxx x xx xx xx x xx xx xx x xx x xx xx x xxx xx xxx x xx xx xx xx xx xx xx xx xx xxxx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xxxx xx xx xx xx x xx xxx x xxx xx x xxx xx xx xx x x xx xx xxxxxx xx xx xx xx xx x xx xx xx x xx x xx xx x x xx x x x xx x xx xxx xx xx xxxxxx x xx x xx x xxx xxx x x x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
75 " x xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xx xxx xx xx x xx xx x xx xx xx xx xx xxx xx xxx xx xx xx xxx xx xx xx xx x xx xx xxx xx xx xxx xx xxx xxx xx xxx xxx xxx xx xx x xx xx xx xx xx xx xx xx xx xx xx xx xxx xxx xxx xxx xxx xxx xx x x xx xx xxx xx xx xx x xx xx xxx x x x xx xxxxxx xx xx xx xx xx xx xx xx xx xx xx x xx x x x x xx x x x xx x xxx xxxxx x x x xx xx xx xx xx xx xx xx xx xx x xx xx x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
76 "xxx xxxx xxxxxxx xxxxx xxxxxxx xxxxxxxx xxxx xxxx x xxxx xxxx xxxx xxx xxxx xxx xxxxxxxx xxx xx xxxx xxx x xxxxx xxxx xxxxx xxxx xx x xxxx xxxx xxxxx xx xx xx xxx xxxx xxxx xxxxxxxx xx xxx x xxx xxx xx xxx xxx xxxx xxxxxx xxxx xxx xxxx xx xxxx xxx xxxx xxxx xxx xxx xxxx xxx xxx xx xx xx xx xxxx xxxx xx xx xxx xx xx xx xxx xxx xx xxxxxx xx xxxx xxxxxx xxxx xxxx xxxx xxxx xx xxxx xxx xx xxxxxx x x xxxx x xx xxxx xx xx xx x xx xx xx xx xx xx xx xx x xx x x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
77 " xxxx xxxxxx xx xx xx x x x x xx xx xx xx x x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
78 " xx x xx xx xx xx xxx x x xxxxxxx xxxx xx xxxx xx x x "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
79 " xxxxx xx xxxx xxxx xx "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
80 )
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
81 "List of strings representing pixel lines for the button font.")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
82
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
83 (defvar xpm-button-font-line-indices
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
84 '(("A" 0 10)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
85 ("B" 11 19)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
86 ("C" 20 28)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
87 ("D" 29 38)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
88 ("E" 39 47)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
89 ("F" 48 56)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
90 ("G" 57 66)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
91 ("H" 67 77)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
92 ("I" 78 82)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
93 ("J" 83 90)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
94 ("K" 91 100)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
95 ("L" 101 109)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
96 ("M" 110 121)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
97 ("N" 122 132)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
98 ("O" 133 142)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
99 ("P" 143 151)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
100 ("Q" 152 162)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
101 ("R" 163 172)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
102 ("S" 173 180)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
103 ("T" 181 189)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
104 ("U" 190 199)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
105 ("V" 200 210)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
106 ("W" 211 224)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
107 ("X" 225 234)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
108 ("Y" 235 243)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
109 ("Z" 244 252)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
110 ("a" 253 260)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
111 ("b" 261 269)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
112 ("c" 270 276)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
113 ("d" 277 285)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
114 ("e" 286 292)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
115 ("f" 293 298)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
116 ("g" 299 306)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
117 ("h" 307 315)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
118 ("i" 316 320)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
119 ("j" 321 324)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
120 ("k" 325 333)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
121 ("l" 334 338)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
122 ("m" 339 351)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
123 ("n" 352 360)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
124 ("o" 361 368)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
125 ("p" 369 377)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
126 ("q" 378 386)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
127 ("r" 387 393)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
128 ("s" 394 399)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
129 ("t" 400 405)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
130 ("u" 406 414)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
131 ("v" 415 423)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
132 ("w" 424 436)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
133 ("x" 437 444)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
134 ("y" 445 453)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
135 ("z" 454 460)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
136 ("0" 461 467)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
137 ("1" 468 472)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
138 ("2" 473 479)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
139 ("3" 480 486)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
140 ("4" 487 493)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
141 ("5" 494 500)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
142 ("6" 501 507)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
143 ("7" 508 514)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
144 ("8" 515 521)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
145 ("9" 522 528)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
146 ("`" 529 531)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
147 ("~" 532 538)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
148 ("!" 539 541)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
149 ("@" 542 552)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
150 ("#" 553 560)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
151 ("$" 561 567)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
152 ("%" 568 580)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
153 ("^" 581 586)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
154 ("&" 587 597)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
155 ("*" 598 603)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
156 ("(" 604 608)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
157 (")" 609 613)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
158 ("-" 614 620)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
159 ("_" 621 628)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
160 ("=" 629 635)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
161 ("+" 636 643)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
162 ("[" 644 648)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
163 ("{" 649 653)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
164 ("]" 654 658)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
165 ("}" 659 663)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
166 (";" 664 666)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
167 (":" 667 669)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
168 ("'" 670 672)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
169 ("\"" 673 676)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
170 ("," 677 679)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
171 ("<" 680 686)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
172 ("." 687 689)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
173 (">" 690 696)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
174 ("/" 697 700)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
175 ("?" 701 707)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
176 ("\\" 708 713)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
177 ("|" 714 715)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
178 (" " 716 719))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
179 "Indices into the xpm-button-font-pixel-lines strings for each character.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
180 Format is
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
181 (STR START END)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
182 STR contains the character.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
183 START is where the character's pixels start in each string of
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
184 xpm-button-font-pixel-lines (0 is the index of the first pixel).
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
185 END is the index of the position after the last pixel of the character.")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
186
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
187 (defun xpm-button-color-rgb-components (color)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
188 "Return the RGB components of COLOR as a list of integers (R G B).
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
189 16-bit values are always returned.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
190 #FEFEFE and rgb:fe/fe/fe style color specifications are parsed directly
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
191 into their components."
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
192 (color-instance-rgb-components (make-color-instance color)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
193
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
194 (defun xpm-button-compute-contrast-color (color)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
195 "Compute a contrasting color for COLOR.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
196 The new color is created by xor-ing the RGB values of COLOR with all ones."
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
197 (let* ((rgb (xpm-button-color-rgb-components color))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
198 (r (logxor (nth 0 rgb) 65535))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
199 (g (logxor (nth 1 rgb) 65535))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
200 (b (logxor (nth 2 rgb) 65535)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
201 (format "rgb:%04x/%04x/%04x" r g b)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
202
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
203 (defun xpm-button-compute-shadow-colors (color)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
204 "Compute shadow colors for COLOR.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
205 COLOR should be a string naming a color.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
206 Returns (COLOR1 . COLOR2) where COLOR1 is the brighter shadow color
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
207 and COLOR2 is the dimmer color."
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
208 (let* ((rgb (xpm-button-color-rgb-components color))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
209 (r (nth 0 rgb))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
210 (g (nth 1 rgb))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
211 (b (nth 2 rgb))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
212 (bright-r (/ (* r 12) 10))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
213 (bright-g (/ (* g 12) 10))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
214 (bright-b (/ (* b 12) 10))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
215 (dim-r (/ (* r 8) 10))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
216 (dim-g (/ (* g 8) 10))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
217 (dim-b (/ (* b 8) 10)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
218 (if (> bright-r 65535)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
219 (setq bright-r 65535))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
220 (if (> bright-g 65535)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
221 (setq bright-g 65535))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
222 (if (> bright-b 65535)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
223 (setq bright-b 65535))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
224 (cons (format "rgb:%04x/%04x/%04x" bright-r bright-g bright-b)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
225 (format "rgb:%04x/%04x/%04x" dim-r dim-g dim-b))))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
226
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
227 ;;;###autoload
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
228 (defun xpm-button-create (text shadow-thickness fg-color bg-color)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
229 "Returns a list of XPM image instantiators for a button displaying TEXT.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
230 The list is of the form
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
231 (UP DOWN DISABLED)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
232 where UP, DOWN, and DISABLED are the up, down and disabled image
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
233 instantiators for the button.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
234
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
235 SHADOW-THICKNESS specifies how many pixels should be used for the
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
236 shadows on the edges of the buttons. It should be a positive integer,
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
237 or 0 to mean no shadows on the edges.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
238 FG-COLOR is the color used to display the text. It should be a string.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
239 BG-COLOR is the background color the text will be displayed upon.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
240 It should be a string."
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
241 (save-excursion
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
242 (set-buffer (get-buffer-create " xpm-button"))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
243 (erase-buffer)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
244 ;; create the correct number of lines for the pixels for the
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
245 ;; characters.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
246 (insert-char ?\n (length xpm-button-font-pixel-lines))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
247 (let ((i 0)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
248 (str (make-string 1 0))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
249 (lim (length text))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
250 (bg-char ? )
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
251 font-pixel-lines q)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
252 ;; loop through text, adding the character pixels
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
253 (while (< i lim)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
254 (aset str 0 (aref text i))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
255 (if (null (setq q (assoc str xpm-button-font-line-indices)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
256 nil ; no pixel data for this character
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
257 (goto-char (point-min))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
258 (setq font-pixel-lines xpm-button-font-pixel-lines)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
259 (while font-pixel-lines
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
260 (end-of-line)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
261 (if (not (bolp))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
262 ;; Insert space before some of the characters.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
263 ;; This isn't really correct for this font
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
264 ;; but doing it right is too hard.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
265 ;; This isn't TeX after all.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
266 (if (memq (aref str 0) '(?, ?. ?\" ?! ?| ?\' ?\`))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
267 (insert-char bg-char 1))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
268 ;; offset the start a bit from the left edge of the button
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
269 (insert-char bg-char xpm-button-horizontal-padding))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
270 ;; insert the character pixels.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
271 (insert (substring (car font-pixel-lines) (nth 1 q) (nth 2 q)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
272 (forward-line)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
273 (setq font-pixel-lines (cdr font-pixel-lines))))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
274 (setq i (1+ i)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
275 ;; now offset the text from the right edge of the button.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
276 (goto-char (point-min))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
277 (while (not (eobp))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
278 (end-of-line)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
279 (insert-char bg-char xpm-button-horizontal-padding)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
280 (forward-line)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
281 (let ((bright-char ?b)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
282 (dim-char ?d)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
283 (fg-char ?x)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
284 (bg-char ? )
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
285 (shadow-colors (xpm-button-compute-shadow-colors bg-color))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
286 i len up-string down-string disabled-string)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
287 ;; find the length of a pixel line.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
288 (goto-char (point-min))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
289 (end-of-line)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
290 (setq len (- (point) (point-min)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
291 ;; offset text from the top of the button
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
292 (goto-char (point-min))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
293 (setq i xpm-button-vertical-padding)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
294 (while (> i 0)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
295 (insert-char bg-char len)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
296 (insert ?\n)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
297 (setq i (1- i)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
298 ;; offset text from the bottom of the button
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
299 (goto-char (point-max))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
300 (setq i xpm-button-vertical-padding)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
301 (while (> i 0)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
302 (insert-char bg-char len)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
303 (insert ?\n)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
304 (setq i (1- i)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
305 ;; add shadows to the pixel lines
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
306 (goto-char (point-min))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
307 (while (not (eobp))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
308 (insert-char bright-char shadow-thickness)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
309 (end-of-line)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
310 (insert-char dim-char shadow-thickness)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
311 (forward-line))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
312 ;; add top and bottom shadow lines
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
313 (setq i shadow-thickness)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
314 (goto-char (point-min))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
315 (while (> i 0)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
316 (insert-char bright-char (+ len shadow-thickness i))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
317 (insert-char dim-char (- shadow-thickness i))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
318 (insert ?\n)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
319 (setq i (1- i)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
320 (setq i shadow-thickness)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
321 (goto-char (point-max))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
322 (while (> i 0)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
323 (insert-char bright-char i)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
324 (insert-char dim-char (+ len (* 2 shadow-thickness) (- i)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
325 (insert ?\n)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
326 (setq i (1- i)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
327 ;; add doublequotes, commas and XPM header goop.
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
328 (goto-char (point-min))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
329 (while (not (eobp))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
330 (insert "\"")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
331 (end-of-line)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
332 (insert "\",")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
333 (forward-line))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
334 (insert "};\n")
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
335 (goto-char (point-min))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
336 ;; color map for the UP button
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
337 (insert (format
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
338 "/* XPM */
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
339 static char * button_xpm[] = {
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
340 \"%d %d 4 1\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
341 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
342 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
343 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
344 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
345 "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
346 (+ len (* shadow-thickness 2))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
347 (+ (* xpm-button-vertical-padding 2)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
348 (* shadow-thickness 2)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
349 (length xpm-button-font-pixel-lines))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
350 fg-char fg-color
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
351 bg-char bg-color
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
352 bright-char (car shadow-colors)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
353 dim-char (cdr shadow-colors)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
354 (setq up-string (buffer-string))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
355 (delete-region (point-min) (point))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
356 ;; color map for the DOWN button
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
357 (insert (format
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
358 "/* XPM */
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
359 static char * button_xpm[] = {
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
360 \"%d %d 4 1\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
361 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
362 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
363 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
364 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
365 "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
366 (+ len (* shadow-thickness 2))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
367 (+ (* xpm-button-vertical-padding 2)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
368 (* shadow-thickness 2)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
369 (length xpm-button-font-pixel-lines))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
370 fg-char (xpm-button-compute-contrast-color fg-color)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
371 bg-char bg-color
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
372 bright-char (cdr shadow-colors)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
373 dim-char (car shadow-colors)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
374 (setq down-string (buffer-string))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
375 (delete-region (point-min) (point))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
376 ;; color map for the DISABLED button
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
377 (insert (format
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
378 "/* XPM */
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
379 static char * button_xpm[] = {
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
380 \"%d %d 4 1\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
381 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
382 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
383 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
384 \"%c c %s\",
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
385 "
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
386 (+ len (* shadow-thickness 2))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
387 (+ (* xpm-button-vertical-padding 2)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
388 (* shadow-thickness 2)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
389 (length xpm-button-font-pixel-lines))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
390 fg-char fg-color
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
391 bg-char bg-color
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
392 bright-char (car shadow-colors)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
393 dim-char (cdr shadow-colors)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
394 ;; stipple the foreground pixels
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
395 (let ((str (make-string 1 0))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
396 (bit 0)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
397 lim line-start)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
398 (aset str 0 fg-char)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
399 (while (not (eobp))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
400 (setq lim (save-excursion (end-of-line) (point))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
401 line-start (point))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
402 (while (search-forward str lim t)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
403 (if (= (% (- (point) line-start) 2) bit)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
404 (subst-char-in-region (1- (point)) (point) fg-char bg-char t)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
405 (if (zerop bit)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
406 (setq bit 1)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
407 (setq bit 0))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
408 (forward-line)))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
409 (setq disabled-string (buffer-string))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
410
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
411 (list (vector 'xpm ':data up-string)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
412 (vector 'xpm ':data down-string)
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
413 (vector 'xpm ':data disabled-string)) )))
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
414
182f72e8cd0d Import from CVS: tag r21-1-7
cvs
parents:
diff changeset
415 ;;; xpm-button.el ends here