Author: calberto
Date: 2007-06-19 14:40:22 -0400 (Tue, 19 Jun 2007)
New Revision: 80222
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
Log:
2007-06-19 Carlos Alberto Cortez <[EMAIL PROTECTED]>
* ListViewItem.cs: Actually set bounds for subitems in Details view
(2.0 feature).
* ThemeWin32Classic.cs: Refactor the drawing code for subitems, so we
can invoke from the owner draw routines if we need it. Also, add
support for Owner draw in Details view.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-06-19 18:35:31 UTC (rev 80221)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2007-06-19 18:40:22 UTC (rev 80222)
@@ -1,3 +1,11 @@
+2007-06-19 Carlos Alberto Cortez <[EMAIL PROTECTED]>
+
+ * ListViewItem.cs: Actually set bounds for subitems in Details view
+ (2.0 feature).
+ * ThemeWin32Classic.cs: Refactor the drawing code for subitems, so we
+ can invoke from the owner draw routines if we need it. Also, add
+ support for Owner draw in Details view.
+
2007-06-18 Jonathan Pobst <[EMAIL PROTECTED]>
* ToolStripDropDownMenu.cs, ToolStripItem.cs, ToolStripLabel.cs,
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs
2007-06-19 18:35:31 UTC (rev 80221)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs
2007-06-19 18:40:22 UTC (rev 80222)
@@ -790,6 +790,13 @@
item_rect.Width += owner.Columns [i].Wd;
bounds.Width += owner.Columns [i].Wd;
}
+
+ // Bounds for sub items
+ int n = Math.Min (owner.Columns.Count,
sub_items.Count);
+ for (int i = 0; i < n; i++) {
+ Rectangle col_rect = owner.Columns
[i].Rect;
+ sub_items [i].SetBounds (col_rect.X, 0,
col_rect.Width, item_ht);
+ }
break;
case View.LargeIcon:
@@ -935,8 +942,8 @@
#if NET_2_0
private string name = String.Empty;
private object tag;
+#endif
internal Rectangle bounds;
-#endif
#region Public Constructors
public ListViewSubItem ()
@@ -976,7 +983,12 @@
}
#if NET_2_0
- public Rectangle Bounds {
+ public
+#else
+
+ internal
+#endif
+ Rectangle Bounds {
get {
Rectangle retval = bounds;
if (owner != null) {
@@ -987,7 +999,6 @@
return retval;
}
}
-#endif
[Localizable (true)]
public Font Font {
@@ -1087,7 +1098,6 @@
owner.owner.Invalidate ();
}
-#if NET_2_0
internal int Height {
get {
return bounds.Height;
@@ -1098,7 +1108,6 @@
{
bounds = new Rectangle (x, y, width, height);
}
-#endif
#endregion // Private Methods
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
2007-06-19 18:35:31 UTC (rev 80221)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
2007-06-19 18:40:22 UTC (rev 80222)
@@ -2407,7 +2407,20 @@
item, item.Bounds, index, item_state);
item.ListView.OnDrawItem (args);
- return !args.DrawDefault;
+ if (args.DrawDefault)
+ return false;
+
+ for (int i = 0; i < item.SubItems.Count; i++) {
+ int count = Math.Min
(item.ListView.Columns.Count, item.SubItems.Count);
+
+ // Do system drawing for subitems if no owner
draw is done
+ for (int j = 0; j < count; j++)
+ if (!DrawListViewSubItemOwnerDraw (dc,
item, item_state, j))
+ DrawListViewSubItem (dc,
item.ListView, item, j);
+ }
+
+ return true;
+
}
#endif
@@ -2574,71 +2587,15 @@
control.Columns.Count :
subItems.Count);
if (count > 0) {
- ColumnHeader col;
- ListViewItem.ListViewSubItem subItem;
- Rectangle sub_item_rect = text_rect;
-
- // set the format for subitems
- format.FormatFlags =
StringFormatFlags.NoWrap;
-
// 0th subitem is the item already drawn
- for (int index = 1; index < count;
index++) {
- subItem = subItems [index];
- col = control.Columns [index];
- format.Alignment =
col.Format.Alignment;
- sub_item_rect.X = col.Rect.X -
control.h_marker;
- sub_item_rect.Width = col.Wd;
- Rectangle sub_item_text_rect =
sub_item_rect;
- sub_item_text_rect.X += 3;
- sub_item_text_rect.Width -= 6;
+ for (int index = 1; index < count;
index++)
+ DrawListViewSubItem (dc,
control, item, index);
- SolidBrush sub_item_back_br =
null;
- SolidBrush sub_item_fore_br =
null;
- Font sub_item_font = null;
-
- if
(item.UseItemStyleForSubItems) {
- sub_item_back_br =
ResPool.GetSolidBrush (item.BackColor);
- sub_item_fore_br =
ResPool.GetSolidBrush (item.ForeColor);
- sub_item_font =
item.Font;
- } else {
- sub_item_back_br =
ResPool.GetSolidBrush (subItem.BackColor);
- sub_item_fore_br =
ResPool.GetSolidBrush (subItem.ForeColor);
- sub_item_font =
subItem.Font;
- }
-
- int sub_item_text_width = (int)
Math.Ceiling (control.DeviceContext.MeasureString (subItem.Text,
-
sub_item_font).Width);
-
- format.Trimming =
sub_item_text_width > sub_item_text_rect.Width ?
StringTrimming.EllipsisCharacter :
- StringTrimming.None;
-
- if (item.Selected &&
(control.Focused || !control.HideSelection) && control.FullRowSelect) {
- Brush bg, text;
- if (control.Focused) {
- bg =
SystemBrushes.Highlight;
- text =
SystemBrushes.HighlightText;
- } else {
- bg =
SystemBrushes.Control;
- text =
sub_item_fore_br;
- }
-
- dc.FillRectangle (bg,
sub_item_rect);
- if (subItem.Text !=
null && subItem.Text.Length > 0)
- dc.DrawString
(subItem.Text, sub_item_font,
-
text, sub_item_text_rect, format);
- } else {
- dc.FillRectangle
(sub_item_back_br, sub_item_rect);
- if (subItem.Text !=
null && subItem.Text.Length > 0)
- dc.DrawString
(subItem.Text, sub_item_font,
-
sub_item_fore_br,
-
sub_item_text_rect, format);
- }
- }
-
// Fill in selection for remaining
columns if Column.Count > SubItems.Count
+ ColumnHeader col;
+ Rectangle sub_item_rect = text_rect;
if (item.Selected && (control.Focused
|| !control.HideSelection) && control.FullRowSelect) {
- for (int index = count; index <
control.Columns.Count; index++)
- {
+ for (int index = count; index <
control.Columns.Count; index++) {
col = control.Columns
[index];
sub_item_rect.X =
col.Rect.X - control.h_marker;
sub_item_rect.Width =
col.Wd;
@@ -2668,6 +2625,74 @@
format.Dispose ();
}
+ protected virtual void DrawListViewSubItem (Graphics dc,
ListView control, ListViewItem item, int index)
+ {
+ ListViewItem.ListViewSubItem subItem = item.SubItems
[index];
+ ColumnHeader col = control.Columns [index];
+ StringFormat format = new StringFormat ();
+ format.Alignment = col.Format.Alignment;
+ format.FormatFlags = StringFormatFlags.NoWrap;
+ format.Trimming = StringTrimming.EllipsisCharacter;
+
+ Rectangle sub_item_rect = subItem.Bounds;
+ Rectangle sub_item_text_rect = sub_item_rect;
+ sub_item_text_rect.X += 3;
+ sub_item_text_rect.Width -= 6;
+
+ SolidBrush sub_item_back_br = null;
+ SolidBrush sub_item_fore_br = null;
+ Font sub_item_font = null;
+
+ if (item.UseItemStyleForSubItems) {
+ sub_item_back_br = ResPool.GetSolidBrush
(item.BackColor);
+ sub_item_fore_br = ResPool.GetSolidBrush
(item.ForeColor);
+ sub_item_font = item.Font;
+ } else {
+ sub_item_back_br = ResPool.GetSolidBrush
(subItem.BackColor);
+ sub_item_fore_br = ResPool.GetSolidBrush
(subItem.ForeColor);
+ sub_item_font = subItem.Font;
+ }
+
+ if (item.Selected && (control.Focused ||
!control.HideSelection) && control.FullRowSelect) {
+ Brush bg, text;
+ if (control.Focused) {
+ bg = SystemBrushes.Highlight;
+ text = SystemBrushes.HighlightText;
+ } else {
+ bg = SystemBrushes.Control;
+ text = sub_item_fore_br;
+
+ }
+
+ dc.FillRectangle (bg, sub_item_rect);
+ if (subItem.Text != null && subItem.Text.Length
> 0)
+ dc.DrawString (subItem.Text,
sub_item_font,
+ text,
sub_item_text_rect, format);
+ } else {
+ dc.FillRectangle (sub_item_back_br,
sub_item_rect);
+ if (subItem.Text != null && subItem.Text.Length
> 0)
+ dc.DrawString (subItem.Text,
sub_item_font,
+ sub_item_fore_br,
+ sub_item_text_rect,
format);
+ }
+
+ format.Dispose ();
+ }
+
+#if NET_2_0
+ protected virtual bool DrawListViewSubItemOwnerDraw (Graphics
dc, ListViewItem item, ListViewItemStates state, int index)
+ {
+ ListView control = item.ListView;
+ ListViewItem.ListViewSubItem subitem = item.SubItems
[index];
+
+ DrawListViewSubItemEventArgs args = new
DrawListViewSubItemEventArgs (dc, subitem.Bounds, item,
+ subitem, item.Index, index,
control.Columns [index], state);
+ control.OnDrawSubItem (args);
+
+ return !args.DrawDefault;
+ }
+#endif
+
// Sizing
public override Size ListViewCheckBoxSize {
get { return new Size (16, 16); }
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches