1 ;; Common Lisp bindings for GTK+ v2.x
2 ;; Copyright 2001-2006 Espen S. Johnsen <espen@users.sf.net>
4 ;; Permission is hereby granted, free of charge, to any person obtaining
5 ;; a copy of this software and associated documentation files (the
6 ;; "Software"), to deal in the Software without restriction, including
7 ;; without limitation the rights to use, copy, modify, merge, publish,
8 ;; distribute, sublicense, and/or sell copies of the Software, and to
9 ;; permit persons to whom the Software is furnished to do so, subject to
10 ;; the following conditions:
12 ;; The above copyright notice and this permission notice shall be
13 ;; included in all copies or substantial portions of the Software.
15 ;; THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 ;; EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 ;; MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 ;; IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 ;; CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 ;; TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 ;; SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 ;; $Id: pango.lisp,v 1.14 2007-06-06 10:43:54 espen Exp $
27 (eval-when (:compile-toplevel :load-toplevel :execute)
28 (init-types-in-library pango "libpango-1.0" :prefix "pango_")
29 (init-types-in-library pango "libpangoxft-1.0" :prefix "pango_xft")
30 (init-types-in-library pango "libpangoft2-1.0" :prefix "pango_fc")
31 (init-types-in-library pango "libpangocairo-1.0" :prefix "pango_cairo"))
34 (eval-when (:compile-toplevel :load-toplevel :execute)
35 (define-types-by-introspection "Pango"))
37 (defclass font-description (boxed)
41 :getter "pango_font_description_get_family"
42 :setter "pango_font_description_set_family"
43 :boundp %font-description-family-boundp
44 :makunbound %font-description-family-makunbound
45 :accessor font-description-family
50 :getter "pango_font_description_get_style"
51 :setter "pango_font_description_set_style"
52 :boundp %font-description-style-boundp
53 :makunbound %font-description-style-makunbound
54 :accessor font-description-style
59 :getter "pango_font_description_get_variant"
60 :setter "pango_font_description_set_variant"
61 :boundp %font-description-variant-boundp
62 :makunbound %font-description-variant-makunbound
63 :accessor font-description-variant
68 :getter "pango_font_description_get_weight"
69 :setter "pango_font_description_set_weight"
70 :boundp %font-description-weight-boundp
71 :makunbound %font-description-weight-makunbound
72 :accessor font-description-weight
77 :getter "pango_font_description_get_stretch"
78 :setter "pango_font_description_set_stretch"
79 :boundp %font-description-stretch-boundp
80 :makunbound %font-description-stretch-makbound
81 :accessor font-description-stretch
86 :setter (setf font-description-size)
87 :getter "pango_font_description_get_size"
88 :boundp %font-description-size-boundp
89 :makunbound %font-description-size-makunbound
90 :reader font-description-size
92 #?(pkg-exists-p "pango" :atleast-version "1.8.0")
95 :getter "pango_font_description_get_size_is_absolute"
96 :boundp %font-description-size-boundp
97 :reader font-description-size-is-absolute-p
99 (:metaclass boxed-class))
101 (defclass layout (gobject)
104 :getter "pango_layout_get_context"
105 :reader layout-context
110 :getter "pango_layout_get_text"
111 :setter %layout-set-text
112 :accessor layout-text
117 :getter "pango_layout_get_attributes"
118 :setter "pango_layout_set_attributes"
119 :accessor layout-attributes
123 :initarg :font-description
124 :getter "pango_layout_get_font_description"
125 :setter "pango_layout_set_font_description"
126 :accessor layout-font-description
127 :type font-description)
131 :getter "pango_layout_get_width"
132 :setter "pango_layout_set_width"
133 :accessor layout-width
138 :getter "pango_layout_get_wrap"
139 :setter "pango_layout_set_wrap"
140 :accessor layout-wrap
145 :getter "pango_layout_get_ellipsize"
146 :setter "pango_layout_set_ellipsize"
147 :accessor layout-ellipsize
148 :type ellipsize-mode)
152 :getter "pango_layout_get_indent"
153 :setter "pango_layout_set_indetn"
154 :accessor layout-indent
159 :getter "pango_layout_get_spacing"
160 :setter "pango_layout_set_spacing"
161 :accessor layout-spacing
166 :getter "pango_layout_get_justify"
167 :setter "pango_layout_set_justify"
168 :accessor layout-justify-p
173 :getter "pango_layout_get_auto_dir"
174 :setter "pango_layout_set_auto_dir"
175 :accessor layout-auto-dir-p
180 :getter "pango_layout_get_alignment"
181 :setter "pango_layout_set_alignment"
182 :accessor layout-alignment
187 :getter "pango_layout_tab_array"
188 :setter "pango_layout_tab-array"
189 :accessor layout-tab-array
193 :initarg :single-paragraph
194 :getter "pango_layout_get_single_paragraph_mode"
195 :setter "pango_layout_set_single_paragraph_mode"
196 :accessor layout-single-paragraph-p
198 (:metaclass gobject-class))
200 (defclass cairo-font-map (interface)
203 :getter "pango_cairo_font_map_get_resolution"
204 :setter "pango_cairo_font_map_set_resolution"
205 :accessor cairo-font-map-resolution
207 (:metaclass interface-class))
210 ;;;; Font description
212 (defmethod initialize-instance ((desc font-description) &key absolute-size)
215 (setf (font-description-size desc t) absolute-size)))
217 (defbinding %font-description-new () pointer)
219 (defmethod allocate-foreign ((desc font-description) &rest initargs)
220 (declare (ignore initargs))
221 (%font-description-new))
223 (defbinding %font-description-get-set-fields () font-mask
224 (desc font-description))
226 (defun %font-description-family-boundp (desc)
227 (find :family (%font-description-get-set-fields desc)))
229 (defun %font-description-style-boundp (desc)
230 (find :style (%font-description-get-set-fields desc)))
232 (defun %font-description-variant-boundp (desc)
233 (find :variant (%font-description-get-set-fields desc)))
235 (defun %font-description-weight-boundp (desc)
236 (find :weight (%font-description-get-set-fields desc)))
238 (defun %font-description-stretch-boundp (desc)
239 (find :stretch (%font-description-get-set-fields desc)))
241 (defun %font-description-size-boundp (desc)
242 (find :size (%font-description-get-set-fields desc)))
244 (defbinding %font-description-unset-fields () nil
245 (desc font-description)
248 (defun %font-description-family-makunbound (desc)
249 (%font-description-unset-fields desc :family))
251 (defun %font-description-style-makunbound (desc)
252 (%font-description-unset-fields desc :style))
254 (defun %font-description-variant-makunbound (desc)
255 (%font-description-unset-fields desc :variant))
257 (defun %font-description-weight-makunbound (desc)
258 (%font-description-unset-fields desc :weight))
260 (defun %font-description-stretch-makunbound (desc)
261 (%font-description-unset-fields desc :stretch))
263 (defun %font-description-size-makunbound (desc)
264 (%font-description-unset-fields desc :size))
266 (defbinding %font-description-set-size () nil
267 (desc font-description)
270 #?(pkg-exists-p "pango" :atleast-version "1.8.0")
271 (defbinding %font-description-set-absolute-size () nil
272 (desc font-description)
275 (defun (setf font-description-size) (size desc &optional absolute-p)
277 #?(pkg-exists-p "pango" :atleast-version "1.8.0")
278 (%font-description-set-absolute-size desc size)
279 #?-(pkg-exists-p "pango" :atleast-version "1.8.0")
280 (error "Setting of absolute font size requires at least Pango 1.8.0")
281 (%font-description-set-size desc size)))
283 (defbinding font-description-merge (desc merge-desc &optional replace-p) nil
284 (desc font-description)
285 (merge-desc font-description)
288 (defbinding font-description-better-match () boolean
289 (desc font-description)
290 (old-math font-description)
291 (new-math font-description))
293 (defbinding font-description-from-string () font-description
296 (defbinding font-description-to-string () string
297 (desc font-description))
302 (defmethod initialize-instance ((layout layout) &key markup)
305 (layout-set-markup layout markup)))
307 (defmethod allocate-foreign ((layout layout) &key context)
309 (context (%layout-new context))
310 (cairo:context (%cairo-create-layout context))))
312 (defbinding %layout-new () pointer
315 (defbinding layout-copy () (referenced layout)
318 (defbinding layout-context-changed () nil
321 (defbinding %layout-set-text () nil
326 (defbinding layout-set-markup () nil
335 (defbinding (cairo-create-font-map "pango_cairo_font_map_new")
336 () (referenced font-map))
338 (defbinding cairo-font-map-get-default () font-map)
340 (defbinding cairo-font-map-create-context () (referenced context)
341 (font-map cairo-font-map))
343 (defbinding (cairo-context-resolution "pango_cairo_context_get_resolution")
347 (defbinding %cairo-context-set-resolution () nil
351 (defun (setf cairo-context-resolution) (dpi context)
352 (%cairo-context-set-resolution context dpi))
354 (defbinding (cairo-context-font-options "pango_cairo_context_get_font_options")
355 () cairo:font-options
358 (defbinding %cairo-context-set-font-options () nil
360 (font-options cairo:font-options))
362 (defun (setf cairo-context-font-options) (font-options context)
363 (%cairo-context-set-font-options context font-options))
365 (defbinding %cairo-create-layout () pointer
368 (defbinding cairo-update-layout () nil
372 (defbinding cairo-show-glyph-string () nil
375 (glyphs glyph-string))
377 (defbinding cairo-show-layout-line () nil
381 (defbinding cairo-show-layout () nil
385 (defbinding cairo-show-error-underline () nil
390 (height double-float))
392 (defbinding cairo-glyph-string-path () nil
395 (glyphs glyph-string))
397 (defbinding cairo-layout-line-path () nil
401 (defbinding cairo-layout-path () nil
405 (defbinding cairo-error-underline-path () nil
410 (height double-float))