2 // System.Windows.Forms.StatusBarPanel
5 // stubbed out by Richard Baumann (biochem333@nyc.rr.com)
6 // Dennis Hayes (dennish@Raytek.com)
7 // Aleksey Ryabchuk (ryabchuk@yahoo.com)
9 // (C) Ximian, Inc., 2002/3
13 using System
.ComponentModel
;
15 namespace System
.Windows
.Forms
{
18 /// Represents a panel in a StatusBar control.
20 public class StatusBarPanel
: Component
, ISupportInitialize
{
25 private HorizontalAlignment alignment
;
26 private StatusBarPanelAutoSize autoSize
;
27 private StatusBarPanelBorderStyle borderStyle
;
30 private StatusBar parent
;
31 private StatusBarPanelStyle style
;
33 private string toolTipText
;
35 private bool suppressUpdates
;
38 // --- Constructors/Destructors
40 public StatusBarPanel() : base()
42 alignment
= HorizontalAlignment
.Left
;
43 autoSize
= StatusBarPanelAutoSize
.None
;
44 borderStyle
= StatusBarPanelBorderStyle
.Sunken
;
46 style
= StatusBarPanelStyle
.Text
;
48 suppressUpdates
= false;
54 public void BeginInit()
56 suppressUpdates
= true;
61 suppressUpdates
= false;
62 UpdateParent( true, true, null );
65 public override string ToString()
67 return "StatusBarPanel: {" + Text + "}";
70 // --- Public Properties
72 public HorizontalAlignment Alignment
{
73 get { return alignment; }
75 if ( !Enum
.IsDefined ( typeof(HorizontalAlignment
), value ) )
76 throw new InvalidEnumArgumentException( "Alignment",
78 typeof(HorizontalAlignment
));
81 UpdateParent ( false, true, this );
85 public StatusBarPanelAutoSize AutoSize
{
86 get { return autoSize; }
89 if ( !Enum
.IsDefined ( typeof(StatusBarPanelAutoSize
), value ) )
90 throw new InvalidEnumArgumentException( "AutoSize",
92 typeof(StatusBarPanelAutoSize
));
94 UpdateParent ( true, false, null );
98 public StatusBarPanelBorderStyle BorderStyle
{
99 get { return borderStyle; }
101 if ( !Enum
.IsDefined ( typeof(StatusBarPanelBorderStyle
), value ) )
102 throw new InvalidEnumArgumentException( "BorderStyle",
104 typeof(StatusBarPanelBorderStyle
));
107 UpdateParent ( false, true, this );
115 UpdateParent ( true, false, null );
121 get { return minWidth; }
124 throw new ArgumentException(
125 string.Format("'{0}' is not a valid value for 'value'. 'value' must be greater than or equal to 0.",
128 UpdateParent ( true, false, null );
132 public StatusBar Parent
{
133 get { return parent; }
136 public StatusBarPanelStyle Style
{
137 get { return style; }
139 if ( !Enum
.IsDefined ( typeof(StatusBarPanelStyle
), value ) )
140 throw new InvalidEnumArgumentException( "Style",
142 typeof(StatusBarPanelStyle
));
144 UpdateParent ( false, true, this );
152 UpdateParent ( AutoSize
== StatusBarPanelAutoSize
.Contents
, true, this );
156 public string ToolTipText
158 get { return toolTipText; }
161 UpdateTooltips ( this );
166 get { return width; }
168 // According to MS documentation this method
169 // should throw ArgumentException if value < MinWidth,
170 // but it does not actually happens.
171 if ( value < MinWidth
)
175 UpdateParent ( true, false, null );
179 public int GetContentWidth ( ) {
180 if( Parent
!= null) {
182 if ( Text
!= null ) {}
183 //cxsize = Win32.GetTextExtent( Parent.Handle, Text ).cx;
184 return cxsize
< MinWidth
? MinWidth
: cxsize
;
189 private void UpdateParent ( bool UpdateParts
, bool UpdateText
, StatusBarPanel p
) {
190 if ( Parent
!= null && suppressUpdates
!= true)
191 Parent
.UpdatePanels ( UpdateParts
, UpdateText
, p
);
194 private void UpdateTooltips ( StatusBarPanel p
) {
195 if ( Parent
!= null && suppressUpdates
!= true)
196 Parent
.UpdateToolTips ( p
);
199 internal void SetParent ( StatusBar prnt
) {