Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGeorge Giolfan <ggiolfan@mono-cvs.ximian.com>2008-06-03 22:57:44 +0400
committerGeorge Giolfan <ggiolfan@mono-cvs.ximian.com>2008-06-03 22:57:44 +0400
commitd485667d503c967095d90f4c975fdc11c45ad024 (patch)
tree56e42c841d996158f54cb132b217f693115758bc
parentfef6ae1a8b894a37406d4e26b625159c5964d69d (diff)
2008-06-03 George Giolfan <georgegiolfan@yahoo.com>
* ColumnHeader.cs: CalcColumnHeader now uses the theme to get the height. * DataGridView.cs: * EnableHeadersVisualStyles: Fixed default value. EnteredHeaderCell, PressedHeaderCell: Added. * DataGridViewCell.cs: Refactored: Extracted GetBorderPen. * DataGridViewColumnHeaderCell.cs, DataGridViewRowHeaderCell.cs: Gave the theme a chance to override default painting. * ListView.cs: Added EnteredColumnHeader. Refactored: Extracted GetColumnHeaderInvalidateArea, Invalidate(ColumnHeader). * Theme.cs, ThemeVisualStyles.cs, ThemeWin32Classic.cs: Added members for ListView and DataGridView header rendering. * DataGridViewTest.cs: Added EnableHeadersVisualStylesDefaultValue. svn path=/trunk/mcs/; revision=104778
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog13
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs4
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs79
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs9
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs14
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs21
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs63
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs20
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeVisualStyles.cs159
-rw-r--r--mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs92
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog4
-rw-r--r--mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs5
12 files changed, 453 insertions, 30 deletions
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
index 34a7182eaf7..027162b5787 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
@@ -1,3 +1,16 @@
+2008-06-03 George Giolfan <georgegiolfan@yahoo.com>
+
+ * ColumnHeader.cs: CalcColumnHeader now uses the theme to get the height.
+ * DataGridView.cs: * EnableHeadersVisualStyles: Fixed default value.
+ EnteredHeaderCell, PressedHeaderCell: Added.
+ * DataGridViewCell.cs: Refactored: Extracted GetBorderPen.
+ * DataGridViewColumnHeaderCell.cs, DataGridViewRowHeaderCell.cs: Gave the
+ theme a chance to override default painting.
+ * ListView.cs: Added EnteredColumnHeader. Refactored: Extracted
+ GetColumnHeaderInvalidateArea, Invalidate(ColumnHeader).
+ * Theme.cs, ThemeVisualStyles.cs, ThemeWin32Classic.cs: Added members for
+ ListView and DataGridView header rendering.
+
2008-06-03 Ivan N. Zlatev <contact@i-nz.net>
* RichTextBox.cs: GetPositionFromCharIndex should return the
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 c6a9b6031aa..2ff57ed5aa0 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ColumnHeader.cs
@@ -152,9 +152,9 @@ namespace System.Windows.Forms
format.FormatFlags = StringFormatFlags.NoWrap;
if (owner != null)
- column_rect.Height = owner.Font.Height + 5;
+ column_rect.Height = ThemeEngine.Current.ListViewGetHeaderHeight (owner, owner.Font);
else
- column_rect.Height = ThemeEngine.Current.DefaultFont.Height + 5;
+ column_rect.Height = ThemeEngine.Current.ListViewGetHeaderHeight (null, ThemeEngine.Current.DefaultFont);
if (width >= 0)
column_rect.Width = width;
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs
index 256a1e947b8..6c8615136f3 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridView.cs
@@ -81,7 +81,7 @@ namespace System.Windows.Forms {
private DataGridViewCellStyle defaultCellStyle;
//private Control editingControl;
private DataGridViewEditMode editMode;
- private bool enableHeadersVisualStyles;
+ private bool enableHeadersVisualStyles = true;
private DataGridViewCell firstDisplayedCell;
private int firstDisplayedScrollingColumnHiddenWidth;
private int firstDisplayedScrollingColumnIndex;
@@ -134,6 +134,9 @@ namespace System.Windows.Forms {
private int gridWidth;
private int gridHeight;
+ DataGridViewHeaderCell pressed_header_cell;
+ DataGridViewHeaderCell entered_header_cell;
+
public DataGridView ()
{
SetStyle (ControlStyles.Opaque, true);
@@ -704,6 +707,26 @@ namespace System.Windows.Forms {
set { enableHeadersVisualStyles = value; }
}
+ internal DataGridViewHeaderCell EnteredHeaderCell {
+ get { return entered_header_cell; }
+ set {
+ if (entered_header_cell == value)
+ return;
+ if (ThemeEngine.Current.DataGridViewHeaderCellHasHotStyle (this)) {
+ Region area_to_invalidate = new Region ();
+ area_to_invalidate.MakeEmpty ();
+ if (entered_header_cell != null)
+ area_to_invalidate.Union (GetHeaderCellBounds (entered_header_cell));
+ entered_header_cell = value;
+ if (entered_header_cell != null)
+ area_to_invalidate.Union (GetHeaderCellBounds (entered_header_cell));
+ Invalidate (area_to_invalidate);
+ area_to_invalidate.Dispose ();
+ } else
+ entered_header_cell = value;
+ }
+ }
+
[Browsable (false)]
[DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
public DataGridViewCell FirstDisplayedCell {
@@ -860,6 +883,10 @@ namespace System.Windows.Forms {
set { }
}
+ internal DataGridViewHeaderCell PressedHeaderCell {
+ get { return pressed_header_cell; }
+ }
+
[Browsable (true)]
[DefaultValue (false)]
public bool ReadOnly {
@@ -4015,6 +4042,10 @@ namespace System.Windows.Forms {
DoSelectionOnMouseDown (hitTest);
if (hitTest.Type != DataGridViewHitTestType.Cell) {
+ if (hitTest.Type == DataGridViewHitTestType.ColumnHeader)
+ pressed_header_cell = columns [hitTest.ColumnIndex].HeaderCell;
+ else if (hitTest.Type == DataGridViewHitTestType.RowHeader)
+ pressed_header_cell = rows [hitTest.RowIndex].HeaderCell;
Invalidate ();
return;
}
@@ -4050,6 +4081,8 @@ namespace System.Windows.Forms {
OnCellMouseLeave (new DataGridViewCellEventArgs (hover_cell.ColumnIndex, hover_cell.RowIndex));
hover_cell = null;
}
+
+ EnteredHeaderCell = null;
}
protected override void OnMouseMove (MouseEventArgs e)
@@ -4059,6 +4092,8 @@ namespace System.Windows.Forms {
HitTestInfo hit = this.HitTest (e.X, e.Y);
if (hit.Type == DataGridViewHitTestType.Cell) {
+ EnteredHeaderCell = null;
+
DataGridViewCell new_cell = GetCellInternal (hit.ColumnIndex, hit.RowIndex);
// Check if we have moved into an error icon area
@@ -4110,6 +4145,8 @@ namespace System.Windows.Forms {
} else if (hit.Type == DataGridViewHitTestType.RowHeader) {
DataGridViewRowHeaderCell new_cell = Rows[hit.RowIndex].HeaderCell;
+ EnteredHeaderCell = new_cell;
+
// Check if we have moved into an error icon area
Rectangle icon = new_cell.InternalErrorIconsBounds;
@@ -4126,6 +4163,8 @@ namespace System.Windows.Forms {
MouseLeftErrorIcon (new_cell);
}
} else if (hit.Type == DataGridViewHitTestType.TopLeftHeader) {
+ EnteredHeaderCell = null;
+
DataGridViewTopLeftHeaderCell new_cell = (DataGridViewTopLeftHeaderCell)TopLeftHeaderCell;
// Check if we have moved into an error icon area
@@ -4145,6 +4184,11 @@ namespace System.Windows.Forms {
}
} else {
+ if (hit.Type == DataGridViewHitTestType.ColumnHeader)
+ EnteredHeaderCell = Columns [hit.ColumnIndex].HeaderCell;
+ else
+ EnteredHeaderCell = null;
+
// We have left the cell area
if (hover_cell != null) {
OnCellMouseLeave (new DataGridViewCellEventArgs (hover_cell.ColumnIndex, hover_cell.RowIndex));
@@ -4163,6 +4207,13 @@ namespace System.Windows.Forms {
Rectangle display = GetCellDisplayRectangle (hit.ColumnIndex, hit.RowIndex, false);
OnCellMouseUp (new DataGridViewCellMouseEventArgs (hit.ColumnIndex, hit.RowIndex, e.X - display.X, e.Y - display.Y, e));
}
+
+ if (pressed_header_cell != null) {
+ DataGridViewHeaderCell cell = pressed_header_cell;
+ pressed_header_cell = null;
+ if (ThemeEngine.Current.DataGridViewHeaderCellHasPressedStyle (this))
+ Invalidate (GetHeaderCellBounds (cell));
+ }
}
protected override void OnMouseWheel (MouseEventArgs e)
@@ -5359,6 +5410,32 @@ namespace System.Windows.Forms {
return result;
}
+ Rectangle GetHeaderCellBounds (DataGridViewHeaderCell cell)
+ {
+ Rectangle bounds = new Rectangle (ClientRectangle.Location, cell.Size);
+ if (cell is DataGridViewColumnHeaderCell) {
+ if (RowHeadersVisible)
+ bounds.X += RowHeadersWidth;
+ List<DataGridViewColumn> sortedColumns = columns.ColumnDisplayIndexSortedArrayList;
+ for (int index = first_col_index; index < sortedColumns.Count; index++) {
+ DataGridViewColumn column = sortedColumns [index];
+ if (column.Index == cell.ColumnIndex)
+ break;
+ bounds.X += column.Width;
+ }
+ } else {
+ if (ColumnHeadersVisible)
+ bounds.Y += ColumnHeadersHeight;
+ for (int index = first_row_index; index < Rows.Count; index++) {
+ DataGridViewRow row = GetRowInternal (index);
+ if (row.HeaderCell == cell)
+ break;
+ bounds.Y += row.Height;
+ }
+ }
+ return bounds;
+ }
+
private void PrepareEditingRow (bool cell_changed, bool column_changed)
{
bool show = false;
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
index a79ad344ba3..5607a739167 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewCell.cs
@@ -1370,10 +1370,15 @@ namespace System.Windows.Forms {
Color color = style.BackColor;
graphics.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (color), cellBounds);
}
+
+ internal Pen GetBorderPen ()
+ {
+ return ThemeEngine.Current.ResPool.GetPen (DataGridView.GridColor);
+ }
- private void PaintPartBorder (Graphics graphics, Rectangle cellBounds, int rowIndex)
+ internal virtual void PaintPartBorder (Graphics graphics, Rectangle cellBounds, int rowIndex)
{
- Pen p = ThemeEngine.Current.ResPool.GetPen (DataGridView.GridColor);
+ Pen p = GetBorderPen ();
if (columnIndex == -1) {
graphics.DrawLine (p, cellBounds.Left, cellBounds.Top, cellBounds.Left, cellBounds.Bottom - 1);
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs
index 2ec152451f6..6171526a0af 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewColumnHeaderCell.cs
@@ -228,6 +228,20 @@ namespace System.Windows.Forms {
base.Paint (graphics, clipBounds, cellBounds, rowIndex, dataGridViewElementState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, post);
}
+ internal override void PaintPartBackground (Graphics graphics, Rectangle cellBounds, DataGridViewCellStyle style)
+ {
+ if (ThemeEngine.Current.DataGridViewColumnHeaderCellDrawBackground (this, graphics, cellBounds))
+ return;
+ base.PaintPartBackground (graphics, cellBounds, style);
+ }
+
+ internal override void PaintPartBorder (Graphics graphics, Rectangle cellBounds, int rowIndex)
+ {
+ if (ThemeEngine.Current.DataGridViewColumnHeaderCellDrawBorder (this, graphics, cellBounds))
+ return;
+ base.PaintPartBorder (graphics, cellBounds, rowIndex);
+ }
+
protected override bool SetValue (int rowIndex, object value) {
header_text = value;
return true;
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs
index 503b9f0cbf0..003be0bb079 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridViewRowHeaderCell.cs
@@ -231,6 +231,27 @@ namespace System.Windows.Forms {
base.Paint (graphics, clipBounds, cellBounds, rowIndex, cellState, value, formattedValue, errorText, cellStyle, advancedBorderStyle, post);
}
+ internal override void PaintPartBackground (Graphics graphics, Rectangle cellBounds, DataGridViewCellStyle style)
+ {
+ if (ThemeEngine.Current.DataGridViewRowHeaderCellDrawBackground (this, graphics, cellBounds))
+ return;
+ base.PaintPartBackground (graphics, cellBounds, style);
+ }
+
+ internal override void PaintPartSelectionBackground (Graphics graphics, Rectangle cellBounds, DataGridViewElementStates cellState, DataGridViewCellStyle cellStyle)
+ {
+ if (ThemeEngine.Current.DataGridViewRowHeaderCellDrawSelectionBackground (this))
+ return;
+ base.PaintPartSelectionBackground (graphics, cellBounds, cellState, cellStyle);
+ }
+
+ internal override void PaintPartBorder (Graphics graphics, Rectangle cellBounds, int rowIndex)
+ {
+ if (ThemeEngine.Current.DataGridViewRowHeaderCellDrawBorder (this, graphics, cellBounds))
+ return;
+ base.PaintPartBorder (graphics, cellBounds, rowIndex);
+ }
+
private void DrawRightArrowGlyph (Graphics g, Pen p, int x, int y)
{
g.DrawLine (p, x, y, x, y + 8);
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
index d4a47908f69..d9948977e74 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
@@ -398,6 +398,11 @@ namespace System.Windows.Forms
}
}
+ internal ColumnHeader EnteredColumnHeader {
+ get {
+ return header_control.EnteredColumnHeader;
+ }
+ }
#endregion // Private Internal Properties
#region Protected Properties
@@ -1922,7 +1927,7 @@ namespace System.Windows.Forms
layout_wd = ClientRectangle.Width;
} else {
header_control.Width = x;
- header_control.Height = columns.Count > 0 ? columns [0].Ht : Font.Height + 5;
+ header_control.Height = columns.Count > 0 ? columns [0].Ht : ThemeEngine.Current.ListViewGetHeaderHeight (this, Font);
header_control.Visible = true;
}
}
@@ -3969,6 +3974,7 @@ namespace System.Windows.Forms
ColumnHeader drag_column;
int drag_x;
int drag_to_index = -1;
+ ColumnHeader entered_column_header;
public HeaderControl (ListView owner)
{
@@ -3977,6 +3983,32 @@ namespace System.Windows.Forms
MouseDown += new MouseEventHandler (HeaderMouseDown);
MouseMove += new MouseEventHandler (HeaderMouseMove);
MouseUp += new MouseEventHandler (HeaderMouseUp);
+ MouseLeave += new EventHandler (OnMouseLeave);
+ }
+
+ internal ColumnHeader EnteredColumnHeader {
+ get { return entered_column_header; }
+ private set {
+ if (entered_column_header == value)
+ return;
+ if (ThemeEngine.Current.ListViewHasHotHeaderStyle) {
+ Region region_to_invalidate = new Region ();
+ region_to_invalidate.MakeEmpty ();
+ if (entered_column_header != null)
+ region_to_invalidate.Union (GetColumnHeaderInvalidateArea (entered_column_header));
+ entered_column_header = value;
+ if (entered_column_header != null)
+ region_to_invalidate.Union (GetColumnHeaderInvalidateArea (entered_column_header));
+ Invalidate (region_to_invalidate);
+ region_to_invalidate.Dispose ();
+ } else
+ entered_column_header = value;
+ }
+ }
+
+ void OnMouseLeave (object sender, EventArgs e)
+ {
+ EnteredColumnHeader = null;
}
private ColumnHeader ColumnAtX (int x)
@@ -4022,13 +4054,23 @@ namespace System.Windows.Forms
drag_to_index = GetReorderedIndex (clicked_column);
}
clicked_column.Pressed = true;
- Rectangle bounds = clicked_column.Rect;
- bounds.X -= owner.h_marker;
- Invalidate (bounds);
+ Invalidate (clicked_column);
return;
}
}
+ void Invalidate (ColumnHeader columnHeader)
+ {
+ Invalidate (GetColumnHeaderInvalidateArea (columnHeader));
+ }
+
+ Rectangle GetColumnHeaderInvalidateArea (ColumnHeader columnHeader)
+ {
+ Rectangle bounds = columnHeader.Rect;
+ bounds.X -= owner.h_marker;
+ return bounds;
+ }
+
void StopResize ()
{
column_resize_active = false;
@@ -4077,17 +4119,16 @@ namespace System.Windows.Forms
ColumnHeader over = ColumnAtX (me.X + owner.h_marker);
bool pressed = clicked_column.Pressed;
clicked_column.Pressed = over == clicked_column;
- if (clicked_column.Pressed ^ pressed) {
- Rectangle bounds = clicked_column.Rect;
- bounds.X -= owner.h_marker;
- Invalidate (bounds);
- }
+ if (clicked_column.Pressed ^ pressed)
+ Invalidate (clicked_column);
}
return;
}
for (int i = 0; i < owner.Columns.Count; i++) {
Rectangle zone = owner.Columns [i].Rect;
+ if (zone.Contains (pt))
+ EnteredColumnHeader = owner.Columns [i];
zone.X = zone.Right - 5;
zone.Width = 10;
if (zone.Contains (pt)) {
@@ -4117,9 +4158,7 @@ namespace System.Windows.Forms
if (clicked_column != null && clicked_column.Pressed) {
clicked_column.Pressed = false;
- Rectangle bounds = clicked_column.Rect;
- bounds.X -= owner.h_marker;
- Invalidate (bounds);
+ Invalidate (clicked_column);
owner.OnColumnClick (new ColumnClickEventArgs (clicked_column.Index));
}
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
index 2e2b8192f7c..21347ade791 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Theme.cs
@@ -786,6 +786,24 @@ namespace System.Windows.Forms
#endregion // Datagrid
+#if NET_2_0
+ #region DataGridView
+ #region DataGridViewHeaderCell
+ #region DataGridViewRowHeaderCell
+ public abstract bool DataGridViewRowHeaderCellDrawBackground (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds);
+ public abstract bool DataGridViewRowHeaderCellDrawSelectionBackground (DataGridViewRowHeaderCell cell);
+ public abstract bool DataGridViewRowHeaderCellDrawBorder (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds);
+ #endregion
+ #region DataGridViewColumnHeaderCell
+ public abstract bool DataGridViewColumnHeaderCellDrawBackground (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds);
+ public abstract bool DataGridViewColumnHeaderCellDrawBorder (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds);
+ #endregion
+ public abstract bool DataGridViewHeaderCellHasPressedStyle (DataGridView dataGridView);
+ public abstract bool DataGridViewHeaderCellHasHotStyle (DataGridView dataGridView);
+ #endregion
+ #endregion
+#endif
+
#region DateTimePicker
public abstract void DrawDateTimePicker(Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp);
@@ -814,8 +832,10 @@ namespace System.Windows.Forms
public abstract void DrawListViewItems (Graphics dc, Rectangle clip_rectangle, ListView control);
public abstract void DrawListViewHeader (Graphics dc, Rectangle clip_rectangle, ListView control);
public abstract void DrawListViewHeaderDragDetails (Graphics dc, ListView control, ColumnHeader drag_column, int target_x);
+ public abstract bool ListViewHasHotHeaderStyle { get; }
// Sizing
+ public abstract int ListViewGetHeaderHeight (ListView listView, Font font);
public abstract Size ListViewCheckBoxSize { get; }
public abstract int ListViewColumnHeaderHeight { get; }
public abstract int ListViewDefaultColumnWidth { get; }
diff --git a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeVisualStyles.cs b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeVisualStyles.cs
index 3ed7ef3b7b0..e6ecaf9de55 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeVisualStyles.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeVisualStyles.cs
@@ -25,6 +25,7 @@
// Ernesto Carrea, equistango@gmail.com
using System.Drawing;
+using System.Drawing.Drawing2D;
using System.Windows.Forms.VisualStyles;
namespace System.Windows.Forms
@@ -410,6 +411,156 @@ namespace System.Windows.Forms
}
#endregion
#endregion
+#if NET_2_0
+ #region DataGridView
+ #region DataGridViewHeaderCell
+ #region DataGridViewRowHeaderCell
+ public override bool DataGridViewRowHeaderCellDrawBackground (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ if (!cell.DataGridView.EnableHeadersVisualStyles)
+ return base.DataGridViewRowHeaderCellDrawBackground (cell, g, bounds);
+ VisualStyleElement element = DataGridViewRowHeaderCellGetVisualStyleElement (cell);
+ if (!VisualStyleRenderer.IsElementDefined (element))
+ return base.DataGridViewRowHeaderCellDrawBackground (cell, g, bounds);
+ bounds.Width--;
+ Bitmap bitmap = new Bitmap (bounds.Height, bounds.Width);
+ Graphics bitmap_g = Graphics.FromImage (bitmap);
+ Rectangle bitmap_rectangle = new Rectangle (Point.Empty, bitmap.Size);
+ VisualStyleRenderer renderer = new VisualStyleRenderer (element);
+ if (!AreEqual (element, VisualStyleElement.Header.Item.Normal) && renderer.IsBackgroundPartiallyTransparent ())
+ new VisualStyleRenderer (VisualStyleElement.Header.Item.Normal).DrawBackground (bitmap_g, bitmap_rectangle);
+ renderer.DrawBackground (bitmap_g, bitmap_rectangle);
+ bitmap_g.Dispose ();
+ g.Transform = new Matrix(0, 1, 1, 0, 0, 0);
+ g.DrawImage (bitmap, bounds.Y, bounds.X);
+ bitmap.Dispose ();
+ g.ResetTransform ();
+ return true;
+ }
+ public override bool DataGridViewRowHeaderCellDrawSelectionBackground (DataGridViewRowHeaderCell cell)
+ {
+ if (!cell.DataGridView.EnableHeadersVisualStyles || !VisualStyleRenderer.IsElementDefined (DataGridViewRowHeaderCellGetVisualStyleElement (cell)))
+ return base.DataGridViewRowHeaderCellDrawSelectionBackground (cell);
+ return true;
+ }
+ public override bool DataGridViewRowHeaderCellDrawBorder (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ if (!cell.DataGridView.EnableHeadersVisualStyles || !VisualStyleRenderer.IsElementDefined (DataGridViewRowHeaderCellGetVisualStyleElement (cell)))
+ return base.DataGridViewRowHeaderCellDrawBorder (cell, g, bounds);
+ g.DrawLine (cell.GetBorderPen (), bounds.Right - 1, bounds.Top, bounds.Right - 1, bounds.Bottom - 1);
+ return true;
+ }
+ static VisualStyleElement DataGridViewRowHeaderCellGetVisualStyleElement (DataGridViewRowHeaderCell cell)
+ {
+ if (cell.DataGridView.PressedHeaderCell == cell)
+ return VisualStyleElement.Header.Item.Pressed;
+ if (cell.DataGridView.EnteredHeaderCell == cell)
+ return VisualStyleElement.Header.Item.Hot;
+ if (cell.OwningRow.SelectedInternal)
+ return VisualStyleElement.Header.Item.Pressed;
+ return VisualStyleElement.Header.Item.Normal;
+ }
+ #endregion
+ #region DataGridViewColumnHeaderCell
+ public override bool DataGridViewColumnHeaderCellDrawBackground (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ if (!cell.DataGridView.EnableHeadersVisualStyles || cell is DataGridViewTopLeftHeaderCell)
+ return base.DataGridViewColumnHeaderCellDrawBackground (cell, g, bounds);
+ VisualStyleElement element = DataGridViewColumnHeaderCellGetVisualStyleElement (cell);
+ if (!VisualStyleRenderer.IsElementDefined (element))
+ return base.DataGridViewColumnHeaderCellDrawBackground (cell, g, bounds);
+ bounds.Height--;
+ VisualStyleRenderer renderer = new VisualStyleRenderer (element);
+ if (!AreEqual (element, VisualStyleElement.Header.Item.Normal) && renderer.IsBackgroundPartiallyTransparent ())
+ new VisualStyleRenderer (VisualStyleElement.Header.Item.Normal).DrawBackground (g, bounds);
+ renderer.DrawBackground (g, bounds);
+ return true;
+ }
+ public override bool DataGridViewColumnHeaderCellDrawBorder (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ if (!cell.DataGridView.EnableHeadersVisualStyles || cell is DataGridViewTopLeftHeaderCell || !VisualStyleRenderer.IsElementDefined (VisualStyleElement.Header.Item.Normal))
+ return base.DataGridViewColumnHeaderCellDrawBorder (cell, g, bounds);
+ g.DrawLine (cell.GetBorderPen (), bounds.Left, bounds.Bottom - 1, bounds.Right - 1, bounds.Bottom - 1);
+ return true;
+ }
+ static VisualStyleElement DataGridViewColumnHeaderCellGetVisualStyleElement (DataGridViewColumnHeaderCell cell)
+ {
+ if (cell.DataGridView.PressedHeaderCell == cell)
+ return VisualStyleElement.Header.Item.Pressed;
+ if (cell.DataGridView.EnteredHeaderCell == cell)
+ return VisualStyleElement.Header.Item.Hot;
+ return VisualStyleElement.Header.Item.Normal;
+ }
+ #endregion
+ public override bool DataGridViewHeaderCellHasPressedStyle (DataGridView dataGridView)
+ {
+ if (!dataGridView.EnableHeadersVisualStyles || !VisualStyleRenderer.IsElementDefined (VisualStyleElement.Header.Item.Pressed))
+ return base.DataGridViewHeaderCellHasPressedStyle (dataGridView);
+ return true;
+ }
+ public override bool DataGridViewHeaderCellHasHotStyle (DataGridView dataGridView)
+ {
+ if (!dataGridView.EnableHeadersVisualStyles || !VisualStyleRenderer.IsElementDefined (VisualStyleElement.Header.Item.Hot))
+ return base.DataGridViewHeaderCellHasHotStyle (dataGridView);
+ return true;
+ }
+ #endregion
+ #endregion
+#endif
+ #region ListView
+ protected override void ListViewDrawColumnHeaderBackground (ListView listView, ColumnHeader columnHeader, Graphics g, Rectangle area, Rectangle clippingArea)
+ {
+ VisualStyleElement element;
+ if (listView.HeaderStyle == ColumnHeaderStyle.Clickable)
+ if (columnHeader.Pressed)
+ element = VisualStyleElement.Header.Item.Pressed;
+ else if (columnHeader == listView.EnteredColumnHeader)
+ element = VisualStyleElement.Header.Item.Hot;
+ else
+ element = VisualStyleElement.Header.Item.Normal;
+ else
+ element = VisualStyleElement.Header.Item.Normal;
+ if (!VisualStyleRenderer.IsElementDefined (element)) {
+ base.ListViewDrawColumnHeaderBackground (listView, columnHeader, g, area, clippingArea);
+ return;
+ }
+ new VisualStyleRenderer (element).DrawBackground (g, area, clippingArea);
+ }
+ protected override void ListViewDrawUnusedHeaderBackground (ListView listView, Graphics g, Rectangle area, Rectangle clippingArea)
+ {
+ VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
+ if (!VisualStyleRenderer.IsElementDefined (element)) {
+ base.ListViewDrawUnusedHeaderBackground (listView, g, area, clippingArea);
+ return;
+ }
+ new VisualStyleRenderer (element).DrawBackground (g, area, clippingArea);
+ }
+ public override bool ListViewHasHotHeaderStyle {
+ get {
+ if (!VisualStyleRenderer.IsElementDefined (VisualStyleElement.Header.Item.Hot))
+ return base.ListViewHasHotHeaderStyle;
+ return true;
+ }
+ }
+ public override int ListViewGetHeaderHeight (ListView listView, Font font)
+ {
+ VisualStyleElement element = VisualStyleElement.Header.Item.Normal;
+ if (!VisualStyleRenderer.IsElementDefined (element))
+ return base.ListViewGetHeaderHeight (listView, font);
+ Control control = null;
+ Graphics g;
+ if (listView == null) {
+ control = new Control ();
+ g = control.CreateGraphics ();
+ } else
+ g = listView.CreateGraphics ();
+ int result = new VisualStyleRenderer (element).GetPartSize (g, ThemeSizeType.True).Height;
+ g.Dispose ();
+ if (listView == null)
+ control.Dispose ();
+ return result;
+ }
+ #endregion
#region GroupBox
public override void DrawGroupBox (Graphics dc, Rectangle area, GroupBox box)
{
@@ -1503,5 +1654,13 @@ namespace System.Windows.Forms
}
}
#endregion
+
+ static bool AreEqual (VisualStyleElement value1, VisualStyleElement value2)
+ {
+ return
+ value1.ClassName == value1.ClassName &&
+ value1.Part == value2.Part &&
+ value1.State == value2.State;
+ }
}
}
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 e7f13b263e4..8bdbfd2ee87 100644
--- a/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
+++ b/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
@@ -2162,7 +2162,52 @@ namespace System.Windows.Forms
}
#endregion // Datagrid
-
+
+#if NET_2_0
+ #region DataGridView
+ #region DataGridViewHeaderCell
+ #region DataGridViewRowHeaderCell
+ public override bool DataGridViewRowHeaderCellDrawBackground (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ return false;
+ }
+
+ public override bool DataGridViewRowHeaderCellDrawSelectionBackground (DataGridViewRowHeaderCell cell)
+ {
+ return false;
+ }
+
+ public override bool DataGridViewRowHeaderCellDrawBorder (DataGridViewRowHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ return false;
+ }
+ #endregion
+
+ #region DataGridViewColumnHeaderCell
+ public override bool DataGridViewColumnHeaderCellDrawBackground (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ return false;
+ }
+
+ public override bool DataGridViewColumnHeaderCellDrawBorder (DataGridViewColumnHeaderCell cell, Graphics g, Rectangle bounds)
+ {
+ return false;
+ }
+ #endregion
+
+ public override bool DataGridViewHeaderCellHasPressedStyle (DataGridView dataGridView)
+ {
+ return false;
+ }
+
+ public override bool DataGridViewHeaderCellHasHotStyle (DataGridView dataGridView)
+ {
+ return false;
+ }
+ #endregion
+ #endregion
+#endif
+
#region DateTimePicker
public override void DrawDateTimePicker(Graphics dc, Rectangle clip_rectangle, DateTimePicker dtp)
@@ -2511,12 +2556,7 @@ namespace System.Windows.Forms
continue;
#endif
- ButtonState state;
- if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
- state = col.Pressed ? ButtonState.Pushed : ButtonState.Normal;
- else
- state = ButtonState.Flat;
- CPDrawButton (dc, rect, state);
+ ListViewDrawColumnHeaderBackground (control, col, dc, rect, clip);
rect.X += 5;
rect.Width -= 10;
if (rect.Width <= 0)
@@ -2531,17 +2571,32 @@ namespace System.Windows.Forms
Rectangle rect = control.Columns [0].Rect;
rect.X = right;
rect.Width = control.Right - right;
- ButtonState state;
- if (control.HeaderStyle == ColumnHeaderStyle.Clickable)
- state = ButtonState.Normal;
- else
- state = ButtonState.Flat;
- CPDrawButton (dc, rect, state);
+ ListViewDrawUnusedHeaderBackground (control, dc, rect, clip);
}
}
}
}
+ protected virtual void ListViewDrawColumnHeaderBackground (ListView listView, ColumnHeader columnHeader, Graphics g, Rectangle area, Rectangle clippingArea)
+ {
+ ButtonState state;
+ if (listView.HeaderStyle == ColumnHeaderStyle.Clickable)
+ state = columnHeader.Pressed ? ButtonState.Pushed : ButtonState.Normal;
+ else
+ state = ButtonState.Flat;
+ CPDrawButton (g, area, state);
+ }
+
+ protected virtual void ListViewDrawUnusedHeaderBackground (ListView listView, Graphics g, Rectangle area, Rectangle clippingArea)
+ {
+ ButtonState state;
+ if (listView.HeaderStyle == ColumnHeaderStyle.Clickable)
+ state = ButtonState.Normal;
+ else
+ state = ButtonState.Flat;
+ CPDrawButton (g, area, state);
+ }
+
public override void DrawListViewHeaderDragDetails (Graphics dc, ListView view, ColumnHeader col, int target_x)
{
Rectangle rect = col.Rect;
@@ -2921,7 +2976,18 @@ namespace System.Windows.Forms
}
#endif
+ public override bool ListViewHasHotHeaderStyle {
+ get {
+ return false;
+ }
+ }
+
// Sizing
+ public override int ListViewGetHeaderHeight (ListView listView, Font font)
+ {
+ return font.Height + 5;
+ }
+
public override Size ListViewCheckBoxSize {
get { return new Size (16, 16); }
}
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
index 94ab0031e49..696174a1c3c 100644
--- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/ChangeLog
@@ -1,3 +1,7 @@
+2008-06-03 George Giolfan <georgegiolfan@yahoo.com>
+
+ * DataGridViewTest.cs: Added EnableHeadersVisualStylesDefaultValue.
+
2008-06-03 Jonathan Pobst <monkey@jpobst.com>
* TableLayoutTest.cs Add another test for bug #396433.
diff --git a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs
index 4ed7d19b3b6..ae6a34cb2ef 100644
--- a/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs
+++ b/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/DataGridViewTest.cs
@@ -1496,6 +1496,11 @@ namespace MonoTests.System.Windows.Forms
class cust { public string Name { get { return "test"; } } }
+ [Test]
+ public void EnableHeadersVisualStylesDefaultValue ()
+ {
+ Assert.AreEqual (true, new DataGridView ().EnableHeadersVisualStyles);
+ }
}
[TestFixture]