[Mono-bugs] [Bug 656193] New: Patch to fix checkable menu items' check position

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Sun Nov 28 20:02:54 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=656193

https://bugzilla.novell.com/show_bug.cgi?id=656193#c0


           Summary: Patch to fix checkable menu items' check position
    Classification: Mono
           Product: Mono: Class Libraries
           Version: 2.8.x
          Platform: x86
        OS/Version: Windows 7
            Status: NEW
          Severity: Normal
          Priority: P5 - None
         Component: Windows.Forms
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: xocotl at gmail.com
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.12)
Gecko/20101026 Firefox/3.6.12

Two things here:

ThemeWin32Classic.cs's CPDrawMenuGlyph did not draw within the requested
bounding box. I fixed this. To keep the patch short, I noticed but did not fix
another issue the old code had -- it doesn't scale correctly when the size goes
up. Luckily the only calls to it use the default 7x6 size, which explains why
nobody noticed.

As a result of CPDrawMenuGlyph not drawing in its bounding box, it appears
ToolStripProfessionalRenderer used a hard-coded draw position, presumably
because nothing algorithmic worked :) Since CPDrawMenuGlyph now draws in its
bounding box, ToolStripProfessionalRenderer can just 'center' instead of
hard-code.

The end result of this, on my PC, is to move the menu item checkmark down one
pixel, making it pixel-perfect in its blue box relative to Microsoft's
System.Windows.Forms.

The text still seems to be off vs MS SWF, that and the menu bar being two
pixels too short I will investigate next (I am using Mono for some contract
work on Windows and feel these little issues are noticeable)...

diff --git
a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
index 36e9944..68d3031 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
@@ -7165,14 +7165,13 @@ namespace System.Windows.Forms

                 Pen pen = ResPool.GetPen (color);
                 lineWidth = Math.Max (2, rectangle.Width / 6);
-                rect = new Rectangle(rectangle.X + lineWidth, rectangle.Y +
lineWidth, rectangle.Width - lineWidth * 2, rectangle.Height- lineWidth * 2);

                 int Scale = Math.Max (1, rectangle.Width / 12);
-                int top = (rect.Y + lineWidth + ((rect.Height - ((2 * Scale) +
lineWidth)) / 2));
+                int top = rectangle.Y + (rectangle.Height - lineWidth) / 2;

                 for (int i=0; i<lineWidth; i++) {
-                    graphics.DrawLine (pen, rect.Left+lineWidth/2, top+i,
rect.Left+lineWidth/2+2*Scale, top+2*Scale+i);
-                    graphics.DrawLine (pen, rect.Left+lineWidth/2+2*Scale,
top+2*Scale+i, rect.Left+lineWidth/2+6*Scale, top-2*Scale+i);
+                    graphics.DrawLine (pen, rectangle.Left+lineWidth/2, top+i,
rectangle.Left+lineWidth/2+2*Scale, top+2*Scale+i);
+                    graphics.DrawLine (pen,
rectangle.Left+lineWidth/2+2*Scale, top+2*Scale+i,
rectangle.Left+lineWidth/2+6*Scale, top-2*Scale+i);
                 }
                 return;
             }
diff --git
a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripProfessionalRenderer.cs
b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripProfessionalRenderer.cs
index cebe702..5c3e23e 100644
---
a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripProfessionalRenderer.cs
+++
b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripProfessionalRenderer.cs
@@ -206,8 +206,12 @@ namespace System.Windows.Forms
                 e.Graphics.FillRectangle
(ThemeEngine.Current.ResPool.GetSolidBrush
(this.ColorTable.CheckSelectedBackground), e.ImageRectangle);
                 e.Graphics.DrawRectangle (ThemeEngine.Current.ResPool.GetPen
(this.ColorTable.ButtonSelectedBorder), e.ImageRectangle);
             }
-            if (e.Item.Image == null)
-                ControlPaint.DrawMenuGlyph(e.Graphics, new Rectangle
(6,5,7,6), MenuGlyph.Checkmark);
+            if (e.Item.Image == null) {
+        Rectangle r = new Rectangle (e.ImageRectangle.Left +
(e.ImageRectangle.Width - 7) / 2,
+          e.ImageRectangle.Top + (e.ImageRectangle.Height - 6) / 2, 7, 6);
+          
+                ControlPaint.DrawMenuGlyph(e.Graphics, r,
MenuGlyph.Checkmark);
+      }

             base.OnRenderItemCheck (e);
         }


Reproducible: Always

Steps to Reproduce:
1.
2.
3.

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list