2007-08-28 Jonathan Pobst <monkey@jpobst.com>
[mono.git] / mcs / class / Managed.Windows.Forms / System.Windows.Forms / TableLayoutStyleCollection.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 // Copyright 2004-2006 Novell, Inc.
25 //
26
27 #if NET_2_0
28 using System;
29 using System.ComponentModel;
30 using System.Collections;
31 using System.Windows.Forms.Layout;
32
33 namespace System.Windows.Forms {
34         [Editor ("System.Windows.Forms.Design.StyleCollectionEditor, " + Consts.AssemblySystem_Design, typeof (System.Drawing.Design.UITypeEditor))]
35         public abstract class TableLayoutStyleCollection : IList, ICollection, IEnumerable
36         {
37                 ArrayList al = new ArrayList ();
38                 TableLayoutPanel table;
39                 
40                 internal TableLayoutStyleCollection (TableLayoutPanel table)
41                 {
42                         this.table = table;
43                 }
44                 
45                 public int Add (TableLayoutStyle style)
46                 {
47                         return al.Add (style);
48                 }
49                 
50                 public void Clear ()
51                 {
52                         al.Clear ();
53                         
54                         // FIXME: Need to investigate what happens when the style is gone.
55                         table.PerformLayout ();
56                 }
57                 
58                 public int Count {
59                         get { return al.Count; }
60                 }
61                 
62                 public void RemoveAt (int index)
63                 {
64                         al.RemoveAt (index);
65                 }
66                 
67 #region IList methods
68                 //
69                 // The IList methods will later be implemeneted, this is to get us started
70                 //
71                 int IList.Add (object style)
72                 {
73                         return al.Add ((TableLayoutStyle) style);
74                 }
75                 
76                 bool IList.Contains (object style)
77                 {
78                         return al.Contains ((TableLayoutStyle) style);
79                 }
80                 
81                 int IList.IndexOf (object style)
82                 {
83                         return al.IndexOf ((TableLayoutStyle) style);
84                 }
85                 
86                 void IList.Insert (int index, object style)
87                 {
88                         al.Insert (index, (TableLayoutStyle) style);
89                 }
90
91                 void IList.Remove (object style)
92                 {
93                         al.Remove ((TableLayoutStyle) style);
94                 }
95
96                 bool IList.IsFixedSize {
97                         get {
98                                 return al.IsFixedSize;
99                         }
100                 }
101
102                 bool IList.IsReadOnly {
103                         get {
104                                 return al.IsReadOnly;
105                         }
106                 }
107
108                 object IList.this [int index] {
109                         get {
110                                 return al [index];
111                         }
112                         set {
113                                 al [index] = value;
114                         }
115                 }
116 #endregion
117
118 #region ICollection methods
119                 void ICollection.CopyTo (Array array, int startIndex)
120                 {
121                         al.CopyTo (array, startIndex);
122                 }
123
124                 object ICollection.SyncRoot {
125                         get {
126                                 return al.SyncRoot;
127                         }
128                 }
129
130                 bool ICollection.IsSynchronized {
131                         get {
132                                 return al.IsSynchronized;
133                         }
134                 }
135 #endregion
136
137 #region IEnumerable methods
138                 IEnumerator IEnumerable.GetEnumerator ()
139                 {
140                         return al.GetEnumerator ();
141                 }
142 #endregion
143                 public TableLayoutStyle this [int idx] {
144                         get {
145                                 return (TableLayoutStyle) al [idx];
146                         }
147
148                         set {
149                                 al [idx] = value;
150                         }
151                 }
152         }
153                 
154 }       
155 #endif