Author: toshok
Date: 2006-05-26 00:14:31 -0400 (Fri, 26 May 2006)
New Revision: 61149
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
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBox.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
Log:
2006-05-26 Chris Toshok <[EMAIL PROTECTED]>
* DataGrid.cs (ColumnStartedEditing): fill these in. for now just
invalidate the current row header if we need to, but presumably
we'll invalidate the row corrsponding to the bounds or
editingControl.
(GridHScrolled): switch back to this method, as it's part of the
public api. *sigh*.
(GridVScrolled): same.
(OnMouseWheel): hack up something that more or less works. Call
GridHScrolled/GridVScrolled directly, instead of duplicating much
of their code here.
(EnsureCellVisibility): reinstate a bunch of this code, since we
can't just set the scrollbar Value and expect to do all the work
in the ValueChanged handler. Also, Call Update() after scrolling
in one direction so the other XplatX11.ScrollWindow call has the
proper stuff in the proper places.
(EditCell): set is_editing to true before calling .Edit.
* DataGridTextBox.cs (set_IsInEditOrNavigateMode): just set it,
don't bother comparing first.
(OnKeyPress): call grid.ColumnStartedEditing before calling
base.OnKeyPress. this will set is_changing and invalidate the row
header if necessary.
(ProcessKeyMessage): for WM_CHAR messages, call
ProcessKeyEventArgs directly. swallow anything other than WM_CHAR
and WM_KEYDOWN.
* DataGridBoolColumn.cs (Edit): don't set is_editing to true here.
it's done in the DataGrid.
(NextState): call grid.ColumnStartedEditing, which takes care of
invalidating the row header (and setting is_changing).
* DataGridTextBoxColumn.cs (Edit): don't set is_editing to true
here. it's done in the DataGrid.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-05-26 01:32:06 UTC (rev 61148)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-05-26 04:14:31 UTC (rev 61149)
@@ -1,3 +1,39 @@
+2006-05-26 Chris Toshok <[EMAIL PROTECTED]>
+
+ * DataGrid.cs (ColumnStartedEditing): fill these in. for now just
+ invalidate the current row header if we need to, but presumably
+ we'll invalidate the row corrsponding to the bounds or
+ editingControl.
+ (GridHScrolled): switch back to this method, as it's part of the
+ public api. *sigh*.
+ (GridVScrolled): same.
+ (OnMouseWheel): hack up something that more or less works. Call
+ GridHScrolled/GridVScrolled directly, instead of duplicating much
+ of their code here.
+ (EnsureCellVisibility): reinstate a bunch of this code, since we
+ can't just set the scrollbar Value and expect to do all the work
+ in the ValueChanged handler. Also, Call Update() after scrolling
+ in one direction so the other XplatX11.ScrollWindow call has the
+ proper stuff in the proper places.
+ (EditCell): set is_editing to true before calling .Edit.
+
+ * DataGridTextBox.cs (set_IsInEditOrNavigateMode): just set it,
+ don't bother comparing first.
+ (OnKeyPress): call grid.ColumnStartedEditing before calling
+ base.OnKeyPress. this will set is_changing and invalidate the row
+ header if necessary.
+ (ProcessKeyMessage): for WM_CHAR messages, call
+ ProcessKeyEventArgs directly. swallow anything other than WM_CHAR
+ and WM_KEYDOWN.
+
+ * DataGridBoolColumn.cs (Edit): don't set is_editing to true here.
+ it's done in the DataGrid.
+ (NextState): call grid.ColumnStartedEditing, which takes care of
+ invalidating the row header (and setting is_changing).
+
+ * DataGridTextBoxColumn.cs (Edit): don't set is_editing to true
+ here. it's done in the DataGrid.
+
2006-05-25 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
* Control.cs: allow changing the cursor when the mouse position is
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
2006-05-26 01:32:06 UTC (rev 61148)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGrid.cs
2006-05-26 04:14:31 UTC (rev 61149)
@@ -171,9 +171,9 @@
internal DataGridDrawing grid_drawing;
internal int first_visiblerow;
internal int horz_pixeloffset;
- internal bool is_editing; // Current cell is edit mode
+ bool is_adding; // Indicates when we are adding
a row
+ bool is_editing; // Current cell is edit mode
internal bool is_changing; // Indicates if current cell is
been changed (in edit mode)
- internal bool is_adding; // Indicates when we are adding
a row
private Hashtable selected_rows;
private int selection_start; // used for range selection
private bool begininit;
@@ -243,9 +243,9 @@
CurrentTableStyle = default_style;
horiz_scrollbar = new ImplicitHScrollBar ();
- horiz_scrollbar.ValueChanged += new EventHandler
(GridHValueChanged);
+ horiz_scrollbar.Scroll += new ScrollEventHandler
(GridHScrolled);
vert_scrollbar = new ImplicitVScrollBar ();
- vert_scrollbar.ValueChanged += new EventHandler
(GridVValueChanged);
+ vert_scrollbar.Scroll += new ScrollEventHandler
(GridVScrolled);
SetStyle (ControlStyles.UserMouse, true);
@@ -1042,12 +1042,23 @@
protected internal virtual void ColumnStartedEditing (Control
editingControl)
{
-
+ bool need_invalidate = is_changing == false;
+ // XXX calculate the row header to invalidate
+ // (using the editingControl's position?)
+ // instead of using InvalidateCurrentRowHeader
+ is_changing = true;
+ if (need_invalidate)
+ InvalidateCurrentRowHeader ();
}
protected internal virtual void ColumnStartedEditing (Rectangle
bounds)
{
-
+ bool need_invalidate = is_changing == false;
+ // XXX calculate the row header to invalidate
+ // instead of using InvalidateCurrentRowHeader
+ is_changing = true;
+ if (need_invalidate)
+ InvalidateCurrentRowHeader ();
}
protected override AccessibleObject CreateAccessibilityInstance
()
@@ -1127,23 +1138,29 @@
return string.Empty;
}
- protected virtual void GridHValueChanged (object sender,
EventArgs e)
+ protected virtual void GridHScrolled (object sender,
ScrollEventArgs se)
{
- if (horiz_scrollbar.Value == horz_pixeloffset)
+ if (se.NewValue == horz_pixeloffset ||
+ se.Type == ScrollEventType.EndScroll) {
return;
+ }
- ScrollToColumnInPixels (horiz_scrollbar.Value);
+ ScrollToColumnInPixels (se.NewValue);
}
- protected virtual void GridVValueChanged (object sender,
EventArgs e)
+ protected virtual void GridVScrolled (object sender,
ScrollEventArgs se)
{
int old_first_visiblerow = first_visiblerow;
- first_visiblerow = vert_scrollbar.Value;
+ first_visiblerow = se.NewValue;
+
+ if (first_visiblerow == old_first_visiblerow)
+ return;
+
grid_drawing.UpdateVisibleRowCount ();
+
+ if (first_visiblerow == old_first_visiblerow)
+ return;
- if (first_visiblerow == old_first_visiblerow) {
- return;
- }
ScrollToRow (old_first_visiblerow, first_visiblerow);
}
@@ -1409,25 +1426,36 @@
base.OnMouseWheel (e);
bool ctrl_pressed = ((Control.ModifierKeys &
Keys.Control) != 0);
+ int pixels;
if (ctrl_pressed) { // scroll horizontally
if (e.Delta > 0) {
- horiz_scrollbar.Value = Math.Max
(horiz_scrollbar.Minimum,
-
horiz_scrollbar.Value + horiz_scrollbar.LargeChange);
+ /* left */
+ pixels = Math.Max
(horiz_scrollbar.Minimum,
+
horiz_scrollbar.Value - horiz_scrollbar.LargeChange);
}
else {
- horiz_scrollbar.Value = Math.Min
(horiz_scrollbar.Maximum - horiz_scrollbar.LargeChange + 1,
-
horiz_scrollbar.Value + horiz_scrollbar.LargeChange);
+ /* right */
+ pixels = Math.Min
(horiz_scrollbar.Maximum - horiz_scrollbar.LargeChange + 1,
+
horiz_scrollbar.Value + horiz_scrollbar.LargeChange);
}
+
+ GridHScrolled (this, new ScrollEventArgs
(ScrollEventType.ThumbPosition, pixels));
+ horiz_scrollbar.Value = pixels;
} else {
if (e.Delta > 0) {
- vert_scrollbar.Value = Math.Max
(vert_scrollbar.Minimum,
-
vert_scrollbar.Value + vert_scrollbar.LargeChange);
+ /* up */
+ pixels = Math.Max
(vert_scrollbar.Minimum,
+ vert_scrollbar.Value
- vert_scrollbar.LargeChange);
}
else {
- vert_scrollbar.Value = Math.Min
(vert_scrollbar.Maximum - vert_scrollbar.LargeChange + 1,
-
vert_scrollbar.Value + vert_scrollbar.LargeChange);
+ /* down */
+ pixels = Math.Min
(vert_scrollbar.Maximum - vert_scrollbar.LargeChange + 1,
+ vert_scrollbar.Value
+ vert_scrollbar.LargeChange);
}
+
+ GridVScrolled (this, new ScrollEventArgs
(ScrollEventType.ThumbPosition, pixels));
+ vert_scrollbar.Value = pixels;
}
}
@@ -1894,20 +1922,30 @@
{
if (cell.ColumnNumber <= first_visiblecolumn ||
cell.ColumnNumber + 1 >= first_visiblecolumn +
visiblecolumn_count) {
-
+
first_visiblecolumn =
grid_drawing.GetFirstColumnForColumnVisilibility (first_visiblecolumn,
cell.ColumnNumber);
- int pixel = grid_drawing.GetColumnStartingPixel
(first_visiblecolumn);
+ int pixel =
grid_drawing.GetColumnStartingPixel (first_visiblecolumn);
+ ScrollToColumnInPixels (pixel);
horiz_scrollbar.Value = pixel;
+ Update();
}
if (cell.RowNumber < first_visiblerow ||
- cell.RowNumber + 1 >= first_visiblerow +
visiblerow_count) {
+ cell.RowNumber + 1 >= first_visiblerow +
visiblerow_count) {
- if (cell.RowNumber + 1 >= first_visiblerow +
visiblerow_count) {
- vert_scrollbar.Value = 1 +
cell.RowNumber - visiblerow_count;
- } else {
- vert_scrollbar.Value = cell.RowNumber;
+ if (cell.RowNumber + 1 >= first_visiblerow +
visiblerow_count) {
+ int old_first_visiblerow =
first_visiblerow;
+ first_visiblerow = 1 + cell.RowNumber -
visiblerow_count;
+ grid_drawing.UpdateVisibleRowCount ();
+ ScrollToRow (old_first_visiblerow,
first_visiblerow);
+ }else {
+ int old_first_visiblerow =
first_visiblerow;
+ first_visiblerow = cell.RowNumber;
+ grid_drawing.UpdateVisibleRowCount ();
+ ScrollToRow (old_first_visiblerow,
first_visiblerow);
}
+
+ vert_scrollbar.Value = first_visiblerow;
}
}
@@ -2121,6 +2159,8 @@
Invalidate (); // We have just added a new row
}
+ is_editing = true;
+
CurrentTableStyle.GridColumnStyles[cell.ColumnNumber].Edit (ListManager,
cell.RowNumber, GetCellBounds (cell.RowNumber,
cell.ColumnNumber),
_readonly, string.Empty, true);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
2006-05-26 01:32:06 UTC (rev 61148)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridBoolColumn.cs
2006-05-26 04:14:31 UTC (rev 61149)
@@ -169,7 +169,6 @@
oldState = GetState (null, rowNum);
SetState (rowNum, GetState (source, rowNum) |
CheckState.Selected);
grid.Invalidate (grid.GetCurrentCellBounds ());
- grid.is_editing = true;
}
[MonoTODO]
@@ -366,10 +365,8 @@
{
CheckState state = GetNextState (GetState (null, row));
- bool refresh_rowheader = grid.is_changing == false;
- grid.is_changing = true;
- if (refresh_rowheader)
- grid.InvalidateCurrentRowHeader ();
+ grid.ColumnStartedEditing (new Rectangle());
+
SetState (row, state);
grid.Invalidate (grid.GetCellBounds (row, column));
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBox.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBox.cs
2006-05-26 01:32:06 UTC (rev 61148)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBox.cs
2006-05-26 04:14:31 UTC (rev 61149)
@@ -62,9 +62,7 @@
return isedit;
}
set {
- if (value != isedit) {
- isedit = value;
- }
+ isedit = value;
}
}
@@ -72,9 +70,8 @@
#region Public Instance Methods
protected override void OnKeyPress (KeyPressEventArgs e)
- {
- grid.is_changing = true;
- grid.InvalidateCurrentRowHeader ();
+ {
+ grid.ColumnStartedEditing (Bounds);
base.OnKeyPress (e);
}
@@ -90,13 +87,13 @@
// If we decide DataGrid needs to process we call
grid.ProcessKeyPreviewInternal and return true
// If we want TextBox to handle the key , we return
false;
- // We only care about KEYDOWN messages
- if (m.Msg != (int)Msg.WM_KEYDOWN) {
- return false;
- }
+ switch ((Msg)m.Msg) {
+ case Msg.WM_CHAR:
+ return ProcessKeyEventArgs (ref m);
- if (isedit) {
- switch (key) {
+ case Msg.WM_KEYDOWN:
+ if (isedit) {
+ switch (key) {
case Keys.F2: {
SelectionStart = Text.Length;
SelectionLength = 0;
@@ -157,7 +154,11 @@
default: {
return
base.ProcessKeyMessage(ref m);
}
+ }
}
+ break;
+ default:
+ return false;
}
return base.ProcessKeyMessage(ref m);
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
2006-05-26 01:32:06 UTC (rev 61148)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DataGridTextBoxColumn.cs
2006-05-26 04:14:31 UTC (rev 61149)
@@ -195,8 +195,6 @@
textbox.Focus ();
textbox.SelectAll ();
grid.ResumeLayout (false);
-
- grid.is_editing = true;
}
protected void EndEdit ()
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches