3 * Copyright (C) 2006-2009 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.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
20 * Jürg Billeter <j@bitron.ch>
23 [CCode (cheader_filename = "cairo.h")]
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 ();
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 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_matrix (Matrix matrix);
48 public void get_matrix (out Matrix matrix);
50 public void set_antialias (Antialias antialias);
51 public Antialias get_antialias ();
53 public void set_dash (double[]? dashes, double offset);
55 public void set_fill_rule (FillRule fill_rule);
56 public FillRule get_fill_rule ();
58 public void set_line_cap (LineCap line_cap);
59 public LineCap get_line_cap ();
61 public void set_line_join (LineJoin line_join);
62 public LineJoin get_line_join ();
64 public void set_line_width (double width);
65 public double get_line_width ();
67 public void set_miter_limit (double limit);
68 public double get_miter_limit ();
70 public void set_operator (Operator op);
71 public Operator get_operator ();
73 public void set_tolerance (double tolerance);
74 public double get_tolerance ();
77 public void clip_preserve ();
78 public void clip_extents (out double x1, out double y1, out double x2, out double y2);
79 public void reset_clip ();
82 public void fill_preserve ();
83 public void fill_extents (out double x1, out double y1, out double x2, out double y2);
84 public bool in_fill (double x, double y);
86 public void mask (Pattern pattern);
87 public void mask_surface (Surface surface, double surface_x, double surface_y);
90 public void paint_with_alpha (double alpha);
92 public void stroke ();
93 public void stroke_preserve ();
94 public void stroke_extents (out double x1, out double y1, out double x2, out double y2);
95 public bool in_stroke (double x, double y);
97 public void copy_page ();
98 public void show_page ();
100 public Path copy_path ();
101 public Path copy_path_flat ();
103 public void append_path (Path path);
105 public void get_current_point (out double x, out double y);
107 public void new_path ();
108 public void new_sub_path ();
109 public void close_path ();
111 public void arc (double xc, double yc, double radius, double angle1, double angle2);
112 public void arc_negative (double xc, double yc, double radius, double angle1, double angle2);
114 public void curve_to (double x1, double y1, double x2, double y2, double x3, double y3);
115 public void line_to (double x, double y);
116 public void move_to (double x, double y);
118 public void rectangle (double x, double y, double width, double height);
120 public void glyph_path (Glyph[] glyphs);
121 public void text_path (string utf8);
123 public void rel_curve_to (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
124 public void rel_line_to (double dx, double dy);
125 public void rel_move_to (double dx, double dy);
127 public void translate (double tx, double ty);
128 public void scale (double sx, double sy);
129 public void rotate (double angle);
130 public void transform (Matrix matrix);
131 public void identity_matrix ();
133 public void user_to_device (ref double x, ref double y);
134 public void user_to_device_distance (ref double dx, ref double dy);
135 public void device_to_user (ref double x, ref double y);
136 public void device_to_user_distance (ref double dx, ref double dy);
138 public void select_font_face (string family, FontSlant slant, FontWeight weight);
139 public void set_font_size (double size);
140 public void set_font_matrix (Matrix matrix);
141 public void get_font_matrix (out Matrix matrix);
142 public void set_font_options (FontOptions options);
143 public void get_font_options (out FontOptions options);
145 public void show_text (string utf8);
146 public void show_glyphs (Glyph[] glyphs);
148 public weak FontFace get_font_face ();
149 public void font_extents (out FontExtents extents);
150 public void set_font_face (FontFace font_face);
151 public void set_scaled_font (ScaledFont font);
152 public void text_extents (string utf8, out TextExtents extents);
153 public void glyph_extents (Glyph[] glyphs, out TextExtents extents);
156 [CCode (cname = "cairo_antialias_t")]
157 public enum Antialias {
164 [CCode (cname = "cairo_fill_rule_t")]
165 public enum FillRule {
170 [CCode (cname = "cairo_line_cap_t")]
171 public enum LineCap {
177 [CCode (cname = "cairo_line_join_t")]
178 public enum LineJoin {
184 [CCode (cname = "cairo_operator_t")]
185 public enum Operator {
203 [CCode (free_function = "cairo_path_destroy", cname = "cairo_path_t")]
205 public Status status;
206 [CCode (array_length = false)]
207 public PathData[] data;
211 [CCode (cname = "cairo_path_data_t")]
212 public struct PathData {
213 public PathDataHeader header;
214 public PathDataPoint point;
217 public struct PathDataHeader {
218 public PathDataType type;
222 public struct PathDataPoint {
227 [CCode (cprefix = "CAIRO_PATH_")]
228 public enum PathDataType {
236 [CCode (ref_function = "cairo_pattern_reference", unref_function = "cairo_pattern_destroy", cname = "cairo_pattern_t")]
237 public class Pattern {
238 public void add_color_stop_rgb (double offset, double red, double green, double blue);
239 public void add_color_stop_rgba (double offset, double red, double green, double blue, double alpha);
241 [CCode (cname = "cairo_pattern_create_rgb")]
242 public Pattern.rgb (double red, double green, double blue);
243 [CCode (cname = "cairo_pattern_create_rgba")]
244 public Pattern.rgba (double red, double green, double blue, double alpha);
245 [CCode (cname = "cairo_pattern_create_for_surface")]
246 public Pattern.for_surface (Surface surface);
247 [CCode (cname = "cairo_pattern_create_linear")]
248 public Pattern.linear (double x0, double y0, double x1, double y1);
249 [CCode (cname = "cairo_pattern_create_radial")]
250 public Pattern.radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1);
252 public Status status ();
254 public void set_extend (Extend extend);
255 public Extend get_extend ();
257 public void set_filter (Filter filter);
258 public Filter get_filter ();
260 public void set_matrix (Matrix matrix);
261 public void get_matrix (out Matrix matrix);
263 public PatternType get_type ();
266 [CCode (cname = "cairo_extend_t")]
274 [CCode (cname = "cairo_filter_t")]
284 [CCode (cname = "cairo_pattern_type_t")]
285 public enum PatternType {
292 [CCode (cname = "cairo_glyph_t")]
296 [CCode (cname = "cairo_font_slant_t")]
297 public enum FontSlant {
303 [CCode (cname = "cairo_font_weight_t")]
304 public enum FontWeight {
310 [CCode (ref_function = "cairo_font_face_reference", unref_function = "cairo_font_face_destroy", cname = "cairo_font_face_t")]
311 public class FontFace {
312 public Status status ();
313 public FontType get_type ();
316 [CCode (cname = "cairo_font_type_t")]
317 public enum FontType {
325 [CCode (ref_function = "cairo_scaled_font_reference", unref_function = "cairo_scaled_font_destroy", cname = "cairo_scaled_font_t")]
326 public class ScaledFont {
327 [CCode (cname = "cairo_scaled_font_create")]
328 public ScaledFont (Matrix font_matrix, Matrix ctm, FontOptions options);
329 public Status status ();
330 public void extents (out FontExtents extents);
331 public void text_extents (string utf8, out TextExtents extents);
332 public void glyph_extents (Glyph[] glyphs, out TextExtents extents);
333 public weak FontFace get_font_face ();
334 public void get_font_options (out FontOptions options);
335 public void get_font_matrix (out Matrix font_matrix);
336 public void get_ctm (out Matrix ctm);
337 public FontType get_type ();
340 [CCode (cname = "cairo_font_extents_t")]
341 public struct FontExtents {
342 public double ascent;
343 public double descent;
344 public double height;
345 public double max_x_advance;
346 public double max_y_advance;
349 [CCode (cname = "cairo_text_extents_t")]
350 public struct TextExtents {
351 public double x_bearing;
352 public double y_bearing;
354 public double height;
355 public double x_advance;
356 public double y_advance;
360 [CCode (copy_function = "cairo_font_options_copy", free_function = "cairo_font_options_destroy", cname = "cairo_font_options_t")]
361 public class FontOptions {
362 [CCode (cname = "cairo_font_options_create")]
363 public FontOptions ();
364 public Status status ();
365 public void merge (FontOptions other);
366 public ulong hash ();
367 public bool equal (FontOptions other);
368 public void set_antialias (Antialias antialias);
369 public Antialias get_antialias ();
370 public void set_subpixel_order (SubpixelOrder subpixel_order);
371 public SubpixelOrder get_subpixel_order ();
372 public void set_hint_style (HintStyle hint_style);
373 public HintStyle get_hint_style ();
374 public void set_hint_metrics (HintMetrics hint_metrics);
375 public HintMetrics get_hint_metrics ();
378 [CCode (cname = "cairo_subpixel_order_t")]
379 public enum SubpixelOrder {
387 [CCode (cname = "cairo_hint_style_t")]
388 public enum HintStyle {
396 [CCode (cname = "cairo_hint_metrics_t")]
397 public enum HintMetrics {
404 [CCode (ref_function = "cairo_surface_reference", unref_function = "cairo_surface_destroy", cname = "cairo_surface_t", cheader_filename = "cairo.h")]
405 public class Surface {
406 [CCode (cname = "cairo_surface_create_similar")]
407 public Surface.similar (Surface other, Content content, int width, int height);
408 public void finish ();
409 public void flush ();
410 public void get_font_options (out FontOptions options);
411 public Content get_content ();
412 public void mark_dirty ();
413 public void mark_dirty_rectangle (int x, int y, int width, int height);
414 public void set_device_offset (double x_offset, double y_offset);
415 public void get_device_offset (out double x_offset, out double y_offset);
416 public void set_fallback_resolution (double x_pixels_per_inch, double y_pixels_per_inch);
417 public Status status ();
418 public SurfaceType get_type ();
420 public Status write_to_png (string filename);
421 public Status write_to_png_stream (WriteFunc write_func, void* closure);
424 [CCode (cname = "cairo_content_t")]
425 public enum Content {
431 [CCode (cname = "cairo_surface_type_t")]
432 public enum SurfaceType {
446 [CCode (cname = "cairo_format_t")]
456 [CCode (cname = "cairo_surface_t")]
457 public class ImageSurface : Surface {
458 [CCode (cname = "cairo_image_surface_create")]
459 public ImageSurface (Format format, int width, int height);
460 [CCode (cname = "cairo_image_surface_create_for_data")]
461 public ImageSurface.for_data ([CCode (array_length = false)] uchar[] data, Format format, int width, int height, int stride);
462 [CCode (array_length = false)]
463 public weak uchar[] get_data ();
464 public Format get_format ();
465 public int get_width ();
466 public int get_height ();
467 public int get_stride ();
469 [CCode (cname = "cairo_image_surface_create_from_png")]
470 public ImageSurface.from_png (string filename);
471 [CCode (cname = "cairo_image_surface_create_from_png_stream")]
472 public ImageSurface.from_png_stream (ReadFunc read_func, void* closure);
476 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-pdf.h")]
477 public class PdfSurface : Surface {
478 [CCode (cname = "cairo_pdf_surface_create")]
479 public PdfSurface (string filename, double width_in_points, double height_in_points);
480 [CCode (cname = "cairo_pdf_surface_create_for_stream")]
481 public PdfSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
482 public void set_size (double width_in_points, double height_in_points);
485 public static delegate Status ReadFunc (void* closure, uchar[] data);
486 public static delegate Status WriteFunc (void* closure, uchar[] data);
489 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-ps.h")]
490 public class PsSurface : Surface {
491 [CCode (cname = "cairo_ps_surface_create")]
492 public PsSurface (string filename, double width_in_points, double height_in_points);
493 [CCode (cname = "cairo_ps_surface_create_for_stream")]
494 public PsSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
495 public void set_size (double width_in_points, double height_in_points);
496 public void dsc_begin_setup ();
497 public void dsc_begin_page_setup ();
498 public void dsc_comment (string comment);
502 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-svg.h")]
503 public class SvgSurface : Surface {
504 [CCode (cname = "cairo_svg_surface_create")]
505 public SvgSurface (string filename, double width_in_points, double height_in_points);
506 [CCode (cname = "cairo_svg_surface_create_for_stream")]
507 public SvgSurface.for_stream (WriteFunc write_func, void* closure, double width_in_points, double height_in_points);
508 public void restrict_to_version (SvgVersion version);
509 public static void get_versions (out SvgVersion[] versions);
512 [CCode (cname = "cairo_svg_version_t", cprefix = "CAIRO_SVG_")]
513 public enum SvgVersion {
519 [CCode (cname = "cairo_surface_t", cheader_filename = "cairo-xlib.h")]
520 public class XlibSurface : Surface {
521 [CCode (cname = "cairo_xlib_surface_create")]
522 public XlibSurface (void* dpy, int drawable, void* visual, int width, int height);
523 [CCode (cname = "cairo_xlib_surface_create_for_bitmap")]
524 public XlibSurface.for_bitmap (void* dpy, int bitmap, void* screen, int width, int height);
525 public void set_size (int width, int height);
526 public void* get_display ();
527 public void* get_screen ();
528 public void set_drawable (int drawable, int width, int height);
529 public int get_drawable ();
530 public void* get_visual ();
531 public int get_width ();
532 public int get_height ();
533 public int get_depth ();
536 [CCode (cname = "cairo_matrix_t", has_type_id = "false")]
537 public struct Matrix {
538 [CCode (cname = "cairo_matrix_init")]
539 public Matrix (double xx, double yx, double xy, double yy, double x0, double y0);
540 [CCode (cname = "cairo_matrix_init_identity")]
541 public Matrix.identity ();
543 public void translate (double tx, double ty);
544 public void scale (double sx, double sy);
545 public void rotate (double radians);
546 public Status invert ();
547 public void multiply (Matrix a, Matrix b);
548 public void transform_distance (ref double dx, ref double dy);
549 public void transform_point (ref double x, ref double y);
552 [CCode (cname = "cairo_rectangle_t", has_type_id = "false")]
553 public struct Rectangle
558 public double height;
561 [CCode (cname = "cairo_status_t")]
576 SURFACE_TYPE_MISMATCH,
577 PATTERN_TYPE_MISMATCH,
586 public int version ();
587 public weak string version_string ();