2 // ToolStripSeparator.cs
\r
4 // Permission is hereby granted, free of charge, to any person obtaining
\r
5 // a copy of this software and associated documentation files (the
\r
6 // "Software"), to deal in the Software without restriction, including
\r
7 // without limitation the rights to use, copy, modify, merge, publish,
\r
8 // distribute, sublicense, and/or sell copies of the Software, and to
\r
9 // permit persons to whom the Software is furnished to do so, subject to
\r
10 // the following conditions:
\r
12 // The above copyright notice and this permission notice shall be
\r
13 // included in all copies or substantial portions of the Software.
\r
15 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
\r
16 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
\r
17 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
\r
18 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
\r
19 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
\r
20 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
\r
21 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
\r
23 // Copyright (c) 2006 Jonathan Pobst
\r
26 // Jonathan Pobst (monkey@jpobst.com)
\r
30 using System.Drawing;
\r
31 using System.ComponentModel;
\r
33 namespace System.Windows.Forms
\r
35 public class ToolStripSeparator : ToolStripItem
\r
37 private bool auto_tool_tip;
\r
38 private ToolStripItemDisplayStyle display_style;
\r
39 private bool double_click_enabled;
\r
40 private ContentAlignment image_align;
\r
41 private int image_index;
\r
42 private ToolStripItemImageScaling image_scaling;
\r
43 private ContentAlignment text_align;
\r
44 private TextImageRelation text_image_relation;
\r
45 private string tool_tip_text;
\r
47 public ToolStripSeparator ()
\r
49 this.ForeColor = SystemColors.ControlDark;
\r
52 #region Public Properties
\r
54 [EditorBrowsable (EditorBrowsableState.Never)]
\r
55 public bool AutoToolTip {
\r
56 get { return this.auto_tool_tip; }
\r
57 set { this.auto_tool_tip = value; }
\r
60 public override bool CanSelect { get { return false; } }
\r
63 [EditorBrowsable (EditorBrowsableState.Never)]
\r
64 public ToolStripItemDisplayStyle DisplayStyle {
\r
65 get { return this.display_style; }
\r
66 set { this.display_style = value; }
\r
70 [EditorBrowsable (EditorBrowsableState.Never)]
\r
71 public bool DoubleClickEnabled {
\r
72 get { return this.double_click_enabled; }
\r
73 set { this.double_click_enabled = value; }
\r
77 [EditorBrowsable (EditorBrowsableState.Never)]
\r
78 public override bool Enabled {
\r
79 get { return base.Enabled; }
\r
80 set { base.Enabled = value; }
\r
84 [EditorBrowsable (EditorBrowsableState.Never)]
\r
85 public override Font Font {
\r
86 get { return base.Font; }
\r
87 set { base.Font = value; }
\r
91 [EditorBrowsable (EditorBrowsableState.Never)]
\r
92 public override Image Image {
\r
93 get { return base.Image; }
\r
94 set { base.Image = value; }
\r
98 [EditorBrowsable (EditorBrowsableState.Never)]
\r
99 public ContentAlignment ImageAlign {
\r
100 get { return this.image_align; }
\r
102 if (!Enum.IsDefined (typeof (ContentAlignment), value))
\r
103 throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ContentAlignment", value));
\r
105 this.image_align = value;
\r
109 [Browsable (false)]
\r
110 [EditorBrowsable (EditorBrowsableState.Never)]
\r
111 public int ImageIndex {
\r
112 get { return this.image_index; }
\r
115 throw new ArgumentException ("ImageIndex cannot be less than -1");
\r
117 this.image_index = value;
\r
121 [Browsable (false)]
\r
122 [EditorBrowsable (EditorBrowsableState.Never)]
\r
123 public ToolStripItemImageScaling ImageScaling {
\r
124 get { return this.image_scaling; }
\r
125 set { this.image_scaling = value; }
\r
128 [Browsable (false)]
\r
129 [EditorBrowsable (EditorBrowsableState.Never)]
\r
130 public override string Text {
\r
131 get { return base.Text; }
\r
132 set { base.Text = value; }
\r
135 [Browsable (false)]
\r
136 [EditorBrowsable (EditorBrowsableState.Never)]
\r
137 public ContentAlignment TextAlign {
\r
138 get { return this.text_align; }
\r
140 if (!Enum.IsDefined (typeof (ContentAlignment), value))
\r
141 throw new InvalidEnumArgumentException (string.Format ("Enum argument value '{0}' is not valid for ContentAlignment", value));
\r
143 this.text_align = value;
\r
147 [Browsable (false)]
\r
148 [EditorBrowsable (EditorBrowsableState.Never)]
\r
149 public TextImageRelation TextImageRelation {
\r
150 get { return this.text_image_relation; }
\r
151 set { this.text_image_relation = value; }
\r
154 [Browsable (false)]
\r
155 [EditorBrowsable (EditorBrowsableState.Never)]
\r
156 public string ToolTipText {
\r
157 get { return this.tool_tip_text; }
\r
158 set { this.tool_tip_text = value; }
\r
162 #region Protected Properties
\r
163 protected internal override Padding DefaultMargin { get { return new Padding(); } }
\r
164 protected override Size DefaultSize { get { return new Size(6, 6); } }
\r
167 #region Public Methods
\r
168 public override Size GetPreferredSize (Size constrainingSize)
\r
170 return new Size(6, 6);
\r
174 #region Protected Methods
\r
175 [Browsable (false)]
\r
176 [EditorBrowsable (EditorBrowsableState.Never)]
\r
177 protected override void OnFontChanged (EventArgs e)
\r
179 base.OnFontChanged (e);
\r
182 protected override void OnPaint (PaintEventArgs e)
\r
186 if (this.Owner != null)
\r
187 this.Owner.Renderer.DrawSeparator(new ToolStripSeparatorRenderEventArgs(e.Graphics, this, this.Owner.Orientation == Orientation.Horizontal ? true : false));
\r
190 protected internal override void SetBounds (Rectangle bounds)
\r
192 base.SetBounds (bounds);
\r
196 #region Public Events
\r
197 [Browsable (false)]
\r
198 [EditorBrowsable (EditorBrowsableState.Never)]
\r
199 public event EventHandler DisplayStyleChanged;
\r
201 [Browsable (false)]
\r
202 [EditorBrowsable (EditorBrowsableState.Never)]
\r
203 public event EventHandler EnabledChanged;
\r
205 [Browsable (false)]
\r
206 [EditorBrowsable (EditorBrowsableState.Never)]
\r
207 public event EventHandler TextChanged;
\r