1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Jackson Harper (jackson@ximian.com)
29 using System.ComponentModel;
30 using System.ComponentModel.Design;
31 using System.Runtime.InteropServices;
33 namespace System.Windows.Forms {
37 [DefaultProperty("Text")]
38 [DesignTimeVisible(false)]
39 public class StatusBarPanel : Component, ISupportInitialize {
40 #region Local Variables
41 private StatusBar parent;
43 private bool initializing;
44 private string text = String.Empty;
45 private string tool_tip_text = String.Empty;
48 private HorizontalAlignment alignment = HorizontalAlignment.Left;
49 private StatusBarPanelAutoSize auto_size = StatusBarPanelAutoSize.None;
50 private StatusBarPanelBorderStyle border_style = StatusBarPanelBorderStyle.Sunken;
51 private StatusBarPanelStyle style = StatusBarPanelStyle.Text;
52 private int width = 100;
53 private int min_width = 10;
60 #endregion // Local Variables
63 public StatusBarPanel ()
66 #endregion // Constructors
68 [DefaultValue(HorizontalAlignment.Left)]
70 public HorizontalAlignment Alignment {
71 get { return alignment; }
74 InvalidateContents ();
79 [RefreshProperties (RefreshProperties.All)]
81 [DefaultValue(StatusBarPanelAutoSize.None)]
82 public StatusBarPanelAutoSize AutoSize {
83 get { return auto_size; }
90 [DefaultValue(StatusBarPanelBorderStyle.Sunken)]
92 public StatusBarPanelBorderStyle BorderStyle {
93 get { return border_style; }
106 InvalidateContents ();
112 [RefreshProperties(RefreshProperties.All)]
113 public int MinWidth {
116 MSDN says that when AutoSize = None then MinWidth is automatically
117 set to Width, but neither v1.1 nor v2.0 behave that way.
124 throw new ArgumentOutOfRangeException ("value");
127 throw new ArgumentException ("value");
130 if (min_width > width)
153 get { return width; }
156 throw new ArgumentException ("value");
167 [DefaultValue(StatusBarPanelStyle.Text)]
168 public StatusBarPanelStyle Style {
169 get { return style; }
176 [TypeConverter (typeof (StringConverter))]
177 [Localizable (false)]
179 [DefaultValue (null)]
196 InvalidateContents ();
202 public string ToolTipText {
203 get { return tool_tip_text; }
204 set { tool_tip_text = value; }
208 public StatusBar Parent {
209 get { return parent; }
212 private void Invalidate ()
216 parent.UpdatePanel (this);
219 private void InvalidateContents ()
223 parent.UpdatePanelContents (this);
226 internal void SetParent (StatusBar parent)
228 this.parent = parent;
231 internal void SetWidth (int width)
234 if (min_width > this.width)
235 this.width = min_width;
238 public override string ToString ()
240 return "StatusBarPanel: {" + Text +"}";
243 protected override void Dispose (bool disposing)
247 public void BeginInit ()
252 public void EndInit ()
257 if (min_width > width)
260 initializing = false;