* UnsafeNativeMethods.cs: added IEnumVariant interface,
[mono.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / NumericUpDown.cs
index d0568fb2367ed22c9f754dba8a20130e3303a066..6308329b268e788d37430c16c2c24491829410f4 100644 (file)
@@ -4,8 +4,9 @@
 // Author:
 //   stubbed out by Paul Osman (paul.osman@sympatico.ca)
 //     Dennis Hayes (dennish@raytek.com)
+//     Alexandre Pigolkine (pigolkine@gxm.de)
 //
-// (C) 2002 Ximian, Inc
+// (C) 2002/3 Ximian, Inc
 //
 using System.ComponentModel;
 namespace System.Windows.Forms {
@@ -16,6 +17,12 @@ namespace System.Windows.Forms {
 
     public class NumericUpDown : UpDownBase, ISupportInitialize {
 
+               private decimal Value_ = 0;
+       private int DecimalPlaces_;
+       private bool Hexadecimal_ = false;
+       private decimal Increment_ = 1;
+       private decimal Maximum_ = 100;
+       private decimal Minimum_ = 0;
                //
                //  --- Constructor
                //
@@ -26,8 +33,11 @@ namespace System.Windows.Forms {
                }
 
                public override void DownButton(){
-                       throw new NotImplementedException ();
+                       if( Value_ > Minimum_) {
+                               Value = Math.Max(Value_ - Increment_, Minimum_);
+                       }
                }
+
                //
                //  --- Public Properties
                //
@@ -35,40 +45,61 @@ namespace System.Windows.Forms {
                [MonoTODO]
                public int DecimalPlaces  {
                        get {
-                               throw new NotImplementedException ();
+                               return DecimalPlaces_;
                        }
                        set {
-                               throw new NotImplementedException ();
+                               //FIXME:
+                               DecimalPlaces_ = value;
                        }
                }
 
                [MonoTODO]
                public bool Hexadecimal  {
                        get {
-                               throw new NotImplementedException ();
+                               return Hexadecimal_;
                        }
                        set {
-                               throw new NotImplementedException ();
+                               //FIXME:
+                               Hexadecimal_ = value;
                        }
                }
 
+               public decimal Increment {
+                       get {
+                               return Increment_;
+                       } 
+                       set {
+                               Increment_ = value;
+                       }
+               }
+               
                [MonoTODO]
                public decimal Maximum  {
                        get {
-                               throw new NotImplementedException ();
+                               return Maximum_;
                        }
                        set {
-                               throw new NotImplementedException ();
+                               //FIXME:
+                               if( Maximum_ != value) {
+                                       Maximum_ = value;
+                                       Minimum = Math.Min(Maximum_,Minimum_);
+                                       Value = Math.Min(Value_,Minimum_);
+                               }
                        }
                }
 
                [MonoTODO]
                public decimal Minimum  {
                        get {
-                               throw new NotImplementedException ();
+                               return Minimum_;
                        }
                        set {
-                               throw new NotImplementedException ();
+                               //FIXME:
+                               if( Minimum_ != value) {
+                                       Minimum_ = value;
+                                       Maximum = Math.Max(Maximum_,Minimum_);
+                                       Value = Math.Max(Value_,Minimum_);
+                               }
                        }
                }
 
@@ -76,10 +107,10 @@ namespace System.Windows.Forms {
                public override string Text  {
                        //FIXME: just to get it to run
                        get {
-                               return base.Text;
+                               return Value_.ToString();
                        }
                        set {
-                               base.Text = value;
+                               Value = Decimal.Parse(value);
                        }
                }
 
@@ -89,17 +120,21 @@ namespace System.Windows.Forms {
                                throw new NotImplementedException ();
                        }
                        set {
-                               throw new NotImplementedException ();
+                               //FIXME:
                        }
                }
 
                [MonoTODO]
                public decimal Value  {
                        get {
-                               throw new NotImplementedException ();
+                               return Value_;
                        }
                        set {
-                               throw new NotImplementedException ();
+                               //FIXME:
+                               if( Value_ != value) {
+                                       Value_ = value;
+                                       UpdateEditText();
+                               }
                        }
                }
 
@@ -110,13 +145,16 @@ namespace System.Windows.Forms {
                [MonoTODO]
                public override string ToString()
                {
-                       throw new NotImplementedException ();
+                       //FIXME:
+                       return base.ToString();
                }
 
                [MonoTODO]
                public override void UpButton()
                {
-                       throw new NotImplementedException ();
+                       if( Value_ != Maximum_) {
+                               Value = Math.Min(Value_ + Increment_, Maximum_);
+                       }
                }
 
                //
@@ -131,48 +169,41 @@ namespace System.Windows.Forms {
                [MonoTODO]
                protected override AccessibleObject CreateAccessibilityInstance() 
                {
-                       throw new NotImplementedException ();
+                       //FIXME:
+                       return base.CreateAccessibilityInstance();
                }
 
                [MonoTODO]
                protected override void OnTextBoxKeyPress(object source, KeyPressEventArgs e)
                {
-                       throw new NotImplementedException ();
+                       //FIXME:
+                       base.OnTextBoxKeyPress(source, e);
                }
 
                [MonoTODO]
                protected virtual void OnValueChanged(EventArgs e) 
                {
-                       throw new NotImplementedException ();
+                       //FIXME:
                }
 
                [MonoTODO]
                protected void ParseEditText() 
                {
-                       throw new NotImplementedException ();
+                       //FIXME:
                }
 
                [MonoTODO]
                protected override void UpdateEditText() 
                {
-                       throw new NotImplementedException ();
+                       //FIXME:
+                       base.Text = Value_.ToString();
                }
 
                [MonoTODO]
                protected override void ValidateEditText() 
                {
-                       throw new NotImplementedException ();
-               }
-
-               [MonoTODO]
-               public override bool Equals(object o) {
-                       throw new NotImplementedException ();
-               }
-
-               [MonoTODO]
-               public override int GetHashCode() {
-                       //FIXME add our proprities
-                       return base.GetHashCode();
+                       //FIXME:
+                       base.ValidateEditText();
                }
 
                void ISupportInitialize.BeginInit(){