1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
25 // Partially based on work by:
26 // Aleksey Ryabchuk ryabchuk@yahoo.com
27 // Alexandre Pigolkine pigolkine@gmx.de
28 // Dennis Hayes dennish@raytek.com
29 // Jaak Simm jaaksimm@firm.ee
30 // John Sohn jsohn@columbus.rr.com
36 using System.ComponentModel;
37 using System.ComponentModel.Design;
38 using System.ComponentModel.Design.Serialization;
39 using System.Collections;
40 using System.Diagnostics;
42 using System.Reflection;
43 using System.Runtime.InteropServices;
44 using System.Security;
45 using System.Threading;
48 namespace System.Windows.Forms
50 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
51 [DefaultProperty("Text")]
52 [DefaultEvent("Click")]
53 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
54 [ToolboxItemFilter("System.Windows.Forms")]
55 public class Control : Component, ISynchronizeInvoke, IWin32Window
57 #region Local Variables
60 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
61 internal object creator_thread; // thread that created the control
62 internal ControlNativeWindow window; // object for native window handle
63 internal string name; // for object naming
66 private bool create_handled; // true if OnCreateControl has been sent
67 internal bool has_focus; // true if control has focus
68 internal bool is_visible; // true if control is visible
69 internal bool is_entered; // is the mouse inside the control?
70 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
71 internal bool is_selected; // true if control is selected
72 internal bool is_accessible; // true if the control is visible to accessibility applications
73 internal bool is_captured; // tracks if the control has captured the mouse
74 internal bool is_toplevel; // tracks if the control is a toplevel window
75 internal bool is_recreating; // tracks if the handle for the control is being recreated
76 internal bool causes_validation; // tracks if validation is executed on changes
77 internal int tab_index; // position in tab order of siblings
78 internal bool tab_stop = true; // is the control a tab stop?
79 internal bool is_disposed; // has the window already been disposed?
80 internal Size client_size; // size of the client area (window excluding decorations)
81 internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
82 internal ControlStyles control_style; // rather win32-specific, style bits for control
83 internal ImeMode ime_mode = ImeMode.Inherit;
84 internal bool layout_pending; // true if our parent needs to re-layout us
85 internal object control_tag; // object that contains data about our control
86 internal int mouse_clicks; // Counter for mouse clicks
87 internal Cursor cursor; // Cursor for the window
88 private bool allow_drop; // true if the control accepts droping objects on it
91 internal Color foreground_color; // foreground color for control
92 internal Color background_color; // background color for control
93 internal Image background_image; // background image for control
94 internal Font font; // font for control
95 internal string text; // window/title text for control
96 internal BorderStyle border_style; // Border style of control
99 internal AnchorStyles anchor_style; // anchoring requirements for our control
100 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
101 internal int dist_left; // distance to the left border of the parent
102 internal int dist_top; // distance to the top border of the parent
103 internal int dist_right; // distance to the right border of the parent
104 internal int dist_bottom; // distance to the bottom border of the parent
106 // to be categorized...
107 static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
108 internal ControlCollection child_controls; // our children
109 internal Control parent; // our parent control
110 internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
111 internal BindingContext binding_context; // TODO
112 internal RightToLeft right_to_left; // drawing direction for control
113 internal int layout_suspended;
114 internal ContextMenu context_menu; // Context menu associated with the control
116 private Graphics dc_mem; // Graphics context for double buffering
117 private Bitmap bmp_mem; // Bitmap for double buffering control
118 private bool needs_redraw = true;
120 private ControlBindingsCollection data_bindings;
122 #endregion // Local Variables
124 #region Private Classes
125 // This helper class allows us to dispatch messages to Control.WndProc
126 internal class ControlNativeWindow : NativeWindow {
127 private Control owner;
129 public ControlNativeWindow(Control control) : base() {
134 public Control Owner {
140 static internal Control ControlFromHandle(IntPtr hWnd) {
141 ControlNativeWindow window;
143 window = (ControlNativeWindow)window_collection[hWnd];
148 protected override void WndProc(ref Message m) {
149 owner.WndProc(ref m);
154 #region Public Classes
156 public class ControlAccessibleObject : AccessibleObject {
157 #region ControlAccessibleObject Local Variables
158 private Control owner;
159 #endregion // ControlAccessibleObject Local Variables
161 #region ControlAccessibleObject Constructors
162 public ControlAccessibleObject(Control ownerControl) {
163 this.owner = ownerControl;
165 #endregion // ControlAccessibleObject Constructors
167 #region ControlAccessibleObject Public Instance Properties
168 public override string DefaultAction {
170 return base.DefaultAction;
174 public override string Description {
176 return base.Description;
180 public IntPtr Handle {
186 // We don't want to let them set it
190 public override string Help {
196 public override string KeyboardShortcut {
198 return base.KeyboardShortcut;
202 public override string Name {
212 public Control Owner {
218 public override AccessibleObject Parent {
225 public override AccessibleRole Role {
230 #endregion // ControlAccessibleObject Public Instance Properties
232 #region ControlAccessibleObject Public Instance Methods
233 public override int GetHelpTopic(out string FileName) {
234 return base.GetHelpTopic (out FileName);
237 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
238 public void NotifyClients(AccessibleEvents accEvent) {
239 throw new NotImplementedException();
242 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
243 public void NotifyClients(AccessibleEvents accEvent, int childID) {
244 throw new NotImplementedException();
247 public override string ToString() {
248 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
251 #endregion // ControlAccessibleObject Public Instance Methods
254 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
255 [ListBindable(false)]
256 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
257 #region ControlCollection Local Variables
258 private ArrayList list;
259 private ArrayList impl_list;
260 private Control [] all_controls;
261 internal Control owner;
262 #endregion // ControlCollection Local Variables
264 #region ControlCollection Public Constructor
265 public ControlCollection(Control owner) {
267 this.list=new ArrayList();
271 #region ControlCollection Public Instance Properties
278 public bool IsReadOnly {
280 return list.IsReadOnly;
284 public virtual Control this[int index] {
286 if (index < 0 || index >= list.Count) {
287 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
289 return (Control)list[index];
292 #endregion // ControlCollection Public Instance Properties
294 #region ControlCollection Private Instance Methods
295 public virtual void Add (Control value)
300 if (Contains (value))
303 if (value.tab_index == -1) {
309 end = owner.child_controls.Count;
310 for (int i = 0; i < end; i++) {
311 index = owner.child_controls[i].tab_index;
316 value.tab_index = use;
321 value.Parent = owner;
322 owner.UpdateZOrder();
323 owner.OnControlAdded(new ControlEventArgs(value));
326 internal void AddToList (Control c)
332 internal virtual void AddImplicit (Control control)
334 if (impl_list == null)
335 impl_list = new ArrayList ();
337 impl_list.Add (control);
338 control.Parent = owner;
339 owner.UpdateZOrder ();
342 public virtual void AddRange (Control[] controls)
344 if (controls == null)
345 throw new ArgumentNullException ("controls");
347 owner.SuspendLayout ();
350 for (int i = 0; i < controls.Length; i++)
353 owner.ResumeLayout ();
357 internal virtual void AddRangeImplicit (Control [] controls)
359 if (controls == null)
360 throw new ArgumentNullException ("controls");
362 owner.SuspendLayout ();
365 for (int i = 0; i < controls.Length; i++)
366 AddImplicit (controls [i]);
368 owner.ResumeLayout ();
372 public virtual void Clear ()
374 owner.SuspendLayout();
376 for (int i = 0; i < list.Count; i++) {
377 owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
380 owner.ResumeLayout();
383 internal virtual void ClearImplicit ()
385 if (impl_list == null)
391 public bool Contains (Control value)
393 for (int i = list.Count; i > 0; ) {
396 if (list [i] == value) {
397 // Do we need to do anything here?
404 internal bool ImplicitContains (Control value)
406 if (impl_list == null)
409 for (int i = impl_list.Count; i > 0; ) {
412 if (impl_list [i] == value) {
413 // Do we need to do anything here?
420 internal bool AllContains (Control value)
422 return Contains (value) || ImplicitContains (value);
425 public void CopyTo (Array array, int index)
427 list.CopyTo(array, index);
430 public override bool Equals(object other) {
431 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
438 public int GetChildIndex(Control child) {
439 return GetChildIndex(child, false);
442 public int GetChildIndex(Control child, bool throwException) {
445 index=list.IndexOf(child);
447 if (index==-1 && throwException) {
448 throw new ArgumentException("Not a child control", "child");
453 public IEnumerator GetEnumerator() {
454 return list.GetEnumerator();
457 internal IEnumerator GetAllEnumerator ()
459 Control [] res = GetAllControls ();
460 return res.GetEnumerator ();
463 internal Control [] GetAllControls ()
465 if (all_controls != null)
468 if (impl_list == null)
469 return (Control []) list.ToArray (typeof (Control));
470 Control [] res = new Control [list.Count + impl_list.Count];
472 impl_list.CopyTo (res, list.Count);
476 public override int GetHashCode() {
477 return base.GetHashCode();
480 public int IndexOf(Control control) {
481 return list.IndexOf(control);
484 public virtual void Remove(Control value) {
487 owner.OnControlRemoved(new ControlEventArgs(value));
490 owner.UpdateZOrder();
493 internal virtual void RemoveImplicit (Control control)
495 if (impl_list != null) {
497 impl_list.Remove (control);
499 control.Parent = null;
500 owner.UpdateZOrder ();
503 public void RemoveAt(int index) {
504 if (index < 0 || index >= list.Count) {
505 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
507 Remove ((Control)list[index]);
510 public void SetChildIndex(Control child, int newIndex) {
513 old_index=list.IndexOf(child);
515 throw new ArgumentException("Not a child control", "child");
518 if (old_index==newIndex) {
524 if (newIndex>list.Count) {
527 list.Insert(newIndex, child);
529 child.parent = owner;
530 owner.UpdateZOrder();
532 #endregion // ControlCollection Private Instance Methods
534 #region ControlCollection Interface Properties
535 object IList.this[int index] {
537 if (index<0 || index>=list.Count) {
538 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
544 if (!(value is Control)) {
545 throw new ArgumentException("Object of type Control required", "value");
548 list[index]=(Control)value;
552 bool IList.IsFixedSize {
558 bool IList.IsReadOnly {
560 return list.IsReadOnly;
564 bool ICollection.IsSynchronized {
566 return list.IsSynchronized;
570 object ICollection.SyncRoot {
572 return list.SyncRoot;
575 #endregion // ControlCollection Interface Properties
577 #region ControlCollection Interface Methods
578 int IList.Add(object value) {
580 throw new ArgumentNullException("value", "Cannot add null controls");
583 if (!(value is Control)) {
584 throw new ArgumentException("Object of type Control required", "value");
587 return list.Add(value);
590 bool IList.Contains(object value) {
591 if (!(value is Control)) {
592 throw new ArgumentException("Object of type Control required", "value");
595 return this.Contains((Control) value);
598 int IList.IndexOf(object value) {
599 if (!(value is Control)) {
600 throw new ArgumentException("Object of type Control required", "value");
603 return this.IndexOf((Control) value);
606 void IList.Insert(int index, object value) {
607 if (!(value is Control)) {
608 throw new ArgumentException("Object of type Control required", "value");
611 list.Insert(index, value);
614 void IList.Remove(object value) {
615 if (!(value is Control)) {
616 throw new ArgumentException("Object of type Control required", "value");
622 void ICollection.CopyTo(Array array, int index) {
624 list.CopyTo(array, index);
628 Object ICloneable.Clone() {
629 ControlCollection clone = new ControlCollection(this.owner);
630 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
633 #endregion // ControlCollection Interface Methods
635 #endregion // ControlCollection Class
637 #region Public Constructors
639 creator_thread = Thread.CurrentThread;
641 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
643 create_handled = false;
649 layout_pending = false;
651 causes_validation = true;
653 layout_suspended = 0;
657 right_to_left = RightToLeft.Inherit;
658 border_style = BorderStyle.None;
659 background_color = Color.Empty;
665 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
666 ControlStyles.Selectable | ControlStyles.StandardClick |
667 ControlStyles.StandardDoubleClick;
670 background_image = null;
674 window = new ControlNativeWindow(this);
675 child_controls = CreateControlsInstance();
676 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
677 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
678 XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, CreateParams.ExStyle, IntPtr.Zero, out bounds);
679 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
685 public Control(Control parent, string text) : this() {
690 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
695 bounds.Height=height;
696 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
700 public Control(string text) : this() {
704 public Control(string text, int left, int top, int width, int height) : this() {
708 bounds.Height=height;
709 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
713 private delegate void RemoveDelegate(object c);
715 protected override void Dispose(bool disposing) {
727 if (this.InvokeRequired) {
728 this.Invoke(new MethodInvoker(DestroyHandle));
729 this.Invoke(new RemoveDelegate(controls.Remove), new object[] {this});
732 controls.Remove(this);
735 #endregion // Public Constructors
737 #region Internal Properties
738 internal BorderStyle InternalBorderStyle {
744 if (!Enum.IsDefined (typeof (BorderStyle), value))
745 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
747 if (border_style != value) {
748 border_style = value;
750 if (IsHandleCreated) {
751 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
757 #endregion // Internal Properties
759 #region Private & Internal Methods
760 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
761 AsyncMethodResult result;
762 AsyncMethodData data;
767 if (!p.IsHandleCreated) {
768 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
773 result = new AsyncMethodResult ();
774 data = new AsyncMethodData ();
776 data.Method = method;
778 data.Result = new WeakReference (result);
781 if (!ExecutionContext.IsFlowSuppressed ()) {
782 data.Context = ExecutionContext.Capture ();
785 #if !MWF_ON_MSRUNTIME
786 if (SecurityManager.SecurityEnabled) {
787 data.Stack = CompressedStack.GetCompressedStack ();
792 XplatUI.SendAsyncMethod (data);
796 internal Graphics DeviceContext {
799 CreateBuffers(this.Width, this.Height);
805 private Bitmap ImageBuffer {
808 CreateBuffers(this.Width, this.Height);
814 internal void CreateBuffers (int width, int height) {
815 if (dc_mem != null) {
829 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
830 dc_mem = Graphics.FromImage (bmp_mem);
834 internal void InvalidateBuffers ()
836 if (dc_mem != null) {
847 internal static void SetChildColor(Control parent) {
850 for (int i=0; i < parent.child_controls.Count; i++) {
851 child=parent.child_controls[i];
852 if (child.child_controls.Count>0) {
853 SetChildColor(child);
859 internal bool Select(Control control) {
861 IContainerControl container;
863 if (control == null) {
867 parent = control.parent;
869 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
870 while (parent != null) {
871 if (!parent.Visible || !parent.is_enabled) {
874 parent = parent.parent;
878 control.is_selected = true;
880 container = GetContainerControl();
881 if (container != null) {
882 container.ActiveControl = control;
884 if (control.IsHandleCreated) {
885 XplatUI.SetFocus(control.window.Handle);
890 internal virtual void DoDefaultAction() {
891 // Only here to be overriden by our actual controls; this is needed by the accessibility class
894 internal static int LowOrder (int param) {
895 return ((int)(short)(param & 0xffff));
898 internal static int HighOrder (int param) {
899 return ((int)(short)(param >> 16));
902 // This method exists so controls overriding OnPaintBackground can have default background painting done
903 internal virtual void PaintControlBackground (PaintEventArgs pevent)
905 if (background_image == null) {
906 pevent.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), new Rectangle(pevent.ClipRectangle.X - 1, pevent.ClipRectangle.Y - 1, pevent.ClipRectangle.Width + 2, pevent.ClipRectangle.Height + 2));
910 DrawBackgroundImage (pevent.Graphics);
913 void DrawBackgroundImage (Graphics g)
915 using (TextureBrush b = new TextureBrush (background_image)) {
916 g.FillRectangle (b, ClientRectangle);
920 internal void DndEnter (DragEventArgs e)
925 internal void DndOver (DragEventArgs e)
930 internal void DndDrop (DragEventArgs e)
935 internal void DndLeave (EventArgs e)
940 internal void DnDFeedback(GiveFeedbackEventArgs e)
945 internal void DnDContinueDrag(QueryContinueDragEventArgs e) {
946 OnQueryContinueDrag(e);
949 internal static MouseButtons FromParamToMouseButtons (int param) {
950 MouseButtons buttons = MouseButtons.None;
952 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
953 buttons |= MouseButtons.Left;
955 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
956 buttons |= MouseButtons.Middle;
958 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
959 buttons |= MouseButtons.Right;
965 internal virtual bool ProcessControlMnemonic(char charCode) {
966 return ProcessMnemonic(charCode);
969 private static Control FindFlatForward(Control container, Control start) {
975 end = container.child_controls.Count;
978 index = start.tab_index;
983 for (int i = 0; i < end; i++) {
985 if (container.child_controls[i].tab_index > index) {
986 found = container.child_controls[i];
988 } else if (found.tab_index > container.child_controls[i].tab_index) {
989 if (container.child_controls[i].tab_index > index) {
990 found = container.child_controls[i];
997 private static Control FindControlForward(Control container, Control start) {
1003 if (start != null) {
1004 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
1005 found = FindControlForward(start, null);
1006 if (found != null) {
1012 while (p != container) {
1013 found = FindFlatForward(p, start);
1014 if (found != null) {
1021 return FindFlatForward(container, start);
1024 private static Control FindFlatBackward(Control container, Control start) {
1030 end = container.child_controls.Count;
1032 if (start != null) {
1033 index = start.tab_index;
1035 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1037 for (int i = 0; i < end; i++) {
1038 if (container.child_controls[i].tab_index > index) {
1039 index = container.child_controls[i].tab_index;
1045 for (int i = 0; i < end; i++) {
1046 if (found == null) {
1047 if (container.child_controls[i].tab_index < index) {
1048 found = container.child_controls[i];
1050 } else if (found.tab_index < container.child_controls[i].tab_index) {
1051 if (container.child_controls[i].tab_index < index) {
1052 found = container.child_controls[i];
1059 private static Control FindControlBackward(Control container, Control start) {
1064 if (start != null) {
1065 found = FindFlatBackward(start.parent, start);
1066 if (found == null && start.parent != container) {
1067 return start.parent;
1070 if (found == null) {
1071 found = FindFlatBackward(container, start);
1074 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
1075 found = FindControlBackward(found, null);
1076 if (found != null) {
1084 private void HandleClick(int clicks) {
1085 if (GetStyle(ControlStyles.StandardClick)) {
1087 if (GetStyle(ControlStyles.StandardDoubleClick)) {
1088 OnDoubleClick(EventArgs.Empty);
1090 OnClick(EventArgs.Empty);
1093 OnClick(EventArgs.Empty);
1098 private void CheckDataBindings ()
1100 if (data_bindings == null)
1103 BindingContext binding_context = BindingContext;
1104 foreach (Binding binding in data_bindings) {
1105 binding.Check (binding_context);
1108 #endregion // Private & Internal Methods
1110 #region Public Static Properties
1111 public static Color DefaultBackColor {
1113 return ThemeEngine.Current.DefaultControlBackColor;
1117 public static Font DefaultFont {
1119 return ThemeEngine.Current.DefaultFont;
1123 public static Color DefaultForeColor {
1125 return ThemeEngine.Current.DefaultControlForeColor;
1129 public static Keys ModifierKeys {
1131 return XplatUI.State.ModifierKeys;
1135 public static MouseButtons MouseButtons {
1137 return XplatUI.State.MouseButtons;
1141 public static Point MousePosition {
1143 return Cursor.Position;
1149 public static bool CheckForIllegalCrossThreadCalls
1158 #endregion // Public Static Properties
1160 #region Public Instance Properties
1161 [EditorBrowsable(EditorBrowsableState.Advanced)]
1163 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1164 public AccessibleObject AccessibilityObject {
1166 if (accessibility_object==null) {
1167 accessibility_object=CreateAccessibilityInstance();
1169 return accessibility_object;
1173 [EditorBrowsable(EditorBrowsableState.Advanced)]
1175 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1176 public string AccessibleDefaultActionDescription {
1178 return AccessibilityObject.default_action;
1182 AccessibilityObject.default_action=value;
1187 [DefaultValue(null)]
1188 public string AccessibleDescription {
1190 return AccessibilityObject.description;
1194 AccessibilityObject.description=value;
1199 [DefaultValue(null)]
1200 public string AccessibleName {
1202 return AccessibilityObject.Name;
1206 AccessibilityObject.Name=value;
1210 [DefaultValue(AccessibleRole.Default)]
1211 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1212 public AccessibleRole AccessibleRole {
1214 return AccessibilityObject.role;
1218 AccessibilityObject.role=value;
1222 [DefaultValue(false)]
1223 public virtual bool AllowDrop {
1229 if (allow_drop == value)
1233 XplatUI.SetAllowDrop (Handle, value);
1238 [RefreshProperties(RefreshProperties.Repaint)]
1239 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1240 public virtual AnchorStyles Anchor {
1242 return anchor_style;
1248 if (parent != null) {
1249 parent.PerformLayout(this, "Parent");
1255 public virtual Color BackColor {
1257 if (background_color.IsEmpty) {
1259 return parent.BackColor;
1261 return DefaultBackColor;
1263 return background_color;
1267 background_color=value;
1268 SetChildColor(this);
1269 OnBackColorChanged(EventArgs.Empty);
1275 [DefaultValue(null)]
1276 public virtual Image BackgroundImage {
1278 return background_image;
1282 if (background_image!=value) {
1283 background_image=value;
1284 OnBackgroundImageChanged(EventArgs.Empty);
1289 [EditorBrowsable(EditorBrowsableState.Advanced)]
1291 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1292 public virtual BindingContext BindingContext {
1294 if (binding_context != null)
1295 return binding_context;
1298 binding_context = Parent.BindingContext;
1299 return binding_context;
1302 if (binding_context != value) {
1303 binding_context = value;
1304 OnBindingContextChanged(EventArgs.Empty);
1309 [EditorBrowsable(EditorBrowsableState.Advanced)]
1311 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1314 return bounds.Y+bounds.Height;
1318 [EditorBrowsable(EditorBrowsableState.Advanced)]
1320 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1321 public Rectangle Bounds {
1327 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1331 [EditorBrowsable(EditorBrowsableState.Advanced)]
1333 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1334 public bool CanFocus {
1336 if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1343 [EditorBrowsable(EditorBrowsableState.Advanced)]
1345 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1346 public bool CanSelect {
1350 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1354 parent = this.parent;
1355 while (parent != null) {
1356 if (!parent.is_visible || !parent.is_enabled) {
1360 parent = parent.parent;
1366 [EditorBrowsable(EditorBrowsableState.Advanced)]
1368 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1369 public bool Capture {
1371 return this.is_captured;
1375 if (this.IsHandleCreated) {
1376 if (value && !is_captured) {
1378 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1379 } else if (!value && is_captured) {
1380 XplatUI.UngrabWindow(this.window.Handle);
1381 is_captured = false;
1387 [DefaultValue(true)]
1388 public bool CausesValidation {
1390 return this.causes_validation;
1394 if (this.causes_validation != value) {
1395 causes_validation = value;
1396 OnCausesValidationChanged(EventArgs.Empty);
1401 [EditorBrowsable(EditorBrowsableState.Advanced)]
1403 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1404 public Rectangle ClientRectangle {
1406 client_rect.Width = client_size.Width;
1407 client_rect.Height = client_size.Height;
1412 [EditorBrowsable(EditorBrowsableState.Advanced)]
1414 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1415 public Size ClientSize {
1418 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1419 return ((Form)this).form_parent_window.ClientSize;
1427 this.SetClientSizeCore(value.Width, value.Height);
1431 [EditorBrowsable(EditorBrowsableState.Advanced)]
1433 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1434 [DescriptionAttribute("ControlCompanyNameDescr")]
1435 public String CompanyName {
1437 return "Mono Project, Novell, Inc.";
1441 [EditorBrowsable(EditorBrowsableState.Advanced)]
1443 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1444 public bool ContainsFocus {
1450 for (int i=0; i < child_controls.Count; i++) {
1451 if (child_controls[i].ContainsFocus) {
1459 [DefaultValue(null)]
1460 public virtual ContextMenu ContextMenu {
1462 return context_menu;
1466 if (context_menu != value) {
1467 context_menu = value;
1468 OnContextMenuChanged(EventArgs.Empty);
1474 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1475 public ControlCollection Controls {
1477 return this.child_controls;
1481 [EditorBrowsable(EditorBrowsableState.Advanced)]
1483 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1484 public bool Created {
1486 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1493 [AmbientValue(null)]
1494 public virtual Cursor Cursor {
1496 if (cursor != null) {
1500 if (parent != null) {
1501 return parent.Cursor;
1504 return Cursors.Default;
1508 if (cursor != value) {
1513 pt = Cursor.Position;
1514 if (bounds.Contains(pt)) {
1515 if (GetChildAtPoint(pt) == null) {
1516 if (cursor != null) {
1517 XplatUI.SetCursor(window.Handle, cursor.handle);
1519 if (parent != null) {
1520 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1522 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1528 OnCursorChanged(EventArgs.Empty);
1534 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1535 [ParenthesizePropertyName(true)]
1536 [RefreshProperties(RefreshProperties.All)]
1537 public ControlBindingsCollection DataBindings {
1539 if (data_bindings == null)
1540 data_bindings = new ControlBindingsCollection (this);
1541 return data_bindings;
1545 [EditorBrowsable(EditorBrowsableState.Advanced)]
1547 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1548 public virtual Rectangle DisplayRectangle {
1550 return ClientRectangle;
1554 [EditorBrowsable(EditorBrowsableState.Advanced)]
1556 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1557 public bool Disposing {
1564 [RefreshProperties(RefreshProperties.Repaint)]
1565 [DefaultValue(DockStyle.None)]
1566 public virtual DockStyle Dock {
1572 if (dock_style == value) {
1578 if (parent != null) {
1579 parent.PerformLayout(this, "Parent");
1582 OnDockChanged(EventArgs.Empty);
1588 public bool Enabled {
1594 if (is_enabled == value) {
1600 OnEnabledChanged (EventArgs.Empty);
1604 [EditorBrowsable(EditorBrowsableState.Advanced)]
1606 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1607 public virtual bool Focused {
1609 return this.has_focus;
1614 [AmbientValue(null)]
1616 public virtual Font Font {
1622 if (Parent != null && Parent.Font != null) {
1630 if (font != null && font.Equals (value)) {
1636 OnFontChanged (EventArgs.Empty);
1641 public virtual Color ForeColor {
1643 if (foreground_color.IsEmpty) {
1645 return parent.ForeColor;
1647 return DefaultForeColor;
1649 return foreground_color;
1653 if (foreground_color != value) {
1654 foreground_color=value;
1656 OnForeColorChanged(EventArgs.Empty);
1663 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1664 public IntPtr Handle { // IWin32Window
1666 if (!IsHandleCreated) {
1669 return window.Handle;
1673 [EditorBrowsable(EditorBrowsableState.Advanced)]
1675 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1676 public bool HasChildren {
1678 if (this.child_controls.Count>0) {
1685 [EditorBrowsable(EditorBrowsableState.Always)]
1687 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1690 return this.bounds.Height;
1694 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1698 [AmbientValue(ImeMode.Inherit)]
1700 public ImeMode ImeMode {
1702 if (ime_mode == DefaultImeMode) {
1704 return parent.ImeMode;
1706 return ImeMode.NoControl; // default value
1712 if (ime_mode != value) {
1715 OnImeModeChanged(EventArgs.Empty);
1720 [EditorBrowsable(EditorBrowsableState.Advanced)]
1722 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1723 public bool InvokeRequired { // ISynchronizeInvoke
1725 if (creator_thread!=Thread.CurrentThread) {
1732 [EditorBrowsable(EditorBrowsableState.Advanced)]
1734 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1735 public bool IsAccessible {
1737 return is_accessible;
1741 is_accessible = value;
1745 [EditorBrowsable(EditorBrowsableState.Advanced)]
1747 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1748 public bool IsDisposed {
1750 return this.is_disposed;
1754 [EditorBrowsable(EditorBrowsableState.Advanced)]
1756 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1757 public bool IsHandleCreated {
1759 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1767 [EditorBrowsable(EditorBrowsableState.Always)]
1769 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1772 return this.bounds.X;
1776 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1781 public Point Location {
1783 return new Point(bounds.X, bounds.Y);
1787 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1792 public string Name {
1803 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1804 public Control Parent {
1810 if (value == this) {
1811 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1814 if (parent!=value) {
1816 parent.Controls.Remove(this);
1822 if (!parent.Controls.AllContains (this)) {
1823 Console.WriteLine ("Adding child: " + this);
1824 parent.Controls.Add(this);
1827 if (IsHandleCreated) {
1828 XplatUI.SetParent(Handle, value.Handle);
1831 OnParentChanged(EventArgs.Empty);
1837 [EditorBrowsable(EditorBrowsableState.Advanced)]
1839 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1840 public string ProductName {
1842 Type t = typeof (AssemblyProductAttribute);
1843 Assembly assembly = GetType().Module.Assembly;
1844 object [] attrs = assembly.GetCustomAttributes (t, false);
1845 AssemblyProductAttribute a = null;
1846 // On MS we get a NullRefException if product attribute is not
1848 if (attrs != null && attrs.Length > 0)
1849 a = (AssemblyProductAttribute) attrs [0];
1854 [EditorBrowsable(EditorBrowsableState.Advanced)]
1856 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1857 public string ProductVersion {
1859 Type t = typeof (AssemblyVersionAttribute);
1860 Assembly assembly = GetType().Module.Assembly;
1861 object [] attrs = assembly.GetCustomAttributes (t, false);
1862 if (attrs == null || attrs.Length < 1)
1864 return ((AssemblyVersionAttribute)attrs [0]).Version;
1868 [EditorBrowsable(EditorBrowsableState.Advanced)]
1870 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1871 public bool RecreatingHandle {
1873 return is_recreating;
1877 [EditorBrowsable(EditorBrowsableState.Advanced)]
1879 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1880 public Region Region {
1882 return new Region(this.bounds);
1889 g = this.CreateGraphics();
1890 r = value.GetBounds(g);
1892 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1898 [EditorBrowsable(EditorBrowsableState.Advanced)]
1900 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1903 return this.bounds.X+this.bounds.Width;
1907 [AmbientValue(RightToLeft.Inherit)]
1909 public virtual RightToLeft RightToLeft {
1911 if (right_to_left == RightToLeft.Inherit) {
1913 return parent.RightToLeft;
1915 return RightToLeft.No; // default value
1917 return right_to_left;
1921 if (value != right_to_left) {
1922 right_to_left = value;
1923 OnRightToLeftChanged(EventArgs.Empty);
1928 [EditorBrowsable(EditorBrowsableState.Advanced)]
1929 public override ISite Site {
1942 return new Size(Width, Height);
1946 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1951 [MergableProperty(false)]
1952 public int TabIndex {
1954 if (tab_index != -1) {
1961 if (tab_index != value) {
1963 OnTabIndexChanged(EventArgs.Empty);
1969 [DefaultValue(true)]
1970 public bool TabStop {
1976 if (tab_stop != value) {
1978 OnTabStopChanged(EventArgs.Empty);
1983 [Localizable(false)]
1985 [TypeConverter(typeof(StringConverter))]
1986 [DefaultValue(null)]
1993 control_tag = value;
1999 [BindableAttribute(true)]
2000 public virtual string Text {
2002 // Our implementation ignores ControlStyles.CacheText - we always cache
2007 if (value == null) {
2008 value = String.Empty;
2013 if (IsHandleCreated) {
2014 XplatUI.Text(Handle, text);
2016 OnTextChanged (EventArgs.Empty);
2021 [EditorBrowsable(EditorBrowsableState.Always)]
2023 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2026 return this.bounds.Y;
2030 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2034 [EditorBrowsable(EditorBrowsableState.Advanced)]
2036 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2037 public Control TopLevelControl {
2041 while (p.parent != null) {
2050 public bool Visible {
2054 } else if (parent != null) {
2055 return parent.Visible;
2062 SetVisibleCore(value);
2066 [EditorBrowsable(EditorBrowsableState.Always)]
2068 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2071 return this.bounds.Width;
2075 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2079 [EditorBrowsable(EditorBrowsableState.Never)]
2081 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2082 public IWindowTarget WindowTarget {
2091 #endregion // Public Instance Properties
2093 #region Protected Instance Properties
2094 protected virtual CreateParams CreateParams {
2096 CreateParams create_params = new CreateParams();
2099 create_params.Caption = Text;
2102 create_params.Caption = text;
2106 create_params.X = Left;
2109 create_params.X = this.bounds.X;
2113 create_params.Y = Top;
2116 create_params.Y = this.bounds.Y;
2120 create_params.Width = Width;
2123 create_params.Width = this.bounds.Width;
2127 create_params.Height = Height;
2130 create_params.Height = this.bounds.Height;
2134 create_params.ClassName = XplatUI.DefaultClassName;
2135 create_params.ClassStyle = 0;
2136 create_params.ExStyle = 0;
2137 create_params.Param = 0;
2140 create_params.ExStyle |= (int)WindowStyles.WS_EX_ACCEPTFILES;
2144 create_params.Parent = parent.Handle;
2147 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2150 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2153 return create_params;
2157 protected virtual ImeMode DefaultImeMode {
2159 return ImeMode.Inherit;
2163 protected virtual Size DefaultSize {
2165 return new Size(100, 23);
2169 protected int FontHeight {
2179 protected bool RenderRightToLeft {
2181 return (this.right_to_left == RightToLeft.Yes);
2185 protected bool ResizeRedraw {
2187 return GetStyle(ControlStyles.ResizeRedraw);
2191 SetStyle(ControlStyles.ResizeRedraw, value);
2195 [EditorBrowsable(EditorBrowsableState.Advanced)]
2197 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2198 protected virtual bool ShowFocusCues {
2204 [EditorBrowsable(EditorBrowsableState.Advanced)]
2206 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2207 protected bool ShowKeyboardCues {
2212 #endregion // Protected Instance Properties
2214 #region Public Static Methods
2215 [EditorBrowsable(EditorBrowsableState.Advanced)]
2216 public static Control FromChildHandle(IntPtr handle) {
2217 IEnumerator control = Control.controls.GetEnumerator();
2219 while (control.MoveNext()) {
2220 if (((Control)control.Current).window.Handle == handle) {
2222 if (((Control)control.Current).Parent != null) {
2223 return ((Control)control.Current).Parent;
2230 [EditorBrowsable(EditorBrowsableState.Advanced)]
2231 public static Control FromHandle(IntPtr handle) {
2232 IEnumerator control = Control.controls.GetEnumerator();
2234 while (control.MoveNext()) {
2235 if (((Control)control.Current).window.Handle == handle) {
2237 return ((Control)control.Current);
2243 public static bool IsMnemonic(char charCode, string text) {
2246 amp = text.IndexOf('&');
2249 if (amp + 1 < text.Length) {
2250 if (text[amp + 1] != '&') {
2251 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2261 #region Protected Static Methods
2262 [EditorBrowsable(EditorBrowsableState.Advanced)]
2263 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2266 c = Control.FromHandle(hWnd);
2276 #region Public Instance Methods
2277 [EditorBrowsable(EditorBrowsableState.Advanced)]
2278 public IAsyncResult BeginInvoke(Delegate method) {
2279 return BeginInvokeInternal(method, null);
2282 [EditorBrowsable(EditorBrowsableState.Advanced)]
2283 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2284 return BeginInvokeInternal (method, args);
2287 public void BringToFront() {
2288 if ((parent != null) && (parent.child_controls[0]!=this)) {
2289 if (parent.child_controls.Contains(this)) {
2290 parent.child_controls.SetChildIndex(this, 0);
2294 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
2296 if (parent != null) {
2301 public bool Contains(Control ctl) {
2302 while (ctl != null) {
2311 public void CreateControl() {
2313 if (!IsHandleCreated) {
2317 if (!create_handled) {
2318 create_handled = true;
2322 Control [] controls = child_controls.GetAllControls ();
2323 for (int i=0; i<controls.Length; i++) {
2324 controls [i].CreateControl ();
2328 public Graphics CreateGraphics() {
2329 if (!IsHandleCreated) {
2330 this.CreateControl();
2332 return Graphics.FromHwnd(this.window.Handle);
2335 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2336 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2339 [EditorBrowsable(EditorBrowsableState.Advanced)]
2340 public object EndInvoke (IAsyncResult async_result) {
2341 AsyncMethodResult result = (AsyncMethodResult) async_result;
2342 return result.EndInvoke ();
2345 public Form FindForm() {
2358 public bool Focus() {
2359 if (IsHandleCreated && !has_focus) {
2361 XplatUI.SetFocus(window.Handle);
2366 public Control GetChildAtPoint(Point pt) {
2367 // Microsoft's version of this function doesn't seem to work, so I can't check
2368 // if we only consider children or also grandchildren, etc.
2369 // I'm gonna say 'children only'
2370 for (int i=0; i<child_controls.Count; i++) {
2371 if (child_controls[i].Bounds.Contains(pt)) {
2372 return child_controls[i];
2378 public IContainerControl GetContainerControl() {
2379 Control current = this;
2381 while (current!=null) {
2382 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2383 return (IContainerControl)current;
2385 current = current.parent;
2390 public Control GetNextControl(Control ctl, bool forward) {
2391 // If we're not a container we don't play
2392 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2396 // If ctl is not contained by this, we start at the first child of this
2397 if (!this.Contains(ctl)) {
2401 // Search through our controls, starting at ctl, stepping into children as we encounter them
2402 // try to find the control with the tabindex closest to our own, or, if we're looking into
2403 // child controls, the one with the smallest tabindex
2405 return FindControlForward(this, ctl);
2407 return FindControlBackward(this, ctl);
2410 public void Hide() {
2411 this.Visible = false;
2414 public void Invalidate() {
2415 Invalidate(ClientRectangle, false);
2418 public void Invalidate(bool invalidateChildren) {
2419 Invalidate(ClientRectangle, invalidateChildren);
2422 public void Invalidate(System.Drawing.Rectangle rc) {
2423 Invalidate(rc, false);
2426 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2427 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2431 NotifyInvalidate(rc);
2433 XplatUI.Invalidate(Handle, rc, false);
2435 if (invalidateChildren) {
2436 Control [] controls = child_controls.GetAllControls ();
2437 for (int i=0; i<controls.Length; i++)
2438 controls [i].Invalidate ();
2440 OnInvalidated(new InvalidateEventArgs(rc));
2443 public void Invalidate(System.Drawing.Region region) {
2444 Invalidate(region, false);
2447 [MonoTODO("Figure out if GetRegionScans is usable")]
2448 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2449 throw new NotImplementedException();
2451 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2452 //if (invalidateChildren) {
2453 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2457 public object Invoke (Delegate method) {
2458 return Invoke(method, null);
2461 public object Invoke (Delegate method, object[] args) {
2462 if (!this.InvokeRequired) {
2463 return method.DynamicInvoke(args);
2466 IAsyncResult result = BeginInvoke (method, args);
2467 return EndInvoke(result);
2470 [EditorBrowsable(EditorBrowsableState.Advanced)]
2471 public void PerformLayout() {
2472 PerformLayout(null, null);
2475 [EditorBrowsable(EditorBrowsableState.Advanced)]
2476 public void PerformLayout(Control affectedControl, string affectedProperty) {
2477 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2479 if (layout_suspended > 0) {
2480 layout_pending = true;
2484 layout_pending = false;
2486 // Prevent us from getting messed up
2489 // Perform all Dock and Anchor calculations
2492 AnchorStyles anchor;
2495 space=this.DisplayRectangle;
2497 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2498 Control [] controls = child_controls.GetAllControls ();
2499 for (int i = controls.Length - 1; i >= 0; i--) {
2500 child = controls [i];
2501 switch (child.Dock) {
2502 case DockStyle.None: {
2507 case DockStyle.Left: {
2508 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2509 space.X+=child.Width;
2510 space.Width-=child.Width;
2514 case DockStyle.Top: {
2515 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2516 space.Y+=child.Height;
2517 space.Height-=child.Height;
2521 case DockStyle.Right: {
2522 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2523 space.Width-=child.Width;
2527 case DockStyle.Bottom: {
2528 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2529 space.Height-=child.Height;
2535 for (int i = controls.Length - 1; i >= 0; i--) {
2538 if (child.Dock == DockStyle.Fill) {
2539 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2545 space=this.DisplayRectangle;
2547 for (int i=0; i < controls.Length; i++) {
2553 child = controls[i];
2554 anchor = child.Anchor;
2558 width = child.Width;
2559 height = child.Height;
2561 // If the control is docked we don't need to do anything
2562 if (child.Dock != DockStyle.None) {
2566 if ((anchor & AnchorStyles.Left) !=0 ) {
2567 if ((anchor & AnchorStyles.Right) != 0) {
2568 width = client_size.Width - child.dist_right - left;
2570 ; // Left anchored only, nothing to be done
2572 } else if ((anchor & AnchorStyles.Right) != 0) {
2573 left = client_size.Width - child.dist_right - width;
2575 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
2576 // This calculates from scratch every time:
2577 left = child.dist_left + (client_size.Width - (child.dist_left + width + child.dist_right)) / 2;
2580 if ((anchor & AnchorStyles.Top) !=0 ) {
2581 if ((anchor & AnchorStyles.Bottom) != 0) {
2582 height = client_size.Height - child.dist_bottom - top;
2584 ; // Top anchored only, nothing to be done
2586 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2587 top = client_size.Height - child.dist_bottom - height;
2589 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
2590 // This calculates from scratch every time:
2591 top = child.dist_top + (client_size.Height - (child.dist_top + height + child.dist_bottom)) / 2;
2603 child.SetBounds(left, top, width, height);
2606 // Let everyone know
2610 // Need to make sure we decremend layout_suspended
2616 public Point PointToClient (Point p) {
2620 XplatUI.ScreenToClient (Handle, ref x, ref y);
2622 return new Point (x, y);
2625 public Point PointToScreen(Point p) {
2629 XplatUI.ClientToScreen(Handle, ref x, ref y);
2631 return new Point(x, y);
2634 public virtual bool PreProcessMessage(ref Message msg) {
2637 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
2638 key_data = (Keys)msg.WParam.ToInt32();
2639 if (!ProcessCmdKey(ref msg, key_data)) {
2640 if (IsInputKey(key_data)) {
2644 return ProcessDialogKey(key_data);
2648 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2649 if (IsInputChar((char)msg.WParam)) {
2652 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
2653 if (IsInputChar((char)msg.WParam)) {
2656 return ProcessDialogChar((char)msg.WParam);
2661 public Rectangle RectangleToClient(Rectangle r) {
2662 return new Rectangle(PointToClient(r.Location), r.Size);
2665 public Rectangle RectangleToScreen(Rectangle r) {
2666 return new Rectangle(PointToScreen(r.Location), r.Size);
2669 public virtual void Refresh() {
2670 if (IsHandleCreated == true) {
2673 XplatUI.UpdateWindow(window.Handle);
2675 Control [] controls = child_controls.GetAllControls ();
2676 for (int i=0; i < controls.Length; i++) {
2677 controls[i].Refresh();
2683 [EditorBrowsable(EditorBrowsableState.Never)]
2684 public virtual void ResetBackColor() {
2685 background_color = Color.Empty;
2688 [EditorBrowsable(EditorBrowsableState.Never)]
2690 public void ResetBindings() {
2694 [EditorBrowsable(EditorBrowsableState.Never)]
2695 public virtual void ResetCursor() {
2699 [EditorBrowsable(EditorBrowsableState.Never)]
2700 public virtual void ResetFont() {
2704 [EditorBrowsable(EditorBrowsableState.Never)]
2705 public virtual void ResetForeColor() {
2706 foreground_color = Color.Empty;
2709 [EditorBrowsable(EditorBrowsableState.Never)]
2710 public void ResetImeMode() {
2711 ime_mode = DefaultImeMode;
2714 [EditorBrowsable(EditorBrowsableState.Never)]
2715 public virtual void ResetRightToLeft() {
2716 right_to_left = RightToLeft.Inherit;
2719 public virtual void ResetText() {
2720 text = String.Empty;
2723 public void ResumeLayout() {
2724 ResumeLayout (true);
2727 public void ResumeLayout(bool performLayout) {
2730 if (layout_suspended > 0) {
2734 if (performLayout || layout_pending) {
2739 public void Scale(float ratio) {
2740 ScaleCore(ratio, ratio);
2743 public void Scale(float dx, float dy) {
2747 public void Select() {
2748 Select(false, false);
2751 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2756 c = GetNextControl(c, forward);
2765 if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
2769 } while (c != ctl); // If we wrap back to ourselves we stop
2774 public void SendToBack() {
2775 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2776 if (parent.child_controls.Contains(this)) {
2777 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2781 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2782 if (parent != null) {
2787 public void SetBounds(int x, int y, int width, int height) {
2788 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2791 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2792 SetBoundsCore(x, y, width, height, specified);
2795 public void Show() {
2796 if (!IsHandleCreated) {
2797 this.CreateControl();
2803 public void SuspendLayout() {
2807 public void Update() {
2808 needs_redraw = true;
2809 if (IsHandleCreated) {
2810 XplatUI.UpdateWindow(window.Handle);
2813 #endregion // Public Instance Methods
2815 #region Protected Instance Methods
2816 [EditorBrowsable(EditorBrowsableState.Advanced)]
2817 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2818 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2819 throw new NotImplementedException();
2822 [EditorBrowsable(EditorBrowsableState.Advanced)]
2823 protected virtual AccessibleObject CreateAccessibilityInstance() {
2824 return new Control.ControlAccessibleObject(this);
2827 [EditorBrowsable(EditorBrowsableState.Advanced)]
2828 protected virtual ControlCollection CreateControlsInstance() {
2829 return new ControlCollection(this);
2832 [EditorBrowsable(EditorBrowsableState.Advanced)]
2833 protected virtual void CreateHandle() {
2835 throw new ObjectDisposedException(Name);
2838 if (IsHandleCreated) {
2842 window.CreateHandle(CreateParams);
2844 // Find out where the window manager placed us
2846 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
2847 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
2851 if (window.Handle!=IntPtr.Zero) {
2852 if (!controls.Contains(window.Handle)) {
2856 creator_thread = Thread.CurrentThread;
2858 OnHandleCreated(EventArgs.Empty);
2862 [EditorBrowsable(EditorBrowsableState.Advanced)]
2863 protected virtual void DefWndProc(ref Message m) {
2864 window.DefWndProc(ref m);
2867 [EditorBrowsable(EditorBrowsableState.Advanced)]
2868 protected virtual void DestroyHandle() {
2869 if (IsHandleCreated) {
2870 // Destroy our children before we destroy ourselves, to prevent them from
2871 // being implictly (without us knowing) destroyed
2872 Control [] controls = child_controls.GetAllControls ();
2873 for (int i=0; i < controls.Length; i++) {
2874 controls[i].DestroyHandle();
2878 if (window != null) {
2879 window.DestroyHandle();
2881 OnHandleDestroyed(EventArgs.Empty);
2885 protected bool GetStyle(ControlStyles flag) {
2886 return (control_style & flag) != 0;
2889 protected bool GetTopLevel() {
2893 [EditorBrowsable(EditorBrowsableState.Advanced)]
2894 protected virtual void InitLayout() {
2895 dist_left = bounds.X;
2896 dist_top = bounds.Y;
2897 if (parent != null) {
2898 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
2899 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
2903 [EditorBrowsable(EditorBrowsableState.Advanced)]
2904 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2905 toInvoke.OnGotFocus(e);
2908 [EditorBrowsable(EditorBrowsableState.Advanced)]
2909 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2910 toInvoke.OnLostFocus(e);
2913 [EditorBrowsable(EditorBrowsableState.Advanced)]
2914 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2915 toInvoke.OnClick(e);
2918 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2919 toInvoke.OnPaint(e);
2922 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2923 toInvoke.OnPaintBackground(e);
2926 protected virtual bool IsInputChar (char charCode) {
2927 if (parent != null) {
2928 return parent.IsInputChar(charCode);
2934 protected virtual bool IsInputKey (Keys keyData) {
2935 // Doc says this one calls IsInputChar; not sure what to do with that
2939 [EditorBrowsable(EditorBrowsableState.Advanced)]
2940 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2944 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2945 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2949 if (parent != null) {
2950 return parent.ProcessCmdKey(ref msg, keyData);
2956 protected virtual bool ProcessDialogChar(char charCode) {
2957 if (parent != null) {
2958 return parent.ProcessDialogChar (charCode);
2964 protected virtual bool ProcessDialogKey (Keys keyData) {
2965 if (parent != null) {
2966 return parent.ProcessDialogKey (keyData);
2972 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2974 KeyEventArgs key_event;
2977 case (int)Msg.WM_KEYDOWN: {
2978 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2979 OnKeyDown (key_event);
2980 return key_event.Handled;
2982 case (int)Msg.WM_KEYUP: {
2983 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2984 OnKeyUp (key_event);
2985 return key_event.Handled;
2988 case (int)Msg.WM_CHAR: {
2989 KeyPressEventArgs key_press_event;
2991 key_press_event = new KeyPressEventArgs((char)msg.WParam);
2992 OnKeyPress(key_press_event);
2993 return key_press_event.Handled;
3004 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3005 if (parent != null) {
3006 if (parent.ProcessKeyPreview(ref msg)) {
3014 protected virtual bool ProcessKeyPreview(ref Message msg) {
3015 if (parent != null) {
3016 return parent.ProcessKeyPreview(ref msg);
3022 protected virtual bool ProcessMnemonic(char charCode) {
3027 [EditorBrowsable(EditorBrowsableState.Advanced)]
3028 protected void RaiseDragEvent(object key, DragEventArgs e) {
3032 [EditorBrowsable(EditorBrowsableState.Advanced)]
3033 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3037 [EditorBrowsable(EditorBrowsableState.Advanced)]
3038 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3042 [EditorBrowsable(EditorBrowsableState.Advanced)]
3043 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3047 [EditorBrowsable(EditorBrowsableState.Advanced)]
3048 protected void RecreateHandle() {
3049 IEnumerator child = child_controls.GetAllEnumerator();
3053 if (IsHandleCreated) {
3059 while (child.MoveNext()) {
3060 ((Control)child.Current).RecreateHandle();
3066 is_recreating = false;
3069 [EditorBrowsable(EditorBrowsableState.Advanced)]
3070 protected void ResetMouseEventArgs() {
3074 [EditorBrowsable(EditorBrowsableState.Advanced)]
3075 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3076 if (right_to_left == RightToLeft.No) {
3081 case ContentAlignment.TopLeft: {
3082 return ContentAlignment.TopRight;
3085 case ContentAlignment.TopRight: {
3086 return ContentAlignment.TopLeft;
3089 case ContentAlignment.MiddleLeft: {
3090 return ContentAlignment.MiddleRight;
3093 case ContentAlignment.MiddleRight: {
3094 return ContentAlignment.MiddleLeft;
3097 case ContentAlignment.BottomLeft: {
3098 return ContentAlignment.BottomRight;
3101 case ContentAlignment.BottomRight: {
3102 return ContentAlignment.BottomLeft;
3106 // if it's center it doesn't change
3112 [EditorBrowsable(EditorBrowsableState.Advanced)]
3113 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3114 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3118 if (align == HorizontalAlignment.Left) {
3119 return HorizontalAlignment.Right;
3122 // align must be HorizontalAlignment.Right
3123 return HorizontalAlignment.Left;
3126 [EditorBrowsable(EditorBrowsableState.Advanced)]
3127 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3128 if (right_to_left == RightToLeft.No) {
3132 if (align == LeftRightAlignment.Left) {
3133 return LeftRightAlignment.Right;
3136 // align must be LeftRightAlignment.Right;
3137 return LeftRightAlignment.Left;
3140 [EditorBrowsable(EditorBrowsableState.Advanced)]
3141 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3142 return RtlTranslateAlignment(align);
3145 [EditorBrowsable(EditorBrowsableState.Advanced)]
3146 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3147 return RtlTranslateAlignment(align);
3150 [EditorBrowsable(EditorBrowsableState.Advanced)]
3151 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3152 return RtlTranslateAlignment(align);
3155 [EditorBrowsable(EditorBrowsableState.Advanced)]
3156 protected virtual void ScaleCore(float dx, float dy) {
3162 location = new Point((int)(Left * dx), (int)(Top * dy));
3163 size = this.ClientSize;
3166 if (!GetStyle(ControlStyles.FixedWidth)) {
3167 size.Width = (int)(size.Width * dx);
3170 if (!GetStyle(ControlStyles.FixedHeight)) {
3171 size.Height = (int)(size.Height * dy);
3174 Location = location;
3177 /* Now scale our children */
3178 Control [] controls = child_controls.GetAllControls ();
3179 for (int i=0; i < controls.Length; i++) {
3180 controls[i].Scale(dx, dy);
3186 protected virtual void Select(bool directed, bool forward) {
3191 // Select this control
3196 if (parent == null) {
3200 // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
3202 index = parent.child_controls.IndexOf(this);
3207 if ((index+1) < parent.child_controls.Count) {
3216 index = parent.child_controls.Count-1;
3219 result = Select(parent.child_controls[index]);
3220 } while (!result && parent.child_controls[index] != this);
3223 [EditorBrowsable(EditorBrowsableState.Advanced)]
3224 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3225 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3226 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3230 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3234 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3238 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3242 if (IsHandleCreated) {
3243 XplatUI.SetWindowPos(Handle, x, y, width, height);
3246 UpdateBounds(x, y, width, height);
3249 Control [] controls = child_controls.GetAllControls ();
3250 for (int i = controls.Length - 1; i >= 0; i--) {
3251 controls[i].InitLayout();
3255 [EditorBrowsable(EditorBrowsableState.Advanced)]
3256 protected virtual void SetClientSizeCore(int x, int y) {
3257 // Calculate the actual window size from the client size (it usually stays the same or grows)
3258 Rectangle ClientRect;
3259 Rectangle WindowRect;
3262 ClientRect = new Rectangle(0, 0, x, y);
3263 cp = this.CreateParams;
3265 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
3269 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3272 [EditorBrowsable(EditorBrowsableState.Advanced)]
3273 protected void SetStyle(ControlStyles flag, bool value) {
3275 control_style |= flag;
3277 control_style &= ~flag;
3279 OnStyleChanged(EventArgs.Empty);
3282 protected void SetTopLevel(bool value) {
3283 if ((GetTopLevel() != value) && (parent != null)) {
3284 throw new Exception();
3288 if (value == true) {
3298 is_toplevel = value;
3301 protected virtual void SetVisibleCore(bool value) {
3302 if (value!=is_visible) {
3305 if (IsHandleCreated) {
3306 XplatUI.SetVisible(Handle, value);
3307 // Explicitly move Toplevel windows to where we want them;
3308 // apparently moving unmapped toplevel windows doesn't work
3309 if (is_visible && (this is Form)) {
3310 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3314 OnVisibleChanged(EventArgs.Empty);
3317 if (dc_mem != null) {
3322 if (bmp_mem != null) {
3327 this.CreateBuffers(bounds.Width, bounds.Height);
3331 if (value == false && parent != null) {
3334 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3335 container = (Control)parent.GetContainerControl();
3336 if (container != null) {
3337 container.SelectNextControl(this, true, true, true, true);
3341 if (parent != null) {
3342 parent.PerformLayout(this, "visible");
3344 PerformLayout(this, "visible");
3349 [EditorBrowsable(EditorBrowsableState.Advanced)]
3350 protected void UpdateBounds() {
3358 if (!IsHandleCreated) {
3362 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3364 UpdateBounds(x, y, width, height, client_width, client_height);
3367 [EditorBrowsable(EditorBrowsableState.Advanced)]
3368 protected void UpdateBounds(int x, int y, int width, int height) {
3369 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3371 bool resized = false;
3373 int client_x_diff = this.bounds.Width-this.client_size.Width;
3374 int client_y_diff = this.bounds.Height-this.client_size.Height;
3376 // Needed to generate required notifications
3377 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3381 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3388 bounds.Height=height;
3390 // Update client rectangle as well
3391 client_size.Width=width-client_x_diff;
3392 client_size.Height=height-client_y_diff;
3395 OnLocationChanged(EventArgs.Empty);
3399 OnSizeChanged(EventArgs.Empty);
3403 [EditorBrowsable(EditorBrowsableState.Advanced)]
3404 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3405 UpdateBounds(x, y, width, height);
3407 this.client_size.Width=clientWidth;
3408 this.client_size.Height=clientHeight;
3411 [EditorBrowsable(EditorBrowsableState.Advanced)]
3412 protected void UpdateStyles() {
3413 if (!IsHandleCreated) {
3417 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3420 [EditorBrowsable(EditorBrowsableState.Advanced)]
3421 protected void UpdateZOrder() {
3422 Control [] controls;
3426 if (parent == null) {
3432 controls = ctl.child_controls.GetAllControls ();
3433 for (int i = 1; i < controls.Length; i++ ) {
3434 XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
3437 if (!IsHandleCreated) {
3441 controls = child_controls.GetAllControls ();
3442 for (int i = 1; i < controls.Length; i++ ) {
3443 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3448 protected virtual void WndProc(ref Message m) {
3450 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3452 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3456 switch((Msg)m.Msg) {
3457 case Msg.WM_WINDOWPOSCHANGED: {
3460 if (GetStyle(ControlStyles.ResizeRedraw)) {
3467 case Msg.WM_PAINT: {
3468 PaintEventArgs paint_event;
3470 paint_event = XplatUI.PaintEventStart(Handle, true);
3472 if (!needs_redraw) {
3473 // Just blit the previous image
3474 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3475 XplatUI.PaintEventEnd(Handle, true);
3480 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3481 dc = paint_event.SetGraphics (DeviceContext);
3484 if ((control_style & (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) == (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
3485 OnPaintBackground(paint_event);
3487 PaintControlBackground(paint_event);
3490 OnPaint(paint_event);
3492 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3493 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3494 paint_event.SetGraphics (dc);
3495 needs_redraw = false;
3498 XplatUI.PaintEventEnd(Handle, true);
3503 case Msg.WM_ERASEBKGND: {
3504 // The DefWndProc will never have to handle this, we always paint the background in managed code
3505 m.Result = (IntPtr)1;
3509 case Msg.WM_LBUTTONUP: {
3510 HandleClick(mouse_clicks);
3511 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3513 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3515 if (mouse_clicks > 1) {
3521 case Msg.WM_LBUTTONDOWN: {
3522 if (CanSelect && !is_selected) {
3525 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3526 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3532 case Msg.WM_LBUTTONDBLCLK: {
3534 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3535 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3541 case Msg.WM_MBUTTONUP: {
3542 HandleClick(mouse_clicks);
3543 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3545 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3547 if (mouse_clicks > 1) {
3553 case Msg.WM_MBUTTONDOWN: {
3554 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3555 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3561 case Msg.WM_MBUTTONDBLCLK: {
3563 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3564 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3569 case Msg.WM_RBUTTONUP: {
3570 if (context_menu != null) {
3571 context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
3574 HandleClick(mouse_clicks);
3575 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3577 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3579 if (mouse_clicks > 1) {
3585 case Msg.WM_RBUTTONDOWN: {
3586 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3587 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3592 case Msg.WM_RBUTTONDBLCLK: {
3594 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3595 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3600 case Msg.WM_MOUSEWHEEL: {
3602 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3603 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3604 HighOrder(m.WParam.ToInt32())));
3609 case Msg.WM_MOUSEMOVE: {
3610 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3612 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3617 case Msg.WM_MOUSE_ENTER: {
3622 OnMouseEnter(EventArgs.Empty);
3626 case Msg.WM_MOUSE_LEAVE: {
3628 OnMouseLeave(EventArgs.Empty);
3632 case Msg.WM_MOUSEHOVER: {
3633 OnMouseHover(EventArgs.Empty);
3637 case Msg.WM_SYSKEYDOWN:
3638 case Msg.WM_KEYDOWN:
3639 case Msg.WM_SYSKEYUP:
3641 case Msg.WM_SYSCHAR:
3643 Console.WriteLine("Got {0}", (Msg)m.Msg);
3644 if (ProcessKeyEventArgs(ref m)) {
3648 if (PreProcessMessage(ref m)) {
3652 if (ProcessKeyMessage(ref m)) {
3661 if (m.LParam != IntPtr.Zero) {
3664 hi = new HELPINFO();
3666 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3667 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3669 mouse_pos = Control.MousePosition;
3671 OnHelpRequested(new HelpEventArgs(mouse_pos));
3672 m.Result = (IntPtr)1;
3676 case Msg.WM_KILLFOCUS: {
3677 OnLeave(EventArgs.Empty);
3678 if (CausesValidation) {
3680 e = new CancelEventArgs(false);
3689 OnValidated(EventArgs.Empty);
3692 this.has_focus = false;
3693 this.is_selected = false;
3694 OnLostFocus(EventArgs.Empty);
3698 case Msg.WM_SETFOCUS: {
3699 OnEnter(EventArgs.Empty);
3700 this.has_focus = true;
3701 OnGotFocus(EventArgs.Empty);
3706 case Msg.WM_SYSCOLORCHANGE: {
3707 ThemeEngine.Current.ResetDefaults();
3708 OnSystemColorsChanged(EventArgs.Empty);
3713 case Msg.WM_SETCURSOR: {
3714 if (cursor == null) {
3719 XplatUI.SetCursor(window.Handle, cursor.handle);
3720 m.Result = (IntPtr)1;
3731 #endregion // Public Instance Methods
3733 #region OnXXX methods
3734 [EditorBrowsable(EditorBrowsableState.Advanced)]
3735 protected virtual void OnBackColorChanged(EventArgs e) {
3736 if (BackColorChanged!=null) BackColorChanged(this, e);
3737 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3740 [EditorBrowsable(EditorBrowsableState.Advanced)]
3741 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3742 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3743 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3746 [EditorBrowsable(EditorBrowsableState.Advanced)]
3747 protected virtual void OnBindingContextChanged(EventArgs e) {
3748 CheckDataBindings ();
3749 if (BindingContextChanged!=null) {
3750 BindingContextChanged(this, e);
3752 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3755 [EditorBrowsable(EditorBrowsableState.Advanced)]
3756 protected virtual void OnCausesValidationChanged(EventArgs e) {
3757 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3760 [EditorBrowsable(EditorBrowsableState.Advanced)]
3761 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3762 if (ChangeUICues!=null) ChangeUICues(this, e);
3765 [EditorBrowsable(EditorBrowsableState.Advanced)]
3766 protected virtual void OnClick(EventArgs e) {
3767 if (Click!=null) Click(this, e);
3770 [EditorBrowsable(EditorBrowsableState.Advanced)]
3771 protected virtual void OnContextMenuChanged(EventArgs e) {
3772 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3775 [EditorBrowsable(EditorBrowsableState.Advanced)]
3776 protected virtual void OnControlAdded(ControlEventArgs e) {
3777 if (ControlAdded!=null) ControlAdded(this, e);
3780 [EditorBrowsable(EditorBrowsableState.Advanced)]
3781 protected virtual void OnControlRemoved(ControlEventArgs e) {
3782 if (ControlRemoved!=null) ControlRemoved(this, e);
3785 [EditorBrowsable(EditorBrowsableState.Advanced)]
3786 protected virtual void OnCreateControl() {
3790 [EditorBrowsable(EditorBrowsableState.Advanced)]
3791 protected virtual void OnCursorChanged(EventArgs e) {
3792 if (CursorChanged!=null) CursorChanged(this, e);
3795 [EditorBrowsable(EditorBrowsableState.Advanced)]
3796 protected virtual void OnDockChanged(EventArgs e) {
3797 if (DockChanged!=null) DockChanged(this, e);
3800 [EditorBrowsable(EditorBrowsableState.Advanced)]
3801 protected virtual void OnDoubleClick(EventArgs e) {
3802 if (DoubleClick!=null) DoubleClick(this, e);
3805 [EditorBrowsable(EditorBrowsableState.Advanced)]
3806 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3807 if (DragDrop!=null) DragDrop(this, drgevent);
3810 [EditorBrowsable(EditorBrowsableState.Advanced)]
3811 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3812 if (DragEnter!=null) DragEnter(this, drgevent);
3815 [EditorBrowsable(EditorBrowsableState.Advanced)]
3816 protected virtual void OnDragLeave(EventArgs e) {
3817 if (DragLeave!=null) DragLeave(this, e);
3820 [EditorBrowsable(EditorBrowsableState.Advanced)]
3821 protected virtual void OnDragOver(DragEventArgs drgevent) {
3822 if (DragOver!=null) DragOver(this, drgevent);
3825 [EditorBrowsable(EditorBrowsableState.Advanced)]
3826 protected virtual void OnEnabledChanged(EventArgs e) {
3827 if (EnabledChanged!=null) EnabledChanged(this, e);
3828 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3831 [EditorBrowsable(EditorBrowsableState.Advanced)]
3832 protected virtual void OnEnter(EventArgs e) {
3833 if (Enter!=null) Enter(this, e);
3836 [EditorBrowsable(EditorBrowsableState.Advanced)]
3837 protected virtual void OnFontChanged(EventArgs e) {
3838 if (FontChanged!=null) FontChanged(this, e);
3839 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3842 [EditorBrowsable(EditorBrowsableState.Advanced)]
3843 protected virtual void OnForeColorChanged(EventArgs e) {
3844 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3845 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3848 [EditorBrowsable(EditorBrowsableState.Advanced)]
3849 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3850 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3853 [EditorBrowsable(EditorBrowsableState.Advanced)]
3854 protected virtual void OnGotFocus(EventArgs e) {
3855 if (GotFocus!=null) GotFocus(this, e);
3858 [EditorBrowsable(EditorBrowsableState.Advanced)]
3859 protected virtual void OnHandleCreated(EventArgs e) {
3860 if (HandleCreated!=null) HandleCreated(this, e);
3863 [EditorBrowsable(EditorBrowsableState.Advanced)]
3864 protected virtual void OnHandleDestroyed(EventArgs e) {
3865 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3868 [EditorBrowsable(EditorBrowsableState.Advanced)]
3869 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3870 if (HelpRequested!=null) HelpRequested(this, hevent);
3873 protected virtual void OnImeModeChanged(EventArgs e) {
3874 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3877 [EditorBrowsable(EditorBrowsableState.Advanced)]
3878 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3879 needs_redraw = true;
3880 if (Invalidated!=null) Invalidated(this, e);
3883 [EditorBrowsable(EditorBrowsableState.Advanced)]
3884 protected virtual void OnKeyDown(KeyEventArgs e) {
3885 if (KeyDown!=null) KeyDown(this, e);
3888 [EditorBrowsable(EditorBrowsableState.Advanced)]
3889 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3890 if (KeyPress!=null) KeyPress(this, e);
3893 [EditorBrowsable(EditorBrowsableState.Advanced)]
3894 protected virtual void OnKeyUp(KeyEventArgs e) {
3895 if (KeyUp!=null) KeyUp(this, e);
3898 [EditorBrowsable(EditorBrowsableState.Advanced)]
3899 protected virtual void OnLayout(LayoutEventArgs levent) {
3900 if (Layout!=null) Layout(this, levent);
3903 [EditorBrowsable(EditorBrowsableState.Advanced)]
3904 protected virtual void OnLeave(EventArgs e) {
3905 if (Leave!=null) Leave(this, e);
3908 [EditorBrowsable(EditorBrowsableState.Advanced)]
3909 protected virtual void OnLocationChanged(EventArgs e) {
3911 if (LocationChanged!=null) LocationChanged(this, e);
3914 [EditorBrowsable(EditorBrowsableState.Advanced)]
3915 protected virtual void OnLostFocus(EventArgs e) {
3916 if (LostFocus!=null) LostFocus(this, e);
3919 [EditorBrowsable(EditorBrowsableState.Advanced)]
3920 protected virtual void OnMouseDown(MouseEventArgs e) {
3921 if (MouseDown!=null) MouseDown(this, e);
3924 [EditorBrowsable(EditorBrowsableState.Advanced)]
3925 protected virtual void OnMouseEnter(EventArgs e) {
3926 if (MouseEnter!=null) MouseEnter(this, e);
3929 [EditorBrowsable(EditorBrowsableState.Advanced)]
3930 protected virtual void OnMouseHover(EventArgs e) {
3931 if (MouseHover!=null) MouseHover(this, e);
3934 [EditorBrowsable(EditorBrowsableState.Advanced)]
3935 protected virtual void OnMouseLeave(EventArgs e) {
3936 if (MouseLeave!=null) MouseLeave(this, e);
3939 [EditorBrowsable(EditorBrowsableState.Advanced)]
3940 protected virtual void OnMouseMove(MouseEventArgs e) {
3941 if (MouseMove!=null) MouseMove(this, e);
3944 [EditorBrowsable(EditorBrowsableState.Advanced)]
3945 protected virtual void OnMouseUp(MouseEventArgs e) {
3946 if (MouseUp!=null) MouseUp(this, e);
3949 [EditorBrowsable(EditorBrowsableState.Advanced)]
3950 protected virtual void OnMouseWheel(MouseEventArgs e) {
3951 if (MouseWheel!=null) MouseWheel(this, e);
3954 [EditorBrowsable(EditorBrowsableState.Advanced)]
3955 protected virtual void OnMove(EventArgs e) {
3956 if (Move!=null) Move(this, e);
3959 [EditorBrowsable(EditorBrowsableState.Advanced)]
3960 protected virtual void OnNotifyMessage(Message m) {
3964 [EditorBrowsable(EditorBrowsableState.Advanced)]
3965 protected virtual void OnPaint(PaintEventArgs e) {
3966 if (Paint!=null) Paint(this, e);
3969 [EditorBrowsable(EditorBrowsableState.Advanced)]
3970 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3971 PaintControlBackground (pevent);
3974 [EditorBrowsable(EditorBrowsableState.Advanced)]
3975 protected virtual void OnParentBackColorChanged(EventArgs e) {
3976 if (background_color.IsEmpty && background_image==null) {
3978 OnBackColorChanged(e);
3982 [EditorBrowsable(EditorBrowsableState.Advanced)]
3983 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3984 if (background_color.IsEmpty && background_image==null) {
3986 OnBackgroundImageChanged(e);
3990 [EditorBrowsable(EditorBrowsableState.Advanced)]
3991 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3992 if (binding_context==null) {
3993 binding_context=Parent.binding_context;
3994 OnBindingContextChanged(e);
3998 [EditorBrowsable(EditorBrowsableState.Advanced)]
3999 protected virtual void OnParentChanged(EventArgs e) {
4000 if (ParentChanged!=null) ParentChanged(this, e);
4003 [EditorBrowsable(EditorBrowsableState.Advanced)]
4004 protected virtual void OnParentEnabledChanged(EventArgs e) {
4005 if (is_enabled != Parent.is_enabled) {
4006 is_enabled=Parent.is_enabled;
4008 if (EnabledChanged != null) {
4009 EnabledChanged(this, e);
4014 [EditorBrowsable(EditorBrowsableState.Advanced)]
4015 protected virtual void OnParentFontChanged(EventArgs e) {
4022 [EditorBrowsable(EditorBrowsableState.Advanced)]
4023 protected virtual void OnParentForeColorChanged(EventArgs e) {
4024 if (foreground_color.IsEmpty) {
4026 OnForeColorChanged(e);
4030 [EditorBrowsable(EditorBrowsableState.Advanced)]
4031 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4032 if (right_to_left==RightToLeft.Inherit) {
4034 OnRightToLeftChanged(e);
4038 [EditorBrowsable(EditorBrowsableState.Advanced)]
4039 protected virtual void OnParentVisibleChanged(EventArgs e) {
4041 OnVisibleChanged(e);
4045 [EditorBrowsable(EditorBrowsableState.Advanced)]
4046 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4047 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
4050 [EditorBrowsable(EditorBrowsableState.Advanced)]
4051 protected virtual void OnResize(EventArgs e) {
4052 if (Resize!=null) Resize(this, e);
4054 PerformLayout(this, "bounds");
4056 if (parent != null) {
4057 parent.PerformLayout();
4061 [EditorBrowsable(EditorBrowsableState.Advanced)]
4062 protected virtual void OnRightToLeftChanged(EventArgs e) {
4063 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
4064 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4067 [EditorBrowsable(EditorBrowsableState.Advanced)]
4068 protected virtual void OnSizeChanged(EventArgs e) {
4069 InvalidateBuffers ();
4071 if (SizeChanged!=null) SizeChanged(this, e);
4074 [EditorBrowsable(EditorBrowsableState.Advanced)]
4075 protected virtual void OnStyleChanged(EventArgs e) {
4076 if (StyleChanged!=null) StyleChanged(this, e);
4079 [EditorBrowsable(EditorBrowsableState.Advanced)]
4080 protected virtual void OnSystemColorsChanged(EventArgs e) {
4081 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
4084 [EditorBrowsable(EditorBrowsableState.Advanced)]
4085 protected virtual void OnTabIndexChanged(EventArgs e) {
4086 if (TabIndexChanged!=null) TabIndexChanged(this, e);
4089 [EditorBrowsable(EditorBrowsableState.Advanced)]
4090 protected virtual void OnTabStopChanged(EventArgs e) {
4091 if (TabStopChanged!=null) TabStopChanged(this, e);
4094 [EditorBrowsable(EditorBrowsableState.Advanced)]
4095 protected virtual void OnTextChanged(EventArgs e) {
4096 if (TextChanged!=null) TextChanged(this, e);
4099 [EditorBrowsable(EditorBrowsableState.Advanced)]
4100 protected virtual void OnValidated(EventArgs e) {
4101 if (Validated!=null) Validated(this, e);
4104 [EditorBrowsable(EditorBrowsableState.Advanced)]
4105 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4106 if (Validating!=null) Validating(this, e);
4109 [EditorBrowsable(EditorBrowsableState.Advanced)]
4110 protected virtual void OnVisibleChanged(EventArgs e) {
4117 if (bmp_mem!=null) {
4123 if (!this.IsHandleCreated) {
4124 this.CreateControl();
4130 if (VisibleChanged!=null) VisibleChanged(this, e);
4132 // We need to tell our kids
4133 for (int i=0; i<child_controls.Count; i++) {
4134 child_controls[i].OnParentVisibleChanged(e);
4137 #endregion // OnXXX methods
4140 public event EventHandler BackColorChanged;
4141 public event EventHandler BackgroundImageChanged;
4142 public event EventHandler BindingContextChanged;
4143 public event EventHandler CausesValidationChanged;
4144 public event UICuesEventHandler ChangeUICues;
4145 public event EventHandler Click;
4146 public event EventHandler ContextMenuChanged;
4148 [EditorBrowsable(EditorBrowsableState.Advanced)]
4150 public event ControlEventHandler ControlAdded;
4152 [EditorBrowsable(EditorBrowsableState.Advanced)]
4154 public event ControlEventHandler ControlRemoved;
4156 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4157 public event EventHandler CursorChanged;
4158 public event EventHandler DockChanged;
4159 public event EventHandler DoubleClick;
4160 public event DragEventHandler DragDrop;
4161 public event DragEventHandler DragEnter;
4162 public event EventHandler DragLeave;
4163 public event DragEventHandler DragOver;
4164 public event EventHandler EnabledChanged;
4165 public event EventHandler Enter;
4166 public event EventHandler FontChanged;
4167 public event EventHandler ForeColorChanged;
4168 public event GiveFeedbackEventHandler GiveFeedback;
4170 [EditorBrowsable(EditorBrowsableState.Advanced)]
4172 public event EventHandler GotFocus;
4174 [EditorBrowsable(EditorBrowsableState.Advanced)]
4176 public event EventHandler HandleCreated;
4178 [EditorBrowsable(EditorBrowsableState.Advanced)]
4180 public event EventHandler HandleDestroyed;
4182 public event HelpEventHandler HelpRequested;
4183 public event EventHandler ImeModeChanged;
4185 [EditorBrowsable(EditorBrowsableState.Advanced)]
4187 public event InvalidateEventHandler Invalidated;
4189 public event KeyEventHandler KeyDown;
4190 public event KeyPressEventHandler KeyPress;
4191 public event KeyEventHandler KeyUp;
4192 public event LayoutEventHandler Layout;
4193 public event EventHandler Leave;
4194 public event EventHandler LocationChanged;
4196 [EditorBrowsable(EditorBrowsableState.Advanced)]
4198 public event EventHandler LostFocus;
4200 public event MouseEventHandler MouseDown;
4201 public event EventHandler MouseEnter;
4202 public event EventHandler MouseHover;
4203 public event EventHandler MouseLeave;
4204 public event MouseEventHandler MouseMove;
4205 public event MouseEventHandler MouseUp;
4207 [EditorBrowsable(EditorBrowsableState.Advanced)]
4209 public event MouseEventHandler MouseWheel;
4211 public event EventHandler Move;
4212 public event PaintEventHandler Paint;
4213 public event EventHandler ParentChanged;
4214 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
4215 public event QueryContinueDragEventHandler QueryContinueDrag;
4216 public event EventHandler Resize;
4217 public event EventHandler RightToLeftChanged;
4218 public event EventHandler SizeChanged;
4219 public event EventHandler StyleChanged;
4220 public event EventHandler SystemColorsChanged;
4221 public event EventHandler TabIndexChanged;
4222 public event EventHandler TabStopChanged;
4223 public event EventHandler TextChanged;
4224 public event EventHandler Validated;
4225 public event CancelEventHandler Validating;
4226 public event EventHandler VisibleChanged;
4227 #endregion // Events