New test.
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / TableLayoutSettings.cs
1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
8 // 
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
11 // 
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
19 //
20 //
21 // Author:
22 //   Miguel de Icaza (miguel@gnome.org)
23 //
24 // (C) 2004 Novell, Inc.
25 //
26 #if NET_2_0
27 using System;
28 using System.ComponentModel;
29 using System.Collections;
30 using System.Windows.Forms.Layout;
31
32 namespace System.Windows.Forms {
33
34         public class TableLayoutSettings : LayoutSettings {
35                 TableLayoutPanel panel;
36                 ColumnStyleCollection column_style;
37                 TableLayoutPanelGrowStyle grow_style;
38                 int column_count;
39                 int row_count;
40
41                 // Statics
42                 static LayoutEngine layout_engine = new TableLayout ();
43                 
44                 internal TableLayoutSettings (TableLayoutPanel panel)
45                 {
46                         this.panel = panel;
47                         column_count = 0;
48                         row_count = 0;
49                         grow_style = TableLayoutPanelGrowStyle.AddRows;
50                         column_style = new ColumnStyleCollection (panel);
51                 }
52
53                 public int ColumnCount {
54                         get {
55                                 return column_count;
56                         }
57
58                         set {
59                                 column_count = value;
60                         }
61                 }
62
63                 public int RowCount {
64                         get {
65                                 return row_count;
66                         }
67
68                         set {
69                                 row_count = value;
70                         }
71                 }
72
73                 public TableLayoutPanelGrowStyle GrowStyle {
74                         get {
75                                 return grow_style;
76                         }
77                 }
78
79                 public override LayoutEngine LayoutEngine {
80                         get {
81                                 return layout_engine;
82                         }
83                 }
84                                 
85                 public TableLayoutSettings.ColumnStyleCollection ColumnStyle {
86                         get {
87                                 return column_style;
88                         }
89                 }
90
91                 public abstract class StyleCollection {
92                         ArrayList al = new ArrayList ();
93                         TableLayoutPanel table;
94                         
95                         internal StyleCollection (TableLayoutPanel table)
96                         {
97                                 this.table = table;
98                         }
99                         
100                         public int Add (TableLayoutSettings.Style style)
101                         {
102                                 return al.Add (style);
103                         }
104
105                         // FIXME; later this should be an override.
106                         public void Clear ()
107                         {
108                                 al.Clear ();
109
110                                 // FIXME: Need to investigate what happens when the style is gone.
111                                 table.Relayout ();
112                         }
113
114 #region IList methods
115                         //
116                         // The IList methods will later be implemeneted, this is to get us started
117                         //
118                         internal bool Contains (Style style)
119                         {
120                                 return al.Contains (style);
121                         }
122
123                         internal int IndexOf (Style style)
124                         {
125                                 return al.IndexOf (style);
126                         }
127
128                         internal void Insert (int index, Style style)
129                         {
130                                 al.Insert (index, style);
131                         }
132
133                         internal void Remove (Style style)
134                         {
135                                 al.Remove (style);
136                         }
137
138 #endregion
139                         public Style this [int idx] {
140                                 get {
141                                         return (Style) al [idx];
142                                 }
143
144                                 set {
145                                         al [idx] = value;
146                                 }
147                         }
148                 }
149                 
150                 public class ColumnStyleCollection : StyleCollection {
151
152                         internal ColumnStyleCollection (TableLayoutPanel panel) : base (panel)
153                         {
154                         }
155                         
156                         public void Add (ColumnStyle style)
157                         {
158                                 base.Add (style);
159                         }
160
161                         public bool Contains (ColumnStyle style)
162                         {
163                                 return base.Contains (style);
164                         }
165
166                         public int IndexOf (ColumnStyle style)
167                         {
168                                 return base.IndexOf (style);
169                         }
170
171                         public void Insert (int index, ColumnStyle style)
172                         {
173                                 base.Insert (index, style);
174                         }
175
176                         public void Remove (ColumnStyle style)
177                         {
178                                 base.Remove (style);
179                         }
180
181                         public new ColumnStyle this [int index] {
182                                 get {
183                                         return (ColumnStyle) base [index];
184                                 }
185
186                                 set {
187                                         base [index] = value;
188                                 }
189                         }
190                 }
191
192                 public class Style {
193                         internal SizeType size_type;
194                         
195                         public SizeType SizeType {
196                                 get {
197                                         return size_type;
198                                 }
199
200                                 set {
201                                         size_type = value;
202                                 }
203                         }
204                 }
205         }
206
207 }
208 #endif