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
20 * Jürg Billeter <j@bitron.ch>
23 [CCode (cheader_filename
= "cairo.h")]
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 ();
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 ();
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 ();
75 public void clip_preserve ();
76 public void reset_clip ();
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
);
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
);
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
);
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
);
153 public void glyph_extents (Glyph
[] glyphs
, int num_glyphs
, ref TextExtents extents
);
156 public enum Antialias
{
163 public enum FillRule
{
168 public enum LineCap
{
174 public enum LineJoin
{
180 public enum Operator
{
197 [ReferenceType (free_function
= "cairo_path_destroy")]
198 [CCode (cname
= "cairo_path_t")]
200 public Status status
;
202 public PathData
[] 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
;
217 public struct PathDataPoint
{
222 [CCode (cprefix
= "CAIRO_PATH_")]
223 public enum PathDataType
{
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")]
269 [CCode (cname
= "cairo_filter_t")]
279 [CCode (cname
= "cairo_pattern_type_t")]
280 public enum PatternType
{
288 [CCode (cname
= "cairo_glyph_t")]
289 public struct Glyph
{
292 [CCode (cname
= "cairo_font_slant_t")]
293 public enum FontSlant
{
299 [CCode (cname
= "cairo_font_weight_t")]
300 public enum FontWeight
{
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
{
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
);
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
;
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
{
384 [CCode (cname
= "cairo_hint_style_t")]
385 public enum HintStyle
{
393 [CCode (cname
= "cairo_hint_metrics_t")]
394 public enum HintMetrics
{
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
{
427 public enum SurfaceType
{
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")]
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
);
480 public static delegate Status
ReadFunc (pointer closure
, uchar[] data
, uint length
);
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
);
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
{
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
);
564 SURFACE_TYPE_MISMATCH
,
565 PATTERN_TYPE_MISMATCH
,
574 public int version ();
575 public weak string! version_string ();