Copied remotely
[mono.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / NumericUpDown.cs
1 //
2 // System.Windows.Forms.NumericUpDown.cs
3 //
4 // Author:
5 //   stubbed out by Paul Osman (paul.osman@sympatico.ca)
6 //      Dennis Hayes (dennish@raytek.com)
7 //      Alexandre Pigolkine (pigolkine@gxm.de)
8 //
9 // (C) 2002/3 Ximian, Inc
10 //
11
12 //
13 // Permission is hereby granted, free of charge, to any person obtaining
14 // a copy of this software and associated documentation files (the
15 // "Software"), to deal in the Software without restriction, including
16 // without limitation the rights to use, copy, modify, merge, publish,
17 // distribute, sublicense, and/or sell copies of the Software, and to
18 // permit persons to whom the Software is furnished to do so, subject to
19 // the following conditions:
20 // 
21 // The above copyright notice and this permission notice shall be
22 // included in all copies or substantial portions of the Software.
23 // 
24 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
25 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
26 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
27 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
28 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
29 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
30 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 //
32 using System.ComponentModel;
33 namespace System.Windows.Forms {
34
35         // <summary>
36         //
37         // </summary>
38
39     public class NumericUpDown : UpDownBase, ISupportInitialize {
40
41                 private decimal Value_ = 0;
42         private int DecimalPlaces_;
43         private bool Hexadecimal_ = false;
44         private decimal Increment_ = 1;
45         private decimal Maximum_ = 100;
46         private decimal Minimum_ = 0;
47                 //
48                 //  --- Constructor
49                 //
50                 [MonoTODO]
51                 public NumericUpDown()
52                 {
53                         
54                 }
55
56                 public override void DownButton(){
57                         if( Value_ > Minimum_) {
58                                 Value = Math.Max(Value_ - Increment_, Minimum_);
59                         }
60                 }
61
62                 //
63                 //  --- Public Properties
64                 //
65
66                 [MonoTODO]
67                 public int DecimalPlaces  {
68                         get {
69                                 return DecimalPlaces_;
70                         }
71                         set {
72                                 //FIXME:
73                                 DecimalPlaces_ = value;
74                         }
75                 }
76
77                 [MonoTODO]
78                 public bool Hexadecimal  {
79                         get {
80                                 return Hexadecimal_;
81                         }
82                         set {
83                                 //FIXME:
84                                 Hexadecimal_ = value;
85                         }
86                 }
87
88                 public decimal Increment {
89                         get {
90                                 return Increment_;
91                         } 
92                         set {
93                                 Increment_ = value;
94                         }
95                 }
96                 
97                 [MonoTODO]
98                 public decimal Maximum  {
99                         get {
100                                 return Maximum_;
101                         }
102                         set {
103                                 //FIXME:
104                                 if( Maximum_ != value) {
105                                         Maximum_ = value;
106                                         Minimum = Math.Min(Maximum_,Minimum_);
107                                         Value = Math.Min(Value_,Minimum_);
108                                 }
109                         }
110                 }
111
112                 [MonoTODO]
113                 public decimal Minimum  {
114                         get {
115                                 return Minimum_;
116                         }
117                         set {
118                                 //FIXME:
119                                 if( Minimum_ != value) {
120                                         Minimum_ = value;
121                                         Maximum = Math.Max(Maximum_,Minimum_);
122                                         Value = Math.Max(Value_,Minimum_);
123                                 }
124                         }
125                 }
126
127                 [MonoTODO]
128                 public override string Text  {
129                         //FIXME: just to get it to run
130                         get {
131                                 return Value_.ToString();
132                         }
133                         set {
134                                 Value = Decimal.Parse(value);
135                         }
136                 }
137
138                 [MonoTODO]
139                 public bool ThousandsSeparator  {
140                         get {
141                                 throw new NotImplementedException ();
142                         }
143                         set {
144                                 //FIXME:
145                         }
146                 }
147
148                 [MonoTODO]
149                 public decimal Value  {
150                         get {
151                                 return Value_;
152                         }
153                         set {
154                                 //FIXME:
155                                 if( Value_ != value) {
156                                         Value_ = value;
157                                         UpdateEditText();
158                                 }
159                         }
160                 }
161
162                 //
163                 //  --- Public Methods
164                 //
165
166                 [MonoTODO]
167                 public override string ToString()
168                 {
169                         //FIXME:
170                         return base.ToString();
171                 }
172
173                 [MonoTODO]
174                 public override void UpButton()
175                 {
176                         if( Value_ != Maximum_) {
177                                 Value = Math.Min(Value_ + Increment_, Maximum_);
178                         }
179                 }
180
181                 //
182                 //  --- Public Events
183                 //
184
185                 public event EventHandler ValueChanged;
186
187                 //
188                 //  --- Protected Methods
189                 //
190                 [MonoTODO]
191                 protected override AccessibleObject CreateAccessibilityInstance() 
192                 {
193                         //FIXME:
194                         return base.CreateAccessibilityInstance();
195                 }
196
197                 [MonoTODO]
198                 protected override void OnTextBoxKeyPress(object source, KeyPressEventArgs e)
199                 {
200                         //FIXME:
201                         base.OnTextBoxKeyPress(source, e);
202                 }
203
204                 [MonoTODO]
205                 protected virtual void OnValueChanged(EventArgs e) 
206                 {
207                         //FIXME:
208                 }
209
210                 [MonoTODO]
211                 protected void ParseEditText() 
212                 {
213                         //FIXME:
214                 }
215
216                 [MonoTODO]
217                 protected override void UpdateEditText() 
218                 {
219                         //FIXME:
220                         base.Text = Value_.ToString();
221                 }
222
223                 [MonoTODO]
224                 protected override void ValidateEditText() 
225                 {
226                         //FIXME:
227                         base.ValidateEditText();
228                 }
229
230                 void ISupportInitialize.BeginInit(){
231                         //FIXME:
232                 }
233
234                 void ISupportInitialize.EndInit(){
235                         //FIXME:
236                 }
237
238         }
239 }