dotgnu-pnet-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[dotgnu-pnet-commits] pnetlib ./ChangeLog System.Windows.Forms/TabCon...


From: Heiko Weiss
Subject: [dotgnu-pnet-commits] pnetlib ./ChangeLog System.Windows.Forms/TabCon...
Date: Mon, 29 May 2006 11:47:23 +0000

CVSROOT:        /sources/dotgnu-pnet
Module name:    pnetlib
Branch:         
Changes by:     Heiko Weiss <address@hidden>    06/05/29 11:47:23

Modified files:
        .              : ChangeLog 
        System.Windows.Forms: TabControl.cs 

Log message:
        fixed SelectedIndex and SelectedTab like M$ does
        fixed MouseDown

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/ChangeLog.diff?tr1=1.2407&tr2=1.2408&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/dotgnu-pnet/pnetlib/System.Windows.Forms/TabControl.cs.diff?tr1=1.29&tr2=1.30&r1=text&r2=text

Patches:
Index: pnetlib/ChangeLog
diff -u pnetlib/ChangeLog:1.2407 pnetlib/ChangeLog:1.2408
--- pnetlib/ChangeLog:1.2407    Thu May 25 19:29:11 2006
+++ pnetlib/ChangeLog   Mon May 29 11:47:22 2006
@@ -1,3 +1,8 @@
+2006-05-29  Heiko Weiss  <address@hidden>
+
+       * System.Windows.Forms/TabControl.cs: fixed SelectedIndex and
+       SelectedTab like M$ does, fixed MouseDown.
+
 2006-05-18  Heiko Weiss  <address@hidden>
 
        * System.Windows.Forms/ScrollableControl.cs: fixed autoscrolling
Index: pnetlib/System.Windows.Forms/TabControl.cs
diff -u pnetlib/System.Windows.Forms/TabControl.cs:1.29 
pnetlib/System.Windows.Forms/TabControl.cs:1.30
--- pnetlib/System.Windows.Forms/TabControl.cs:1.29     Wed Apr 12 17:50:50 2006
+++ pnetlib/System.Windows.Forms/TabControl.cs  Mon May 29 11:47:23 2006
@@ -108,7 +108,9 @@
                        return tabPageCollection[index];
                }
 
-               protected string GetToolTipText(object item){
+               protected string GetToolTipText(object item)
+               {
+                       if( selectedIndex < 0 ) return string.Empty;
                        return (tabPageCollection[selectedIndex] as 
TabPage).ToolTipText;
                }
 
@@ -270,7 +272,7 @@
                {
                        get
                        {
-                               if (selectedIndex == -1)
+                               if (SelectedIndex == -1)        // use 
SelectedIndex instead of selectedIndex to active a first tab page, if none was 
selected
                                {
                                        return null;
                                }
@@ -281,7 +283,8 @@
                        }
                        set
                        {
-                               selectedIndex = 
tabPageCollection.IndexOf(value);
+                               // use SelectedIndex, not selectedIndex to do 
events
+                               SelectedIndex = 
tabPageCollection.IndexOf(value);
                        }
                }
 
@@ -685,8 +688,10 @@
                                                //if (SelectedIndex < TabCount)
                                                //{
                                                        // Check to see if we 
have selected a tab that isnt on the last row and move the tab row down
+                                               if( selectedIndex >= 0 ) {
                                                        if 
(tabs[SelectedIndex].row != maxRow)
                                                                RowToBottom(ref 
tabs, tabs[SelectedIndex].row, maxRow);
+                                               }
                                                //}
 
                                                // Find the actual bounds
@@ -1002,24 +1007,15 @@
                public int SelectedIndex {
                        get
                        {
-                               if (selectedIndex == -1)
-                               {
-                                       // if selectedIndex is -1 (none TabPage 
was selected)
-                                       // Check if any TabPage is visible
-                                       // Select first visible TabPage
-                                       int iCount = tabPageCollection.Count;
-                                       for( int i = 0; i < iCount; i++ ) {
-                                               if( 
tabPageCollection[i].Visible ) {
-                                                       SelectedIndex = i;
-                                                       break;
-                                               }
-                                       }
-                                       return selectedIndex;
-                               }
-                               else
-                               {
-                                       return selectedIndex;
+                               if( selectedIndex == -1 && 
tabPageCollection.Count > 0 ) {
+                                       selectedIndex = 0;      // select first 
tab page without calling OnSelectedIndexChanged, like windows does.
+                                       
+                                       Control selectedPage = GetChildByIndex( 
selectedIndex );
+                                       selectedPage.Visible = true;
+                                       SetTabPageBounds();
+                                       InvalidateTabs();
                                }
+                               return selectedIndex;
                        }
                        set
                        {
@@ -1130,47 +1126,51 @@
                // Select the tab that is clicked
                protected override void OnMouseDown(MouseEventArgs e)
                {
-                       if (moveButtonsShowing && 
moveButtonLeftBounds.Contains( e.X, e.Y ))
-                       {
-                               moveButtonLeftState = ButtonState.Pushed;
-                               if (moveButtonsTabOffset > 0)
+                       // select tabs only on left mouse button
+                       if( e.Button == MouseButtons.Left ) {
+                               if (moveButtonsShowing && 
moveButtonLeftBounds.Contains( e.X, e.Y ))
                                {
-                                       moveButtonsTabOffset--;
-                                       InvalidateTabs();
+                                       moveButtonLeftState = 
ButtonState.Pushed;
+                                       if (moveButtonsTabOffset > 0)
+                                       {
+                                               moveButtonsTabOffset--;
+                                               InvalidateTabs();
+                                       }
                                }
-                       }
-                       else if (moveButtonsShowing && 
moveButtonRightBounds.Contains(e.X, e.Y))
-                       {
-                               moveButtonRightState = ButtonState.Pushed;
-                               if (moveButtonsTabOffset < 
tabPageCollection.Count - 1 && moveButtonsCovered)
+                               else if (moveButtonsShowing && 
moveButtonRightBounds.Contains(e.X, e.Y))
                                {
-                                       moveButtonsTabOffset++;
-                                       InvalidateTabs();
+                                       moveButtonRightState = 
ButtonState.Pushed;
+                                       if (moveButtonsTabOffset < 
tabPageCollection.Count - 1 && moveButtonsCovered)
+                                       {
+                                               moveButtonsTabOffset++;
+                                               InvalidateTabs();
+                                       }
                                }
-                       }
-                       else
-                       {
-                               moveButtonRightState = ButtonState.Normal;
-                               int newSelectedIndex =  GetMouseOverTab( e.X, 
e.Y );
-                               if (newSelectedIndex > -1)
+                               else
                                {
-                                       SelectedIndex = newSelectedIndex;
-                                       
-                                       // Handle focus.
-                                       if (!Focused)
+                                       moveButtonRightState = 
ButtonState.Normal;
+                                       int newSelectedIndex =  
GetMouseOverTab( e.X, e.Y );
+                                       if (newSelectedIndex > -1)
                                        {
-                                               if 
(!SelectedTab.SelectNextControl(null, true, true, false, false))
+                                               SelectedIndex = 
newSelectedIndex;
+                                               
+                                               // Handle focus.
+                                               if (!Focused)
                                                {
-                                                       IContainerControl 
container = Parent.GetContainerControl();
-                                                       if (container != null)
+                                                       if 
(!SelectedTab.SelectNextControl(null, true, true, false, false))
                                                        {
-                                                               
container.ActiveControl = this;
+                                                               
IContainerControl container = Parent.GetContainerControl();
+                                                               if (container 
!= null)
+                                                               {
+                                                                       
container.ActiveControl = this;
+                                                               }
                                                        }
                                                }
+       
                                        }
-
                                }
                        }
+                       
                        base.OnMouseDown (e);
 
                }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]