2 // ToolStripContainer.cs
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;
34 namespace System.Windows.Forms
37 [ClassInterface (ClassInterfaceType.AutoDispatch)]
38 [Designer ("System.Windows.Forms.Design.ToolStripContainerDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
39 public class ToolStripContainer : ContainerControl
41 private ToolStripPanel bottom_panel;
42 private ToolStripContentPanel content_panel;
43 private ToolStripPanel left_panel;
44 private ToolStripPanel right_panel;
45 private ToolStripPanel top_panel;
47 #region Public Constructors
48 public ToolStripContainer () : base ()
50 SetStyle (ControlStyles.SupportsTransparentBackColor, true);
51 SetStyle (ControlStyles.ResizeRedraw, true);
53 content_panel = new ToolStripContentPanel ();
54 content_panel.Dock = DockStyle.Fill;
55 this.Controls.Add (content_panel);
57 this.top_panel = new ToolStripPanel ();
58 this.top_panel.Dock = DockStyle.Top;
59 this.top_panel.Height = 0;
60 this.Controls.Add (top_panel);
62 this.bottom_panel = new ToolStripPanel ();
63 this.bottom_panel.Dock = DockStyle.Bottom;
64 this.bottom_panel.Height = 0;
65 this.Controls.Add (bottom_panel);
67 this.left_panel = new ToolStripPanel ();
68 this.left_panel.Dock = DockStyle.Left;
69 this.left_panel.Width = 0;
70 this.Controls.Add (left_panel);
72 this.right_panel = new ToolStripPanel ();
73 this.right_panel.Dock = DockStyle.Right;
74 this.right_panel.Width = 0;
75 this.Controls.Add (right_panel);
79 #region Public Properties
81 [EditorBrowsable (EditorBrowsableState.Never)]
82 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
83 public override bool AutoScroll {
84 get { return base.AutoScroll; }
85 set { base.AutoScroll = value; }
89 [EditorBrowsable (EditorBrowsableState.Never)]
90 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
91 public new Size AutoScrollMargin {
92 get { return base.AutoScrollMargin; }
93 set { base.AutoScrollMargin = value; }
97 [EditorBrowsable (EditorBrowsableState.Never)]
98 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
99 public new Size AutoScrollMinSize {
100 get { return base.AutoScrollMinSize; }
101 set { base.AutoScrollMinSize = value; }
105 [EditorBrowsable (EditorBrowsableState.Never)]
106 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
107 public new Color BackColor {
108 get { return base.BackColor; }
109 set { base.BackColor = value; }
113 [EditorBrowsable (EditorBrowsableState.Never)]
114 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
115 public new Image BackgroundImage {
116 get { return base.BackgroundImage; }
117 set { base.BackgroundImage = value; }
121 [EditorBrowsable (EditorBrowsableState.Never)]
122 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
123 public override ImageLayout BackgroundImageLayout {
124 get { return base.BackgroundImageLayout; }
125 set { base.BackgroundImageLayout = value; }
128 [Localizable (false)]
129 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
130 public ToolStripPanel BottomToolStripPanel {
131 get { return this.bottom_panel; }
134 [DefaultValue (true)]
135 public bool BottomToolStripPanelVisible {
136 get { return this.bottom_panel.Visible; }
137 set { this.bottom_panel.Visible = value; }
141 [EditorBrowsable (EditorBrowsableState.Never)]
142 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
143 public new bool CausesValidation {
144 get { return base.CausesValidation; }
145 set { base.CausesValidation = value; }
148 [Localizable (false)]
149 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
150 public ToolStripContentPanel ContentPanel {
151 get { return this.content_panel; }
155 [EditorBrowsable (EditorBrowsableState.Never)]
156 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
157 public new ContextMenuStrip ContextMenuStrip {
158 get { return base.ContextMenuStrip; }
159 set { base.ContextMenuStrip = value; }
162 [EditorBrowsable (EditorBrowsableState.Never)]
163 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
164 public new ControlCollection Controls {
165 get { return base.Controls; }
169 [EditorBrowsable (EditorBrowsableState.Never)]
170 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
171 public override Cursor Cursor {
172 get { return base.Cursor; }
173 set { base.Cursor = value; }
177 [EditorBrowsable (EditorBrowsableState.Never)]
178 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
179 public new Color ForeColor {
180 get { return base.ForeColor; }
181 set { base.ForeColor = value; }
184 [Localizable (false)]
185 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
186 public ToolStripPanel LeftToolStripPanel {
187 get { return this.left_panel; }
190 [DefaultValue (true)]
191 public bool LeftToolStripPanelVisible {
192 get { return this.left_panel.Visible; }
193 set { this.left_panel.Visible = value; }
196 [Localizable (false)]
197 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
198 public ToolStripPanel RightToolStripPanel {
199 get { return this.right_panel; }
202 [DefaultValue (true)]
203 public bool RightToolStripPanelVisible {
204 get { return this.right_panel.Visible; }
205 set { this.right_panel.Visible = value; }
208 [Localizable (false)]
209 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
210 public ToolStripPanel TopToolStripPanel {
211 get { return this.top_panel; }
214 [DefaultValue (true)]
215 public bool TopToolStripPanelVisible {
216 get { return this.top_panel.Visible; }
217 set { this.top_panel.Visible = value; }
221 #region Protected Properties
222 protected override Size DefaultSize {
223 get { return new Size (150, 175); }
227 #region Protected Methods
228 [EditorBrowsable (EditorBrowsableState.Advanced)]
229 protected override ControlCollection CreateControlsInstance ()
231 return new ToolStripContainerTypedControlCollection (this);
234 protected override void OnRightToLeftChanged (EventArgs e)
236 base.OnRightToLeftChanged (e);
239 protected override void OnSizeChanged (EventArgs e)
241 base.OnSizeChanged (e);
245 #region Public Events
247 [EditorBrowsable (EditorBrowsableState.Never)]
248 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
249 public new event EventHandler BackColorChanged {
250 add { base.BackColorChanged += value; }
251 remove { base.BackColorChanged -= value; }
255 [EditorBrowsable (EditorBrowsableState.Never)]
256 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
257 public new event EventHandler BackgroundImageChanged {
258 add { base.BackgroundImageChanged += value; }
259 remove { base.BackgroundImageChanged -= value; }
263 [EditorBrowsable (EditorBrowsableState.Never)]
264 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
265 public new event EventHandler BackgroundImageLayoutChanged {
266 add { base.BackgroundImageLayoutChanged += value; }
267 remove { base.BackgroundImageLayoutChanged -= value; }
271 [EditorBrowsable (EditorBrowsableState.Never)]
272 public new event EventHandler CausesValidationChanged {
273 add { base.CausesValidationChanged += value; }
274 remove { base.CausesValidationChanged -= value; }
278 [EditorBrowsable (EditorBrowsableState.Never)]
279 public new event EventHandler ContextMenuStripChanged {
280 add { base.ContextMenuStripChanged += value; }
281 remove { base.ContextMenuStripChanged -= value; }
285 [EditorBrowsable (EditorBrowsableState.Never)]
286 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
287 public new event EventHandler CursorChanged {
288 add { base.CursorChanged += value; }
289 remove { base.CursorChanged -= value; }
293 [EditorBrowsable (EditorBrowsableState.Never)]
294 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
295 public new event EventHandler ForeColorChanged {
296 add { base.ForeColorChanged += value; }
297 remove { base.ForeColorChanged -= value; }
301 #region Private Class : ToolStripContainerTypedControlCollection
302 private class ToolStripContainerTypedControlCollection : ControlCollection
304 public ToolStripContainerTypedControlCollection (Control owner) : base (owner)