annotate lisp/utils/xpm-button.el @ 163:0132846995bd r20-3b8

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