Author: toshok
Date: 2007-01-15 21:04:30 -0500 (Mon, 15 Jan 2007)
New Revision: 71103

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DomainUpDown.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs
   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/UpDownBase.cs
Log:
2007-01-15  Chris Toshok  <[EMAIL PROTECTED]>

        * ListView.cs: drop the *Internal overrides, just do our work in
        ItemControl's WndProc instead.

        * UpDownBase.cs: a few large changes.  Fix up the Selectable state
        of the various controls, and forward the events properly (in the
        same manner as MS) from the textbox to the UpDown.  Also the
        ActiveControl of the UpDownBase gets set properly now.  Finally,
        we don't call UpdateEditText from the ctor.  Fixes bug #79957.

        * NumericUpDown.cs: set Text in the ctor.

        * DomainUpDown.cs: call UpdateEditText in the ctor.
        
        * TextBox.cs: on ms.net, WM_LBUTTONDOWN sets focus on the textbox,
        so even a Selectable = false textbox can be focused if you click
        in it.  Go figure.

        * Control.cs: remove On{Got,Lost}FocusInternal.  Subclasses can
        just add their handling in their respective WndProc's.  Also add
        an explicit FocusInternal method that doesn't consult CanFocus
        before calling Select(this).

        * TextBoxBase.cs: deal with removal of the FocusInternal calls -
        do our work in WndProc instead.

        * TabControl.cs: same.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-01-16 01:51:52 UTC (rev 71102)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2007-01-16 02:04:30 UTC (rev 71103)
@@ -1,3 +1,32 @@
+2007-01-15  Chris Toshok  <[EMAIL PROTECTED]>
+
+       * ListView.cs: drop the *Internal overrides, just do our work in
+       ItemControl's WndProc instead.
+
+       * UpDownBase.cs: a few large changes.  Fix up the Selectable state
+       of the various controls, and forward the events properly (in the
+       same manner as MS) from the textbox to the UpDown.  Also the
+       ActiveControl of the UpDownBase gets set properly now.  Finally,
+       we don't call UpdateEditText from the ctor.  Fixes bug #79957.
+
+       * NumericUpDown.cs: set Text in the ctor.
+
+       * DomainUpDown.cs: call UpdateEditText in the ctor.
+       
+       * TextBox.cs: on ms.net, WM_LBUTTONDOWN sets focus on the textbox,
+       so even a Selectable = false textbox can be focused if you click
+       in it.  Go figure.
+
+       * Control.cs: remove On{Got,Lost}FocusInternal.  Subclasses can
+       just add their handling in their respective WndProc's.  Also add
+       an explicit FocusInternal method that doesn't consult CanFocus
+       before calling Select(this).
+
+       * TextBoxBase.cs: deal with removal of the FocusInternal calls -
+       do our work in WndProc instead.
+
+       * TabControl.cs: same.
+
 2007-01-15  Everaldo Canuto  <[EMAIL PROTECTED]>
 
        * Menu.cs: implement MergeItems and Replace for MenuMerge method.

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-01-16 01:51:52 UTC (rev 71102)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs       
2007-01-16 02:04:30 UTC (rev 71103)
@@ -1228,12 +1228,6 @@
                        return true;
                }
 
-               internal void SelectChild (Control control)
-               {
-                       if (control.IsHandleCreated)
-                               XplatUI.SetFocus (control.window.Handle);
-               }
-
                internal virtual void DoDefaultAction() {
                        // Only here to be overriden by our actual controls; 
this is needed by the accessibility class
                }
@@ -3276,6 +3270,13 @@
                        return has_focus;
                }
 
+               internal void FocusInternal ()
+               {
+                       is_focusing = true;
+                       Select(this);
+                       is_focusing = false;
+               }
+
                public Control GetChildAtPoint(Point pt) {
                        // Microsoft's version of this function doesn't seem to 
work, so I can't check
                        // if we only consider children or also grandchildren, 
etc.
@@ -4693,14 +4694,14 @@
 
                        case Msg.WM_KILLFOCUS: {
                                this.has_focus = false;
-                               OnLostFocusInternal (EventArgs.Empty);
+                               OnLostFocus (EventArgs.Empty);
                                return;
                        }
 
                        case Msg.WM_SETFOCUS: {
                                if (!has_focus) {                
                                        this.has_focus = true;
-                                       OnGotFocusInternal (EventArgs.Empty);
+                                       OnGotFocus (EventArgs.Empty);
                                }
                                return;
                        }
@@ -5174,16 +5175,6 @@
                        // Override me
                }
 
-               internal virtual void OnGotFocusInternal (EventArgs e)
-               {
-                       OnGotFocus (e);
-               }
-
-               internal virtual void OnLostFocusInternal (EventArgs e)
-               {
-                       OnLostFocus (e);
-               }
-
                [EditorBrowsable(EditorBrowsableState.Advanced)]
                protected virtual void OnPaintBackground(PaintEventArgs pevent) 
{
                        PaintControlBackground (pevent);

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DomainUpDown.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DomainUpDown.cs  
2007-01-16 01:51:52 UTC (rev 71102)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/DomainUpDown.cs  
2007-01-16 02:04:30 UTC (rev 71103)
@@ -271,6 +271,7 @@
                        if (sorted && (index >= 0)) // index < 0 means it is 
already sorting
                                items.PrivSort();
 
+                       // XXX this might be wrong - it might be an explict 
'Text = ...' assignment.
                        UpdateEditText();
 
                        if (new_item) {
@@ -421,6 +422,8 @@
 
                        this.txtView.LostFocus +=new 
EventHandler(TextBoxLostFocus);
                        this.txtView.KeyPress += new 
KeyPressEventHandler(TextBoxKeyDown);
+
+                       UpdateEditText ();
                }
                #endregion      // Public Constructors
 

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs      
2007-01-16 01:51:52 UTC (rev 71102)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListView.cs      
2007-01-16 02:04:30 UTC (rev 71103)
@@ -1869,15 +1869,20 @@
                                ThemeEngine.Current.DrawListViewItems 
(pe.Graphics, pe.ClipRectangle, owner);
                        }
 
-                       internal override void OnGotFocusInternal (EventArgs e)
+                       protected override void WndProc (ref Message m)
                        {
-                               owner.Select (false, true);
+                               switch ((Msg)m.Msg) {
+                               case Msg.WM_KILLFOCUS:
+                                       owner.Select (false, true);
+                                       break;
+                               case Msg.WM_SETFOCUS:
+                                       owner.Select (false, true);
+                                       break;
+                               default:
+                                       break;
+                               }
+                               base.WndProc (ref m);
                        }
-
-                       internal override void OnLostFocusInternal (EventArgs e)
-                       {
-                               owner.Select (false, true);
-                       }
                }
                
                internal class ListViewLabelEditTextBox : TextBox

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs 
2007-01-16 01:51:52 UTC (rev 71102)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/NumericUpDown.cs 
2007-01-16 02:04:30 UTC (rev 71103)
@@ -64,6 +64,8 @@
                        maximum = 100M;
                        minimum = 0.0M;
                        thousands_separator = false;
+
+                       Text = "0";
                }
                #endregion      // Public Constructors
 

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs       
2007-01-16 01:51:52 UTC (rev 71102)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBox.cs       
2007-01-16 02:04:30 UTC (rev 71103)
@@ -338,6 +338,12 @@
                }
 
                protected override void WndProc(ref Message m) {
+                       switch ((Msg)m.Msg) {
+                               case Msg.WM_LBUTTONDOWN:
+                                       FocusInternal ();
+                                       break;
+                       }
+
                        base.WndProc(ref m);
                }
                #endregion      // Protected Instance Methods

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs   
2007-01-16 01:51:52 UTC (rev 71102)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TextBoxBase.cs   
2007-01-16 02:04:30 UTC (rev 71103)
@@ -1221,68 +1221,77 @@
 
                protected override void WndProc(ref Message m) {
                        switch ((Msg)m.Msg) {
-                               case Msg.WM_KEYDOWN: {
-                                       if (ProcessKeyMessage(ref m) || 
ProcessKey((Keys)m.WParam.ToInt32() | XplatUI.State.ModifierKeys)) {
-                                               m.Result = IntPtr.Zero;
-                                               return;
-                                       }
-                                       DefWndProc (ref m);
+                       case Msg.WM_KEYDOWN: {
+                               if (ProcessKeyMessage(ref m) || 
ProcessKey((Keys)m.WParam.ToInt32() | XplatUI.State.ModifierKeys)) {
+                                       m.Result = IntPtr.Zero;
                                        return;
                                }
+                               DefWndProc (ref m);
+                               return;
+                       }
 
-                               case Msg.WM_CHAR: {
-                                       int     ch;
+                       case Msg.WM_CHAR: {
+                               int     ch;
 
-                                       if (ProcessKeyMessage(ref m)) {
-                                               m.Result = IntPtr.Zero;
-                                               return;
-                                       }
-
-                                       if (read_only) {
-                                               return;
-                                       }
-
+                               if (ProcessKeyMessage(ref m)) {
                                        m.Result = IntPtr.Zero;
+                                       return;
+                               }
 
-                                       ch = m.WParam.ToInt32();
+                               if (read_only) {
+                                       return;
+                               }
 
-                                       if (ch == 127) {
-                                               HandleBackspace(true);
-                                       } else if (ch >= 32) {
-                                               if (document.selection_visible) 
{
-                                                       
document.ReplaceSelection("", false);
-                                               }
+                               m.Result = IntPtr.Zero;
 
-                                               char c = (char)m.WParam;
-                                               switch (character_casing) {
-                                               case CharacterCasing.Upper:
-                                                       c = Char.ToUpper((char) 
m.WParam);
-                                                       break;
-                                               case CharacterCasing.Lower:
-                                                       c = Char.ToLower((char) 
m.WParam);
-                                                       break;
-                                               }
+                               ch = m.WParam.ToInt32();
 
-                                               if (document.Length < 
max_length) {
-                                                       
document.InsertCharAtCaret(c, true);
-                                                       
OnTextChanged(EventArgs.Empty);
-                                                       CaretMoved(this, null);
-                                               } else {
-                                                       XplatUI.AudibleAlert();
-                                               }
-                                               return;
-                                       } else if (ch == 8) {
-                                               HandleBackspace(false);
+                               if (ch == 127) {
+                                       HandleBackspace(true);
+                               } else if (ch >= 32) {
+                                       if (document.selection_visible) {
+                                               document.ReplaceSelection("", 
false);
                                        }
 
-                                       return;
-                               }
+                                       char c = (char)m.WParam;
+                                       switch (character_casing) {
+                                       case CharacterCasing.Upper:
+                                               c = Char.ToUpper((char) 
m.WParam);
+                                               break;
+                                       case CharacterCasing.Lower:
+                                               c = Char.ToLower((char) 
m.WParam);
+                                               break;
+                                       }
 
-                               default: {
-                                       base.WndProc(ref m);
+                                       if (document.Length < max_length) {
+                                               document.InsertCharAtCaret(c, 
true);
+                                               OnTextChanged(EventArgs.Empty);
+                                               CaretMoved(this, null);
+                                       } else {
+                                               XplatUI.AudibleAlert();
+                                       }
                                        return;
+                               } else if (ch == 8) {
+                                       HandleBackspace(false);
                                }
+
+                               return;
                        }
+
+                       case Msg.WM_SETFOCUS:
+                               document.CaretHasFocus ();
+                               base.WndProc(ref m);
+                               break;
+
+                       case Msg.WM_KILLFOCUS:
+                               document.CaretLostFocus ();
+                               base.WndProc(ref m);
+                               break;
+
+                       default:
+                               base.WndProc(ref m);
+                               return;
+                       }
                }
 
                #endregion      // Protected Instance Methods
@@ -1452,18 +1461,6 @@
                        #endif
                }
 
-               internal override void OnGotFocusInternal (EventArgs e)
-               {
-                       document.CaretHasFocus ();
-                       base.OnGotFocusInternal (e);
-               }
-
-               internal override void OnLostFocusInternal (EventArgs e)
-               {
-                       document.CaretLostFocus ();
-                       base.OnLostFocusInternal (e);
-               }
-
                private bool IsDoubleClick (MouseEventArgs e)
                {
                        TimeSpan interval = DateTime.Now - click_last;

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs    
2007-01-16 01:51:52 UTC (rev 71102)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/UpDownBase.cs    
2007-01-16 02:04:30 UTC (rev 71103)
@@ -57,17 +57,19 @@
                        #endregion      // Local Variables
 
                        #region Constructors
-                       public UpDownSpinner(UpDownBase owner) {
+                       public UpDownSpinner(UpDownBase owner)
+                       {
                                this.owner = owner;
 
                                mouse_pressed = 0;
 
-                               
this.SetStyle(ControlStyles.AllPaintingInWmPaint, true);
-                               this.SetStyle(ControlStyles.DoubleBuffer, true);
-                               this.SetStyle(ControlStyles.Opaque, true);
-                               this.SetStyle(ControlStyles.ResizeRedraw, true);
-                               this.SetStyle(ControlStyles.UserPaint, true);
-                               this.SetStyle(ControlStyles.FixedHeight, true);
+                               SetStyle(ControlStyles.AllPaintingInWmPaint, 
true);
+                               SetStyle(ControlStyles.DoubleBuffer, true);
+                               SetStyle(ControlStyles.Opaque, true);
+                               SetStyle(ControlStyles.ResizeRedraw, true);
+                               SetStyle(ControlStyles.UserPaint, true);
+                               SetStyle(ControlStyles.FixedHeight, true);
+                               SetStyle(ControlStyles.Selectable, false);
 
                                tmrRepeat = new Timer();
 
@@ -80,7 +82,8 @@
                        #endregion      // Constructors
 
                        #region Private & Internal Methods
-                       private void compute_rects() {
+                       private void compute_rects ()
+                       {
                                int top_button_height;
                                int bottom_button_height;
 
@@ -91,7 +94,8 @@
                                bottom_button_rect = new Rectangle(0, 
top_button_height, ClientSize.Width, bottom_button_height);
                        }
 
-                       private void redraw(Graphics graphics) {
+                       private void redraw (Graphics graphics)
+                       {
                                ButtonState top_button_state;
                                ButtonState bottom_button_state;
 
@@ -111,7 +115,8 @@
                                ControlPaint.DrawScrollButton(graphics, 
bottom_button_rect, ScrollButton.Down, bottom_button_state);
                        }
 
-                       private void tmrRepeat_Tick(object sender, EventArgs e) 
{
+                       private void tmrRepeat_Tick (object sender, EventArgs e)
+                       {
                                if (repeat_delay > 1) {
                                        repeat_counter++;
 
@@ -138,7 +143,8 @@
                        #endregion      // Private & Internal Methods
 
                        #region Protected Instance Methods
-                       protected override void OnMouseDown(MouseEventArgs e) {
+                       protected override void OnMouseDown (MouseEventArgs e)
+                       {
                                if (e.Button != MouseButtons.Left) {
                                        return;
                                }
@@ -162,7 +168,8 @@
                                Refresh ();
                        }
 
-                       protected override void OnMouseMove(MouseEventArgs e) {
+                       protected override void OnMouseMove (MouseEventArgs e)
+                       {
                                ButtonState before, after;
 
                                before = ButtonState.Normal;
@@ -199,71 +206,89 @@
                                }
                        }
 
-                       protected override void OnMouseUp(MouseEventArgs e) {
+                       protected override void OnMouseUp(MouseEventArgs e)
+                       {
                                mouse_pressed = 0;
                                Capture = false;
 
                                Refresh ();
                        }
 
-                       protected override void OnMouseWheel(MouseEventArgs e) {
+                       protected override void OnMouseWheel(MouseEventArgs e)
+                       {
                                if (e.Delta > 0)
                                        owner.UpButton();
                                else if (e.Delta < 0)
                                        owner.DownButton();
                        }
 
-                       protected override void OnPaint(PaintEventArgs e) {
+                       protected override void OnPaint(PaintEventArgs e)
+                       {
                                redraw(e.Graphics);
                        }
 
-                       protected override void OnResize(EventArgs e) {
+                       protected override void OnResize(EventArgs e)
+                       {
                                base.OnResize(e);
                                compute_rects();
                        }
                        #endregion      // Protected Instance Methods
-
-                       
-                       internal void SetSelectable (bool selectable)
-                       {
-                               SetStyle (ControlStyles.Selectable, selectable);
-                       }
                }
                #endregion      // UpDownSpinner Sub-class
 
                internal class UpDownTextBox : TextBox {
 
-                       //private UpDownBase owner;
+                       private UpDownBase owner;
 
                        public UpDownTextBox (UpDownBase owner)
                        {
-                               //this.owner = owner;
+                               this.owner = owner;
 
                                SetStyle (ControlStyles.FixedWidth, false);
+                               SetStyle (ControlStyles.Selectable, false);
                        }
 
-                       internal void SetSelectable (bool selectable)
+
+                       // The following can be shown to be present by
+                       // adding events to both the UpDown and the
+                       // internal textbox.  the textbox doesn't
+                       // generate any, and the updown generates them
+                       // all instead.
+                       protected override void OnGotFocus (EventArgs e)
                        {
-                               SetStyle (ControlStyles.Selectable, selectable);
+                               ShowSelection = true;
+                               owner.OnGotFocus (e);
+                               // doesn't chain up
                        }
 
-                       internal void ActivateCaret (bool active)
+                       protected override void OnLostFocus (EventArgs e)
                        {
-                               if (active)
-                                       document.CaretHasFocus ();
-                               else
-                                       document.CaretLostFocus ();
+                               ShowSelection = false;
+                               owner.OnLostFocus (e);
+                               // doesn't chain up
                        }
 
-                       protected override void OnGotFocus(EventArgs e)
+                       protected override void OnMouseDown (MouseEventArgs e)
                        {
-                               this.Parent.OnGotFocusInternal(e);
+                               // XXX look into whether or not the
+                               // mouse event args are altered in
+                               // some way.
+
+                               owner.OnMouseDown (e);
+                               // doesn't chain up
                        }
 
-                       protected override void OnLostFocus(EventArgs e)
+                       protected override void OnMouseUp (MouseEventArgs e)
                        {
-                               this.Parent.OnLostFocusInternal(e);
+                               // XXX look into whether or not the
+                               // mouse event args are altered in
+                               // some way.
+
+                               owner.OnMouseUp (e);
+                               // doesn't chain up
                        }
+
+                       // XXX there are likely more events that forward up to 
the UpDown
                }
 
                #region Local Variables
@@ -276,7 +301,8 @@
                #endregion      // Local Variables
 
                #region Public Constructors
-               public UpDownBase() {
+               public UpDownBase()
+               {
                        _UpDownAlign = LeftRightAlignment.Right;
                        border_style = BorderStyle.Fixed3D;
 
@@ -311,17 +337,17 @@
                        // So the child controls don't get auto selected when 
the updown is selected
                        auto_select_child = false;
                        SetStyle(ControlStyles.FixedHeight, true);
+                       SetStyle(ControlStyles.Selectable, true);
 #if NET_2_0
                        SetStyle (ControlStyles.Opaque | 
ControlStyles.ResizeRedraw, true);
                        SetStyle (ControlStyles.StandardClick | 
ControlStyles.UseTextForAccessibility, false);
 #endif
-
-                       UpdateEditText ();
                }
                #endregion
 
                #region Private Methods
-               void reseat_controls() {
+               void reseat_controls()
+               {
                        int text_displacement = 0;
 
                        int spinner_width = 16;
@@ -346,26 +372,11 @@
                        txtView.TabIndex = TabIndex;
                }
 
-               internal override void OnPaintInternal (PaintEventArgs e) {
+               internal override void OnPaintInternal (PaintEventArgs e)
+               {
                        
e.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), 
ClientRectangle);
                }
 
-               internal override void OnGotFocusInternal (EventArgs e)
-               {
-                       base.OnGotFocusInternal (e);
-                       txtView.ActivateCaret (true);
-                       txtView.SetSelectable (false);
-                       spnSpinner.SetSelectable (false);
-               }
-
-               internal override void OnLostFocusInternal (EventArgs e)
-               {
-                       base.OnLostFocusInternal (e);
-                       txtView.ActivateCaret (false);
-                       txtView.SetSelectable (true);
-                       spnSpinner.SetSelectable (true);
-               }
-
                #endregion      // Private Methods
 
                #region Public Instance Properties
@@ -452,7 +463,7 @@
                
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
                public override bool Focused {
                        get {
-                               return base.Focused;
+                               return txtView.Focused;
                        }
                }
 
@@ -526,6 +537,8 @@
 
                                if (!suppress_validation)
                                        ValidateEditText();
+
+                               txtView.SelectionLength = 0;
                        }
                }
 
@@ -587,16 +600,18 @@
                #endregion      // Protected Instance Properties
 
                #region Public Instance Methods
-               public abstract void DownButton();
-               public void Select(int start, int length) {
+               public abstract void DownButton ();
+               public void Select(int start, int length)
+               {
                        txtView.Select(start, length);
                }
 
-               public abstract void UpButton();
+               public abstract void UpButton ();
                #endregion      // Public Instance Methods
 
                #region Protected Instance Methods
-               protected override void Dispose(bool disposing) {
+               protected override void Dispose (bool disposing)
+               {
                        if (disposing) {
                                txtView.Dispose();
                                txtView = null;
@@ -607,34 +622,36 @@
                        base.Dispose (disposing);
                }
 
-               protected virtual void OnChanged(object source, EventArgs e) {
+               protected virtual void OnChanged (object source, EventArgs e)
+               {
                }
 
-               protected override void OnFontChanged(EventArgs e) {
+               protected override void OnFontChanged (EventArgs e)
+               {
                        txtView.Font = this.Font;
                        Height = PreferredHeight;
                }
 
-               protected override void OnHandleCreated(EventArgs e) {
+               protected override void OnHandleCreated (EventArgs e)
+               {
                        base.OnHandleCreated (e);
                }
 
-               protected override void OnLayout(LayoutEventArgs e) {
+               protected override void OnLayout (LayoutEventArgs e)
+               {
                        base.OnLayout(e);
                }
 
-               protected override void OnMouseWheel(MouseEventArgs e) {
-                       if (e.Delta > 0) 
-                       {
+               protected override void OnMouseWheel (MouseEventArgs e)
+               {
+                       if (e.Delta > 0)
                                UpButton();
-                       } 
-                       else if (e.Delta < 0) 
-                       {
+                       else if (e.Delta < 0)
                                DownButton();
-                       }
                }
 
-               protected virtual void OnTextBoxKeyDown(object source, 
KeyEventArgs e) {
+               protected virtual void OnTextBoxKeyDown (object source, 
KeyEventArgs e)
+               {
                        if (_InterceptArrowKeys) {
                                if ((e.KeyCode == Keys.Up) || (e.KeyCode == 
Keys.Down)) {
                                        e.Handled = true;
@@ -649,7 +666,8 @@
                        OnKeyDown(e);
                }
 
-               protected virtual void OnTextBoxKeyPress(object source, 
KeyPressEventArgs e) {
+               protected virtual void OnTextBoxKeyPress (object source, 
KeyPressEventArgs e)
+               {
                        if (e.KeyChar == '\r') {
                                e.Handled = true;
                                ValidateEditText();
@@ -657,52 +675,61 @@
                        OnKeyPress(e);
                }
 
-               protected virtual void OnTextBoxLostFocus(object source, 
EventArgs e) {
+               protected virtual void OnTextBoxLostFocus (object source, 
EventArgs e)
+               {
                        if (user_edit) {
                                ValidateEditText();
                        }
                }
 
-               protected virtual void OnTextBoxResize(object source, EventArgs 
e) {
+               protected virtual void OnTextBoxResize (object source, 
EventArgs e)
+               {
                        // compute the new height, taking the border into 
account
                        Height = PreferredHeight;
 
                        // let anchoring reposition the controls
                }
 
-               protected virtual void OnTextBoxTextChanged(object source, 
EventArgs e) {
-                       if (changing_text) {
+               protected virtual void OnTextBoxTextChanged (object source, 
EventArgs e)
+               {
+                       if (changing_text)
                                ChangingText = false;
-                       } else {
+                       else
                                UserEdit = true;
-                       }
 
                        OnTextChanged(e);
                }
 
-               protected override void SetBoundsCore(int x, int y, int width, 
int height, BoundsSpecified specified) {
+               protected override void SetBoundsCore (int x, int y, int width, 
int height, BoundsSpecified specified)
+               {
                        base.SetBoundsCore(x, y, width, height, specified);
 
-                       if ((specified & BoundsSpecified.Size) != 
BoundsSpecified.None) {
+                       if ((specified & BoundsSpecified.Size) != 
BoundsSpecified.None)
                                reseat_controls();
-                       }
                }
 
-               protected abstract void UpdateEditText();
+               protected abstract void UpdateEditText ();
 
-               protected virtual void ValidateEditText() {
+               protected virtual void ValidateEditText ()
+               {
                        // to be overridden by subclassers
                }
 
                [EditorBrowsable(EditorBrowsableState.Advanced)]
-               protected override void WndProc(ref Message m) {
-
+               protected override void WndProc (ref Message m)
+               {
                        switch((Msg) m.Msg) {
                        case Msg.WM_KEYUP:
                        case Msg.WM_KEYDOWN:
                        case Msg.WM_CHAR:
                                XplatUI.SendMessage (txtView.Handle, (Msg) 
m.Msg, m.WParam, m.LParam);
                                break;
+                       case Msg.WM_SETFOCUS:
+                               ActiveControl = txtView;
+                               break;
+                       case Msg.WM_KILLFOCUS:
+                               ActiveControl = null;
+                               break;
                        default:
                                base.WndProc (ref m);
                                break;

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

Reply via email to