diff options
author | Miguel de Icaza <miguel@gnome.org> | 2007-07-07 21:18:37 +0400 |
---|---|---|
committer | Miguel de Icaza <miguel@gnome.org> | 2007-07-07 21:18:37 +0400 |
commit | 7e01eb3a7877194be98b420d4aab49765addf48a (patch) | |
tree | 96d2b3f58f9b8d004bca3d367d4f143f43b88f9d /mcs/class | |
parent | c4fa66cf61bfce7a9988d76a58be126a35d8d8d1 (diff) |
2007-07-07 Miguel de Icaza <miguel@novell.com>
Integrated various patches from Alp Toker:
* Mono.Cairo/FontFace.cs: Add to the build.
* Mono.Cairo/Context.cs: Add a number of methods that are
compatible with the public Cairo API, and add commented out
Obsoletes for the names that we had.
(MaskSurface): More descriptive parameters
(SetSourceRGB, SetSourceRGBA): Removed [Obsoletes] from as those
are the public Cairo names. Use the API directly without
creating a helper Color.
(FontFace): New property.
* Mono.Cairo/FontFace.cs: Partial integration of Alp's work for
FontFace. There are two differences: no support for owns flag,
and no automatic unreffing on the finalizer thread. Instead we
display an error message.
svn path=/trunk/mcs/; revision=81562
Diffstat (limited to 'mcs/class')
-rw-r--r-- | mcs/class/Mono.Cairo/ChangeLog | 19 | ||||
-rw-r--r-- | mcs/class/Mono.Cairo/Mono.Cairo.dll.sources | 1 | ||||
-rw-r--r-- | mcs/class/Mono.Cairo/Mono.Cairo/Context.cs | 53 | ||||
-rw-r--r-- | mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs | 70 |
4 files changed, 131 insertions, 12 deletions
diff --git a/mcs/class/Mono.Cairo/ChangeLog b/mcs/class/Mono.Cairo/ChangeLog index 01a5ff3c49a..680eb2d9ea5 100644 --- a/mcs/class/Mono.Cairo/ChangeLog +++ b/mcs/class/Mono.Cairo/ChangeLog @@ -1,5 +1,24 @@ 2007-07-07 Miguel de Icaza <miguel@novell.com> + Integrated various patches from Alp Toker: + + * Mono.Cairo/Context.cs: Add a number of methods that are + compatible with the public Cairo API, and add commented out + Obsoletes for the names that we had. + + (MaskSurface): More descriptive parameters + + (SetSourceRGB, SetSourceRGBA): Removed [Obsoletes] from as those + are the public Cairo names. Use the API directly without + creating a helper Color. + + (FontFace): New property. + + * Mono.Cairo/FontFace.cs: Partial integration of Alp's work for + FontFace. There are two differences: no support for owns flag, + and no automatic unreffing on the finalizer thread. Instead we + display an error message. + * NativeMethods.cs: Split the native methods into its own file. * Mono.Cairo/Context.cs: Integrate Alp's patch to not use ref in diff --git a/mcs/class/Mono.Cairo/Mono.Cairo.dll.sources b/mcs/class/Mono.Cairo/Mono.Cairo.dll.sources index ff8b8ca650b..bf095d2f53f 100644 --- a/mcs/class/Mono.Cairo/Mono.Cairo.dll.sources +++ b/mcs/class/Mono.Cairo/Mono.Cairo.dll.sources @@ -10,6 +10,7 @@ ./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 diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/Context.cs b/mcs/class/Mono.Cairo/Mono.Cairo/Context.cs index aabd594cf2f..aebe966b1d5 100644 --- a/mcs/class/Mono.Cairo/Mono.Cairo/Context.cs +++ b/mcs/class/Mono.Cairo/Mono.Cairo/Context.cs @@ -256,8 +256,8 @@ namespace Cairo { public Cairo.Color Color { set { NativeMethods.cairo_set_source_rgba (state, value.R, - value.G, value.B, - value.A); + value.G, value.B, + value.A); } } @@ -369,16 +369,14 @@ namespace Cairo { } } - [Obsolete ("Use Color property")] public void SetSourceRGB (double r, double g, double b) { - Color = new Color (r, g, b); + NativeMethods.cairo_set_source_rgb (state, r, g, b); } - [Obsolete ("Use Color property")] public void SetSourceRGBA (double r, double g, double b, double a) { - Color = new Color (r, g, b, a); + NativeMethods.cairo_set_source_rgba (state, r, g, b, a); } //[Obsolete ("Use SetSource method (with double parameters)")] @@ -511,9 +509,9 @@ namespace Cairo { NativeMethods.cairo_mask (state, pattern.Pointer); } - public void MaskSurface (Surface surface, double x, double y) + public void MaskSurface (Surface surface, double surface_x, double surface_y) { - NativeMethods.cairo_mask_surface (state, surface.Handle, x, y); + NativeMethods.cairo_mask_surface (state, surface.Handle, surface_x, surface_y); } public void Stroke () @@ -637,27 +635,52 @@ namespace Cairo { NativeMethods.cairo_transform (state, m); } - - //FIXME: obsolete these methods +#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 { @@ -794,6 +817,16 @@ namespace Cairo { { 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) { diff --git a/mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs b/mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs index 751b7565d7f..684bf0f80e7 100644 --- a/mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs +++ b/mcs/class/Mono.Cairo/Mono.Cairo/FontFace.cs @@ -1,20 +1,86 @@ +// +// 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 + 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"); + } + + void IDisposable.Dispose () + { + 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; } + 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); |