2009-01-06 Gonzalo Paniagua Javier <gonzalo@novell.com>
[mono.git] / mcs / class / Mono.Cairo / Mono.Cairo / FontOptions.cs
index 3c4b30f62dced6b907d14171b00d3541617d7a28..476910f1b1d35396394f8c83430a0366139aa88f 100644 (file)
@@ -25,6 +25,7 @@
 // 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
@@ -32,11 +33,11 @@ namespace Cairo
        public class FontOptions : IDisposable
        {
                IntPtr handle;
-               bool disposed = false;
+               bool disposed;
 
                public FontOptions ()
                {
-                       handle = CairoAPI.cairo_font_options_create ();
+                       handle = NativeMethods.cairo_font_options_create ();
                }
 
                ~FontOptions ()
@@ -51,12 +52,12 @@ namespace Cairo
 
                public FontOptions Copy ()
                {
-                       return new FontOptions (CairoAPI.cairo_font_options_copy (handle));
+                       return new FontOptions (NativeMethods.cairo_font_options_copy (handle));
                }
 
                public void Destroy ()
                {
-                       CairoAPI.cairo_font_options_destroy (handle);
+                       NativeMethods.cairo_font_options_destroy (handle);
                }
 
                public void Dispose ()
@@ -76,7 +77,7 @@ namespace Cairo
 
                public static bool operator == (FontOptions options, FontOptions other)
                {
-                       return CairoAPI.cairo_font_options_equal (options.Handle, other.Handle);
+                       return Equals (options, other);
                }
 
                public static bool operator != (FontOptions options, FontOptions other)
@@ -86,9 +87,12 @@ namespace Cairo
 
                public override bool Equals (object other)
                {
-                       if (other is FontOptions)
-                               return this == (FontOptions) other;
-                       return false;
+                       return Equals (other as FontOptions);
+               }
+
+               bool Equals (FontOptions options)
+               {
+                       return options != null && NativeMethods.cairo_font_options_equal (Handle, options.Handle);
                }
 
                public IntPtr Handle {
@@ -97,36 +101,38 @@ namespace Cairo
 
                public override int GetHashCode ()
                {
-                       return (int) CairoAPI.cairo_font_options_hash (handle);
+                       return (int) NativeMethods.cairo_font_options_hash (handle);
                }
                
                public void Merge (FontOptions other)
                {
-                       CairoAPI.cairo_font_options_merge (handle, other.Handle);
+                       if (other == null)
+                               throw new ArgumentNullException ("other");
+                       NativeMethods.cairo_font_options_merge (handle, other.Handle);
                }
 
                public Antialias Antialias {
-                       get { return CairoAPI.cairo_font_options_get_antialias (handle); }
-                       set { CairoAPI.cairo_font_options_set_antialias (handle, value); }
+                       get { return NativeMethods.cairo_font_options_get_antialias (handle); }
+                       set { NativeMethods.cairo_font_options_set_antialias (handle, value); }
                }
 
                public HintMetrics HintMetrics {
-                       get { return CairoAPI.cairo_font_options_get_hint_metrics (handle);}
-                       set { CairoAPI.cairo_font_options_set_hint_metrics (handle, value); }
+                       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 CairoAPI.cairo_font_options_get_hint_style (handle);}
-                       set { CairoAPI.cairo_font_options_set_hint_style (handle, value); }
+                       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 CairoAPI.cairo_font_options_status (handle); }
+                       get { return NativeMethods.cairo_font_options_status (handle); }
                }
 
                public SubpixelOrder SubpixelOrder {
-                       get { return CairoAPI.cairo_font_options_get_subpixel_order (handle);}
-                       set { CairoAPI.cairo_font_options_set_subpixel_order (handle, value); }
+                       get { return NativeMethods.cairo_font_options_get_subpixel_order (handle);}
+                       set { NativeMethods.cairo_font_options_set_subpixel_order (handle, value); }
                }
        }
 }