From c30257b17dd958335f1e7029e520213cc08f6011 Mon Sep 17 00:00:00 2001 From: Sebastien Pouliot Date: Wed, 22 Mar 2006 20:22:00 +0000 Subject: [PATCH] 2006-03-22 Sebastien Pouliot * 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 --- .../System.Drawing.Drawing2D/ChangeLog | 7 ++ .../System.Drawing.Drawing2D/GraphicsPath.cs | 66 ++++++++++++------- .../LinearGradientBrush.cs | 27 +++++--- 3 files changed, 67 insertions(+), 33 deletions(-) diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog index dfcaa158eb4..3b33bc8de77 100644 --- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog +++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/ChangeLog @@ -1,3 +1,10 @@ +2006-03-22 Sebastien Pouliot + + * 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 * Matrix.cs: Add missing checks to methods (and fix unit tests). diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs index 0da90f4e7de..d8832e2e0aa 100644 --- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs +++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/GraphicsPath.cs @@ -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); diff --git a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs index 88bfcc8744f..abdc54637b5 100644 --- a/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs +++ b/mcs/class/System.Drawing/System.Drawing.Drawing2D/LinearGradientBrush.cs @@ -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 @@ -29,19 +28,18 @@ // 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 description for LinearGradientBrush. - /// 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); } } } -- 2.25.1