Merge pull request #1275 from ranma42/fix-lib64
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / ToolStripStatusLabel.cs
1 //
2 // StatusStrip.cs
3 //
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:
11 // 
12 // The above copyright notice and this permission notice shall be
13 // included in all copies or substantial portions of the Software.
14 // 
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.
22 //
23 // Copyright (c) 2006 Jonathan Pobst
24 //
25 // Authors:
26 //      Jonathan Pobst (monkey@jpobst.com)
27 //
28
29 using System;
30 using System.Drawing;
31 using System.ComponentModel;
32 using System.Runtime.InteropServices;
33 using System.Windows.Forms.Design;
34
35 namespace System.Windows.Forms
36 {
37         [ToolStripItemDesignerAvailability (ToolStripItemDesignerAvailability.StatusStrip)]
38         public class ToolStripStatusLabel : ToolStripLabel
39         {
40                 private ToolStripStatusLabelBorderSides border_sides;
41                 private Border3DStyle border_style;
42                 private bool spring;
43                 
44                 #region Public Constructors
45                 public ToolStripStatusLabel ()
46                         : this (String.Empty, null, null, String.Empty)
47                 {
48                 }
49
50                 public ToolStripStatusLabel (Image image)
51                         : this (String.Empty, image, null, String.Empty)
52                 {
53                 }
54
55                 public ToolStripStatusLabel (string text)
56                         : this (text, null, null, String.Empty)
57                 {
58                 }
59
60                 public ToolStripStatusLabel (string text, Image image)
61                         : this (text, image, null, String.Empty)
62                 {
63                 }
64
65                 public ToolStripStatusLabel (string text, Image image, EventHandler onClick)
66                         : this (text, image, onClick, String.Empty)
67                 {
68                 }
69
70                 public ToolStripStatusLabel (string text, Image image, EventHandler onClick, string name)
71                         : base (text, image, false, onClick, name)
72                 {
73                         this.border_style = Border3DStyle.Flat;
74                 }
75                 #endregion
76
77                 #region Public Properties
78                 [Browsable (false)]
79                 [EditorBrowsable (EditorBrowsableState.Advanced)]
80                 public new ToolStripItemAlignment Alignment {
81                         get { return base.Alignment; }
82                         set { base.Alignment = value; }
83                 }
84                 
85                 [DefaultValue (ToolStripStatusLabelBorderSides.None)]
86                 public ToolStripStatusLabelBorderSides BorderSides {
87                         get { return this.border_sides; }
88                         set { this.border_sides = value; }
89                 }
90                 
91                 [DefaultValue (Border3DStyle.Flat)]
92                 public Border3DStyle BorderStyle {
93                         get { return this.border_style; }
94                         set { this.border_style = value; }
95                 }
96                 
97                 [DefaultValue (false)]
98                 public bool Spring {
99                         get { return this.spring; }
100                         set {
101                                 if (this.spring != value) {
102                                         this.spring = value;
103                                         CalculateAutoSize ();
104                                 }
105                         }
106                 }
107                 #endregion
108
109                 #region Protected Properties
110                 protected internal override Padding DefaultMargin {
111                         get { return new Padding (0, 3, 0, 2); }
112                 }
113                 #endregion
114
115                 #region Public Methods
116                 public override Size GetPreferredSize (Size constrainingSize)
117                 {
118                         return base.GetPreferredSize (constrainingSize);
119                 }
120                 #endregion
121
122                 #region Protected Methods
123                 protected override void OnPaint (PaintEventArgs e)
124                 {
125                         base.OnPaint (e);
126                 }
127                 #endregion
128         }
129 }