(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / ProgressBar.cs
blob3fa47679b47047e84f0d7334f443f9cc202d468e
1 //
2 // System.Windows.Forms.ProgressBar
3 //
4 // Author:
5 // stubbed out by Jaak Simm (jaaksimm@firm.ee)
6 // Dennis Hayes (dennish@Raytek.com)
7 // Aleksey Ryabchuk (ryabchuk@yahoo.com)
8 //
9 // (C) Ximian, Inc., 2002
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.
33 using System.Drawing;
34 using System.Drawing.Printing;
35 using System.ComponentModel;
37 namespace System.Windows.Forms {
39 /// <summary>
40 /// Represents a Windows progress bar control.
41 /// </summary>
43 public sealed class ProgressBar : Control {
45 #region Fields
46 int maximum = 100;
47 int minimum = 0;
48 int step = 10;
49 int val = 0;
50 #endregion
52 #region Constructor
54 public ProgressBar() {
55 SetStyle ( ControlStyles.Selectable, false );
58 #endregion
60 #region Properties
62 [EditorBrowsable (EditorBrowsableState.Never)]
63 public override bool AllowDrop {
64 get { return base.AllowDrop; }
65 set { base.AllowDrop = value; }
68 [EditorBrowsable (EditorBrowsableState.Never)]
69 public override Color BackColor {
70 get { return base.BackColor; }
71 set { base.BackColor = value; }
74 [EditorBrowsable (EditorBrowsableState.Never)]
75 public override Image BackgroundImage {
76 get { return base.BackgroundImage; }
77 set { base.BackgroundImage = value; }
80 /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
81 /// public new bool CausesValidation {get; set;}
83 [MonoTODO]
84 protected override CreateParams CreateParams {
85 get {
86 CreateParams createParams = base.CreateParams;
88 createParams.ClassName = "msctls_progress32";
90 createParams.Style = (int) (
91 WindowStyles.WS_CHILD |
92 WindowStyles.WS_VISIBLE |
93 WindowStyles.WS_CLIPCHILDREN |
94 WindowStyles.WS_CLIPSIBLINGS );
96 return createParams;
101 protected override ImeMode DefaultImeMode {
102 get { return ImeMode.Disable; }
105 protected override Size DefaultSize {
106 get { return new Size(100, 23); }
109 [EditorBrowsable (EditorBrowsableState.Never)]
110 public override Font Font {
111 get { return base.Font; }
112 set { base.Font = value; }
115 [EditorBrowsable (EditorBrowsableState.Never)]
116 public override Color ForeColor {
117 get { return base.ForeColor; }
118 set { base.ForeColor = value; }
121 /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
122 /// public new ImeMode ImeMode {get; set;}
124 public int Maximum {
125 get {
126 return maximum;
128 set {
129 if ( value < 0 )
130 throw new ArgumentException(
131 string.Format("Value '{0}' must be greater than or equal to 0.", value ));
132 maximum = value;
133 if ( IsHandleCreated )
134 Win32.SendMessage( Handle, (int)ProgressBarMessages.PBM_SETRANGE32, Minimum, Maximum );
138 public int Minimum {
139 get {
140 return minimum;
142 set {
143 if ( value < 0 )
144 throw new ArgumentException(
145 string.Format("Value '{0}' must be greater than or equal to 0.", value ));
146 minimum = value;
147 if ( IsHandleCreated )
148 Win32.SendMessage( Handle, (int)ProgressBarMessages.PBM_SETRANGE32, Minimum, Maximum );
152 /// This member supports the .NET Framework infrastructure and is not intended to be used directly from your code.
153 /// public new bool TabStop {get; set;}
154 ///
155 [EditorBrowsable (EditorBrowsableState.Never)]
156 public override RightToLeft RightToLeft {
157 get { return base.RightToLeft; }
158 set { base.RightToLeft = value; }
161 public int Step {
162 get { return step; }
163 set {
164 step = value;
165 if ( IsHandleCreated )
166 Win32.SendMessage( Handle, (int)ProgressBarMessages.PBM_SETSTEP, Step, 0 );
170 [EditorBrowsable (EditorBrowsableState.Never)]
171 public override string Text {
172 get { return base.Text; }
173 set { base.Text = value; }
176 public int Value {
177 get {
178 if ( IsHandleCreated )
179 val = (int)Win32.SendMessage ( Handle, (int)ProgressBarMessages.PBM_GETPOS, 0, 0 );
180 return val;
182 set {
183 if ( value < Minimum || value > Maximum )
184 throw new ArgumentException(
185 string.Format("'{0}' is not a valid value for 'Value'. 'Value' should be between 'Minimum' and 'Maximum'", value));
187 val = value;
189 if ( IsHandleCreated )
190 Win32.SendMessage(Handle, (int)ProgressBarMessages.PBM_SETPOS, val, 0);
193 #endregion
195 #region Methods
197 protected override void CreateHandle() {
198 initCommonControlsLibrary ( );
199 base.CreateHandle();
202 public void Increment(int value) {
203 int newValue = Value + value;
204 if ( newValue < Minimum )
205 newValue = Minimum;
206 if ( newValue > Maximum )
207 newValue = Maximum;
208 Value = newValue;
211 protected override void OnHandleCreated(EventArgs e) {
212 base.OnHandleCreated(e);
213 Win32.SendMessage(Handle, (int)ProgressBarMessages.PBM_SETRANGE32, Minimum, Maximum);
214 Win32.SendMessage(Handle, (int)ProgressBarMessages.PBM_SETPOS, Value, 0);
215 Win32.SendMessage(Handle, (int)ProgressBarMessages.PBM_SETSTEP, Step, 0);
218 public void PerformStep() {
219 if ( IsHandleCreated )
220 Win32.SendMessage(Handle, (int)ProgressBarMessages.PBM_STEPIT, 0, 0);
223 public override string ToString() {
224 return string.Format ("{0}, Minimum: {1}, Maximum: {2}, Value: {3}",
225 GetType().FullName.ToString (),
226 Maximum.ToString (),
227 Minimum.ToString (),
228 Value.ToString () );
230 #endregion
232 private void initCommonControlsLibrary ( ) {
233 if ( !RecreatingHandle ) {
234 INITCOMMONCONTROLSEX initEx = new INITCOMMONCONTROLSEX();
235 initEx.dwICC = CommonControlInitFlags.ICC_PROGRESS_CLASS;
236 Win32.InitCommonControlsEx(initEx);