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)
30 using System.Windows.Forms.Layout;
31 using System.ComponentModel;
32 using System.Runtime.InteropServices;
34 namespace System.Windows.Forms
36 [ComVisibleAttribute (true)]
37 [ClassInterfaceAttribute (ClassInterfaceType.AutoDispatch)]
38 [ProvideProperty ("FlowBreak", typeof (Control))]
39 [DefaultEvent ("Paint")]
40 public class FlowLayoutPanel : Panel, IExtenderProvider
42 private FlowLayoutSettings settings;
44 public FlowLayoutPanel () : base ()
46 settings = new FlowLayoutSettings (this);
47 layout_engine = settings.LayoutEngine;
52 [DefaultValue (FlowDirection.LeftToRight)]
53 public FlowDirection FlowDirection {
54 get { return settings.FlowDirection; }
55 set { settings.FlowDirection = value; }
58 [LocalizableAttribute (true)]
60 public bool WrapContents {
61 get { return settings.WrapContents; }
62 set { settings.WrapContents = value; }
65 public override LayoutEngine LayoutEngine {
66 get { return layout_engine; }
69 internal FlowLayoutSettings LayoutSettings {
70 get { return this.settings; }
74 #region Public Methods
75 [DefaultValue (false)]
76 //[DisplayName ("FlowBreak")]
77 public bool GetFlowBreak (Control control)
79 return settings.GetFlowBreak (control);
82 public void SetFlowBreak (Control control, bool value)
84 settings.SetFlowBreak (control, value);
85 this.PerformLayout (control, "FlowBreak");
89 #region IExtenderProvider Members
90 public bool CanExtend (object extendee)
92 if (extendee is Control)
93 if ((extendee as Control).Parent == this)