2003-08-09 Duncan Mak <duncan@ximian.com>
authorDuncan Mak <duncan@mono-cvs.ximian.com>
Sun, 10 Aug 2003 03:23:30 +0000 (03:23 -0000)
committerDuncan Mak <duncan@mono-cvs.ximian.com>
Sun, 10 Aug 2003 03:23:30 +0000 (03:23 -0000)
* Mono.Cairo.Cairo.cs:
* Mono.Cairo.CairoObject.cs:
* Mono.Cairo.CairoMatrixObject.cs:
* Mono.Cairo.CairoSurfaceObject.cs: Added Cairo binding.

svn path=/trunk/mcs/; revision=17213

mcs/class/Mono.Cairo/ChangeLog [new file with mode: 0644]
mcs/class/Mono.Cairo/Mono.Cairo/Cairo.cs [new file with mode: 0644]
mcs/class/Mono.Cairo/Mono.Cairo/CairoMatrixObject.cs [new file with mode: 0644]
mcs/class/Mono.Cairo/Mono.Cairo/CairoObject.cs [new file with mode: 0644]
mcs/class/Mono.Cairo/Mono.Cairo/CairoSurfaceObject.cs [new file with mode: 0644]

diff --git a/mcs/class/Mono.Cairo/ChangeLog b/mcs/class/Mono.Cairo/ChangeLog
new file mode 100644 (file)
index 0000000..f0b2a4d
--- /dev/null
@@ -0,0 +1,6 @@
+2003-08-09  Duncan Mak  <duncan@ximian.com>
+
+       * Mono.Cairo.Cairo.cs:
+       * Mono.Cairo.CairoObject.cs:
+       * Mono.Cairo.CairoMatrixObject.cs: 
+       * Mono.Cairo.CairoSurfaceObject.cs: Added Cairo binding.
\ No newline at end of file
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Cairo.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Cairo.cs
new file mode 100644 (file)
index 0000000..248ecd4
--- /dev/null
@@ -0,0 +1,421 @@
+//
+// Mono.Cairo.Cairo.cs
+//
+// Author: Duncan Mak (duncan@ximian.com)
+//
+// (C) Ximian, Inc. 2003
+//
+// This is a simplistic binding of the Cairo API to C#. All functions
+// in cairo.h are transcribed into their C# equivelants and all
+// enumerations are also listed here.
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+
+namespace Mono.Cairo {
+
+       internal class Cairo
+        {
+                //
+                // Manipulating state objects
+                //
+               [DllImport (CairoImp)]
+               internal static extern IntPtr cairo_create ();
+
+               [DllImport (CairoImp)]
+               internal static extern IntPtr cairo_destroy (IntPtr cr);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_save (IntPtr cr);                
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_restore (IntPtr cr);
+
+                //
+                // Modify state
+                //
+                [DllImport (CairoImp)]
+                internal static extern void cairo_set_target_surface (IntPtr, cr, IntPtr surface);
+                                
+                [DllImport (CairoImp)]
+                internal static extern void cairo_set_target_image (
+                        IntPtr cr, string data, Cairo.Format format, int width, int height, int stride);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_set_operator (IntPtr cr, Cairo.Operator op);
+
+                       [DllImport (CairoImp)]
+               internal static extern void cairo_set_rgb_color (IntPtr cr, double red, double green, double blue);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_set_alpha (IntPtr cr, double alpha);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_set_pattern (IntPtr cr, IntPtr pattern);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_set_tolerence (IntPtr cr, double tolerance);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_set_fill_rule (IntPtr cr, Cairo.FillRule fill_rule);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_set_line_width (IntPtr cr, double width);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_set_line_cap (IntPtr cr, Cairo.LineCap line_cap);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_set_line_join (IntPtr cr, Cairo.LineJoin line_join);
+
+                       [DllImport (CairoImp)]
+               internal static extern void cairo_set_dash (IntPtr cr, double [] dashes, int ndash, double offset);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_set_miter_limit (IntPtr cr, double limit);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_translate (IntPtr cr, double tx, double ty);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_scale (IntPtr cr, double sx, double sy);
+
+                [DllImport (CairoImp)]                
+                internal static extern void cairo_rotate (IntPtr cr, double angle);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_concat_matrix (IntPtr cr, IntPtr matrix);                
+                
+                [DllImport (CairoImp)]
+                internal static extern void cairo_set_matrix (IntPtr cr, IntPtr matrix);
+                
+                [DllImport (CairoImp)]
+                internal static extern void cairo_default_matrix (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_identity_matrix (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_transform_point (IntPtr cr, ref double x, ref double y);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_transform_distance (IntPtr cr, ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_inverse_transform_point (IntPtr cr, ref double x, ref double y);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_inverse_transform_distance (IntPtr cr, ref double dx, ref double dy);
+
+                //
+                // Path creation
+                //
+               [DllImport (CairoImp)]
+               internal static extern void cairo_new_path (IntPtr cr);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_move_to (IntPtr cr, double x, double y);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_line_to (IntPtr cr, double x, double y);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_curve_to (
+                        IntPtr cr, double x1, double y1, double x2, double y2, double x3, double y3);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_rel_move_to (IntPtr cr, double dx, double dy);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_rel_line_to (IntPtr cr, double dx, double dy);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_rel_curve_to (
+                        IntPtr cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_rectangle (IntPtr cr, double x, double y, double width, double height);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_close_path (IntPtr cr);
+
+                //
+                // Painting
+                //
+                [DllImport (CairoImp)]
+                internal static extern void cairo_stroke (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_fill (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_clip (IntPtr cr);
+
+                //
+                // Font / Text
+                //
+                [DllImport (CairoImp)]
+                internal static extern void cairo_select_font (IntPtr cr, string key);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_scale_font (IntPtr cr, double scale);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_transform_font (
+                        IntPtr cr, double a, double b, double c, double d);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_text_extents (
+                        IntPtr cr, string utf8,
+                        ref double x, ref double y,
+                        ref double width, ref double height,
+                        ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_show_text (IntPtr cr, string utf8);
+
+                //
+                // Image
+                //                
+                [DllImport (CairoImp)]
+                internal static extern void cairo_show_surface (IntPtr cr, IntPtr surface, int width, int height);
+
+                //
+                // query
+                //                                
+                [DllImport (CairoImp)]
+               internal static extern Cairo.Operator cairo_get_operator (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_get_rgb_color (
+                        IntPtr cr, out double red, out double green, out double blue);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_get_alpha (IntPtr cr);
+
+               [DllImport (CairoImp)]
+               internal static extern double cairo_get_tolerance (IntPtr cr);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_get_current_point (
+                        IntPtr cr, out double x, out double y);
+
+               [DllImport (CairoImp)]
+               internal static extern void cairo_get_fill_rule (IntPtr cr);
+
+                [DllImport (CairoImp)]
+               internal static extern double cairo_get_line_width (IntPtr cr);
+
+                [DllImport (CairoImp)]
+               internal static extern LineCap cairo_get_line_cap (IntPtr cr);
+
+                       [DllImport (CairoImp)]
+               internal static extern LineJoin cairo_get_line_join (IntPtr cr);
+
+               [DllImport (CairoImp)]
+               internal static extern double cairo_get_miter_limit (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                internal static extern void cairo_get_matrix (
+                        IntPtr cr,
+                        out double a. out double b,
+                        out double c, out double d,
+                        out double tx, out double ty);
+
+                internal static extern void cairo_get_target_surface (IntPtr cr);
+
+                //
+                // Error status queries
+                //
+                [DllImport (CairoImp)]
+                internal static extern Cairo.Status cairo_get_status (IntPtr cr);
+
+                [DllImport (CairoImp)]
+                internal static extern string cairo_get_status_string (IntPtr cr);
+
+                //
+                // Surface Manipulation
+                //
+                
+                //
+                // This is commented out because we don't have access
+                // to the X11 Drawable and Visual types.
+                //                
+//              [DllImport (CairoImp)]
+//              internal static extern IntPtr cairo_surface_create_for_drawable (
+//                      IntPtr display, Drawable drawable, IntPtr visual,
+//                      Cairo.Format format, Colormap colormap);
+
+                [DllImport (CairoImp)]                
+                internal static extern IntPtr cairo_surface_create_for_image (
+                        string data, Cairo.Format format, int width, int height, int stride);
+
+                [DllImport (CairoImp)]
+                internal static extern IntPtr cairo_surface_create_similar (
+                        IntPtr surface, Cairo.Format format, int width, int height);
+
+                [DllImport (CairoImp)]                
+                internal static extern IntPtr cairo_surface_create_similar_solid (
+                        IntPtr surface, Cairo.Format format,
+                        int width, int height, double red, double green, double blue, double alpha);
+
+                [DllImport (CairoImp)]                
+                internal static extern void cairo_surface_destroy (IntPtr surface);
+
+                [DllImport (CairoImp)]                
+                internal static extern Cairo.Status cairo_surface_put_image (
+                        IntPtr surface, string data, int width, int height, int stride);
+
+                [DllImport (CairoImp)]                
+                internal static extern Cairo.Status cairo_surface_set_repeat (
+                        IntPtr surface, int repeat);
+
+                [DllImport (CairoImp)]                
+                internal static extern Cairo.Status cairo_surface_set_matrix (
+                        IntPtr surface, IntPtr matrix);
+
+                [DllImport (CairoImp)]                
+                internal static extern Cairo.Status cairo_surface_get_matrix (
+                        IntPtr surface, IntPtr matrix);
+
+                [DllImport (CairoImp)]                
+                internal static extern Cairo.Status cairo_surface_set_filter (
+                        IntPtr surface, Cairo.Filter filter);
+
+                //
+                // Matrix
+                //
+
+                [DllImport (CairoImp)]                
+                internal static extern IntPtr cairo_matrix_create ();
+
+                [DllImport (CairoImp)]                
+                internal static extern void cairo_matrix_destroy (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_copy (
+                        IntPtr matrix, IntPtr other);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_set_identity (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_set_affine (
+                        IntPtr matrix,
+                        double a, double b, double c, double d, double tx, double ty);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_get_affine (
+                        IntPtr matrix,
+                        out double a, out double b, out double c, out double d, out double tx, out double ty);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_translate (
+                        IntPtr matrix, double tx, double ty);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_scale (
+                        IntPtr matrix, double sx, double sy);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_rotate (
+                        IntPtr matrix, double radians);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_invert (IntPtr matrix);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_multiply (
+                        out IntPtr result, IntPtr a, IntPtr b);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_transform_distance (
+                        IntPtr matrix, ref double dx, ref double dy);
+
+                [DllImport (CairoImp)]                                
+                internal static extern Cairo.Status cairo_matrix_transform_point (
+                        IntPtr matrix, ref double x, ref double y);
+                                           
+                internal enum Format {
+                        ARGB32 = 0,
+                        RGB24 = 1,
+                        A8 = 2,
+                        A1 = 4
+                }
+
+                internal enum Operator {
+                        Clear = 0,
+                        Src = 1,
+                        Dst = 2,
+                        Over = 3,
+                        OverReverse = 4,
+                        In = 5,
+                        InReverse = 6,
+                        Out = 7,
+                        OutReverse = 8,
+                        Atop = 9,
+                        AtopReverse = 10,
+                        Xor = 11,
+                        Add = 12,
+                        Saturate = 13,
+                
+                        DisjointClear = 16,
+                        DisjointSrc = 17,
+                        DisjointDst = 18,
+                        DisjointOver = 19,
+                        DisjointOverReverse = 20,
+                        DisjointIn = 21,
+                        DisjointInReverse = 22,
+                        DisjointOut = 23,
+                        DisjointOutReverse = 24,
+                        DisjointAtop = 25,
+                        DisjointAtopReverse = 26,
+                        DisjointXor = 27,
+
+                        ConjointClear = 32,
+                        ConjointSrc = 33,
+                        ConjointDst = 34,
+                        ConjointOver = 35,
+                        ConjointOverReverse = 36,
+                        ConjointIn = 37,
+                        ConjointInReverse = 38,
+                        ConjointOut = 39,
+                        ConjointOutReverse = 40,
+                        ConjointAtop = 41,
+                        ConjointAtopReverse = 42,
+                        ConjointXor = 43
+                }
+
+                internal enum FillRule {
+                        Winding,
+                        EvenOdd
+                }
+
+                internal enum LineCap {
+                        Butt, Round, Square
+                }
+
+                internal enum LineJoin {
+                        Miter, Round, Bevel
+                }
+
+                internal enum Status {
+                        Success = 0,
+                        NoMemory,
+                        InvalidRestore,
+                        InvalidPopGroup,
+                        NoCurrentPoint,
+                        InvalidMatrix
+                }
+
+                internal enum Filter {
+                        Fast,
+                        Good,
+                        Best,
+                        Nearest,
+                        Bilinear
+                }
+        }
+}
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/CairoMatrixObject.cs b/mcs/class/Mono.Cairo/Mono.Cairo/CairoMatrixObject.cs
new file mode 100644 (file)
index 0000000..8d72f4f
--- /dev/null
@@ -0,0 +1,106 @@
+//
+// Mono.Cairo.CairoMatrixObject.cs
+//
+// Author: Duncan Mak
+//
+// (C) Ximian Inc, 2003.
+//
+// This is an OO wrapper API for the Cairo API
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using Mono.Cairo;
+
+namespace Mono.Cairo {
+
+       public class CairoMatrixObject
+        {
+                IntPtr matrix;
+
+                public CairoMatrixObject ()
+                        : this (Create ())
+                {                        
+                }
+
+                CairoMatrixObject (IntPtr ptr)
+                {
+                        surface = ptr;
+                }
+
+                public static IntPtr Create ()
+                {
+                        return Cairo.cairo_matrix_create ();
+                }
+
+                public void Destroy ()
+                {
+                        Cairo.cairo_matrix_destroy (matrix);
+                }
+
+                public Cairo.Status Copy (out CairoMatrixObject other)
+                {
+                        return Cairo.cairo_matrix_copy (matrix, out other.Pointer);
+                }
+
+                public IntPtr Pointer {
+                        get { return matrix; }
+                }
+
+                public Cairo.Status SetIdentity ()
+                {
+                        return Cairo.cairo_matrix_set_identity (matrix);
+                }
+
+                public Cairo.Status SetAffine (
+                        double a, double b, double c, double d, double tx, double ty)
+                {
+                        return Cairo.cairo_matrix_set_affine (
+                                matrix, a, b, c, d, tx, ty);
+                }
+                
+                public Cairo.Status GetAffine (
+                        out double a, out double b, out double c, out double d, out double tx, out double ty)
+                {
+                        return Cairo.cairo_matrix_get_affine (
+                                matrix, out a, out b, out c, out d, out tx, out ty);
+                }
+
+                public Cairo.Status Scale (double sx, double sy)
+                {
+                        return Cairo.cairo_matrix_scale (matrix, sx, sy);
+                }
+
+                public Cairo.Status Rotate (double radians)
+                {
+                        return Cairo.cairo_matrix_rotate (matrix, radians);
+                }
+
+                public Cairo.Status Invert ()
+                {
+                        return Cairo.cairo_matrix_inverse (matrix);
+                }
+
+                public static Cairo.Status Multiply (
+                        out CairoMatrixObject result,
+                        CairoMatrixObject a, CairoMatrixObject b)
+                {
+                        return Cairo.cairo_matrix_multiply (
+                                out result.Pointer,
+                                a.Pointer, b.Pointer);
+                }
+
+                public Cairo.Status TransformDistance (ref double dx, ref double dy)
+                {
+                        return Cairo.cairo_matrix_transform_distance (
+                                matrix, ref dx, ref dy);
+                }
+
+                public Cairo.Status TransformPoint (ref double x, ref double y)
+                {
+                        return Cairo.cairo_matrix_transform_distance (
+                                matrix, ref x, ref y);
+                }
+        }
+}
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/CairoObject.cs b/mcs/class/Mono.Cairo/Mono.Cairo/CairoObject.cs
new file mode 100644 (file)
index 0000000..762b1e9
--- /dev/null
@@ -0,0 +1,308 @@
+//
+// Mono.Cairo.CairoObject.cs
+//
+// Author: Duncan Mak
+//
+// (C) Ximian Inc, 2003.
+//
+// This is an OO wrapper API for the Cairo API.
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using Mono.Cairo;
+
+namespace Mono.Cairo {
+
+       public class CairoObject
+        {
+                IntPtr state;
+
+                public CairoObject ()
+                        : this (Create ())
+                {
+                }
+                
+                public CairoObject (IntPtr ptr)
+                {
+                        state = ptr;
+                }
+                
+                public static IntPtr Create ()
+                {
+                        return Cairo.cairo_create ();
+                }
+
+                public IntPtr Destroy ()
+                {
+                        return Cairo.cairo_destroy (state);
+                }
+               
+                public void Save ()
+                {
+                        Cairo.cairo_save (state);
+                }
+
+                public void Restore ()
+                {
+                        Cairo.cairo_restore (state);
+                }
+                
+                public Status Status {
+                        get {
+                                return Cairo.cairo_get_status (state);
+                        }
+                }
+
+                public string StatusString {
+                        get {
+                                return Cairo.cairo_get_status_string (state);
+                        }
+                }
+
+                public IntPtr Pointer {
+                        get {
+                                return state;
+                        }
+                }
+                
+                public Operator Operator {
+                        set {
+                                Cairo.cairo_set_operator (state, value);
+                        }
+
+                        get {
+                                return Cairo.cairo_get_operator (state);
+                        }
+                }
+                
+                public void SetRGBColor (double r, double g, double b)
+                {
+                        Cairo.cairo_set_rgb_color (state, r, g, b);
+                }
+
+                public double Tolerence {
+                        set {
+                                Cairo.cairo_set_tolerence (state, value);
+                        }
+
+                        get {
+                                return Cairo.cairo_get_tolerence (state);
+                        }
+                }                                
+
+                public double Alpha {
+                        set {
+                                Cairo.cairo_set_alpha (state, alpha);
+                        }
+
+                        get {
+                                return Cairo.cairo_get_alpha (state);
+                        }
+                }
+                
+                public Cairo.FillRule FillRule {
+                        set {
+                                Cairo.cairo_set_fill_rule (state, value);
+                        }
+
+                        get {
+                                return Cairo.cairo_get_fill_rule (state);
+                        }
+                }
+                                        
+                public double LineWidth {
+                        set {
+                                Cairo.cairo_set_line_width (state, value);
+                        }
+
+                        get {
+                                return Cairo.cairo_get_line_width (state);
+                        }
+                }
+
+                public Cairo.LineCap LineCap {
+                        set {
+                                Cairo.cairo_set_line_cap (state, value);
+                        }
+
+                        get {
+                                return Cairo.cairo_get_line_cap (state);
+                        }
+                }
+
+                public Cairo.LineJoin LineJoin {
+                        set {
+                                Cairo.cairo_set_line_join (state, value);
+                        }
+
+                        get {
+                                Cairo.cairo_get_line_join (state);
+                        }
+                }
+
+                public void SetDash (double [] dashes, int ndash, double offset)
+                {
+                        Cairo.cairo_set_dash (state, dashes, ndash, offset);
+                }
+
+                public CairoPatternObject Pattern {
+
+                        set {
+                                Cairo.cairo_set_pattern (state, value.Pointer);
+                        }
+                }
+
+                public double MiterLimit {
+                        set {
+                                Cairo.cairo_set_miter_limit (state, value);
+                        }
+
+                        get {
+                                Cairo.cairo_get_miter_limit (state);
+                        }
+                }
+
+                public void GetCurrentPoint (out double x, out double y)
+                {
+                        Cairo.cairo_get_current_point (state, out x, out y);
+                }
+
+                public Point CurrentPoint {
+                        get {
+                                int x, y;
+                                Cairo.cairo_get_current_point (state, out x, out y);
+                                return new Point (x, y);
+                        }
+                }
+
+#region Path methods
+                
+                public void NewPath ()
+                {
+                        Cairo.cairo_new_path (state);
+                }
+               
+                public void MoveTo (double x, double y)
+                {
+                        Cairo.cairo_move_to (state, x, y);
+                }
+               
+                public void LineTo (double x, double y)
+                {
+                        Cairo.cairo_line_to (state, x, y);
+                }
+
+                public void CurveTo (double x1, double y1, double x2, double y2, double x3, doubly y3)
+                {
+                        Cairo.cairo_curve_to (state, x1, y1, x2, x2, x3, y3);
+                }
+
+                public void CurveTo (Point p1, Point p2, Point p3)
+                {
+                        Cairo.cairo_curve_to (state, p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y);
+                }
+
+                public void RelMoveTo (double dx, double dy)
+                {
+                        Cairo.cairo_rel_move_to (state, dx, dy);
+                }
+
+                public void RelLineTo (double dx, double dy)
+                {
+                        Cairo.cairo_rel_line_to (state, dx, dy);
+                }
+
+                public void RelCurveTo (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3)
+                {
+                        Cairo.cairo_rel_curve_to (state, dx1, dy1, dx2, dy2, dx3, dy3); 
+                }
+
+                public void Rectangle (double x, double y, double width, double height)
+                {
+                        Cairo.cairo_rectangle (state, x, y, width, height);
+                }
+               
+                public void ClosePath ()
+                {
+                        Cairo.cairo_close_path (state);
+                }
+#endregion
+
+#region Painting Methods
+
+                public void Stroke ()
+                {
+                        Cairo.cairo_stroke (state);
+                }
+
+                public void Fill ()
+                {
+                        Cairo.cairo_fill (state);
+                }
+
+#endregion
+
+                public void Clip ()
+                {
+                        Cairo.cairo_clip (state);
+                }
+
+#region Modified state
+
+                public void SetTargetImage (
+                        string data, Cairo.Format format, int width, int height, int stride)
+                {
+                        cairo_set_target_image (state, data, format, width, height, stride);
+                }
+
+#endregion
+
+                public void Rotate (double angle)
+                {
+                        Cairo.cairo_rotate (state, angle);
+                }
+
+                public void Scale (double sx, double sy)
+                {
+                        Cairo.cairo_scale (state, sx, sy);
+                }
+
+                public void Translate (double tx, double ty)
+                {
+                        Cairo.cairo_translate (state, tx, ty);
+                }
+
+                public void TransformPoint (ref double x, ref double y)
+                {
+                        Cairo.cairo_tranform_point (state, ref x, ref y);
+                }
+
+                public void TransformDistance (ref double dx, ref double dy)
+                {
+                        Cairo.cairo_tranform_distance (state, ref dx, ref dy);
+                }
+
+                public void InverseTransformPoint (ref double x, ref double y)
+                {
+                        Cairo.cairo_inverse_tranform_point (state, ref x, ref y);
+                }
+
+                public void InverseTransformDistance (ref double dx, ref double dy)
+                {
+                        Cairo.cairo_inverse_tranform_distance (state, ref dx, ref dy);
+                }
+
+                public void ConcatMatrix (CairoMatrixObject matrix)
+                {
+                        Cairo.cairo_concat_matrix (state, matrix.Pointer);
+                }
+
+                public CairoMatrixObject Matrix {
+                        set {
+                                Cairo.cairo_set_matrix (state, value.Pointer);
+                        }
+                }
+        }
+}
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/CairoSurfaceObject.cs b/mcs/class/Mono.Cairo/Mono.Cairo/CairoSurfaceObject.cs
new file mode 100644 (file)
index 0000000..496b2b2
--- /dev/null
@@ -0,0 +1,94 @@
+//
+// Mono.Cairo.CairoSurfaceObject.cs
+//
+// Author: Duncan Mak
+//
+// (C) Ximian Inc, 2003.
+//
+// This is an OO wrapper API for the Cairo API
+//
+
+using System;
+using System.Drawing;
+using System.Runtime.InteropServices;
+using Mono.Cairo;
+
+namespace Mono.Cairo {
+
+       public class CairoSurfaceObject
+        {
+                IntPtr surface;
+
+                CairoSurfaceObject (IntPtr ptr)
+                {
+                        surface = ptr;
+                }
+
+                public static CairoSurfaceObject CreateFromImage (
+                        string data, Cairo.Format format, int width, int height, int stride);
+                {
+                        IntPtr p = Cairo.cairo_surface_create_from_image (
+                                surface, data, format, width, height, stride);
+                        
+                        return new CairoSurfaceObject (p);
+                }
+
+                public static CairoMatrixObject CreateSimilar (Cairo.Format format, int width, int height);
+                {
+                        IntPtr p = Cairo.cairo_surface_create_similar (
+                                surface, format, width, height);
+
+                        return new CairoSurfaceObject (p);
+                }
+
+                public static CairoSurfaceObject CreateSimilarSolid (
+                        Cairo.Format format,
+                        int width, int height, double red, double green, double blue, double alpha)
+                {
+                        IntPtr p = Cairo.cairo_surface_create_similiar_solid (
+                                surface, format, width, height, red, green, blue, alpha);
+
+                        return new CairoSurfaceObject (p);
+                }
+
+                public void Destroy ()
+                {
+                        Cairo.cairo_surface_destroy (surface);
+                }
+
+                public void PutImage (string data, int width, int height, int stride)
+                {
+                        Cairo.cairo_surface_put_image (surface, data, width, height, stride);
+                }
+
+                public IntPtr Pointer {
+                        get { return surface; }
+                }
+
+                public int Repeat {
+                        set {
+                                Cairo.cairo_surface_set_repeat (surface, value);
+                        }
+                }
+
+                public CairoMatrixObject Matrix {
+                        set {
+                                Cairo.cairo_surface_set_matrix (surface, value.Pointer);
+                        }
+
+                        get {
+                                IntPtr p;
+                                
+                                Cairo.cairo_surface_get_matrix (surface, p);
+
+                                return new CairoMatrixObject (p);
+                        }
+                }
+
+                public Cairo.Filter Filter {
+                        set {
+                                Cairo.cairo_surface_set_filter (surface, value);
+                        }
+                }
+        }
+}