From 81e6815080a76327709195bf3f549e6e50bdca00 Mon Sep 17 00:00:00 2001 From: Mike Kestner Date: Thu, 9 Oct 2008 22:35:02 +0000 Subject: [PATCH] 2008-10-09 Mike Kestner * configure.in.in: magic for local Mono.Cairo build. * cairo/*: a local build of Mono.Cairo for .Net-only builds on win32. * */Makefile.am: use local Mono.Cairo where necessary. svn path=/trunk/gtk-sharp/; revision=115399 --- ChangeLog | 6 + Makefile.am | 2 +- cairo/Makefile.am | 91 +++ cairo/Mono.Cairo/Antialias.cs | 43 ++ cairo/Mono.Cairo/Cairo.cs | 53 ++ cairo/Mono.Cairo/Content.cs | 43 ++ cairo/Mono.Cairo/Context.cs | 902 ++++++++++++++++++++++++++++ cairo/Mono.Cairo/DirectFBSurface.cs | 46 ++ cairo/Mono.Cairo/Extend.cs | 45 ++ cairo/Mono.Cairo/FillRule.cs | 41 ++ cairo/Mono.Cairo/Filter.cs | 45 ++ cairo/Mono.Cairo/FontExtents.cs | 104 ++++ cairo/Mono.Cairo/FontFace.cs | 102 ++++ cairo/Mono.Cairo/FontOptions.cs | 139 +++++ cairo/Mono.Cairo/FontSlant.cs | 42 ++ cairo/Mono.Cairo/FontType.cs | 41 ++ cairo/Mono.Cairo/FontWeight.cs | 41 ++ cairo/Mono.Cairo/Format.cs | 48 ++ cairo/Mono.Cairo/GlitzSurface.cs | 46 ++ cairo/Mono.Cairo/Glyph.cs | 96 +++ cairo/Mono.Cairo/Gradient.cs | 65 ++ cairo/Mono.Cairo/HintMetrics.cs | 41 ++ cairo/Mono.Cairo/HintStyle.cs | 43 ++ cairo/Mono.Cairo/ImageSurface.cs | 110 ++++ cairo/Mono.Cairo/LineCap.cs | 41 ++ cairo/Mono.Cairo/LineJoin.cs | 42 ++ cairo/Mono.Cairo/LinearGradient.cs | 60 ++ cairo/Mono.Cairo/Matrix.cs | 193 ++++++ cairo/Mono.Cairo/NativeMethods.cs | 794 ++++++++++++++++++++++++ cairo/Mono.Cairo/Operator.cs | 56 ++ cairo/Mono.Cairo/PSSurface.cs | 67 +++ cairo/Mono.Cairo/Path.cs | 72 +++ cairo/Mono.Cairo/Pattern.cs | 141 +++++ cairo/Mono.Cairo/PatternType.cs | 42 ++ cairo/Mono.Cairo/PdfSurface.cs | 53 ++ cairo/Mono.Cairo/RadialGradient.cs | 46 ++ cairo/Mono.Cairo/Rectangle.cs | 99 +++ cairo/Mono.Cairo/ScaledFont.cs | 114 ++++ cairo/Mono.Cairo/SolidPattern.cs | 73 +++ cairo/Mono.Cairo/Status.cs | 64 ++ cairo/Mono.Cairo/SubpixelOrder.cs | 42 ++ cairo/Mono.Cairo/Surface.cs | 237 ++++++++ cairo/Mono.Cairo/SurfacePattern.cs | 56 ++ cairo/Mono.Cairo/SurfaceType.cs | 48 ++ cairo/Mono.Cairo/SvgSurface.cs | 53 ++ cairo/Mono.Cairo/SvgVersion.cs | 41 ++ cairo/Mono.Cairo/TextExtents.cs | 98 +++ cairo/Mono.Cairo/Win32Surface.cs | 48 ++ cairo/Mono.Cairo/XcbSurface.cs | 59 ++ cairo/Mono.Cairo/XlibSurface.cs | 100 +++ configure.in.in | 6 +- gdk/Makefile.am | 8 +- gtk/Makefile.am | 8 +- pango/Makefile.am | 8 +- sample/GtkDemo/Makefile.am | 12 +- 55 files changed, 5007 insertions(+), 9 deletions(-) create mode 100644 cairo/Makefile.am create mode 100644 cairo/Mono.Cairo/Antialias.cs create mode 100644 cairo/Mono.Cairo/Cairo.cs create mode 100644 cairo/Mono.Cairo/Content.cs create mode 100644 cairo/Mono.Cairo/Context.cs create mode 100644 cairo/Mono.Cairo/DirectFBSurface.cs create mode 100644 cairo/Mono.Cairo/Extend.cs create mode 100644 cairo/Mono.Cairo/FillRule.cs create mode 100644 cairo/Mono.Cairo/Filter.cs create mode 100644 cairo/Mono.Cairo/FontExtents.cs create mode 100644 cairo/Mono.Cairo/FontFace.cs create mode 100644 cairo/Mono.Cairo/FontOptions.cs create mode 100644 cairo/Mono.Cairo/FontSlant.cs create mode 100644 cairo/Mono.Cairo/FontType.cs create mode 100644 cairo/Mono.Cairo/FontWeight.cs create mode 100644 cairo/Mono.Cairo/Format.cs create mode 100644 cairo/Mono.Cairo/GlitzSurface.cs create mode 100644 cairo/Mono.Cairo/Glyph.cs create mode 100644 cairo/Mono.Cairo/Gradient.cs create mode 100644 cairo/Mono.Cairo/HintMetrics.cs create mode 100644 cairo/Mono.Cairo/HintStyle.cs create mode 100644 cairo/Mono.Cairo/ImageSurface.cs create mode 100644 cairo/Mono.Cairo/LineCap.cs create mode 100644 cairo/Mono.Cairo/LineJoin.cs create mode 100644 cairo/Mono.Cairo/LinearGradient.cs create mode 100644 cairo/Mono.Cairo/Matrix.cs create mode 100644 cairo/Mono.Cairo/NativeMethods.cs create mode 100644 cairo/Mono.Cairo/Operator.cs create mode 100644 cairo/Mono.Cairo/PSSurface.cs create mode 100644 cairo/Mono.Cairo/Path.cs create mode 100644 cairo/Mono.Cairo/Pattern.cs create mode 100644 cairo/Mono.Cairo/PatternType.cs create mode 100644 cairo/Mono.Cairo/PdfSurface.cs create mode 100644 cairo/Mono.Cairo/RadialGradient.cs create mode 100644 cairo/Mono.Cairo/Rectangle.cs create mode 100644 cairo/Mono.Cairo/ScaledFont.cs create mode 100644 cairo/Mono.Cairo/SolidPattern.cs create mode 100644 cairo/Mono.Cairo/Status.cs create mode 100644 cairo/Mono.Cairo/SubpixelOrder.cs create mode 100644 cairo/Mono.Cairo/Surface.cs create mode 100644 cairo/Mono.Cairo/SurfacePattern.cs create mode 100644 cairo/Mono.Cairo/SurfaceType.cs create mode 100644 cairo/Mono.Cairo/SvgSurface.cs create mode 100644 cairo/Mono.Cairo/SvgVersion.cs create mode 100644 cairo/Mono.Cairo/TextExtents.cs create mode 100644 cairo/Mono.Cairo/Win32Surface.cs create mode 100644 cairo/Mono.Cairo/XcbSurface.cs create mode 100644 cairo/Mono.Cairo/XlibSurface.cs diff --git a/ChangeLog b/ChangeLog index 1fd3ff714..a7de242f8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +2008-10-09 Mike Kestner + + * configure.in.in: magic for local Mono.Cairo build. + * cairo/*: a local build of Mono.Cairo for .Net-only builds on win32. + * */Makefile.am: use local Mono.Cairo where necessary. + 2008-10-09 Mike Kestner * configure.in.in: kill dead config.in. diff --git a/Makefile.am b/Makefile.am index f1d47b52e..8d355f6ce 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,4 +1,4 @@ -SUBDIRS = sources generator parser glib pango atk gdk gtk glade gtkdotnet sample doc +SUBDIRS = sources generator parser glib cairo pango atk gdk gtk glade gtkdotnet sample doc EXTRA_DIST = \ gtk-sharp.snk \ diff --git a/cairo/Makefile.am b/cairo/Makefile.am new file mode 100644 index 000000000..8fe5d021f --- /dev/null +++ b/cairo/Makefile.am @@ -0,0 +1,91 @@ +ASSEMBLY_NAME = Mono.Cairo +ASSEMBLY = $(ASSEMBLY_NAME).dll + +if ENABLE_MONO_CAIRO +TARGET=$(ASSEMBLY) +else +TARGET= +endif + +noinst_DATA = $(TARGET) + +CLEANFILES = $(ASSEMBLY) $(ASSEMBLY).mdb gtk-sharp.snk AssemblyInfo.cs + +sources = \ + Mono.Cairo/Antialias.cs \ + Mono.Cairo/Cairo.cs \ + Mono.Cairo/Content.cs \ + Mono.Cairo/Context.cs \ + Mono.Cairo/DirectFBSurface.cs \ + Mono.Cairo/Extend.cs \ + Mono.Cairo/FillRule.cs \ + Mono.Cairo/Filter.cs \ + Mono.Cairo/FontExtents.cs \ + Mono.Cairo/FontFace.cs \ + Mono.Cairo/FontOptions.cs \ + Mono.Cairo/FontSlant.cs \ + Mono.Cairo/FontType.cs \ + Mono.Cairo/FontWeight.cs \ + Mono.Cairo/Format.cs \ + Mono.Cairo/GlitzSurface.cs \ + Mono.Cairo/Glyph.cs \ + Mono.Cairo/Gradient.cs \ + Mono.Cairo/HintMetrics.cs \ + Mono.Cairo/HintStyle.cs \ + Mono.Cairo/ImageSurface.cs \ + Mono.Cairo/LinearGradient.cs \ + Mono.Cairo/LineCap.cs \ + Mono.Cairo/LineJoin.cs \ + 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 \ + Mono.Cairo/PSSurface.cs \ + Mono.Cairo/RadialGradient.cs \ + Mono.Cairo/Rectangle.cs \ + Mono.Cairo/ScaledFont.cs \ + Mono.Cairo/SolidPattern.cs \ + Mono.Cairo/Status.cs \ + Mono.Cairo/SubpixelOrder.cs \ + Mono.Cairo/Surface.cs \ + Mono.Cairo/SurfacePattern.cs \ + Mono.Cairo/SurfaceType.cs \ + Mono.Cairo/SvgSurface.cs \ + Mono.Cairo/SvgVersion.cs \ + Mono.Cairo/TextExtents.cs \ + Mono.Cairo/Win32Surface.cs \ + Mono.Cairo/XcbSurface.cs \ + Mono.Cairo/XlibSurface.cs \ + # + +build_sources = $(addprefix $(srcdir)/, $(sources)) AssemblyInfo.cs + +EXTRA_DIST = $(sources) + +gtk-sharp.snk: $(top_srcdir)/gtk-sharp.snk + cp $(top_srcdir)/gtk-sharp.snk . + +AssemblyInfo.cs: $(top_builddir)/AssemblyInfo.cs + @echo "sed -e "s/@API_VERSION@/1.0.5000.0/" -e "s/\[assembly:GLib.*//" $(top_srcdir)/AssemblyInfo.cs.in > $@" + @sed -e "s/@API_VERSION@/1.0.5000.0/" -e "s/\[assembly:GLib.IgnoreClassInitializers\]//" $(top_builddir)/AssemblyInfo.cs > $@ + +$(ASSEMBLY): $(build_sources) gtk-sharp.snk AssemblyInfo.cs + @rm -f $(ASSEMBLY).mdb + $(CSC) $(CSFLAGS) -nowarn:0169,0612,0618 -out:$(ASSEMBLY) -target:library $(references) $(build_sources) + $(GAPI_CDECL_INSERT) + +install-data-local: + @if test -n '$(TARGET)'; then \ + echo "$(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS)"; \ + $(GACUTIL) /i $(ASSEMBLY) /f $(GACUTIL_FLAGS) || exit 1; \ + fi + +uninstall-local: + @if test -n '$(TARGET)'; then \ + echo "$(GACUTIL) /u $(ASSEMBLY_NAME) $(GACUTIL_FLAGS)"; \ + $(GACUTIL) /u $(ASSEMBLY_NAME) $(GACUTIL_FLAGS) || exit 1; \ + fi + diff --git a/cairo/Mono.Cairo/Antialias.cs b/cairo/Mono.Cairo/Antialias.cs new file mode 100644 index 000000000..9ea64f75c --- /dev/null +++ b/cairo/Mono.Cairo/Antialias.cs @@ -0,0 +1,43 @@ +// +// Mono.Cairo.Antialias.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum Antialias + { + Default, + None, + Gray, + Subpixel, + } +} diff --git a/cairo/Mono.Cairo/Cairo.cs b/cairo/Mono.Cairo/Cairo.cs new file mode 100644 index 000000000..c0a5f2ab0 --- /dev/null +++ b/cairo/Mono.Cairo/Cairo.cs @@ -0,0 +1,53 @@ +// +// Cairo.cs - a simplistic binding of the Cairo API to C#. +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// John Luke (john.luke@gmail.com) +// Alp Toker (alp@atoker.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// Copyright (C) 2005 John Luke +// Copyright (C) 2006 Alp Toker +// +// 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 +{ + public static class CairoAPI { + static public int Version { + get { + return Cairo.NativeMethods.cairo_version (); + } + } + + static public string VersionString { + get { + IntPtr x = Cairo.NativeMethods.cairo_version_string (); + return Marshal.PtrToStringAnsi (x); + } + } + } +} diff --git a/cairo/Mono.Cairo/Content.cs b/cairo/Mono.Cairo/Content.cs new file mode 100644 index 000000000..a88d35a93 --- /dev/null +++ b/cairo/Mono.Cairo/Content.cs @@ -0,0 +1,43 @@ +// +// Mono.Cairo.Content.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + //[Flags] + [Serializable] + public enum Content + { + Color = 0x1000, + Alpha = 0x2000, + ColorAlpha = 0x3000, + } +} diff --git a/cairo/Mono.Cairo/Context.cs b/cairo/Mono.Cairo/Context.cs new file mode 100644 index 000000000..8be45624f --- /dev/null +++ b/cairo/Mono.Cairo/Context.cs @@ -0,0 +1,902 @@ +// +// Mono.Cairo.Context.cs +// +// Author: +// Duncan Mak (duncan@ximian.com) +// Miguel de Icaza (miguel@novell.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// Alp Toker (alp@atoker.com) +// +// (C) Ximian Inc, 2003. +// (C) Novell Inc, 2003. +// +// This is an OO wrapper API for the Cairo API. +// +// Copyright (C) 2004 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 struct Point + { + public Point (int x, int y) + { + this.x = x; + this.y = y; + } + + int x, y; + public int X { + get { return x; } + set { x = value; } + } + + public int Y { + get { return y; } + set { y = value; } + } + } + + public struct PointD + { + public PointD (double x, double y) + { + this.x = x; + this.y = y; + } + + double x, y; + public double X { + get { return x; } + set { x = value; } + } + + public double Y { + get { return y; } + set { y = value; } + } + } + + + public struct Distance + { + public Distance (double dx, double dy) + { + this.dx = dx; + this.dy = dy; + } + + double dx, dy; + public double Dx { + get { return dx; } + set { dx = value; } + } + + public double Dy { + get { return dy; } + set { dy = value; } + } + } + + public struct Color + { + public Color(double r, double g, double b) : this (r, g, b, 1.0) + { + } + + public Color(double r, double g, double b, double a) + { + this.r = r; + this.g = g; + this.b = b; + this.a = a; + } + + double r, g, b, a; + + public double R { + get { return r; } + set { r = value; } + } + + public double G { + get { return g; } + set { g = value; } + } + + public double B { + get { return b; } + set { b = value; } + } + + public double A { + get { return a; } + set { a = value; } + } + + } + + [Obsolete ("Renamed Cairo.Context per suggestion from cairo binding guidelines.")] + public class Graphics : Context { + public Graphics (IntPtr state) : base (state) {} + public Graphics (Surface surface) : base (surface) {} + } + + public class Context : IDisposable + { + internal IntPtr state = IntPtr.Zero; + + static int native_glyph_size, c_compiler_long_size; + + static Context () + { + // + // This is used to determine what kind of structure + // we should use to marshal Glyphs, as the public + // definition in Cairo uses `long', which can be + // 32 bits or 64 bits depending on the platform. + // + // We assume that sizeof(long) == sizeof(void*) + // except in the case of Win64 where sizeof(long) + // is 32 bits + // + int ptr_size = Marshal.SizeOf (typeof (IntPtr)); + + PlatformID platform = Environment.OSVersion.Platform; + if (platform == PlatformID.Win32NT || + platform == PlatformID.Win32S || + platform == PlatformID.Win32Windows || + platform == PlatformID.WinCE || + ptr_size == 4){ + c_compiler_long_size = 4; + native_glyph_size = Marshal.SizeOf (typeof (NativeGlyph_4byte_longs)); + } else { + c_compiler_long_size = 8; + native_glyph_size = Marshal.SizeOf (typeof (Glyph)); + } + } + + public Context (Surface surface) + { + state = NativeMethods.cairo_create (surface.Handle); + } + + public Context (IntPtr state) + { + this.state = state; + } + + ~Context () + { + 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 (state == IntPtr.Zero) + return; + + //Console.WriteLine ("Destroying"); + NativeMethods.cairo_destroy (state); + state = IntPtr.Zero; + } + + public void Save () + { + NativeMethods.cairo_save (state); + } + + public void Restore () + { + NativeMethods.cairo_restore (state); + } + + public Antialias Antialias { + get { return NativeMethods.cairo_get_antialias (state); } + set { NativeMethods.cairo_set_antialias (state, value); } + } + + public Cairo.Status Status { + get { + return NativeMethods.cairo_status (state); + } + } + + public IntPtr Handle { + get { + return state; + } + } + + public Cairo.Operator Operator { + set { + NativeMethods.cairo_set_operator (state, value); + } + + get { + return NativeMethods.cairo_get_operator (state); + } + } + + //FIXME: obsolete this property + public Cairo.Color Color { + set { + NativeMethods.cairo_set_source_rgba (state, value.R, value.G, value.B, value.A); + } + } + + [Obsolete ("Use Color property")] + public Cairo.Color ColorRgb { + set { + Color = new Color (value.R, value.G, value.B); + } + } + + public double Tolerance { + get { + return NativeMethods.cairo_get_tolerance (state); + } + + set { + NativeMethods.cairo_set_tolerance (state, value); + } + } + + public Cairo.FillRule FillRule { + set { + NativeMethods.cairo_set_fill_rule (state, value); + } + + get { + return NativeMethods.cairo_get_fill_rule (state); + } + } + + public double LineWidth { + set { + NativeMethods.cairo_set_line_width (state, value); + } + + get { + return NativeMethods.cairo_get_line_width (state); + } + } + + public Cairo.LineCap LineCap { + set { + NativeMethods.cairo_set_line_cap (state, value); + } + + get { + return NativeMethods.cairo_get_line_cap (state); + } + } + + public Cairo.LineJoin LineJoin { + set { + NativeMethods.cairo_set_line_join (state, value); + } + + get { + return NativeMethods.cairo_get_line_join (state); + } + } + + public void SetDash (double [] dashes, double offset) + { + NativeMethods.cairo_set_dash (state, dashes, dashes.Length, offset); + } + + public Pattern Pattern { + set { + NativeMethods.cairo_set_source (state, value.Pointer); + } + + get { + return new Pattern (NativeMethods.cairo_get_source (state)); + } + } + + public Pattern Source { + set { + NativeMethods.cairo_set_source (state, value.Pointer); + } + + get { + return Pattern.Lookup (NativeMethods.cairo_get_source (state)); + } + } + + public double MiterLimit { + set { + NativeMethods.cairo_set_miter_limit (state, value); + } + + get { + return NativeMethods.cairo_get_miter_limit (state); + } + } + + public PointD CurrentPoint { + get { + double x, y; + NativeMethods.cairo_get_current_point (state, out x, out y); + return new PointD (x, y); + } + } + + public Cairo.Surface Target { + set { + if (state != IntPtr.Zero) + NativeMethods.cairo_destroy (state); + + state = NativeMethods.cairo_create (value.Handle); + } + + get { + return Cairo.Surface.LookupExternalSurface ( + NativeMethods.cairo_get_target (state)); + } + } + + public Cairo.ScaledFont ScaledFont { + set { + NativeMethods.cairo_set_scaled_font (state, value.Handle); + } + + get { + return new ScaledFont (NativeMethods.cairo_get_scaled_font (state)); + } + } + + public uint ReferenceCount { + get { return NativeMethods.cairo_get_reference_count (state); } + } + + public void SetSourceRGB (double r, double g, double b) + { + NativeMethods.cairo_set_source_rgb (state, r, g, b); + } + + public void SetSourceRGBA (double r, double g, double b, double a) + { + NativeMethods.cairo_set_source_rgba (state, r, g, b, a); + } + + //[Obsolete ("Use SetSource method (with double parameters)")] + public void SetSourceSurface (Surface source, int x, int y) + { + NativeMethods.cairo_set_source_surface (state, source.Handle, x, y); + } + + public void SetSource (Surface source, double x, double y) + { + NativeMethods.cairo_set_source_surface (state, source.Handle, x, y); + } + + public void SetSource (Surface source) + { + NativeMethods.cairo_set_source_surface (state, source.Handle, 0, 0); + } + +#region Path methods + + public void NewPath () + { + NativeMethods.cairo_new_path (state); + } + + public void NewSubPath () + { + NativeMethods.cairo_new_sub_path (state); + } + + public void MoveTo (PointD p) + { + MoveTo (p.X, p.Y); + } + + public void MoveTo (double x, double y) + { + NativeMethods.cairo_move_to (state, x, y); + } + + public void LineTo (PointD p) + { + LineTo (p.X, p.Y); + } + + public void LineTo (double x, double y) + { + NativeMethods.cairo_line_to (state, x, y); + } + + public void CurveTo (PointD p1, PointD p2, PointD p3) + { + CurveTo (p1.X, p1.Y, p2.X, p2.Y, p3.X, p3.Y); + } + + public void CurveTo (double x1, double y1, double x2, double y2, double x3, double y3) + { + NativeMethods.cairo_curve_to (state, x1, y1, x2, y2, x3, y3); + } + + public void RelMoveTo (Distance d) + { + RelMoveTo (d.Dx, d.Dy); + } + + public void RelMoveTo (double dx, double dy) + { + NativeMethods.cairo_rel_move_to (state, dx, dy); + } + + public void RelLineTo (Distance d) + { + RelLineTo (d.Dx, d.Dy); + } + + public void RelLineTo (double dx, double dy) + { + NativeMethods.cairo_rel_line_to (state, dx, dy); + } + + public void RelCurveTo (Distance d1, Distance d2, Distance d3) + { + RelCurveTo (d1.Dx, d1.Dy, d2.Dx, d2.Dy, d3.Dx, d3.Dy); + } + + public void RelCurveTo (double dx1, double dy1, double dx2, double dy2, double dx3, double dy3) + { + NativeMethods.cairo_rel_curve_to (state, dx1, dy1, dx2, dy2, dx3, dy3); + } + + public void Arc (double xc, double yc, double radius, double angle1, double angle2) + { + NativeMethods.cairo_arc (state, xc, yc, radius, angle1, angle2); + } + + public void ArcNegative (double xc, double yc, double radius, double angle1, double angle2) + { + NativeMethods.cairo_arc_negative (state, xc, yc, radius, angle1, angle2); + } + + public void Rectangle (Rectangle rectangle) + { + Rectangle (rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height); + } + + public void Rectangle (PointD p, double width, double height) + { + Rectangle (p.X, p.Y, width, height); + } + + public void Rectangle (double x, double y, double width, double height) + { + NativeMethods.cairo_rectangle (state, x, y, width, height); + } + + public void ClosePath () + { + 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 + public void Paint () + { + NativeMethods.cairo_paint (state); + } + + public void PaintWithAlpha (double alpha) + { + NativeMethods.cairo_paint_with_alpha (state, alpha); + } + + public void Mask (Pattern pattern) + { + NativeMethods.cairo_mask (state, pattern.Pointer); + } + + public void MaskSurface (Surface surface, double surface_x, double surface_y) + { + NativeMethods.cairo_mask_surface (state, surface.Handle, surface_x, surface_y); + } + + public void Stroke () + { + NativeMethods.cairo_stroke (state); + } + + public void StrokePreserve () + { + NativeMethods.cairo_stroke_preserve (state); + } + + public Rectangle StrokeExtents () + { + double x1, y1, x2, y2; + NativeMethods.cairo_stroke_extents (state, out x1, out y1, out x2, out y2); + return new Rectangle (x1, y1, x2, y2); + } + + public void Fill () + { + NativeMethods.cairo_fill (state); + } + + public Rectangle FillExtents () + { + double x1, y1, x2, y2; + NativeMethods.cairo_fill_extents (state, out x1, out y1, out x2, out y2); + return new Rectangle (x1, y1, x2, y2); + } + + public void FillPreserve () + { + NativeMethods.cairo_fill_preserve (state); + } + +#endregion + + public void Clip () + { + NativeMethods.cairo_clip (state); + } + + public void ClipPreserve () + { + NativeMethods.cairo_clip_preserve (state); + } + + public void ResetClip () + { + NativeMethods.cairo_reset_clip (state); + } + + public bool InStroke (double x, double y) + { + return NativeMethods.cairo_in_stroke (state, x, y); + } + + public bool InFill (double x, double y) + { + return NativeMethods.cairo_in_fill (state, x, y); + } + + public Pattern PopGroup () + { + return Pattern.Lookup (NativeMethods.cairo_pop_group (state)); + } + + public void PopGroupToSource () + { + NativeMethods.cairo_pop_group_to_source (state); + } + + public void PushGroup () + { + NativeMethods.cairo_push_group (state); + } + + public void PushGroup (Content content) + { + NativeMethods.cairo_push_group_with_content (state, content); + } + + public Surface GroupTarget { + get { + IntPtr surface = NativeMethods.cairo_get_group_target (state); + return Surface.LookupSurface (surface); + } + } + + public void Rotate (double angle) + { + NativeMethods.cairo_rotate (state, angle); + } + + public void Scale (double sx, double sy) + { + NativeMethods.cairo_scale (state, sx, sy); + } + + public void Translate (double tx, double ty) + { + NativeMethods.cairo_translate (state, tx, ty); + } + + public void Transform (Matrix m) + { + NativeMethods.cairo_transform (state, m); + } + +#region Methods that will become obsolete in the long term, after 1.2.5 becomes wildly available + + //[Obsolete("Use UserToDevice instead")] + public void TransformPoint (ref double x, ref double y) + { + NativeMethods.cairo_user_to_device (state, ref x, ref y); + } + + //[Obsolete("Use UserToDeviceDistance instead")] + public void TransformDistance (ref double dx, ref double dy) + { + NativeMethods.cairo_user_to_device_distance (state, ref dx, ref dy); + } + + //[Obsolete("Use InverseTransformPoint instead")] + public void InverseTransformPoint (ref double x, ref double y) + { + NativeMethods.cairo_device_to_user (state, ref x, ref y); + } + + //[Obsolete("Use DeviceToUserDistance instead")] + public void InverseTransformDistance (ref double dx, ref double dy) + { + NativeMethods.cairo_device_to_user_distance (state, ref dx, ref dy); + } +#endregion + + public void UserToDevice (ref double x, ref double y) + { + NativeMethods.cairo_user_to_device (state, ref x, ref y); + } + + public void UserToDeviceDistance (ref double dx, ref double dy) + { + NativeMethods.cairo_user_to_device_distance (state, ref dx, ref dy); + } + + public void DeviceToUser (ref double x, ref double y) + { + NativeMethods.cairo_device_to_user (state, ref x, ref y); + } + + public void DeviceToUserDistance (ref double dx, ref double dy) + { + NativeMethods.cairo_device_to_user_distance (state, ref dx, ref dy); + } + + public Cairo.Matrix Matrix { + set { + NativeMethods.cairo_set_matrix (state, value); + } + + get { + Matrix m = new Matrix(); + NativeMethods.cairo_get_matrix (state, m); + return m; + } + } + + public void SetFontSize (double scale) + { + NativeMethods.cairo_set_font_size (state, scale); + } + + public void IdentityMatrix () + { + NativeMethods.cairo_identity_matrix (state); + } + + [Obsolete ("Use SetFontSize() instead.")] + public void FontSetSize (double scale) + { + SetFontSize (scale); + } + + [Obsolete ("Use SetFontSize() instead.")] + public double FontSize { + set { SetFontSize (value); } + } + + public Matrix FontMatrix { + get { + Matrix m; + NativeMethods.cairo_get_font_matrix (state, out m); + return m; + } + set { NativeMethods.cairo_set_font_matrix (state, value); } + } + + public FontOptions FontOptions { + get { + FontOptions options = new FontOptions (); + NativeMethods.cairo_get_font_options (state, options.Handle); + return options; + } + set { NativeMethods.cairo_set_font_options (state, value.Handle); } + } + + [StructLayout(LayoutKind.Sequential)] + internal struct NativeGlyph_4byte_longs { + public int index; + public double x; + public double y; + + public NativeGlyph_4byte_longs (Glyph source) + { + index = (int) source.index; + x = source.x; + y = source.y; + } + } + + static internal IntPtr FromGlyphToUnManagedMemory(Glyph [] glyphs) + { + IntPtr dest = Marshal.AllocHGlobal (native_glyph_size * glyphs.Length); + long pos = dest.ToInt64(); + + if (c_compiler_long_size == 8){ + foreach (Glyph g in glyphs){ + Marshal.StructureToPtr (g, (IntPtr)pos, false); + pos += native_glyph_size; + } + } else { + foreach (Glyph g in glyphs){ + NativeGlyph_4byte_longs n = new NativeGlyph_4byte_longs (g); + + Marshal.StructureToPtr (n, (IntPtr)pos, false); + pos += native_glyph_size; + } + } + + return dest; + } + + public void ShowGlyphs (Glyph[] glyphs) + { + IntPtr ptr; + + ptr = FromGlyphToUnManagedMemory (glyphs); + + NativeMethods.cairo_show_glyphs (state, ptr, glyphs.Length); + + Marshal.FreeHGlobal (ptr); + } + + [Obsolete("The matrix argument was never used, use ShowGlyphs(Glyphs []) instead")] + public void ShowGlyphs (Matrix matrix, Glyph[] glyphs) + { + ShowGlyphs (glyphs); + } + + [Obsolete("The matrix argument was never used, use GlyphPath(Glyphs []) instead")] + public void GlyphPath (Matrix matrix, Glyph[] glyphs) + { + GlyphPath (glyphs); + } + + public void GlyphPath (Glyph[] glyphs) + { + IntPtr ptr; + + ptr = FromGlyphToUnManagedMemory (glyphs); + + NativeMethods.cairo_glyph_path (state, ptr, glyphs.Length); + + Marshal.FreeHGlobal (ptr); + + } + + public FontExtents FontExtents { + get { + FontExtents f_extents; + NativeMethods.cairo_font_extents (state, out f_extents); + return f_extents; + } + } + + public void CopyPage () + { + NativeMethods.cairo_copy_page (state); + } + + [Obsolete ("Use SelectFontFace() instead.")] + public void FontFace (string family, FontSlant slant, FontWeight weight) + { + SelectFontFace (family, slant, weight); + } + + public FontFace ContextFontFace { + get { + return Cairo.FontFace.Lookup (NativeMethods.cairo_get_font_face (state)); + } + + set { + NativeMethods.cairo_set_font_face (state, value == null ? IntPtr.Zero : value.Handle); + } + } + + public void SelectFontFace (string family, FontSlant slant, FontWeight weight) + { + NativeMethods.cairo_select_font_face (state, family, slant, weight); + } + + public void ShowPage () + { + NativeMethods.cairo_show_page (state); + } + + public void ShowText (string str) + { + NativeMethods.cairo_show_text (state, str); + } + + public void TextPath (string str) + { + NativeMethods.cairo_text_path (state, str); + } + + public TextExtents TextExtents (string utf8) + { + TextExtents extents; + NativeMethods.cairo_text_extents (state, utf8, out extents); + return extents; + } + + public TextExtents GlyphExtents (Glyph[] glyphs) + { + IntPtr ptr = FromGlyphToUnManagedMemory (glyphs); + + TextExtents extents; + + NativeMethods.cairo_glyph_extents (state, ptr, glyphs.Length, out extents); + + Marshal.FreeHGlobal (ptr); + + return extents; + } + } +} diff --git a/cairo/Mono.Cairo/DirectFBSurface.cs b/cairo/Mono.Cairo/DirectFBSurface.cs new file mode 100644 index 000000000..a2ae169e7 --- /dev/null +++ b/cairo/Mono.Cairo/DirectFBSurface.cs @@ -0,0 +1,46 @@ +// +// Mono.Cairo.DirectFBSurface.cs +// +// Authors: +// Alp Toker +// +// (C) Alp Toker, 2006. +// +// 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; + +namespace Cairo { + public class DirectFBSurface : Surface + { + internal DirectFBSurface (IntPtr handle, bool owns) : base (handle, owns) + { + } + + public DirectFBSurface (IntPtr dfb, IntPtr dfb_surface) + { + surface = NativeMethods.cairo_directfb_surface_create (dfb, dfb_surface); + lock (surfaces.SyncRoot) { + surfaces [surface] = this; + } + } + } +} diff --git a/cairo/Mono.Cairo/Extend.cs b/cairo/Mono.Cairo/Extend.cs new file mode 100644 index 000000000..0ffee3fbf --- /dev/null +++ b/cairo/Mono.Cairo/Extend.cs @@ -0,0 +1,45 @@ +// +// Mono.Cairo.Extend.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// John Luke (john.luke@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// Copyright (C) 2005 John Luke +// +// 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; + +namespace Cairo +{ + [Serializable] + public enum Extend + { + None, + Repeat, + Reflect, + Pad, + } +} diff --git a/cairo/Mono.Cairo/FillRule.cs b/cairo/Mono.Cairo/FillRule.cs new file mode 100644 index 000000000..6d8c06262 --- /dev/null +++ b/cairo/Mono.Cairo/FillRule.cs @@ -0,0 +1,41 @@ +// +// Mono.Cairo.FillRule.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum FillRule + { + Winding, + EvenOdd + } +} diff --git a/cairo/Mono.Cairo/Filter.cs b/cairo/Mono.Cairo/Filter.cs new file mode 100644 index 000000000..d602ed7d6 --- /dev/null +++ b/cairo/Mono.Cairo/Filter.cs @@ -0,0 +1,45 @@ +// +// Mono.Cairo.Filter.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum Filter + { + Fast, + Good, + Best, + Nearest, + Bilinear, + Gaussian, + } +} diff --git a/cairo/Mono.Cairo/FontExtents.cs b/cairo/Mono.Cairo/FontExtents.cs new file mode 100644 index 000000000..76c7e658d --- /dev/null +++ b/cairo/Mono.Cairo/FontExtents.cs @@ -0,0 +1,104 @@ +// +// Mono.Cairo.FontExtents.cs +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.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 +// +// Copyright (C) 2004 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 FontExtents + { + double ascent; + double descent; + double height; + double maxXAdvance; + double maxYAdvance; + + public double Ascent { + get { return ascent; } + set { ascent = value; } + } + + public double Descent { + get { return descent; } + set { descent = value; } + } + + public double Height { + get { return height; } + set { height = value; } + } + + public double MaxXAdvance { + get { return maxXAdvance; } + set { maxXAdvance = value; } + } + + public double MaxYAdvance { + get { return maxYAdvance; } + set { maxYAdvance = value; } + } + + public FontExtents (double ascent, double descent, double height, double maxXAdvance, double maxYAdvance) + { + this.ascent = ascent; + this.descent = descent; + this.height = height; + this.maxXAdvance = maxXAdvance; + this.maxYAdvance = maxYAdvance; + } + + public override bool Equals (object obj) + { + if (obj is FontExtents) + return this == (FontExtents) obj; + return false; + } + + public override int GetHashCode () + { + return (int) Ascent ^ (int) Descent ^ (int) Height ^ (int) MaxXAdvance ^ (int) MaxYAdvance; + } + + public static bool operator == (FontExtents extents, FontExtents other) + { + return extents.Ascent == other.Ascent && extents.Descent == other.Descent && extents.Height == other.Height && extents.MaxXAdvance == other.MaxXAdvance && extents.MaxYAdvance == other.MaxYAdvance; + } + + public static bool operator != (FontExtents extents, FontExtents other) + { + return !(extents == other); + } + } +} diff --git a/cairo/Mono.Cairo/FontFace.cs b/cairo/Mono.Cairo/FontFace.cs new file mode 100644 index 000000000..c2944b84b --- /dev/null +++ b/cairo/Mono.Cairo/FontFace.cs @@ -0,0 +1,102 @@ +// +// Mono.Cairo.FontFace.cs +// +// Author: +// Alp Toker (alp@atoker.com) +// Miguel de Icaza (miguel@novell.com) +// +// (C) Ximian Inc, 2003. +// +// This is an OO wrapper API for the Cairo API. +// +// Copyright (C) 2004, 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; + +namespace Cairo +{ + public class FontFace : IDisposable + { + IntPtr handle; + + internal static FontFace Lookup (IntPtr handle) + { + if (handle == IntPtr.Zero) + return null; + + NativeMethods.cairo_font_face_reference (handle); + + return new FontFace (handle); + } + + ~FontFace () + { + // Since Cairo is not thread safe, we can not unref the + // font_face here, the programmer must do this with IDisposable.Dispose + + Console.Error.WriteLine ("Programmer forgot to call Dispose on the FontFace"); + Dispose (false); + } + + void IDisposable.Dispose () + { + Dispose (true); + } + + protected virtual void Dispose (bool disposing) + { + if (disposing) + NativeMethods.cairo_font_face_destroy (handle); + handle = IntPtr.Zero; + GC.SuppressFinalize (this); + } + + // TODO: make non-public when all entry points are complete in binding + public FontFace (IntPtr handle) + { + this.handle = handle; + } + + public IntPtr Handle { + get { + return handle; + } + } + + public Status Status { + get { + return NativeMethods.cairo_font_face_status (handle); + } + } + + public FontType FontType { + get { + return NativeMethods.cairo_font_face_get_type (handle); + } + } + + public uint ReferenceCount { + get { return NativeMethods.cairo_font_face_get_reference_count (handle); } + } + } +} + diff --git a/cairo/Mono.Cairo/FontOptions.cs b/cairo/Mono.Cairo/FontOptions.cs new file mode 100644 index 000000000..476910f1b --- /dev/null +++ b/cairo/Mono.Cairo/FontOptions.cs @@ -0,0 +1,139 @@ +// +// Mono.Cairo.FontOptions.cs +// +// Author: +// John Luke (john.luke@gmail.com) +// +// (C) John Luke 2005. +// +// 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; + +namespace Cairo +{ + public class FontOptions : IDisposable + { + IntPtr handle; + bool disposed; + + public FontOptions () + { + handle = NativeMethods.cairo_font_options_create (); + } + + ~FontOptions () + { + Dispose (false); + } + + internal FontOptions (IntPtr handle) + { + this.handle = handle; + } + + public FontOptions Copy () + { + return new FontOptions (NativeMethods.cairo_font_options_copy (handle)); + } + + public void Destroy () + { + NativeMethods.cairo_font_options_destroy (handle); + } + + public void Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + private void Dispose (bool disposing) + { + if (!disposed) { + Destroy (); + handle = IntPtr.Zero; + } + disposed = true; + } + + public static bool operator == (FontOptions options, FontOptions other) + { + return Equals (options, other); + } + + public static bool operator != (FontOptions options, FontOptions other) + { + return !(options == other); + } + + public override bool Equals (object other) + { + return Equals (other as FontOptions); + } + + bool Equals (FontOptions options) + { + return options != null && NativeMethods.cairo_font_options_equal (Handle, options.Handle); + } + + public IntPtr Handle { + get { return handle; } + } + + public override int GetHashCode () + { + return (int) NativeMethods.cairo_font_options_hash (handle); + } + + public void Merge (FontOptions other) + { + if (other == null) + throw new ArgumentNullException ("other"); + NativeMethods.cairo_font_options_merge (handle, other.Handle); + } + + public Antialias Antialias { + get { return NativeMethods.cairo_font_options_get_antialias (handle); } + set { NativeMethods.cairo_font_options_set_antialias (handle, value); } + } + + public HintMetrics HintMetrics { + get { return NativeMethods.cairo_font_options_get_hint_metrics (handle);} + set { NativeMethods.cairo_font_options_set_hint_metrics (handle, value); } + } + + public HintStyle HintStyle { + get { return NativeMethods.cairo_font_options_get_hint_style (handle);} + set { NativeMethods.cairo_font_options_set_hint_style (handle, value); } + } + + public Status Status { + get { return NativeMethods.cairo_font_options_status (handle); } + } + + public SubpixelOrder SubpixelOrder { + get { return NativeMethods.cairo_font_options_get_subpixel_order (handle);} + set { NativeMethods.cairo_font_options_set_subpixel_order (handle, value); } + } + } +} + diff --git a/cairo/Mono.Cairo/FontSlant.cs b/cairo/Mono.Cairo/FontSlant.cs new file mode 100644 index 000000000..c4e1af78f --- /dev/null +++ b/cairo/Mono.Cairo/FontSlant.cs @@ -0,0 +1,42 @@ +// +// Mono.Cairo.FontSlant.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum FontSlant + { + Normal, + Italic, + Oblique + } +} diff --git a/cairo/Mono.Cairo/FontType.cs b/cairo/Mono.Cairo/FontType.cs new file mode 100644 index 000000000..0c71fcb2c --- /dev/null +++ b/cairo/Mono.Cairo/FontType.cs @@ -0,0 +1,41 @@ +// +// Mono.Cairo.FontType.cs +// +// Authors: +// John Luke +// +// (C) John Luke, 2006. +// +// 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; + +namespace Cairo { + + [Serializable] + public enum FontType + { + Toy, + FreeType, + Win32, + Atsui, + } +} diff --git a/cairo/Mono.Cairo/FontWeight.cs b/cairo/Mono.Cairo/FontWeight.cs new file mode 100644 index 000000000..9d1927d8d --- /dev/null +++ b/cairo/Mono.Cairo/FontWeight.cs @@ -0,0 +1,41 @@ +// +// Mono.Cairo.FontWeight.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum FontWeight + { + Normal, + Bold, + } +} diff --git a/cairo/Mono.Cairo/Format.cs b/cairo/Mono.Cairo/Format.cs new file mode 100644 index 000000000..f0bded3c5 --- /dev/null +++ b/cairo/Mono.Cairo/Format.cs @@ -0,0 +1,48 @@ +// +// Mono.Cairo.Format.cs +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum Format + { + Argb32 = 0, + Rgb24 = 1, + A8 = 2, + A1 = 3, + Rgb16565 = 4, + + //[Obsolete ("Use Argb32")] + ARGB32 = Argb32, + //[Obsolete ("Use Rgb24")] + RGB24 = Rgb24, + } +} diff --git a/cairo/Mono.Cairo/GlitzSurface.cs b/cairo/Mono.Cairo/GlitzSurface.cs new file mode 100644 index 000000000..a8cd700a5 --- /dev/null +++ b/cairo/Mono.Cairo/GlitzSurface.cs @@ -0,0 +1,46 @@ +// +// Mono.Cairo.GlitzSurface.cs +// +// Authors: +// Alp Toker +// +// (C) Alp Toker, 2006. +// +// 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; + +namespace Cairo { + public class GlitzSurface : Surface + { + internal GlitzSurface (IntPtr handle, bool owns) : base (handle, owns) + { + } + + public GlitzSurface (IntPtr glitz_surface) + { + surface = NativeMethods.cairo_glitz_surface_create (glitz_surface); + lock (surfaces.SyncRoot) { + surfaces [surface] = this; + } + } + } +} diff --git a/cairo/Mono.Cairo/Glyph.cs b/cairo/Mono.Cairo/Glyph.cs new file mode 100644 index 000000000..ec9c2ff38 --- /dev/null +++ b/cairo/Mono.Cairo/Glyph.cs @@ -0,0 +1,96 @@ +// +// Mono.Cairo.Glyph.cs +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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 Glyph + { + internal long index; + internal double x; + internal double y; + + public Glyph (long index, double x, double y) + { + this.index = index; + this.x = x; + this.y = y; + } + + public long Index { + get { return index; } + set { index = value; } + } + + public double X { + get { return x; } + set { x = value; } + } + + public double Y { + get { return y; } + set { y = value; } + } + + public override bool Equals (object obj) + { + if (obj is Glyph) + return this == (Glyph)obj; + return false; + } + + public override int GetHashCode () + { + return (int) Index ^ (int) X ^ (int) Y; + } + + internal static IntPtr GlyphsToIntPtr (Glyph[] glyphs) + { + int size = Marshal.SizeOf (glyphs[0]); + IntPtr dest = Marshal.AllocHGlobal (size * glyphs.Length); + long pos = dest.ToInt64 (); + for (int i = 0; i < glyphs.Length; i++, pos += size) + Marshal.StructureToPtr (glyphs[i], (IntPtr) pos, false); + return dest; + } + + public static bool operator == (Glyph glyph, Glyph other) + { + return glyph.Index == other.Index && glyph.X == other.X && glyph.Y == other.Y; + } + + public static bool operator != (Glyph glyph, Glyph other) + { + return !(glyph == other); + } + } +} diff --git a/cairo/Mono.Cairo/Gradient.cs b/cairo/Mono.Cairo/Gradient.cs new file mode 100644 index 000000000..c15980b07 --- /dev/null +++ b/cairo/Mono.Cairo/Gradient.cs @@ -0,0 +1,65 @@ +// +// Mono.Cairo.Gradient.cs +// +// Author: Jordi Mas (jordi@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// (C) Ximian Inc, 2004. +// +// Copyright (C) 2004 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; + +namespace Cairo { + + public class Gradient : Pattern + { + protected Gradient (IntPtr handle) : base (handle) + { + } + + protected Gradient () + { + } + + public int ColorStopCount { + get { + int cnt; + NativeMethods.cairo_pattern_get_color_stop_count (pattern, out cnt); + return cnt; + } + } + + public Status AddColorStop (double offset, Cairo.Color c) + { + NativeMethods.cairo_pattern_add_color_stop_rgba (pattern, offset, c.R, c.G, c.B, c.A); + return Status; + } + + public Status AddColorStopRgb (double offset, Cairo.Color c) + { + NativeMethods.cairo_pattern_add_color_stop_rgb (pattern, offset, c.R, c.G, c.B); + return Status; + } + } +} + diff --git a/cairo/Mono.Cairo/HintMetrics.cs b/cairo/Mono.Cairo/HintMetrics.cs new file mode 100644 index 000000000..d43414240 --- /dev/null +++ b/cairo/Mono.Cairo/HintMetrics.cs @@ -0,0 +1,41 @@ +// +// Mono.Cairo.HintMetrics.cs +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum HintMetrics + { + Default, + Off, + On, + } +} diff --git a/cairo/Mono.Cairo/HintStyle.cs b/cairo/Mono.Cairo/HintStyle.cs new file mode 100644 index 000000000..bb848206e --- /dev/null +++ b/cairo/Mono.Cairo/HintStyle.cs @@ -0,0 +1,43 @@ +// +// Mono.Cairo.HintStyle.cs +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum HintStyle + { + Default, + None, + Slight, + Medium, + Full, + } +} diff --git a/cairo/Mono.Cairo/ImageSurface.cs b/cairo/Mono.Cairo/ImageSurface.cs new file mode 100644 index 000000000..bea56baf1 --- /dev/null +++ b/cairo/Mono.Cairo/ImageSurface.cs @@ -0,0 +1,110 @@ +// +// Mono.Cairo.ImageSurface.cs +// +// Authors: +// Duncan Mak +// Miguel de Icaza. +// +// (C) Ximian Inc, 2003. +// (C) Novell, Inc. 2003. +// +// This is an OO wrapper API for the Cairo API +// +// Copyright (C) 2004 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 { + + public class ImageSurface : Surface + { + internal ImageSurface (IntPtr handle, bool owns) : base (handle, owns) + { + } + + public ImageSurface (Format format, int width, int height) + { + surface = NativeMethods.cairo_image_surface_create (format, width, height); + lock (surfaces.SyncRoot){ + surfaces [surface] = this; + } + } + + public ImageSurface (ref byte[] data, Cairo.Format format, int width, int height, int stride) + { + surface = NativeMethods.cairo_image_surface_create_for_data (data, format, width, height, stride); + lock (surfaces.SyncRoot){ + surfaces [surface] = this; + } + } + + public ImageSurface (IntPtr data, Cairo.Format format, int width, int height, int stride) + { + surface = NativeMethods.cairo_image_surface_create_for_data (data, format, width, height, stride); + lock (surfaces.SyncRoot){ + surfaces [surface] = this; + } + } + + public ImageSurface (string filename) + { + surface = NativeMethods.cairo_image_surface_create_from_png (filename); + lock (surfaces.SyncRoot){ + surfaces [surface] = this; + } + } + + public int Width { + get { return NativeMethods.cairo_image_surface_get_width (surface); } + } + + public int Height { + get { return NativeMethods.cairo_image_surface_get_height (surface); } + } + + public byte[] Data { + get { + IntPtr ptr = NativeMethods.cairo_image_surface_get_data (surface); + int length = Height * Stride; + byte[] data = new byte[length]; + Marshal.Copy (ptr, data, 0, length); + return data; + } + } + + public IntPtr DataPtr { + get { + return NativeMethods.cairo_image_surface_get_data (surface); + } + } + + public Format Format { + get { return NativeMethods.cairo_image_surface_get_format (surface); } + } + + public int Stride { + get { return NativeMethods.cairo_image_surface_get_stride (surface); } + } + } +} diff --git a/cairo/Mono.Cairo/LineCap.cs b/cairo/Mono.Cairo/LineCap.cs new file mode 100644 index 000000000..57cfdec21 --- /dev/null +++ b/cairo/Mono.Cairo/LineCap.cs @@ -0,0 +1,41 @@ +// +// Mono.Cairo.LineCap.cs +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum LineCap + { + Butt, + Round, + Square, + } +} diff --git a/cairo/Mono.Cairo/LineJoin.cs b/cairo/Mono.Cairo/LineJoin.cs new file mode 100644 index 000000000..439b2a517 --- /dev/null +++ b/cairo/Mono.Cairo/LineJoin.cs @@ -0,0 +1,42 @@ +// +// Mono.Cairo.LineJoin.cs +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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; + +namespace Cairo +{ + [Serializable] + public enum LineJoin + { + Miter, + Round, + Bevel + } +} + diff --git a/cairo/Mono.Cairo/LinearGradient.cs b/cairo/Mono.Cairo/LinearGradient.cs new file mode 100644 index 000000000..58d8e21ab --- /dev/null +++ b/cairo/Mono.Cairo/LinearGradient.cs @@ -0,0 +1,60 @@ +// +// Mono.Cairo.LinearGradient.cs +// +// Author: Jordi Mas (jordi@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// (C) Ximian Inc, 2004. +// +// Copyright (C) 2004 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; + +namespace Cairo { + + public class LinearGradient : Gradient + { + internal LinearGradient (IntPtr handle) : base (handle) + { + } + + public LinearGradient (double x0, double y0, double x1, double y1) + { + pattern = NativeMethods.cairo_pattern_create_linear (x0, y0, x1, y1); + } + + public PointD[] LinearPoints { + get { + double x0, y0, x1, y1; + PointD[] points = new PointD [2]; + + NativeMethods.cairo_pattern_get_linear_points (pattern, out x0, out y0, out x1, out y1); + + points[0] = new PointD (x0, y0); + points[1] = new PointD (x1, y1); + return points; + } + } + + } +} + diff --git a/cairo/Mono.Cairo/Matrix.cs b/cairo/Mono.Cairo/Matrix.cs new file mode 100644 index 000000000..79e1f359e --- /dev/null +++ b/cairo/Mono.Cairo/Matrix.cs @@ -0,0 +1,193 @@ +// +// Mono.Cairo.Matrix.cs +// +// Author: Duncan Mak +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// Idan Gazit (idan@fastmail.fm) +// +// (C) Ximian Inc, 2003 - 2005. +// +// This is an OO wrapper API for the Cairo API +// +// Copyright (C) 2004 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 class Matrix : ICloneable + { + public double Xx; + public double Yx; + public double Xy; + public double Yy; + public double X0; + public double Y0; + + public Matrix (double xx, double yx, double xy, double yy, + double x0, double y0) + { + this.Xx = xx; this.Yx = yx; this.Xy = xy; + this.Yy = yy; this.X0 = x0; this.Y0 = y0; + } + + public Matrix () + { + this.InitIdentity (); + } + + public bool IsIdentity () + { + return (this == new Matrix ()); + } + + public void InitIdentity () + { + // this.Init(1,0,0,1,0,0); + NativeMethods.cairo_matrix_init_identity (this); + } + + public void Init (double xx, double yx, double xy, double yy, + double x0, double y0) + { + this.Xx = xx; this.Yx = yx; this.Xy = xy; + this.Yy = yy; this.X0 = x0; this.Y0 = y0; + } + + public void InitTranslate (double tx, double ty) + { + //this.Init (1, 0, 0, 1, tx, ty); + NativeMethods.cairo_matrix_init_translate (this, tx, ty); + } + + public void Translate (double tx, double ty) + { + NativeMethods.cairo_matrix_translate (this, tx, ty); + } + + public void InitScale (double sx, double sy) + { + //this.Init (sx, 0, 0, sy, 0, 0); + NativeMethods.cairo_matrix_init_scale (this, sx, sy); + } + + public void Scale (double sx, double sy) + { + NativeMethods.cairo_matrix_scale (this, sx, sy); + } + + public void InitRotate (double radians) + { + /* + double s, c; + s = Math.Sin (radians); + c = Math.Cos (radians); + this.Init (c, s, -s, c, 0, 0); + */ + NativeMethods.cairo_matrix_init_rotate (this, radians); + } + + public void Rotate (double radians) + { + NativeMethods.cairo_matrix_rotate (this, radians); + } + + public Cairo.Status Invert () + { + return NativeMethods.cairo_matrix_invert (this); + } + + public void Multiply (Matrix b) + { + Matrix a = (Matrix) this.Clone (); + NativeMethods.cairo_matrix_multiply (this, a, b); + } + + public static Matrix Multiply (Matrix a, Matrix b) { + Matrix result = new Matrix (); + NativeMethods.cairo_matrix_multiply (result, a, b); + return result; + } + + + public void TransformDistance (ref double dx, ref double dy) + { + NativeMethods.cairo_matrix_transform_distance (this, ref dx, ref dy); + } + + public void TransformPoint (ref double x, ref double y) + { + NativeMethods.cairo_matrix_transform_point (this, ref x, ref y); + } + + public override String ToString () + { + String s = String.Format ("xx:{0:##0.0#} yx:{1:##0.0#} xy:{2:##0.0#} yy:{3:##0.0#} x0:{4:##0.0#} y0:{5:##0.0#}", + this.Xx, this.Yx, this.Xy, this.Yy, this.X0, this.Y0); + return s; + } + + public static bool operator == (Matrix lhs, Matrix rhs) + { + return (lhs.Xx == rhs.Xx && + lhs.Xy == rhs.Xy && + lhs.Yx == rhs.Yx && + lhs.Yy == rhs.Yy && + lhs.X0 == rhs.X0 && + lhs.Y0 == rhs.Y0 ); + } + + public static bool operator != (Matrix lhs, Matrix rhs) + { + return !(lhs==rhs); + } + + + + public override bool Equals(object o) + { + if (! (o is Matrix)) + return false; + else + return (this == (Matrix) o); + } + + public override int GetHashCode() + { + return (int)this.Xx ^ (int)this.Xx>>32 ^ + (int)this.Xy ^ (int)this.Xy>>32 ^ + (int)this.Yx ^ (int)this.Yx>>32 ^ + (int)this.Yy ^ (int)this.Yy>>32 ^ + (int)this.X0 ^ (int)this.X0>>32 ^ + (int)this.Y0 ^ (int)this.Y0>>32; + } + + public object Clone() + { + return this.MemberwiseClone (); + } + + } +} diff --git a/cairo/Mono.Cairo/NativeMethods.cs b/cairo/Mono.Cairo/NativeMethods.cs new file mode 100644 index 000000000..64bc4dd65 --- /dev/null +++ b/cairo/Mono.Cairo/NativeMethods.cs @@ -0,0 +1,794 @@ +// +// Cairo.cs - a simplistic binding of the Cairo API to C#. +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// John Luke (john.luke@gmail.com) +// Alp Toker (alp@atoker.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// Copyright (C) 2005 John Luke +// Copyright (C) 2006 Alp Toker +// +// 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 +{ + // sort these so it is easier to find what is missing + // http://www.cairographics.org/manual/ix01.html + + public static class NativeMethods + { + const string cairo = "libcairo-2.dll"; + + //[DllImport (cairo)] + //internal static extern void cairo_append_path (IntPtr cr, Path path); + + [DllImport (cairo)] + internal static extern void cairo_arc (IntPtr cr, double xc, double yc, double radius, double angle1, double angle2); + + [DllImport (cairo)] + internal static extern void cairo_arc_negative (IntPtr cr, double xc, double yc, double radius, double angle1, double angle2); + + [DllImport (cairo)] + internal static extern IntPtr cairo_atsui_font_face_create_for_atsu_font_id (IntPtr font_id); + + [DllImport (cairo)] + internal static extern void cairo_clip (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_clip_preserve (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_clip_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2); + + [DllImport (cairo)] + internal static extern void cairo_close_path (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_copy_page (IntPtr cr); + + [DllImport (cairo)] + internal static extern IntPtr cairo_copy_path (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); + + [DllImport (cairo)] + internal static extern uint cairo_get_reference_count (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_curve_to (IntPtr cr, double x1, double y1, double x2, double y2, double x3, double y3); + + [DllImport (cairo)] + internal static extern void cairo_debug_reset_static_data (); + + [DllImport (cairo)] + internal static extern void cairo_destroy (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_device_to_user (IntPtr cr, ref double x, ref double y); + + [DllImport (cairo)] + internal static extern void cairo_device_to_user_distance (IntPtr cr, ref double dx, ref double dy); + + [DllImport (cairo)] + internal static extern void cairo_fill (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_fill_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2); + + [DllImport (cairo)] + internal static extern void cairo_fill_preserve (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_font_extents (IntPtr cr, out FontExtents extents); + + // FontFace + [DllImport (cairo)] + internal static extern void cairo_font_face_destroy (IntPtr font_face); + + [DllImport (cairo)] + internal static extern FontType cairo_font_face_get_type (IntPtr font_face); + + //[DllImport (cairo)] + //internal static extern void cairo_font_face_get_user_data (IntPtr font_face); + + //[DllImport (cairo)] + //internal static extern void cairo_font_face_set_user_data (IntPtr font_face); + + [DllImport (cairo)] + internal static extern IntPtr cairo_font_face_reference (IntPtr font_face); + + [DllImport (cairo)] + internal static extern Status cairo_font_face_status (IntPtr font_face); + + [DllImport (cairo)] + internal static extern uint cairo_font_face_get_reference_count (IntPtr surface); + + // FontOptions + [DllImport (cairo)] + internal static extern IntPtr cairo_font_options_copy (IntPtr original); + + [DllImport (cairo)] + internal static extern IntPtr cairo_font_options_create (); + + [DllImport (cairo)] + internal static extern void cairo_font_options_destroy (IntPtr options); + + [DllImport (cairo)] + [return: MarshalAs (UnmanagedType.U1)] + internal static extern bool cairo_font_options_equal (IntPtr options, IntPtr other); + + [DllImport (cairo)] + internal static extern Antialias cairo_font_options_get_antialias (IntPtr options); + + [DllImport (cairo)] + internal static extern HintMetrics cairo_font_options_get_hint_metrics (IntPtr options); + + [DllImport (cairo)] + internal static extern HintStyle cairo_font_options_get_hint_style (IntPtr options); + + [DllImport (cairo)] + internal static extern SubpixelOrder cairo_font_options_get_subpixel_order (IntPtr options); + + [DllImport (cairo)] + internal static extern long cairo_font_options_hash (IntPtr options); + + [DllImport (cairo)] + internal static extern void cairo_font_options_merge (IntPtr options, IntPtr other); + + [DllImport (cairo)] + internal static extern void cairo_font_options_set_antialias (IntPtr options, Antialias aa); + + [DllImport (cairo)] + internal static extern void cairo_font_options_set_hint_metrics (IntPtr options, HintMetrics metrics); + + [DllImport (cairo)] + internal static extern void cairo_font_options_set_hint_style (IntPtr options, HintStyle style); + + [DllImport (cairo)] + internal static extern void cairo_font_options_set_subpixel_order (IntPtr options, SubpixelOrder order); + + [DllImport (cairo)] + internal static extern Status cairo_font_options_status (IntPtr options); + + // Freetype / FontConfig + [DllImport (cairo)] + internal static extern IntPtr cairo_ft_font_face_create_for_ft_face (IntPtr face, int load_flags); + + [DllImport (cairo)] + internal static extern IntPtr cairo_ft_font_face_create_for_pattern (IntPtr fc_pattern); + + [DllImport (cairo)] + internal static extern void cairo_ft_font_options_substitute (FontOptions options, IntPtr pattern); + + [DllImport (cairo)] + internal static extern IntPtr cairo_ft_scaled_font_lock_face (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern void cairo_ft_scaled_font_unlock_face (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern Antialias cairo_get_antialias (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_get_current_point (IntPtr cr, out double x, out double y); + + [DllImport (cairo)] + internal static extern FillRule cairo_get_fill_rule (IntPtr cr); + + [DllImport (cairo)] + internal static extern IntPtr cairo_get_font_face (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_get_font_matrix (IntPtr cr, out Matrix matrix); + + [DllImport (cairo)] + internal static extern void cairo_get_font_options (IntPtr cr, IntPtr options); + + [DllImport (cairo)] + internal static extern IntPtr cairo_get_group_target (IntPtr cr); + + [DllImport (cairo)] + internal static extern LineCap cairo_get_line_cap (IntPtr cr); + + [DllImport (cairo)] + internal static extern LineJoin cairo_get_line_join (IntPtr cr); + + [DllImport (cairo)] + internal static extern double cairo_get_line_width (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_get_matrix (IntPtr cr, Matrix matrix); + + [DllImport (cairo)] + internal static extern double cairo_get_miter_limit (IntPtr cr); + + [DllImport (cairo)] + internal static extern Operator cairo_get_operator (IntPtr cr); + + [DllImport (cairo)] + internal static extern IntPtr cairo_get_source (IntPtr cr); + + [DllImport (cairo)] + internal static extern IntPtr cairo_get_target (IntPtr cr); + + [DllImport (cairo)] + internal static extern double cairo_get_tolerance (IntPtr cr); + + [DllImport (cairo)] + internal static extern IntPtr cairo_glitz_surface_create (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_glyph_extents (IntPtr cr, IntPtr glyphs, int num_glyphs, out TextExtents extents); + + [DllImport (cairo)] + internal static extern void cairo_glyph_path (IntPtr cr, IntPtr glyphs, int num_glyphs); + + [DllImport (cairo)] + internal static extern void cairo_identity_matrix (IntPtr cr); + + // ImageSurface + [DllImport (cairo)] + internal static extern IntPtr cairo_image_surface_create (Cairo.Format format, int width, int height); + + [DllImport (cairo)] + internal static extern IntPtr cairo_image_surface_create_for_data (byte[] data, Cairo.Format format, int width, int height, int stride); + + [DllImport (cairo)] + internal static extern IntPtr cairo_image_surface_create_for_data (IntPtr data, Cairo.Format format, int width, int height, int stride); + + [DllImport (cairo)] + internal static extern IntPtr cairo_image_surface_create_from_png (string filename); + + //[DllImport (cairo)] + //internal static extern IntPtr cairo_image_surface_create_from_png_stream (string filename); + + [DllImport (cairo)] + internal static extern IntPtr cairo_image_surface_get_data (IntPtr surface); + + [DllImport (cairo)] + internal static extern Format cairo_image_surface_get_format (IntPtr surface); + + [DllImport (cairo)] + internal static extern int cairo_image_surface_get_height (IntPtr surface); + + [DllImport (cairo)] + internal static extern int cairo_image_surface_get_stride (IntPtr surface); + + [DllImport (cairo)] + internal static extern int cairo_image_surface_get_width (IntPtr surface); + + [DllImport (cairo)] + internal static extern uint cairo_surface_get_reference_count (IntPtr surface); + + [DllImport (cairo)] + [return: MarshalAs (UnmanagedType.U1)] + internal static extern bool cairo_in_fill (IntPtr cr, double x, double y); + + [DllImport (cairo)] + [return: MarshalAs (UnmanagedType.U1)] + internal static extern bool cairo_in_stroke (IntPtr cr, double x, double y); + + [DllImport (cairo)] + internal static extern void cairo_line_to (IntPtr cr, double x, double y); + + [DllImport (cairo)] + internal static extern void cairo_mask (IntPtr cr, IntPtr pattern); + + [DllImport (cairo)] + internal static extern void cairo_mask_surface (IntPtr cr, IntPtr surface, double x, double y); + + // Matrix + [DllImport (cairo)] + internal static extern void cairo_matrix_init (Matrix matrix, double xx, double yx, double xy, double yy, double x0, double y0); + + [DllImport (cairo)] + internal static extern void cairo_matrix_init_identity (Matrix matrix); + + [DllImport (cairo)] + internal static extern void cairo_matrix_init_rotate (Matrix matrix, double radians); + + [DllImport (cairo)] + internal static extern void cairo_matrix_init_scale (Matrix matrix, double sx, double sy); + + [DllImport (cairo)] + internal static extern void cairo_matrix_init_translate (Matrix matrix, double tx, double ty); + + [DllImport (cairo)] + internal static extern Status cairo_matrix_invert (Matrix matrix); + + [DllImport (cairo)] + internal static extern void cairo_matrix_multiply (Matrix result, Matrix a, Matrix b); + + [DllImport (cairo)] + internal static extern void cairo_matrix_scale (Matrix matrix, double sx, double sy); + + [DllImport (cairo)] + internal static extern void cairo_matrix_rotate (Matrix matrix, double radians); + + [DllImport (cairo)] + internal static extern void cairo_matrix_transform_distance (Matrix matrix, ref double dx, ref double dy); + + [DllImport (cairo)] + internal static extern void cairo_matrix_transform_point (Matrix matrix, ref double x, ref double y); + + [DllImport (cairo)] + internal static extern void cairo_matrix_translate (Matrix matrix, double tx, double ty); + + [DllImport (cairo)] + internal static extern void cairo_move_to (IntPtr cr, double x, double y); + + [DllImport (cairo)] + internal static extern void cairo_new_path (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_new_sub_path (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_paint (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_paint_with_alpha (IntPtr cr, double alpha); + + [DllImport (cairo)] + internal static extern void cairo_path_destroy (IntPtr path); + + // Pattern + [DllImport (cairo)] + internal static extern void cairo_pattern_add_color_stop_rgb (IntPtr pattern, double offset, double red, double green, double blue); + + [DllImport (cairo)] + internal static extern void cairo_pattern_add_color_stop_rgba (IntPtr pattern, double offset, double red, double green, double blue, double alpha); + + [DllImport (cairo)] + internal static extern Status cairo_pattern_get_color_stop_count (IntPtr pattern, out int count); + [DllImport (cairo)] + internal static extern Status cairo_pattern_get_color_stop_rgba (IntPtr pattern, int index, out double offset, out double red, out double green, out double blue, out double alpha); + + [DllImport (cairo)] + internal static extern IntPtr cairo_pattern_create_for_surface (IntPtr surface); + + [DllImport (cairo)] + internal static extern Status cairo_pattern_get_surface (IntPtr pattern, out IntPtr surface); + + [DllImport (cairo)] + internal static extern IntPtr cairo_pattern_create_linear (double x0, double y0, double x1, double y1); + + [DllImport (cairo)] + internal static extern Status cairo_pattern_get_linear_points (IntPtr pattern, out double x0, out double y0, out double x1, out double y1); + + [DllImport (cairo)] + internal static extern IntPtr cairo_pattern_create_radial (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1); + + [DllImport (cairo)] + internal static extern Status cairo_pattern_get_radial_circles (IntPtr pattern, out double x0, out double y0, out double r0, out double x1, out double y1, out double r1); + + [DllImport (cairo)] + internal static extern IntPtr cairo_pattern_create_rgb (double r, double g, double b); + + [DllImport (cairo)] + internal static extern IntPtr cairo_pattern_create_rgba (double r, double g, double b, double a); + + [DllImport (cairo)] + internal static extern Status cairo_pattern_get_rgba (IntPtr pattern, out double red, out double green, out double blue, out double alpha); + + [DllImport (cairo)] + internal static extern void cairo_pattern_destroy (IntPtr pattern); + + [DllImport (cairo)] + internal static extern Extend cairo_pattern_get_extend (IntPtr pattern); + + [DllImport (cairo)] + internal static extern Filter cairo_pattern_get_filter (IntPtr pattern); + + [DllImport (cairo)] + internal static extern void cairo_pattern_get_matrix (IntPtr pattern, Matrix matrix); + + [DllImport (cairo)] + internal static extern PatternType cairo_pattern_get_type (IntPtr pattern); + + [DllImport (cairo)] + internal static extern IntPtr cairo_pattern_reference (IntPtr pattern); + + [DllImport (cairo)] + internal static extern void cairo_pattern_set_extend (IntPtr pattern, Extend extend); + + [DllImport (cairo)] + internal static extern void cairo_pattern_set_filter (IntPtr pattern, Filter filter); + + [DllImport (cairo)] + internal static extern void cairo_pattern_set_matrix (IntPtr pattern, Matrix matrix); + + [DllImport (cairo)] + internal static extern Status cairo_pattern_status (IntPtr pattern); + + // PdfSurface + [DllImport (cairo)] + internal static extern IntPtr cairo_pdf_surface_create (string filename, double width, double height); + + //[DllImport (cairo)] + //internal static extern IntPtr cairo_pdf_surface_create_for_stream (string filename, double width, double height); + + [DllImport (cairo)] + internal static extern void cairo_pdf_surface_set_size (IntPtr surface, double x, double y); + + // PostscriptSurface + [DllImport (cairo)] + internal static extern IntPtr cairo_ps_surface_create (string filename, double width, double height); + + //[DllImport (cairo)] + //internal static extern IntPtr cairo_ps_surface_create_for_stream (string filename, double width, double height); + [DllImport (cairo)] + internal static extern void cairo_ps_surface_begin_page_setup (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_ps_surface_begin_setup (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_ps_surface_dsc_comment (IntPtr surface, string comment); + + [DllImport (cairo)] + internal static extern void cairo_ps_surface_set_size (IntPtr surface, double x, double y); + + [DllImport (cairo)] + internal static extern IntPtr cairo_pop_group (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_pop_group_to_source (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_push_group (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_push_group_with_content (IntPtr cr, Content content); + + [DllImport (cairo)] + internal static extern IntPtr cairo_quartz_surface_create (IntPtr context, bool flipped, int width, int height); + + [DllImport (cairo)] + internal static extern void cairo_rectangle (IntPtr cr, double x, double y, double width, double height); + + [DllImport (cairo)] + internal static extern void cairo_reference (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_rel_curve_to (IntPtr cr, double dx1, double dy1, double dx2, double dy2, double dx3, double dy3); + + [DllImport (cairo)] + internal static extern void cairo_rel_line_to (IntPtr cr, double dx, double dy); + + [DllImport (cairo)] + internal static extern void cairo_rel_move_to (IntPtr cr, double dx, double dy); + + [DllImport (cairo)] + internal static extern void cairo_reset_clip (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_restore (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_rotate (IntPtr cr, double angle); + + [DllImport (cairo)] + internal static extern void cairo_save (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_scale (IntPtr cr, double sx, double sy); + + // ScaledFont + [DllImport (cairo)] + internal static extern IntPtr cairo_scaled_font_create (IntPtr fontFace, Matrix matrix, Matrix ctm, IntPtr options); + + [DllImport (cairo)] + internal static extern IntPtr cairo_scaled_font_destroy (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern void cairo_scaled_font_extents (IntPtr scaled_font, out FontExtents extents); + + [DllImport (cairo)] + internal static extern void cairo_scaled_font_get_ctm (IntPtr scaled_font, out Matrix matrix); + + [DllImport (cairo)] + internal static extern IntPtr cairo_scaled_font_get_font_face (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern void cairo_scaled_font_get_font_matrix (IntPtr scaled_font, out Matrix matrix); + + [DllImport (cairo)] + internal static extern IntPtr cairo_scaled_font_get_font_options (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern FontType cairo_scaled_font_get_type (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern void cairo_scaled_font_glyph_extents (IntPtr scaled_font, IntPtr glyphs, int num_glyphs, out TextExtents extents); + + [DllImport (cairo)] + internal static extern IntPtr cairo_scaled_font_reference (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern Status cairo_scaled_font_status (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern void cairo_set_scaled_font (IntPtr cr, IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern IntPtr cairo_get_scaled_font (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_scaled_font_text_extents (IntPtr scaled_font, string utf8, out TextExtents extents); + + [DllImport (cairo)] + internal static extern void cairo_select_font_face (IntPtr cr, string family, FontSlant slant, FontWeight weight); + + [DllImport (cairo)] + internal static extern void cairo_set_antialias (IntPtr cr, Antialias antialias); + + [DllImport (cairo)] + internal static extern void cairo_set_dash (IntPtr cr, double [] dashes, int ndash, double offset); + + [DllImport (cairo)] + internal static extern void cairo_get_dash (IntPtr cr, IntPtr dashes, out double offset); + + [DllImport (cairo)] + internal static extern int cairo_get_dash_count (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_set_fill_rule (IntPtr cr, Cairo.FillRule fill_rule); + + [DllImport (cairo)] + internal static extern void cairo_set_font_face (IntPtr cr, IntPtr fontFace); + + [DllImport (cairo)] + internal static extern void cairo_set_font_matrix (IntPtr cr, Matrix matrix); + + [DllImport (cairo)] + internal static extern void cairo_set_font_options (IntPtr cr, IntPtr options); + + [DllImport (cairo)] + internal static extern void cairo_set_font_size (IntPtr cr, double size); + + [DllImport (cairo)] + internal static extern void cairo_set_line_cap (IntPtr cr, LineCap line_cap); + + [DllImport (cairo)] + internal static extern void cairo_set_line_join (IntPtr cr, LineJoin line_join); + + [DllImport (cairo)] + internal static extern void cairo_set_line_width (IntPtr cr, double width); + + [DllImport (cairo)] + internal static extern void cairo_set_matrix (IntPtr cr, Matrix matrix); + + [DllImport (cairo)] + internal static extern void cairo_set_miter_limit (IntPtr cr, double limit); + + [DllImport (cairo)] + internal static extern void cairo_set_operator (IntPtr cr, Cairo.Operator op); + + [DllImport (cairo)] + internal static extern void cairo_set_source (IntPtr cr, IntPtr pattern); + + [DllImport (cairo)] + internal static extern void cairo_set_source_rgb (IntPtr cr, double red, double green, double blue); + + [DllImport (cairo)] + internal static extern void cairo_set_source_rgba (IntPtr cr, double red, double green, double blue, double alpha); + + [DllImport (cairo)] + internal static extern void cairo_set_source_surface (IntPtr cr, IntPtr surface, double x, double y); + + [DllImport (cairo)] + internal static extern void cairo_set_tolerance (IntPtr cr, double tolerance); + + [DllImport (cairo)] + internal static extern void cairo_show_glyphs (IntPtr ct, IntPtr glyphs, int num_glyphs); + + [DllImport (cairo)] + internal static extern void cairo_show_page (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_show_text (IntPtr cr, string utf8); + + [DllImport (cairo)] + internal static extern Status cairo_status (IntPtr cr); + + [DllImport (cairo)] + internal static extern IntPtr cairo_status_to_string (Status status); + + [DllImport (cairo)] + internal static extern void cairo_stroke (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_stroke_extents (IntPtr cr, out double x1, out double y1, out double x2, out double y2); + + [DllImport (cairo)] + internal static extern void cairo_stroke_preserve (IntPtr cr); + + [DllImport (cairo)] + internal static extern void cairo_rectangle_list_destroy (IntPtr rectangle_list); + + [DllImport (cairo)] + internal static extern IntPtr cairo_copy_clip_rectangle_list (IntPtr cr); + + // Surface + [DllImport (cairo)] + internal static extern IntPtr cairo_surface_create_similar (IntPtr surface, Cairo.Content content, int width, int height); + + [DllImport (cairo)] + internal static extern void cairo_surface_destroy (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_surface_finish (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_surface_flush (IntPtr surface); + + [DllImport (cairo)] + internal static extern Content cairo_surface_get_content (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_surface_get_device_offset (IntPtr surface, out double x, out double y); + + [DllImport (cairo)] + internal static extern void cairo_surface_get_font_options (IntPtr surface, IntPtr FontOptions); + + [DllImport (cairo)] + internal static extern SurfaceType cairo_surface_get_type (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_surface_mark_dirty (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_surface_mark_dirty_rectangle (IntPtr surface, int x, int y, int width, int height); + + [DllImport (cairo)] + internal static extern IntPtr cairo_surface_reference (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_surface_set_device_offset (IntPtr surface, double x, double y); + + [DllImport (cairo)] + internal static extern void cairo_surface_set_fallback_resolution (IntPtr surface, double x, double y); + + [DllImport (cairo)] + internal static extern Status cairo_surface_status (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_surface_write_to_png (IntPtr surface, string filename); + + //[DllImport (cairo)] + //internal static extern void cairo_surface_write_to_png_stream (IntPtr surface, WriteFunc writeFunc); + + [DllImport (cairo)] + internal static extern IntPtr cairo_svg_surface_create (string fileName, double width, double height); + + //[DllImport (cairo)] + //internal static extern IntPtr cairo_svg_surface_create_for_stream (double width, double height); + + [DllImport (cairo)] + internal static extern IntPtr cairo_svg_surface_restrict_to_version (IntPtr surface, SvgVersion version); + + [DllImport (cairo)] + internal static extern void cairo_text_extents (IntPtr cr, string utf8, out TextExtents extents); + + [DllImport (cairo)] + internal static extern void cairo_text_path (IntPtr ct, string utf8); + + [DllImport (cairo)] + internal static extern void cairo_transform (IntPtr cr, Matrix matrix); + + [DllImport (cairo)] + internal static extern void cairo_translate (IntPtr cr, double tx, double ty); + + [DllImport (cairo)] + internal static extern void cairo_user_to_device (IntPtr cr, ref double x, ref double y); + + [DllImport (cairo)] + internal static extern void cairo_user_to_device_distance (IntPtr cr, ref double dx, ref double dy); + + [DllImport (cairo)] + internal static extern int cairo_version (); + + [DllImport (cairo)] + internal static extern IntPtr cairo_version_string (); + + // DirectFBSurface + [DllImport (cairo)] + internal static extern IntPtr cairo_directfb_surface_create (IntPtr dfb, IntPtr surface); + + // win32 fonts + [DllImport (cairo)] + internal static extern IntPtr cairo_win32_font_face_create_for_logfontw (IntPtr logfontw); + + [DllImport (cairo)] + internal static extern void cairo_win32_scaled_font_done_font (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern double cairo_win32_scaled_font_get_metrics_factor (IntPtr scaled_font); + + [DllImport (cairo)] + internal static extern Status cairo_win32_scaled_font_select_font (IntPtr scaled_font, IntPtr hdc); + + // win32 surface + [DllImport (cairo)] + internal static extern IntPtr cairo_win32_surface_create (IntPtr hdc); + + [DllImport (cairo)] + internal static extern IntPtr cairo_win32_surface_create_with_ddb (IntPtr hdc, Format format, int width, int height); + + // XcbSurface + [DllImport (cairo)] + internal static extern IntPtr cairo_xcb_surface_create (IntPtr connection, uint drawable, IntPtr visual, int width, int height); + + [DllImport (cairo)] + internal static extern IntPtr cairo_xcb_surface_create_for_bitmap (IntPtr connection, uint bitmap, IntPtr screen, int width, int height); + + [DllImport (cairo)] + internal static extern void cairo_xcb_surface_set_size (IntPtr surface, int width, int height); + + // XlibSurface + [DllImport (cairo)] + internal static extern IntPtr cairo_xlib_surface_create (IntPtr display, IntPtr drawable, IntPtr visual, int width, int height); + + [DllImport (cairo)] + internal static extern IntPtr cairo_xlib_surface_create_for_bitmap (IntPtr display, IntPtr bitmap, IntPtr screen, int width, int height); + + [DllImport (cairo)] + internal static extern int cairo_xlib_surface_get_depth (IntPtr surface); + + [DllImport (cairo)] + internal static extern IntPtr cairo_xlib_surface_get_display (IntPtr surface); + + [DllImport (cairo)] + internal static extern IntPtr cairo_xlib_surface_get_drawable (IntPtr surface); + + [DllImport (cairo)] + internal static extern int cairo_xlib_surface_get_height (IntPtr surface); + + [DllImport (cairo)] + internal static extern IntPtr cairo_xlib_surface_get_screen (IntPtr surface); + + [DllImport (cairo)] + internal static extern IntPtr cairo_xlib_surface_get_visual (IntPtr surface); + + [DllImport (cairo)] + internal static extern int cairo_xlib_surface_get_width (IntPtr surface); + + [DllImport (cairo)] + internal static extern void cairo_xlib_surface_set_drawable (IntPtr surface, IntPtr drawable, int width, int height); + + [DllImport (cairo)] + internal static extern void cairo_xlib_surface_set_size (IntPtr surface, int width, int height); + } +} diff --git a/cairo/Mono.Cairo/Operator.cs b/cairo/Mono.Cairo/Operator.cs new file mode 100644 index 000000000..c1ced71d9 --- /dev/null +++ b/cairo/Mono.Cairo/Operator.cs @@ -0,0 +1,56 @@ +// +// Mono.Cairo.Operator.cs +// +// Authors: Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// John Luke (john.luke@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// Copyright (C) 2005 John Luke +// +// 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; + +namespace Cairo +{ + [Serializable] + public enum Operator + { + Clear, + Source, + Over, + In, + Out, + Atop, + + Dest, + DestOver, + DestIn, + DestOut, + DestAtop, + + Xor, + Add, + Saturate, + } +} diff --git a/cairo/Mono.Cairo/PSSurface.cs b/cairo/Mono.Cairo/PSSurface.cs new file mode 100644 index 000000000..1304be623 --- /dev/null +++ b/cairo/Mono.Cairo/PSSurface.cs @@ -0,0 +1,67 @@ +// +// Mono.Cairo.PostscriptSurface.cs +// +// Authors: +// John Luke +// +// (C) John Luke, 2006. +// +// 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; + +namespace Cairo { + + public class PSSurface : Surface + { + internal PSSurface (IntPtr handle, bool owns) : base (handle, owns) + { + } + + public PSSurface (string filename, double width, double height) + { + surface = NativeMethods.cairo_ps_surface_create (filename, width, height); + lock (surfaces.SyncRoot){ + surfaces [surface] = this; + } + } + + public void BeginPageSetup () + { + NativeMethods.cairo_ps_surface_begin_page_setup (surface); + } + + public void BeginSetup () + { + NativeMethods.cairo_ps_surface_begin_setup (surface); + } + + public void DscComment (string comment) + { + NativeMethods.cairo_ps_surface_dsc_comment (surface, comment); + } + + public void SetSize (double width, double height) + { + NativeMethods.cairo_ps_surface_set_size (surface, width, height); + } + } +} diff --git a/cairo/Mono.Cairo/Path.cs b/cairo/Mono.Cairo/Path.cs new file mode 100644 index 000000000..6afed4ef2 --- /dev/null +++ b/cairo/Mono.Cairo/Path.cs @@ -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; + } + } +} diff --git a/cairo/Mono.Cairo/Pattern.cs b/cairo/Mono.Cairo/Pattern.cs new file mode 100644 index 000000000..80a180ee3 --- /dev/null +++ b/cairo/Mono.Cairo/Pattern.cs @@ -0,0 +1,141 @@ +// +// Mono.Cairo.Pattern.cs +// +// Author: Jordi Mas (jordi@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// (C) Ximian Inc, 2004. +// +// Copyright (C) 2004 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.Collections; + +namespace Cairo { + + public class Pattern : IDisposable + { + protected IntPtr pattern = IntPtr.Zero; + + internal static Pattern Lookup (IntPtr pattern) + { + if (pattern == IntPtr.Zero) + return null; + + object x = patterns [pattern]; + if (x != null) + return (Pattern) x; + + PatternType pt = NativeMethods.cairo_pattern_get_type (pattern); + switch (pt) { + case PatternType.Solid: + return new SolidPattern (pattern); + case PatternType.Surface: + return new SurfacePattern (pattern); + case PatternType.Linear: + return new LinearGradient (pattern); + case PatternType.Radial: + return new RadialGradient (pattern); + default: + return new Pattern (pattern); + } + } + + protected Pattern () + { + } + + static Hashtable patterns = new Hashtable (); + + internal Pattern (IntPtr ptr) + { + lock (patterns){ + patterns [ptr] = this; + } + pattern = ptr; + } + + ~Pattern () + { + } + + [Obsolete ("Use the SurfacePattern constructor")] + public Pattern (Surface surface) + { + pattern = NativeMethods.cairo_pattern_create_for_surface (surface.Handle); + } + + protected void Reference () + { + NativeMethods.cairo_pattern_reference (pattern); + } + + void IDisposable.Dispose () + { + Dispose (true); + } + + protected virtual void Dispose (bool disposing) + { + if (disposing) + Destroy (); + GC.SuppressFinalize (this); + } + + public void Destroy () + { + if (pattern != IntPtr.Zero){ + NativeMethods.cairo_pattern_destroy (pattern); + pattern = IntPtr.Zero; + } + lock (patterns){ + patterns.Remove (this); + } + } + + public Status Status + { + get { return NativeMethods.cairo_pattern_status (pattern); } + } + + public Matrix Matrix { + set { + NativeMethods.cairo_pattern_set_matrix (pattern, value); + } + + get { + Matrix m = new Matrix (); + NativeMethods.cairo_pattern_get_matrix (pattern, m); + return m; + } + } + + public IntPtr Pointer { + get { return pattern; } + } + + public PatternType PatternType { + get { return NativeMethods.cairo_pattern_get_type (pattern); } + } + } +} + diff --git a/cairo/Mono.Cairo/PatternType.cs b/cairo/Mono.Cairo/PatternType.cs new file mode 100644 index 000000000..002469ffd --- /dev/null +++ b/cairo/Mono.Cairo/PatternType.cs @@ -0,0 +1,42 @@ +// +// Mono.Cairo.PatternType.cs +// +// Authors: +// John Luke +// +// (C) John Luke, 2006. +// +// 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; + +namespace Cairo { + + [Serializable] + public enum PatternType + { + Solid, + Surface, + Linear, + Radial, + } +} + diff --git a/cairo/Mono.Cairo/PdfSurface.cs b/cairo/Mono.Cairo/PdfSurface.cs new file mode 100644 index 000000000..f3a184bb5 --- /dev/null +++ b/cairo/Mono.Cairo/PdfSurface.cs @@ -0,0 +1,53 @@ +// +// Mono.Cairo.PdfSurface.cs +// +// Authors: +// John Luke +// +// (C) John Luke, 2006. +// +// 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; + +namespace Cairo { + + public class PdfSurface : Surface + { + internal PdfSurface (IntPtr handle, bool owns) : base (handle, owns) + { + } + + public PdfSurface (string filename, double width, double height) + { + surface = NativeMethods.cairo_pdf_surface_create (filename, width, height); + lock (surfaces.SyncRoot){ + surfaces [surface] = this; + } + } + + public void SetSize (double width, double height) + { + NativeMethods.cairo_pdf_surface_set_size (surface, width, height); + } + } +} + diff --git a/cairo/Mono.Cairo/RadialGradient.cs b/cairo/Mono.Cairo/RadialGradient.cs new file mode 100644 index 000000000..df9c32905 --- /dev/null +++ b/cairo/Mono.Cairo/RadialGradient.cs @@ -0,0 +1,46 @@ +// +// Mono.Cairo.Pattern.cs +// +// Author: Jordi Mas (jordi@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// (C) Ximian Inc, 2004. +// +// Copyright (C) 2004 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; + +namespace Cairo { + + public class RadialGradient : Gradient + { + internal RadialGradient (IntPtr handle) : base (handle) + { + } + + public RadialGradient (double cx0, double cy0, double radius0, double cx1, double cy1, double radius1) + { + pattern = NativeMethods.cairo_pattern_create_radial (cx0, cy0, radius0, cx1, cy1, radius1); + } + } +} + diff --git a/cairo/Mono.Cairo/Rectangle.cs b/cairo/Mono.Cairo/Rectangle.cs new file mode 100644 index 000000000..233a1bacf --- /dev/null +++ b/cairo/Mono.Cairo/Rectangle.cs @@ -0,0 +1,99 @@ +// +// Mono.Cairo.Rectangle.cs +// +// Author: +// John Luke (john.luke@gmail.com) +// +// (C) John Luke 2005. +// +// 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; + +namespace Cairo +{ + public struct Rectangle + { + double x; + double y; + double width; + double height; + + public Rectangle (double x, double y, double width, double height) + { + this.x = x; + this.y = y; + this.width = width; + this.height = height; + } + + public Rectangle (Point point, double width, double height) + { + x = point.X; + y = point.Y; + this.width = width; + this.height = height; + } + + public double X { + get { return x; } + } + + public double Y { + get { return y; } + } + + public double Width { + get { return width; } + } + + public double Height { + get { return height; } + } + + public override bool Equals (object obj) + { + if (obj is Rectangle) + return this == (Rectangle)obj; + return false; + } + + public override int GetHashCode () + { + return (int) (x + y + width + height); + } + + public override string ToString () + { + return String.Format ("x:{0} y:{1} w:{2} h:{3}", x, y, width, height); + } + + public static bool operator == (Rectangle rectangle, Rectangle other) + { + return rectangle.X == other.X && rectangle.Y == other.Y && rectangle.Width == other.Width && rectangle.Height == other.Height; + } + + public static bool operator != (Rectangle rectangle, Rectangle other) + { + return !(rectangle == other); + } + } +} diff --git a/cairo/Mono.Cairo/ScaledFont.cs b/cairo/Mono.Cairo/ScaledFont.cs new file mode 100644 index 000000000..8ac48f384 --- /dev/null +++ b/cairo/Mono.Cairo/ScaledFont.cs @@ -0,0 +1,114 @@ +// +// Mono.Cairo.ScaledFont.cs +// +// (c) 2008 Jordi Mas i Hernandez (jordimash@gmail.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 { + + public class ScaledFont : IDisposable + { + protected IntPtr handle = IntPtr.Zero; + + internal ScaledFont (IntPtr handle) + { + this.handle = handle; + } + + public ScaledFont (FontFace fontFace, Matrix matrix, Matrix ctm, FontOptions options) + { + handle = NativeMethods.cairo_scaled_font_create (fontFace.Handle, matrix, ctm, options.Handle); + } + + ~ScaledFont () + { + Dispose (false); + } + + public IntPtr Handle { + get { + return handle; + } + } + + public FontExtents FontExtents { + get { + FontExtents extents; + NativeMethods.cairo_scaled_font_extents (handle, out extents); + return extents; + } + } + + public Matrix FontMatrix { + get { + Matrix m; + NativeMethods.cairo_scaled_font_get_font_matrix (handle, out m); + return m; + } + } + + public FontType FontType { + get { + return NativeMethods.cairo_scaled_font_get_type (handle); + } + } + + public TextExtents GlyphExtents (Glyph[] glyphs) + { + IntPtr ptr = Context.FromGlyphToUnManagedMemory (glyphs); + TextExtents extents; + + NativeMethods.cairo_scaled_font_glyph_extents (handle, ptr, glyphs.Length, out extents); + + Marshal.FreeHGlobal (ptr); + return extents; + } + + public Status Status + { + get { return NativeMethods.cairo_scaled_font_status (handle); } + } + + void IDisposable.Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + if (disposing) { + NativeMethods.cairo_scaled_font_destroy (handle); + handle = IntPtr.Zero; + } + } + + protected void Reference () + { + NativeMethods.cairo_scaled_font_reference (handle); + } + } +} + diff --git a/cairo/Mono.Cairo/SolidPattern.cs b/cairo/Mono.Cairo/SolidPattern.cs new file mode 100644 index 000000000..44dba86a9 --- /dev/null +++ b/cairo/Mono.Cairo/SolidPattern.cs @@ -0,0 +1,73 @@ +// +// Mono.Cairo.Pattern.cs +// +// Author: Jordi Mas (jordi@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// (C) Ximian Inc, 2004. +// +// Copyright (C) 2004 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; + +namespace Cairo { + + public class SolidPattern : Pattern + { + internal SolidPattern (IntPtr handle) : base (handle) + { + } + + public SolidPattern (Color color) + { + pattern = NativeMethods.cairo_pattern_create_rgba (color.R, color.G, color.B, color.A); + } + + public SolidPattern (double r, double g, double b) + { + pattern = NativeMethods.cairo_pattern_create_rgb (r, g, b); + } + + public SolidPattern (double r, double g, double b, double a) + { + NativeMethods.cairo_pattern_create_rgba (r, g, b, a); + } + + public SolidPattern (Color color, bool solid) + { + if (solid) + pattern = NativeMethods.cairo_pattern_create_rgb (color.R, color.G, color.B); + else + pattern = NativeMethods.cairo_pattern_create_rgba (color.R, color.G, color.B, color.A); + } + + public Color Color { + get { + double red, green, blue, alpha; + + NativeMethods.cairo_pattern_get_rgba (pattern, out red, out green, out blue, out alpha); + return new Color (red, green, blue, alpha); + } + } + } +} + diff --git a/cairo/Mono.Cairo/Status.cs b/cairo/Mono.Cairo/Status.cs new file mode 100644 index 000000000..6e5fbe015 --- /dev/null +++ b/cairo/Mono.Cairo/Status.cs @@ -0,0 +1,64 @@ +// +// Mono.Cairo.Status.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// John Luke (john.luke@gmail.com) +// Alp Toker (alp@atoker.com) +// +// Copyright (C) 2004 Novell, Inc (http://www.novell.com) +// Copyright (C) 2005 John Luke +// +// 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; + +namespace Cairo +{ + [Serializable] + public enum Status + { + Success = 0, + NoMemory, + InvalidRestore, + InvalidPopGroup, + NoCurrentPoint, + InvalidMatrix, + InvalidStatus, + NullPointer, + InvalidString, + InvalidPathData, + ReadError, + WriteError, + SurfaceFinished, + SurfaceTypeMismatch, + PatternTypeMismatch, + InvalidContent, + InvalidFormat, + InvalidVisual, + FileNotFound, + InvalidDash, + InvalidDscComment, + InvalidIndex, + ClipNotRepresentable, + } +} diff --git a/cairo/Mono.Cairo/SubpixelOrder.cs b/cairo/Mono.Cairo/SubpixelOrder.cs new file mode 100644 index 000000000..e8ab65813 --- /dev/null +++ b/cairo/Mono.Cairo/SubpixelOrder.cs @@ -0,0 +1,42 @@ +// +// Mono.Cairo.Cairo.cs +// +// Authors: +// John Luke (john.luke@gmail.com) +// +// Copyright (C) John Luke 2005 +// +// 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; + +namespace Cairo +{ + [Serializable] + public enum SubpixelOrder + { + Default, + Rgb, + Bgr, + Vrgb, + Vbgr, + } +} diff --git a/cairo/Mono.Cairo/Surface.cs b/cairo/Mono.Cairo/Surface.cs new file mode 100644 index 000000000..e1a54da47 --- /dev/null +++ b/cairo/Mono.Cairo/Surface.cs @@ -0,0 +1,237 @@ +// +// Mono.Cairo.Surface.cs +// +// Authors: +// Duncan Mak +// Miguel de Icaza. +// Alp Toker +// +// (C) Ximian Inc, 2003. +// (C) Novell, Inc. 2003. +// +// This is an OO wrapper API for the Cairo API +// +// Copyright (C) 2004 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.Collections; + +namespace Cairo { + + public class Surface : IDisposable + { + protected static Hashtable surfaces = new Hashtable (); + internal IntPtr surface = IntPtr.Zero; + + protected Surface() + { + } + + protected Surface (IntPtr ptr, bool owns) + { + surface = ptr; + lock (surfaces.SyncRoot){ + surfaces [ptr] = this; + } + if (!owns) + NativeMethods.cairo_surface_reference (ptr); + } + + static internal Surface LookupExternalSurface (IntPtr p) + { + lock (surfaces.SyncRoot){ + object o = surfaces [p]; + if (o == null){ + return new Surface (p, false); + } + return (Surface) o; + } + } + + static internal Surface LookupSurface (IntPtr surface) + { + SurfaceType st = NativeMethods.cairo_surface_get_type (surface); + switch (st) { + case SurfaceType.Image: + return new ImageSurface (surface, true); + case SurfaceType.Xlib: + return new XlibSurface (surface, true); + case SurfaceType.Xcb: + return new XcbSurface (surface, true); + case SurfaceType.Glitz: + return new GlitzSurface (surface, true); + case SurfaceType.Win32: + return new Win32Surface (surface, true); + + case SurfaceType.Pdf: + return new PdfSurface (surface, true); + case SurfaceType.PS: + return new PSSurface (surface, true); + case SurfaceType.DirectFB: + return new DirectFBSurface (surface, true); + case SurfaceType.Svg: + return new SvgSurface (surface, true); + + default: + return Surface.LookupExternalSurface (surface); + } + } + + [Obsolete ("Use an ImageSurface constructor instead.")] + public static Cairo.Surface CreateForImage ( + ref byte[] data, Cairo.Format format, int width, int height, int stride) + { + IntPtr p = NativeMethods.cairo_image_surface_create_for_data ( + data, format, width, height, stride); + + return new Cairo.Surface (p, true); + } + + [Obsolete ("Use an ImageSurface constructor instead.")] + public static Cairo.Surface CreateForImage ( + Cairo.Format format, int width, int height) + { + IntPtr p = NativeMethods.cairo_image_surface_create ( + format, width, height); + + return new Cairo.Surface (p, true); + } + + + public Cairo.Surface CreateSimilar ( + Cairo.Content content, int width, int height) + { + IntPtr p = NativeMethods.cairo_surface_create_similar ( + this.Handle, content, width, height); + + return new Cairo.Surface (p, true); + } + + ~Surface () + { + Dispose (false); + } + + //[Obsolete ("Use Context.SetSource() followed by Context.Paint()")] + public void Show (Context gr, double x, double y) + { + NativeMethods.cairo_set_source_surface (gr.Handle, surface, x, y); + NativeMethods.cairo_paint (gr.Handle); + } + + void IDisposable.Dispose () + { + Dispose (true); + GC.SuppressFinalize (this); + } + + protected virtual void Dispose (bool disposing) + { + if (surface == IntPtr.Zero) + return; + + lock (surfaces.SyncRoot) + surfaces.Remove (surface); + + NativeMethods.cairo_surface_destroy (surface); + surface = IntPtr.Zero; + } + + public Status Finish () + { + NativeMethods.cairo_surface_finish (surface); + return Status; + } + + public void Flush () + { + NativeMethods.cairo_surface_flush (surface); + } + + public void MarkDirty () + { + NativeMethods.cairo_surface_mark_dirty (Handle); + } + + public void MarkDirty (Rectangle rectangle) + { + NativeMethods.cairo_surface_mark_dirty_rectangle (Handle, (int)rectangle.X, (int)rectangle.Y, (int)rectangle.Width, (int)rectangle.Height); + } + + public IntPtr Handle { + get { + return surface; + } + } + + public PointD DeviceOffset { + get { + double x, y; + NativeMethods.cairo_surface_get_device_offset (surface, out x, out y); + return new PointD (x, y); + } + + set { + NativeMethods.cairo_surface_set_device_offset (surface, value.X, value.Y); + } + } + + public void Destroy() + { + Dispose (true); + } + + public void SetFallbackResolution (double x, double y) + { + NativeMethods.cairo_surface_set_fallback_resolution (surface, x, y); + } + + public void WriteToPng (string filename) + { + NativeMethods.cairo_surface_write_to_png (surface, filename); + } + + [Obsolete ("Use Handle instead.")] + public IntPtr Pointer { + get { + return surface; + } + } + + public Status Status { + get { return NativeMethods.cairo_surface_status (surface); } + } + + public Content Content { + get { return NativeMethods.cairo_surface_get_content (surface); } + } + + public SurfaceType SurfaceType { + get { return NativeMethods.cairo_surface_get_type (surface); } + } + + public uint ReferenceCount { + get { return NativeMethods.cairo_surface_get_reference_count (surface); } + } + } +} diff --git a/cairo/Mono.Cairo/SurfacePattern.cs b/cairo/Mono.Cairo/SurfacePattern.cs new file mode 100644 index 000000000..f4f4298c5 --- /dev/null +++ b/cairo/Mono.Cairo/SurfacePattern.cs @@ -0,0 +1,56 @@ +// +// Mono.Cairo.Pattern.cs +// +// Author: Jordi Mas (jordi@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// (C) Ximian Inc, 2004. +// +// Copyright (C) 2004 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; + +namespace Cairo { + + public class SurfacePattern : Pattern + { + internal SurfacePattern (IntPtr handle) : base (handle) + { + } + + public SurfacePattern (Surface surface) + { + pattern = NativeMethods.cairo_pattern_create_for_surface (surface.Handle); + } + + public Extend Extend { + set { NativeMethods.cairo_pattern_set_extend (pattern, value); } + get { return NativeMethods.cairo_pattern_get_extend (pattern); } + } + + public Filter Filter { + set { NativeMethods.cairo_pattern_set_filter (pattern, value); } + get { return NativeMethods.cairo_pattern_get_filter (pattern); } + } + } +} + diff --git a/cairo/Mono.Cairo/SurfaceType.cs b/cairo/Mono.Cairo/SurfaceType.cs new file mode 100644 index 000000000..83dd4b684 --- /dev/null +++ b/cairo/Mono.Cairo/SurfaceType.cs @@ -0,0 +1,48 @@ +// +// Mono.Cairo.SurfaceType.cs +// +// Authors: +// John Luke +// +// (C) John Luke, 2006. +// +// 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; + +namespace Cairo { + + [Serializable] + public enum SurfaceType + { + Image, + Pdf, + PS, + Xlib, + Xcb, + Glitz, + Quartz, + Win32, + BeOS, + DirectFB, + Svg, + } +} diff --git a/cairo/Mono.Cairo/SvgSurface.cs b/cairo/Mono.Cairo/SvgSurface.cs new file mode 100644 index 000000000..10da981e0 --- /dev/null +++ b/cairo/Mono.Cairo/SvgSurface.cs @@ -0,0 +1,53 @@ +// +// Mono.Cairo.SvgSurface.cs +// +// Authors: +// John Luke +// +// (C) John Luke, 2006. +// +// 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; + +namespace Cairo { + + public class SvgSurface : Surface + { + internal SvgSurface (IntPtr handle, bool owns) : base (handle, owns) + { + } + + public SvgSurface (string filename, double width, double height) + { + surface = NativeMethods.cairo_svg_surface_create (filename, width, height); + lock (surfaces.SyncRoot){ + surfaces [surface] = this; + } + } + + public void RestrictToVersion (SvgVersion version) + { + NativeMethods.cairo_svg_surface_restrict_to_version (surface, version); + } + } +} + diff --git a/cairo/Mono.Cairo/SvgVersion.cs b/cairo/Mono.Cairo/SvgVersion.cs new file mode 100644 index 000000000..99cee2896 --- /dev/null +++ b/cairo/Mono.Cairo/SvgVersion.cs @@ -0,0 +1,41 @@ +// +// Mono.Cairo.SvgVersion.cs +// +// Authors: +// John Luke +// +// (C) John Luke, 2006. +// +// 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; + +namespace Cairo { + + [Serializable] + public enum SvgVersion + { + // FIXME: yuck + OnePointOne = 0, + OnePointTwo, + } +} + diff --git a/cairo/Mono.Cairo/TextExtents.cs b/cairo/Mono.Cairo/TextExtents.cs new file mode 100644 index 000000000..f9cd560f3 --- /dev/null +++ b/cairo/Mono.Cairo/TextExtents.cs @@ -0,0 +1,98 @@ +// +// Mono.Cairo.TextExtents.cs +// +// Authors: +// Duncan Mak (duncan@ximian.com) +// Hisham Mardam Bey (hisham.mardambey@gmail.com) +// +// (C) Ximian, Inc. 2003 +// Copyright (C) 2004 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 TextExtents + { + double xbearing; + double ybearing; + double width; + double height; + double xadvance; + double yadvance; + + public double XBearing { + get { return xbearing; } + set { xbearing = value; } + } + + public double YBearing { + get { return ybearing; } + set { ybearing = value; } + } + + public double Width { + get { return width; } + set { width = value; } + } + + public double Height { + get { return height; } + set { height = value; } + } + + public double XAdvance { + get { return xadvance; } + set { xadvance = value; } + } + + public double YAdvance { + get { return yadvance; } + set { yadvance = value; } + } + + public override bool Equals (object obj) + { + if (obj is TextExtents) + return this == (TextExtents)obj; + return false; + } + + public override int GetHashCode () + { + return (int)XBearing ^ (int)YBearing ^ (int)Width ^ (int)Height ^ (int)XAdvance ^ (int)YAdvance; + } + + public static bool operator == (TextExtents extents, TextExtents other) + { + return extents.XBearing == other.XBearing && extents.YBearing == other.YBearing && extents.Width == other.Width && extents.Height == other.Height && extents.XAdvance == other.XAdvance && extents.YAdvance == other.YAdvance; + } + + public static bool operator != (TextExtents extents, TextExtents other) + { + return !(extents == other); + } + } +} diff --git a/cairo/Mono.Cairo/Win32Surface.cs b/cairo/Mono.Cairo/Win32Surface.cs new file mode 100644 index 000000000..fbb22270a --- /dev/null +++ b/cairo/Mono.Cairo/Win32Surface.cs @@ -0,0 +1,48 @@ +// +// Mono.Cairo.Win32Surface.cs +// +// Authors: +// John Luke +// +// (C) John Luke, 2006. +// +// 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; + +namespace Cairo { + + public class Win32Surface : Surface + { + internal Win32Surface (IntPtr handle, bool owns) : base (handle, owns) + { + } + + public Win32Surface (IntPtr hdc) + { + surface = NativeMethods.cairo_win32_surface_create (hdc); + lock (surfaces.SyncRoot) { + surfaces [surface] = this; + } + } + } + +} diff --git a/cairo/Mono.Cairo/XcbSurface.cs b/cairo/Mono.Cairo/XcbSurface.cs new file mode 100644 index 000000000..97f5f2f6f --- /dev/null +++ b/cairo/Mono.Cairo/XcbSurface.cs @@ -0,0 +1,59 @@ +// +// Mono.Cairo.XcbSurface.cs +// +// Authors: +// Alp Toker +// +// (C) Alp Toker, 2006. +// +// 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; + +namespace Cairo { + public class XcbSurface : Surface + { + internal XcbSurface (IntPtr handle, bool owns) : base (handle, owns) + { + } + + public XcbSurface (IntPtr connection, uint drawable, IntPtr visual, int width, int height) + { + surface = NativeMethods.cairo_xcb_surface_create (connection, drawable, visual, width, height); + lock (surfaces.SyncRoot) { + surfaces [surface] = this; + } + } + + public static XcbSurface FromBitmap (IntPtr connection, uint bitmap, IntPtr screen, int width, int height) + { + IntPtr ptr; + + ptr = NativeMethods.cairo_xcb_surface_create_for_bitmap (connection, bitmap, screen, width, height); + return new XcbSurface (ptr, true); + } + + public void SetSize (int width, int height) + { + NativeMethods.cairo_xcb_surface_set_size (surface, width, height); + } + } +} diff --git a/cairo/Mono.Cairo/XlibSurface.cs b/cairo/Mono.Cairo/XlibSurface.cs new file mode 100644 index 000000000..ef010feea --- /dev/null +++ b/cairo/Mono.Cairo/XlibSurface.cs @@ -0,0 +1,100 @@ +// +// Mono.Cairo.XlibSurface.cs +// +// Authors: +// Duncan Mak +// Miguel de Icaza. +// +// (C) Ximian Inc, 2003. +// (C) Novell, Inc. 2003. +// +// This is an OO wrapper API for the Cairo API +// +// Copyright (C) 2004 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; + +namespace Cairo { + + public class XlibSurface : Surface + { + public XlibSurface (IntPtr display, IntPtr drawable, IntPtr visual, int width, int height) + { + surface = NativeMethods.cairo_xlib_surface_create (display, drawable, visual, width, height); + lock (surfaces.SyncRoot){ + surfaces [surface] = this; + } + } + + public XlibSurface (IntPtr ptr, bool own) : base (ptr, own) + { + } + + public static XlibSurface FromBitmap (IntPtr display, IntPtr bitmap, IntPtr screen, int width, int height) + { + IntPtr ptr; + + ptr = NativeMethods.cairo_xlib_surface_create_for_bitmap (display, bitmap, screen, width, height); + return new XlibSurface(ptr, true); + } + + public void SetDrawable (IntPtr drawable, int width, int height) + { + NativeMethods.cairo_xlib_surface_set_drawable (surface, drawable, width, height); + } + + public void SetSize (int width, int height) + { + NativeMethods.cairo_xlib_surface_set_size (surface, width, height); + } + + public int Depth { + get { return NativeMethods.cairo_xlib_surface_get_depth (surface); } + } + + public IntPtr Display { + get { return NativeMethods.cairo_xlib_surface_get_display (surface); } + } + + public IntPtr Drawable { + get { return NativeMethods.cairo_xlib_surface_get_drawable (surface); } + } + + public int Height { + get { return NativeMethods.cairo_xlib_surface_get_height (surface); } + } + + public IntPtr Screen { + get { return NativeMethods.cairo_xlib_surface_get_screen (surface); } + } + + public IntPtr Visual { + get { return NativeMethods.cairo_xlib_surface_get_visual (surface); } + } + + public int Width { + get { return NativeMethods.cairo_xlib_surface_get_width (surface); } + } + + } +} diff --git a/configure.in.in b/configure.in.in index 2208c2553..1f3008dbd 100644 --- a/configure.in.in +++ b/configure.in.in @@ -168,10 +168,6 @@ AC_SUBST(GENERATED_SOURCES) PKG_CHECK_MODULES(MONO_CAIRO, mono-cairo >= $MONO_REQUIRED_VERSION, has_mono_cairo=true, has_mono_cairo=false) AC_SUBST(MONO_CAIRO_LIBS) -if test "x$has_mono_cairo" = "xfalse" -a "x$API_VERSION" = "x2.8.0.0"; then - AC_MSG_ERROR([You need to install Mono.Cairo.dll and its pkgconfig file or set PKG_CONFIG_PATH to find it.]) -fi - GTK_REQUIRED_VERSION=@GTK_REQUIRED_VERSION@ PKG_CHECK_MODULES(GLIB, gobject-2.0 >= $GTK_REQUIRED_VERSION) @@ -207,6 +203,7 @@ fi AC_SUBST(MDASSEMBLER) AC_SUBST(MONODOCER) +AM_CONDITIONAL(ENABLE_MONO_CAIRO, test "x$has_mono_cairo" = "xfalse") AM_CONDITIONAL(ENABLE_GLADE, test "x$enable_glade" = "xyes") AM_CONDITIONAL(ENABLE_DOTNET, test "x$enable_dotnet" = "xyes") AM_CONDITIONAL(ENABLE_MONODOC, test "x$enable_monodoc" = "xyes") @@ -229,6 +226,7 @@ glib/Makefile glib/glib-sharp-2.0.pc glib/glib-sharp.dll.config glib/glue/Makefile +cairo/Makefile pango/Makefile pango/pango-sharp.dll.config pango/glue/Makefile diff --git a/gdk/Makefile.am b/gdk/Makefile.am index adc21f646..f74b3ce7e 100644 --- a/gdk/Makefile.am +++ b/gdk/Makefile.am @@ -1,10 +1,16 @@ 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 ../pango/pango-api.xml METADATA = Gdk.metadata -references = ../glib/glib-sharp.dll ../pango/pango-sharp.dll +references = ../glib/glib-sharp.dll ../pango/pango-sharp.dll $(local_mono_cairo) glue_includes = gdk/gdk.h sources = \ diff --git a/gtk/Makefile.am b/gtk/Makefile.am index 5e7b3ac22..2ee56e04c 100644 --- a/gtk/Makefile.am +++ b/gtk/Makefile.am @@ -1,5 +1,11 @@ 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-2.0.pc @@ -7,7 +13,7 @@ pkgconfig_DATA=gtk-sharp-2.0.pc SYMBOLS = gtk-symbols.xml INCLUDE_API = $(srcdir)/../glib/glib-api.xml ../pango/pango-api.xml ../atk/atk-api.xml ../gdk/gdk-api.xml METADATA = Gtk.metadata -references = ../glib/glib-sharp.dll ../pango/pango-sharp.dll ../atk/atk-sharp.dll ../gdk/gdk-sharp.dll +references = ../glib/glib-sharp.dll ../pango/pango-sharp.dll ../atk/atk-sharp.dll ../gdk/gdk-sharp.dll $(local_mono_cairo) glue_includes = gtk/gtk.h sources = \ diff --git a/pango/Makefile.am b/pango/Makefile.am index e5655c131..38b726296 100644 --- a/pango/Makefile.am +++ b/pango/Makefile.am @@ -1,9 +1,15 @@ 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 SYMBOLS = pango-symbols.xml -references = ../glib/glib-sharp.dll +references = ../glib/glib-sharp.dll $(local_mono_cairo) glue_includes = pango/pango.h sources = \ diff --git a/sample/GtkDemo/Makefile.am b/sample/GtkDemo/Makefile.am index 20e7d4910..f7b1da29e 100644 --- a/sample/GtkDemo/Makefile.am +++ b/sample/GtkDemo/Makefile.am @@ -1,4 +1,14 @@ -assemblies = ../../glib/glib-sharp.dll ../../pango/pango-sharp.dll ../../atk/atk-sharp.dll ../../gdk/gdk-sharp.dll ../../gtk/gtk-sharp.dll +if ENABLE_MONO_CAIRO +local_mono_cairo=$(top_builddir)/cairo/Mono.Cairo.dll +else +local_mono_cairo= +endif + +assemblies = \ + $(top_builddir)/glib/glib-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 $(local_mono_cairo) + references = $(addprefix /r:, $(assemblies)) @MONO_CAIRO_LIBS@ TARGETS = GtkDemo.exe DEBUGS = $(addsuffix .mdb, $(TARGETS))