fixes GetStringFormatTabStops and adds member to test it
authorJordi Mas i Hernandez <jordi@mono-cvs.ximian.com>
Tue, 9 Mar 2004 19:55:25 +0000 (19:55 -0000)
committerJordi Mas i Hernandez <jordi@mono-cvs.ximian.com>
Tue, 9 Mar 2004 19:55:25 +0000 (19:55 -0000)
svn path=/trunk/mcs/; revision=23843

mcs/class/System.Drawing/System.Drawing/StringFormat.cs
mcs/class/System.Drawing/System.Drawing/gdipFunctions.cs
mcs/class/System.Drawing/Test/System.Drawing/TestStringFormat.cs

index b6b7865c497d6b939c4298dc9f71c79175e26a8e..5a10cbdc8da374ac2eceae98af6627248b28f0e7 100644 (file)
@@ -219,11 +219,13 @@ namespace System.Drawing
                         int count = 0;\r
                         firstTabOffset = 0;\r
                         \r
-                        GDIPlus.GdipGetStringFormatTabStopCount(nativeStrFmt, out count);\r
-                        if (count==0) return null;\r
+                        GDIPlus.GdipGetStringFormatTabStopCount(nativeStrFmt, out count);                      \r
 \r
                         float[] tabStops = new float[count];                        \r
-                        GDIPlus.GdipGetStringFormatTabStops(nativeStrFmt, count, out firstTabOffset, out tabStops);\r
+                        \r
+                        if (count!=0)                        \r
+                               GDIPlus.GdipGetStringFormatTabStops(nativeStrFmt, count, out firstTabOffset, tabStops);\r
+                               \r
                         return tabStops;                        \r
                 }\r
 \r
index a4c2230f5c7f2643aeaca12e83820b15ade74bb6..4a2a1b14b4d21cf5848c4d26f683d737b6dbb350 100644 (file)
@@ -1037,7 +1037,7 @@ namespace System.Drawing {
                 [DllImport ("gdiplus.dll")]
                 internal static extern Status GdipGetStringFormatTabStopCount(IntPtr format, out int count);
                 [DllImport ("gdiplus.dll")]
-                internal static extern Status GdipGetStringFormatTabStops(IntPtr format, int count, out float firstTabOffset, out float[] tabStops);
+                internal static extern Status GdipGetStringFormatTabStops(IntPtr format, int count, out float firstTabOffset, [In, Out] float[] tabStops);
                                
                //ImageCodecInfo functions
                [DllImport("gdiplus.dll")]
index 7156869416299597778bb1c214da27c64327dba3..8de8f8b6f8e9ead63ea66352e2e3aaaaf184ccb3 100644 (file)
@@ -30,8 +30,7 @@ namespace MonoTests.System.Drawing{
                public void TestSpecialConstructors() 
                {                               
                        StringFormat smf = StringFormat.GenericDefault;                 
-                       smf = StringFormat.GenericTypographic;                                                          
-                       
+                       smf = StringFormat.GenericTypographic;                                                                                  
                }       
                
                [Test]
@@ -68,5 +67,25 @@ namespace MonoTests.System.Drawing{
                        AssertEquals (StringFormatFlags.DisplayFormatControl, smf.FormatFlags);                                          
                }               
                
+               [Test]
+               public void TabsStops() 
+               {                               
+                       StringFormat    smf = new StringFormat ();
+                       
+                       float firstTabOffset;                   
+                       float[] tabsSrc = {100, 200, 300, 400};
+                       float[] tabStops;
+                       
+                       smf.SetTabStops(200, tabsSrc);
+                       tabStops = smf.GetTabStops(out firstTabOffset);
+                       
+                       AssertEquals (200, firstTabOffset);                                              
+                       AssertEquals (tabsSrc.Length, tabStops.Length);                                          
+                       AssertEquals (tabsSrc[0], tabStops[0]);                                 
+                       AssertEquals (tabsSrc[1], tabStops[1]);                                 
+                       AssertEquals (tabsSrc[2], tabStops[2]);                                 
+                       AssertEquals (tabsSrc[3], tabStops[3]);                                 
+               }       
+               
        }
 }