New test.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / FlowLayoutPanel.cs
1 //
2 // FlowLayoutPanel.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 #if NET_2_0
30 using System.Windows.Forms.Layout;
31 using System.ComponentModel;
32 using System.Runtime.InteropServices;
33
34 namespace System.Windows.Forms
35 {
36         [ComVisibleAttribute (true)]
37         [ClassInterfaceAttribute (ClassInterfaceType.AutoDispatch)]
38         [ProvideProperty ("FlowBreak", typeof (Control))]
39         [DefaultEvent ("Paint")]
40         public class FlowLayoutPanel : Panel, IExtenderProvider
41         {
42                 private FlowLayoutSettings settings;
43
44                 public FlowLayoutPanel () : base ()
45                 {
46                         settings = new FlowLayoutSettings (this);
47                         layout_engine = settings.LayoutEngine;
48                 }
49
50                 #region Properties
51                 [Localizable (true)]
52                 [DefaultValue (FlowDirection.LeftToRight)]
53                 public FlowDirection FlowDirection {
54                         get { return settings.FlowDirection; }
55                         set { settings.FlowDirection = value; }
56                 }
57
58                 [LocalizableAttribute (true)]
59                 [DefaultValue (true)]
60                 public bool WrapContents {
61                         get { return settings.WrapContents; }
62                         set { settings.WrapContents = value; }
63                 }
64
65                 public override LayoutEngine LayoutEngine {
66                         get { return layout_engine; }
67                 }
68
69                 internal FlowLayoutSettings LayoutSettings {
70                         get { return this.settings; }
71                 }
72                 #endregion
73
74                 #region Public Methods
75                 [DefaultValue (false)]
76                 //[DisplayName ("FlowBreak")]
77                 public bool GetFlowBreak (Control control)
78                 {
79                         return settings.GetFlowBreak (control);
80                 }
81
82                 public void SetFlowBreak (Control control, bool value)
83                 {
84                         settings.SetFlowBreak (control, value);
85                         this.PerformLayout (control, "FlowBreak");
86                 }               
87                 #endregion
88                 
89                 #region IExtenderProvider Members
90                 public bool CanExtend (object extendee)
91                 {
92                         if (extendee is Control)
93                                 if ((extendee as Control).Parent == this)
94                                         return true;
95
96                         return false;
97                 }
98                 #endregion
99         }
100 }
101 #endif