* TreeView.cs: Make sure that when we invalidate a node the bounds
authorJackson Harper <jackson@novell.com>
Fri, 21 Oct 2005 21:49:04 +0000 (21:49 -0000)
committerJackson Harper <jackson@novell.com>
Fri, 21 Oct 2005 21:49:04 +0000 (21:49 -0000)
are big enough to cover the selected box and the focus
rectangle. Use a different colour for the lines connecting nodes
so they show up with all themes.

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

mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
mcs/class/Managed.Windows.Forms/System.Windows.Forms/TreeView.cs

index 3e1ad6a6f792027429724aff5a3eb49c01a7bc54..332603aec26fc4a87da341bd2db173097b7fe8de 100644 (file)
@@ -1,3 +1,10 @@
+2005-10-21  Jackson Harper  <jackson@ximian.com>
+
+       * TreeView.cs: Make sure that when we invalidate a node the bounds
+       are big enough to cover the selected box and the focus
+       rectangle. Use a different colour for the lines connecting nodes
+       so they show up with all themes.
+
 2005-10-21  Peter Dennis Bartok  <pbartok@novell.com>
 
        * NativeWindow.cs: Don't call anything that could call into the driver,
index 42b024075566e161970e0000654d697bdaa7b422..ea00dadd22eadffef15749fa7df6bfb152b540cf 100644 (file)
@@ -319,11 +319,15 @@ namespace System.Windows.Forms {
 
                                Rectangle invalid = Rectangle.Empty;
 
-                               if (selected_node != null)
-                                       invalid = selected_node.Bounds;
-                               if (focused_node != null)
-                                       invalid = Rectangle.Union (focused_node.Bounds, invalid);
-                               invalid = Rectangle.Union (invalid, value.Bounds);
+                               if (selected_node != null) {
+                                       invalid = Bloat (selected_node.Bounds);
+                               }
+                               if (focused_node != null) {
+                                       invalid = Rectangle.Union (invalid,
+                                                       Bloat (focused_node.Bounds));
+                               }
+
+                               invalid = Rectangle.Union (invalid, Bloat (value.Bounds));
 
                                selected_node = value;
                                focused_node = value;
@@ -332,8 +336,7 @@ namespace System.Windows.Forms {
                                        invalid.X = 0;
                                        invalid.Width = ViewportRectangle.Width;
                                }
-                               invalid.Y += 2;
-                               
+
                                Invalidate (invalid);
 
                                // We ensure its visible after we update because
@@ -344,6 +347,15 @@ namespace System.Windows.Forms {
                        }
                }
 
+               private Rectangle Bloat (Rectangle rect)
+               {
+                       rect.Y--;
+                       rect.X--;
+                       rect.Height += 2;
+                       rect.Width += 2;
+                       return rect;
+               }
+
                [DefaultValue(true)]
                public bool ShowLines {
                        get { return show_lines; }
@@ -850,7 +862,8 @@ namespace System.Windows.Forms {
                        }
                                
                        // We need to update the current node so the plus/minus block gets update too
-                       Rectangle invalid = new Rectangle (0, node.Bounds.Top + 2, Width, Height - node.Bounds.Top);
+                       Rectangle invalid = new Rectangle (0, node.Bounds.Top - 1,
+                                       Width, Height - node.Bounds.Top + 1);
                        Invalidate (invalid);
                }
 
@@ -866,7 +879,8 @@ namespace System.Windows.Forms {
                                return;
                        }
 
-                       Rectangle invalid = new Rectangle (0, node.Bounds.Top + 2, Width, node.Bounds.Height);
+                       Rectangle invalid = new Rectangle (0, node.Bounds.Top - 1, Width,
+                                       node.Bounds.Height + 1);
                        Invalidate (invalid);
                }
 
@@ -891,6 +905,12 @@ namespace System.Windows.Forms {
                        
                        dc.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), clip);
 
+                       Color dash_color = ControlPaint.Dark (BackColor);
+                       if (dash_color == BackColor)
+                               dash_color = ControlPaint.Light (BackColor);
+                       dash = new Pen (dash_color, 1);
+                       dash.DashStyle = DashStyle.Dash;
+
                        int depth = 0;
                        int item_height = ItemHeight;
                        int height = ClientRectangle.Height;
@@ -1307,10 +1327,10 @@ namespace System.Windows.Forms {
                                        select_mmove = true;
                                        
                                        if (old_selected != null) {
-                                               Invalidate (Rectangle.Union (old_selected.Bounds,
-                                                                           selected_node.Bounds));
+                                               Invalidate (Rectangle.Union (Bloat (old_selected.Bounds),
+                                                                           Bloat (selected_node.Bounds)));
                                        } else {
-                                               Invalidate (selected_node.Bounds);
+                                               Invalidate (Bloat (selected_node.Bounds));
                                        }
                                }
 
@@ -1331,16 +1351,15 @@ namespace System.Windows.Forms {
 
                        Rectangle invalid;
                        if (!ce.Cancel) {
-                               if (focused_node != null)
-                                       invalid = Rectangle.Union (focused_node.Bounds, selected_node.Bounds);
-                               else
-                                       invalid = selected_node.Bounds;
+                               if (focused_node != null) {
+                                       invalid = Rectangle.Union (Bloat (focused_node.Bounds),
+                                                       Bloat (selected_node.Bounds));
+                               } else {
+                                       invalid = Bloat (selected_node.Bounds);
+                               }
                                focused_node = selected_node;
                                OnAfterSelect (new TreeViewEventArgs (selected_node, TreeViewAction.ByMouse));
-                               invalid.Y -= 2;
-                               invalid.X -= 2;
-                               invalid.Height += 4;
-                               invalid.Width += 4;
+
                                Invalidate (invalid);
                        } else {
                                selected_node = focused_node;