Author: rolf
Date: 2006-11-09 04:46:01 -0500 (Thu, 09 Nov 2006)
New Revision: 67584

Modified:
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs
   
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
   trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs
Log:
 2006-11-09  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>
 
        * TrackBar.cs: 
        - The control is completely invalidated on 
        Got/LostFocus to draw the focus rectangle correctly.
        - When AutoSize then height is always 45 (width for 
        vertical controls).
        
        * ThemeWin32Classic.cs: The TrackBar thumb is now centered
        on the mouse when moved and it doesn't move when grabbed
        until the mouse moves as well. Also fixed some wrong 
        calculations when clicking on the thumb (control thought
        click was outside of thumb and didn't grab it).
        Fixes some of the issues in #79718.



Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-09 09:38:03 UTC (rev 67583)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog        
2006-11-09 09:46:01 UTC (rev 67584)
@@ -1,3 +1,18 @@
+ 2006-11-09  Rolf Bjarne Kvinge  <[EMAIL PROTECTED]>
+ 
+       * TrackBar.cs: 
+       - The control is completely invalidated on 
+       Got/LostFocus to draw the focus rectangle correctly.
+       - When AutoSize then height is always 45 (width for 
+       vertical controls).
+       
+       * ThemeWin32Classic.cs: The TrackBar thumb is now centered
+       on the mouse when moved and it doesn't move when grabbed
+       until the mouse moves as well. Also fixed some wrong 
+       calculations when clicking on the thumb (control thought
+       click was outside of thumb and didn't grab it).
+       Fixes some of the issues in #79718.
+
 2006-11-08  Everaldo Canuto  <[EMAIL PROTECTED]>
 
        * Toolbar.cs: Prevent disabled button to highlight. Fixes #79868.

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs    
    2006-11-09 09:38:03 UTC (rev 67583)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/StatusBarPanel.cs    
    2006-11-09 09:46:01 UTC (rev 67584)
@@ -110,6 +110,8 @@
                                if (value < 0)
                                        throw new ArgumentException ("value");
                                min_width = value;
+                               if (min_width > width)
+                                       width = min_width;
                                Invalidate ();
                        }
                }
@@ -126,7 +128,10 @@
                                        twidth = value;
                                else
                                        width = value;
-                       
+                               
+                               if (min_width > width)
+                                       width = min_width;
+                                       
                                Invalidate ();
                        }
                }

Modified: 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs
===================================================================
--- 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2006-11-09 09:38:03 UTC (rev 67583)
+++ 
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ThemeWin32Classic.cs 
    2006-11-09 09:46:01 UTC (rev 67584)
@@ -4233,15 +4233,23 @@
                        
                        /* Convert thumb position from mouse position to value*/
                        if (mouse_value) {
-                               if (value_pos < thumb_area.Bottom)
-                                       value_pos = (int) ((thumb_area.Bottom - 
value_pos) / pixels_betweenticks);
-                               else
-                                       value_pos = 0;                  
+                               if (tb.mouse_moved) {
+                                       value_pos += (int) pixels_betweenticks 
/ 2;
+                                       if (value_pos < thumb_area.Bottom) {
+                                               value_pos = (int) 
((thumb_area.Bottom - value_pos - (int)(thumb_pos.Width / 2)) / 
pixels_betweenticks);
+                                       } else {
+                                               value_pos = 0;                  
+                                       }
+       
+                                       if (value_pos + tb.Minimum > tb.Maximum)
+                                               value_pos = tb.Maximum - 
tb.Minimum;
+                                       else if (value_pos + tb.Minimum < 
tb.Minimum)
+                                               value_pos = 0;
 
-                               if (value_pos + tb.Minimum > tb.Maximum)
-                                       value_pos = tb.Maximum - tb.Minimum;
-
-                               tb.Value = value_pos + tb.Minimum;
+                                       tb.Value = value_pos + tb.Minimum;      
+                               } else {
+                                       value_pos = tb.Value - tb.Minimum;
+                               }
                        }                       
 
                        // thumb_pos.Y = channel_startpoint.Y ; // + (int) 
(pixels_betweenticks * (float) value_pos);
@@ -4377,7 +4385,7 @@
                        Does not matter the size of the control, Win32 always 
draws:
                                - Ticks starting from pixel 13, 8
                                - Channel starting at pos 8, 19 and ends at 
Width - 8
-                               - Autosize makes always the control 40 pixels 
height
+                               - Autosize makes always the control 45 pixels 
high
                                - Ticks are draw at (channel.Witdh - 10) / 
(Maximum - Minimum)
                                
                */
@@ -4439,15 +4447,22 @@
 
                        /* Convert thumb position from mouse position to value*/
                        if (mouse_value) {                      
-                               if (value_pos >= channel_startpoint.X)
-                                       value_pos = (int)(((float) (value_pos - 
channel_startpoint.X)) / pixels_betweenticks);
-                               else
-                                       value_pos = 0;                          
+                               if (tb.mouse_moved) {
+                                       value_pos += (int) pixels_betweenticks 
/ 2;
+                                       if (value_pos >= channel_startpoint.X) {
+                                               value_pos = (int)(((float) 
(value_pos - channel_startpoint.X - (int)(thumb_pos.Width / 2))) / 
pixels_betweenticks);
+                                       } else
+                                               value_pos = 0;                  
        
+       
+                                       if (value_pos + tb.Minimum > tb.Maximum)
+                                               value_pos = tb.Maximum - 
tb.Minimum;
+                                       else if(value_pos + tb.Minimum < 
tb.Minimum)
+                                               value_pos = 0;
 
-                               if (value_pos + tb.Minimum > tb.Maximum)
-                                       value_pos = tb.Maximum - tb.Minimum;
-                                
-                               tb.Value = value_pos + tb.Minimum;
+                                       tb.Value = value_pos + tb.Minimum;
+                               } else {
+                                       value_pos = tb.Value - tb.Minimum;
+                               }
                        }                       
                        
                        thumb_pos.X = channel_startpoint.X + (int) 
(pixels_betweenticks * (float) value_pos);
@@ -4605,13 +4620,8 @@
                                dc.FillRectangle (ResPool.GetSolidBrush 
(tb.BackColor), clip_rectangle);
                        }
                        
-
                        if (tb.Focused) {
-                               Brush brush = ResPool.GetHatchBrush 
(HatchStyle.Percent50, ColorControl, Color.Black);
-                               dc.FillRectangle (brush, area.X, area.Y, 
area.Width - 1, 1);
-                               dc.FillRectangle (brush, area.X, area.Y + 
area.Height - 1, area.Width - 1, 1);
-                               dc.FillRectangle (brush, area.X, area.Y, 1, 
area.Height - 1);
-                               dc.FillRectangle (brush, area.X + area.Width - 
1, area.Y, 1, area.Height - 1);
+                               CPDrawFocusRectangle(dc, area, tb.ForeColor, 
tb.BackColor);
                        }
 
                        if (tb.Orientation == Orientation.Vertical) {

Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs      
2006-11-09 09:38:03 UTC (rev 67583)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs      
2006-11-09 09:46:01 UTC (rev 67584)
@@ -64,6 +64,9 @@
                internal int thumb_mouseclick;          
                private bool mouse_clickmove;
                private bool is_moving_right; // which way the thumb should 
move when mouse is down (right=up, left=down) 
+               internal int mouse_down_x_offset; // how far from left side of 
thumb was the mouse clicked.
+               internal bool mouse_moved; // has the mouse moved since it was 
clicked?
+               private const int size_of_autosize = 45;
        
                #region events
                [Browsable (false)]
@@ -143,6 +146,8 @@
                        MouseUp += new MouseEventHandler (OnMouseUpTB); 
                        MouseMove += new MouseEventHandler (OnMouseMoveTB);
                        KeyDown += new KeyEventHandler (OnKeyDownTB);
+                       LostFocus += new EventHandler (OnLostFocusTB);
+                       GotFocus += new EventHandler (OnGotFocusTB);
                        holdclick_timer.Elapsed += new ElapsedEventHandler 
(OnFirstClickTimer);
 
                        SetStyle (ControlStyles.UserPaint | 
ControlStyles.Opaque, false);
@@ -227,7 +232,7 @@
                        set {
                                if (value < 0)
                                        throw new ArgumentException( 
string.Format("Value '{0}' must be greater than or equal to 0.", value));
-
+                               
                                largeChange = value;                            
                        }
                }
@@ -278,9 +283,7 @@
                                        orientation = value;
                                        
                                        if (this.IsHandleCreated) {
-                                               int old_witdh = Width;
-                                               Width = Height;
-                                               Height = old_witdh;
+                                               Size = new Size (Height, Width);
                                                Refresh (); 
                                        }
                                }
@@ -367,6 +370,17 @@
                        base.CreateHandle ();
                }
 
+               protected override void SetBoundsCore (int x, int y,int width, 
int height, BoundsSpecified specified)
+               {
+                       if (AutoSize) {
+                               if (orientation == Orientation.Vertical) {
+                                       width = size_of_autosize;
+                               } else {
+                                       height = size_of_autosize;
+                               }
+                       }
+                       base.SetBoundsCore (x, y, width, height, specified);
+               }
 
                public void EndInit ()          
                {
@@ -515,6 +529,8 @@
                {
                        if (!Enabled) return;                                   
        
 
+                       mouse_moved = false;
+
                        bool fire_timer = false;
                        
                        Point point = new Point (e.X, e.Y);
@@ -525,6 +541,7 @@
                                        this.Capture = true;
                                        thumb_pressed = true;
                                        thumb_mouseclick = e.X;
+                                       mouse_down_x_offset = e.X - thumb_pos.X;
                                        Invalidate (thumb_area);
                                }
                                else {
@@ -542,10 +559,14 @@
                                }
                        }
                        else {
-                               if (thumb_pos.Contains (point)) {
+                               Rectangle vertical_thumb_pos = thumb_pos;
+                               vertical_thumb_pos.Width = thumb_pos.Height;
+                               vertical_thumb_pos.Height = thumb_pos.Width;
+                               if (vertical_thumb_pos.Contains (point)) {
                                        this.Capture = true;
                                        thumb_pressed = true;
                                        thumb_mouseclick = e.Y;
+                                       mouse_down_x_offset = e.Y - thumb_pos.Y;
                                        Invalidate (thumb_area);
                                }
                                else {
@@ -573,6 +594,8 @@
                {                       
                        if (!Enabled) return;
                
+                       mouse_moved = true;
+
                        /* Moving the thumb */
                        if (thumb_pressed) {
                                                                                
                
@@ -595,6 +618,15 @@
                        ThemeEngine.Current.DrawTrackBar (pevent.Graphics, 
pevent.ClipRectangle, this);
                }
 
+               private void OnLostFocusTB (object sender, EventArgs e)
+               {
+                       Invalidate();
+               }
+
+               private void OnGotFocusTB (object sender, EventArgs e)
+               {
+                       Invalidate();
+               }
                private void OnKeyDownTB (object sender, KeyEventArgs e) 
                {
                        switch (e.KeyCode) {
@@ -666,16 +698,6 @@
                                        Refresh();
                        }                       
                }                                       
-
-               protected override void SetBoundsCore (int x, int y,int width, 
int height, BoundsSpecified specified)
-               {
-                       if (orientation == Orientation.Vertical) {
-                               width = DefaultSize.Height;
-                       } else {
-                               height = DefaultSize.Height;
-                       }
-                       base.SetBoundsCore (x, y,width, height, specified);
-               }
                #endregion // Private Methods
        }
 }

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

Reply via email to