2 // System.Windows.Forms.Form
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
16 using System.ComponentModel;
17 using System.Collections;
19 namespace System.Windows.Forms{
20 public class Control:Component, ISynchronizeInvoke, IWin32Window{
22 private ControlCollection controls;
23 private Size clientSize;
24 private bool allowDrop = false;
25 private Control parent;
26 private string text, name;
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;
38 internal Widget widget;
39 internal Gtk.Layout layout = null;
40 internal Gtk.VBox vbox = null;
45 Gtk.Application.Init ();
48 public Control ():this (""){
51 public Control (string text):this (null, text){
54 public Control (Control parent, string text){
57 clientSize = DefaultSize;
61 public Control (string text, int left, int top, int width,int height){
62 clientSize = DefaultSize;
65 public Control (Control parent, string text, int left,
66 int top, int width, int height)
74 clientSize = DefaultSize;
78 public AccessibleObject AccessibilityObject{
82 public String AccessibleDefaultActionDescription{
87 public String AccessibleDescription{
93 public String AccessibleName{
98 public AccessibleRole AccessibleRole {
99 get {throw new NotImplementedException ();}
105 public virtual bool AllowDrop{
106 get{return allowDrop;}
107 set{allowDrop = value;}
110 public virtual AnchorStyles Anchor{
111 get {return anchor; }
112 set{anchor = value; }
116 public virtual Color BackColor{
117 get {throw new NotImplementedException ();}
120 Gdk.Color c = new Gdk.Color (value);
121 this.Widget.ModifyBg (Gtk.StateType.Normal, c);
125 public virtual System.Drawing.Image BackgroundImage{
126 get{throw new NotImplementedException ();}
129 //throw new NotImplementedException();
134 public virtual BindingContext BindingContext{
135 get{throw new NotImplementedException ();}
138 public virtual int Bottom{
139 get {return (Top + Height); }
142 public virtual Rectangle Bounds{
143 get {throw new NotImplementedException ();}
144 set {throw new NotImplementedException ();}
147 public virtual bool CanFocus{
148 get {throw new NotImplementedException ();}
151 public virtual bool CanSelect{
152 get {throw new NotImplementedException ();}
155 public virtual bool Capture{
156 get {throw new NotImplementedException (); }
157 set {throw new NotImplementedException ();}
161 public virtual bool CausesValidation{
166 public virtual Rectangle ClientRectangle {
167 get {throw new NotImplementedException (); }
171 public virtual Size ClientSize{
172 get{return clientSize;}
175 OnResize (EventArgs.Empty);
176 Widget.SetSizeRequest (value.Width, value.Height);
179 public virtual String CompanyName{
180 get{return Application.CompanyName;}
183 public virtual bool ContainsFocus{
184 get {throw new NotImplementedException ();}
188 public virtual ContextMenu ContextMenu{
189 get{return contextMenu;}
190 set{contextMenu = value;}
193 public virtual ControlCollection Controls{
195 if (controls == null)
196 controls = CreateControlsInstance();
202 public virtual bool Created{
206 public virtual Cursor Cursor{
207 get{throw new NotImplementedException ();}
212 public ControlBindingsCollection DataBindings{
213 get{throw new NotImplementedException ();}
215 public static Color DefaultBackColor{
216 get {return SystemColors.Control;}
219 public static Font DefaultFont{
220 //get{ return new Font (FontFamily.GenericSansSerif, 10.0); }
221 get {throw new NotImplementedException(); }
223 public static Color DefaultForeColor{
224 get {return SystemColors.ControlText;}
227 public virtual Rectangle DisplayRectangle{
228 get{throw new NotImplementedException ();}
231 public bool Disposing{
235 public virtual DockStyle Dock{
240 get {return Widget.Sensitive;}
241 set {Widget.Sensitive = value;}
244 public virtual bool Focused{
245 get {throw new NotImplementedException ();}
249 public virtual Font Font{
250 // TODO: implementar get.
252 set {this.Widget.ModifyFont (SWFGtkConv.Font (value));}
255 public virtual Color ForeColor{
256 get{throw new NotImplementedException ();}
257 set{this.Widget.ModifyFg (Gtk.StateType.Normal, new Gdk.Color (value));}
261 public IntPtr Handle{
262 get{return IntPtr.Zero;}
264 public virtual bool HasChildren{
265 get{return (Controls.Count > 0);}
268 get {return Size.Height;}
276 public ImeMode ImeMode{
277 get{return ImeMode.Disable;}
287 public virtual bool InvokeRequired{
292 public bool IsAccessible{
297 public bool IsDisposed{
301 public bool IsHandleCreated{
306 get{return Location.X;}
313 public Point Location{
314 get{return location;}
317 OnLocationChanged (EventArgs.Empty);
321 public static Keys ModifierKeys{
322 get{return Keys.None;}
325 public static MouseButtons MouseButtons{
326 get{return MouseButtons.None;}
329 public static Point MousePosition{
331 get{ return new Point (0, 0);}
333 public virtual string Name{
340 public virtual Control Parent{
343 if (parent == value){
347 parent.Controls.Remove (this);
350 value.Controls.Add (this);
355 public virtual String ProductName{
356 get{return Application.ProductName;}
358 public virtual String ProductVersion{
359 get{return Application.ProductVersion;}
362 public virtual bool RecreatingHandle{
366 public virtual Region Region{
367 get{throw new NotImplementedException ();}
370 public virtual int Right{
371 get{ return Left + Width;}
374 public virtual RightToLeft RightToLeft{
375 get{return rightToLeft;}
376 set{rightToLeft = value;}
379 public virtual Size Size{
383 OnResize(EventArgs.Empty);
384 Widget.SetSizeRequest (value.Width, value.Height);
388 public virtual int TabIndex{
389 get{return tabindex;}
390 set{tabindex = value;}
393 public virtual bool TabStop{
395 set{tabStop = value;}
398 public virtual int Tag{
402 public virtual string Text{
406 OnTextChanged (EventArgs.Empty);
409 public virtual int Top{
410 get{return location.Y;}
412 Point p = this.Location;
418 public virtual Control TopLevelControl{
421 while (c.Parent != null){
427 public virtual bool Visible{
428 get{return Widget.Visible;}
429 set{Widget.Visible = value;}
432 public virtual int Width{
433 get {return Size.Width;}
441 // Protected properties
444 protected virtual CreateParams CreateParams{
448 protected virtual ImeMode DefaultImeMode{
449 get {return ImeMode.Inherit;}
452 protected virtual Size DefaultSize{
453 get {return new Size (100, 100);}
456 protected virtual int FontHeight{
457 get {throw new NotImplementedException ();}
461 protected virtual bool ResizeRedraw{
462 get{throw new NotImplementedException ();}
466 protected virtual bool ShowFocusCues{
470 protected virtual bool ShowKeyboardCues{
478 protected void AccessibilityNotifyClients (AccessibleEvents accEvent, int childID){
481 public virtual IAsyncResult BeginInvoke (Delegate method){
485 public virtual IAsyncResult BeginInvoke (Delegate method, object[]args){
490 public virtual void BringToFront (){
492 public virtual bool Contains (Control c){
493 foreach (Control control in Controls){
494 if ( (control == c) || control.Contains(c))
500 protected virtual AccessibleObject CreateAccessibilityInstance (){
501 throw new NotImplementedException ();
504 public virtual void CreateControl (){
507 protected virtual ControlCollection CreateControlsInstance (){
508 return new ControlCollection (this);
511 public virtual Graphics CreateGraphics (){
512 throw new NotImplementedException ();
515 protected virtual void CreateHandle (){
518 protected virtual void DefWndProc (Message m){
521 protected virtual void DestroyHandle (){
524 protected override void Dispose (bool disposing){
525 base.Dispose (disposing);
528 public DragDropEffects DoDragDrop (object data, DragDropEffects allowedEffects){
529 throw new NotImplementedException ();
532 public virtual object EndInvoke (IAsyncResult asyncResult){
533 throw new NotImplementedException ();
536 public virtual Form FindForm (){
540 public virtual bool Focus (){
544 public static Control FromHandle (IntPtr handle){
549 public static Control FromChildHandle (IntPtr handle){
553 public virtual Control GetChildAtPoint (Point pt){
557 public virtual IContainerControl GetContainerControl (){
558 throw new NotImplementedException ();
561 public virtual Control GetNextControl (Control ctl, bool forward){
565 protected virtual bool GetStyle (ControlStyles flag){
569 protected virtual bool GetTopLevel (){
570 throw new NotImplementedException ();
576 protected virtual void InitLayout (){
579 public virtual void Invalidate (){
582 public virtual void Invalidate (bool invalidateChildren){
585 public virtual void Invalidate (Rectangle rc){
588 public virtual void Invalidate (Region region){
591 public virtual void Invalidate (Rectangle rc, bool invalidateChildren)
595 public virtual void Invalidate (Region region,bool invalidateChildren){
598 public virtual object Invoke (Delegate method){
602 public virtual object Invoke (Delegate method, object[]args){
606 protected virtual void InvokeGotFocus (Control toInvoke, EventArgs e){
609 protected virtual void InvokeLostFocus (Control toInvoke, EventArgs e){
612 protected virtual void InvokeOnClick (Control toInvoke, EventArgs e){
615 protected virtual void InvokePaint (Control c, PaintEventArgs e){
618 protected virtual void InvokePaintBackground (Control c, PaintEventArgs e){
621 protected virtual bool IsInputChar (char charCode){
626 protected virtual bool IsInputKey (Keys keyData){
630 public static bool IsMnemonic (char charCode, string text){
633 return text.IndexOf ("&" + charCode) > 0;
637 protected virtual void NotifyInvalidate (Rectangle invalidatedArea){
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);
647 protected virtual void OnBackgroundImageChanged (EventArgs e){
648 if (BackgroundImageChanged != null)
649 BackgroundImageChanged (this, e);
652 protected virtual void OnBindingContextChanged (EventArgs e){
653 if (BindingContextChanged != null)
654 BindingContextChanged (this, e);
657 protected virtual void OnCausesValidationChanged (EventArgs e){
658 if (CausesValidationChanged != null)
659 CausesValidationChanged (this, e);
662 protected virtual void OnChangeUICues (UICuesEventArgs e){
663 if (ChangeUICues != null)
664 ChangeUICues (this, e);
668 protected virtual void OnClick (EventArgs e){
674 protected virtual void OnContextMenuChanged (EventArgs e){
675 if (ContextMenuChanged != null)
676 ContextMenuChanged (this, e);
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;
685 e.Control.parent = this;
687 if (ControlAdded != null)
688 ControlAdded (this, e);
690 Point l = e.Control.Location;
694 layout.Put (e.Control.Widget, l.X, l.Y);
695 //e.Control.LocationChanged +=
696 // new EventHandler (ControlLocationChanged);
699 protected virtual void OnControlRemoved (ControlEventArgs e){
701 layout.Remove (e.Control.Widget);
703 if (ControlRemoved != null)
704 ControlRemoved (this, e);
707 protected virtual void OnCreateControl (){
710 protected virtual void OnCursorChanged (EventArgs e){
711 if (CursorChanged != null)
712 CursorChanged (this, e);
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
719 Parent.PerformLayout (this, "Dock");
720 if (DockChanged != null)
721 DockChanged (this, e);
724 protected virtual void OnDoubleClick (EventArgs e){
725 if (DoubleClick != null)
726 DoubleClick (this, e);
729 protected virtual void OnDragDrop (DragEventArgs drgevent){
730 if (DragDrop != null)
731 DragDrop (this, drgevent);
734 protected virtual void OnDragEnter (DragEventArgs drgevent){
735 if (DragEnter != null)
736 DragEnter (this, drgevent);
739 protected virtual void OnDragLeave (EventArgs e){
740 if (DragLeave != null)
744 protected virtual void OnDragOver (DragEventArgs drgevent){
745 if (DragOver != null)
746 DragOver (this, drgevent);
750 protected virtual void OnEnabledChanged (EventArgs e){
751 if (EnabledChanged != null)
752 EnabledChanged (this, e);
755 protected virtual void OnEnter (EventArgs e){
760 protected virtual void OnFontChanged (EventArgs e){
761 if (FontChanged != null)
762 FontChanged (this, e);
765 protected virtual void OnForeColorChanged (EventArgs e){
766 if (ForeColorChanged != null)
767 ForeColorChanged (this, e);
770 protected virtual void OnGiveFeedback (GiveFeedbackEventArgs gfbevent){
771 if (GiveFeedback != null)
772 GiveFeedback (this, gfbevent);
776 protected virtual void OnGotFocus (EventArgs e){
777 if (GotFocus != null)
781 protected virtual void OnHandleCreated (EventArgs e){
784 protected virtual void OnHandleDestroyed (EventArgs e){
787 protected virtual void OnHelpRequested (HelpEventArgs hevent){
788 if (HelpRequested != null)
789 HelpRequested (this, hevent);
792 protected virtual void OnImeModeChanged (EventArgs e){
793 if (ImeModeChanged != null)
794 ImeModeChanged (this, e);
797 protected virtual void OnInvalidated (InvalidateEventArgs e){
798 if (Invalidated != null)
799 Invalidated (this, e);
803 protected virtual void OnKeyDown (KeyEventArgs e){
809 protected virtual void OnKeyPress (KeyPressEventArgs e){
810 if (KeyPress != null)
815 protected virtual void OnKeyUp (KeyEventArgs e){
821 protected virtual void OnLayout (LayoutEventArgs levent){
823 Layout (this, levent);
826 protected virtual void OnLeave (EventArgs e){
831 protected virtual void OnLocationChanged (EventArgs e){
832 if ((Parent != null) && (Parent.layout != null)){
833 Parent.layout.Move (Widget, Location.X, Location.Y);
835 if (LocationChanged != null)
836 LocationChanged (this, e);
839 protected virtual void OnLostFocus (EventArgs e){
840 if (LostFocus != null)
844 protected virtual void OnMouseDown (MouseEventArgs e){
845 if (MouseDown != null)
849 protected virtual void OnMouseEnter (EventArgs e){
850 if (MouseEnter != null)
851 MouseEnter (this, e);
854 protected virtual void OnMouseHover (EventArgs e){
855 if (MouseHover != null)
856 MouseHover (this, e);
859 protected virtual void OnMouseLeave (EventArgs e){
860 if (MouseLeave != null)
861 MouseLeave (this, e);
865 protected virtual void OnMouseMove (MouseEventArgs e){
866 if (MouseMove != null)
871 protected virtual void OnMouseUp (MouseEventArgs e){
876 protected virtual void OnMouseWheel (MouseEventArgs e){
877 if (MouseWheel != null)
878 MouseWheel (this, e);
881 protected virtual void OnMove (EventArgs e){
886 protected virtual void OnNotifyMessage (Message m){
891 protected virtual void OnPaint (PaintEventArgs e){
898 protected virtual void OnPaintBackground (PaintEventArgs pevent){
899 if (GetStyle (ControlStyles.UserPaint)) {
900 Brush br = new SolidBrush (BackColor);
901 pevent.Graphics.FillRectangle (br,
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
913 * if (BackColorChanged != null)
914 * BackColorChanged (this, e);
916 if (BackColorChanged != null)
917 BackColorChanged (this, e);
919 protected virtual void OnParentBackgroundImageChanged (EventArgs e){
920 if (BackgroundImageChanged != null)
921 BackgroundImageChanged (this, e);
923 protected virtual void OnParentBindingContextChanged (EventArgs e){
924 if (BindingContextChanged != null)
925 BindingContextChanged (this, e);
928 protected virtual void OnParentChanged (EventArgs e){
929 if (ParentChanged != null)
930 ParentChanged (this, e);
932 protected virtual void OnParentEnabledChanged (EventArgs e){
933 if (EnabledChanged != null)
934 EnabledChanged (this, e);
936 protected virtual void OnParentFontChanged (EventArgs e){
937 if (FontChanged != null)
938 FontChanged (this, e);
940 protected virtual void OnParentForeColorChanged (EventArgs e){
941 if (ForeColorChanged != null)
942 ForeColorChanged (this, e);
944 protected virtual void OnParentRightToLeftChanged (EventArgs e){
945 if (RightToLeftChanged != null)
946 RightToLeftChanged (this, e);
948 protected virtual void OnParentVisibleChanged (EventArgs e){
949 if (VisibleChanged != null)
950 VisibleChanged (this, e);
952 protected virtual void OnQueryContinueDrag (QueryContinueDragEventArgs qcdevent){
953 if (QueryContinueDrag != null)
954 QueryContinueDrag (this, qcdevent);
957 protected virtual void OnResize (EventArgs e){
960 PerformLayout (this, "Bounds");
962 protected virtual void OnRightToLeftChanged (EventArgs e){
963 if (RightToLeftChanged != null)
964 RightToLeftChanged (this, e);
966 protected virtual void OnSizeChanged (EventArgs e){
968 if (SizeChanged != null)
969 SizeChanged (this, e);
971 protected virtual void OnStyleChanged (EventArgs e){
972 if (StyleChanged != null)
973 StyleChanged (this, e);
975 protected virtual void OnSystemColorsChanged (EventArgs e){
976 if (SystemColorsChanged != null)
977 SystemColorsChanged (this, e);
980 protected virtual void OnTabIndexChanged (EventArgs e){
981 if (TabIndexChanged != null)
982 TabIndexChanged (this, e);
984 protected virtual void OnTabStopChanged (EventArgs e){
985 if (TabStopChanged != null)
986 TabStopChanged (this, e);
989 protected virtual void OnTextChanged (EventArgs e){
990 if (TextChanged != null)
991 TextChanged (this, e);
993 //[MonoTODO] // this doesn't seem to be documented
994 // protected virtual void OnTextAlignChanged (EventArgs e) {
995 // TextAlignChanged (this, e);
998 protected virtual void OnValidated (EventArgs e){
999 if (Validated != null)
1000 Validated (this, e);
1003 protected virtual void OnValidating (CancelEventArgs e) {
1004 throw new NotImplementedException ();
1007 protected virtual void OnVisibleChanged (EventArgs e){
1008 if (VisibleChanged != null)
1009 VisibleChanged (this, e);
1013 public virtual void PerformLayout (){
1016 public virtual void PerformLayout (Control affectedControl,
1017 string affectedProperty){
1020 public virtual Point PointToClient (Point p){
1021 throw new NotImplementedException ();
1024 public virtual Point PointToScreen (Point p){
1025 throw new NotImplementedException ();
1028 public virtual bool PreProcessMessage (ref Message msg){
1029 throw new NotImplementedException ();
1032 protected virtual bool ProcessCmdKey (ref Message msg, Keys keyData){
1033 throw new NotImplementedException ();
1036 protected virtual bool ProcessDialogChar (char charCode){
1037 throw new NotImplementedException ();
1040 protected virtual bool ProcessDialogKey (Keys keyData){
1041 throw new NotImplementedException ();
1044 protected virtual bool ProcessKeyEventArgs (ref Message m){
1045 throw new NotImplementedException ();
1048 protected virtual bool ProcessKeyMessage (ref Message m){
1049 throw new NotImplementedException ();
1052 protected virtual bool ProcessKeyPreview (ref Message m){
1053 throw new NotImplementedException ();
1057 protected virtual bool ProcessMnemonic (char charCode){
1058 throw new NotImplementedException ();
1061 protected virtual void RaiseDragEvent (object key, DragEventArgs e){
1064 protected virtual void RaiseKeyEvent (object key, KeyEventArgs e){
1067 protected virtual void RaiseMouseEvent (object key, MouseEventArgs e){
1070 protected virtual void RaisePaintEvent (object key, PaintEventArgs e){
1073 protected virtual void RecreateHandle (){
1076 public virtual Rectangle RectangleToClient (Rectangle r){
1077 throw new NotImplementedException ();
1080 public virtual Rectangle RectangleToScreen (Rectangle r){
1081 throw new NotImplementedException ();
1084 protected static bool ReflectMessage (IntPtr hWnd,ref Message m){
1085 //throw new NotImplementedException ();
1089 public virtual void Refresh (){
1092 public virtual void ResetBackColor (){
1095 public virtual void ResetBindings (){
1098 public virtual void ResetCursor (){
1101 public virtual void ResetFont (){
1104 public virtual void ResetForeColor (){
1107 public virtual void ResetImeMode (){
1110 protected virtual void ResetMouseEventArgs (){
1113 public virtual void ResetRightToLeft (){
1116 public virtual void ResetText (){
1118 public virtual void ResumeLayout (){
1119 this.ResumeLayout (true);
1122 public virtual void ResumeLayout (bool performLayout){
1125 protected virtual ContentAlignment
1126 RtlTranslateAlignment (ContentAlignment align){
1127 throw new NotImplementedException ();
1130 protected virtual HorizontalAlignment
1131 RtlTranslateAlignment (HorizontalAlignment align){
1132 throw new NotImplementedException ();
1135 protected virtual LeftRightAlignment
1136 RtlTranslateAlignment (LeftRightAlignment align){
1137 throw new NotImplementedException ();
1140 protected virtual ContentAlignment
1141 RtlTranslateContent (ContentAlignment align){
1142 throw new NotImplementedException ();
1145 protected virtual HorizontalAlignment
1146 RtlTranslateHorizontal (HorizontalAlignment align){
1147 throw new NotImplementedException ();
1150 protected virtual LeftRightAlignment
1151 RtlTranslateLeftRight (LeftRightAlignment align){
1152 throw new NotImplementedException ();
1154 public virtual void Scale (float ratio){
1155 ScaleCore (ratio, ratio);
1157 public virtual void Scale (float dx, float dy){
1161 protected virtual void ScaleCore (float dx, float dy){
1164 public virtual void Select (){
1167 protected virtual void Select (bool directed, bool forward){
1170 public virtual bool SelectNextControl (Control ct,
1177 throw new NotImplementedException ();
1180 public virtual void SendToBack (){
1183 public virtual void SetBounds (int x, int y,int width, int height){
1186 public virtual void SetBounds (int x, int y,
1187 int width, int height,
1193 protected virtual void SetBoundsCore (int x, int y,
1201 protected virtual void SetClientSizeCore (int x, int y){
1204 protected virtual void SetStyle (ControlStyles flag, bool value){
1207 protected virtual void SetTopLevel (bool value){
1210 protected virtual void SetVisibleCore (bool value){
1212 public void Show (){
1216 public virtual void SuspendLayout (){
1219 public virtual void Update (){
1221 protected void UpdateBounds (){
1223 protected virtual void UpdateBounds (int x, int y, int width, int height){
1225 protected virtual void UpdateBounds (int x, int y, int width,
1232 protected virtual void UpdateStyles (){
1234 protected virtual void UpdateZOrder (){
1236 protected virtual void WndProc (ref Message m){
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;
1249 public event EventHandler Click;
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;
1263 public event EventHandler EnabledChanged;
1265 public event EventHandler Enter;
1266 public event EventHandler FontChanged;
1267 public event EventHandler ForeColorChanged;
1268 public event GiveFeedbackEventHandler GiveFeedback;
1271 public event EventHandler GotFocus;
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;
1280 public event KeyEventHandler KeyDown;
1283 public event KeyPressEventHandler KeyPress;
1286 public event KeyEventHandler KeyUp;
1288 public event LayoutEventHandler Layout;
1289 public event EventHandler Leave;
1290 public event EventHandler LocationChanged;
1293 public event EventHandler LostFocus;
1296 public event MouseEventHandler MouseDown;
1298 public event EventHandler MouseEnter;
1299 public event EventHandler MouseHover;
1300 public event EventHandler MouseLeave;
1303 public event MouseEventHandler MouseMove;
1306 public event MouseEventHandler MouseUp;
1308 public event MouseEventHandler MouseWheel;
1309 public event EventHandler Move;
1312 public event PaintEventHandler Paint;
1315 public event EventHandler ParentChanged;
1317 public event QueryAccessibilityHelpEventHandler
1318 QueryAccessibilityHelp;
1319 public event QueryContinueDragEventHandler QueryContinueDrag;
1322 public event EventHandler Resize;
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;
1332 public event EventHandler TextChanged;
1334 public event EventHandler Validated;
1336 public event CancelEventHandler Validating;
1338 public event EventHandler VisibleChanged;
1344 internal Widget Widget{
1346 if (widget == null){
1347 widget = CreateWidget ();
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);
1362 internal virtual void ConnectEvents(){
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);
1370 this.Resize += new EventHandler (this.GtkResize);
1372 internal void GtkResize (object o, EventArgs args){
1373 Widget.SetSizeRequest (Size.Width, Size.Height);
1376 internal void GtkButtonPress(object o, ButtonPressEventArgs args){
1377 OnMouseDown (SWFGtkConv.MouseUpDownArgs(args.Event));
1379 internal void GtkButtonRelease (object o, ButtonReleaseEventArgs args){
1380 OnMouseUp (SWFGtkConv.MouseUpDownArgs(args.Event));
1382 internal void GtkMouseEnter (object o, EnterNotifyEventArgs args){
1383 OnMouseEnter ((EventArgs) args);
1385 internal void GtkMouseLeave (object o, LeaveNotifyEventArgs args){
1386 OnMouseLeave ((EventArgs) args);
1389 public class ControlCollection:IList, ICollection,IEnumerable, ICloneable{
1390 ArrayList list = new ArrayList ();
1391 protected Control owner;
1393 public ControlCollection (Control owner){
1397 private ControlCollection (){
1400 // ControlCollection
1402 // TODO Revisar como implementar esto.
1404 public virtual void Add (Control value){
1406 owner.OnControlAdded (new ControlEventArgs (value));
1408 //owner.OnControlAdded (new ControlEventArgs (value));
1411 //if (this.owner.GetType () ==
1412 // typeof (System.Windows.Forms.Button))
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)
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 ?)
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
1429 // We will also have to to create a way to add widgets to a
1432 //Gtk.Button gtkbutton =(Gtk.Button) this.owner.widget;
1434 //GLib.List mylist =new GLib.List ((IntPtr) 0,
1435 // typeof (Gtk.Widget));
1436 //mylist = gtkbutton.Children;
1437 //foreach (Gtk.Widget awidget in mylist)
1439 // gtkbutton.Remove (awidget);
1441 //gtkbutton.Add (value.widget);
1442 //gtkbutton.ShowAll ();
1445 //else if (value.GetType () == typeof (System.Windows.Forms.StatusBar))
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 ();
1456 // TODO System.Windows.Forms.ToolBar
1457 // But we don't have this type yet :-)
1460 // list.Add (value);
1461 // owner.OnControlAdded (new ControlEventArgs (value));
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
1469 // list.AddRange (controls);
1470 foreach (Control c in controls){
1473 // owner.OnControlAdded (new ControlEventArgs (c));
1476 public bool Contains (Control value){
1477 return list.Contains (value);
1479 public virtual void Remove (Control value){
1480 list.Remove (value);
1481 owner.OnControlRemoved (new ControlEventArgs (value));
1483 public virtual Control this[int index]{
1484 get{return (Control) list[index];}
1486 public int GetChildIndex (Control child){
1487 return GetChildIndex (child, true);
1489 public int GetChildIndex (Control child, bool throwException){
1490 if (throwException && !Contains (child))
1491 throw new Exception ();
1492 return list.IndexOf (child);
1494 public int IndexOf (Control value){
1495 return list.IndexOf (value);
1497 public void SetChildIndex (Control child, int newIndex){
1498 int oldIndex = GetChildIndex (child);
1499 if (oldIndex == newIndex)
1501 // is this correct behavior?
1502 Control other = (Control) list[newIndex];
1503 list[oldIndex] = other;
1504 list[newIndex] = child;
1508 public bool IsFixedSize{
1509 get{return list.IsFixedSize;}
1511 public bool IsReadOnly{
1512 get {return list.IsReadOnly;}
1514 int IList.Add (object value){
1515 return list.Add (value);
1517 public virtual void Clear (){
1520 bool IList.Contains (object value){
1521 return list.Contains (value);
1523 int IList.IndexOf (object value){
1524 return list.IndexOf (value);
1526 void IList.Insert (int index, object value){
1527 list.Insert (index, value);
1529 void IList.Remove (object value){
1530 list.Remove (value);
1532 public void RemoveAt (int index){
1533 list.RemoveAt (index);
1538 get {return list.Count;}
1540 public bool IsSynchronized{
1541 get{return list.IsSynchronized; }
1543 public object SyncRoot{
1544 get{return list.SyncRoot;}
1546 public void CopyTo (Array array, int index){
1547 list.CopyTo (array, index);
1551 public IEnumerator GetEnumerator (){
1552 return list.GetEnumerator ();
1556 public object Clone (){
1557 ControlCollection c =
1558 new ControlCollection ();
1559 c.list = (ArrayList) list.Clone ();
1564 object IList.this[int index]{
1565 get{return list[index]; }
1566 set{list[index] = value;}