4 // Permission is hereby granted, free of charge, to any person obtaining
5 // a copy of this software and associated documentation files (the
6 // "Software"), to deal in the Software without restriction, including
7 // without limitation the rights to use, copy, modify, merge, publish,
8 // distribute, sublicense, and/or sell copies of the Software, and to
9 // permit persons to whom the Software is furnished to do so, subject to
10 // the following conditions:
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 // Copyright (c) 2006 Jonathan Pobst
26 // Jonathan Pobst (monkey@jpobst.com)
31 using System.ComponentModel;
32 using System.Runtime.InteropServices;
33 using System.Windows.Forms.Design;
35 namespace System.Windows.Forms
37 [ToolStripItemDesignerAvailability (ToolStripItemDesignerAvailability.StatusStrip)]
38 public class ToolStripStatusLabel : ToolStripLabel
40 private ToolStripStatusLabelBorderSides border_sides;
41 private Border3DStyle border_style;
44 #region Public Constructors
45 public ToolStripStatusLabel ()
46 : this (String.Empty, null, null, String.Empty)
50 public ToolStripStatusLabel (Image image)
51 : this (String.Empty, image, null, String.Empty)
55 public ToolStripStatusLabel (string text)
56 : this (text, null, null, String.Empty)
60 public ToolStripStatusLabel (string text, Image image)
61 : this (text, image, null, String.Empty)
65 public ToolStripStatusLabel (string text, Image image, EventHandler onClick)
66 : this (text, image, onClick, String.Empty)
70 public ToolStripStatusLabel (string text, Image image, EventHandler onClick, string name)
71 : base (text, image, false, onClick, name)
73 this.border_style = Border3DStyle.Flat;
77 #region Public Properties
79 [EditorBrowsable (EditorBrowsableState.Advanced)]
80 public new ToolStripItemAlignment Alignment {
81 get { return base.Alignment; }
82 set { base.Alignment = value; }
85 [DefaultValue (ToolStripStatusLabelBorderSides.None)]
86 public ToolStripStatusLabelBorderSides BorderSides {
87 get { return this.border_sides; }
88 set { this.border_sides = value; }
91 [DefaultValue (Border3DStyle.Flat)]
92 public Border3DStyle BorderStyle {
93 get { return this.border_style; }
94 set { this.border_style = value; }
97 [DefaultValue (false)]
99 get { return this.spring; }
101 if (this.spring != value) {
103 CalculateAutoSize ();
109 #region Protected Properties
110 protected internal override Padding DefaultMargin {
111 get { return new Padding (0, 3, 0, 2); }
115 #region Public Methods
116 public override Size GetPreferredSize (Size constrainingSize)
118 return base.GetPreferredSize (constrainingSize);
122 #region Protected Methods
123 protected override void OnPaint (PaintEventArgs e)