valac: make it compile with 0.7.2 (ugly workarounds)
[jackpanel.git] / cairo.vapi
blobf7f15f958bf1211942a036455145af78d8b801e3
1 /* cairo.vala
2  *
3  * Copyright (C) 2006-2009  Jürg Billeter
4  *
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.1 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
18  *
19  * Author:
20  *      Jürg Billeter <j@bitron.ch>
21  */
23 [CCode (cheader_filename = "cairo.h")]
24 namespace Cairo {
25         [Compact]
26         [CCode (ref_function = "cairo_reference", unref_function = "cairo_destroy", cname = "cairo_t", cprefix = "cairo_", cheader_filename = "cairo.h")]
27         public class Context {
28                 [CCode (cname = "cairo_create")]
29                 public Context (Surface target);
30                 public Status status ();
31                 public void save ();
32                 public void restore ();
33                 
34                 public weak Surface get_target ();
35                 public void push_group ();
36                 public void push_group_with_content (Content content);
37                 public Pattern pop_group ();
38                 public void pop_group_to_source ();
39                 public weak Surface get_group_target ();
40                 
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_matrix (Matrix matrix);
48                 public void get_matrix (out Matrix matrix);
50                 public void set_antialias (Antialias antialias);
51                 public Antialias get_antialias ();
52                 
53                 public void set_dash (double[]? dashes, double offset);
54                 
55                 public void set_fill_rule (FillRule fill_rule);
56                 public FillRule get_fill_rule ();
57                 
58                 public void set_line_cap (LineCap line_cap);
59                 public LineCap get_line_cap ();
60                 
61                 public void set_line_join (LineJoin line_join);
62                 public LineJoin get_line_join ();
63                 
64                 public void set_line_width (double width);
65                 public double get_line_width ();
66                 
67                 public void set_miter_limit (double limit);
68                 public double get_miter_limit ();
69                 
70                 public void set_operator (Operator op);
71                 public Operator get_operator ();
72                 
73                 public void set_tolerance (double tolerance);
74                 public double get_tolerance ();
75                 
76                 public void clip ();
77                 public void clip_preserve ();
78                 public void reset_clip ();
80                 public void fill ();
81                 public void fill_preserve ();
82                 public void fill_extents (ref double x1, ref double y1, ref double x2, ref double y2);
83                 public bool in_fill (double x, double y);
85                 public void mask (Pattern pattern);
86                 public void mask_surface (Surface surface, double surface_x, double surface_y);
87                 
88                 public void paint ();
89                 public void paint_with_alpha (double alpha);
91                 public void stroke ();
92                 public void stroke_preserve ();
93                 public void stroke_extents (ref double x1, ref double y1, ref double x2, ref double y2);
94                 public bool in_stroke (double x, double y);
96                 public void copy_page ();
97                 public void show_page ();
98                 
99                 public Path copy_path ();
100                 public Path copy_path_flat ();
101                 
102                 public void append_path (Path path);
103                 
104                 public void get_current_point (ref double x, ref double y);
105                 
106                 public void new_path ();
107                 public void new_sub_path ();
108                 public void close_path ();
109                 
110                 public void arc (double xc, double yc, double radius, double angle1, double angle2);
111                 public void arc_negative (double xc, double yc, double radius, double angle1, double angle2);
113                 public void curve_to (double x1, double y1, double x2, double y2, double x3, double y3);
114                 public void line_to (double x, double y);
115                 public void move_to (double x, double y);
116                 
117                 public void rectangle (double x, double y, double width, double height);
118                 
119                 public void glyph_path (Glyph[] glyphs);
120                 public void text_path (string utf8);
121                 
122                 public void rel_curve_to (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
123                 public void rel_line_to (double dx, double dy);
124                 public void rel_move_to (double dx, double dy);
125                 
126                 public void translate (double tx, double ty);
127                 public void scale (double sx, double sy);
128                 public void rotate (double angle);
129                 public void transform (Matrix matrix);
130                 public void identity_matrix ();
131                 
132                 public void user_to_device (ref double x, ref double y);
133                 public void user_to_device_distance (ref double dx, ref double dy);
134                 public void device_to_user (ref double x, ref double y);
135                 public void device_to_user_distance (ref double dx, ref double dy);
136                 
137                 public void select_font_face (string family, FontSlant slant, FontWeight weight);
138                 public void set_font_size (double size);
139                 public void set_font_matrix (Matrix matrix);
140                 public void get_font_matrix (out Matrix matrix);
141                 public void set_font_options (ref FontOptions options);
142                 public void get_font_options (ref FontOptions options);
143                 
144                 public void show_text (string utf8);
145                 public void show_glyphs (Glyph[] glyphs);
146                 
147                 public weak FontFace get_font_face ();
148                 public void font_extents (out 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, out TextExtents extents);
152                 public void glyph_extents (Glyph[] glyphs, out TextExtents extents);
153         }
154         
155         public enum Antialias {
156                 DEFAULT,
157                 NONE,
158                 GRAY,
159                 SUBPIXEL
160         }
161         
162         public enum FillRule {
163                 WINDING,
164                 EVEN_ODD
165         }
166         
167         public enum LineCap {
168                 BUTT,
169                 ROUND,
170                 SQUARE
171         }
172         
173         public enum LineJoin {
174                 MITER,
175                 ROUND,
176                 BEVEL
177         }
178         
179         public enum Operator {
180                 CLEAR,
181                 SOURCE,
182                 OVER,
183                 IN,
184                 OUT,
185                 ATOP,
186                 DEST,
187                 DEST_OVER,
188                 DEST_IN,
189                 DEST_OUT,
190                 DEST_ATOP,
191                 XOR,
192                 ADD,
193                 SATURATE
194         }
195         
196         [Compact]
197         [CCode (free_function = "cairo_path_destroy", cname = "cairo_path_t")]
198         public class Path {
199                 public Status status;
200                 [CCode (array_length = false)]
201                 public PathData[] data;
202                 public int num_data;
203         }
204         
205         [CCode (cname = "cairo_path_data_t")]
206         public struct PathData {
207                 public PathDataHeader header;
208                 public PathDataPoint point;
209         }
210         
211         public struct PathDataHeader {
212                 public PathDataType type;
213                 public int length;
214         }
215         
216         public struct PathDataPoint {
217                 public double x;
218                 public double y;
219         }
220         
221         [CCode (cprefix = "CAIRO_PATH_")]
222         public enum PathDataType {
223                 MOVE_TO,
224                 LINE_TO,
225                 CURVE_TO,
226                 CLOSE_PATH
227         }
228         
229         [Compact]
230         [CCode (ref_function = "cairo_pattern_reference", unref_function = "cairo_pattern_destroy", cname = "cairo_pattern_t")]
231         public class Pattern {
232                 public void add_color_stop_rgb (double offset, double red, double green, double blue);
233                 public void add_color_stop_rgba (double offset, double red, double green, double blue, double alpha);
235                 [CCode (cname = "cairo_pattern_create_rgb")]
236                 public Pattern.rgb (double red, double green, double blue);
237                 [CCode (cname = "cairo_pattern_create_rgba")]
238                 public Pattern.rgba (double red, double green, double blue, double alpha);
239                 [CCode (cname = "cairo_pattern_create_for_surface")]
240                 public Pattern.for_surface (Surface surface);
241                 [CCode (cname = "cairo_pattern_create_linear")]
242                 public Pattern.linear (double x0, double y0, double x1, double y1);
243                 [CCode (cname = "cairo_pattern_create_radial")]
244                 public Pattern.radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
245                 
246                 public Status status ();
247                 
248                 public void set_extend (Extend extend);
249                 public Extend get_extend ();
250                 
251                 public void set_filter (Filter filter);
252                 public Filter get_filter ();
253                 
254                 public void set_matrix (Matrix matrix);
255                 public void get_matrix (out Matrix matrix);
256                 
257                 public PatternType get_type ();
258         }
259         
260         [CCode (cname = "cairo_extend_t")]
261         public enum Extend {
262                 NONE,
263                 REPEAT,
264                 REFLECT,
265                 PAD
266         }
267         
268         [CCode (cname = "cairo_filter_t")]
269         public enum Filter {
270                 FAST,
271                 GOOD,
272                 BEST,
273                 NEAREST,
274                 BILINEAR,
275                 GAUSSIAN
276         }
277         
278         [CCode (cname = "cairo_pattern_type_t")]
279         public enum PatternType {
280                 SOLID,
281                 SURFACE,
282                 LINEAR,
283                 RADIAL
284         }
285         
286         [CCode (cname = "cairo_glyph_t")]
287         public class Glyph {
288         }
289         
290         [CCode (cname = "cairo_font_slant_t")]
291         public enum FontSlant {
292                 NORMAL,
293                 ITALIC,
294                 OBLIQUE
295         }
296         
297         [CCode (cname = "cairo_font_weight_t")]
298         public enum FontWeight {
299                 NORMAL,
300                 BOLD
301         }
302         
303         [Compact]
304         [CCode (ref_function = "cairo_font_face_reference", unref_function = "cairo_font_face_destroy", cname = "cairo_font_face_t")]
305         public class FontFace {
306                 public Status status ();
307                 public FontType get_type ();
308         }
309         
310         [CCode (cname = "cairo_font_type_t")]
311         public enum FontType {
312                 TOY,
313                 FT,
314                 WIN32,
315                 ATSUI
316         }
317         
318         [Compact]
319         [CCode (ref_function = "cairo_scaled_font_reference", unref_function = "cairo_scaled_font_destroy", cname = "cairo_scaled_font_t")]
320         public class ScaledFont {
321                 [CCode (cname = "cairo_scaled_font_create")]
322                 public ScaledFont (Matrix font_matrix, Matrix ctm, ref FontOptions options);
323                 public Status status ();
324                 public void extents (ref FontExtents extents);
325                 public void text_extents (string utf8, ref TextExtents extents);
326                 public void glyph_extents (Glyph[] glyphs, ref TextExtents extents);
327                 public weak FontFace get_font_face ();
328                 public void get_font_options (ref FontOptions options);
329                 public void get_font_matrix (out Matrix font_matrix);
330                 public void get_ctm (out Matrix ctm);
331                 public FontType get_type ();
332         }
333         
334         [CCode (cname = "cairo_font_extents_t")]
335         public struct FontExtents {
336                 public double ascent;
337                 public double descent;
338                 public double height;
339                 public double max_x_advance;
340                 public double max_y_advance;
341         }
342         
343         [CCode (cname = "cairo_text_extents_t")]
344         public struct TextExtents {
345                 public double x_bearing;
346                 public double y_bearing;
347                 public double width;
348                 public double height;
349                 public double x_advance;
350                 public double y_advance;
351         }
352         
353         [Compact]
354         [CCode (copy_function = "cairo_font_options_copy", free_function = "cairo_font_options_destroy", cname = "cairo_font_options_t")]
355         public class FontOptions {
356                 [CCode (cname = "cairo_font_options_create")]
357                 public FontOptions ();
358                 public Status status ();
359                 public void merge (FontOptions other);
360                 public ulong hash ();
361                 public bool equal (FontOptions other);
362                 public void set_antialias (Antialias antialias);
363                 public Antialias get_antialias ();
364                 public void set_subpixel_order (SubpixelOrder subpixel_order);
365                 public SubpixelOrder get_subpixel_order ();
366                 public void set_hint_style (HintStyle hint_style);
367                 public HintStyle get_hint_style ();
368                 public void set_hint_metrics (HintMetrics hint_metrics);
369                 public HintMetrics get_hint_metrics ();
370         }
371         
372         [CCode (cname = "cairo_subpixel_order_t")]
373         public enum SubpixelOrder {
374                 DEFAULT,
375                 RGB,
376                 BGR,
377                 VRGB,
378                 VBGR
379         }
380         
381         [CCode (cname = "cairo_hint_style_t")]
382         public enum HintStyle {
383                 DEFAULT,
384                 NONE,
385                 SLIGHT,
386                 MEDIUM,
387                 FULL
388         }
389         
390         [CCode (cname = "cairo_hint_metrics_t")]
391         public enum HintMetrics {
392                 DEFAULT,
393                 OFF,
394                 ON
395         }
396         
397         [Compact]
398         [CCode (ref_function = "cairo_surface_reference", unref_function = "cairo_surface_destroy", cname = "cairo_surface_t", cheader_filename = "cairo.h")]
399         public class Surface {
400                 [CCode (cname = "cairo_surface_create_similar")]
401                 public Surface.similar (Surface other, Content content, int width, int height);
402                 public void finish ();
403                 public void flush ();
404                 public void get_font_options (ref FontOptions options);
405                 public Content get_content ();
406                 public void mark_dirty ();
407                 public void mark_dirty_rectangle (int x, int y, int width, int height);
408                 public void set_device_offset (double x_offset, double y_offset);
409                 public void get_device_offset (ref double x_offset, ref double y_offset);
410                 public void set_fallback_resolution (double x_pixels_per_inch, double y_pixels_per_inch);
411                 public Status status ();
412                 public SurfaceType get_type ();
414                 public Status write_to_png (string filename);
415                 public Status write_to_png_stream (WriteFunc write_func, void* closure);
416         }
417         
418         public enum Content {
419                 COLOR,
420                 ALPHA,
421                 COLOR_ALPHA
422         }
423         
424         public enum SurfaceType {
425                 IMAGE,
426                 PDF,
427                 PS,
428                 XLIB,
429                 XCB,
430                 GLITZ,
431                 QUARTZ,
432                 WIN32,
433                 BEOS,
434                 DIRECTFB,
435                 SVG
436         }
437         
438         public enum Format {
439                 ARGB32,
440                 RGB24,
441                 A8,
442                 A1,
443                 RGB16_565
444         }
445         
446         [Compact]
447         [CCode (cname = "cairo_surface_t")]
448         public class ImageSurface : Surface {
449                 [CCode (cname = "cairo_image_surface_create")]
450                 public ImageSurface (Format format, int width, int height);
451                 [CCode (cname = "cairo_image_surface_create_for_data")]
452                 public ImageSurface.for_data ([CCode (array_length = false)] uchar[] data, Format format, int width, int height, int stride);
453                 public uchar[] get_data ();
454                 public Format get_format ();
455                 public int get_width ();
456                 public int get_height ();
457                 public int get_stride ();
459                 [CCode (cname = "cairo_image_surface_create_from_png")]
460                 public ImageSurface.from_png (string filename);
461                 [CCode (cname = "cairo_image_surface_create_from_png_stream")]
462                 public ImageSurface.from_png_stream (ReadFunc read_func, void* closure);
463         }
464         
465         [Compact]
466         [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-pdf.h")]
467         public class PdfSurface : Surface {
468                 [CCode (cname = "cairo_pdf_surface_create")]
469                 public PdfSurface (string filename, double width_in_points, double height_in_points);
470                 [CCode (cname = "cairo_pdf_surface_create_for_stream")]
471                 public PdfSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
472                 public void set_size (double width_in_points, double height_in_points);
473         }
474         
475         public static delegate Status ReadFunc (void* closure, uchar[] data);
476         public static delegate Status WriteFunc (void* closure, uchar[] data);
477         
478         [Compact]
479         [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-ps.h")]
480         public class PsSurface : Surface {
481                 [CCode (cname = "cairo_ps_surface_create")]
482                 public PsSurface (string filename, double width_in_points, double height_in_points);
483                 [CCode (cname = "cairo_ps_surface_create_for_stream")]
484                 public PsSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
485                 public void set_size (double width_in_points, double height_in_points);
486                 public void dsc_begin_setup ();
487                 public void dsc_begin_page_setup ();
488                 public void dsc_comment (string comment);
489         }
490         
491         [Compact]
492         [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-svg.h")]
493         public class SvgSurface : Surface {
494                 [CCode (cname = "cairo_svg_surface_create")]
495                 public SvgSurface (string filename, double width_in_points, double height_in_points);
496                 [CCode (cname = "cairo_svg_surface_create_for_stream")]
497                 public SvgSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
498                 public void restrict_to_version (SvgVersion version);
499                 public static void get_versions (out SvgVersion[] versions);
500         }
501         
502         [CCode (cname = "cairo_svg_version_t", cprefix = "CAIRO_SVG_")]
503         public enum SvgVersion {
504                 VERSION_1_1,
505                 VERSION_1_2
506         }
507         
508         [Compact]
509         [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-xlib.h")]
510         public class XlibSurface : Surface {
511                 [CCode (cname = "cairo_xlib_surface_create")]
512                 public XlibSurface (void* dpy, int drawable, void* visual, int width, int height);
513                 [CCode (cname = "cairo_xlib_surface_create_for_bitmap")]
514                 public XlibSurface.for_bitmap (void* dpy, int bitmap, void* screen, int width, int height);
515                 public void set_size (int width, int height);
516                 public void* get_display ();
517                 public void* get_screen ();
518                 public void set_drawable (int drawable, int width, int height);
519                 public int get_drawable ();
520                 public void* get_visual ();
521                 public int get_width ();
522                 public int get_height ();
523                 public int get_depth ();
524         }
525         
526         [CCode (cname = "cairo_matrix_t")]
527         public struct Matrix {
528                 [CCode (cname = "cairo_matrix_init")]
529                 public Matrix (double xx, double yx, double xy, double yy, double x0, double y0);
530                 [CCode (cname = "cairo_matrix_init_identity")]
531                 public Matrix.identity ();
533                 public void translate (double tx, double ty);
534                 public void scale (double sx, double sy);
535                 public void rotate (double radians);
536                 public Status invert ();
537                 public void multiply (Matrix a, Matrix b);
538                 public void transform_distance (ref double dx, ref double dy);
539                 public void transform_point (ref double x, ref double y);
540         }
541         
542         public enum Status {
543                 SUCCESS,
544                 NO_MEMORY,
545                 INVALID_RESTORE,
546                 INVALID_POP_GROUP,
547                 NO_CURRENT_POINT,
548                 INVALID_MATRIX,
549                 INVALID_STATUS,
550                 NULL_POINTER,
551                 INVALID_STRING,
552                 INVALID_PATH_DATA,
553                 READ_ERROR,
554                 WRITE_ERROR,
555                 SURFACE_FINISHED,
556                 SURFACE_TYPE_MISMATCH,
557                 PATTERN_TYPE_MISMATCH,
558                 INVALID_CONTENT,
559                 INVALID_FORMAT,
560                 INVALID_VISUAL,
561                 FILE_NOT_FOUND,
562                 INVALID_DASH,
563                 INVALID_DSC_COMMENT
564         }
565         
566         public int version ();
567         public weak string version_string ();