2008-09-24 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Wed, 24 Sep 2008 13:07:58 +0000 (13:07 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Wed, 24 Sep 2008 13:07:58 +0000 (13:07 -0000)
* ThemeWin32Classic.cs: When drawing gridlines for ListView don't use
the item bounds, since we can't iterate over them in virtual mode.
Also fix wrong calculation of the gridlines when using scrolling.
Fixes #400390.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs

index 20aa8ba14ae43de45da844e9c524c8fff8522a4c..713062f556518e4665468d76db1bc249bd691555 100644 (file)
@@ -1,3 +1,10 @@
+2008-09-24  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * ThemeWin32Classic.cs: When drawing gridlines for ListView don't use
+       the item bounds, since we can't iterate over them in virtual mode.
+       Also fix wrong calculation of the gridlines when using scrolling.
+       Fixes #400390.
+
 2008-09-23  Carlos Alberto Cortez <calberto.cortez@gmail.com>
 
        * XplatUIX11.cs: When handling EnterNotify events, take into account
index 415cc3814abe8bd7996c0cc604174eafca893a42..34e913fe83f087a8f5e10879431ab3976dcf1899 100644 (file)
@@ -2685,30 +2685,24 @@ namespace System.Windows.Forms
                        
                        // draw the gridlines
                        if (details && control.GridLines) {
+                               Size control_size = control.ClientSize;
                                int top = (control.HeaderStyle == ColumnHeaderStyle.None) ?
-                                       2 : control.Font.Height + 2;
+                                       0 : control.header_control.Height;
 
                                // draw vertical gridlines
-                               foreach (ColumnHeader col in control.Columns)
+                               foreach (ColumnHeader col in control.Columns) {
+                                       int column_right = col.Rect.Right - control.h_marker;
                                        dc.DrawLine (SystemPens.Control,
-                                                    col.Rect.Right, top,
-                                                    col.Rect.Right, control.TotalHeight);
-                               // draw horizontal gridlines
-                               ListViewItem last_item = null;
-                               foreach (ListViewItem item in control.Items) {
-                                       dc.DrawLine (SystemPens.Control,
-                                                    item.GetBounds (ItemBoundsPortion.Entire).Left, item.GetBounds (ItemBoundsPortion.Entire).Top,
-                                                    control.TotalWidth, item.GetBounds (ItemBoundsPortion.Entire).Top);
-                                       last_item = item;
+                                                    column_right, top,
+                                                    column_right, control_size.Height);
                                }
 
-                               // draw a line after at the bottom of the last item
-                               if (last_item != null) {
-                                       dc.DrawLine (SystemPens.Control,
-                                                    last_item.GetBounds (ItemBoundsPortion.Entire).Left,
-                                                    last_item.GetBounds (ItemBoundsPortion.Entire).Bottom,
-                                                    control.TotalWidth,
-                                                    last_item.GetBounds (ItemBoundsPortion.Entire).Bottom);
+                               // draw horizontal gridlines
+                               int item_height = control.ItemSize.Height;
+                               int y = top + item_height - (control.v_marker % item_height); // scroll bar offset
+                               while (y < control_size.Height) {
+                                       dc.DrawLine (SystemPens.Control, 0, y, control_size.Width, y);
+                                       y += item_height;
                                }
                        }