Author: toshok
Date: 2006-07-06 22:24:23 -0400 (Thu, 06 Jul 2006)
New Revision: 62334

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabel.cs
Log:
        * LinkLabel.cs (.ctor): SetStyle Selectable to true.
        (OnEnableChanged): s/Refresh/Invalidate
        (OnGotFocus): if we have a focused index already, refocus it (so
        if we mouse out/in to the window it'll focus the right link).
        (OnKeyDown): move the tab handling out of here.
        (OnLostFocus): don't set focused_index to -1, so we can refocus it
        when we lose focus.
        (OnMouseDown): don't Capture here - Control handles it.  Also,
        focus the active link.
        (OnMouseUp): don't deal with Capture.
        (OnPaintBackgroundInternal): remove.
        (OnTextAlignChanged): CreateLinkPieces before calling the
        superclass's method.
        (OnTextChanged): call CreateLinkPieces before calling superclass's
        method.
        (ProcessDialogKey): handle Tab here, and call Select(bool,bool) to
        move around.
        (Select): implement this, moving the selection between different
        links, and call parent.SelectNextControl if we don't have another
        link to focus in the given direction.
        (CreateLinkPieces): call Invalidate instead of Refresh.

2006-07-06  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-07-07 00:26:04 UTC (rev 62333)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-07-07 02:24:23 UTC (rev 62334)
@@ -1,5 +1,29 @@
 2006-07-06  Chris Toshok  <[EMAIL PROTECTED]>
 
+       * LinkLabel.cs (.ctor): SetStyle Selectable to true.
+       (OnEnableChanged): s/Refresh/Invalidate
+       (OnGotFocus): if we have a focused index already, refocus it (so
+       if we mouse out/in to the window it'll focus the right link).
+       (OnKeyDown): move the tab handling out of here.
+       (OnLostFocus): don't set focused_index to -1, so we can refocus it
+       when we lose focus.
+       (OnMouseDown): don't Capture here - Control handles it.  Also,
+       focus the active link.
+       (OnMouseUp): don't deal with Capture.
+       (OnPaintBackgroundInternal): remove.
+       (OnTextAlignChanged): CreateLinkPieces before calling the
+       superclass's method.
+       (OnTextChanged): call CreateLinkPieces before calling superclass's
+       method.
+       (ProcessDialogKey): handle Tab here, and call Select(bool,bool) to
+       move around.
+       (Select): implement this, moving the selection between different
+       links, and call parent.SelectNextControl if we don't have another
+       link to focus in the given direction.
+       (CreateLinkPieces): call Invalidate instead of Refresh.
+
+2006-07-06  Chris Toshok  <[EMAIL PROTECTED]>
+
        * ThemeWin32Classic.cs: DrawLinkLabel changes to accomodate the
        new LinkLabel internals.
 

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabel.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabel.cs     
2006-07-07 00:26:04 UTC (rev 62333)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/LinkLabel.cs     
2006-07-07 02:24:23 UTC (rev 62334)
@@ -98,8 +98,8 @@
                        DisabledLinkColor = ThemeEngine.Current.ColorGrayText;
                        LinkColor = Color.FromArgb (255, 0, 0, 255);
                        VisitedLinkColor = Color.FromArgb (255, 128, 0, 128);
-                       SetStyle (ControlStyles.Selectable, false);
                        SetStyle (ControlStyles.Opaque, true);
+                       SetStyle (ControlStyles.Selectable, true);
                }
 
                #region Public Properties
@@ -256,7 +256,7 @@
                protected override void OnEnabledChanged (EventArgs e)
                {
                        base.OnEnabledChanged (e);
-                       Refresh ();
+                       Invalidate ();
                }
 
                protected override void OnFontChanged (EventArgs e)
@@ -269,39 +269,29 @@
                protected override void OnGotFocus (EventArgs e)
                {
                        base.OnGotFocus (e);                    
-                       
-                       // Set focus to the first enabled link piece            
        
-                       for (int i = 0; i < sorted_links.Length; i ++) {
-                               if (sorted_links[i].Enabled) {
-                                       sorted_links[i].Focused = true;
-                                       focused_index = i;
-                                       break;
+
+                       // Set focus to the first enabled link piece
+                       if (focused_index == -1) {
+                               for (int i = 0; i < sorted_links.Length; i ++) {
+                                       if (sorted_links[i].Enabled) {
+                                               focused_index = i;
+                                               break;
+                                       }
                                }
                        }
+
+                       if (focused_index != -1)
+                               sorted_links[focused_index].Focused = true;
                }
 
                protected override void OnKeyDown (KeyEventArgs e)
                {
-                       base.OnKeyDown(e);
-
-                       // Set focus to the next link piece
-                       if (e.KeyCode == Keys.Tab || e.KeyCode == Keys.Right) {
-                               if (focused_index != -1) {
-                                       sorted_links[focused_index].Focused = 
false;
-                                       for (int n = focused_index + 1; n < 
sorted_links.Length; n++) {
-                                               if (sorted_links[n].Enabled) {
-                                                       sorted_links[n].Focused 
= true;
-                                                       focused_index = n;
-                                                       e.Handled = true;
-                                                       return;
-                                               }               
-                                       }
-                               }
-                       } else if (e.KeyCode == Keys.Return) {
-                               if (focused_index != -1) {
+                       if (e.KeyCode == Keys.Return) {
+                               if (focused_index != -1)
                                        OnLinkClicked (new 
LinkLabelLinkClickedEventArgs (sorted_links[focused_index]));
-                               }
                        }
+
+                       base.OnKeyDown(e);
                }
 
                protected virtual void OnLinkClicked 
(LinkLabelLinkClickedEventArgs e)
@@ -317,7 +307,6 @@
                        // Clean focus in link pieces
                        if (focused_index != -1)
                                sorted_links[focused_index].Focused = false;
-                       focused_index = -1;
                }
 
                protected override void OnMouseDown (MouseEventArgs e)
@@ -325,7 +314,6 @@
                        if (!Enabled) return;
 
                        base.OnMouseDown (e);
-                       this.Capture = true;
 
                        for (int i = 0; i < sorted_links.Length; i ++) {
                                if (sorted_links[i].Contains (e.X, e.Y) && 
sorted_links[i].Enabled) {
@@ -333,6 +321,8 @@
                                        if (focused_index != -1)
                                                
sorted_links[focused_index].Focused = false;
                                        active_link = sorted_links[i];
+                                       focused_index = i;
+                                       sorted_links[focused_index].Focused = 
true;
                                        break;
                                }
                        }
@@ -383,7 +373,6 @@
                        if (!Enabled) return;
 
                        base.OnMouseUp (e);
-                       this.Capture = false;
 
                        if (active_link == null)
                                return;
@@ -404,10 +393,6 @@
                        // Do not call base.OnPaint since it's the Label class 
                }
 
-               internal override void OnPaintBackgroundInternal(PaintEventArgs 
e) {
-                       base.OnPaintBackground (e);
-               }
-
                protected override void OnPaintBackground (PaintEventArgs e)
                {
                        base.OnPaintBackground (e);
@@ -415,13 +400,14 @@
 
                protected override void OnTextAlignChanged (EventArgs e)
                {
+                       CreateLinkPieces ();                    
                        base.OnTextAlignChanged (e);
-                       CreateLinkPieces ();                    
                }
 
                protected override void OnTextChanged (EventArgs e)
                {
-                       base.OnTextChanged (e);                 
+                       CreateLinkPieces ();
+                       base.OnTextChanged (e);
                }
                
                protected Link PointInLink (int x, int y)
@@ -435,12 +421,41 @@
 
                protected override bool ProcessDialogKey (Keys keyData)
                {
+                       if ((keyData & Keys.KeyCode) ==  Keys.Tab) {
+                               Select (true, (keyData & Keys.Shift) == 0);
+                               return true;
+                       }
                        return base.ProcessDialogKey (keyData);
                }
 
                protected override void Select (bool directed, bool forward)
                {
-                       base.Select (directed, forward);
+                       if (directed) {
+                               if (focused_index != -1)
+                                       sorted_links[focused_index].Focused = 
false;
+
+                               if (forward) {
+                                       for (int n = focused_index + 1; n < 
sorted_links.Length; n++) {
+                                               if (sorted_links[n].Enabled) {
+                                                       sorted_links[n].Focused 
= true;
+                                                       focused_index = n;
+                                                       return;
+                                               }
+                                       }
+                               }
+                               else {
+                                       for (int n = focused_index - 1; n >= 0; 
n--) {
+                                               if (sorted_links[n].Enabled) {
+                                                       sorted_links[n].Focused 
= true;
+                                                       focused_index = n;
+                                                       return;
+                                               }
+                                       }
+                               }
+
+                               if (parent != null)
+                                       parent.SelectNextControl (this, 
forward, false, true, true);
+                       }
                }
 
                protected override void SetBoundsCore (int x, int y, int width, 
int height, BoundsSpecified specified)
@@ -546,8 +561,7 @@
                        for (int i = 0; i < pieces.Length; i ++)
                                pieces[i].region = regions[i];
 
-                       if (Visible && IsHandleCreated)
-                               Refresh ();
+                       Invalidate ();
                }
 
                private void SortLinks ()

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

Reply via email to