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.13 2007/04/06 14:51:26 espen Exp $
27 (eval-when (:compile-toplevel :load-toplevel :execute)
28 (init-types-in-library #.(concatenate 'string
29 (pkg-variable "pango" "libdir")
30 "/libpango-1.0." asdf:*dso-extension*)
32 (init-types-in-library #.(concatenate 'string
33 (pkg-variable "pango" "libdir")
34 "/libpangoxft-1.0." asdf:*dso-extension*)
36 (init-types-in-library #.(concatenate 'string
37 (pkg-variable "pango" "libdir")
38 "/libpangoft2-1.0." asdf:*dso-extension*)
40 (init-types-in-library #.(concatenate 'string
41 (pkg-variable "pango" "libdir")
42 "/libpangocairo-1.0." asdf:*dso-extension*)
43 :prefix "pango_cairo"))
46 (eval-when (:compile-toplevel :load-toplevel :execute)
47 (define-types-by-introspection "Pango"))
49 (defclass font-description (boxed)
53 :getter "pango_font_description_get_family"
54 :setter "pango_font_description_set_family"
55 :boundp %font-description-family-boundp
56 :makunbound %font-description-family-makunbound
57 :accessor font-description-family
62 :getter "pango_font_description_get_style"
63 :setter "pango_font_description_set_style"
64 :boundp %font-description-style-boundp
65 :makunbound %font-description-style-makunbound
66 :accessor font-description-style
71 :getter "pango_font_description_get_variant"
72 :setter "pango_font_description_set_variant"
73 :boundp %font-description-variant-boundp
74 :makunbound %font-description-variant-makunbound
75 :accessor font-description-variant
80 :getter "pango_font_description_get_weight"
81 :setter "pango_font_description_set_weight"
82 :boundp %font-description-weight-boundp
83 :makunbound %font-description-weight-makunbound
84 :accessor font-description-weight
89 :getter "pango_font_description_get_stretch"
90 :setter "pango_font_description_set_stretch"
91 :boundp %font-description-stretch-boundp
92 :makunbound %font-description-stretch-makbound
93 :accessor font-description-stretch
98 :setter (setf font-description-size)
99 :getter "pango_font_description_get_size"
100 :boundp %font-description-size-boundp
101 :makunbound %font-description-size-makunbound
102 :reader font-description-size
104 #?(pkg-exists-p "pango" :atleast-version "1.8.0")
107 :getter "pango_font_description_get_size_is_absolute"
108 :boundp %font-description-size-boundp
109 :reader font-description-size-is-absolute-p
111 (:metaclass boxed-class))
113 (defclass layout (gobject)
116 :getter "pango_layout_get_context"
117 :reader layout-context
122 :getter "pango_layout_get_text"
123 :setter %layout-set-text
124 :accessor layout-text
129 :getter "pango_layout_get_attributes"
130 :setter "pango_layout_set_attributes"
131 :accessor layout-attributes
135 :initarg :font-description
136 :getter "pango_layout_get_font_description"
137 :setter "pango_layout_set_font_description"
138 :accessor layout-font-description
139 :type font-description)
143 :getter "pango_layout_get_width"
144 :setter "pango_layout_set_width"
145 :accessor layout-width
150 :getter "pango_layout_get_wrap"
151 :setter "pango_layout_set_wrap"
152 :accessor layout-wrap
157 :getter "pango_layout_get_ellipsize"
158 :setter "pango_layout_set_ellipsize"
159 :accessor layout-ellipsize
160 :type ellipsize-mode)
164 :getter "pango_layout_get_indent"
165 :setter "pango_layout_set_indetn"
166 :accessor layout-indent
171 :getter "pango_layout_get_spacing"
172 :setter "pango_layout_set_spacing"
173 :accessor layout-spacing
178 :getter "pango_layout_get_justify"
179 :setter "pango_layout_set_justify"
180 :accessor layout-justify-p
185 :getter "pango_layout_get_auto_dir"
186 :setter "pango_layout_set_auto_dir"
187 :accessor layout-auto-dir-p
192 :getter "pango_layout_get_alignment"
193 :setter "pango_layout_set_alignment"
194 :accessor layout-alignment
199 :getter "pango_layout_tab_array"
200 :setter "pango_layout_tab-array"
201 :accessor layout-tab-array
205 :initarg :single-paragraph
206 :getter "pango_layout_get_single_paragraph_mode"
207 :setter "pango_layout_set_single_paragraph_mode"
208 :accessor layout-single-paragraph-p
210 (:metaclass gobject-class))
212 (defclass cairo-font-map (interface)
215 :getter "pango_cairo_font_map_get_resolution"
216 :setter "pango_cairo_font_map_set_resolution"
217 :accessor cairo-font-map-resolution
219 (:metaclass interface-class))
222 ;;;; Font description
224 (defmethod initialize-instance ((desc font-description) &key absolute-size)
227 (setf (font-description-size desc t) absolute-size)))
229 (defbinding %font-description-new () pointer)
231 (defmethod allocate-foreign ((desc font-description) &rest initargs)
232 (declare (ignore initargs))
233 (%font-description-new))
235 (defbinding %font-description-get-set-fields () font-mask
236 (desc font-description))
238 (defun %font-description-family-boundp (desc)
239 (find :family (%font-description-get-set-fields desc)))
241 (defun %font-description-style-boundp (desc)
242 (find :style (%font-description-get-set-fields desc)))
244 (defun %font-description-variant-boundp (desc)
245 (find :variant (%font-description-get-set-fields desc)))
247 (defun %font-description-weight-boundp (desc)
248 (find :weight (%font-description-get-set-fields desc)))
250 (defun %font-description-stretch-boundp (desc)
251 (find :stretch (%font-description-get-set-fields desc)))
253 (defun %font-description-size-boundp (desc)
254 (find :size (%font-description-get-set-fields desc)))
256 (defbinding %font-description-unset-fields () nil
257 (desc font-description)
260 (defun %font-description-family-makunbound (desc)
261 (%font-description-unset-fields desc :family))
263 (defun %font-description-style-makunbound (desc)
264 (%font-description-unset-fields desc :style))
266 (defun %font-description-variant-makunbound (desc)
267 (%font-description-unset-fields desc :variant))
269 (defun %font-description-weight-makunbound (desc)
270 (%font-description-unset-fields desc :weight))
272 (defun %font-description-stretch-makunbound (desc)
273 (%font-description-unset-fields desc :stretch))
275 (defun %font-description-size-makunbound (desc)
276 (%font-description-unset-fields desc :size))
278 (defbinding %font-description-set-size () nil
279 (desc font-description)
282 #?(pkg-exists-p "pango" :atleast-version "1.8.0")
283 (defbinding %font-description-set-absolute-size () nil
284 (desc font-description)
287 (defun (setf font-description-size) (size desc &optional absolute-p)
289 #?(pkg-exists-p "pango" :atleast-version "1.8.0")
290 (%font-description-set-absolute-size desc size)
291 #?-(pkg-exists-p "pango" :atleast-version "1.8.0")
292 (error "Setting of absolute font size requires at least Pango 1.8.0")
293 (%font-description-set-size desc size)))
295 (defbinding font-description-merge (desc merge-desc &optional replace-p) nil
296 (desc font-description)
297 (merge-desc font-description)
300 (defbinding font-description-better-match () boolean
301 (desc font-description)
302 (old-math font-description)
303 (new-math font-description))
305 (defbinding font-description-from-string () font-description
308 (defbinding font-description-to-string () string
309 (desc font-description))
314 (defmethod initialize-instance ((layout layout) &key markup)
317 (layout-set-markup layout markup)))
319 (defmethod allocate-foreign ((layout layout) &key context)
321 (context (%layout-new context))
322 (cairo:context (%cairo-create-layout context))))
324 (defbinding %layout-new () pointer
327 (defbinding layout-copy () (referenced layout)
330 (defbinding layout-context-changed () nil
333 (defbinding %layout-set-text () nil
338 (defbinding layout-set-markup () nil
347 (defbinding (cairo-create-font-map "pango_cairo_font_map_new")
348 () (referenced font-map))
350 (defbinding cairo-font-map-get-default () font-map)
352 (defbinding cairo-font-map-create-context () (referenced context)
353 (font-map cairo-font-map))
355 (defbinding (cairo-context-resolution "pango_cairo_context_get_resolution")
359 (defbinding %cairo-context-set-resolution () nil
363 (defun (setf cairo-context-resolution) (dpi context)
364 (%cairo-context-set-resolution context dpi))
366 (defbinding (cairo-context-font-options "pango_cairo_context_get_font_options")
367 () cairo:font-options
370 (defbinding %cairo-context-set-font-options () nil
372 (font-options cairo:font-options))
374 (defun (setf cairo-context-font-options) (font-options context)
375 (%cairo-context-set-font-options context font-options))
377 (defbinding %cairo-create-layout () pointer
380 (defbinding cairo-update-layout () nil
384 (defbinding cairo-show-glyph-string () nil
387 (glyphs glyph-string))
389 (defbinding cairo-show-layout-line () nil
393 (defbinding cairo-show-layout () nil
397 (defbinding cairo-show-error-underline () nil
402 (height double-float))
404 (defbinding cairo-glyph-string-path () nil
407 (glyphs glyph-string))
409 (defbinding cairo-layout-line-path () nil
413 (defbinding cairo-layout-path () nil
417 (defbinding cairo-error-underline-path () nil
422 (height double-float))