- Added ActiveMdiChild method
[mono.git] / mcs / class / System.Windows.Forms / Gtk / Control.cs
1 //
2 // System.Windows.Forms.Form
3 //
4 // Author:
5 //   Miguel de Icaza (miguel@ximian.com)
6 //   Rachel Hestilow (hestilow@ximian.com)
7 //   Joel Basson  (jstrike@mweb.co.za)
8 //   Philip Van Hoof (me@freax.org)
9 // (C) 2002 Ximian, Inc
10 //
11
12 using System;
13 using System.Drawing;
14 using Gtk;
15 using GtkSharp;
16 using System.ComponentModel;
17 using System.Collections;
18
19 namespace System.Windows.Forms{
20         public class Control:Component, ISynchronizeInvoke, IWin32Window{
21
22                 private ControlCollection controls;
23                 private Size clientSize;
24                 private bool allowDrop = false;
25                 private Control parent;
26                 private string text, name;
27                 private Size size;
28                 private int left, top, width, height, tabindex, index, tag;             
29                 private Point location = new System.Drawing.Point (0, 0);               
30                 private AnchorStyles anchor = AnchorStyles.Top | AnchorStyles.Left;
31                 private bool tabStop = true;
32                 private RightToLeft rightToLeft;
33                 private DockStyle dock = DockStyle.None;
34                 private ContextMenu contextMenu;
35                 
36                 
37                 
38                 internal Widget widget;
39                 internal Gtk.Layout layout = null;
40                 internal Gtk.VBox vbox = null;
41                 
42                 
43
44                 static Control (){
45                         Gtk.Application.Init ();
46                 }
47
48                 public Control ():this (""){
49                 }
50
51                 public Control (string text):this (null, text){
52                 }
53
54                 public Control (Control parent, string text){
55                         this.Parent = parent;
56                         this.text = text;
57                         clientSize = DefaultSize;
58
59                 }
60
61                 public Control (string text, int left, int top, int width,int height){
62                         clientSize = DefaultSize;
63                 }
64
65                 public Control (Control parent, string text, int left,
66                                 int top, int width, int height)
67                 {
68                         this.Parent = parent;
69                         this.text = text;
70                         this.left = left;
71                         this.top = top;
72                         this.width = width;
73                         this.height = height;
74                         clientSize = DefaultSize;
75                 }
76
77                 [MonoTODO] 
78                 public AccessibleObject AccessibilityObject{
79                         get     {return null;}
80                 }
81                 [MonoTODO] 
82                 public String AccessibleDefaultActionDescription{
83                         get     {return "";}
84                         set     {return;}
85                 }
86                 [MonoTODO] 
87                 public String AccessibleDescription{
88                         get{return "";}
89                         set{return;     }
90
91                 }
92                 [MonoTODO] 
93                 public String AccessibleName{
94                         get     {return "";     }
95                         set     {return;}
96                 }
97                 [MonoTODO] 
98                 public AccessibleRole AccessibleRole    {
99                         get     {throw new NotImplementedException ();}
100                         set     {return;}
101                 }
102
103                 
104                 [MonoTODO] 
105                 public virtual bool AllowDrop{
106                         get{return allowDrop;}
107                         set{allowDrop = value;}
108                 }
109                 [MonoTODO]
110                 public virtual AnchorStyles Anchor{
111                         get     {return anchor; }
112                         set{anchor = value;     }
113                 }
114
115                 [MonoTODO] 
116                 public virtual Color BackColor{
117                         get     {throw new NotImplementedException ();}
118                         set{
119                                 // ?
120                                 Gdk.Color c = new Gdk.Color (value);
121                                 this.Widget.ModifyBg (Gtk.StateType.Normal, c);
122                         }
123                 }
124                 [MonoTODO] 
125                 public virtual System.Drawing.Image BackgroundImage{
126                         get{throw new NotImplementedException ();}
127                         set     {
128                                 return;
129                                 //throw new NotImplementedException();
130                         }
131                 }
132
133                 [MonoTODO] 
134                 public virtual BindingContext BindingContext{
135                         get{throw new NotImplementedException ();}
136                         set{return;}
137                 }
138                 public virtual int Bottom{
139                         get     {return (Top + Height); }
140                 }
141                 [MonoTODO] 
142                 public virtual Rectangle Bounds{
143                         get     {throw new NotImplementedException ();}
144                         set {throw new NotImplementedException ();}
145                 }
146                 [MonoTODO] 
147                 public virtual bool CanFocus{
148                         get     {throw new NotImplementedException ();}
149                 }
150                 [MonoTODO] 
151                 public virtual bool CanSelect{
152                         get     {throw new NotImplementedException ();}
153                 }
154                 [MonoTODO] 
155                 public virtual bool Capture{
156                         get     {throw new NotImplementedException ();  }
157                         set     {throw new NotImplementedException ();}
158
159                 }
160                 [MonoTODO] 
161                 public virtual bool CausesValidation{
162                         get{return true;}
163                         set{}
164                 }
165                 [MonoTODO] 
166                 public virtual Rectangle ClientRectangle        {
167                         get     {throw new NotImplementedException ();  }
168                 }
169
170                 [MonoTODO] 
171                 public virtual Size ClientSize{
172                         get{return clientSize;}
173                         set{
174                                 clientSize = value;
175                                 OnResize (EventArgs.Empty);
176                                 Widget.SetSizeRequest (value.Width, value.Height);
177                         }
178                 }
179                 public virtual String CompanyName{
180                         get{return Application.CompanyName;}
181                 }
182                 [MonoTODO]
183                 public virtual bool ContainsFocus{
184                         get     {throw new NotImplementedException ();}
185                 }
186                 
187                 [MonoTODO] 
188                 public virtual ContextMenu ContextMenu{
189                         get{return contextMenu;}
190                         set{contextMenu = value;}
191                 }
192
193                 public virtual ControlCollection Controls{
194                         get     {
195                                 if (controls == null)
196                                         controls = CreateControlsInstance();
197                                 return controls;
198                                 
199                         }
200                 }
201                 [MonoTODO] 
202                 public virtual bool Created{
203                         get{return true;}
204                 }
205                 [MonoTODO] 
206                 public virtual Cursor Cursor{
207                         get{throw new NotImplementedException ();}
208                         set{}
209
210                 }
211                 [MonoTODO] 
212                 public ControlBindingsCollection DataBindings{
213                         get{throw new NotImplementedException ();}
214                 }
215                 public static Color DefaultBackColor{
216                         get     {return SystemColors.Control;}
217                 }
218                 [MonoTODO] 
219                 public static Font DefaultFont{
220                         //get{ return new Font (FontFamily.GenericSansSerif, 10.0); }
221                         get {throw new NotImplementedException(); }
222                 }
223                 public static Color DefaultForeColor{
224                         get     {return SystemColors.ControlText;}
225                 }
226                 [MonoTODO] 
227                 public virtual Rectangle DisplayRectangle{
228                         get{throw new NotImplementedException ();}
229                 }
230                 [MonoTODO] 
231                 public bool Disposing{
232                         get{return false;}
233                 }
234                 [MonoTODO]
235                 public virtual DockStyle Dock{
236                         get     {return dock;}
237                         set {dock = value;}
238                 }
239                 public bool Enabled{
240                         get     {return Widget.Sensitive;}
241                         set     {Widget.Sensitive = value;}
242                 }
243                 [MonoTODO] 
244                 public virtual bool Focused{
245                         get     {throw new NotImplementedException ();}
246                 }
247
248                 [MonoTODO] 
249                 public virtual Font Font{
250                         // TODO: implementar get.
251                         get     {return null;}
252                         set {this.Widget.ModifyFont (SWFGtkConv.Font (value));}
253                 }
254                 [MonoTODO]
255                 public virtual Color ForeColor{
256                         get{throw new NotImplementedException ();}
257                         set{this.Widget.ModifyFg (Gtk.StateType.Normal,  new Gdk.Color (value));}
258                 }
259
260                 [MonoTODO] 
261                 public IntPtr Handle{
262                         get{return IntPtr.Zero;}
263                 }
264                 public virtual bool HasChildren{
265                         get{return (Controls.Count > 0);}
266                 }
267                 public int Height{
268                         get     {return Size.Height;}
269                         set {
270                                 Size s = Size;
271                                 s.Height = value;
272                                 this.Size = s;
273                         }
274                 }
275                 [MonoTODO] 
276                 public ImeMode ImeMode{
277                         get{return ImeMode.Disable;}
278                         set{return;     }
279                 }
280                 [MonoTODO]
281                 public int Index{
282                         get{return index;}
283                         set{index = value;}
284                 }
285
286                 [MonoTODO] 
287                 public virtual bool InvokeRequired{
288                         get {return false;}
289                 }
290
291                 [MonoTODO] 
292                 public bool IsAccessible{
293                         get{return true;}
294                         set{return;     }
295                 }
296                 [MonoTODO] 
297                 public bool IsDisposed{
298                         get{return false;}
299                 }
300                 [MonoTODO] 
301                 public bool IsHandleCreated{
302                         get     {return true;}
303                 }
304
305                 public int Left{
306                         get{return Location.X;}
307                         set{
308                                 Point p = Location;
309                                 p.X = value;
310                                 this.Location = p;
311                         }
312                 }
313                 public Point Location{
314                         get{return location;}
315                         set{
316                                 location = value;
317                                 OnLocationChanged (EventArgs.Empty);                                            
318                         }
319                 }
320                 [MonoTODO] 
321                 public static Keys ModifierKeys{
322                         get{return Keys.None;}
323                 }
324                 [MonoTODO] 
325                 public static MouseButtons MouseButtons{
326                         get{return MouseButtons.None;}
327                 }
328                 [MonoTODO] 
329                 public static Point MousePosition{
330                         
331                         get{ return new Point (0, 0);}
332                 }
333                 public virtual string Name{
334                         get{return name;}
335                         set{
336                                 name = value;
337                                 Widget.Name = value;
338                         }
339                 }
340                 public virtual Control Parent{
341                         get{return parent;}
342                         set{
343                                 if (parent == value){
344                                         return;
345                                 }
346                                 if (parent != null){
347                                         parent.Controls.Remove (this);
348                                 }
349                                 if (value != null){
350                                         value.Controls.Add (this);
351                                 }
352                                 parent = value;
353                         }
354                 }
355                 public virtual String ProductName{
356                         get{return Application.ProductName;}
357                 }
358                 public virtual String ProductVersion{
359                         get{return Application.ProductVersion;}
360                 }
361                 [MonoTODO] 
362                 public virtual bool RecreatingHandle{
363                         get{return false;}
364                 }
365                 [MonoTODO] 
366                 public virtual Region Region{
367                         get{throw new NotImplementedException ();}
368                         set{}
369                 }
370                 public virtual int Right{
371                         get{ return Left + Width;}
372                 }
373                 [MonoTODO] 
374                 public virtual RightToLeft RightToLeft{
375                         get{return rightToLeft;}
376                         set{rightToLeft = value;}
377                 }
378
379                 public virtual Size Size{
380                         get{return size;}
381                         set{
382                                 size = value;                           
383                                 OnResize(EventArgs.Empty);
384                                 Widget.SetSizeRequest (value.Width, value.Height);
385                         }
386                 }
387                 [MonoTODO]
388                 public virtual int TabIndex{
389                         get{return tabindex;}
390                         set{tabindex = value;}
391                 }
392                 [MonoTODO]
393                 public virtual bool TabStop{
394                         get{return tabStop;}
395                         set{tabStop = value;}
396                 }
397                 [MonoTODO]
398                 public virtual int Tag{
399                         get{return tag;}
400                         set{tag = value;}
401                 }
402                 public virtual string Text{
403                         get{return text;}
404                         set{
405                                 text = value;
406                                 OnTextChanged (EventArgs.Empty);
407                         }
408                 }
409                 public virtual int Top{
410                         get{return location.Y;}
411                         set{
412                                 Point p = this.Location;
413                                 p.Y = value;
414                                 this.Location = p;
415                         }
416                 }
417                 [MonoTODO]
418                 public virtual Control TopLevelControl{
419                         get{
420                                 Control c = this;
421                                 while (c.Parent != null){
422                                         c = c.Parent;
423                                 }
424                                 return c;
425                         }
426                 }
427                 public virtual bool Visible{
428                         get{return Widget.Visible;}
429                         set{Widget.Visible = value;}
430                 }
431
432                 public virtual int Width{
433                         get     {return Size.Width;}
434                         set     {
435                                 Size s = this.Size;
436                                 s.Width = value;
437                                 this.Size = s;
438                         }
439                 }
440
441                 // Protected properties
442
443                 [MonoTODO] 
444                 protected virtual CreateParams CreateParams{
445                         get{return null;}
446                 }
447                 [MonoTODO] 
448                 protected virtual ImeMode DefaultImeMode{
449                         get     {return ImeMode.Inherit;}
450                 }
451
452                 protected virtual Size DefaultSize{
453                         get     {return new Size (100, 100);}
454                 }
455                 [MonoTODO] 
456                 protected virtual int FontHeight{
457                         get     {throw new NotImplementedException ();}
458                         set {}
459                 }
460                 [MonoTODO] 
461                 protected virtual bool ResizeRedraw{
462                         get{throw new NotImplementedException ();}
463                         set{}
464                 }
465                 [MonoTODO] 
466                 protected virtual bool ShowFocusCues{
467                         get{return false;}
468                 }
469                 [MonoTODO] 
470                 protected virtual bool ShowKeyboardCues{
471                         get{return false;}
472                 }
473
474
475                 // Metodos 
476
477                 [MonoTODO]
478                 protected void  AccessibilityNotifyClients (AccessibleEvents accEvent,  int childID){
479                 }
480                 [MonoTODO]
481                 public virtual IAsyncResult BeginInvoke (Delegate method){
482                         return null;
483                 }
484                 [MonoTODO]
485                 public virtual IAsyncResult BeginInvoke (Delegate method, object[]args){
486                         return null;
487                 }
488
489                 [MonoTODO] 
490                 public virtual void BringToFront (){
491                 }
492                 public virtual bool Contains (Control c){
493                         foreach (Control control in Controls){
494                                 if  ( (control == c)  || control.Contains(c))
495                                         return true;
496                         }
497                         return false;
498                 }
499                 [MonoTODO]
500                 protected virtual AccessibleObject      CreateAccessibilityInstance (){
501                         throw new NotImplementedException ();
502                 }
503                 [MonoTODO] 
504                 public virtual void CreateControl (){
505                 }
506                 [MonoTODO]
507                 protected virtual ControlCollection     CreateControlsInstance (){
508                         return new ControlCollection (this);                    
509                 }
510                 [MonoTODO] 
511                 public virtual Graphics CreateGraphics (){
512                         throw new NotImplementedException ();
513                 }
514                 [MonoTODO] 
515                 protected virtual void CreateHandle (){
516                 }
517                 [MonoTODO] 
518                 protected virtual void DefWndProc (Message m){
519                 }
520                 [MonoTODO] 
521                 protected virtual void DestroyHandle (){
522                 }
523                 [MonoTODO] 
524                 protected override void Dispose (bool disposing){
525                         base.Dispose (disposing);
526                 }
527                 [MonoTODO]
528                 public DragDropEffects DoDragDrop (object data, DragDropEffects allowedEffects){
529                         throw new NotImplementedException ();
530                 }
531                 [MonoTODO]
532                 public virtual object EndInvoke (IAsyncResult asyncResult){
533                         throw new NotImplementedException ();
534                 }
535                 [MonoTODO] 
536                 public virtual Form FindForm (){
537                         return null;
538                 }
539                 [MonoTODO] 
540                 public virtual bool Focus (){
541                         return false;
542                 }
543                 [MonoTODO] 
544                 public static Control FromHandle (IntPtr handle){
545                         return null;
546                 }
547
548                 [MonoTODO]
549                 public static Control FromChildHandle (IntPtr handle){
550                         return null;
551                 }
552                 [MonoTODO] 
553                 public virtual Control GetChildAtPoint (Point pt){
554                         return null;
555                 }
556                 [MonoTODO]
557                 public virtual IContainerControl GetContainerControl (){
558                         throw new NotImplementedException ();
559                 }
560                 [MonoTODO]
561                 public virtual Control GetNextControl (Control ctl, bool forward){
562                         return null;
563                 }
564                 [MonoTODO]
565                 protected virtual bool GetStyle (ControlStyles flag){
566                         return true;
567                 }
568                 [MonoTODO] 
569                 protected virtual bool GetTopLevel (){
570                         throw new NotImplementedException ();
571                 }
572                 public void Hide (){
573                         Widget.Hide ();
574                 }
575                 [MonoTODO] 
576                 protected virtual void InitLayout (){
577                 }
578                 [MonoTODO] 
579                 public virtual void Invalidate (){
580                 }
581                 [MonoTODO]
582                 public virtual void Invalidate (bool invalidateChildren){
583                 }
584                 [MonoTODO] 
585                 public virtual void Invalidate (Rectangle rc){
586                 }
587                 [MonoTODO] 
588                 public virtual void Invalidate (Region region){
589                 }
590                 [MonoTODO]
591                 public virtual void Invalidate (Rectangle rc, bool invalidateChildren)
592                 {
593                 }
594                 [MonoTODO]
595                 public virtual void Invalidate (Region region,bool      invalidateChildren){
596                 }
597                 [MonoTODO] 
598                 public virtual object Invoke (Delegate method){
599                         return null;
600                 }
601                 [MonoTODO]
602                 public virtual object Invoke (Delegate method, object[]args){
603                         return null;
604                 }
605                 [MonoTODO]
606                 protected virtual void InvokeGotFocus (Control toInvoke, EventArgs e){
607                 }
608                 [MonoTODO]
609                 protected virtual void InvokeLostFocus (Control toInvoke, EventArgs e){
610                 }
611                 [MonoTODO]
612                 protected virtual void InvokeOnClick (Control toInvoke, EventArgs e){
613                 }
614                 [MonoTODO]
615                 protected virtual void InvokePaint (Control c, PaintEventArgs e){
616                 }
617                 [MonoTODO]
618                 protected virtual void InvokePaintBackground (Control c, PaintEventArgs e){
619                 }
620                 [MonoTODO] 
621                 protected virtual bool IsInputChar (char charCode){
622                         return true;
623                 }
624
625                 [MonoTODO] 
626                 protected virtual bool IsInputKey (Keys keyData){
627                         return false;
628                 }
629
630                 public static bool IsMnemonic (char charCode, string text){
631                         if (text == null)
632                                 return false;
633                         return text.IndexOf ("&" + charCode) > 0;
634                 }
635
636                 [MonoTODO]
637                 protected virtual void NotifyInvalidate (Rectangle invalidatedArea){
638                 }
639                 protected virtual void OnBackColorChanged (EventArgs e){
640                         if (BackColorChanged != null)
641                                 BackColorChanged (this, e);
642                         foreach (Control ctl in Controls){
643                                 ctl.OnParentBackColorChanged (e);
644                         }
645                 }
646
647                 protected virtual void OnBackgroundImageChanged (EventArgs e){
648                         if (BackgroundImageChanged != null)
649                                 BackgroundImageChanged (this, e);
650                 }
651
652                 protected virtual void OnBindingContextChanged (EventArgs e){
653                         if (BindingContextChanged != null)
654                                 BindingContextChanged (this, e);
655                 }
656
657                 protected virtual void OnCausesValidationChanged (EventArgs e){
658                         if (CausesValidationChanged != null)
659                                 CausesValidationChanged (this, e);
660                 }
661
662                 protected virtual void OnChangeUICues (UICuesEventArgs e){
663                         if (ChangeUICues != null)
664                                 ChangeUICues (this, e);
665                 }
666
667                 //Compact Framework
668                 protected virtual void OnClick (EventArgs e){
669                         if (Click != null)
670                                 Click (this, e);
671                 }
672
673
674                 protected virtual void OnContextMenuChanged (EventArgs e){
675                         if (ContextMenuChanged != null)
676                                 ContextMenuChanged (this, e);
677                 }
678                 protected virtual void OnControlAdded (ControlEventArgs e){
679                         e.Control.Visible = true;
680                         // If the control have another parent, remove it from the child list
681                         if (e.Control.parent != this){
682                                 e.Control.Parent = null;
683                         }
684                         
685                         e.Control.parent = this;
686                         
687                         if (ControlAdded != null)
688                                 ControlAdded (this, e);
689
690                         Point l = e.Control.Location;
691                         if (layout == null){
692                               Widget w = Widget;
693                         }
694                         layout.Put (e.Control.Widget, l.X, l.Y);
695                         //e.Control.LocationChanged +=
696                         //      new EventHandler (ControlLocationChanged);
697                 }
698
699                 protected virtual void OnControlRemoved (ControlEventArgs e){           
700                         if (layout != null){
701                                 layout.Remove (e.Control.Widget);
702                         }                       
703                         if (ControlRemoved != null)
704                                 ControlRemoved (this, e);
705                 }
706
707                 protected virtual void OnCreateControl (){
708                 }
709
710                 protected virtual void OnCursorChanged (EventArgs e){
711                         if (CursorChanged != null)
712                                 CursorChanged (this, e);
713                 }
714
715                 protected virtual void OnDockChanged (EventArgs e){
716                         // changing this property does not affect the control directly
717                         // so have its parent to calculate new layout
718                         if (Parent != null)
719                                 Parent.PerformLayout (this, "Dock");
720                         if (DockChanged != null)
721                                 DockChanged (this, e);
722                 }
723
724                 protected virtual void OnDoubleClick (EventArgs e){
725                         if (DoubleClick != null)
726                                 DoubleClick (this, e);
727                 }
728
729                 protected virtual void OnDragDrop (DragEventArgs drgevent){
730                         if (DragDrop != null)
731                                 DragDrop (this, drgevent);
732                 }
733
734                 protected virtual void OnDragEnter (DragEventArgs drgevent){
735                         if (DragEnter != null)
736                                 DragEnter (this, drgevent);
737                 }
738
739                 protected virtual void OnDragLeave (EventArgs e){
740                         if (DragLeave != null)
741                                 DragLeave (this, e);
742                 }
743
744                 protected virtual void OnDragOver (DragEventArgs drgevent){
745                         if (DragOver != null)
746                                 DragOver (this, drgevent);
747                 }
748
749                 //Compact Framework
750                 protected virtual void OnEnabledChanged (EventArgs e){
751                         if (EnabledChanged != null)
752                                 EnabledChanged (this, e);
753                 }
754
755                 protected virtual void OnEnter (EventArgs e){
756                         if (Enter != null)
757                                 Enter (this, e);
758                 }
759
760                 protected virtual void OnFontChanged (EventArgs e){
761                         if (FontChanged != null)
762                                 FontChanged (this, e);
763                 }
764
765                 protected virtual void OnForeColorChanged (EventArgs e){
766                         if (ForeColorChanged != null)
767                                 ForeColorChanged (this, e);
768                 }
769
770                 protected virtual void OnGiveFeedback (GiveFeedbackEventArgs  gfbevent){
771                         if (GiveFeedback != null)
772                                 GiveFeedback (this, gfbevent);
773                 }
774
775                 //Compact Framework
776                 protected virtual void OnGotFocus (EventArgs e){
777                         if (GotFocus != null)
778                                 GotFocus (this, e);
779                 }
780
781                 protected virtual void OnHandleCreated (EventArgs e){
782                 }
783
784                 protected virtual void OnHandleDestroyed (EventArgs e){
785                 }
786
787                 protected virtual void OnHelpRequested (HelpEventArgs hevent){
788                         if (HelpRequested != null)
789                                 HelpRequested (this, hevent);
790                 }
791
792                 protected virtual void OnImeModeChanged (EventArgs e){
793                         if (ImeModeChanged != null)
794                                 ImeModeChanged (this, e);
795                 }
796
797                 protected virtual void OnInvalidated (InvalidateEventArgs e){
798                         if (Invalidated != null)
799                                 Invalidated (this, e);
800                 }
801
802                 //Compact Framework
803                 protected virtual void OnKeyDown (KeyEventArgs e){
804                         if (KeyDown != null)
805                                 KeyDown (this, e);
806                 }
807
808                 //Compact Framework
809                 protected virtual void OnKeyPress (KeyPressEventArgs e){
810                         if (KeyPress != null)
811                                 KeyPress (this, e);
812                 }
813
814                 //Compact Framework
815                 protected virtual void OnKeyUp (KeyEventArgs e){
816                         if (KeyUp != null)
817                                 KeyUp (this, e);
818
819                 }
820
821                 protected virtual void OnLayout (LayoutEventArgs levent){
822                          if (Layout != null)
823                                 Layout (this, levent);
824                 }
825
826                 protected virtual void OnLeave (EventArgs e){
827                         if (Leave != null)
828                                 Leave (this, e);
829                 }
830
831                 protected virtual void OnLocationChanged (EventArgs e){
832                         if ((Parent != null) && (Parent.layout != null)){
833                                 Parent.layout.Move (Widget, Location.X, Location.Y);
834                         }
835                         if (LocationChanged != null)
836                                 LocationChanged (this, e);
837                 }
838                 //Compact Framework
839                 protected virtual void OnLostFocus (EventArgs e){
840                         if (LostFocus != null)
841                                 LostFocus (this, e);
842                 }
843                 //Compact Framework
844                 protected virtual void OnMouseDown (MouseEventArgs e){
845                         if (MouseDown != null)
846                                 MouseDown (this, e);
847                 }
848
849                 protected virtual void OnMouseEnter (EventArgs e){
850                         if (MouseEnter != null)
851                                 MouseEnter (this, e);
852                 }
853
854                 protected virtual void OnMouseHover (EventArgs e){
855                         if (MouseHover != null)
856                                 MouseHover (this, e);
857                 }
858
859                 protected virtual void OnMouseLeave (EventArgs e){              
860                         if (MouseLeave != null)
861                                 MouseLeave (this, e);
862                 }
863
864                 //Compact Framework
865                 protected virtual void OnMouseMove (MouseEventArgs e){
866                         if (MouseMove != null)
867                                 MouseMove (this, e);
868                 }
869
870                 //Compact Framework
871                 protected virtual void OnMouseUp (MouseEventArgs e){
872                         if (MouseUp != null)
873                                 MouseUp (this, e);
874                 }
875
876                 protected virtual void OnMouseWheel (MouseEventArgs e){
877                         if (MouseWheel != null)
878                                 MouseWheel (this, e);
879                 }
880
881                 protected virtual void OnMove (EventArgs e){
882                         if (Move != null)
883                                 Move (this, e);
884                 }
885
886                 protected virtual void OnNotifyMessage (Message m){
887                         //FIXME:
888                 }
889
890                 //Compact Framework
891                 protected virtual void OnPaint (PaintEventArgs e){
892                         if (Paint != null)
893                                 Paint (this, e);
894                 }
895
896                 //
897                 //Compact Framework
898                 protected virtual void OnPaintBackground (PaintEventArgs  pevent){
899                         if (GetStyle (ControlStyles.UserPaint)) {
900                                 Brush br = new SolidBrush (BackColor);
901                                 pevent.Graphics.FillRectangle (br,
902                                                                pevent.
903                                                                ClipRectangle);
904                                 br.Dispose ();
905                         }
906                 }
907
908                 protected virtual void OnParentBackColorChanged (EventArgs e){
909                         BackColor = Parent.BackColor;
910                         // FIXME: setting BackColor fires the BackColorChanged event,
911                         // so we do not need to call this here
912                         /*
913                          * if (BackColorChanged != null)
914                          * BackColorChanged (this, e);
915                          */
916                          if (BackColorChanged != null)
917                                 BackColorChanged (this, e);
918                 }
919                 protected virtual void OnParentBackgroundImageChanged (EventArgs e){
920                         if (BackgroundImageChanged != null)
921                                 BackgroundImageChanged (this, e);
922                 }
923                 protected virtual void OnParentBindingContextChanged (EventArgs e){
924                         if (BindingContextChanged != null)
925                                 BindingContextChanged (this, e);
926                 }
927                 //Compact Framework
928                 protected virtual void OnParentChanged (EventArgs e){
929                         if (ParentChanged != null)
930                                 ParentChanged (this, e);
931                 }
932                 protected virtual void OnParentEnabledChanged (EventArgs e){
933                         if (EnabledChanged != null)
934                                 EnabledChanged (this, e);
935                 }
936                 protected virtual void OnParentFontChanged (EventArgs e){
937                         if (FontChanged != null)
938                                 FontChanged (this, e);
939                 }
940                 protected virtual void OnParentForeColorChanged (EventArgs e){
941                         if (ForeColorChanged != null)
942                                 ForeColorChanged (this, e);
943                 }
944                 protected virtual void OnParentRightToLeftChanged (EventArgs e){
945                         if (RightToLeftChanged != null)
946                                 RightToLeftChanged (this, e);
947                 }
948                 protected virtual void OnParentVisibleChanged (EventArgs e){
949                         if (VisibleChanged != null)
950                                 VisibleChanged (this, e);
951                 }
952                 protected virtual void OnQueryContinueDrag (QueryContinueDragEventArgs qcdevent){
953                         if (QueryContinueDrag != null)
954                                 QueryContinueDrag (this, qcdevent);
955                 }
956                 //Compact Framework
957                 protected virtual void OnResize (EventArgs e){
958                         if (Resize != null)
959                                 Resize (this, e);
960                         PerformLayout (this, "Bounds");
961                 }
962                 protected virtual void OnRightToLeftChanged (EventArgs e){
963                         if (RightToLeftChanged != null)
964                                 RightToLeftChanged (this, e);
965                 }
966                 protected virtual void OnSizeChanged (EventArgs e){
967                         OnResize (e);
968                         if (SizeChanged != null)
969                                 SizeChanged (this, e);
970                 }
971                 protected virtual void OnStyleChanged (EventArgs e){
972                         if (StyleChanged != null)
973                                 StyleChanged (this, e);
974                 }
975                 protected virtual void OnSystemColorsChanged (EventArgs e){
976                         if (SystemColorsChanged != null)
977                                 SystemColorsChanged (this, e);
978                 }
979
980                 protected virtual void OnTabIndexChanged (EventArgs e){
981                         if (TabIndexChanged != null)
982                                 TabIndexChanged (this, e);
983                 }
984                 protected virtual void OnTabStopChanged (EventArgs e){
985                         if (TabStopChanged != null)
986                                 TabStopChanged (this, e);
987                 }
988                 //Compact Framework
989                 protected virtual void OnTextChanged (EventArgs e){
990                         if (TextChanged != null)
991                                 TextChanged (this, e);
992                 }
993                 //[MonoTODO] // this doesn't seem to be documented
994                 //              protected virtual void OnTextAlignChanged (EventArgs e) {
995                 //                      TextAlignChanged (this, e);
996                 //              }
997
998                 protected virtual void OnValidated (EventArgs e){
999                         if (Validated != null)
1000                                 Validated (this, e);
1001                 }
1002                 [MonoTODO]
1003                 protected virtual void OnValidating (CancelEventArgs e) {
1004                         throw new NotImplementedException ();
1005                 }
1006                 [MonoTODO]
1007                 protected virtual void OnVisibleChanged (EventArgs e){
1008                         if (VisibleChanged != null)
1009                                 VisibleChanged (this, e);
1010                         PerformLayout ();
1011                 }
1012                 [MonoTODO] 
1013                 public virtual void PerformLayout (){
1014                 }
1015                 [MonoTODO]
1016                 public virtual void PerformLayout (Control affectedControl,
1017                                                            string affectedProperty){
1018                 }
1019                 [MonoTODO] 
1020                 public virtual Point PointToClient (Point p){
1021                         throw new NotImplementedException ();
1022                 }
1023                 [MonoTODO] 
1024                 public virtual Point PointToScreen (Point p){
1025                         throw new NotImplementedException ();
1026                 }
1027                 [MonoTODO]
1028                 public virtual bool PreProcessMessage (ref Message msg){
1029                         throw new NotImplementedException ();
1030                 }
1031                 [MonoTODO]
1032                 protected virtual bool ProcessCmdKey (ref Message msg, Keys keyData){
1033                         throw new NotImplementedException ();
1034                 }
1035                 [MonoTODO]
1036                 protected virtual bool ProcessDialogChar (char charCode){
1037                         throw new NotImplementedException ();
1038                 }
1039                 [MonoTODO]
1040                 protected virtual bool ProcessDialogKey (Keys keyData){
1041                         throw new NotImplementedException ();
1042                 }
1043                 [MonoTODO]
1044                 protected virtual bool ProcessKeyEventArgs (ref Message m){
1045                         throw new NotImplementedException ();
1046                 }
1047                 [MonoTODO]
1048                 protected virtual bool ProcessKeyMessage (ref Message  m){
1049                         throw new NotImplementedException ();
1050                 }
1051                 [MonoTODO]
1052                 protected virtual bool ProcessKeyPreview (ref Message m){
1053                         throw new NotImplementedException ();
1054                 }
1055
1056                 [MonoTODO]
1057                 protected virtual bool ProcessMnemonic (char charCode){
1058                         throw new NotImplementedException ();
1059                 }
1060                 [MonoTODO]
1061                 protected virtual void RaiseDragEvent (object key, DragEventArgs e){
1062                 }
1063                 [MonoTODO]
1064                 protected virtual void RaiseKeyEvent (object key, KeyEventArgs e){
1065                 }
1066                 [MonoTODO]
1067                 protected virtual void RaiseMouseEvent (object key, MouseEventArgs e){
1068                 }
1069                 [MonoTODO]
1070                 protected virtual void RaisePaintEvent (object key,     PaintEventArgs e){
1071                 }
1072                 [MonoTODO] 
1073                 protected virtual void RecreateHandle (){
1074                 }
1075                 [MonoTODO]
1076                 public virtual Rectangle RectangleToClient (Rectangle r){
1077                         throw new NotImplementedException ();
1078                 }
1079                 [MonoTODO]
1080                 public virtual Rectangle RectangleToScreen (Rectangle r){
1081                         throw new NotImplementedException ();
1082                 }
1083                 [MonoTODO]
1084                 protected static bool ReflectMessage (IntPtr hWnd,ref Message m){
1085                         //throw new NotImplementedException ();
1086                         return false;
1087                 }
1088                 [MonoTODO] 
1089                 public virtual void Refresh (){
1090                 }
1091                 [MonoTODO] 
1092                 public virtual void ResetBackColor (){
1093                 }
1094                 [MonoTODO] 
1095                 public virtual void ResetBindings (){
1096                 }
1097                 [MonoTODO] 
1098                 public virtual void ResetCursor (){
1099                 }
1100                 [MonoTODO] 
1101                 public virtual void ResetFont (){
1102                 }
1103                 [MonoTODO] 
1104                 public virtual void ResetForeColor (){
1105                 }
1106                 [MonoTODO] 
1107                 public virtual void ResetImeMode (){
1108                 }
1109                 [MonoTODO] 
1110                 protected virtual void ResetMouseEventArgs (){
1111                 }
1112                 [MonoTODO] 
1113                 public virtual void ResetRightToLeft (){
1114                 }
1115                 [MonoTODO] 
1116                 public virtual void ResetText (){
1117                 }
1118                 public virtual void ResumeLayout (){
1119                         this.ResumeLayout (true);
1120                 }
1121                 [MonoTODO]
1122                 public virtual void ResumeLayout (bool performLayout){
1123                 }
1124                 [MonoTODO]
1125                 protected virtual ContentAlignment
1126                         RtlTranslateAlignment (ContentAlignment align){
1127                         throw new NotImplementedException ();
1128                 }
1129                 [MonoTODO]
1130                 protected virtual HorizontalAlignment
1131                         RtlTranslateAlignment (HorizontalAlignment align){
1132                         throw new NotImplementedException ();
1133                 }
1134                 [MonoTODO]
1135                 protected virtual LeftRightAlignment
1136                         RtlTranslateAlignment (LeftRightAlignment align){
1137                         throw new NotImplementedException ();
1138                 }
1139                 [MonoTODO]
1140                 protected virtual ContentAlignment
1141                         RtlTranslateContent (ContentAlignment align){
1142                         throw new NotImplementedException ();
1143                 }
1144                 [MonoTODO]
1145                         protected virtual HorizontalAlignment
1146                         RtlTranslateHorizontal (HorizontalAlignment align){
1147                         throw new NotImplementedException ();
1148                 }
1149                 [MonoTODO]
1150                 protected virtual LeftRightAlignment
1151                         RtlTranslateLeftRight (LeftRightAlignment align){
1152                         throw new NotImplementedException ();
1153                 }
1154                 public virtual void Scale (float ratio){
1155                         ScaleCore (ratio, ratio);
1156                 }
1157                 public virtual void Scale (float dx, float dy){
1158                         ScaleCore (dx, dy);
1159                 }
1160                 [MonoTODO]
1161                 protected virtual void ScaleCore (float dx, float dy){
1162                 }
1163                 [MonoTODO] 
1164                 public virtual void Select (){
1165                 }
1166                 [MonoTODO]
1167                 protected virtual void Select (bool directed, bool forward){
1168                 }
1169                 [MonoTODO]
1170                 public virtual bool SelectNextControl (Control ct,
1171                                                                bool forward,
1172                                                                bool
1173                                                                tabStopOnly,
1174                                                                bool nested,
1175                                                                bool wrap)
1176                 {
1177                         throw new NotImplementedException ();
1178                 }
1179                 [MonoTODO] 
1180                 public virtual void SendToBack (){
1181                 }
1182                 [MonoTODO]
1183                 public virtual void SetBounds (int x, int y,int width, int height){
1184                 }
1185                 [MonoTODO]
1186                 public virtual void SetBounds (int x, int y,
1187                                                        int width, int height,
1188                                                        BoundsSpecified
1189                                                        specified)
1190                 {
1191                 }
1192                 [MonoTODO]
1193                 protected virtual void SetBoundsCore (int x, int y,
1194                                                               int width,
1195                                                               int height,
1196                                                               BoundsSpecified
1197                                                               specified)
1198                 {
1199                 }
1200                 [MonoTODO]
1201                 protected virtual void SetClientSizeCore (int x, int y){
1202                 }
1203                 [MonoTODO]
1204                 protected virtual void SetStyle (ControlStyles flag, bool value){
1205                 }
1206                 [MonoTODO] 
1207                 protected virtual void SetTopLevel (bool value){
1208                 }
1209                 [MonoTODO] 
1210                 protected virtual void SetVisibleCore (bool value){
1211                 }
1212                 public void Show (){
1213                         Widget.Show ();
1214                 }
1215                 [MonoTODO] 
1216                 public virtual void SuspendLayout (){
1217                 }
1218                 [MonoTODO] 
1219                 public virtual void Update (){
1220                 }
1221                 protected void UpdateBounds (){
1222                 }
1223                 protected virtual void UpdateBounds (int x, int y, int width, int height){
1224                 }
1225                 protected virtual void UpdateBounds (int x, int y, int width,
1226                                                      int height,
1227                                                      int clientWidth,
1228                                                      int clientHeight)
1229                 {
1230
1231                 }
1232                 protected virtual void UpdateStyles (){
1233                 }
1234                 protected virtual void UpdateZOrder (){
1235                 }
1236                 protected virtual void WndProc (ref Message m){
1237                 }
1238
1239
1240                 // Events
1241
1242                 public event EventHandler BackColorChanged;
1243                 public event EventHandler BackgroundImageChanged;
1244                 public event EventHandler BindingContextChanged;
1245                 public event EventHandler CausesValidationChanged;
1246                 public event UICuesEventHandler ChangeUICues;
1247
1248                 //Compact Framework
1249                 public event EventHandler Click;
1250
1251                 public event EventHandler ContextMenuChanged;
1252                 public event ControlEventHandler ControlAdded;
1253                 public event ControlEventHandler ControlRemoved;
1254                 public event EventHandler CursorChanged;
1255                 public event EventHandler DockChanged;
1256                 public event EventHandler DoubleClick;
1257                 public event DragEventHandler DragDrop;
1258                 public event DragEventHandler DragEnter;
1259                 public event EventHandler DragLeave;
1260                 public event DragEventHandler DragOver;
1261
1262                 //Compact Framework
1263                 public event EventHandler EnabledChanged;
1264
1265                 public event EventHandler Enter;
1266                 public event EventHandler FontChanged;
1267                 public event EventHandler ForeColorChanged;
1268                 public event GiveFeedbackEventHandler GiveFeedback;
1269
1270                 //Compact Framework
1271                 public event EventHandler GotFocus;
1272
1273                 public event EventHandler HandleCreated;
1274                 public event EventHandler HandleDestroyed;
1275                 public event HelpEventHandler HelpRequested;
1276                 public event EventHandler ImeModeChanged;
1277                 public event InvalidateEventHandler Invalidated;
1278
1279                 //Compact Framework
1280                 public event KeyEventHandler KeyDown;
1281
1282                 //Compact Framework
1283                 public event KeyPressEventHandler KeyPress;
1284
1285                 //Compact Framework
1286                 public event KeyEventHandler KeyUp;
1287
1288                 public event LayoutEventHandler Layout;
1289                 public event EventHandler Leave;
1290                 public event EventHandler LocationChanged;
1291
1292                 //Compact Framework
1293                 public event EventHandler LostFocus;
1294
1295                 //Compact Framework
1296                 public event MouseEventHandler MouseDown;
1297
1298                 public event EventHandler MouseEnter;
1299                 public event EventHandler MouseHover;
1300                 public event EventHandler MouseLeave;
1301
1302                 //Compact Framework
1303                 public event MouseEventHandler MouseMove;
1304
1305                 //Compact Framework
1306                 public event MouseEventHandler MouseUp;
1307
1308                 public event MouseEventHandler MouseWheel;
1309                 public event EventHandler Move;
1310
1311                 //Compact Framework
1312                 public event PaintEventHandler Paint;
1313
1314                 //Compact Framework
1315                 public event EventHandler ParentChanged;
1316
1317                 public event QueryAccessibilityHelpEventHandler
1318                         QueryAccessibilityHelp;
1319                 public event QueryContinueDragEventHandler QueryContinueDrag;
1320
1321                 //Compact Framework
1322                 public event EventHandler Resize;
1323
1324                 public event EventHandler RightToLeftChanged;
1325                 public event EventHandler SizeChanged;
1326                 public event EventHandler StyleChanged;
1327                 public event EventHandler SystemColorsChanged;
1328                 public event EventHandler TabIndexChanged;
1329                 public event EventHandler TabStopChanged;
1330
1331                 //Compact Framework
1332                 public event EventHandler TextChanged;
1333
1334                 public event EventHandler Validated;
1335
1336                 public event CancelEventHandler Validating;
1337
1338                 public event EventHandler VisibleChanged;
1339
1340
1341
1342
1343
1344                 internal Widget Widget{
1345                         get{
1346                                 if (widget == null){
1347                                         widget = CreateWidget ();
1348                                         ConnectEvents();
1349                                 }                               
1350                                 return widget;
1351                         }
1352                 }
1353                 internal virtual Widget CreateWidget (){
1354                         vbox = new Gtk.VBox (false, 0);
1355                         layout = new Gtk.Layout (new Gtk.Adjustment (0, 0, 1, .1, .1,.1),
1356                                                  new Gtk.Adjustment (0, 0, 1,.1, .1, .1));
1357                         vbox.PackStart (layout, true, true, 0);
1358                         vbox.ShowAll ();
1359                         return vbox;
1360                 }
1361                 
1362                 internal virtual void ConnectEvents(){
1363                         Widget w = Widget;
1364                         
1365                         w.EnterNotifyEvent += new GtkSharp.EnterNotifyEventHandler(this.GtkMouseEnter);
1366                         w.LeaveNotifyEvent += new GtkSharp.LeaveNotifyEventHandler(this.GtkMouseLeave);
1367                         w.ButtonPressEvent += new GtkSharp.ButtonPressEventHandler(this.GtkButtonPress);
1368                         w.ButtonReleaseEvent += new GtkSharp.ButtonReleaseEventHandler(this.GtkButtonRelease);
1369                         
1370                         this.Resize += new EventHandler (this.GtkResize);
1371                 }
1372                 internal void GtkResize (object o, EventArgs args){
1373                         Widget.SetSizeRequest (Size.Width, Size.Height);
1374                 }
1375                 [MonoTODO]
1376                 internal void GtkButtonPress(object o, ButtonPressEventArgs args){                      
1377                         OnMouseDown (SWFGtkConv.MouseUpDownArgs(args.Event));
1378                 }
1379                 internal void GtkButtonRelease (object o, ButtonReleaseEventArgs args){
1380                         OnMouseUp (SWFGtkConv.MouseUpDownArgs(args.Event));
1381                 }
1382                 internal void GtkMouseEnter (object o, EnterNotifyEventArgs args){
1383                         OnMouseEnter ((EventArgs) args);
1384                 }
1385                 internal void GtkMouseLeave (object o, LeaveNotifyEventArgs args){
1386                         OnMouseLeave ((EventArgs) args);
1387                 }
1388
1389                 public class ControlCollection:IList, ICollection,IEnumerable, ICloneable{
1390                         ArrayList list = new ArrayList ();
1391                         protected Control owner;
1392
1393                         public ControlCollection (Control owner){
1394                                 this.owner = owner;
1395                         }
1396
1397                         private ControlCollection (){
1398                         }
1399
1400                         // ControlCollection
1401                         //
1402                         // TODO Revisar como implementar esto.
1403                         // 
1404                         public virtual void Add (Control value){
1405                                 list.Add (value);
1406                                 owner.OnControlAdded (new ControlEventArgs (value));
1407                                 //list.Add (value);
1408                                 //owner.OnControlAdded (new ControlEventArgs (value));
1409
1410
1411                                 //if (this.owner.GetType () ==
1412                                 //    typeof (System.Windows.Forms.Button))
1413                                 //{     
1414                                         // This makes Gtk throw a warning about a label already being added
1415                                         // This is actually support that Gtk just does not have :(
1416                                         // Should we reinvent the Button-object for that? (Inherit from Gtk.Container
1417                                         // and implement our own OnClicked handlers and stuff like that)
1418
1419                                         // Or .. we remove the label and replace it with a Container which
1420                                         // we fill with the added Controls .. (question: how do I remove the
1421                                         // label and/or get the Gtk.Widget inside the button ?)
1422                                         //
1423                                         // Phillip : I added in the code, but you will have to do do the
1424                                         // positioning stuff. You understand that better than me :-)
1425                                         // The Controls property has to be overriden in the base class
1426                                         // (ie Button.cs) now
1427                                         // if you want to be able to add controls to a control
1428                                         //
1429                                         // We will also have to to create a way to add widgets to a
1430                                         // GroupBox 
1431
1432                                         //Gtk.Button gtkbutton =(Gtk.Button) this.owner.widget;
1433                                         // ?
1434                                         //GLib.List mylist =new GLib.List ((IntPtr) 0,
1435                                         //                     typeof (Gtk.Widget));
1436                                         //mylist = gtkbutton.Children;
1437                                         //foreach (Gtk.Widget awidget in mylist)
1438                                         //{
1439                                         //      gtkbutton.Remove (awidget);
1440                                         //}
1441                                         //gtkbutton.Add (value.widget);
1442                                         //gtkbutton.ShowAll ();
1443                                         //list.Add (value);
1444                                 //}
1445                                 //else if (value.GetType () == typeof (System.Windows.Forms.StatusBar))
1446                                 //{
1447                                         // SWF on Windows adds above the last added StatusBar
1448                                         // I think that this adds below the last one ..
1449                                         // So a reorderchild operation might be required here..
1450                                         //this.owner.vbox.PackEnd (value.widget, false, false, 0);
1451                                         // this.vbox.ReorderChild (value.widget, 0);
1452                                         //this.owner.vbox.ShowAll ();
1453                                         //list.Add (value);
1454                                 //}
1455                                 
1456                                 // TODO System.Windows.Forms.ToolBar
1457                                 // But we don't have this type yet :-)
1458                                 //else
1459                                 //{
1460                                 //      list.Add (value);
1461                                 //      owner.OnControlAdded (new ControlEventArgs (value));
1462                                 //}
1463                         }
1464                         public virtual void AddRange (Control[] controls){
1465                                 // Because we really do have to check for a few
1466                                 // special cases we cannot use the AddRange and
1467                                 // will have to check each Control that we add
1468
1469                                 // list.AddRange (controls);
1470                                 foreach (Control c in controls){
1471                                         this.Add (c);
1472                                 }
1473                                 // owner.OnControlAdded (new ControlEventArgs (c));
1474                         }
1475
1476                         public bool Contains (Control value){
1477                                 return list.Contains (value);
1478                         }
1479                         public virtual void Remove (Control value){
1480                                 list.Remove (value);
1481                                 owner.OnControlRemoved (new ControlEventArgs (value));
1482                         }
1483                         public virtual Control this[int index]{
1484                                 get{return (Control) list[index];}
1485                         }
1486                         public int GetChildIndex (Control child){
1487                                 return GetChildIndex (child, true);
1488                         }
1489                         public int GetChildIndex (Control child, bool throwException){
1490                                 if (throwException && !Contains (child))
1491                                         throw new Exception ();
1492                                 return list.IndexOf (child);
1493                         }
1494                         public int IndexOf (Control value){
1495                                 return list.IndexOf (value);
1496                         }
1497                         public void SetChildIndex (Control child, int newIndex){
1498                                 int oldIndex = GetChildIndex (child);
1499                                 if (oldIndex == newIndex)
1500                                         return;
1501                                 // is this correct behavior?
1502                                 Control other = (Control) list[newIndex];
1503                                 list[oldIndex] = other;
1504                                 list[newIndex] = child;
1505                         }
1506
1507                         // IList
1508                         public bool IsFixedSize{
1509                                 get{return list.IsFixedSize;}
1510                         }
1511                         public bool IsReadOnly{
1512                                 get     {return list.IsReadOnly;}
1513                         }
1514                         int IList.Add (object value){
1515                                 return list.Add (value);
1516                         }
1517                         public virtual void Clear (){
1518                                 list.Clear ();
1519                         }
1520                         bool IList.Contains (object value){
1521                                 return list.Contains (value);
1522                         }
1523                         int IList.IndexOf (object value){
1524                                 return list.IndexOf (value);
1525                         }
1526                         void IList.Insert (int index, object value){
1527                                 list.Insert (index, value);
1528                         }
1529                         void IList.Remove (object value){
1530                                 list.Remove (value);
1531                         }
1532                         public void RemoveAt (int index){
1533                                 list.RemoveAt (index);
1534                         }
1535
1536                         // ICollection
1537                         public int Count{
1538                                 get     {return list.Count;}
1539                         }
1540                         public bool IsSynchronized{
1541                                 get{return list.IsSynchronized; }
1542                         }
1543                         public object SyncRoot{
1544                                 get{return list.SyncRoot;}
1545                         }
1546                         public void CopyTo (Array array, int index){
1547                                 list.CopyTo (array, index);
1548                         }
1549
1550                         // IEnumerable
1551                         public IEnumerator GetEnumerator (){
1552                                 return list.GetEnumerator ();
1553                         }
1554
1555                         // ICloneable
1556                         public object Clone (){
1557                                 ControlCollection c =
1558                                         new ControlCollection ();
1559                                 c.list = (ArrayList) list.Clone ();
1560                                 c.owner = owner;
1561                                 return c;
1562                         }
1563
1564                         object IList.this[int index]{
1565                                 get{return list[index]; }
1566                                 set{list[index] = value;}
1567                         }
1568                 }
1569         }
1570 }