2006-03-22 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Wed, 22 Mar 2006 20:22:00 +0000 (20:22 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Wed, 22 Mar 2006 20:22:00 +0000 (20:22 -0000)
* GraphicsPath.cs: Call [libgdiplus|GDI+] for AddString (even if it
is not yet implemented in libgdiplus).
* LinearGradientBrush.cs: Update the rectangle when using the internal
ctor. Fix a few missing validations.

svn path=/trunk/mcs/; revision=58311

mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog
mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs
mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs

index dfcaa158eb40a5da8049a11a6a044d130d87dd52..3b33bc8de774bfb2195a5ab571f6c659a53d35cd 100644 (file)
@@ -1,3 +1,10 @@
+2006-03-22  Sebastien Pouliot  <sebastien@ximian.com> 
+
+       * GraphicsPath.cs: Call [libgdiplus|GDI+] for AddString (even if it 
+       is not yet implemented in libgdiplus).
+       * LinearGradientBrush.cs: Update the rectangle when using the internal
+       ctor. Fix a few missing validations.
+
 2006-03-17  Sebastien Pouliot  <sebastien@ximian.com> 
 
        * Matrix.cs: Add missing checks to methods (and fix unit tests).
index 0da90f4e7de19161a8cc0174503a04c52edbe366..d8832e2e0aac4a7aa1cf8df3c9c67f598303ca0c 100644 (file)
@@ -610,30 +610,50 @@ namespace System.Drawing.Drawing2D
                         GDIPlus.CheckStatus (status);                          
                 }
                 
-                [MonoTODO]
-                public void AddString (string s, FontFamily family, int style,  float emSize,  Point origin,   StringFormat format)
-                {
-                       throw new NotImplementedException ();
-                }      
-                
-                [MonoTODO]
-               public void AddString (string s,  FontFamily family,  int style,  float emSize,  PointF origin,   StringFormat format)
-               {
-                       throw new NotImplementedException ();
-                }      
-               
-               [MonoTODO]
-               public void AddString (string s, FontFamily family, int style, float emSize,  Rectangle layoutRect, StringFormat format)
-               {
-                       throw new NotImplementedException ();
-                }      
-               
-               [MonoTODO]
-               public void AddString (string s, FontFamily family, int style, float emSize,  RectangleF layoutRect,   StringFormat format)
+               [MonoTODO ("GdipAddStringI isn't implemented in libgdiplus")]
+               public void AddString (string s, FontFamily family, int style, float emSize, Point origin, StringFormat format)
+               {
+                       Rectangle layout;
+                       layout.X = origin.X;
+                       layout.Y = origin.Y;
+                       AddString (s, family, style, emSize, layout, format);
+               }
+
+               [MonoTODO ("GdipAddString isn't implemented in libgdiplus")]
+               public void AddString (string s, FontFamily family, int style, float emSize, PointF origin, StringFormat format)
                {
-                       throw new NotImplementedException ();
-                }      
-                
+                       RectangleF layout;
+                       layout.X = origin.X;
+                       layout.Y = origin.Y;
+                       AddString (s, family, style, emSize, layout, format);
+                }
+
+               [MonoTODO ("GdipAddStringI isn't implemented in libgdiplus")]
+               public void AddString (string s, FontFamily family, int style, float emSize, Rectangle layoutRect, StringFormat format)
+               {
+                       if (s == null)
+                               throw new ArgumentNullException ("s");
+
+                       IntPtr ffamily = (family == null) ? IntPtr.Zero : family.NativeObject;
+                       IntPtr sformat = (format == null) ? IntPtr.Zero : format.NativeObject;
+
+                       Status status = GDIPlus.GdipAddStringI (nativePath, s, s.Length, ffamily, style, emSize, ref layoutRect, sformat);
+                       GDIPlus.CheckStatus (status);
+               }
+
+               [MonoTODO ("GdipAddString isn't implemented in libgdiplus")]
+               public void AddString (string s, FontFamily family, int style, float emSize, RectangleF layoutRect, StringFormat format)
+               {
+                       if (s == null)
+                               throw new ArgumentNullException ("s");
+
+                       IntPtr ffamily = (family == null) ? IntPtr.Zero : family.NativeObject;
+                       IntPtr sformat = (format == null) ? IntPtr.Zero : format.NativeObject;
+
+                       Status status = GDIPlus.GdipAddString (nativePath, s, s.Length, ffamily, style, emSize, ref layoutRect, sformat);
+                       GDIPlus.CheckStatus (status);
+               }
+
                public void ClearMarkers()               
                {
                        Status s = GDIPlus.GdipClearPathMarkers (nativePath);
index 88bfcc8744f47725b982db92bedef229adf8b52a..abdc54637b5b78e5997746b35e79ca9360df5823 100644 (file)
@@ -6,8 +6,7 @@
 //   Ravindra (rkumar@novell.com)
 //
 // Copyright (C) 2002/3 Ximian, Inc. http://www.ximian.com
-//
-// Copyright (C) 2004 Novell, Inc (http://www.novell.com)
+// Copyright (C) 2004,2006 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
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-using System.Drawing;
+using System.ComponentModel;
+
+namespace System.Drawing.Drawing2D {
 
-namespace System.Drawing.Drawing2D
-{
-       /// <summary>
-       /// Summary description for LinearGradientBrush.
-       /// </summary>
        public sealed class LinearGradientBrush : Brush
        {
                RectangleF rectangle;
                
                internal LinearGradientBrush (IntPtr native) : base (native)
                {
+                       Status status = GDIPlus.GdipGetLineRect (native, out rectangle);
+                       GDIPlus.CheckStatus (status);
                }
 
                public LinearGradientBrush (Point point1, Point point2, Color color1, Color color2)
@@ -236,6 +234,9 @@ namespace System.Drawing.Drawing2D
                                return matrix;
                        }
                        set {
+                               if (value == null)
+                                       throw new ArgumentNullException ("Transform");
+
                                Status status = GDIPlus.GdipSetLineTransform (nativeObject, value.nativeMatrix);
                                GDIPlus.CheckStatus (status);
                        }
@@ -250,6 +251,10 @@ namespace System.Drawing.Drawing2D
                                return wrapMode;
                        }
                        set {
+                               // note: Clamp isn't valid (context wise) but it is checked in libgdiplus
+                               if ((value < WrapMode.Tile) || (value > WrapMode.Clamp))
+                                       throw new InvalidEnumArgumentException ("WrapMode");
+
                                Status status = GDIPlus.GdipSetLineWrapMode (nativeObject, value);
                                GDIPlus.CheckStatus (status);
                        }
@@ -264,6 +269,9 @@ namespace System.Drawing.Drawing2D
 
                public void MultiplyTransform (Matrix matrix, MatrixOrder order)
                {
+                       if (matrix == null)
+                               throw new ArgumentNullException ("matrix");
+
                        Status status = GDIPlus.GdipMultiplyLineTransform (nativeObject, matrix.nativeMatrix, order);
                        GDIPlus.CheckStatus (status);
                }
@@ -341,8 +349,7 @@ namespace System.Drawing.Drawing2D
                        Status status = GDIPlus.GdipCloneBrush (nativeObject, out clonePtr);
                        GDIPlus.CheckStatus (status);
 
-                       LinearGradientBrush clone = new LinearGradientBrush (clonePtr);
-                       return clone;
+                       return new LinearGradientBrush (clonePtr);
                }
        }
 }