Author: toshok
Date: 2006-06-12 12:29:36 -0400 (Mon, 12 Jun 2006)
New Revision: 61630
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
Log:
* DataGrid.cs (set_CurrentCell): concede focus as we move around.
we need this to get rid of the selected background in the bool
column.
(CancelEditing): move the ConcedeFocus call to above the Abort
call. Also, set is_changing to false and invalidate the row
header if we were changing before.
(ProcessKeyPreviewInternal): remove, since noone outside this
class calls it anymore. Roll the code into ProcessKeyPreview.
(EndEdit): remove the internal version.
(InvalidateCurrentRowHeader): make private.
* DataGridBoolColumn.cs: simplify this class a bunch. remove the
Keys.Escape handling (and with it the last call to
DataGrid.EndEdit from outside the class.)
2006-06-12 Chris Toshok <[EMAIL PROTECTED]>
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-06-12 15:42:06 UTC (rev 61629)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-06-12 16:29:36 UTC (rev 61630)
@@ -1,5 +1,23 @@
2006-06-12 Chris Toshok <[EMAIL PROTECTED]>
+ * DataGrid.cs (set_CurrentCell): concede focus as we move around.
+ we need this to get rid of the selected background in the bool
+ column.
+ (CancelEditing): move the ConcedeFocus call to above the Abort
+ call. Also, set is_changing to false and invalidate the row
+ header if we were changing before.
+ (ProcessKeyPreviewInternal): remove, since noone outside this
+ class calls it anymore. Roll the code into ProcessKeyPreview.
+ (EndEdit): remove the internal version.
+ (InvalidateCurrentRowHeader): make private.
+
+ * DataGridBoolColumn.cs: simplify this class a bunch. remove the
+ Keys.Escape handling (and with it the last call to
+ DataGrid.EndEdit from outside the class.)
+
+
+2006-06-12 Chris Toshok <[EMAIL PROTECTED]>
+
* DataGridTextBox.cs (.ctor): isedit defaults to false.
(OnKeyPress): set isedit to true.
(ProcessKeyMessage): remove Keys.Enter handling from here. it's
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
2006-06-12 15:42:06 UTC (rev 61629)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
2006-06-12 16:29:36 UTC (rev 61630)
@@ -481,6 +481,9 @@
}
#endif
+ if (was_editing)
+
CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber].ConcedeFocus ();
+
//Console.WriteLine ("set_CurrentCell, {0}x{1},
RowsCount = {2}, from {3}", value.RowNumber, value.ColumnNumber, RowsCount,
Environment.StackTrace);
if (need_add) {
Console.WriteLine ("+ calling AddNew");
@@ -1084,13 +1087,15 @@
if (!is_editing)
return;
+
CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber].ConcedeFocus ();
+
if (is_changing) {
if (current_cell.ColumnNumber <
CurrentTableStyle.GridColumnStyles.Count)
CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber].Abort
(current_cell.RowNumber);
+ is_changing = false;
+ grid_drawing.InvalidateRowHeader
(current_cell.RowNumber);
}
-
-
CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber].ConcedeFocus ();
if (is_adding) {
ListManager.CancelCurrentEdit ();
is_adding = false;
@@ -1800,8 +1805,7 @@
return false; // message not processed
}
- // Called from DataGridTextBox
- internal bool ProcessKeyPreviewInternal(ref Message m)
+ protected override bool ProcessKeyPreview (ref Message m)
{
if ((Msg)m.Msg == Msg.WM_KEYDOWN) {
Keys key = (Keys) m.WParam.ToInt32 ();
@@ -1810,14 +1814,7 @@
return true;
}
}
- return false;
- }
- protected override bool ProcessKeyPreview (ref Message m)
- {
- if (ProcessKeyPreviewInternal(ref m)) {
- return true;
- }
return base.ProcessKeyPreview (ref m);
}
@@ -2020,13 +2017,6 @@
list_manager.ItemChanged -= new ItemChangedEventHandler
(OnListManagerItemChanged);
}
- // EndEdit current editing operation
- internal virtual bool EndEdit (bool shouldAbort)
- {
- return EndEdit
(CurrentTableStyle.GridColumnStyles[current_cell.ColumnNumber],
- CurrentRow, shouldAbort);
- }
-
private void EnsureCellVisibility (DataGridCell cell)
{
if (cell.ColumnNumber <= first_visiblecolumn ||
@@ -2058,7 +2048,7 @@
}
}
- internal IEnumerable GetDataSource (object source, string
member)
+ private IEnumerable GetDataSource (object source, string member)
{
if (source is IEnumerable)
return (IEnumerable) source;
@@ -2094,7 +2084,7 @@
}
- internal void InvalidateCurrentRowHeader ()
+ private void InvalidateCurrentRowHeader ()
{
grid_drawing.InvalidateRowHeader (CurrentRow);
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
2006-06-12 15:42:06 UTC (rev 61629)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
2006-06-12 16:29:36 UTC (rev 61630)
@@ -51,34 +51,28 @@
private object truevalue;
private Hashtable checkboxes_state;
CheckState oldState;
+ int row;
+
#endregion // Local Variables
#region Constructors
- public DataGridBoolColumn () : base ()
+ public DataGridBoolColumn () : this (null, false)
{
- CommonConstructor ();
}
- public DataGridBoolColumn (PropertyDescriptor prop) : base
(prop)
+ public DataGridBoolColumn (PropertyDescriptor prop) : this
(prop, false)
{
- CommonConstructor ();
}
public DataGridBoolColumn (PropertyDescriptor prop, bool
isDefault) : base (prop)
{
- CommonConstructor ();
- is_default = isDefault;
- }
-
- private void CommonConstructor ()
- {
- allownull = true;
falsevalue = false;
nullvalue = null;
truevalue = true;
+ allownull = true;
checkboxes_state = new Hashtable ();
+ is_default = isDefault;
}
-
#endregion
#region Public Instance Properties
@@ -152,8 +146,9 @@
protected internal override bool Commit (CurrencyManager
source, int rowNum)
{
- SetColumnValueAtRow (source, rowNum, FromStateToValue
(GetState (source, rowNum)));
- SetState (rowNum, GetState (source, rowNum) &
~CheckState.Selected);
+ CheckState newState = GetState (source, rowNum);
+ SetColumnValueAtRow (source, rowNum, FromStateToValue
(newState));
+ SetState (rowNum, newState & ~CheckState.Selected);
grid.Invalidate (grid.GetCurrentCellBounds ());
return true;
}
@@ -161,13 +156,15 @@
[MonoTODO]
protected internal override void ConcedeFocus ()
{
-
+ SetState (row, GetState (null, row) &
~CheckState.Selected);
+ grid.Invalidate (grid.GetCurrentCellBounds ());
}
protected internal override void Edit (CurrencyManager source,
int rowNum, Rectangle bounds, bool readOnly, string instantText, bool
cellIsVisible)
{
- oldState = GetState (null, rowNum);
- SetState (rowNum, GetState (source, rowNum) |
CheckState.Selected);
+ row = rowNum;
+ oldState = GetState (source, rowNum);
+ SetState (rowNum, oldState | CheckState.Selected);
grid.Invalidate (grid.GetCurrentCellBounds ());
}
@@ -223,26 +220,30 @@
Size chkbox_size = GetPreferredSize (g, null);
Rectangle rect = new Rectangle ();
ButtonState state;
+ CheckState check_state = GetState (source, rowNum);
+
chkbox_size.Width -= 2;
chkbox_size.Height -= 2;
+
rect.X = bounds.X + ((bounds.Width - chkbox_size.Width)
/ 2);
rect.Y = bounds.Y + ((bounds.Height -
chkbox_size.Height) / 2);
rect.Width = chkbox_size.Width;
rect.Height = chkbox_size.Height;
// If the cell is selected
- if ((GetState (source, rowNum) & CheckState.Selected)
== CheckState.Selected) {
+ if ((check_state & CheckState.Selected) ==
CheckState.Selected) {
backBrush =
ThemeEngine.Current.ResPool.GetSolidBrush (grid.SelectionBackColor);
+ check_state &= ~CheckState.Selected;
}
g.FillRectangle (backBrush, bounds);
- switch (GetState (source, rowNum) &
~CheckState.Selected) {
+ switch (check_state) {
case CheckState.Checked:
state = ButtonState.Checked;
break;
case CheckState.Null:
- state = ButtonState.Inactive;
+ state = ButtonState.Checked |
ButtonState.Inactive;
break;
case CheckState.UnChecked:
default:
@@ -258,13 +259,13 @@
{
object value = null;
- if (obj.Equals (nullvalue)) {
+ if (obj.Equals (nullvalue))
value = Convert.DBNull;
- } else {
- if (obj.Equals (truevalue)) {
- value = true;
- }
- }
+ else if (obj.Equals (truevalue))
+ value = true;
+ else if (obj.Equals (falsevalue))
+ value = false;
+ /* else error? */
base.SetColumnValueAtRow (lm, row, value);
}
@@ -278,30 +279,22 @@
private object FromStateToValue (CheckState state)
{
- state = state & ~CheckState.Selected;
-
- if ((state & CheckState.Checked) == CheckState.Checked)
{
+ if ((state & CheckState.Checked) == CheckState.Checked)
return truevalue;
- }
-
- if ((state & CheckState.Null) == CheckState.Null) {
+ else if ((state & CheckState.Null) == CheckState.Null)
return nullvalue;
- }
-
- return falsevalue;
+ else
+ return falsevalue;
}
private CheckState FromValueToState (object obj)
{
- if (obj.Equals (truevalue)) {
+ if (obj.Equals (truevalue))
return CheckState.Checked;
- }
-
- if (obj.Equals (nullvalue)) {
+ else if (obj.Equals (nullvalue))
return CheckState.Null;
- }
-
- return CheckState.UnChecked;
+ else
+ return CheckState.UnChecked;
}
private CheckState GetState (CurrencyManager source, int row)
@@ -350,34 +343,27 @@
case Keys.Space:
NextState (row, column);
break;
- case Keys.Escape:
- grid.EndEdit (true);
- break;
}
}
internal override void OnMouseDown (MouseEventArgs e, int row,
int column)
{
+ this.row = row;
NextState (row, column);
}
private void NextState (int row, int column)
{
- CheckState state = GetNextState (GetState (null, row));
-
grid.ColumnStartedEditing (new Rectangle());
- SetState (row, state);
+ SetState (row, GetNextState (GetState (null, row)));
+
grid.Invalidate (grid.GetCellBounds (row, column));
}
private void SetState (int row, CheckState state)
- {
- if (checkboxes_state[row] == null) {
- checkboxes_state.Add (row, state);
- } else {
- checkboxes_state[row] = state;
- }
+ {
+ checkboxes_state[row] = state;
}
#endregion Private Instance Methods
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches