2007-04-02 Jonathan Pobst <monkey@jpobst.com>
authorJonathan Pobst <monkey@jpobst.com>
Mon, 2 Apr 2007 21:24:42 +0000 (21:24 -0000)
committerJonathan Pobst <monkey@jpobst.com>
Mon, 2 Apr 2007 21:24:42 +0000 (21:24 -0000)
* StatusStrip.cs: Layout fixes for PDN.
* ToolStrip.cs: Set item's available to true, and placement to main when
added.
* ToolStripItem.cs: Fix an Available issue, check that Parent is really
changing in setter before doing any work, add InternalVisible.
* ToolStripPanel.cs: Remove unused variable to fix compiler warning.
* ToolStripSplitStackLayout.cs: If we run out of things to hide, don't
infinite loop.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusStrip.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStrip.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripItem.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripPanel.cs
mcs/class/Managed.Windows.Forms/System.Windows.Forms/ToolStripSplitStackLayout.cs

index 24fe8688725c7a221ca1210f230daf5130574c81..5e5e103940db8c7351d80f67990a2cfc9c6da867 100644 (file)
@@ -1,3 +1,14 @@
+2007-04-02  Jonathan Pobst  <monkey@jpobst.com>
+
+       * StatusStrip.cs: Layout fixes for PDN.
+       * ToolStrip.cs: Set item's available to true, and placement to main when
+       added.
+       * ToolStripItem.cs: Fix an Available issue, check that Parent is really
+       changing in setter before doing any work, add InternalVisible.
+       * ToolStripPanel.cs: Remove unused variable to fix compiler warning.
+       * ToolStripSplitStackLayout.cs: If we run out of things to hide, don't
+       infinite loop.
+
 2007-04-02  Jackson Harper  <jackson@ximian.com>
 
        * TextBox.cs: LBUTTON does not make the textbox select all of it's
index 9d13347fa293b4e9b390abf86684859377e67ca8..d3bd96bc3ca415e5af070a8feb9650f35cc5e7f7 100644 (file)
@@ -154,7 +154,8 @@ namespace System.Windows.Forms
 
                protected virtual void OnSpringTableLayoutCore ()
                {
-                       this.SetDisplayedItems ();
+                       if (!this.Created)
+                               return;
 
                        ToolStripItemOverflow[] overflow = new ToolStripItemOverflow[this.Items.Count];
                        ToolStripItemPlacement[] placement = new ToolStripItemPlacement[this.Items.Count];
@@ -169,6 +170,7 @@ namespace System.Windows.Forms
                                overflow[i] = tsi.Overflow;
                                widths[i] = tsi.GetPreferredSize (proposedSize).Width + tsi.Margin.Horizontal;
                                placement[i] = tsi.Overflow == ToolStripItemOverflow.Always ? ToolStripItemPlacement.None : ToolStripItemPlacement.Main;
+                               placement[i] = tsi.Available ? placement[i] : ToolStripItemPlacement.None;
                                total_width += placement[i] == ToolStripItemPlacement.Main ? widths[i] : 0;
                                if (tsi is ToolStripStatusLabel && (tsi as ToolStripStatusLabel).Spring)
                                        spring_count++;
@@ -198,6 +200,10 @@ namespace System.Windows.Forms
                                                        removed_one = true;
                                                        break;
                                                }
+
+                               // There's nothing left to remove, break or we will loop forever        
+                               if (!removed_one)
+                                       break;
                        }
 
                        if (spring_count > 0) {
@@ -226,7 +232,9 @@ namespace System.Windows.Forms
                                }
 
                                i++;
-                       }                       
+                       }
+
+                       this.SetDisplayedItems ();
                }
 
                protected override void SetDisplayedItems ()
@@ -234,8 +242,11 @@ namespace System.Windows.Forms
                        this.displayed_items.Clear ();
 
                        foreach (ToolStripItem tsi in this.Items)
-                               if (tsi.Available)
+                               if (tsi.Placement == ToolStripItemPlacement.Main) {
                                        this.displayed_items.AddNoOwnerOrLayout (tsi);
+                                       tsi.InternalVisible = true;     
+                               } else
+                                       tsi.InternalVisible = false;
                }
                
                protected override void WndProc (ref Message m)
index 9595f68bf925335847d0ce32f88f51becd770498..1134ef75aff0884a6dab063ef70d15d0e71ee87e 100644 (file)
@@ -575,6 +575,8 @@ namespace System.Windows.Forms
 
                protected internal virtual void OnItemAdded (ToolStripItemEventArgs e)
                {
+                       e.Item.Available = true;
+                       e.Item.SetPlacement (ToolStripItemPlacement.Main);
                        this.DoAutoSize ();
                        this.PerformLayout ();
                        
index 734103c097ec5464d9ddd665c1fb426cfb679296..5eee479452f851f2abceda20846083491a3d40ce 100644 (file)
@@ -45,6 +45,7 @@ namespace System.Windows.Forms
                private bool allow_drop;
                private ToolStripItemAlignment alignment;
                private AnchorStyles anchor;
+               private bool available;
                private bool auto_size;
                private bool auto_tool_tip;
                private Color back_color;
@@ -104,6 +105,7 @@ namespace System.Windows.Forms
                        this.anchor = AnchorStyles.Left | AnchorStyles.Top;
                        this.auto_size = true;
                        this.auto_tool_tip = this.DefaultAutoToolTip;
+                       this.available = true;
                        this.back_color = Control.DefaultBackColor;
                        this.background_image_layout = ImageLayout.Tile;
                        this.can_select = true;
@@ -249,9 +251,10 @@ namespace System.Windows.Forms
                [Browsable (false)]
                [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
                public bool Available {
-                       get { return this.visible; }
+                       get { return this.available; }
                        set {
-                               if (this.visible != value) {
+                               if (this.available != value) {
+                                       available = value;
                                        visible = value;
 
                                        if (this.parent != null)
@@ -689,6 +692,7 @@ namespace System.Windows.Forms
                        }
                        set { 
                                if (this.visible != value) {
+                                       this.available = value;
                                        this.SetVisibleCore (value);
                                }
                        }
@@ -724,9 +728,11 @@ namespace System.Windows.Forms
                protected internal ToolStrip Parent {
                        get { return this.parent; }
                        set { 
-                               ToolStrip old_parent = this.parent;
-                               this.parent = value; 
-                               OnParentChanged(old_parent, this.parent);
+                               if (this.parent != value) {
+                                       ToolStrip old_parent = this.parent;
+                                       this.parent = value; 
+                                       OnParentChanged(old_parent, this.parent);
+                               }
                        }
                }
                protected internal virtual bool ShowKeyboardCues { get { return false; } }
@@ -1456,6 +1462,11 @@ namespace System.Windows.Forms
                        this.placement = placement;
                }
 
+               internal bool InternalVisible {
+                       get { return this.visible; }
+                       set { this.visible = value; }
+               }
+               
                internal Point Location {
                        get { return this.bounds.Location; }
                        set {
index 28fd28499ed7bcfd1b3aa834ce6f9e91c8f21f4f..4e6a99014f3c60b46faf95c5173d95eba9f39c74 100644 (file)
@@ -308,8 +308,6 @@ namespace System.Windows.Forms
                        }
 
                        // Find how big we are so we can autosize ourself
-                       int height = 0;
-                               
                        if (this.rows.Count > 0) {
                                int last_row_bottom = this.rows[this.rows.Count - 1].Bounds.Bottom;
                        
index 921a47f74aac3174bc4757a8781a9983d7f84841..46d38f47c819f05971c45f1d5ca391fcfb657eee 100644 (file)
@@ -204,6 +204,10 @@ namespace System.Windows.Forms
                                                        removed_one = true;
                                                        break;
                                                }
+                                       
+                               // There's nothing left to remove, break or we will loop forever        
+                               if (!removed_one)
+                                       break;
                        }
 
                        i = 0;