diff --git a/cairo/AssemblyInfo.cs b/cairo/AssemblyInfo.cs index f112aef19..d96c651fb 100644 --- a/cairo/AssemblyInfo.cs +++ b/cairo/AssemblyInfo.cs @@ -1,5 +1,5 @@ using System.Reflection; using System.Runtime.CompilerServices; -[assembly:AssemblyVersion("2.0.0.0")] +[assembly:AssemblyVersion("1.10.0.0")] [assembly:AssemblyDelaySign(false)] diff --git a/cairo/Makefile.am b/cairo/Makefile.am index 799a5402d..16e815f42 100644 --- a/cairo/Makefile.am +++ b/cairo/Makefile.am @@ -1,12 +1,8 @@ -ASSEMBLY_NAME = Mono.Cairo +ASSEMBLY_NAME = cairo-sharp ASSEMBLY = $(ASSEMBLY_NAME).dll SNK = $(srcdir)/mono.snk -if ENABLE_MONO_CAIRO TARGET=$(ASSEMBLY) -else -TARGET= -endif noinst_DATA = $(TARGET) @@ -48,6 +44,7 @@ sources = \ PSSurface.cs \ RadialGradient.cs \ Rectangle.cs \ + Region.cs \ ScaledFont.cs \ SolidPattern.cs \ Status.cs \ diff --git a/cairo/Region.cs b/cairo/Region.cs new file mode 100644 index 000000000..a78541573 --- /dev/null +++ b/cairo/Region.cs @@ -0,0 +1,252 @@ +// Copyright (C) 2011 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; + +namespace Cairo +{ + + [StructLayout(LayoutKind.Sequential)] + public struct RectangleInt { + public int X; + public int Y; + public int Width; + public int Height; + } + + public enum RegionOverlap { + In, + Out, + Part, + } + + public class Region : IDisposable { + + const string libname = "libcairo.dll"; + + IntPtr handle; + public IntPtr Handle { + get { return handle; } + } + + ~Region () + { + Dispose (false); + } + + [DllImport (libname)] + static extern IntPtr cairo_region_reference (IntPtr region); + + public Region (IntPtr handle) + { + handle = cairo_region_reference (handle); + } + + [DllImport (libname)] + static extern IntPtr cairo_region_create (); + + public Region () + { + handle = cairo_region_create (); + } + + [DllImport (libname)] + static extern IntPtr cairo_region_create_rectangle (ref RectangleInt rect); + + public Region (RectangleInt rect) + { + handle = cairo_region_create_rectangle (ref rect); + } + + [DllImport (libname)] + static extern IntPtr cairo_region_create_rectangles (RectangleInt[] rects, int count); + + public Region (RectangleInt[] rects) + { + handle = cairo_region_create_rectangles (rects, rects.Length); + } + + [DllImport (libname)] + static extern IntPtr cairo_region_copy (IntPtr original); + + public Region Copy () + { + return new Region (cairo_region_copy (Handle)); + } + + [DllImport (libname)] + static extern void cairo_region_destroy (IntPtr region); + + public void Dispose () + { + Dispose (true); + } + + void Dispose (bool disposing) + { + if (handle != IntPtr.Zero) + cairo_region_destroy (Handle); + handle = IntPtr.Zero; + if (disposing) + GC.SuppressFinalize (this); + } + + [DllImport (libname)] + static extern bool cairo_region_equal (IntPtr a, IntPtr b); + + public override bool Equals (object obj) + { + return (obj is Region) && cairo_region_equal (Handle, (obj as Region).Handle); + } + + [DllImport (libname)] + static extern Status cairo_region_status (IntPtr region); + + public Status Status { + get { return cairo_region_status (Handle); } + } + + [DllImport (libname)] + static extern void cairo_region_get_extents (IntPtr region, out RectangleInt extents); + + public RectangleInt Extents { + get { + RectangleInt result; + cairo_region_get_extents (Handle, out result); + return result; + } + } + + [DllImport (libname)] + static extern int cairo_region_num_rectangles (IntPtr region); + + public int NumRectangles { + get { return cairo_region_num_rectangles (Handle); } + } + + [DllImport (libname)] + static extern void cairo_region_get_rectangle (IntPtr region, int nth, out RectangleInt rectangle); + + public RectangleInt GetRectangle (int nth) + { + RectangleInt val; + cairo_region_get_rectangle (Handle, nth, out val); + return val; + } + + [DllImport (libname)] + static extern bool cairo_region_is_empty (IntPtr region); + + public bool IsEmpty { + get { return cairo_region_is_empty (Handle); } + } + + [DllImport (libname)] + static extern RegionOverlap cairo_region_contains_rectangle (IntPtr region, ref RectangleInt rectangle); + + public RegionOverlap ContainsPoint (RectangleInt rectangle) + { + return cairo_region_contains_rectangle (Handle, ref rectangle); + } + + [DllImport (libname)] + static extern bool cairo_region_contains_point (IntPtr region, int x, int y); + + public bool ContainsPoint (int x, int y) + { + return cairo_region_contains_point (Handle, x, y); + } + + [DllImport (libname)] + static extern void cairo_region_translate (IntPtr region, int dx, int dy); + + public void Translate (int dx, int dy) + { + cairo_region_translate (Handle, dx, dy); + } + + [DllImport (libname)] + static extern Status cairo_region_subtract (IntPtr dst, IntPtr other); + + public Status Subtract (Region other) + { + return cairo_region_subtract (Handle, other.Handle); + } + + [DllImport (libname)] + static extern Status cairo_region_subtract_rectangle (IntPtr dst, ref RectangleInt rectangle); + + public Status SubtractRectangle (RectangleInt rectangle) + { + return cairo_region_subtract_rectangle (Handle, ref rectangle); + } + + [DllImport (libname)] + static extern Status cairo_region_intersect (IntPtr dst, IntPtr other); + + public Status Intersect (Region other) + { + return cairo_region_intersect (Handle, other.Handle); + } + + [DllImport (libname)] + static extern Status cairo_region_intersect_rectangle (IntPtr dst, ref RectangleInt rectangle); + + public Status IntersectRectangle (RectangleInt rectangle) + { + return cairo_region_intersect_rectangle (Handle, ref rectangle); + } + + [DllImport (libname)] + static extern Status cairo_region_union (IntPtr dst, IntPtr other); + + public Status Union (Region other) + { + return cairo_region_union (Handle, other.Handle); + } + + [DllImport (libname)] + static extern Status cairo_region_union_rectangle (IntPtr dst, ref RectangleInt rectangle); + + public Status UnionRectangle (RectangleInt rectangle) + { + return cairo_region_union_rectangle (Handle, ref rectangle); + } + + [DllImport (libname)] + static extern Status cairo_region_xor (IntPtr dst, IntPtr other); + + public Status Xor (Region other) + { + return cairo_region_xor (Handle, other.Handle); + } + + [DllImport (libname)] + static extern Status cairo_region_xor_rectangle (IntPtr dst, ref RectangleInt rectangle); + + public Status XorRectangle (RectangleInt rectangle) + { + return cairo_region_xor_rectangle (Handle, ref rectangle); + } + } +} diff --git a/cairo/cairo-api.xml b/cairo/cairo-api.xml new file mode 100644 index 000000000..c39d69dd0 --- /dev/null +++ b/cairo/cairo-api.xml @@ -0,0 +1,6 @@ + + + + + + diff --git a/configure.ac b/configure.ac index 8aa4f800d..90c36e6ef 100644 --- a/configure.ac +++ b/configure.ac @@ -165,9 +165,6 @@ AC_SUBST(LIB_PREFIX) AC_SUBST(LIB_SUFFIX) AC_SUBST(GENERATED_SOURCES) -PKG_CHECK_MODULES(MONO_CAIRO, mono-cairo >= $MONO_REQUIRED_VERSION, enable_mono_cairo=no, enable_mono_cairo=yes) -AC_SUBST(MONO_CAIRO_LIBS) - GTK_REQUIRED_VERSION=2.99.0 GLIB_REQUIRED_VERSION=2.27.90 @@ -204,7 +201,6 @@ else fi AC_SUBST(MDOC) -AM_CONDITIONAL(ENABLE_MONO_CAIRO, test "x$enable_mono_cairo" = "xyes") AM_CONDITIONAL(ENABLE_DOTNET, test "x$enable_dotnet" = "xyes") AM_CONDITIONAL(ENABLE_MONODOC, test "x$enable_monodoc" = "xyes") @@ -278,7 +274,6 @@ echo "" echo " Optional assemblies included in the build:" echo "" echo " * gtk-dotnet.dll: $enable_dotnet" -echo " * Mono.Cairo.dll: $cairo_comment" echo "" echo " NOTE: if any of the above say 'no' you may install the" echo " corresponding development packages for them, rerun" diff --git a/gdk/Gdk.metadata b/gdk/Gdk.metadata index d8dd2b6c8..8083fcd93 100644 --- a/gdk/Gdk.metadata +++ b/gdk/Gdk.metadata @@ -204,7 +204,6 @@ false 128 1 - - + diff --git a/gdk/Makefile.am b/gdk/Makefile.am index 08f2a67d5..93c8369aa 100644 --- a/gdk/Makefile.am +++ b/gdk/Makefile.am @@ -1,16 +1,10 @@ SUBDIRS = . glue -if ENABLE_MONO_CAIRO -local_mono_cairo=$(top_builddir)/cairo/Mono.Cairo.dll -else -local_mono_cairo= -endif - pkg = gdk SYMBOLS = gdk-symbols.xml -INCLUDE_API = $(srcdir)/../glib/glib-api.xml $(top_builddir)/gio/gio-api.xml $(top_builddir)/pango/pango-api.xml +INCLUDE_API = $(top_srcdir)/glib/glib-api.xml $(top_srcdir)/cairo/cairo-api.xml $(top_builddir)/gio/gio-api.xml $(top_builddir)/pango/pango-api.xml METADATA = Gdk.metadata -references = $(top_builddir)/glib/glib-sharp.dll $(top_builddir)/gio/gio-sharp.dll $(top_builddir)/pango/pango-sharp.dll $(local_mono_cairo) +references = $(top_builddir)/glib/glib-sharp.dll $(top_builddir)/gio/gio-sharp.dll $(top_builddir)/pango/pango-sharp.dll $(top_builddir)/cairo/cairo-sharp.dll glue_includes = gdk/gdk.h sources = \ @@ -74,4 +68,4 @@ customs = \ add_dist = -include ../Makefile.include +include $(top_srcdir)/Makefile.include diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 01d0a409e..96dd908fd 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1,19 +1,13 @@ SUBDIRS = . glue -if ENABLE_MONO_CAIRO -local_mono_cairo=$(top_builddir)/cairo/Mono.Cairo.dll -else -local_mono_cairo= -endif - pkg = gtk pkgconfigdir=$(libdir)/pkgconfig pkgconfig_DATA=gtk-sharp-3.0.pc SYMBOLS = gtk-symbols.xml -INCLUDE_API = $(srcdir)/../glib/glib-api.xml $(top_builddir)/gio/gio-api.xml $(top_builddir)/pango/pango-api.xml $(top_builddir)/atk/atk-api.xml $(top_builddir)/gdk/gdk-api.xml +INCLUDE_API = $(top_srcdir)/glib/glib-api.xml $(top_srcdir)/cairo/cairo-api.xml $(top_builddir)/gio/gio-api.xml $(top_builddir)/pango/pango-api.xml $(top_builddir)/atk/atk-api.xml $(top_builddir)/gdk/gdk-api.xml METADATA = Gtk.metadata -references = $(top_builddir)/glib/glib-sharp.dll $(top_builddir)/gio/gio-sharp.dll $(top_builddir)/pango/pango-sharp.dll $(top_builddir)/atk/atk-sharp.dll $(top_builddir)/gdk/gdk-sharp.dll $(local_mono_cairo) +references = $(top_builddir)/glib/glib-sharp.dll $(top_builddir)/cairo/cairo-sharp.dll $(top_builddir)/gio/gio-sharp.dll $(top_builddir)/pango/pango-sharp.dll $(top_builddir)/atk/atk-sharp.dll $(top_builddir)/gdk/gdk-sharp.dll glue_includes = gtk/gtk.h sources = \ @@ -145,5 +139,5 @@ customs = \ add_dist = gtk-sharp-3.0.pc.in -include ../Makefile.include +include $(top_srcdir)/Makefile.include diff --git a/pango/Makefile.am b/pango/Makefile.am index 97fdc74d5..ed85ae85e 100644 --- a/pango/Makefile.am +++ b/pango/Makefile.am @@ -1,15 +1,10 @@ SUBDIRS = . glue -if ENABLE_MONO_CAIRO -local_mono_cairo=$(top_builddir)/cairo/Mono.Cairo.dll -else -local_mono_cairo= -endif - pkg = pango METADATA = Pango.metadata +INCLUDE_API = $(top_srcdir)/cairo/cairo-api.xml SYMBOLS = pango-symbols.xml -references = ../glib/glib-sharp.dll $(local_mono_cairo) +references = $(top_builddir)/glib/glib-sharp.dll $(top_builddir)/cairo/cairo-sharp.dll glue_includes = pango/pango.h sources = \ @@ -62,5 +57,5 @@ customs = \ add_dist = -include ../Makefile.include +include $(top_srcdir)/Makefile.include diff --git a/pango/Pango.metadata b/pango/Pango.metadata index b966d0d8f..f36791297 100644 --- a/pango/Pango.metadata +++ b/pango/Pango.metadata @@ -99,7 +99,6 @@ 1 1 1 - /api/namespace/class[@name='Global'] /api/namespace/class[@name='Global'] diff --git a/sample/GtkDemo/Makefile.am b/sample/GtkDemo/Makefile.am index c5b7e0103..57fca2e15 100644 --- a/sample/GtkDemo/Makefile.am +++ b/sample/GtkDemo/Makefile.am @@ -1,15 +1,13 @@ -if ENABLE_MONO_CAIRO -cairo_ref=$(top_builddir)/cairo/Mono.Cairo.dll -else -cairo_ref=Mono.Cairo -endif - assemblies = \ - $(top_builddir)/glib/glib-sharp.dll $(top_builddir)/gio/gio-sharp.dll \ - $(top_builddir)/pango/pango-sharp.dll $(top_builddir)/atk/atk-sharp.dll \ - $(top_builddir)/gdk/gdk-sharp.dll $(top_builddir)/gtk/gtk-sharp.dll + $(top_builddir)/glib/glib-sharp.dll \ + $(top_builddir)/gio/gio-sharp.dll \ + $(top_builddir)/cairo/cairo-sharp.dll \ + $(top_builddir)/pango/pango-sharp.dll \ + $(top_builddir)/atk/atk-sharp.dll \ + $(top_builddir)/gdk/gdk-sharp.dll \ + $(top_builddir)/gtk/gtk-sharp.dll -references = $(addprefix -r:, $(assemblies) $(cairo_ref)) +references = $(addprefix -r:, $(assemblies) TARGETS = GtkDemo.exe DEBUGS = $(addsuffix .mdb, $(TARGETS)) CLEANFILES = $(TARGETS) $(DEBUGS) diff --git a/sample/Makefile.am b/sample/Makefile.am index 239804708..02dd84a55 100755 --- a/sample/Makefile.am +++ b/sample/Makefile.am @@ -1,11 +1,5 @@ SUBDIRS = test GtkDemo pixmaps valtest opaquetest gio gtk-gio -if ENABLE_MONO_CAIRO -cairo_ref=-r:$(top_builddir)/cairo/Mono.Cairo.dll -else -cairo_ref=-r:Mono.Cairo -endif - if ENABLE_DOTNET DOTNET_TARGETS=drawing-sample.exe DOTNET_ASSEMBLY=../gtkdotnet/gtk-dotnet.dll @@ -21,6 +15,7 @@ DEBUGS = $(addsuffix .mdb, $(TARGETS)) assemblies = \ $(top_builddir)/glib/glib-sharp.dll \ $(top_builddir)/gio/gio-sharp.dll \ + $(top_builddir)/cairo/cairo-sharp.dll \ $(top_builddir)/pango/pango-sharp.dll \ $(top_builddir)/atk/atk-sharp.dll \ $(top_builddir)/gdk/gdk-sharp.dll \ @@ -71,7 +66,7 @@ treemodeldemo.exe: $(srcdir)/TreeModelDemo.cs $(assemblies) $(CSC) $(CSFLAGS) -out:treemodeldemo.exe $(references) $(srcdir)/TreeModelDemo.cs cairo-sample.exe: $(srcdir)/CairoSample.cs $(assemblies) - $(CSC) $(CSFLAGS) -out:cairo-sample.exe $(references) $(cairo_ref) $(srcdir)/CairoSample.cs + $(CSC) $(CSFLAGS) -out:cairo-sample.exe $(references) $(srcdir)/CairoSample.cs testdnd.exe: $(srcdir)/TestDnd.cs $(assemblies) $(CSC) $(CSFLAGS) -unsafe -out:testdnd.exe $(references) $(srcdir)/TestDnd.cs