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
62 #region UIA Framework Events
64 static object UIATextChangedEvent = new object ();
66 internal event EventHandler UIATextChanged {
67 add { Events.AddHandler (UIATextChangedEvent, value); }
68 remove { Events.RemoveHandler (UIATextChangedEvent, value); }
71 internal void OnUIATextChanged (EventArgs e)
73 EventHandler eh = (EventHandler) Events [UIATextChangedEvent];
81 public StatusBarPanel ()
84 #endregion // Constructors
86 [DefaultValue(HorizontalAlignment.Left)]
88 public HorizontalAlignment Alignment {
89 get { return alignment; }
92 InvalidateContents ();
97 [RefreshProperties (RefreshProperties.All)]
99 [DefaultValue(StatusBarPanelAutoSize.None)]
100 public StatusBarPanelAutoSize AutoSize {
101 get { return auto_size; }
108 [DefaultValue(StatusBarPanelBorderStyle.Sunken)]
110 public StatusBarPanelBorderStyle BorderStyle {
111 get { return border_style; }
113 border_style = value;
124 InvalidateContents ();
130 [RefreshProperties(RefreshProperties.All)]
131 public int MinWidth {
134 MSDN says that when AutoSize = None then MinWidth is automatically
135 set to Width, but neither v1.1 nor v2.0 behave that way.
142 throw new ArgumentOutOfRangeException ("value");
145 throw new ArgumentException ("value");
148 if (min_width > width)
171 get { return width; }
174 throw new ArgumentException ("value");
185 [DefaultValue(StatusBarPanelStyle.Text)]
186 public StatusBarPanelStyle Style {
187 get { return style; }
194 [TypeConverter (typeof (StringConverter))]
195 [Localizable (false)]
197 [DefaultValue (null)]
214 InvalidateContents ();
217 // UIA Framework Event: Text Changed
218 OnUIATextChanged (EventArgs.Empty);
225 public string ToolTipText {
226 get { return tool_tip_text; }
227 set { tool_tip_text = value; }
231 public StatusBar Parent {
232 get { return parent; }
235 private void Invalidate ()
239 parent.UpdatePanel (this);
242 private void InvalidateContents ()
246 parent.UpdatePanelContents (this);
249 internal void SetParent (StatusBar parent)
251 this.parent = parent;
254 internal void SetWidth (int width)
257 if (min_width > this.width)
258 this.width = min_width;
261 public override string ToString ()
263 return "StatusBarPanel: {" + Text +"}";
266 protected override void Dispose (bool disposing)
270 public void BeginInit ()
275 public void EndInit ()
280 if (min_width > width)
283 initializing = false;