View | Details | Raw Unified | Return to bug 322421
Collapse All | Expand All

(-)System.Windows.Forms/ChangeLog (+13 lines)
Lines 1-3 Link Here
1
2006-11-03  Rolf Bjarne Kvinge <RKvinge@novell.com>
2
3
	* TrackBar.cs: The control is completely invalidated on 
4
	Got/LostFocus to draw the focus rectangle correctly. 
5
	Fixes #79341.
6
7
	* ThemeWin32Classic.cs: The TrackBar thumb is now centered
8
	on the mouse when moved and it doesn't move when grabbed
9
	until the mouse moves as well. Also fixed some wrong 
10
	calculations when clicking on the thumb (control thought
11
	click was outside of thumb and didn't grab it).
12
	Fixes some of the issues in #79718.
13
1
2006-11-03  Jackson Harper  <jackson@ximian.com>
14
2006-11-03  Jackson Harper  <jackson@ximian.com>
2
15
3
	* TextBoxBase.cs: Don't bail from the scrollbar calcs for non
16
	* TextBoxBase.cs: Don't bail from the scrollbar calcs for non
(-)System.Windows.Forms/TrackBar.cs (-4 / +24 lines)
Lines 64-70 Link Here
64
		internal int thumb_mouseclick;		
64
		internal int thumb_mouseclick;		
65
		private bool mouse_clickmove;
65
		private bool mouse_clickmove;
66
		private bool is_moving_right; // which way the thumb should move when mouse is down (right=up, left=down) 
66
		private bool is_moving_right; // which way the thumb should move when mouse is down (right=up, left=down) 
67
	
67
		internal int mouse_down_x_offset; // how far from left side of thumb was the mouse clicked.
68
		internal bool mouse_moved; // has the mouse moved since it was clicked?
69
		
68
		#region events
70
		#region events
69
		[Browsable (false)]
71
		[Browsable (false)]
70
		[EditorBrowsable (EditorBrowsableState.Never)]
72
		[EditorBrowsable (EditorBrowsableState.Never)]
Lines 143-148 Link Here
143
			MouseUp += new MouseEventHandler (OnMouseUpTB); 
145
			MouseUp += new MouseEventHandler (OnMouseUpTB); 
144
			MouseMove += new MouseEventHandler (OnMouseMoveTB);
146
			MouseMove += new MouseEventHandler (OnMouseMoveTB);
145
			KeyDown += new KeyEventHandler (OnKeyDownTB);
147
			KeyDown += new KeyEventHandler (OnKeyDownTB);
148
			LostFocus += new EventHandler (OnLostFocusTB);
149
			GotFocus += new EventHandler (OnGotFocusTB);
146
			holdclick_timer.Elapsed += new ElapsedEventHandler (OnFirstClickTimer);
150
			holdclick_timer.Elapsed += new ElapsedEventHandler (OnFirstClickTimer);
147
151
148
			SetStyle (ControlStyles.UserPaint | ControlStyles.Opaque, false);
152
			SetStyle (ControlStyles.UserPaint | ControlStyles.Opaque, false);
Lines 515-522 Link Here
515
    		{
519
    		{
516
    			if (!Enabled) return;			    			
520
    			if (!Enabled) return;			    			
517
521
522
			mouse_moved = false;
518
			bool fire_timer = false;
523
			bool fire_timer = false;
519
    			
520
    			Point point = new Point (e.X, e.Y);
524
    			Point point = new Point (e.X, e.Y);
521
525
522
			if (orientation == Orientation.Horizontal) {
526
			if (orientation == Orientation.Horizontal) {
Lines 525-530 Link Here
525
					this.Capture = true;
529
					this.Capture = true;
526
					thumb_pressed = true;
530
					thumb_pressed = true;
527
					thumb_mouseclick = e.X;
531
					thumb_mouseclick = e.X;
532
					mouse_down_x_offset = e.X - thumb_pos.X;
528
					Invalidate (thumb_area);
533
					Invalidate (thumb_area);
529
				}
534
				}
530
				else {
535
				else {
Lines 542-551 Link Here
542
				}
547
				}
543
			}
548
			}
544
			else {
549
			else {
545
				if (thumb_pos.Contains (point)) {
550
				Rectangle vertical_thumb_pos = thumb_pos;
551
				vertical_thumb_pos.Width = thumb_pos.Height;
552
				vertical_thumb_pos.Height = thumb_pos.Width;
553
				if (vertical_thumb_pos.Contains (point)) {
546
					this.Capture = true;
554
					this.Capture = true;
547
					thumb_pressed = true;
555
					thumb_pressed = true;
548
					thumb_mouseclick = e.Y;
556
					thumb_mouseclick = e.Y;
557
					mouse_down_x_offset = e.Y - thumb_pos.Y;
549
					Invalidate (thumb_area);
558
					Invalidate (thumb_area);
550
				}
559
				}
551
				else {
560
				else {
Lines 572-578 Link Here
572
    		private void OnMouseMoveTB (object sender, MouseEventArgs e)
581
    		private void OnMouseMoveTB (object sender, MouseEventArgs e)
573
    		{    			
582
    		{    			
574
    			if (!Enabled) return;
583
    			if (!Enabled) return;
575
    		
584
585
    			mouse_moved = true;
586
576
    			/* Moving the thumb */
587
    			/* Moving the thumb */
577
    			if (thumb_pressed) {
588
    			if (thumb_pressed) {
578
								 				
589
								 				
Lines 595-600 Link Here
595
			ThemeEngine.Current.DrawTrackBar (pevent.Graphics, pevent.ClipRectangle, this);
606
			ThemeEngine.Current.DrawTrackBar (pevent.Graphics, pevent.ClipRectangle, this);
596
		}
607
		}
597
608
609
		private void OnLostFocusTB (object sender, EventArgs e)
610
		{
611
			Invalidate();
612
		}
613
614
		private void OnGotFocusTB (object sender, EventArgs e)
615
		{
616
			Invalidate();
617
		}
598
		private void OnKeyDownTB (object sender, KeyEventArgs e) 
618
		private void OnKeyDownTB (object sender, KeyEventArgs e) 
599
		{
619
		{
600
			switch (e.KeyCode) {
620
			switch (e.KeyCode) {
(-)System.Windows.Forms/ThemeWin32Classic.cs (-23 / +33 lines)
Lines 4222-4236 Link Here
4222
			
4222
			
4223
			/* Convert thumb position from mouse position to value*/
4223
			/* Convert thumb position from mouse position to value*/
4224
			if (mouse_value) {
4224
			if (mouse_value) {
4225
				if (value_pos < thumb_area.Bottom)
4225
				if (tb.mouse_moved) {
4226
					value_pos = (int) ((thumb_area.Bottom - value_pos) / pixels_betweenticks);
4226
					value_pos += (int) pixels_betweenticks / 2;
4227
				else
4227
					if (value_pos < thumb_area.Bottom) {
4228
					value_pos = 0;			
4228
						value_pos = (int) ((thumb_area.Bottom - value_pos - (int)(thumb_pos.Width / 2)) / pixels_betweenticks);
4229
					} else {
4230
						value_pos = 0;			
4231
					}
4232
	
4233
					if (value_pos + tb.Minimum > tb.Maximum)
4234
						value_pos = tb.Maximum - tb.Minimum;
4235
					else if (value_pos + tb.Minimum < tb.Minimum)
4236
						value_pos = 0;
4229
4237
4230
				if (value_pos + tb.Minimum > tb.Maximum)
4238
					tb.Value = value_pos + tb.Minimum;	
4231
					value_pos = tb.Maximum - tb.Minimum;
4239
				} else {
4232
4240
					value_pos = tb.Value - tb.Minimum;
4233
				tb.Value = value_pos + tb.Minimum;
4241
				}
4234
			}			
4242
			}			
4235
4243
4236
			// thumb_pos.Y = channel_startpoint.Y ; // + (int) (pixels_betweenticks * (float) value_pos);
4244
			// thumb_pos.Y = channel_startpoint.Y ; // + (int) (pixels_betweenticks * (float) value_pos);
Lines 4366-4372 Link Here
4366
			Does not matter the size of the control, Win32 always draws:
4374
			Does not matter the size of the control, Win32 always draws:
4367
				- Ticks starting from pixel 13, 8
4375
				- Ticks starting from pixel 13, 8
4368
				- Channel starting at pos 8, 19 and ends at Width - 8
4376
				- Channel starting at pos 8, 19 and ends at Width - 8
4369
				- Autosize makes always the control 40 pixels height
4377
				- Autosize makes always the control DefaultSize.Height pixels high
4370
				- Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
4378
				- Ticks are draw at (channel.Witdh - 10) / (Maximum - Minimum)
4371
				
4379
				
4372
		*/
4380
		*/
Lines 4428-4442 Link Here
4428
4436
4429
			/* Convert thumb position from mouse position to value*/
4437
			/* Convert thumb position from mouse position to value*/
4430
			if (mouse_value) {			
4438
			if (mouse_value) {			
4431
				if (value_pos >= channel_startpoint.X)
4439
				if (tb.mouse_moved) {
4432
					value_pos = (int)(((float) (value_pos - channel_startpoint.X)) / pixels_betweenticks);
4440
					value_pos += (int) pixels_betweenticks / 2;
4433
				else
4441
					if (value_pos >= channel_startpoint.X) {
4434
					value_pos = 0;				
4442
						value_pos = (int)(((float) (value_pos - channel_startpoint.X - (int)(thumb_pos.Width / 2))) / pixels_betweenticks);
4443
					} else
4444
						value_pos = 0;				
4445
	
4446
					if (value_pos + tb.Minimum > tb.Maximum)
4447
						value_pos = tb.Maximum - tb.Minimum;
4448
					else if(value_pos + tb.Minimum < tb.Minimum)
4449
						value_pos = 0;
4435
4450
4436
				if (value_pos + tb.Minimum > tb.Maximum)
4451
					tb.Value = value_pos + tb.Minimum;
4437
					value_pos = tb.Maximum - tb.Minimum;
4452
				} else {
4438
                                
4453
					value_pos = tb.Value - tb.Minimum;
4439
				tb.Value = value_pos + tb.Minimum;
4454
				}
4440
			}			
4455
			}			
4441
			
4456
			
4442
			thumb_pos.X = channel_startpoint.X + (int) (pixels_betweenticks * (float) value_pos);
4457
			thumb_pos.X = channel_startpoint.X + (int) (pixels_betweenticks * (float) value_pos);
Lines 4594-4606 Link Here
4594
				dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
4609
				dc.FillRectangle (ResPool.GetSolidBrush (tb.BackColor), clip_rectangle);
4595
			}
4610
			}
4596
			
4611
			
4597
4598
			if (tb.Focused) {
4612
			if (tb.Focused) {
4599
				Brush brush = ResPool.GetHatchBrush (HatchStyle.Percent50, ColorControl, Color.Black);
4613
				CPDrawFocusRectangle(dc, area, tb.ForeColor, tb.BackColor);
4600
				dc.FillRectangle (brush, area.X, area.Y, area.Width - 1, 1);
4601
				dc.FillRectangle (brush, area.X, area.Y + area.Height - 1, area.Width - 1, 1);
4602
				dc.FillRectangle (brush, area.X, area.Y, 1, area.Height - 1);
4603
				dc.FillRectangle (brush, area.X + area.Width - 1, area.Y, 1, area.Height - 1);
4604
			}
4614
			}
4605
4615
4606
			if (tb.Orientation == Orientation.Vertical) {
4616
			if (tb.Orientation == Orientation.Vertical) {

Return to bug 322421