Author: jackson
Date: 2006-05-25 14:45:09 -0400 (Thu, 25 May 2006)
New Revision: 61131

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
Log:

        * TreeView.cs: Scrollable is true by default
        - Use invalidate instead of refresh where needed
        - Factor the scrollable value into scrollbar updating
        - Update the scrollbars if the Scrollable property is altered
        - Update the selected node if its ImageIndex is changed
        - Handle null nodes in UpdateNode (mainly so we don't have to
        check if selected is null when updating it



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-05-25 17:41:39 UTC (rev 61130)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-05-25 18:45:09 UTC (rev 61131)
@@ -4,7 +4,14 @@
        panels when we have auto size contents.  Also we are only updating
        the contents of the panel, not the borders, so compensate for the
        border width (TODO: get this width from the theme somehow).
-
+       * TreeView.cs: Scrollable is true by default
+       - Use invalidate instead of refresh where needed
+       - Factor the scrollable value into scrollbar updating
+       - Update the scrollbars if the Scrollable property is altered
+       - Update the selected node if its ImageIndex is changed
+       - Handle null nodes in UpdateNode (mainly so we don't have to
+       check if selected is null when updating it
+       
 2006-05-25 Gonzalo Paniagua Javier <[EMAIL PROTECTED]>
 
        * Application.cs: set the DialogResult to fixed when the main form is

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs      
2006-05-25 17:41:39 UTC (rev 61130)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs      
2006-05-25 18:45:09 UTC (rev 61131)
@@ -62,7 +62,7 @@
                
                private bool checkboxes;
                private bool label_edit;
-               private bool scrollable;
+               private bool scrollable = true;
                private bool show_lines = true;
                private bool show_root_lines = true;
                private bool show_plus_minus = true;
@@ -76,7 +76,6 @@
                internal int skipped_nodes;
                internal int hbar_offset;
                
-               
                private int update_stack;
                private bool update_needed;
                
@@ -177,7 +176,7 @@
                                if (!checkboxes)
                                        root_node.CollapseAllUncheck ();
 
-                               Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -192,7 +191,7 @@
                                if (value == full_row_select)
                                        return;
                                full_row_select = value;
-                               Refresh ();
+                               Invalidate ();
                        }
                }
                [DefaultValue(true)]
@@ -202,7 +201,7 @@
                                if (hide_selection == value)
                                        return;
                                hide_selection = value;
-                               this.Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -226,7 +225,7 @@
                                if (image_index == value)
                                        return;
                                image_index = value;
-                               Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -235,7 +234,7 @@
                        get { return image_list; }
                        set {
                                image_list = value;
-                               Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -254,7 +253,7 @@
                                                "'Indent' must be greater than 
or equal to 0.");
                                }
                                indent = value;
-                               Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -269,7 +268,7 @@
                                if (value == item_height)
                                        return;
                                item_height = value;
-                               Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -299,6 +298,7 @@
                                if (scrollable == value)
                                        return;
                                scrollable = value;
+                               UpdateScrollBars ();
                        }
                }
 
@@ -313,6 +313,7 @@
                                        throw new ArgumentException ("'" + 
value + "' is not a valid value for 'value'. " +
                                                "'value' must be greater than 
or equal to 0.");
                                }
+                               UpdateNode (SelectedNode);
                        }
                }
 
@@ -379,7 +380,7 @@
                                if (show_lines == value)
                                        return;
                                show_lines = value;
-                               Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -390,7 +391,7 @@
                                if (show_plus_minus == value)
                                        return;
                                show_plus_minus = value;
-                               Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -401,7 +402,7 @@
                                if (show_root_lines == value)
                                        return;
                                show_root_lines = value;
-                               Refresh ();
+                               Invalidate ();
                        }
                }
 
@@ -414,7 +415,7 @@
                                if (sorted) {
                                        Nodes.Sort ();
                                        top_node = null;
-                                       Refresh ();
+                                       Invalidate ();
                                }
                        }
                }
@@ -948,13 +949,16 @@
 
                internal void UpdateNode (TreeNode node)
                {
+                       if (node == null)
+                               return;
+
                        if (update_stack > 0) {
                                update_needed = true;
                                return;
                        }
 
                        if (node == root_node) {
-                               Refresh ();
+                               Invalidate ();
                                return;
                        }
 
@@ -1250,40 +1254,44 @@
                {
                        if (update_stack > 0)
                                return;
-                       
-                       OpenTreeNodeEnumerator walk = new 
OpenTreeNodeEnumerator (root_node);
+
+                       bool vert = false;
+                       bool horz = false;
                        int height = -1;
                        int width = -1;
-                       bool vert = false;
-                       bool horz = false;
 
-                       while (walk.MoveNext ()) {
-                               int r = walk.CurrentNode.Bounds.Right;
-                               int b = walk.CurrentNode.Bounds.Bottom;
+                       if (scrollable) {
+                               OpenTreeNodeEnumerator walk = new 
OpenTreeNodeEnumerator (root_node);
+                               
+                               
+                               while (walk.MoveNext ()) {
+                                       int r = walk.CurrentNode.Bounds.Right;
+                                       int b = walk.CurrentNode.Bounds.Bottom;
 
-                               if (r > width)
-                                       width = r;
-                               if (b > height)
-                                       height = b;
-                       }
+                                       if (r > width)
+                                               width = r;
+                                       if (b > height)
+                                               height = b;
+                               }
 
-                       // Remove scroll adjustments
-                       if (nodes.Count > 0)
-                               height -= nodes [0].Bounds.Top;
-                       width += hbar_offset;
+                               // Remove scroll adjustments
+                               if (nodes.Count > 0)
+                                       height -= nodes [0].Bounds.Top;
+                               width += hbar_offset;
 
-                       if (height > ClientRectangle.Height) {
-                               vert = true;
+                               if (height > ClientRectangle.Height) {
+                                       vert = true;
 
-                               if (width > ClientRectangle.Width - 
SystemInformation.VerticalScrollBarWidth)
+                                       if (width > ClientRectangle.Width - 
SystemInformation.VerticalScrollBarWidth)
+                                               horz = true;
+                               } else if (width > ClientRectangle.Width) {
                                        horz = true;
-                       } else if (width > ClientRectangle.Width) {
-                               horz = true;
+                               }
+
+                               if (!vert && horz && height > 
ClientRectangle.Height - SystemInformation.HorizontalScrollBarHeight)
+                                       vert = true;
                        }
 
-                       if (!vert && horz && height > ClientRectangle.Height - 
SystemInformation.HorizontalScrollBarHeight)
-                               vert = true;
-
                        if (vert) {
                                vbar.SetValues (max_visible_order - 2, 
ViewportRectangle.Height / ItemHeight);
                                /*
@@ -1541,7 +1549,8 @@
 
                        selected_node = focused_node;
                        select_mmove = false;
-                       Refresh();
+                       Invalidate (focused_node.Bounds);
+                       Invalidate (selected_node.Bounds);
                }
 
                private void DoubleClickHandler (object sender, MouseEventArgs 
e) {

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

Reply via email to