2007-05-08 Carlos Alberto Cortez <calberto.cortez@gmail.com>
authorCarlos Alberto Cortez <calberto.cortez@gmail.com>
Wed, 9 May 2007 06:11:59 +0000 (06:11 -0000)
committerCarlos Alberto Cortez <calberto.cortez@gmail.com>
Wed, 9 May 2007 06:11:59 +0000 (06:11 -0000)
* Control.cs: Add InternalContains focus property, which hast the same
functionality of ContainsFocus, but also including implicit controls.
* ListViewItem.cs: Use InternalContainsFocus instead of ContainsFocus,
since we need to know if the focus is contained in our implicit
ItemControl when calculating Layout. Fixes part of #80888.

svn path=/trunk/mcs/; revision=76984

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/Control.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ListViewItem.cs

index 92cb0d8906844922d84aeefee175768a9688f08d..362f6e717b6d92e7b53e60c1b1ee598d40ec1d6d 100644 (file)
@@ -1,3 +1,11 @@
+2007-05-08  Carlos Alberto Cortez <calberto.cortez@gmail.com>
+
+       * Control.cs: Add InternalContains focus property, which hast the same
+       functionality of ContainsFocus, but also including implicit controls.
+       * ListViewItem.cs: Use InternalContainsFocus instead of ContainsFocus,
+       since we need to know if the focus is contained in our implicit
+       ItemControl when calculating Layout. Fixes part of #80888.
+
 2007-05-08  Everaldo Canuto  <everaldo@simios.org>
 
        * ToolTip.cs: Remove center form string alignment as it must be align to
index f80127ba0f9266ff7747c7024a89a04312183b08..4a8aa8bbc9758ea240eaf077b9fa5f49636253a4 100644 (file)
@@ -1120,6 +1120,26 @@ namespace System.Windows.Forms
                                return false;
                        }
                }
+
+               // Looks for focus in child controls
+               // and also in the implicit ones
+               internal bool InternalContainsFocus {
+                       get {
+                               IntPtr focused_window;
+
+                               focused_window = XplatUI.GetFocus();
+                               if (IsHandleCreated) {
+                                       if (focused_window == Handle)
+                                               return true;
+
+                                       foreach (Control child_control in child_controls.GetAllControls ())
+                                               if (child_control.InternalContainsFocus)
+                                                       return true;
+                               }
+
+                               return false;
+                       }
+               }
                
                // Mouse is currently within the control's bounds
                internal bool Entered {
index 379e14240e0ed2df197a26bcbec984ce1d718414..1fc8ac2fdccf7d19c1a4bdae386a56ec775a4035 100644 (file)
@@ -752,7 +752,7 @@ namespace System.Windows.Forms
 
                                SizeF sz = owner.DeviceContext.MeasureString (Text, Font);
                                if ((int) sz.Width > text_size.Width) {
-                                       if (Focused && owner.ContainsFocus) {
+                                       if (Focused && owner.InternalContainsFocus) {
                                                int text_width = text_size.Width;
                                                StringFormat format = new StringFormat ();
                                                format.Alignment = StringAlignment.Center;