signiture fixes
[mono.git] / mcs / class / System.Windows.Forms / System.Windows.Forms / ImageList.cs
1 //
2 // System.Windows.Forms.ImageList.cs
3 //
4 // Author:
5 //   stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
6 //      Dennis Hayes (dennish@raytek.com)
7 //   Aleksey Ryabchuk (ryabchuk@yahoo.com)
8 //
9 // (C) 2002/3 Ximian, Inc
10 //
11 using System.ComponentModel;
12 using System.Drawing;
13 using System.Collections;
14 using System.Runtime.Serialization;
15
16 namespace System.Windows.Forms {
17
18         // <summary>
19         //
20         // </summary>
21     public sealed class ImageList : Component {
22                 ColorDepth colorDepth;
23                 Size       size;
24                 Color      transparentColor;
25                 IntPtr     handle;
26                 ImageCollection images;
27
28                 ImageListStreamer imageListStreamer;
29
30                 [MonoTODO]
31                 public ImageList() {
32                         colorDepth = ColorDepth.Depth4Bit;
33                         size = new Size ( 16, 16 );
34                         transparentColor = Color.Transparent;
35                 }
36
37                 [MonoTODO]
38                 public ImageList(IContainer cont) : this() {
39                         cont.Add ( this );
40                 }
41
42
43                 [MonoTODO]
44                 public ColorDepth ColorDepth {
45                         get {   return colorDepth; }
46                         set {
47                                 if ( !Enum.IsDefined ( typeof( ColorDepth ), value ) )
48                                         throw new InvalidEnumArgumentException( "ColorDepth",
49                                                 (int)value,
50                                                 typeof( ColorDepth ) );
51
52                                 if ( colorDepth != value ) {
53                                         colorDepth = value;
54                                         if ( HandleCreated )
55                                                 recreateHandle ( );
56                                 }
57                         }
58                 }
59
60                 [MonoTODO]
61                 protected override void Dispose(bool disposing){
62                         base.Dispose(disposing);
63                 }
64
65                 [MonoTODO]
66                 public IntPtr Handle {
67                         get {
68                                 if ( !HandleCreated )
69                                         createHandle ( );
70                                 return handle;
71                         }
72                 }
73
74                 [MonoTODO]
75                 public bool HandleCreated {
76                         get {   return handle != IntPtr.Zero;   }
77                 }
78
79                 [MonoTODO]
80                 public ImageList.ImageCollection Images {
81                         get {
82                                 if ( images == null )
83                                         images = new ImageCollection ( this );
84                                 return images;
85                         }
86                 }
87
88                 [MonoTODO]
89                 public Size ImageSize {
90                         get {   return size;  }
91                         set {
92                                 if ( value.IsEmpty || value.Width  <= 0 || value.Height <= 0 || 
93                                         value.Width  > 256 || value.Height > 256 )
94                                         throw new ArgumentException( ); // FIXME: message
95
96                                 if ( size != value ) {
97                                         size = value;
98                                         if ( HandleCreated )
99                                                 recreateHandle ( );
100                                         
101                                 }
102                         }
103                 }
104
105                 [MonoTODO]
106                 public ImageListStreamer ImageStream {
107                         get {
108                                 return imageListStreamer;
109                         }
110                         set {
111                                 imageListStreamer = value;
112                                 destroyHandle ( );
113                                 handle = imageListStreamer.Handle;
114                         }
115                 }
116
117                 [MonoTODO]
118                 public Color TransparentColor {
119                         get {   return transparentColor; }
120                         set {   transparentColor = value;}
121                 }
122
123                 //
124                 //  --- Public Methods
125                 //
126
127                 [MonoTODO]
128                 public void Draw(Graphics g, Point pt, int index)
129                 {
130                         //FIXME:
131                 }
132
133                 [MonoTODO]
134                 public void Draw(Graphics g, int x, int y, int index)
135                 {
136                         //FIXME:
137                 }
138
139                 [MonoTODO]
140                 public void Draw(Graphics g, int x, int y, int width, int height, int index)
141                 {
142                         //FIXME:
143                 }
144
145                 [MonoTODO]
146                 public override string ToString()
147                 {
148                         //FIXME:
149                         return base.ToString();
150                 }
151
152                 //
153                 //  --- Public Events
154                 //
155                 public event EventHandler RecreateHandle;
156
157                 private void createHandle ( )
158                 {
159                         ImageListStreamer.initCommonControlsLibrary( );
160                 }
161
162                 private void recreateHandle ( ) {
163                 }
164
165                 private void destroyHandle ( )
166                 {
167                         if ( HandleCreated )
168                                 Win32.ImageList_Destroy ( handle );
169                 }
170
171                 //
172                 // System.Windows.Forms.ImageList.ImageCollection.cs
173                 //
174                 // Author:
175                 //   stubbed out by Daniel Carrera (dcarrera@math.toronto.edu)
176                 //   Aleksey Ryabchuk (ryabchuk@yahoo.com)
177                 //// (C) 2002 Ximian, Inc
178                 ////
179                 // <summary>
180                 //
181                 // </summary>
182
183                 public sealed class ImageCollection : IList, ICollection, IEnumerable {
184                         private ArrayList list;
185                         private ImageList owner;
186
187
188                 public ImageCollection( ImageList owner )  {
189                         list = new ArrayList();
190                         this.owner = owner;
191                 }
192
193                 [MonoTODO]
194                 public int Count {
195                         get { return list.Count; }
196                 }
197
198                 [MonoTODO]
199                 public bool Empty {
200                         get { return list.Count == 0; }
201                 }
202
203                 [MonoTODO]
204                 public bool IsReadOnly {
205                         get { return list.IsReadOnly; }
206                 }
207
208                 [MonoTODO]
209                 public Image this[int index] {
210                         get {   return ( Image ) list[ index ]; }
211                         set {   list[ index ] = value;  }
212                 }
213
214                 [MonoTODO]
215                 public void Add(Icon icon) {
216                         if ( icon == null )
217                                 throw new ArgumentNullException("value");
218                         
219                         //list.Add( Bitmap.FromHicon ( icon.Handle ) );
220                 }
221
222                 [MonoTODO]
223                 public void Add(Image img) {
224                         if ( img == null )
225                                 throw new ArgumentNullException("value");
226
227                         list.Add( img );
228                 }
229
230                 [MonoTODO]
231                 public int Add(Image img, Color col) {
232                         if ( img == null )
233                                 throw new ArgumentNullException("value");
234
235                         return list.Add( img );
236                 }
237
238                 [MonoTODO]
239                 public int AddStrip( Image value ) {
240                         return -1;
241                 }
242
243                 [MonoTODO]
244                 public void Clear() {
245                         list.Clear ( );
246                 }
247
248                 [MonoTODO]
249                 public bool Contains(Image image) {
250                         return list.Contains( image );
251                 }
252
253                 [MonoTODO]
254                 public IEnumerator GetEnumerator() {
255                         return list.GetEnumerator();
256                 }
257
258                 [MonoTODO]
259                 public int IndexOf(Image image) {
260                         return list.IndexOf( image );
261                 }
262
263                 [MonoTODO]
264                 public void Remove(Image image) {
265                         list.Remove( image );
266                 }
267
268                 [MonoTODO]
269                 public void RemoveAt(int index) {
270                         if (index < 0 || index > Count )
271                                 throw new ArgumentOutOfRangeException( "index" );
272
273                         list.RemoveAt( index );
274                 }
275
276                 [MonoTODO]
277                 public override string ToString()
278                 {
279                         //FIXME:
280                         return base.ToString();
281                 }
282                         /// <summary>
283                         /// IList Interface implmentation.
284                         /// </summary>
285                         bool IList.IsReadOnly{
286                                 get{    return list.IsReadOnly; }
287                         }
288                         bool IList.IsFixedSize{
289                                 get{    return list.IsFixedSize; }
290                         }
291
292                         object IList.this[int index]{
293                                 get { return this[index]; }
294                                 set { this[index]= (Image) value; }
295                         }
296                 
297                         [MonoTODO]
298                         void IList.Clear(){
299                                 Clear ( );
300                         }
301                 
302                         [MonoTODO]
303                         int IList.Add( object value ){
304                                 if (!(value is Image))
305                                         throw new ArgumentException();//FIXME: message
306
307                                 Add( (Image) value );
308                                 return Count;
309                         }
310
311                         [MonoTODO]
312                         bool IList.Contains( object value ){
313                                 if (!(value is Image))
314                                         return false;
315                                 return Contains( (Image) value );
316                         }
317
318                         [MonoTODO]
319                         int IList.IndexOf( object value ){
320                                 if ( !( value is Image))
321                                         return -1;
322                                 return IndexOf( (Image) value );
323                         }
324
325                         [MonoTODO]
326                         void IList.Insert( int index, object value ){
327                                 if ( !( value is Image ) )
328                                         throw new ArgumentException();//FIXME: message
329                                 
330                                 list.Insert ( index, value );
331                         }
332
333                         [MonoTODO]
334                         void IList.Remove( object value ){
335                                 if ( !(value is Image) )
336                                         throw new ArgumentException(); //FIXME: message
337
338                                 Remove( (Image) value);
339                         }
340
341                         [MonoTODO]
342                         void IList.RemoveAt( int index ){
343                                 RemoveAt ( index );
344                         }
345                         // End of IList interface
346
347                         /// <summary>
348                         /// ICollection Interface implmentation.
349                         /// </summary>
350                         int ICollection.Count{
351                                 get{    return Count;  }
352                         }
353                         bool ICollection.IsSynchronized{
354                                 get{    return list.IsSynchronized; }
355                         }
356                         object ICollection.SyncRoot{
357                                 get{    return list.SyncRoot;   }
358                         }
359                         void ICollection.CopyTo(Array array, int index){
360                                 list.CopyTo ( array, index );
361                         }
362                         // End Of ICollection
363
364                 }// End of Subclass
365
366          }//End of class
367 }