Rename Managed.Windows.Forms to System.Windows.Forms for consistency.
[mono.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / ToolStripContainer.cs
1 //
2 // ToolStripContainer.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
34 namespace System.Windows.Forms
35 {
36         [ComVisible (true)]
37         [ClassInterface (ClassInterfaceType.AutoDispatch)]
38         [Designer ("System.Windows.Forms.Design.ToolStripContainerDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
39         public class ToolStripContainer : ContainerControl
40         {
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;
46
47                 #region Public Constructors
48                 public ToolStripContainer () : base ()
49                 {
50                         SetStyle (ControlStyles.SupportsTransparentBackColor, true);
51                         SetStyle (ControlStyles.ResizeRedraw, true);
52
53                         content_panel = new ToolStripContentPanel ();
54                         content_panel.Dock = DockStyle.Fill;
55                         this.Controls.Add (content_panel);
56
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);
61
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);
66
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);
71
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);
76         }
77                 #endregion
78
79                 #region Public Properties
80                 [Browsable (false)]
81                 [EditorBrowsable (EditorBrowsableState.Never)]
82                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
83                 public override bool AutoScroll {
84                         get { return base.AutoScroll; }
85                         set { base.AutoScroll = value; }
86                 }
87
88                 [Browsable (false)]
89                 [EditorBrowsable (EditorBrowsableState.Never)]
90                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
91                 public new Size AutoScrollMargin {
92                         get { return base.AutoScrollMargin; }
93                         set { base.AutoScrollMargin = value; }
94                 }
95
96                 [Browsable (false)]
97                 [EditorBrowsable (EditorBrowsableState.Never)]
98                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
99                 public new Size AutoScrollMinSize {
100                         get { return base.AutoScrollMinSize; }
101                         set { base.AutoScrollMinSize = value; }
102                 }
103                 
104                 [Browsable (false)]
105                 [EditorBrowsable (EditorBrowsableState.Never)]
106                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
107                 public new Color BackColor {
108                         get { return base.BackColor; }
109                         set { base.BackColor = value; }
110                 }
111                 
112                 [Browsable (false)]
113                 [EditorBrowsable (EditorBrowsableState.Never)]
114                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
115                 public new Image BackgroundImage {
116                         get { return base.BackgroundImage; }
117                         set { base.BackgroundImage = value; }
118                 }
119
120                 [Browsable (false)]
121                 [EditorBrowsable (EditorBrowsableState.Never)]
122                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
123                 public override ImageLayout BackgroundImageLayout {
124                         get { return base.BackgroundImageLayout; }
125                         set { base.BackgroundImageLayout = value; }
126                 }
127                 
128                 [Localizable (false)]
129                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
130                 public ToolStripPanel BottomToolStripPanel {
131                         get { return this.bottom_panel; }
132                 }
133
134                 [DefaultValue (true)]
135                 public bool BottomToolStripPanelVisible {
136                         get { return this.bottom_panel.Visible; }
137                         set { this.bottom_panel.Visible = value; }
138                 }
139
140                 [Browsable (false)]
141                 [EditorBrowsable (EditorBrowsableState.Never)]
142                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
143                 public new bool CausesValidation {
144                         get { return base.CausesValidation; }
145                         set { base.CausesValidation = value; }
146                 }
147
148                 [Localizable (false)]
149                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
150                 public ToolStripContentPanel ContentPanel {
151                         get { return this.content_panel; }
152                 }
153
154                 [Browsable (false)]
155                 [EditorBrowsable (EditorBrowsableState.Never)]
156                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
157                 public new ContextMenuStrip ContextMenuStrip {
158                         get { return base.ContextMenuStrip; }
159                         set { base.ContextMenuStrip = value; }
160                 }
161
162                 [EditorBrowsable (EditorBrowsableState.Never)]
163                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
164                 public new ControlCollection Controls {
165                         get { return base.Controls; }
166                 }
167                 
168                 [Browsable (false)]
169                 [EditorBrowsable (EditorBrowsableState.Never)]
170                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
171                 public override Cursor Cursor {
172                         get { return base.Cursor; }
173                         set { base.Cursor = value; }
174                 }
175                 
176                 [Browsable (false)]
177                 [EditorBrowsable (EditorBrowsableState.Never)]
178                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
179                 public new Color ForeColor {
180                         get { return base.ForeColor; }
181                         set { base.ForeColor = value; }
182                 }
183                 
184                 [Localizable (false)]
185                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
186                 public ToolStripPanel LeftToolStripPanel {
187                         get { return this.left_panel; }
188                 }
189
190                 [DefaultValue (true)]
191                 public bool LeftToolStripPanelVisible {
192                         get { return this.left_panel.Visible; }
193                         set { this.left_panel.Visible = value; }
194                 }
195
196                 [Localizable (false)]
197                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
198                 public ToolStripPanel RightToolStripPanel {
199                         get { return this.right_panel; }
200                 }
201
202                 [DefaultValue (true)]
203                 public bool RightToolStripPanelVisible {
204                         get { return this.right_panel.Visible; }
205                         set { this.right_panel.Visible = value; }
206                 }
207         
208                 [Localizable (false)]
209                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Content)]
210                 public ToolStripPanel TopToolStripPanel {
211                         get { return this.top_panel; }
212                 }
213
214                 [DefaultValue (true)]
215                 public bool TopToolStripPanelVisible {
216                         get { return this.top_panel.Visible; }
217                         set { this.top_panel.Visible = value; }
218                 }
219                 #endregion
220
221                 #region Protected Properties
222                 protected override Size DefaultSize {
223                         get { return new Size (150, 175); }
224                 }
225                 #endregion
226
227                 #region Protected Methods
228                 [EditorBrowsable (EditorBrowsableState.Advanced)]
229                 protected override ControlCollection CreateControlsInstance ()
230                 {
231                         return new ToolStripContainerTypedControlCollection (this);
232                 }
233
234                 protected override void OnRightToLeftChanged (EventArgs e)
235                 {
236                         base.OnRightToLeftChanged (e);
237                 }
238                 
239                 protected override void OnSizeChanged (EventArgs e)
240                 {
241                         base.OnSizeChanged (e);
242                 }
243                 #endregion
244
245                 #region Public Events
246                 [Browsable (false)]
247                 [EditorBrowsable (EditorBrowsableState.Never)]
248                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
249                 public new event EventHandler BackColorChanged {
250                         add { base.BackColorChanged += value; }
251                         remove { base.BackColorChanged -= value; }
252                 }
253
254                 [Browsable (false)]
255                 [EditorBrowsable (EditorBrowsableState.Never)]
256                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
257                 public new event EventHandler BackgroundImageChanged {
258                         add { base.BackgroundImageChanged += value; }
259                         remove { base.BackgroundImageChanged -= value; }
260                 }
261
262                 [Browsable (false)]
263                 [EditorBrowsable (EditorBrowsableState.Never)]
264                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
265                 public new event EventHandler BackgroundImageLayoutChanged {
266                         add { base.BackgroundImageLayoutChanged += value; }
267                         remove { base.BackgroundImageLayoutChanged -= value; }
268                 }
269
270                 [Browsable (false)]
271                 [EditorBrowsable (EditorBrowsableState.Never)]
272                 public new event EventHandler CausesValidationChanged {
273                         add { base.CausesValidationChanged += value; }
274                         remove { base.CausesValidationChanged -= value; }
275                 }
276
277                 [Browsable (false)]
278                 [EditorBrowsable (EditorBrowsableState.Never)]
279                 public new event EventHandler ContextMenuStripChanged {
280                         add { base.ContextMenuStripChanged += value; }
281                         remove { base.ContextMenuStripChanged -= value; }
282                 }
283
284                 [Browsable (false)]
285                 [EditorBrowsable (EditorBrowsableState.Never)]
286                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
287                 public new event EventHandler CursorChanged {
288                         add { base.CursorChanged += value; }
289                         remove { base.CursorChanged -= value; }
290                 }
291
292                 [Browsable (false)]
293                 [EditorBrowsable (EditorBrowsableState.Never)]
294                 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
295                 public new event EventHandler ForeColorChanged {
296                         add { base.ForeColorChanged += value; }
297                         remove { base.ForeColorChanged -= value; }
298                 }
299                 #endregion
300
301                 #region Private Class : ToolStripContainerTypedControlCollection
302                 private class ToolStripContainerTypedControlCollection : ControlCollection
303                 {
304                         public ToolStripContainerTypedControlCollection (Control owner) : base (owner)
305                         {
306                         }
307                 }
308                 #endregion
309         }
310 }