/[gtk-cffi]/gtk-cffi/gdk/color.lisp
ViewVC logotype

Contents of /gtk-cffi/gdk/color.lisp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.10 - (show annotations)
Mon Dec 31 13:33:38 2012 UTC (15 months, 2 weeks ago) by rklochkov
Branch: MAIN
CVS Tags: HEAD
Changes since 1.9: +6 -6 lines
Backed to CFFI 10.7 (was version from git)
1 (in-package :gdk-cffi)
2
3 (defcstruct color-struct
4 "GdkColor"
5 (pixel :int32)
6 (red :int16)
7 (green :int16)
8 (blue :int16))
9
10 (defcfun gdk-color-parse :boolean (str :string)
11 (color :pointer))
12 (defcfun gdk-color-to-string :string (color :pointer))
13 (defcfun gdk-color-free :void (color :pointer))
14
15 (define-foreign-type color-cffi (freeable)
16 ()
17 (:actual-type :pointer)
18 (:simple-parser pcolor))
19
20 (defmethod free-ptr ((class (eql 'color-cffi)) ptr)
21 (gdk-color-free ptr))
22
23 (defmethod translate-to-foreign (value (type color-cffi))
24 (if (pointerp value) value
25 (let ((color-st (foreign-alloc (cffi-objects::struct-type 'color-struct))))
26 (gdk-color-parse (string value) color-st)
27 color-st)))
28
29 (defmethod translate-from-foreign (ptr (type color-cffi))
30 (gdk-color-to-string ptr))
31
32 (defcfun (color-equal "gdk_color_equal") :boolean
33 (color pcolor) (color2 pcolor))
34
35 (defcstruct rgba-struct
36 "GdkRGBA"
37 (red :double)
38 (green :double)
39 (blue :double)
40 (alpha :double))
41
42 (define-foreign-type rgba-cffi (freeable)
43 ()
44 (:actual-type :pointer)
45 (:simple-parser prgba))
46
47 (defcfun gdk-rgba-parse :boolean (color :pointer)
48 (str :string))
49 (defcfun gdk-rgba-to-string :string (color :pointer))
50 (defcfun gdk-rgba-free :void (color :pointer))
51
52 (defmethod free-ptr ((class (eql 'rgba-cffi)) ptr)
53 (gdk-rgba-free ptr))
54
55 (defmethod translate-to-foreign (value (type rgba-cffi))
56 (if (pointerp value) value
57 (let ((color-st (foreign-alloc :pointer)))
58 (assert (gdk-rgba-parse color-st (string value)) (value)
59 "Bad RGBA color")
60 color-st)))
61
62 (defmethod translate-from-foreign (ptr (type rgba-cffi))
63 (gdk-rgba-to-string ptr))

  ViewVC Help
Powered by ViewVC 1.1.5