Add Gdk/Pixbufs
[cl-gtk2.git] / gdk / gdk.drawing-primitives.lisp
blob03e7324a333014a0ab4366cd0985c83a8de66ffb
1 (in-package :gdk)
3 (defcfun gdk-drawable-get-size :void
4 (drawable (g-object drawable))
5 (width (:pointer :int))
6 (height (:pointer :int)))
8 (defun drawable-get-size (drawable)
9 (with-foreign-objects ((x :int)
10 (y :int))
11 (gdk-drawable-get-size drawable x y)
12 (values (mem-ref x :int) (mem-ref y :int))))
14 (export 'drawable-get-size)
16 (defcfun (draw-point "gdk_draw_point") :void
17 (drawable (g-object drawable))
18 (gc (g-object graphics-context))
19 (x :int)
20 (y :int))
22 (export 'draw-point)
24 (defcfun gdk-draw-points :void
25 (drawable (g-object drawable))
26 (gc (g-object graphics-context))
27 (points :pointer)
28 (n :int))
30 (defun draw-points (drawable gc points)
31 (let ((n (length points)))
32 (with-foreign-object (points-ptr 'point-cstruct n)
33 (let ((i 0))
34 (map nil
35 (lambda (pt)
36 (gobject::copy-slots-to-native
38 (inc-pointer points-ptr (* i (foreign-type-size 'point-cstruct)))
39 (gobject::g-boxed-cstruct-wrapper-info-cstruct-description (gobject::get-g-boxed-foreign-info 'point)))
40 (incf i))
41 points))
42 (gdk-draw-points drawable gc points-ptr n))))
44 (export 'draw-points)
46 (defcfun (draw-line "gdk_draw_line") :void
47 (drawable (g-object drawable))
48 (gc (g-object graphics-context))
49 (x1 :int)
50 (y1 :int)
51 (x2 :int)
52 (y2 :int))
54 (export 'draw-line)
56 (defcfun gdk-draw-lines :void
57 (drawable (g-object drawable))
58 (gc (g-object graphics-context))
59 (points :pointer)
60 (n :int))
62 (defun draw-lines (drawable gc points)
63 (let ((n (length points)))
64 (with-foreign-object (points-ptr 'point-cstruct n)
65 (let ((i 0))
66 (map nil
67 (lambda (pt)
68 (gobject::copy-slots-to-native
70 (inc-pointer points-ptr (* i (foreign-type-size 'point-cstruct)))
71 (gobject::g-boxed-cstruct-wrapper-info-cstruct-description (gobject::get-g-boxed-foreign-info 'point)))
72 (incf i))
73 points))
74 (gdk-draw-lines drawable gc points-ptr n))))
76 (export 'draw-lines)
78 (defcfun (draw-pixbuf "gdk_draw_pixbuf") :void
79 (drawable (g-object drawable))
80 (gc (g-object graphics-context))
81 (pixbuf (g-object pixbuf))
82 (src-x :int)
83 (src-y :int)
84 (dest-x :int)
85 (dest-y :int)
86 (width :int)
87 (height :int)
88 (dither rgb-dither)
89 (x-dither :int)
90 (y-dither :int))
92 (export 'draw-pixbuf)
94 (defcfun gdk-draw-segments :void
95 (drawable (g-object drawable))
96 (gc (g-object graphics-context))
97 (segments :pointer)
98 (n-segments :int))
100 (defun draw-segments (drawable gc segments)
101 (let ((n (length segments)))
102 (with-foreign-object (segments-ptr 'segment-cstruct n)
103 (let ((i 0))
104 (map nil
105 (lambda (segment)
106 (gobject::copy-slots-to-native
107 segment
108 (inc-pointer segments-ptr (* i (foreign-type-size 'segment-cstruct)))
109 (gobject::g-boxed-cstruct-wrapper-info-cstruct-description (gobject::get-g-boxed-foreign-info 'segment)))
110 (incf i))
111 segments))
112 (gdk-draw-segments drawable gc segments-ptr n))))
114 (export 'draw-segments)
116 (defcfun (draw-rectangle "gdk_draw_rectangle") :void
117 (drawable (g-object drawable))
118 (gc (g-object graphics-context))
119 (filled :boolean)
120 (x :int)
121 (y :int)
122 (width :int)
123 (height :int))
125 (defcfun (draw-arc "gdk_draw_arc") :void
126 (drawable (g-object drawable))
127 (gc (g-object graphics-context))
128 (filled :boolean)
129 (x :int)
130 (y :int)
131 (width :int)
132 (height :int)
133 (angle1 :int)
134 (angle2 :int))
136 (export 'draw-arc)
138 (defcfun gdk-draw-polygon :void
139 (drawable (g-object drawable))
140 (gc (g-object graphics-context))
141 (filled :boolean)
142 (points :pointer)
143 (n-points :int))
145 (defun draw-polygon (drawable gc filled points)
146 (let ((n (length points)))
147 (with-foreign-object (points-ptr 'point-cstruct n)
148 (let ((i 0))
149 (map nil
150 (lambda (point)
151 (gobject::copy-slots-to-native
152 point
153 (inc-pointer points-ptr (* i (foreign-type-size 'point-cstruct)))
154 (gobject::g-boxed-cstruct-wrapper-info-cstruct-description (gobject::get-g-boxed-foreign-info 'point)))
155 (incf i))
156 points))
157 (gdk-draw-polygon drawable gc filled points-ptr n))))
159 (export 'draw-polygon)
161 (defcfun gdk-draw-trapezoids :void
162 (drawable (g-object drawable))
163 (gc (g-object graphics-context))
164 (trapezoids :pointer)
165 (n :int))
167 (defun draw-trapezoids (drawable gc trapezoids)
168 (let ((n (length trapezoids)))
169 (with-foreign-object (trapezoids-ptr 'trapezoid-cstruct n)
170 (let ((i 0))
171 (map nil
172 (lambda (trapezoid)
173 (gobject::copy-slots-to-native
174 trapezoid
175 (inc-pointer trapezoids-ptr (* i (foreign-type-size 'trapezoid-cstruct)))
176 (gobject::g-boxed-cstruct-wrapper-info-cstruct-description (gobject::get-g-boxed-foreign-info 'trapezoid)))
177 (incf i))
178 trapezoids))
179 (gdk-draw-trapezoids drawable gc trapezoids-ptr n))))
181 (export 'draw-trapezoids)
183 ;; TODO
184 ;; void gdk_draw_glyphs (GdkDrawable *drawable,
185 ;; GdkGC *gc,
186 ;; PangoFont *font,
187 ;; gint x,
188 ;; gint y,
189 ;; PangoGlyphString *glyphs);
190 ;; void gdk_draw_glyphs_transformed (GdkDrawable *drawable,
191 ;; GdkGC *gc,
192 ;; const PangoMatrix *matrix,
193 ;; PangoFont *font,
194 ;; gint x,
195 ;; gint y,
196 ;; PangoGlyphString *glyphs);
197 ;; void gdk_draw_layout_line (GdkDrawable *drawable,
198 ;; GdkGC *gc,
199 ;; gint x,
200 ;; gint y,
201 ;; PangoLayoutLine *line);
202 ;; void gdk_draw_layout_line_with_colors (GdkDrawable *drawable,
203 ;; GdkGC *gc,
204 ;; gint x,
205 ;; gint y,
206 ;; PangoLayoutLine *line,
207 ;; const GdkColor *foreground,
208 ;; const GdkColor *background);
210 (defcfun (draw-layout "gdk_draw_layout") :void
211 (drawable (g-object drawable))
212 (gc (g-object graphics-context))
213 (x :int)
214 (y :int)
215 (layout (g-object pango-layout)))
217 (export 'draw-layout)
219 (defcfun (draw-layout-with-colors "gdk_draw_layout_with_colors") :void
220 (drawable (g-object drawable))
221 (gc (g-object graphics-context))
222 (x :int)
223 (y :int)
224 (layout (g-object pango-layout))
225 (foreground (g-boxed-foreign color))
226 (background (g-boxed-foreign color)))
228 (export 'draw-layout-with-colors)
230 ;; ignored:
231 ;; void gdk_draw_string (GdkDrawable *drawable,
232 ;; GdkFont *font,
233 ;; GdkGC *gc,
234 ;; gint x,
235 ;; gint y,
236 ;; const gchar *string);
237 ;; void gdk_draw_text (GdkDrawable *drawable,
238 ;; GdkFont *font,
239 ;; GdkGC *gc,
240 ;; gint x,
241 ;; gint y,
242 ;; const gchar *text,
243 ;; gint text_length);
244 ;; void gdk_draw_text_wc (GdkDrawable *drawable,
245 ;; GdkFont *font,
246 ;; GdkGC *gc,
247 ;; gint x,
248 ;; gint y,
249 ;; const GdkWChar *text,
250 ;; gint text_length);
253 (defcfun (draw-drawable "gdk_draw_drawable") :void
254 (drawable (g-object drawable))
255 (gc (g-object graphics-context))
256 (src (g-object drawable))
257 (x-src :int)
258 (y-src :int)
259 (x-dest :int)
260 (y-dest :int)
261 (width :int)
262 (height :int))
264 (export 'draw-drawable)
266 (defcfun (draw-image "gdk_draw_image") :void
267 (drawable (g-object drawable))
268 (gc (g-object graphics-context))
269 (image (g-object gdk-image))
270 (x-src :int)
271 (y-src :int)
272 (x-dest :int)
273 (y-dest :int)
274 (width :int)
275 (height :int))
277 (export 'draw-image)
279 (defcfun (drawable-get-image "gdk_drawable_get_image") (g-object gdk-image)
280 (drawable (g-object drawable))
281 (x :int)
282 (y :int)
283 (width :int)
284 (height :int))
286 (export 'drawable-get-image)
288 (defcfun (drawable-copy-to-image "gdk_drawable_copy_to_image") (g-object gdk-image)
289 (drawable (g-object drawable))
290 (image (g-object gdk-image))
291 (src-x :int)
292 (src-y :int)
293 (dest-x :int)
294 (dest-y :int)
295 (width :int)
296 (height :int))
298 (export 'drawable-copy-to-image)