Author: jpobst
Date: 2007-02-23 18:25:10 -0500 (Fri, 23 Feb 2007)
New Revision: 73378

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextRenderer.cs
Log:
2007-02-23  Jonathan Pobst  <[EMAIL PROTECTED]>

        * TextRenderer.cs: Add clipping support, thanks to George.
        [Fixes bug #80949]

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-02-23 19:49:03 UTC (rev 73377)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-02-23 23:25:10 UTC (rev 73378)
@@ -1,3 +1,8 @@
+2007-02-23  Jonathan Pobst  <[EMAIL PROTECTED]>
+
+       * TextRenderer.cs: Add clipping support, thanks to George.
+       [Fixes bug #80949]
+
 2007-02-23  Gert Driesen  <[EMAIL PROTECTED]>
 
        * ListViewItem.cs: Cancel label edit when item is removed from 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextRenderer.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextRenderer.cs  
2007-02-23 19:49:03 UTC (rev 73377)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextRenderer.cs  
2007-02-23 23:25:10 UTC (rev 73378)
@@ -133,8 +133,24 @@
                                Rectangle new_bounds = PadRectangle (bounds, 
flags);
                                new_bounds.Offset ((int)(dc as 
Graphics).Transform.OffsetX, (int)(dc as Graphics).Transform.OffsetY);
 
-                               IntPtr hdc = dc.GetHdc ();
-
+                               IntPtr hdc = IntPtr.Zero;
+                       
+                               // If we need to use the graphics clipping 
region, add it to our hdc
+                               if ((flags & 
TextFormatFlags.PreserveGraphicsClipping) == 
TextFormatFlags.PreserveGraphicsClipping) {
+                                       Graphics graphics = (Graphics)dc;
+                                       Region clip_region = graphics.Clip;
+                                       
+                                       if (!clip_region.IsInfinite (graphics)) 
{
+                                               IntPtr hrgn = 
clip_region.GetHrgn (graphics);
+                                               hdc = dc.GetHdc ();
+                                               SelectClipRgn (hdc, hrgn);
+                                               clip_region.ReleaseHrgn (hrgn);
+                                       }
+                               }
+                               
+                               if (hdc == IntPtr.Zero)
+                                       hdc = dc.GetHdc ();
+                                       
                                // Set the fore color
                                if (foreColor != Color.Empty)
                                        SetTextColor (hdc, 
ColorTranslator.ToWin32 (foreColor));
@@ -433,6 +449,9 @@
 
                [DllImport ("gdi32")]
                static extern bool DeleteObject (IntPtr objectHandle);
+
+               [DllImport("gdi32")]
+               static extern bool SelectClipRgn(IntPtr hdc, IntPtr hrgn);
                #endregion
        }
 }

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to