write static delegate instead of callback use static delegate instead of
[vala-lang.git] / vapi / cairo.vala
blob5e22a4d3b92302070d1a5bb7ceb21b631c191e29
1 /* cairo.vala
3 * Copyright (C) 2006-2007 Jürg Billeter
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 * Author:
20 * Jürg Billeter <j@bitron.ch>
23 [CCode (cheader_filename = "cairo.h")]
24 namespace Cairo {
25 [ReferenceType (dup_function = "cairo_reference", free_function = "cairo_destroy")]
26 [CCode (cname = "cairo_t", cprefix = "cairo_", cheader_filename = "cairo.h")]
27 public struct Context {
28 [CCode (cname = "cairo_create")]
29 public Context (Surface target);
30 public Status status ();
31 public void save ();
32 public void restore ();
34 public weak Surface get_target ();
35 public void push_group ();
36 public void push_group_with_content (Content content);
37 public ref Pattern pop_group ();
38 public void pop_group_to_source ();
39 public weak Surface get_group_target ();
41 public void set_source_rgb (double red, double green, double blue);
42 public void set_source_rgba (double red, double green, double blue, double alpha);
43 public void set_source (Pattern source);
44 public void set_source_surface (Surface surface, double x, double y);
45 public weak Pattern get_source ();
47 public void set_antialias (Antialias antialias);
48 public Antialias get_antialias ();
50 [NoArrayLength ()]
51 public void set_dash (double[] dashes, int num_dashes, double offset);
53 public void set_fill_rule (FillRule fill_rule);
54 public FillRule get_fill_rule ();
56 public void set_line_cap (LineCap line_cap);
57 public LineCap get_line_cap ();
59 public void set_line_join (LineJoin line_join);
60 public LineJoin get_line_join ();
62 public void set_line_width (double width);
63 public double get_line_width ();
65 public void set_miter_limit (double limit);
66 public double get_miter_limit ();
68 public void set_operator (Operator op);
69 public Operator get_operator ();
71 public void set_tolerance (double tolerance);
72 public double get_tolerance ();
74 public void clip ();
75 public void clip_preserve ();
76 public void reset_clip ();
78 public void fill ();
79 public void fill_preserve ();
80 public void fill_extents (ref double x1, ref double y1, ref double x2, ref double y2);
81 public bool in_fill (double x, double y);
83 public void mask (Pattern pattern);
84 public void mask_surface (Surface surface, double surface_x, double surface_y);
86 public void paint ();
87 public void paint_with_alpha (double alpha);
89 public void stroke ();
90 public void stroke_preserve ();
91 public void stroke_extents (ref double x1, ref double y1, ref double x2, ref double y2);
92 public bool in_stroke (double x, double y);
94 public void copy_page ();
95 public void show_page ();
97 public ref Path copy_path ();
98 public ref Path copy_path_flat ();
100 public void append_path (Path path);
102 public void get_current_point (ref double x, ref double y);
104 public void new_path ();
105 public void new_sub_path ();
106 public void close_path ();
108 public void arc (double xc, double yc, double radius, double angle1, double angle2);
109 public void arc_negative (double xc, double yc, double radius, double angle1, double angle2);
111 public void curve_to (double x1, double y1, double x2, double y2, double x3, double y3);
112 public void line_to (double x, double y);
113 public void move_to (double x, double y);
115 public void rectangle (double x, double y, double width, double height);
117 [NoArrayLength ()]
118 public void glyph_path (Glyph[] glyphs, int num_glyphs);
119 public void text_path (string! utf8);
121 public void rel_curve_to (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
122 public void rel_line_to (double dx, double dy);
123 public void rel_move_to (double dx, double dy);
125 public void translate (double tx, double ty);
126 public void scale (double sx, double sy);
127 public void rotate (double angle);
128 public void transform (Matrix matrix);
129 public void identity_matrix ();
131 public void user_to_device (ref double x, ref double y);
132 public void user_to_device_distance (ref double dx, ref double dy);
133 public void device_to_user (ref double x, ref double y);
134 public void device_to_user_distance (ref double dx, ref double dy);
136 public void select_font_face (string! family, FontSlant slant, FontWeight weight);
137 public void set_font_size (double size);
138 public void set_font_matrix (Matrix! matrix);
139 public void get_font_matrix (Matrix matrix);
140 public void set_font_options (ref FontOptions! options);
141 public void get_font_options (ref FontOptions options);
143 public void show_text (string! utf8);
144 [NoArrayLength ()]
145 public void show_glyphs (Glyph[] glyphs, int num_glyphs);
147 public weak FontFace get_font_face ();
148 public void font_extents (ref FontExtents extents);
149 public void set_font_face (FontFace font_face);
150 public void set_scaled_font (ScaledFont! font);
151 public void text_extents (string! utf8, ref TextExtents extents);
152 [NoArrayLength ()]
153 public void glyph_extents (Glyph[] glyphs, int num_glyphs, ref TextExtents extents);
156 public enum Antialias {
157 DEFAULT,
158 NONE,
159 GRAY,
160 SUBPIXEL
163 public enum FillRule {
164 WINDING,
165 EVEN_ODD
168 public enum LineCap {
169 BUTT,
170 ROUND,
171 SQUARE
174 public enum LineJoin {
175 MITER,
176 ROUND,
177 BEVEL
180 public enum Operator {
181 CLEAR,
182 SOURCE,
183 OVER,
185 OUT,
186 ATOP,
187 DEST,
188 DEST_OVER,
189 DEST_IN,
190 DEST_OUT,
191 DEST_ATOP,
192 XOR,
193 ADD,
194 SATURATE
197 [ReferenceType (free_function = "cairo_path_destroy")]
198 [CCode (cname = "cairo_path_t")]
199 public struct Path {
200 public Status status;
201 [NoArrayLength ()]
202 public PathData[] data;
203 public int num_data;
206 [CCode (cname = "cairo_path_data_t")]
207 public struct PathData {
208 public PathDataHeader header;
209 public PathDataPoint point;
212 public struct PathDataHeader {
213 public PathDataType type;
214 public int length;
217 public struct PathDataPoint {
218 public double x;
219 public double y;
222 [CCode (cprefix = "CAIRO_PATH_")]
223 public enum PathDataType {
224 MOVE_TO,
225 LINE_TO,
226 CURVE_TO,
227 CLOSE_PATH
230 [ReferenceType (dup_function = "cairo_pattern_reference", free_function = "cairo_pattern_destroy")]
231 [CCode (cname = "cairo_pattern_t")]
232 public struct Pattern {
233 public void add_color_stop_rgb (double offset, double red, double green, double blue);
234 public void add_color_stop_rgba (double offset, double red, double green, double blue, double alpha);
236 [CCode (cname = "cairo_pattern_create_rgb")]
237 public Pattern.rgb (double red, double green, double blue);
238 [CCode (cname = "cairo_pattern_create_rgba")]
239 public Pattern.rgba (double red, double green, double blue, double alpha);
240 [CCode (cname = "cairo_pattern_create_for_surface")]
241 public Pattern.for_surface (Surface! surface);
242 [CCode (cname = "cairo_pattern_create_linear")]
243 public Pattern.linear (double x0, double y0, double x1, double y1);
244 [CCode (cname = "cairo_pattern_create_radial")]
245 public Pattern.radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
247 public Status status ();
249 public void set_extend (Extend extend);
250 public Extend get_extend ();
252 public void set_filter (Filter filter);
253 public Filter get_filter ();
255 public void set_matrix (Matrix matrix);
256 public void get_matrix (Matrix matrix);
258 public PatternType get_type ();
261 [CCode (cname = "cairo_extend_t")]
262 public enum Extend {
263 NONE,
264 REPEAT,
265 REFLECT,
269 [CCode (cname = "cairo_filter_t")]
270 public enum Filter {
271 FAST,
272 GOOD,
273 BEST,
274 NEAREST,
275 BILINEAR,
276 GAUSSIAN
279 [CCode (cname = "cairo_pattern_type_t")]
280 public enum PatternType {
281 SOLID,
282 SURFACE,
283 LINEAR,
284 RADIAL
287 [ReferenceType ()]
288 [CCode (cname = "cairo_glyph_t")]
289 public struct Glyph {
292 [CCode (cname = "cairo_font_slant_t")]
293 public enum FontSlant {
294 NORMAL,
295 ITALIC,
296 OBLIQUE
299 [CCode (cname = "cairo_font_weight_t")]
300 public enum FontWeight {
301 NORMAL,
302 BOLD
305 [ReferenceType (dup_function = "cairo_font_face_reference", free_function = "cairo_font_face_destroy")]
306 [CCode (cname = "cairo_font_face_t")]
307 public struct FontFace {
308 public Status status ();
309 public FontType get_type ();
312 [CCode (cname = "cairo_font_type_t")]
313 public enum FontType {
314 TOY,
316 WIN32,
317 ATSUI
320 [ReferenceType (dup_function = "cairo_scaled_font_reference", free_function = "cairo_scaled_font_destroy")]
321 [CCode (cname = "cairo_scaled_font_t")]
322 public struct ScaledFont {
323 [CCode (cname = "cairo_scaled_font_create")]
324 public ScaledFont (Matrix font_matrix, Matrix ctm, ref FontOptions options);
325 public Status status ();
326 public void extents (ref FontExtents extents);
327 public void text_extents (string! utf8, ref TextExtents extents);
328 [NoArrayLength ()]
329 public void glyph_extents (Glyph[] glyphs, int num_glyphs, ref TextExtents extents);
330 public weak FontFace get_font_face ();
331 public void get_font_options (ref FontOptions options);
332 public void get_font_matrix (Matrix font_matrix);
333 public void get_ctm (Matrix ctm);
334 public FontType get_type ();
337 [CCode (cname = "cairo_font_extents_t")]
338 public struct FontExtents {
339 public double ascent;
340 public double descent;
341 public double height;
342 public double max_x_advance;
343 public double max_y_advance;
346 [CCode (cname = "cairo_text_extents_t")]
347 public struct TextExtents {
348 public double x_bearing;
349 public double y_bearing;
350 public double width;
351 public double height;
352 public double x_advance;
353 public double y_advance;
356 [ReferenceType (dup_function = "cairo_font_options_copy", free_function = "cairo_font_options_destroy")]
357 [CCode (cname = "cairo_font_options_t")]
358 public struct FontOptions {
359 [CCode (cname = "cairo_font_options_create")]
360 public FontOptions ();
361 public Status status ();
362 public void merge (FontOptions other);
363 public ulong hash ();
364 public bool equal (FontOptions other);
365 public void set_antialias (Antialias antialias);
366 public Antialias get_antialias ();
367 public void set_subpixel_order (SubpixelOrder subpixel_order);
368 public SubpixelOrder get_subpixel_order ();
369 public void set_hint_style (HintStyle hint_style);
370 public HintStyle get_hint_style ();
371 public void set_hint_metrics (HintMetrics hint_metrics);
372 public HintMetrics get_hint_metrics ();
375 [CCode (cname = "cairo_subpixel_order_t")]
376 public enum SubpixelOrder {
377 DEFAULT,
378 RGB,
379 BGR,
380 VRGB,
381 VBGR
384 [CCode (cname = "cairo_hint_style_t")]
385 public enum HintStyle {
386 DEFAULT,
387 NONE,
388 SLIGHT,
389 MEDIUM,
390 FULL
393 [CCode (cname = "cairo_hint_metrics_t")]
394 public enum HintMetrics {
395 DEFAULT,
396 OFF,
400 [ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
401 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo.h")]
402 public struct Surface {
403 [CCode (cname = "cairo_surface_create_similar")]
404 public Surface.similar (Surface! other, Content content, int width, int height);
405 public void finish ();
406 public void flush ();
407 public void get_font_options (ref FontOptions options);
408 public Content get_content ();
409 public void mark_dirty ();
410 public void mark_dirty_rectangle (int x, int y, int width, int height);
411 public void set_device_offset (double x_offset, double y_offset);
412 public void get_device_offset (ref double x_offset, ref double y_offset);
413 public void set_fallback_resolution (double x_pixels_per_inch, double y_pixels_per_inch);
414 public Status status ();
415 public SurfaceType get_type ();
417 public Status write_to_png (string! filename);
418 public Status write_to_png_stream (WriteFunc write_func, pointer closure);
421 public enum Content {
422 COLOR,
423 ALPHA,
424 COLOR_ALPHA
427 public enum SurfaceType {
428 IMAGE,
429 PDF,
431 XLIB,
432 XCB,
433 GLITZ,
434 QUARTZ,
435 WIN32,
436 BEOS,
437 DIRECTFB,
441 public enum Format {
442 ARGB32,
443 RGB24,
446 RGB16_565
449 [ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
450 [CCode (cname = "cairo_surface_t")]
451 public struct ImageSurface : Surface {
452 [CCode (cname = "cairo_image_surface_create")]
453 public ImageSurface (Format format, int width, int height);
454 [CCode (cname = "cairo_image_surface_create_for_data")]
455 [NoArrayLength ()]
456 public ImageSurface.for_data (uchar[] data, Format format, int width, int height, int stride);
457 public uchar[] get_data ();
458 public Format get_format ();
459 public int get_width ();
460 public int get_height ();
461 public int get_stride ();
463 [CCode (cname = "cairo_image_surface_create_from_png")]
464 public ImageSurface.from_png (string! filename);
465 [CCode (cname = "cairo_image_surface_create_from_png_stream")]
466 public ImageSurface.from_png_stream (ReadFunc read_func, pointer closure);
469 [ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
470 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-pdf.h")]
471 public struct PdfSurface : Surface {
472 [CCode (cname = "cairo_pdf_surface_create")]
473 public PdfSurface (string! filename, double width_in_points, double height_in_points);
474 [CCode (cname = "cairo_pdf_surface_create_for_stream")]
475 public PdfSurface.for_stream (WriteFunc write_func, pointer closure, double width_in_points, double height_in_points);
476 public void set_size (double width_in_points, double height_in_points);
479 [NoArrayLength ()]
480 public static delegate Status ReadFunc (pointer closure, uchar[] data, uint length);
481 [NoArrayLength ()]
482 public static delegate Status WriteFunc (pointer closure, uchar[] data, uint length);
484 [ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
485 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-ps.h")]
486 public struct PsSurface : Surface {
487 [CCode (cname = "cairo_ps_surface_create")]
488 public PsSurface (string! filename, double width_in_points, double height_in_points);
489 [CCode (cname = "cairo_ps_surface_create_for_stream")]
490 public PsSurface.for_stream (WriteFunc write_func, pointer closure, double width_in_points, double height_in_points);
491 public void set_size (double width_in_points, double height_in_points);
492 public void dsc_begin_setup ();
493 public void dsc_begin_page_setup ();
494 public void dsc_comment (string! comment);
497 [ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
498 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-svg.h")]
499 public struct SvgSurface : Surface {
500 [CCode (cname = "cairo_svg_surface_create")]
501 public SvgSurface (string! filename, double width_in_points, double height_in_points);
502 [CCode (cname = "cairo_svg_surface_create_for_stream")]
503 public SvgSurface.for_stream (WriteFunc write_func, pointer closure, double width_in_points, double height_in_points);
504 public void restrict_to_version (SvgVersion version);
505 [NoArrayLength ()]
506 public static void get_versions (out SvgVersion[] versions, ref int num_versions);
509 [CCode (cname = "cairo_svg_version_t", cprefix = "CAIRO_SVG_")]
510 public enum SvgVersion {
511 VERSION_1_1,
512 VERSION_1_2
515 [ReferenceType (dup_function = "cairo_surface_reference", free_function = "cairo_surface_destroy")]
516 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-xlib.h")]
517 public struct XlibSurface : Surface {
518 [CCode (cname = "cairo_xlib_surface_create")]
519 public XlibSurface (pointer dpy, int drawable, pointer visual, int width, int height);
520 [CCode (cname = "cairo_xlib_surface_create_for_bitmap")]
521 public XlibSurface.for_bitmap (pointer dpy, int bitmap, pointer screen, int width, int height);
522 public void set_size (int width, int height);
523 public pointer get_display ();
524 public pointer get_screen ();
525 public void set_drawable (int drawable, int width, int height);
526 public int get_drawable ();
527 public pointer get_visual ();
528 public int get_width ();
529 public int get_height ();
530 public int get_depth ();
533 [ReferenceType (free_function = "g_free")]
534 [CCode (cname = "cairo_matrix_t")]
535 public struct Matrix {
536 public void init (double xx, double yx, double xy, double yy, double x0, double y0);
537 public void init_identity ();
538 public void init_translate (double tx, double ty);
539 public void init_scale (double sx, double sy);
540 public void init_rotate (double radians);
541 public void translate (double tx, double ty);
542 public void scale (double sx, double sy);
543 public void rotate (double radians);
544 public Status invert ();
545 public void multiply (Matrix a, Matrix b);
546 public void transform_distance (ref double dx, ref double dy);
547 public void transform_point (ref double x, ref double y);
550 public enum Status {
551 SUCCESS,
552 NO_MEMORY,
553 INVALID_RESTORE,
554 INVALID_POP_GROUP,
555 NO_CURRENT_POINT,
556 INVALID_MATRIX,
557 INVALID_STATUS,
558 NULL_POINTER,
559 INVALID_STRING,
560 INVALID_PATH_DATA,
561 READ_ERROR,
562 WRITE_ERROR,
563 SURFACE_FINISHED,
564 SURFACE_TYPE_MISMATCH,
565 PATTERN_TYPE_MISMATCH,
566 INVALID_CONTENT,
567 INVALID_FORMAT,
568 INVALID_VISUAL,
569 FILE_NOT_FOUND,
570 INVALID_DASH,
571 INVALID_DSC_COMMENT
574 public int version ();
575 public weak string! version_string ();