diff options
author | Carlos Alberto Cortez <calberto.cortez@gmail.com> | 2008-10-17 09:50:10 +0400 |
---|---|---|
committer | Carlos Alberto Cortez <calberto.cortez@gmail.com> | 2008-10-17 09:50:10 +0400 |
commit | e0500805ea61736190e7afb5e58dfbf9b0e3fbc8 (patch) | |
tree | 2362e5d55828ec0d1d89220da8902d86e050e59c /mcs/class/Managed.Windows.Forms | |
parent | 7a559618d0f5598605b0b1692cf9a20e829f519f (diff) |
2008-10-17 Carlos Alberto Cortez <calberto.cortez@gmail.com>
* ColumnHeader.cs: Invalidate ListView.header_control when setting
ImageIndex/ImageKey.
* ThemeWin32Classic.cs: When drawing the column header, draw a image
for the column if available, and make the required adjustments to the
text location.
Fixes #435105.
svn path=/trunk/mcs/; revision=116165
Diffstat (limited to 'mcs/class/Managed.Windows.Forms')
3 files changed, 48 insertions, 3 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog index 93200361ee6..2c1b70c8a29 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog @@ -1,3 +1,12 @@ +2008-10-17 Carlos Alberto Cortez <calberto.cortez@gmail.com> + + * ColumnHeader.cs: Invalidate ListView.header_control when setting + ImageIndex/ImageKey. + * ThemeWin32Classic.cs: When drawing the column header, draw a image + for the column if available, and make the required adjustments to the + text location. + Fixes #435105. + 2008-10-17 Neville Gao <nevillegao@gmail.com> * StatusBarPanel.cs: Control enabled to support accessibility. diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs index 2ff57ed5aa0..2edaa99d010 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs @@ -212,6 +212,9 @@ namespace System.Windows.Forms image_index = value; image_key = String.Empty; + + if (owner != null) + owner.header_control.Invalidate (); } } @@ -228,6 +231,9 @@ namespace System.Windows.Forms set { image_key = value == null ? String.Empty : value; image_index = -1; + + if (owner != null) + owner.header_control.Invalidate (); } } 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 82c10aa6ace..0b8cedc306c 100644 --- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs +++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs @@ -2752,9 +2752,39 @@ namespace System.Windows.Forms if (rect.Width <= 0) continue; - dc.DrawString (col.Text, control.Font, - SystemBrushes.ControlText, - rect, col.Format); +#if NET_2_0 + int image_index; + if (control.SmallImageList == null) + image_index = -1; + else + image_index = col.ImageKey == String.Empty ? col.ImageIndex : control.SmallImageList.Images.IndexOfKey (col.ImageKey); + + if (image_index > -1 && image_index < control.SmallImageList.Images.Count) { + int image_width = control.SmallImageList.ImageSize.Width + 5; + int text_width = (int)dc.MeasureString (col.Text, control.Font).Width; + int x_origin = rect.X; + + switch (col.TextAlign) { + case HorizontalAlignment.Left: + break; + case HorizontalAlignment.Right: + x_origin = rect.Right - (text_width + image_width); + break; + case HorizontalAlignment.Center: + x_origin = (rect.Width - (text_width + image_width)) / 2 + rect.X; + break; + } + + if (x_origin < rect.X) + x_origin = rect.X; + + control.SmallImageList.Draw (dc, new Point (x_origin, rect.Y), image_index); + rect.X += image_width; + rect.Width -= image_width; + } +#endif + + dc.DrawString (col.Text, control.Font, SystemBrushes.ControlText, rect, col.Format); } int right = control.GetReorderedColumn (control.Columns.Count - 1).Rect.Right - control.h_marker; if (right < control.Right) { |