1 ;; Common Lisp bindings for GTK+ v2.0
2 ;; Copyright (C) 1999-2004 Espen S. Johnsen <espen@users.sf.net>
4 ;; This library is free software; you can redistribute it and/or
5 ;; modify it under the terms of the GNU Lesser General Public
6 ;; License as published by the Free Software Foundation; either
7 ;; version 2 of the License, or (at your option) any later version.
9 ;; This library is distributed in the hope that it will be useful,
10 ;; but WITHOUT ANY WARRANTY; without even the implied warranty of
11 ;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 ;; Lesser General Public License for more details.
14 ;; You should have received a copy of the GNU Lesser General Public
15 ;; License along with this library; if not, write to the Free Software
16 ;; Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18 ;; $Id: gtkstyle.lisp,v 1.2 2005/04/17 21:43:16 espen Exp $
25 (eval-when (:compile-toplevel :load-toplevel :execute)
26 (defbinding %style-font-desc-offset () int))
28 (defclass style (gobject)
32 :setter (setf style-fg)
37 :setter (setf style-bg)
42 :setter (setf style-light)
47 :setter (setf style-dark)
52 :setter (setf style-mid)
57 :setter (setf style-text)
62 :setter (setf style-base)
67 :setter (setf style-text-aa)
72 :setter (setf style-black)
77 :setter (setf style-white)
81 :offset #.(%style-font-desc-offset)
83 :accessor style-font-desc
85 :type pango:font-description)
88 :accessor style-xthickness
93 :accessor style-ythickness
105 :getter style-light-gc)
108 :getter style-dark-gc)
111 :getter style-mid-gc)
114 :getter style-text-gc)
117 :getter style-base-gc)
120 :getter style-text-aa-gc)
123 :getter style-black-gc)
126 :getter style-white-gc))
127 (:metaclass gobject-class))
130 (defbinding style-copy () style
133 (defbinding style-attach () style
137 (defbinding style-detach () style
141 (deftype color-type ()
142 '(enum :fg :bg :light :dark :mid :text :base :text-aa :white :black))
144 (defbinding %style-get-color () (copy-of gdk:color)
146 (color-type color-type)
149 (defbinding %style-set-color () nil
151 (color-type color-type)
155 (defbinding %style-get-gc () gdk:gc
157 (color-type color-type)
160 (defun %style-get-color-vector (style color-type)
162 with states = (enum-mapping 'state-type)
163 with vector = (make-array (length states))
164 for (symbol index) in states
165 do (setf (svref vector index) (%style-get-color style color-type symbol))
166 finally (return vector)))
168 (defun %style-set-color-vector (style color-type vector)
170 for (symbol index) in (enum-mapping 'state-type)
171 do (%style-set-color style color-type symbol (svref vector index))))
173 (defun %style-get-gc-vector (style color-type)
175 with states = (enum-mapping 'state-type)
176 with vector = (make-array (length states))
177 for (symbol index) in states
178 do (setf (svref vector index) (%style-get-gc style color-type symbol))
179 finally (return vector)))
181 (defmacro define-style-color-accessor (name type)
183 (defun ,name (style &optional state)
185 (%style-get-color style ,type state)
186 (%style-get-color-vector style ,type)))
187 (defun (setf ,name) (color style &optional state)
189 (%style-set-color style ,type state color)
190 (%style-set-color-vector style ,type color)))))
192 (define-style-color-accessor style-fg :fg)
193 (define-style-color-accessor style-bg :bg)
194 (define-style-color-accessor style-light :light)
195 (define-style-color-accessor style-dark :dark)
196 (define-style-color-accessor style-mid :mid)
197 (define-style-color-accessor style-text :text)
198 (define-style-color-accessor style-base :base)
199 (define-style-color-accessor style-text-aa :text-aa)
201 (defun style-black (style)
202 (%style-get-color style :black :normal))
204 (defun style-white (style)
205 (%style-get-color style :black :normal))
207 (defmacro define-style-gc-reader (name type)
208 `(defun ,name (style &optional state)
210 (%style-get-gc style ,type state)
211 (%style-get-gc-vector style ,type))))
213 (define-style-gc-reader style-fg-gc :fg)
214 (define-style-gc-reader style-bg-gc :bg)
215 (define-style-gc-reader style-light-gc :light)
216 (define-style-gc-reader style-dark-gc :dark)
217 (define-style-gc-reader style-mid-gc :mid)
218 (define-style-gc-reader style-text-gc :text)
219 (define-style-gc-reader style-base-gc :base)
220 (define-style-gc-reader style-text-aa-gc :text-aa)
222 (defun style-black-gc (style)
223 (%style-get-gc style :black :normal))
225 (defun style-white-gc (style)
226 (%style-get-gc style :white :normal))
229 '(style-fg style-bg style-light style-dark style-mid style-text style-base
230 style-text-aa style-fg-gc style-bg-gc style-light-gc style-dark-gc
231 style-mid-gc style-text-gc style-base-gc style-text-aa-gc))