Add CopyPath, CopyPathFlat, AppendPath
authorMiguel de Icaza <miguel@gnome.org>
Mon, 23 Jul 2007 05:51:55 +0000 (05:51 -0000)
committerMiguel de Icaza <miguel@gnome.org>
Mon, 23 Jul 2007 05:51:55 +0000 (05:51 -0000)
svn path=/trunk/mcs/; revision=82462

mcs/class/Mono.Cairo/Mono.Cairo.dll.sources
mcs/class/Mono.Cairo/Mono.Cairo/Context.cs
mcs/class/Mono.Cairo/Mono.Cairo/NativeMethods.cs
mcs/class/Mono.Cairo/Mono.Cairo/Path.cs [new file with mode: 0644]

index bf095d2f53f1a337017b0611f2541549df729b13..9051e918ee6cdb70d173512ff200dcfeb05ce4b3 100644 (file)
@@ -28,6 +28,7 @@
 ./Mono.Cairo/Matrix.cs
 ./Mono.Cairo/NativeMethods.cs
 ./Mono.Cairo/Operator.cs
+./Mono.Cairo/Path.cs
 ./Mono.Cairo/Pattern.cs
 ./Mono.Cairo/PatternType.cs
 ./Mono.Cairo/PdfSurface.cs
index 39940befd46cdc027db4f41b72067a3ca2e802d1..037f4e1fa790f83ae12e9d95f0e699943811fa55 100644 (file)
@@ -500,6 +500,22 @@ namespace Cairo {
                 {
                         NativeMethods.cairo_close_path (state);
                 }
+
+               public Path CopyPath ()
+               {
+                       return new Path (NativeMethods.cairo_copy_path (state));
+               }
+
+               public Path CopyPathFlat ()
+               {
+                       return new Path (NativeMethods.cairo_copy_path_flat (state));
+               }
+
+               public void AppendPath (Path path)
+               {
+                       NativeMethods.cairo_append_path (state, path.handle);
+               }
+               
 #endregion
 
 #region Painting Methods
index 55a2eb2d602a40fde96215fee4bcccfd094d3c88..78d35193e1b54af00323607b0932fb6dd8ec3268 100644 (file)
@@ -72,11 +72,14 @@ namespace Cairo
                [DllImport (cairo)]
                internal static extern void cairo_copy_page (IntPtr cr);
                
-               //[DllImport (cairo)]
-               //internal static extern Path cairo_copy_path (IntPtr cr);
+               [DllImport (cairo)]
+               internal static extern IntPtr cairo_copy_path (IntPtr cr);
                
-               //[DllImport (cairo)]
-               //internal static extern Path cairo_copy_path_flat (IntPtr cr);
+               [DllImport (cairo)]
+               internal static extern IntPtr cairo_copy_path_flat (IntPtr cr);
+
+               [DllImport (cairo)]
+               internal static extern IntPtr cairo_append_path (IntPtr cr, IntPtr path);
                
                [DllImport (cairo)]
                internal static extern IntPtr cairo_create (IntPtr target);
diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Path.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Path.cs
new file mode 100644 (file)
index 0000000..6afed4e
--- /dev/null
@@ -0,0 +1,72 @@
+//
+// Mono.Cairo.Context.cs
+//
+// Author:
+//   Miguel de Icaza (miguel@novell.com)
+//
+// This is an OO wrapper API for the Cairo API.
+//
+// Copyright 2007 Novell, Inc (http://www.novell.com)
+//
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+// 
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+// 
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+//
+
+using System;
+using System.Runtime.InteropServices;
+using Cairo;
+
+namespace Cairo {
+
+        public class Path : IDisposable 
+        {
+                internal IntPtr handle = IntPtr.Zero;
+               
+               internal Path (IntPtr handle)
+               {
+                       this.handle = handle;
+               }
+
+               ~Path ()
+               {
+                       Dispose (false);
+               }
+
+               
+               void IDisposable.Dispose ()
+               {
+                       Dispose (true);
+                       GC.SuppressFinalize (this);
+               }
+               
+                protected virtual void Dispose (bool disposing)
+                {
+                       if (!disposing){
+                               Console.Error.WriteLine ("Cairo.Context: called from finalization thread, programmer is missing a call to Dispose");
+                               return;
+                       }
+                       
+                       if (handle == IntPtr.Zero)
+                               return;
+
+                        NativeMethods.cairo_path_destroy (handle);
+                       handle = IntPtr.Zero;
+                }
+        }
+}