Author: rolf
Date: 2006-11-02 15:09:02 -0500 (Thu, 02 Nov 2006)
New Revision: 67296
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs
Log:
2006-11-02 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* TrackBar.cs: Now orientation only switches height / width if
the control's handle is created (Win32 does it like this). Also
fixed a typo in ToString() for a test to pass, changed the
exception thrown in set_LargeChange and set_SmallChange to
match Win32 behaviour, and added TrackBar tests to the unit
tests.
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-11-02 19:48:59 UTC (rev 67295)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2006-11-02 20:09:02 UTC (rev 67296)
@@ -1,3 +1,12 @@
+2006-11-02 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
+
+ * TrackBar.cs: Now orientation only switches height / width if
+ the control's handle is created (Win32 does it like this). Also
+ fixed a typo in ToString() for a test to pass, changed the
+ exception thrown in set_LargeChange and set_SmallChange to
+ match Win32 behaviour, and added TrackBar tests to the unit
+ tests.
+
2006-11-02 Chris Toshok <[EMAIL PROTECTED]>
* XplatUIX11.cs: the atom we want is _NET_WM_STATE_SKIP_TASKBAR,
@@ -13,7 +22,7 @@
* TextBoxBase.cs: Use client rectangle not bounds for checking if
the mouse is in the client rectangle (duh).
-2006-11-02 Rolf Bjarne KVinge <[EMAIL PROTECTED]>
+2006-11-02 Rolf Bjarne Kvinge <[EMAIL PROTECTED]>
* TrackBar.cs: Fixed trackbar jumping around when clicking
on it - the trackbar was not detecting correctly at which
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-02 19:48:59 UTC (rev 67295)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/TrackBar.cs
2006-11-02 20:09:02 UTC (rev 67296)
@@ -25,13 +25,13 @@
//
// Authors:
// Jordi Mas i Hernandez, [EMAIL PROTECTED]
-//
+// Rolf Bjarne Kvinge, [EMAIL PROTECTED]
+//
// TODO:
// - The AutoSize functionality seems quite broken for vertical
controls in .Net 1.1. Not
// sure if we are implementing it the right way.
//
-
// NOT COMPLETE
using System.ComponentModel;
@@ -64,7 +64,7 @@
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)
-
+
#region events
[Browsable (false)]
[EditorBrowsable (EditorBrowsableState.Never)]
@@ -226,7 +226,7 @@
get { return largeChange; }
set {
if (value < 0)
- throw new Exception(
string.Format("Value '{0}' must be greater than or equal to 0.", value));
+ throw new ArgumentOutOfRangeException(
string.Format("Value '{0}' must be greater than or equal to 0.", value));
largeChange = value;
}
@@ -276,11 +276,13 @@
/* Orientation can be changed once the control
has been created */
if (orientation != value) {
orientation = value;
-
- int old_witdh = Width;
- Width = Height;
- Height = old_witdh;
- Refresh ();
+
+ if (this.IsHandleCreated) {
+ int old_witdh = Width;
+ Width = Height;
+ Height = old_witdh;
+ Refresh ();
+ }
}
}
}
@@ -290,7 +292,7 @@
get { return smallChange;}
set {
if ( value < 0 )
- throw new Exception(
string.Format("Value '{0}' must be greater than or equal to 0.", value));
+ throw new ArgumentOutOfRangeException(
string.Format("Value '{0}' must be greater than or equal to 0.", value));
if (smallChange != value) {
smallChange = value;
@@ -440,7 +442,7 @@
public override string ToString()
{
- return string.Format("System.Windows.Forms.Trackbar,
Minimum: {0}, Maximum: {1}, Value: {2}",
+ return string.Format("System.Windows.Forms.TrackBar,
Minimum: {0}, Maximum: {1}, Value: {2}",
Minimum, Maximum, Value);
}
@@ -545,7 +547,6 @@
thumb_pressed = true;
thumb_mouseclick = e.Y;
Invalidate (thumb_area);
-
}
else {
if (ClientRectangle.Contains (point)) {
@@ -668,10 +669,13 @@
protected override void SetBoundsCore (int x, int y,int width,
int height, BoundsSpecified specified)
{
- base.SetBoundsCore (x, y,width, height, specified);
+ if (orientation == Orientation.Vertical) {
+ width = DefaultSize.Height;
+ } else {
+ height = DefaultSize.Height;
+ }
+ base.SetBoundsCore (x, y,width, height, specified);
}
-
-
#endregion // Private Methods
}
}
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
2006-11-02 19:48:59 UTC (rev 67295)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms_test.dll.sources
2006-11-02 20:09:02 UTC (rev 67296)
@@ -65,6 +65,7 @@
System.Windows.Forms/ToolBarTest.cs
System.Windows.Forms/ToolBarButtonTest.cs
System.Windows.Forms/ToolTipTest.cs
+System.Windows.Forms/TrackBarTest.cs
System.Windows.Forms/TreeNodeTest.cs
System.Windows.Forms/TreeViewTest.cs
System.Windows.Forms/UpDownTest.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs
2006-11-02 19:48:59 UTC (rev 67295)
+++
trunk/mcs/class/Managed.Windows.Forms/Test/System.Windows.Forms/TrackBarTest.cs
2006-11-02 20:09:02 UTC (rev 67296)
@@ -57,8 +57,16 @@
TrackBar myTrackBar = new TrackBar ();
myTrackBar.LargeChange = -1;
}
-
+
[Test]
+ [ExpectedException (typeof (ArgumentOutOfRangeException))]
+ public void SmallChangeTest ()
+ {
+ TrackBar myTrackBar = new TrackBar ();
+ myTrackBar.SmallChange = -1;
+ }
+
+ [Test]
public void SetRangeTest ()
{
TrackBar myTrackBar = new TrackBar ();
@@ -74,6 +82,42 @@
myTrackBar.Text = "New TrackBar";
Assert.AreEqual ("System.Windows.Forms.TrackBar,
Minimum: 0, Maximum: 10, Value: 0", myTrackBar.ToString (), "#T3");
}
- }
+
+ [Test]
+ public void OrientationSizeTest ()
+ {
+ int width;
+ int height ;
+ using (TrackBar myTrackBar = new TrackBar()) {
+ width = myTrackBar.Width;
+ height = myTrackBar.Height;
+ myTrackBar.Orientation = Orientation.Vertical;
+ Assert.AreEqual(width, myTrackBar.Width,
"#OS1");
+ Assert.AreEqual(height, myTrackBar.Height,
"#OS2");
+ }
+
+ using (Form myForm = new Form()) {
+ using ( TrackBar myTrackBar = new TrackBar()) {
+ width = myTrackBar.Width;
+ height = myTrackBar.Height;
+ myForm.Controls.Add(myTrackBar);
+ IntPtr handle = myTrackBar.Handle; //
causes the handle to be created.
+ myTrackBar.Orientation =
Orientation.Vertical;
+ Assert.AreEqual(height,
myTrackBar.Width, "#OS3");
+ Assert.AreEqual(width,
myTrackBar.Height, "#OS4");
+ }
+ }
+
+ using (Form myForm = new Form()) {
+ using ( TrackBar myTrackBar = new TrackBar()) {
+ myForm.Controls.Add(myTrackBar);
+ IntPtr handle = myTrackBar.Handle; //
causes the handle to be created.
+ myTrackBar.Width = 200;
+ myTrackBar.Orientation =
Orientation.Vertical;
+ Assert.AreEqual(200, myTrackBar.Height,
"#OS5");
+ }
+ }
+ }
}
+}
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches