Author: jackson
Date: 2006-12-11 13:52:02 -0500 (Mon, 11 Dec 2006)
New Revision: 69348

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
Log:

        * TextControl.cs: Draw the caret and the selection when a flag
        * is
        set on the owner.
        * TextBoxBase.cs: We want to draw the caret and the selection
        * for
        TextBox but not for TextBoxBase.
        - If the window is resized and scrolling is no longer needed
          (the
        whole doc is visible) set the scroll position to zero.
        - Scroll to the caret when the document is recalculated (this
        might be wrong, need a lot of testing here)
        - The default SelectWord (the one TextBox uses) should move the
        caret to the end of the word.
        - SelectAll moves the caret to the end of the selection.
        * TextBox.cs: We don't selectall on focus, we just do it when
        * the
        control is created.




Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-12-11 18:32:42 UTC (rev 69347)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-12-11 18:52:02 UTC (rev 69348)
@@ -1,3 +1,19 @@
+2006-12-11  Jackson Harper  <[EMAIL PROTECTED]>
+
+       * TextControl.cs: Draw the caret and the selection when a flag is
+       set on the owner.
+       * TextBoxBase.cs: We want to draw the caret and the selection for
+       TextBox but not for TextBoxBase.
+       - If the window is resized and scrolling is no longer needed (the
+       whole doc is visible) set the scroll position to zero.
+       - Scroll to the caret when the document is recalculated (this
+       might be wrong, need a lot of testing here)
+       - The default SelectWord (the one TextBox uses) should move the
+       caret to the end of the word.
+       - SelectAll moves the caret to the end of the selection.
+       * TextBox.cs: We don't selectall on focus, we just do it when the
+       control is created.
+       
 2006-12-11  Mike Kestner  <[EMAIL PROTECTED]>
 
        * ComboBox.cs: stub in a 2.0 override for ProcessKeyEventArgs.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs       
2006-12-11 18:32:42 UTC (rev 69347)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs       
2006-12-11 18:52:02 UTC (rev 69348)
@@ -240,12 +240,12 @@
                }
 
                protected override void OnGotFocus(EventArgs e) {
-                       SelectAll ();
                        base.OnGotFocus (e);
                }
 
                protected override void OnHandleCreated(EventArgs e) {
                        base.OnHandleCreated (e);
+                       SelectAll ();
                }
 
                protected override void OnMouseUp(MouseEventArgs e) {

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs   
2006-12-11 18:32:42 UTC (rev 69347)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs   
2006-12-11 18:52:02 UTC (rev 69348)
@@ -64,6 +64,7 @@
                internal bool                   richtext;
                internal bool                   show_selection;         // set 
to true to always show selection, even if no focus is set
                internal int                    selection_length = -1;  // set 
to the user-specified selection length, or -1 if none
+               internal bool show_caret_w_selection;  // TextBox shows the 
caret when the selection is visible
                internal int                    requested_height;
                internal int                    canvas_width;
                internal int                    canvas_height;
@@ -98,6 +99,7 @@
                        word_wrap = true;
                        richtext = false;
                        show_selection = false;
+                       show_caret_w_selection = (this is TextBox);
                        document = new Document(this);
                        document.WidthChanged += new 
EventHandler(document_WidthChanged);
                        document.HeightChanged += new 
EventHandler(document_HeightChanged);
@@ -736,6 +738,7 @@
                        last = document.GetLine(document.Lines);
                        document.SetSelectionStart(document.GetLine(1), 0);
                        document.SetSelectionEnd(last, last.text.Length);
+                       document.PositionCaret (document.selection_end.line, 
document.selection_end.pos);
                        selection_length = -1;
                }
 
@@ -1552,14 +1555,14 @@
                {
                        if (hscroll.Visible) {
                                //vscroll.Maximum += hscroll.Height;
-                               canvas_height = Math.Max (0, ClientSize.Height 
- hscroll.Height);
+                               canvas_height = ClientSize.Height - 
hscroll.Height;
                        } else {
                                canvas_height = ClientSize.Height;
                        }
 
                        if (vscroll.Visible) {
                                //hscroll.Maximum += vscroll.Width;
-                               canvas_width = Math.Max (0, ClientSize.Width - 
vscroll.Width);
+                               canvas_width = ClientSize.Width - vscroll.Width;
                        } else {
                                canvas_width = ClientSize.Width;
                        }
@@ -1639,6 +1642,7 @@
                        }
 
                        document.SetSelection (document.caret.line, start, 
document.caret.line, end);
+                       document.PositionCaret (document.selection_end.line, 
document.selection_end.pos);
                }
 
                internal void CalculateDocument() {
@@ -1647,6 +1651,7 @@
                        }
                        document.RecalculateDocument(CreateGraphicsInternal());
                        CalculateScrollBars();
+                       ScrollToCaret ();
                        Invalidate();
                }
 
@@ -1827,6 +1832,7 @@
                                return;
                        
                        pos = document.Caret;
+
                        //Console.WriteLine("Caret now at {0} (Thumb: {1}x{2}, 
Canvas: {3}x{4}, Document {5}x{6})", pos, hscroll.Value, vscroll.Value, 
canvas_width, canvas_height, document.Width, document.Height);
 
 
@@ -1879,6 +1885,10 @@
 
                        if (pos.Y < document.ViewPortY) {
                                vscroll.Value = pos.Y;
+                       } else if (pos.Y < document.ViewPortHeight) {
+                               // The window has probably been resized, making 
the entire thing visible, so
+                               // we need to set the scroll position back to 
zero.
+                               vscroll.Value = 0;
                        }
 
                        if ((pos.Y + height) > (document.ViewPortY + 
canvas_height)) {

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs   
2006-12-11 18:32:42 UTC (rev 69347)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextControl.cs   
2006-12-11 18:52:02 UTC (rev 69348)
@@ -1109,7 +1109,7 @@
                        selection_visible = value;
 
                        // cursor and selection are enemies, we can't have both 
in the same room at the same time
-                       if (owner.IsHandleCreated)
+                       if (owner.IsHandleCreated && 
!owner.show_caret_w_selection)
                                XplatUI.CaretVisible (owner.Handle, 
!selection_visible);
                }
 

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to