Author: calberto
Date: 2007-08-24 19:17:22 -0400 (Fri, 24 Aug 2007)
New Revision: 84836
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
Log:
2007-08-24 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ListView.cs: Some more code refactoring to add support sorting
with groups (now for Details view). Remove unused code also.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-08-24 23:05:15 UTC (rev 84835)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-08-24 23:17:22 UTC (rev 84836)
@@ -1,4 +1,8 @@
+2007-08-24 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+ * ListView.cs: Some more code refactoring to add support sorting
+ with groups (now for Details view). Remove unused code also.
+
2007-08-24 Jonathan Pobst <[EMAIL PROTECTED]>
* NodeLabelEditEventArgs.cs: EndEdit immediately when CancelEdit is
called.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
2007-08-24 23:05:15 UTC (rev 84835)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
2007-08-24 23:17:22 UTC (rev 84836)
@@ -1517,7 +1517,7 @@
#if NET_2_0
if (using_groups)
- CalculateGroupsLayout (sz, y_spacing);
+ CalculateGroupsLayout (sz, y_spacing, 0);
#endif
int row = 0, col = 0;
@@ -1577,9 +1577,10 @@
}
#if NET_2_0
- void CalculateGroupsLayout (Size item_size, int y_spacing)
+ void CalculateGroupsLayout (Size item_size, int y_spacing, int
y_origin)
{
- int y = 0;
+ int y = y_origin;
+ bool details = view == View.Details;
for (int i = 0; i < groups.InternalCount; i++) {
ListViewGroup group = groups.GetInternalGroup
(i);
@@ -1587,7 +1588,7 @@
continue;
group.current_item = 0; // Reset layout
- y += LayoutGroupHeader (group, y,
item_size.Height, y_spacing, group.rows);
+ y += LayoutGroupHeader (group, y,
item_size.Height, y_spacing, details ? group.ItemCount : group.rows);
}
layout_ht = y; // Update height taking into account
Groups' headers heights
@@ -1633,26 +1634,6 @@
}
}
- int LayoutDetailsSection (ListViewItemCollection
items_collection, int item_height, int y_origin, ref int current_item)
- {
- int y = y_origin;
-
- for (int i = 0; i < items_collection.Count; i++) {
- ListViewItem item = items_collection [i];
- SetItemLocation (current_item, 0, y, 0, 0);
- current_item++;
-#if NET_2_0
- if (!virtual_mode) // Virtual mode sets Layout
until draw time
-#endif
- item.Layout ();
-
- y += item_height + 2;
- }
-
- // Return height of groups section
- return (y + 10) - y_origin;
- }
-
void LayoutDetails ()
{
LayoutHeader ();
@@ -1670,27 +1651,46 @@
int item_height = GetDetailsItemHeight ();
ItemSize = new Size (0, item_height); // We only cache
Height for details view
-
int y = header_control.Height;
- int current_item = 0;
#if NET_2_0
- if (show_groups && groups.Count > 0 && view !=
View.List) {
- for (int i = 0; i < groups.Count; i++) {
- ListViewGroup group = groups [i];
- if (group.Items.Count == 0)
- continue;
+ bool using_groups = show_groups && groups.Count > 0 &&
view != View.List;
+ if (using_groups)
+ CalculateGroupsLayout (ItemSize, 2, y);
+#endif
- y += LayoutDetailsSection (group.Items,
item_height, y, ref current_item);
- }
- } else
+ for (int i = 0; i < items.Count; i++) {
+ ListViewItem item = items [i];
+#if NET_2_0
+ if (!virtual_mode) // Virtual mode sets Layout
until draw time
#endif
- y += LayoutDetailsSection (items, item_height,
y, ref current_item);
+ item.Layout ();
+#if NET_2_0
+ if (using_groups) {
+ ListViewGroup group = item.Group;
+ if (group == null)
+ group = groups.DefaultGroup;
+
+ int current_item = group.current_item++;
+ Point group_items_loc =
group.items_area_location;
+
+ SetItemLocation (i, 0, current_item *
(item_height + 2) + group_items_loc.Y, 0, 0);
+ } else
+#endif
+ {
+ SetItemLocation (i, 0, y, 0, 0);
+ y += item_height + 4;
+ }
+ }
+
// some space for bottom gridline
if (items.Count > 0 && grid_lines)
y += 2;
- layout_ht = y;
+#if NET_2_0
+ if (!using_groups) // With groups it has been
previously computed
+#endif
+ layout_ht = y;
}
private void AdjustItemsPositionArray (int count)
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches