/[dotgnu-pnet]/pnetlib/System.Windows.Forms/TabControl.cs
ViewVC logotype

Diff of /pnetlib/System.Windows.Forms/TabControl.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.23 by drobosson, Mon Dec 27 15:35:11 2004 UTC revision 1.24 by drobosson, Tue Dec 28 07:27:55 2004 UTC
# Line 79  namespace System.Windows.Forms Line 79  namespace System.Windows.Forms
79                  private const int indent = 2;                  private const int indent = 2;
80                  // Used to track first paint call, hack to mimmick MS implementation                  // Used to track first paint call, hack to mimmick MS implementation
81                  // of setting first added tab as active                  // of setting first added tab as active
                 private bool firstPaint = true;  
82    
83                  // Tab events                  // Tab events
84                  public event DrawItemEventHandler DrawItem;                  public event DrawItemEventHandler DrawItem;
# Line 123  namespace System.Windows.Forms Line 122  namespace System.Windows.Forms
122    
123                  protected virtual void OnSelectedIndexChanged(EventArgs e)                  protected virtual void OnSelectedIndexChanged(EventArgs e)
124                  {                  {
125                          if (selectedIndex == -1 || selectedIndex >= TabCount)                          //redundant check, is done is SelectedIndex already
126                          {                          //if (selectedIndex == -1 || selectedIndex >= TabCount)
127                                  return;                          //{
128                          }                          //      return;
129                            //}
130                          SuspendLayout();                          SuspendLayout();
131                          if (prevSelectedIndex > -1)                          if (prevSelectedIndex > -1)
132                          {                          {
# Line 281  namespace System.Windows.Forms Line 281  namespace System.Windows.Forms
281                          }                          }
282                          set                          set
283                          {                          {
284                                  SelectedIndex = tabPageCollection.IndexOf(value);                                  selectedIndex = tabPageCollection.IndexOf(value);
285                          }                          }
286                  }                  }
287    
# Line 357  namespace System.Windows.Forms Line 357  namespace System.Windows.Forms
357    
358                          public override void Add(Control control)                          public override void Add(Control control)
359                          {                          {
                                 control.Visible = false;  
360                                  base.Add(control);                                  base.Add(control);
361                                  tabOwner.InvalidateTabs ();                                  tabOwner.InvalidateTabs ();
362                                  tabOwner.SetTabPageBounds();                                  tabOwner.SetTabPageBounds();
                                 if (tabOwner.SelectedTab == control)  
                                 {  
                                         control.Visible = true;  
                                 }  
363                          }                          }
364    
365                          [TODO]                          [TODO]
# Line 546  namespace System.Windows.Forms Line 541  namespace System.Windows.Forms
541    
542                  protected override void OnPaint(PaintEventArgs e)                  protected override void OnPaint(PaintEventArgs e)
543                  {                  {
                         // Work around to set the SelectedTab to the first  
                         // added TabPage.  
                         if(firstPaint)  
                         {  
                                 if((selectedIndex > -1) &&  
                                         (tabPageCollection.Count > 0))  
                                 {  
                                         SelectedTab = (TabPage)tabPageCollection[selectedIndex];  
                                 }  
                                 firstPaint = false;  
                         }  
544    
545                          Draw(e.Graphics);                          Draw(e.Graphics);
546                          // Draw the visible TabPage (child controls)                          // Draw the visible TabPage (child controls)
# Line 618  namespace System.Windows.Forms Line 602  namespace System.Windows.Forms
602                          {                          {
603                                  for( int i = 0; i < tabPageCollection.Count; i++ )                                  for( int i = 0; i < tabPageCollection.Count; i++ )
604                                  {                                  {
605                                          if (row == PositionInfo.positions[i].row && i != selectedIndex)                                          if (row == PositionInfo.positions[i].row && i != SelectedIndex)
606                                          {                                          {
607                                                  Rectangle bounds = GetTabRect(i);                                                  Rectangle bounds = GetTabRect(i);
608                                                  // Remove bottom line off bounds if not selected so border isnt covered                                                  // Remove bottom line off bounds if not selected so border isnt covered
# Line 628  namespace System.Windows.Forms Line 612  namespace System.Windows.Forms
612                                          }                                          }
613                                  }                                  }
614                          }                          }
615                          if (selectedIndex > -1 && selectedIndex < TabPages.Count)                          if (SelectedIndex < TabPages.Count)
616                          {                          {
617                                  Rectangle bounds = GetTabRect(selectedIndex);                                  Rectangle bounds = GetTabRect(SelectedIndex);
618                                  g.SetClip(new Rectangle(bounds.Left, bounds.Top, bounds.Width, bounds.Height), Drawing.Drawing2D.CombineMode.Intersect);                                  g.SetClip(new Rectangle(bounds.Left, bounds.Top, bounds.Width, bounds.Height), Drawing.Drawing2D.CombineMode.Intersect);
619                                                                    
620                                  DrawItemState state;                                  DrawItemState state;
621                                  if (Focused)                                  if (Focused)
622                                          state = DrawItemState.Focus;                                          state = DrawItemState.Focus;// | DrawItemState.Selected;
623                                  else                                  else
624                                          state = DrawItemState.None;                                          state = DrawItemState.Default; //DrawItemState.Selected;
625                                  OnDrawItem( new DrawItemEventArgs(g, Font, bounds, selectedIndex, state, ForeColor, BackColor));                                  OnDrawItem( new DrawItemEventArgs(g, Font, bounds, SelectedIndex, state, ForeColor, BackColor));
626                          }                          }
627    
628                  }                  }
# Line 688  namespace System.Windows.Forms Line 672  namespace System.Windows.Forms
672                                                                  SizeTabsFillRight ( ref tabs, graphics, rowWidth, out maxRow );                                                                  SizeTabsFillRight ( ref tabs, graphics, rowWidth, out maxRow );
673                                                  }                                                  }
674                                                  // Do we need to move the row that was selected to the bottom of the tabs?                                                  // Do we need to move the row that was selected to the bottom of the tabs?
675                                                  if (selectedIndex > -1 && selectedIndex < TabCount)                                                  // why is bounds checked here again? its redundant.
676                                                  {                                                  //if (SelectedIndex < TabCount)
677                                                    //{
678                                                          // Check to see if we have selected a tab that isnt on the last row and move the tab row down                                                          // Check to see if we have selected a tab that isnt on the last row and move the tab row down
679                                                          if (tabs[selectedIndex].row != maxRow)                                                          if (tabs[SelectedIndex].row != maxRow)
680                                                                  RowToBottom(ref tabs, tabs[selectedIndex].row, maxRow);                                                                  RowToBottom(ref tabs, tabs[SelectedIndex].row, maxRow);
681                                                  }                                                  //}
682    
683                                                  // Find the actual bounds                                                  // Find the actual bounds
684                                                  LayoutTabBounds( ref tabs, rowWidth );                                                  LayoutTabBounds( ref tabs, rowWidth );
# Line 935  namespace System.Windows.Forms Line 920  namespace System.Windows.Forms
920                                  {                                  {
921                                          // Move the tabs thats selected by 1                                          // Move the tabs thats selected by 1
922                                          int selDelta = 0;                                          int selDelta = 0;
923                                          if (i != selectedIndex)                                          if (i != SelectedIndex)
924                                                  selDelta = 1;                                                  selDelta = 1;
925    
926                                          TabPosition tab = tabs[i];                                          TabPosition tab = tabs[i];
927                                          int width = tab.bounds.Width + (1-selDelta)*2*indent;                                          int width = tab.bounds.Width + (1-selDelta)*2*indent;
928                                          // Draw the left edge of tabs that begin a row or are selected                                          // Draw the left edge of tabs that begin a row or are selected
929                                          if (tab.bounds.Left - leftOffset == 0 || selectedIndex == i)                                          if (tab.bounds.Left - leftOffset == 0 || SelectedIndex == i)
930                                                  tab.leftExposed = true;                                                  tab.leftExposed = true;
931                                          tab.bounds = new Rectangle(tab.bounds.Left + indent - (1-selDelta)*2 - leftOffset, yDirection *((tab.row + extraRow ) * down + selDelta) + top, width, down + 1 - selDelta );                                          tab.bounds = new Rectangle(tab.bounds.Left + indent - (1-selDelta)*2 - leftOffset, yDirection *((tab.row + extraRow ) * down + selDelta) + top, width, down + 1 - selDelta );
932                                          tabs[i] = tab;                                          tabs[i] = tab;
# Line 1019  namespace System.Windows.Forms Line 1004  namespace System.Windows.Forms
1004                          }                          }
1005                          set                          set
1006                          {                          {
1007                                    if (value < 0 || value >= tabPageCollection.Count)
1008                                    {
1009                                            throw new IndexOutOfRangeException(value.ToString());
1010                                    }
1011                                  if (value != selectedIndex)                                  if (value != selectedIndex)
1012                                  {                                  {
1013                                          prevSelectedIndex = selectedIndex;                                          prevSelectedIndex = selectedIndex;

Legend:
Removed from v.1.23  
changed lines
  Added in v.1.24

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26