Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
;;; xwem-faces.el --- XWEM can handle Emacs faces.
;; Copyright (C) 2003 by Free Software Foundation, Inc.
;; Author: Zajcev Evgeny <zevlg@yandex.ru>
;; Created: Mon Dec 29 12:04:19 MSK 2003
;; Keywords: xwem
;; X-CVS: $Id$
;; This file is part of XWEM.
;; XWEM is free software; you can redistribute it and/or modify it
;; under the terms of the GNU General Public License as published by
;; the Free Software Foundation; either version 2, or (at your option)
;; any later version.
;; XWEM is distributed in the hope that it will be useful, but WITHOUT
;; ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
;; or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
;; License for more details.
;; You should have received a copy of the GNU General Public License
;; along with XEmacs; see the file COPYING. If not, write to the Free
;; Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
;; 02111-1307, USA.
;;; Synched up with: Not in FSF
;;; Commentary:
;; Faces support.
;;; Code:
(require 'cus-face) ; for `custom-face-get-spec'
(defgroup xwem-faces nil
"*Group to customize faces used by XWEM."
:prefix "xwem-face-"
:group 'xwem)
(defface xwem-face-white
`((t (:foreground "white" :background "black")))
"White color face."
:group 'xwem-faces)
(defface xwem-face-black
`((t (:foreground "black" :background "black")))
"Black color face."
:group 'xwem-faces)
(defface xwem-face-red
`((t (:foreground "red" :background "black")))
"Red color face."
:group 'xwem-faces)
(defface xwem-face-green
`((t (:foreground "green" :background "black")))
"Green color face."
:group 'xwem-faces)
(defface xwem-face-blue
`((t (:foreground "blue" :background "black")))
"Blue color face."
:group 'xwem-faces)
(defface xwem-face-yellow
`((t (:foreground "yellow" :background "black")))
"Yellow color face."
:group 'xwem-faces)
(defface xwem-face-cyan
`((t (:foreground "cyan" :background "black")))
"Cyan color face."
:group 'xwem-faces)
(defface xwem-face-magenta
`((t (:foreground "magenta" :background "black")))
"Magenta color face."
:group 'xwem-faces)
(defface xwem-face-darkgray
`((t (:foreground "gray20" :background "black")))
"DarkGray color face."
:group 'xwem-faces)
(defface xwem-face-lightgray
`((t (:foreground "gray80" :background "black")))
"LightGray color face."
:group 'xwem-faces)
(defface xwem-face-gray
`((t (:foreground "gray50" :background "black")))
"Gray color face."
:group 'xwem-faces)
(defface xwem-face-outline1
`((t (:foreground "red" :background "black")))
"Face used to outline something."
:group 'xwem-faces)
(defface xwem-face-outline2
`((t (:foreground "blue" :background "black")))
"Face used to outline something."
:group 'xwem-faces)
(defface xwem-face-outline3
`((t (:foreground "cyan" :background "black")))
"Face used to outline something."
:group 'xwem-faces)
;;; Functions
(defun xwem-eface-to-gc (xdpy face &optional d)
"On display XDPY convert Emacs FACE to X graphical context.
Drawable D.
TOOD: - maybe add support for domains?."
(let* ((cmap (XDefaultColormap xdpy))
(fgcol (xwem-misc-colorspec->rgb-vector-safe (face-foreground-name face) [0 0 0]))
(bgcol (xwem-misc-colorspec->rgb-vector-safe (face-background-name face) [0 0 0]))
(gc (XCreateGC
xdpy (or (and (X-Drawable-p d) d)
(XDefaultRootWindow xdpy))
(make-X-Gc :dpy xdpy :id (X-Dpy-get-id xdpy)
:line-style (xwem-face-tag face :line-style)
:line-width (xwem-face-tag face :line-width)
:cap-style (xwem-face-tag face :cap-style)
:join-style (xwem-face-tag face :join-style)
:function (xwem-face-tag face :function)
:subwindow-mode (xwem-face-tag face :subwindow-mode)
:graphics-exposures (xwem-face-tag face :graphics-exposures)
:foreground (XAllocColor xdpy cmap
(make-X-Color :id (X-Dpy-get-id xdpy)
:cmap cmap
:red (aref fgcol 0)
:green (aref fgcol 1)
:blue (aref fgcol 2)))
:background (XAllocColor xdpy cmap
(make-X-Color :id (X-Dpy-get-id xdpy)
:cmap cmap
:red (aref bgcol 0)
:green (aref bgcol 1)
:blue (aref bgcol 2)))
:font (X-Font-get xdpy (face-font-name face))))))
(put face 'xwem-face-gc gc)
gc))
;;;###autoload
(defun xwem-init-faces ()
"Initialize faces."
(xwem-message 'info "Initializing faces ...")
;; NOTE:
;; - Faces initialization now dynamic.
)
;;;###autoload
(defun xwem-face-tag (face tag)
"Get FACE's TAG value.
For example \\(xwem-face-tag 'xwem-face-win-selected :line-width\\)."
(let ((spec (custom-face-get-spec face)))
(while (and spec
(not (eq (car (car spec)) t)))
(setq spec (cdr spec)))
(when (car spec)
(plist-get (cadr (car spec)) tag))))
;;;###autoload
(defun xwem-face-get-gc (name &optional xdpy d)
"Return X-Gc with NAME.
Name can be symbol or string."
(let ((gc (get name 'xwem-face-gc)))
(unless (X-Gc-p gc)
(xwem-eface-to-gc (or xdpy (xwem-dpy)) name d)
(setq gc (get name 'xwem-face-gc)))
gc))
;;;###autoload
(defun xwem-face-set-foreground (face fg)
"Set FACE's foreground color to FG."
(set-face-foreground face fg)
(let ((xdpy (xwem-dpy))
(gc (xwem-face-get-gc face))
(fgcol (xwem-misc-colorspec->rgb-vector-safe (face-foreground-name face) [0 0 0])))
(setf (X-Gc-foreground (XAllocColor xdpy (XDefaultColormap xdpy)
(make-X-Color :id (X-Dpy-get-id xdpy)
:cmap (XDefaultColormap xdpy)
:red (aref fgcol 0)
:green (aref fgcol 1)
:blue (aref fgcol 2)))))
(XChangeGC xdpy gc)))
(provide 'xwem-faces)
;;; xwem-faces.el ends here