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 internal 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 virtual 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 virtual 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, null, 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);
797 internal void PointToClient (ref int x, ref int y)
799 XplatUI.ScreenToClient (Handle, ref x, ref y);
802 internal void PointToScreen (ref int x, ref int y)
804 XplatUI.ClientToScreen (Handle, ref x, ref y);
807 internal Graphics DeviceContext {
810 CreateBuffers(this.Width, this.Height);
816 private Bitmap ImageBuffer {
819 CreateBuffers(this.Width, this.Height);
825 internal void CreateBuffers (int width, int height) {
826 if (dc_mem != null) {
840 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
841 dc_mem = Graphics.FromImage (bmp_mem);
845 internal void InvalidateBuffers ()
847 if (dc_mem != null) {
858 internal static void SetChildColor(Control parent) {
861 for (int i=0; i < parent.child_controls.Count; i++) {
862 child=parent.child_controls[i];
863 if (child.child_controls.Count>0) {
864 SetChildColor(child);
870 internal bool Select(Control control) {
872 IContainerControl container;
874 if (control == null) {
878 parent = control.parent;
880 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
881 while (parent != null) {
882 if (!parent.Visible || !parent.is_enabled) {
885 parent = parent.parent;
889 control.is_selected = true;
891 container = GetContainerControl();
892 if (container != null) {
893 container.ActiveControl = control;
895 if (control.IsHandleCreated) {
896 XplatUI.SetFocus(control.window.Handle);
901 internal virtual void DoDefaultAction() {
902 // Only here to be overriden by our actual controls; this is needed by the accessibility class
905 internal static int LowOrder (int param) {
906 return ((int)(short)(param & 0xffff));
909 internal static int HighOrder (int param) {
910 return ((int)(short)(param >> 16));
913 // This method exists so controls overriding OnPaintBackground can have default background painting done
914 internal virtual void PaintControlBackground (PaintEventArgs pevent)
916 if (background_image == null) {
917 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));
921 DrawBackgroundImage (pevent.Graphics);
924 void DrawBackgroundImage (Graphics g)
926 using (TextureBrush b = new TextureBrush (background_image)) {
927 g.FillRectangle (b, ClientRectangle);
931 internal virtual void DndEnter (DragEventArgs e)
938 internal virtual void DndOver (DragEventArgs e)
945 internal virtual void DndDrop (DragEventArgs e)
949 } catch (Exception exc) {
950 Console.Error.WriteLine ("MWF: Exception while dropping:");
951 Console.Error.WriteLine (exc);
955 internal virtual void DndLeave (EventArgs e)
962 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
969 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
972 OnQueryContinueDrag(e);
976 internal static MouseButtons FromParamToMouseButtons (int param) {
977 MouseButtons buttons = MouseButtons.None;
979 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
980 buttons |= MouseButtons.Left;
982 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
983 buttons |= MouseButtons.Middle;
985 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
986 buttons |= MouseButtons.Right;
992 internal virtual bool ProcessControlMnemonic(char charCode) {
993 return ProcessMnemonic(charCode);
996 private static Control FindFlatForward(Control container, Control start) {
1002 end = container.child_controls.Count;
1004 if (start != null) {
1005 index = start.tab_index;
1010 for (int i = 0; i < end; i++) {
1011 if (found == null) {
1012 if (container.child_controls[i].tab_index > index) {
1013 found = container.child_controls[i];
1015 } else if (found.tab_index > container.child_controls[i].tab_index) {
1016 if (container.child_controls[i].tab_index > index) {
1017 found = container.child_controls[i];
1024 private static Control FindControlForward(Control container, Control start) {
1030 if (start != null) {
1031 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
1032 found = FindControlForward(start, null);
1033 if (found != null) {
1039 while (p != container) {
1040 found = FindFlatForward(p, start);
1041 if (found != null) {
1048 return FindFlatForward(container, start);
1051 private static Control FindFlatBackward(Control container, Control start) {
1057 end = container.child_controls.Count;
1059 if (start != null) {
1060 index = start.tab_index;
1062 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1064 for (int i = 0; i < end; i++) {
1065 if (container.child_controls[i].tab_index > index) {
1066 index = container.child_controls[i].tab_index;
1072 for (int i = 0; i < end; i++) {
1073 if (found == null) {
1074 if (container.child_controls[i].tab_index < index) {
1075 found = container.child_controls[i];
1077 } else if (found.tab_index < container.child_controls[i].tab_index) {
1078 if (container.child_controls[i].tab_index < index) {
1079 found = container.child_controls[i];
1086 private static Control FindControlBackward(Control container, Control start) {
1091 if (start != null) {
1092 found = FindFlatBackward(start.parent, start);
1093 if (found == null && start.parent != container) {
1094 return start.parent;
1097 if (found == null) {
1098 found = FindFlatBackward(container, start);
1101 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
1102 found = FindControlBackward(found, null);
1103 if (found != null) {
1111 private void HandleClick(int clicks) {
1112 if (GetStyle(ControlStyles.StandardClick)) {
1114 if (GetStyle(ControlStyles.StandardDoubleClick)) {
1115 OnDoubleClick(EventArgs.Empty);
1117 OnClick(EventArgs.Empty);
1120 OnClick(EventArgs.Empty);
1125 private void CheckDataBindings ()
1127 if (data_bindings == null)
1130 BindingContext binding_context = BindingContext;
1131 foreach (Binding binding in data_bindings) {
1132 binding.Check (binding_context);
1135 #endregion // Private & Internal Methods
1137 #region Public Static Properties
1138 public static Color DefaultBackColor {
1140 return ThemeEngine.Current.DefaultControlBackColor;
1144 public static Font DefaultFont {
1146 return ThemeEngine.Current.DefaultFont;
1150 public static Color DefaultForeColor {
1152 return ThemeEngine.Current.DefaultControlForeColor;
1156 public static Keys ModifierKeys {
1158 return XplatUI.State.ModifierKeys;
1162 public static MouseButtons MouseButtons {
1164 return XplatUI.State.MouseButtons;
1168 public static Point MousePosition {
1170 return Cursor.Position;
1176 public static bool CheckForIllegalCrossThreadCalls
1185 #endregion // Public Static Properties
1187 #region Public Instance Properties
1188 [EditorBrowsable(EditorBrowsableState.Advanced)]
1190 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1191 public AccessibleObject AccessibilityObject {
1193 if (accessibility_object==null) {
1194 accessibility_object=CreateAccessibilityInstance();
1196 return accessibility_object;
1200 [EditorBrowsable(EditorBrowsableState.Advanced)]
1202 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1203 public string AccessibleDefaultActionDescription {
1205 return AccessibilityObject.default_action;
1209 AccessibilityObject.default_action=value;
1214 [DefaultValue(null)]
1215 public string AccessibleDescription {
1217 return AccessibilityObject.description;
1221 AccessibilityObject.description=value;
1226 [DefaultValue(null)]
1227 public string AccessibleName {
1229 return AccessibilityObject.Name;
1233 AccessibilityObject.Name=value;
1237 [DefaultValue(AccessibleRole.Default)]
1238 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1239 public AccessibleRole AccessibleRole {
1241 return AccessibilityObject.role;
1245 AccessibilityObject.role=value;
1249 [DefaultValue(false)]
1250 public virtual bool AllowDrop {
1256 if (allow_drop == value)
1260 XplatUI.SetAllowDrop (Handle, value);
1265 [RefreshProperties(RefreshProperties.Repaint)]
1266 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1267 public virtual AnchorStyles Anchor {
1269 return anchor_style;
1275 if (parent != null) {
1276 parent.PerformLayout(this, "Parent");
1282 public virtual Color BackColor {
1284 if (background_color.IsEmpty) {
1286 return parent.BackColor;
1288 return DefaultBackColor;
1290 return background_color;
1294 background_color=value;
1295 SetChildColor(this);
1296 OnBackColorChanged(EventArgs.Empty);
1302 [DefaultValue(null)]
1303 public virtual Image BackgroundImage {
1305 return background_image;
1309 if (background_image!=value) {
1310 background_image=value;
1311 OnBackgroundImageChanged(EventArgs.Empty);
1316 [EditorBrowsable(EditorBrowsableState.Advanced)]
1318 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1319 public virtual BindingContext BindingContext {
1321 if (binding_context != null)
1322 return binding_context;
1325 binding_context = Parent.BindingContext;
1326 return binding_context;
1329 if (binding_context != value) {
1330 binding_context = value;
1331 OnBindingContextChanged(EventArgs.Empty);
1336 [EditorBrowsable(EditorBrowsableState.Advanced)]
1338 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1341 return bounds.Y+bounds.Height;
1345 [EditorBrowsable(EditorBrowsableState.Advanced)]
1347 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1348 public Rectangle Bounds {
1354 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1358 [EditorBrowsable(EditorBrowsableState.Advanced)]
1360 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1361 public bool CanFocus {
1363 if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1370 [EditorBrowsable(EditorBrowsableState.Advanced)]
1372 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1373 public bool CanSelect {
1377 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1381 parent = this.parent;
1382 while (parent != null) {
1383 if (!parent.is_visible || !parent.is_enabled) {
1387 parent = parent.parent;
1393 [EditorBrowsable(EditorBrowsableState.Advanced)]
1395 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1396 public bool Capture {
1398 return this.is_captured;
1402 if (this.IsHandleCreated) {
1403 if (value && !is_captured) {
1405 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1406 } else if (!value && is_captured) {
1407 XplatUI.UngrabWindow(this.window.Handle);
1408 is_captured = false;
1414 [DefaultValue(true)]
1415 public bool CausesValidation {
1417 return this.causes_validation;
1421 if (this.causes_validation != value) {
1422 causes_validation = value;
1423 OnCausesValidationChanged(EventArgs.Empty);
1428 [EditorBrowsable(EditorBrowsableState.Advanced)]
1430 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1431 public Rectangle ClientRectangle {
1433 client_rect.Width = client_size.Width;
1434 client_rect.Height = client_size.Height;
1439 [EditorBrowsable(EditorBrowsableState.Advanced)]
1441 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1442 public Size ClientSize {
1445 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1446 return ((Form)this).form_parent_window.ClientSize;
1454 this.SetClientSizeCore(value.Width, value.Height);
1458 [EditorBrowsable(EditorBrowsableState.Advanced)]
1460 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1461 [DescriptionAttribute("ControlCompanyNameDescr")]
1462 public String CompanyName {
1464 return "Mono Project, Novell, Inc.";
1468 [EditorBrowsable(EditorBrowsableState.Advanced)]
1470 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1471 public bool ContainsFocus {
1477 for (int i=0; i < child_controls.Count; i++) {
1478 if (child_controls[i].ContainsFocus) {
1486 [DefaultValue(null)]
1487 public virtual ContextMenu ContextMenu {
1489 return context_menu;
1493 if (context_menu != value) {
1494 context_menu = value;
1495 OnContextMenuChanged(EventArgs.Empty);
1501 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1502 public ControlCollection Controls {
1504 return this.child_controls;
1508 [EditorBrowsable(EditorBrowsableState.Advanced)]
1510 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1511 public bool Created {
1513 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1520 [AmbientValue(null)]
1521 public virtual Cursor Cursor {
1523 if (cursor != null) {
1527 if (parent != null) {
1528 return parent.Cursor;
1531 return Cursors.Default;
1535 if (cursor != value) {
1540 pt = Cursor.Position;
1541 if (bounds.Contains(pt)) {
1542 if (GetChildAtPoint(pt) == null) {
1543 if (cursor != null) {
1544 XplatUI.SetCursor(window.Handle, cursor.handle);
1546 if (parent != null) {
1547 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1549 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1555 OnCursorChanged(EventArgs.Empty);
1561 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1562 [ParenthesizePropertyName(true)]
1563 [RefreshProperties(RefreshProperties.All)]
1564 public ControlBindingsCollection DataBindings {
1566 if (data_bindings == null)
1567 data_bindings = new ControlBindingsCollection (this);
1568 return data_bindings;
1572 [EditorBrowsable(EditorBrowsableState.Advanced)]
1574 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1575 public virtual Rectangle DisplayRectangle {
1577 return ClientRectangle;
1581 [EditorBrowsable(EditorBrowsableState.Advanced)]
1583 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1584 public bool Disposing {
1591 [RefreshProperties(RefreshProperties.Repaint)]
1592 [DefaultValue(DockStyle.None)]
1593 public virtual DockStyle Dock {
1599 if (dock_style == value) {
1605 if (parent != null) {
1606 parent.PerformLayout(this, "Parent");
1609 OnDockChanged(EventArgs.Empty);
1615 public bool Enabled {
1621 if (is_enabled == value) {
1627 OnEnabledChanged (EventArgs.Empty);
1631 [EditorBrowsable(EditorBrowsableState.Advanced)]
1633 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1634 public virtual bool Focused {
1636 return this.has_focus;
1641 [AmbientValue(null)]
1643 public virtual Font Font {
1649 if (Parent != null && Parent.Font != null) {
1657 if (font != null && font.Equals (value)) {
1663 OnFontChanged (EventArgs.Empty);
1668 public virtual Color ForeColor {
1670 if (foreground_color.IsEmpty) {
1672 return parent.ForeColor;
1674 return DefaultForeColor;
1676 return foreground_color;
1680 if (foreground_color != value) {
1681 foreground_color=value;
1683 OnForeColorChanged(EventArgs.Empty);
1690 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1691 public IntPtr Handle { // IWin32Window
1693 if (!IsHandleCreated) {
1696 return window.Handle;
1700 [EditorBrowsable(EditorBrowsableState.Advanced)]
1702 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1703 public bool HasChildren {
1705 if (this.child_controls.Count>0) {
1712 [EditorBrowsable(EditorBrowsableState.Always)]
1714 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1717 return this.bounds.Height;
1721 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1725 [AmbientValue(ImeMode.Inherit)]
1727 public ImeMode ImeMode {
1729 if (ime_mode == DefaultImeMode) {
1731 return parent.ImeMode;
1733 return ImeMode.NoControl; // default value
1739 if (ime_mode != value) {
1742 OnImeModeChanged(EventArgs.Empty);
1747 [EditorBrowsable(EditorBrowsableState.Advanced)]
1749 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1750 public bool InvokeRequired { // ISynchronizeInvoke
1752 if (creator_thread!=Thread.CurrentThread) {
1759 [EditorBrowsable(EditorBrowsableState.Advanced)]
1761 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1762 public bool IsAccessible {
1764 return is_accessible;
1768 is_accessible = value;
1772 [EditorBrowsable(EditorBrowsableState.Advanced)]
1774 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1775 public bool IsDisposed {
1777 return this.is_disposed;
1781 [EditorBrowsable(EditorBrowsableState.Advanced)]
1783 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1784 public bool IsHandleCreated {
1786 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1794 [EditorBrowsable(EditorBrowsableState.Always)]
1796 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1799 return this.bounds.X;
1803 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1808 public Point Location {
1810 return new Point(bounds.X, bounds.Y);
1814 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1819 public string Name {
1830 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1831 public Control Parent {
1837 if (value == this) {
1838 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1841 if (parent!=value) {
1843 parent.Controls.Remove(this);
1849 if (!parent.Controls.AllContains (this)) {
1850 Console.WriteLine ("Adding child: " + this);
1851 parent.Controls.Add(this);
1854 if (IsHandleCreated) {
1855 XplatUI.SetParent(Handle, value.Handle);
1858 OnParentChanged(EventArgs.Empty);
1864 [EditorBrowsable(EditorBrowsableState.Advanced)]
1866 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1867 public string ProductName {
1869 Type t = typeof (AssemblyProductAttribute);
1870 Assembly assembly = GetType().Module.Assembly;
1871 object [] attrs = assembly.GetCustomAttributes (t, false);
1872 AssemblyProductAttribute a = null;
1873 // On MS we get a NullRefException if product attribute is not
1875 if (attrs != null && attrs.Length > 0)
1876 a = (AssemblyProductAttribute) attrs [0];
1881 [EditorBrowsable(EditorBrowsableState.Advanced)]
1883 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1884 public string ProductVersion {
1886 Type t = typeof (AssemblyVersionAttribute);
1887 Assembly assembly = GetType().Module.Assembly;
1888 object [] attrs = assembly.GetCustomAttributes (t, false);
1889 if (attrs == null || attrs.Length < 1)
1891 return ((AssemblyVersionAttribute)attrs [0]).Version;
1895 [EditorBrowsable(EditorBrowsableState.Advanced)]
1897 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1898 public bool RecreatingHandle {
1900 return is_recreating;
1904 [EditorBrowsable(EditorBrowsableState.Advanced)]
1906 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1907 public Region Region {
1909 return new Region(this.bounds);
1916 g = this.CreateGraphics();
1917 r = value.GetBounds(g);
1919 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1925 [EditorBrowsable(EditorBrowsableState.Advanced)]
1927 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1930 return this.bounds.X+this.bounds.Width;
1934 [AmbientValue(RightToLeft.Inherit)]
1936 public virtual RightToLeft RightToLeft {
1938 if (right_to_left == RightToLeft.Inherit) {
1940 return parent.RightToLeft;
1942 return RightToLeft.No; // default value
1944 return right_to_left;
1948 if (value != right_to_left) {
1949 right_to_left = value;
1950 OnRightToLeftChanged(EventArgs.Empty);
1955 [EditorBrowsable(EditorBrowsableState.Advanced)]
1956 public override ISite Site {
1969 return new Size(Width, Height);
1973 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1978 [MergableProperty(false)]
1979 public int TabIndex {
1981 if (tab_index != -1) {
1988 if (tab_index != value) {
1990 OnTabIndexChanged(EventArgs.Empty);
1996 [DefaultValue(true)]
1997 public bool TabStop {
2003 if (tab_stop != value) {
2005 OnTabStopChanged(EventArgs.Empty);
2010 [Localizable(false)]
2012 [TypeConverter(typeof(StringConverter))]
2013 [DefaultValue(null)]
2020 control_tag = value;
2026 [BindableAttribute(true)]
2027 public virtual string Text {
2029 // Our implementation ignores ControlStyles.CacheText - we always cache
2034 if (value == null) {
2035 value = String.Empty;
2040 if (IsHandleCreated) {
2041 XplatUI.Text(Handle, text);
2043 OnTextChanged (EventArgs.Empty);
2048 [EditorBrowsable(EditorBrowsableState.Always)]
2050 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2053 return this.bounds.Y;
2057 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2061 [EditorBrowsable(EditorBrowsableState.Advanced)]
2063 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2064 public Control TopLevelControl {
2068 while (p.parent != null) {
2077 public bool Visible {
2081 } else if (parent != null) {
2082 return parent.Visible;
2089 SetVisibleCore(value);
2093 [EditorBrowsable(EditorBrowsableState.Always)]
2095 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2098 return this.bounds.Width;
2102 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2106 [EditorBrowsable(EditorBrowsableState.Never)]
2108 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2109 public IWindowTarget WindowTarget {
2118 #endregion // Public Instance Properties
2120 #region Protected Instance Properties
2121 protected virtual CreateParams CreateParams {
2123 CreateParams create_params = new CreateParams();
2126 create_params.Caption = Text;
2129 create_params.Caption = text;
2133 create_params.X = Left;
2136 create_params.X = this.bounds.X;
2140 create_params.Y = Top;
2143 create_params.Y = this.bounds.Y;
2147 create_params.Width = Width;
2150 create_params.Width = this.bounds.Width;
2154 create_params.Height = Height;
2157 create_params.Height = this.bounds.Height;
2161 create_params.ClassName = XplatUI.DefaultClassName;
2162 create_params.ClassStyle = 0;
2163 create_params.ExStyle = 0;
2164 create_params.Param = 0;
2167 create_params.ExStyle |= (int)WindowStyles.WS_EX_ACCEPTFILES;
2171 create_params.Parent = parent.Handle;
2174 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2177 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2180 switch (border_style) {
2181 case BorderStyle.FixedSingle:
2182 create_params.Style |= (int) WindowStyles.WS_BORDER;
2184 case BorderStyle.Fixed3D:
2185 create_params.ExStyle |= (int) WindowStyles.WS_EX_CLIENTEDGE;
2189 return create_params;
2193 protected virtual ImeMode DefaultImeMode {
2195 return ImeMode.Inherit;
2199 protected virtual Size DefaultSize {
2201 return new Size(100, 23);
2205 protected int FontHeight {
2215 protected bool RenderRightToLeft {
2217 return (this.right_to_left == RightToLeft.Yes);
2221 protected bool ResizeRedraw {
2223 return GetStyle(ControlStyles.ResizeRedraw);
2227 SetStyle(ControlStyles.ResizeRedraw, value);
2231 [EditorBrowsable(EditorBrowsableState.Advanced)]
2233 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2234 protected virtual bool ShowFocusCues {
2240 [EditorBrowsable(EditorBrowsableState.Advanced)]
2242 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2243 protected bool ShowKeyboardCues {
2248 #endregion // Protected Instance Properties
2250 #region Public Static Methods
2251 [EditorBrowsable(EditorBrowsableState.Advanced)]
2252 public static Control FromChildHandle(IntPtr handle) {
2253 IEnumerator control = Control.controls.GetEnumerator();
2255 while (control.MoveNext()) {
2256 if (((Control)control.Current).window.Handle == handle) {
2258 if (((Control)control.Current).Parent != null) {
2259 return ((Control)control.Current).Parent;
2266 [EditorBrowsable(EditorBrowsableState.Advanced)]
2267 public static Control FromHandle(IntPtr handle) {
2268 IEnumerator control = Control.controls.GetEnumerator();
2270 while (control.MoveNext()) {
2271 if (((Control)control.Current).window.Handle == handle) {
2273 return ((Control)control.Current);
2279 public static bool IsMnemonic(char charCode, string text) {
2282 amp = text.IndexOf('&');
2285 if (amp + 1 < text.Length) {
2286 if (text[amp + 1] != '&') {
2287 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2297 #region Protected Static Methods
2298 [EditorBrowsable(EditorBrowsableState.Advanced)]
2299 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2302 c = Control.FromHandle(hWnd);
2312 #region Public Instance Methods
2313 [EditorBrowsable(EditorBrowsableState.Advanced)]
2314 public IAsyncResult BeginInvoke(Delegate method) {
2315 return BeginInvokeInternal(method, null);
2318 [EditorBrowsable(EditorBrowsableState.Advanced)]
2319 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2320 return BeginInvokeInternal (method, args);
2323 public void BringToFront() {
2324 if ((parent != null) && (parent.child_controls[0]!=this)) {
2325 if (parent.child_controls.Contains(this)) {
2326 parent.child_controls.SetChildIndex(this, 0);
2330 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
2332 if (parent != null) {
2337 public bool Contains(Control ctl) {
2338 while (ctl != null) {
2347 public void CreateControl() {
2349 if (!IsHandleCreated) {
2353 if (!create_handled) {
2354 create_handled = true;
2358 Control [] controls = child_controls.GetAllControls ();
2359 for (int i=0; i<controls.Length; i++) {
2360 controls [i].CreateControl ();
2364 public Graphics CreateGraphics() {
2365 if (!IsHandleCreated) {
2366 this.CreateControl();
2368 return Graphics.FromHwnd(this.window.Handle);
2371 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2372 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2375 [EditorBrowsable(EditorBrowsableState.Advanced)]
2376 public object EndInvoke (IAsyncResult async_result) {
2377 AsyncMethodResult result = (AsyncMethodResult) async_result;
2378 return result.EndInvoke ();
2381 public Form FindForm() {
2394 public bool Focus() {
2395 if (IsHandleCreated && !has_focus) {
2397 XplatUI.SetFocus(window.Handle);
2402 public Control GetChildAtPoint(Point pt) {
2403 // Microsoft's version of this function doesn't seem to work, so I can't check
2404 // if we only consider children or also grandchildren, etc.
2405 // I'm gonna say 'children only'
2406 for (int i=0; i<child_controls.Count; i++) {
2407 if (child_controls[i].Bounds.Contains(pt)) {
2408 return child_controls[i];
2414 public IContainerControl GetContainerControl() {
2415 Control current = this;
2417 while (current!=null) {
2418 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2419 return (IContainerControl)current;
2421 current = current.parent;
2426 public Control GetNextControl(Control ctl, bool forward) {
2427 // If we're not a container we don't play
2428 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2432 // If ctl is not contained by this, we start at the first child of this
2433 if (!this.Contains(ctl)) {
2437 // Search through our controls, starting at ctl, stepping into children as we encounter them
2438 // try to find the control with the tabindex closest to our own, or, if we're looking into
2439 // child controls, the one with the smallest tabindex
2441 return FindControlForward(this, ctl);
2443 return FindControlBackward(this, ctl);
2446 public void Hide() {
2447 this.Visible = false;
2450 public void Invalidate() {
2451 Invalidate(ClientRectangle, false);
2454 public void Invalidate(bool invalidateChildren) {
2455 Invalidate(ClientRectangle, invalidateChildren);
2458 public void Invalidate(System.Drawing.Rectangle rc) {
2459 Invalidate(rc, false);
2462 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2463 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2467 NotifyInvalidate(rc);
2469 XplatUI.Invalidate(Handle, rc, false);
2471 if (invalidateChildren) {
2472 Control [] controls = child_controls.GetAllControls ();
2473 for (int i=0; i<controls.Length; i++)
2474 controls [i].Invalidate ();
2476 OnInvalidated(new InvalidateEventArgs(rc));
2479 public void Invalidate(System.Drawing.Region region) {
2480 Invalidate(region, false);
2483 [MonoTODO("Figure out if GetRegionScans is usable")]
2484 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2485 throw new NotImplementedException();
2487 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2488 //if (invalidateChildren) {
2489 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2493 public object Invoke (Delegate method) {
2494 return Invoke(method, null);
2497 public object Invoke (Delegate method, object[] args) {
2498 if (!this.InvokeRequired) {
2499 return method.DynamicInvoke(args);
2502 IAsyncResult result = BeginInvoke (method, args);
2503 return EndInvoke(result);
2506 [EditorBrowsable(EditorBrowsableState.Advanced)]
2507 public void PerformLayout() {
2508 PerformLayout(null, null);
2511 [EditorBrowsable(EditorBrowsableState.Advanced)]
2512 public void PerformLayout(Control affectedControl, string affectedProperty) {
2513 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2515 if (layout_suspended > 0) {
2516 layout_pending = true;
2520 layout_pending = false;
2522 // Prevent us from getting messed up
2525 // Perform all Dock and Anchor calculations
2528 AnchorStyles anchor;
2531 space=this.DisplayRectangle;
2533 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2534 Control [] controls = child_controls.GetAllControls ();
2535 for (int i = controls.Length - 1; i >= 0; i--) {
2536 child = controls [i];
2537 switch (child.Dock) {
2538 case DockStyle.None: {
2543 case DockStyle.Left: {
2544 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2545 space.X+=child.Width;
2546 space.Width-=child.Width;
2550 case DockStyle.Top: {
2551 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2552 space.Y+=child.Height;
2553 space.Height-=child.Height;
2557 case DockStyle.Right: {
2558 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2559 space.Width-=child.Width;
2563 case DockStyle.Bottom: {
2564 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2565 space.Height-=child.Height;
2571 for (int i = controls.Length - 1; i >= 0; i--) {
2574 if (child.Dock == DockStyle.Fill) {
2575 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2581 space=this.DisplayRectangle;
2583 for (int i=0; i < controls.Length; i++) {
2589 child = controls[i];
2590 anchor = child.Anchor;
2594 width = child.Width;
2595 height = child.Height;
2597 // If the control is docked we don't need to do anything
2598 if (child.Dock != DockStyle.None) {
2602 if ((anchor & AnchorStyles.Left) !=0 ) {
2603 if ((anchor & AnchorStyles.Right) != 0) {
2604 width = client_size.Width - child.dist_right - left;
2606 ; // Left anchored only, nothing to be done
2608 } else if ((anchor & AnchorStyles.Right) != 0) {
2609 left = client_size.Width - child.dist_right - width;
2611 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
2612 // This calculates from scratch every time:
2613 left = child.dist_left + (client_size.Width - (child.dist_left + width + child.dist_right)) / 2;
2616 if ((anchor & AnchorStyles.Top) !=0 ) {
2617 if ((anchor & AnchorStyles.Bottom) != 0) {
2618 height = client_size.Height - child.dist_bottom - top;
2620 ; // Top anchored only, nothing to be done
2622 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2623 top = client_size.Height - child.dist_bottom - height;
2625 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
2626 // This calculates from scratch every time:
2627 top = child.dist_top + (client_size.Height - (child.dist_top + height + child.dist_bottom)) / 2;
2639 child.SetBounds(left, top, width, height);
2642 // Let everyone know
2646 // Need to make sure we decremend layout_suspended
2652 public Point PointToClient (Point p) {
2656 XplatUI.ScreenToClient (Handle, ref x, ref y);
2658 return new Point (x, y);
2661 public Point PointToScreen(Point p) {
2665 XplatUI.ClientToScreen(Handle, ref x, ref y);
2667 return new Point(x, y);
2670 public virtual bool PreProcessMessage(ref Message msg) {
2673 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
2674 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
2676 if (!ProcessCmdKey(ref msg, key_data)) {
2677 if (IsInputKey(key_data)) {
2681 return ProcessDialogKey(key_data);
2685 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2686 if (IsInputChar((char)msg.WParam)) {
2689 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
2690 if (IsInputChar((char)msg.WParam)) {
2693 return ProcessDialogChar((char)msg.WParam);
2698 public Rectangle RectangleToClient(Rectangle r) {
2699 return new Rectangle(PointToClient(r.Location), r.Size);
2702 public Rectangle RectangleToScreen(Rectangle r) {
2703 return new Rectangle(PointToScreen(r.Location), r.Size);
2706 public virtual void Refresh() {
2707 if (IsHandleCreated == true) {
2710 XplatUI.UpdateWindow(window.Handle);
2712 Control [] controls = child_controls.GetAllControls ();
2713 for (int i=0; i < controls.Length; i++) {
2714 controls[i].Refresh();
2720 [EditorBrowsable(EditorBrowsableState.Never)]
2721 public virtual void ResetBackColor() {
2722 background_color = Color.Empty;
2725 [EditorBrowsable(EditorBrowsableState.Never)]
2727 public void ResetBindings() {
2731 [EditorBrowsable(EditorBrowsableState.Never)]
2732 public virtual void ResetCursor() {
2736 [EditorBrowsable(EditorBrowsableState.Never)]
2737 public virtual void ResetFont() {
2741 [EditorBrowsable(EditorBrowsableState.Never)]
2742 public virtual void ResetForeColor() {
2743 foreground_color = Color.Empty;
2746 [EditorBrowsable(EditorBrowsableState.Never)]
2747 public void ResetImeMode() {
2748 ime_mode = DefaultImeMode;
2751 [EditorBrowsable(EditorBrowsableState.Never)]
2752 public virtual void ResetRightToLeft() {
2753 right_to_left = RightToLeft.Inherit;
2756 public virtual void ResetText() {
2757 text = String.Empty;
2760 public void ResumeLayout() {
2761 ResumeLayout (true);
2764 public void ResumeLayout(bool performLayout) {
2767 if (layout_suspended > 0) {
2771 if (performLayout || layout_pending) {
2776 public void Scale(float ratio) {
2777 ScaleCore(ratio, ratio);
2780 public void Scale(float dx, float dy) {
2784 public void Select() {
2785 Select(false, false);
2788 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2793 c = GetNextControl(c, forward);
2802 if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
2806 } while (c != ctl); // If we wrap back to ourselves we stop
2811 public void SendToBack() {
2812 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2813 if (parent.child_controls.Contains(this)) {
2814 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2818 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2819 if (parent != null) {
2824 public void SetBounds(int x, int y, int width, int height) {
2825 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2828 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2829 SetBoundsCore(x, y, width, height, specified);
2832 public void Show() {
2833 if (!IsHandleCreated) {
2834 this.CreateControl();
2840 public void SuspendLayout() {
2844 public void Update() {
2845 needs_redraw = true;
2846 if (IsHandleCreated) {
2847 XplatUI.UpdateWindow(window.Handle);
2850 #endregion // Public Instance Methods
2852 #region Protected Instance Methods
2853 [EditorBrowsable(EditorBrowsableState.Advanced)]
2854 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2855 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2856 throw new NotImplementedException();
2859 [EditorBrowsable(EditorBrowsableState.Advanced)]
2860 protected virtual AccessibleObject CreateAccessibilityInstance() {
2861 return new Control.ControlAccessibleObject(this);
2864 [EditorBrowsable(EditorBrowsableState.Advanced)]
2865 protected virtual ControlCollection CreateControlsInstance() {
2866 return new ControlCollection(this);
2869 [EditorBrowsable(EditorBrowsableState.Advanced)]
2870 protected virtual void CreateHandle() {
2872 throw new ObjectDisposedException(Name);
2875 if (IsHandleCreated) {
2879 window.CreateHandle(CreateParams);
2881 if (window.Handle!=IntPtr.Zero) {
2882 if (!controls.Contains(window.Handle)) {
2886 creator_thread = Thread.CurrentThread;
2888 OnHandleCreated(EventArgs.Empty);
2891 // Find out where the window manager placed us
2893 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
2894 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
2899 [EditorBrowsable(EditorBrowsableState.Advanced)]
2900 protected virtual void DefWndProc(ref Message m) {
2901 window.DefWndProc(ref m);
2904 [EditorBrowsable(EditorBrowsableState.Advanced)]
2905 protected virtual void DestroyHandle() {
2906 if (IsHandleCreated) {
2907 // Destroy our children before we destroy ourselves, to prevent them from
2908 // being implictly (without us knowing) destroyed
2909 Control [] controls = child_controls.GetAllControls ();
2910 for (int i=0; i < controls.Length; i++) {
2911 controls[i].DestroyHandle();
2915 if (window != null) {
2916 window.DestroyHandle();
2918 OnHandleDestroyed(EventArgs.Empty);
2922 protected bool GetStyle(ControlStyles flag) {
2923 return (control_style & flag) != 0;
2926 protected bool GetTopLevel() {
2930 [EditorBrowsable(EditorBrowsableState.Advanced)]
2931 protected virtual void InitLayout() {
2932 dist_left = bounds.X;
2933 dist_top = bounds.Y;
2934 if (parent != null) {
2935 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
2936 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
2940 [EditorBrowsable(EditorBrowsableState.Advanced)]
2941 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2942 toInvoke.OnGotFocus(e);
2945 [EditorBrowsable(EditorBrowsableState.Advanced)]
2946 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2947 toInvoke.OnLostFocus(e);
2950 [EditorBrowsable(EditorBrowsableState.Advanced)]
2951 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2952 toInvoke.OnClick(e);
2955 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2956 toInvoke.OnPaint(e);
2959 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2960 toInvoke.OnPaintBackground(e);
2963 protected virtual bool IsInputChar (char charCode) {
2964 if (parent != null) {
2965 return parent.IsInputChar(charCode);
2971 protected virtual bool IsInputKey (Keys keyData) {
2972 // Doc says this one calls IsInputChar; not sure what to do with that
2976 [EditorBrowsable(EditorBrowsableState.Advanced)]
2977 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2981 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2982 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2986 if (parent != null) {
2987 return parent.ProcessCmdKey(ref msg, keyData);
2993 protected virtual bool ProcessDialogChar(char charCode) {
2994 if (parent != null) {
2995 return parent.ProcessDialogChar (charCode);
3001 protected virtual bool ProcessDialogKey (Keys keyData) {
3002 if (parent != null) {
3003 return parent.ProcessDialogKey (keyData);
3009 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3011 KeyEventArgs key_event;
3014 case (int)Msg.WM_SYSKEYDOWN:
3015 case (int)Msg.WM_KEYDOWN: {
3016 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3017 OnKeyDown (key_event);
3018 return key_event.Handled;
3021 case (int)Msg.WM_SYSKEYUP:
3022 case (int)Msg.WM_KEYUP: {
3023 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3024 OnKeyUp (key_event);
3025 return key_event.Handled;
3028 case (int)Msg.WM_SYSCHAR:
3029 case (int)Msg.WM_CHAR: {
3030 KeyPressEventArgs key_press_event;
3032 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3033 OnKeyPress(key_press_event);
3034 return key_press_event.Handled;
3045 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3046 if (parent != null) {
3047 if (parent.ProcessKeyPreview(ref msg)) {
3055 protected virtual bool ProcessKeyPreview(ref Message msg) {
3056 if (parent != null) {
3057 return parent.ProcessKeyPreview(ref msg);
3063 protected virtual bool ProcessMnemonic(char charCode) {
3068 [EditorBrowsable(EditorBrowsableState.Advanced)]
3069 protected void RaiseDragEvent(object key, DragEventArgs e) {
3073 [EditorBrowsable(EditorBrowsableState.Advanced)]
3074 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3078 [EditorBrowsable(EditorBrowsableState.Advanced)]
3079 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3083 [EditorBrowsable(EditorBrowsableState.Advanced)]
3084 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3088 [EditorBrowsable(EditorBrowsableState.Advanced)]
3089 protected void RecreateHandle() {
3090 IEnumerator child = child_controls.GetAllEnumerator();
3094 if (IsHandleCreated) {
3100 while (child.MoveNext()) {
3101 ((Control)child.Current).RecreateHandle();
3107 is_recreating = false;
3110 [EditorBrowsable(EditorBrowsableState.Advanced)]
3111 protected void ResetMouseEventArgs() {
3115 [EditorBrowsable(EditorBrowsableState.Advanced)]
3116 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3117 if (right_to_left == RightToLeft.No) {
3122 case ContentAlignment.TopLeft: {
3123 return ContentAlignment.TopRight;
3126 case ContentAlignment.TopRight: {
3127 return ContentAlignment.TopLeft;
3130 case ContentAlignment.MiddleLeft: {
3131 return ContentAlignment.MiddleRight;
3134 case ContentAlignment.MiddleRight: {
3135 return ContentAlignment.MiddleLeft;
3138 case ContentAlignment.BottomLeft: {
3139 return ContentAlignment.BottomRight;
3142 case ContentAlignment.BottomRight: {
3143 return ContentAlignment.BottomLeft;
3147 // if it's center it doesn't change
3153 [EditorBrowsable(EditorBrowsableState.Advanced)]
3154 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3155 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3159 if (align == HorizontalAlignment.Left) {
3160 return HorizontalAlignment.Right;
3163 // align must be HorizontalAlignment.Right
3164 return HorizontalAlignment.Left;
3167 [EditorBrowsable(EditorBrowsableState.Advanced)]
3168 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3169 if (right_to_left == RightToLeft.No) {
3173 if (align == LeftRightAlignment.Left) {
3174 return LeftRightAlignment.Right;
3177 // align must be LeftRightAlignment.Right;
3178 return LeftRightAlignment.Left;
3181 [EditorBrowsable(EditorBrowsableState.Advanced)]
3182 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3183 return RtlTranslateAlignment(align);
3186 [EditorBrowsable(EditorBrowsableState.Advanced)]
3187 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3188 return RtlTranslateAlignment(align);
3191 [EditorBrowsable(EditorBrowsableState.Advanced)]
3192 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3193 return RtlTranslateAlignment(align);
3196 [EditorBrowsable(EditorBrowsableState.Advanced)]
3197 protected virtual void ScaleCore(float dx, float dy) {
3203 location = new Point((int)(Left * dx), (int)(Top * dy));
3204 size = this.ClientSize;
3207 if (!GetStyle(ControlStyles.FixedWidth)) {
3208 size.Width = (int)(size.Width * dx);
3211 if (!GetStyle(ControlStyles.FixedHeight)) {
3212 size.Height = (int)(size.Height * dy);
3215 Location = location;
3218 /* Now scale our children */
3219 Control [] controls = child_controls.GetAllControls ();
3220 for (int i=0; i < controls.Length; i++) {
3221 controls[i].Scale(dx, dy);
3227 protected virtual void Select(bool directed, bool forward) {
3232 // Select this control
3237 if (parent == null) {
3241 // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
3243 index = parent.child_controls.IndexOf(this);
3248 if ((index+1) < parent.child_controls.Count) {
3257 index = parent.child_controls.Count-1;
3260 result = Select(parent.child_controls[index]);
3261 } while (!result && parent.child_controls[index] != this);
3264 [EditorBrowsable(EditorBrowsableState.Advanced)]
3265 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3266 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3267 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3271 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3275 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3279 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3283 if (IsHandleCreated) {
3284 XplatUI.SetWindowPos(Handle, x, y, width, height);
3287 UpdateBounds(x, y, width, height);
3290 Control [] controls = child_controls.GetAllControls ();
3291 for (int i = controls.Length - 1; i >= 0; i--) {
3292 controls[i].InitLayout();
3296 [EditorBrowsable(EditorBrowsableState.Advanced)]
3297 protected virtual void SetClientSizeCore(int x, int y) {
3298 // Calculate the actual window size from the client size (it usually stays the same or grows)
3299 Rectangle ClientRect;
3300 Rectangle WindowRect;
3303 ClientRect = new Rectangle(0, 0, x, y);
3304 cp = this.CreateParams;
3306 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3310 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3313 [EditorBrowsable(EditorBrowsableState.Advanced)]
3314 protected void SetStyle(ControlStyles flag, bool value) {
3316 control_style |= flag;
3318 control_style &= ~flag;
3320 OnStyleChanged(EventArgs.Empty);
3323 protected void SetTopLevel(bool value) {
3324 if ((GetTopLevel() != value) && (parent != null)) {
3325 throw new Exception();
3329 if (value == true) {
3339 is_toplevel = value;
3342 protected virtual void SetVisibleCore(bool value) {
3343 if (value!=is_visible) {
3346 if (IsHandleCreated) {
3347 XplatUI.SetVisible(Handle, value);
3348 // Explicitly move Toplevel windows to where we want them;
3349 // apparently moving unmapped toplevel windows doesn't work
3350 if (is_visible && (this is Form)) {
3351 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3355 OnVisibleChanged(EventArgs.Empty);
3358 if (dc_mem != null) {
3363 if (bmp_mem != null) {
3368 this.CreateBuffers(bounds.Width, bounds.Height);
3372 if (value == false && parent != null) {
3375 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3376 container = (Control)parent.GetContainerControl();
3377 if (container != null) {
3378 container.SelectNextControl(this, true, true, true, true);
3382 if (parent != null) {
3383 parent.PerformLayout(this, "visible");
3385 PerformLayout(this, "visible");
3390 [EditorBrowsable(EditorBrowsableState.Advanced)]
3391 protected void UpdateBounds() {
3399 if (!IsHandleCreated) {
3403 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3405 UpdateBounds(x, y, width, height, client_width, client_height);
3408 [EditorBrowsable(EditorBrowsableState.Advanced)]
3409 protected void UpdateBounds(int x, int y, int width, int height) {
3410 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3412 bool resized = false;
3414 int client_x_diff = this.bounds.Width-this.client_size.Width;
3415 int client_y_diff = this.bounds.Height-this.client_size.Height;
3417 // Needed to generate required notifications
3418 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3422 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3429 bounds.Height=height;
3431 // Update client rectangle as well
3432 client_size.Width=width-client_x_diff;
3433 client_size.Height=height-client_y_diff;
3436 OnLocationChanged(EventArgs.Empty);
3440 OnSizeChanged(EventArgs.Empty);
3444 [EditorBrowsable(EditorBrowsableState.Advanced)]
3445 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3446 UpdateBounds(x, y, width, height);
3448 this.client_size.Width=clientWidth;
3449 this.client_size.Height=clientHeight;
3452 [EditorBrowsable(EditorBrowsableState.Advanced)]
3453 protected void UpdateStyles() {
3454 if (!IsHandleCreated) {
3458 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3461 [EditorBrowsable(EditorBrowsableState.Advanced)]
3462 protected void UpdateZOrder() {
3463 Control [] controls;
3467 if (parent == null) {
3473 controls = ctl.child_controls.GetAllControls ();
3474 for (int i = 1; i < controls.Length; i++ ) {
3475 XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
3478 if (!IsHandleCreated) {
3482 controls = child_controls.GetAllControls ();
3483 for (int i = 1; i < controls.Length; i++ ) {
3484 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3489 protected virtual void WndProc(ref Message m) {
3491 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3493 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3497 switch((Msg)m.Msg) {
3498 case Msg.WM_WINDOWPOSCHANGED: {
3501 if (GetStyle(ControlStyles.ResizeRedraw)) {
3508 case Msg.WM_PAINT: {
3509 PaintEventArgs paint_event;
3511 paint_event = XplatUI.PaintEventStart(Handle, true);
3513 if (!needs_redraw) {
3514 // Just blit the previous image
3515 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3516 XplatUI.PaintEventEnd(Handle, true);
3521 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3522 dc = paint_event.SetGraphics (DeviceContext);
3525 OnPaintBackground(paint_event);
3526 // Leave out for now, our controls can do Paint += ... as well
3527 //OnPaintInternal(paint_event);
3528 OnPaint(paint_event);
3530 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3531 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3532 paint_event.SetGraphics (dc);
3533 needs_redraw = false;
3536 XplatUI.PaintEventEnd(Handle, true);
3541 case Msg.WM_ERASEBKGND: {
3542 // The DefWndProc will never have to handle this, we always paint the background in managed code
3543 m.Result = (IntPtr)1;
3547 case Msg.WM_LBUTTONUP: {
3548 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3550 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3552 HandleClick(mouse_clicks);
3553 if (mouse_clicks > 1) {
3559 case Msg.WM_LBUTTONDOWN: {
3560 if (CanSelect && !is_selected) {
3563 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3564 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3570 case Msg.WM_LBUTTONDBLCLK: {
3572 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3573 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3579 case Msg.WM_MBUTTONUP: {
3580 HandleClick(mouse_clicks);
3581 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3583 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3585 if (mouse_clicks > 1) {
3591 case Msg.WM_MBUTTONDOWN: {
3592 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3593 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3599 case Msg.WM_MBUTTONDBLCLK: {
3601 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3602 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3607 case Msg.WM_RBUTTONUP: {
3608 if (context_menu != null) {
3609 context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
3612 HandleClick(mouse_clicks);
3613 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3615 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3617 if (mouse_clicks > 1) {
3623 case Msg.WM_RBUTTONDOWN: {
3624 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3625 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3630 case Msg.WM_RBUTTONDBLCLK: {
3632 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3633 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3638 case Msg.WM_MOUSEWHEEL: {
3640 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3641 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3642 HighOrder(m.WParam.ToInt32())));
3647 case Msg.WM_MOUSEMOVE: {
3648 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3650 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3655 case Msg.WM_MOUSE_ENTER: {
3660 OnMouseEnter(EventArgs.Empty);
3664 case Msg.WM_MOUSE_LEAVE: {
3666 OnMouseLeave(EventArgs.Empty);
3670 case Msg.WM_MOUSEHOVER: {
3671 OnMouseHover(EventArgs.Empty);
3675 case Msg.WM_SYSKEYDOWN:
3676 case Msg.WM_KEYDOWN:
3677 case Msg.WM_SYSKEYUP:
3679 case Msg.WM_SYSCHAR:
3681 if (PreProcessMessage(ref m)) {
3685 if (ProcessKeyMessage(ref m)) {
3689 if (ProcessKeyEventArgs(ref m)) {
3699 if (m.LParam != IntPtr.Zero) {
3702 hi = new HELPINFO();
3704 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3705 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3707 mouse_pos = Control.MousePosition;
3709 OnHelpRequested(new HelpEventArgs(mouse_pos));
3710 m.Result = (IntPtr)1;
3714 case Msg.WM_KILLFOCUS: {
3715 OnLeave(EventArgs.Empty);
3716 if (CausesValidation) {
3718 e = new CancelEventArgs(false);
3727 OnValidated(EventArgs.Empty);
3730 this.has_focus = false;
3731 this.is_selected = false;
3732 OnLostFocus(EventArgs.Empty);
3736 case Msg.WM_SETFOCUS: {
3737 OnEnter(EventArgs.Empty);
3738 this.has_focus = true;
3739 OnGotFocus(EventArgs.Empty);
3744 case Msg.WM_SYSCOLORCHANGE: {
3745 ThemeEngine.Current.ResetDefaults();
3746 OnSystemColorsChanged(EventArgs.Empty);
3751 case Msg.WM_SETCURSOR: {
3752 if (cursor == null) {
3757 XplatUI.SetCursor(window.Handle, cursor.handle);
3758 m.Result = (IntPtr)1;
3769 #endregion // Public Instance Methods
3771 #region OnXXX methods
3772 [EditorBrowsable(EditorBrowsableState.Advanced)]
3773 protected virtual void OnBackColorChanged(EventArgs e) {
3774 if (BackColorChanged!=null) BackColorChanged(this, e);
3775 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3778 [EditorBrowsable(EditorBrowsableState.Advanced)]
3779 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3780 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3781 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3784 [EditorBrowsable(EditorBrowsableState.Advanced)]
3785 protected virtual void OnBindingContextChanged(EventArgs e) {
3786 CheckDataBindings ();
3787 if (BindingContextChanged!=null) {
3788 BindingContextChanged(this, e);
3790 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3793 [EditorBrowsable(EditorBrowsableState.Advanced)]
3794 protected virtual void OnCausesValidationChanged(EventArgs e) {
3795 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3798 [EditorBrowsable(EditorBrowsableState.Advanced)]
3799 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3800 if (ChangeUICues!=null) ChangeUICues(this, e);
3803 [EditorBrowsable(EditorBrowsableState.Advanced)]
3804 protected virtual void OnClick(EventArgs e) {
3805 if (Click!=null) Click(this, e);
3808 [EditorBrowsable(EditorBrowsableState.Advanced)]
3809 protected virtual void OnContextMenuChanged(EventArgs e) {
3810 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3813 [EditorBrowsable(EditorBrowsableState.Advanced)]
3814 protected virtual void OnControlAdded(ControlEventArgs e) {
3815 if (ControlAdded!=null) ControlAdded(this, e);
3818 [EditorBrowsable(EditorBrowsableState.Advanced)]
3819 protected virtual void OnControlRemoved(ControlEventArgs e) {
3820 if (ControlRemoved!=null) ControlRemoved(this, e);
3823 [EditorBrowsable(EditorBrowsableState.Advanced)]
3824 protected virtual void OnCreateControl() {
3828 [EditorBrowsable(EditorBrowsableState.Advanced)]
3829 protected virtual void OnCursorChanged(EventArgs e) {
3830 if (CursorChanged!=null) CursorChanged(this, e);
3833 [EditorBrowsable(EditorBrowsableState.Advanced)]
3834 protected virtual void OnDockChanged(EventArgs e) {
3835 if (DockChanged!=null) DockChanged(this, e);
3838 [EditorBrowsable(EditorBrowsableState.Advanced)]
3839 protected virtual void OnDoubleClick(EventArgs e) {
3840 if (DoubleClick!=null) DoubleClick(this, e);
3843 [EditorBrowsable(EditorBrowsableState.Advanced)]
3844 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3845 if (DragDrop!=null) DragDrop(this, drgevent);
3848 [EditorBrowsable(EditorBrowsableState.Advanced)]
3849 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3850 if (DragEnter!=null) DragEnter(this, drgevent);
3853 [EditorBrowsable(EditorBrowsableState.Advanced)]
3854 protected virtual void OnDragLeave(EventArgs e) {
3855 if (DragLeave!=null) DragLeave(this, e);
3858 [EditorBrowsable(EditorBrowsableState.Advanced)]
3859 protected virtual void OnDragOver(DragEventArgs drgevent) {
3860 if (DragOver!=null) DragOver(this, drgevent);
3863 [EditorBrowsable(EditorBrowsableState.Advanced)]
3864 protected virtual void OnEnabledChanged(EventArgs e) {
3865 if (EnabledChanged!=null) EnabledChanged(this, e);
3866 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3869 [EditorBrowsable(EditorBrowsableState.Advanced)]
3870 protected virtual void OnEnter(EventArgs e) {
3871 if (Enter!=null) Enter(this, e);
3874 [EditorBrowsable(EditorBrowsableState.Advanced)]
3875 protected virtual void OnFontChanged(EventArgs e) {
3876 if (FontChanged!=null) FontChanged(this, e);
3877 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3880 [EditorBrowsable(EditorBrowsableState.Advanced)]
3881 protected virtual void OnForeColorChanged(EventArgs e) {
3882 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3883 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3886 [EditorBrowsable(EditorBrowsableState.Advanced)]
3887 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3888 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3891 [EditorBrowsable(EditorBrowsableState.Advanced)]
3892 protected virtual void OnGotFocus(EventArgs e) {
3893 if (GotFocus!=null) GotFocus(this, e);
3896 [EditorBrowsable(EditorBrowsableState.Advanced)]
3897 protected virtual void OnHandleCreated(EventArgs e) {
3898 if (HandleCreated!=null) HandleCreated(this, e);
3901 [EditorBrowsable(EditorBrowsableState.Advanced)]
3902 protected virtual void OnHandleDestroyed(EventArgs e) {
3903 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3906 [EditorBrowsable(EditorBrowsableState.Advanced)]
3907 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3908 if (HelpRequested!=null) HelpRequested(this, hevent);
3911 protected virtual void OnImeModeChanged(EventArgs e) {
3912 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3915 [EditorBrowsable(EditorBrowsableState.Advanced)]
3916 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3917 needs_redraw = true;
3918 if (Invalidated!=null) Invalidated(this, e);
3921 [EditorBrowsable(EditorBrowsableState.Advanced)]
3922 protected virtual void OnKeyDown(KeyEventArgs e) {
3923 if (KeyDown!=null) KeyDown(this, e);
3926 [EditorBrowsable(EditorBrowsableState.Advanced)]
3927 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3928 if (KeyPress!=null) KeyPress(this, e);
3931 [EditorBrowsable(EditorBrowsableState.Advanced)]
3932 protected virtual void OnKeyUp(KeyEventArgs e) {
3933 if (KeyUp!=null) KeyUp(this, e);
3936 [EditorBrowsable(EditorBrowsableState.Advanced)]
3937 protected virtual void OnLayout(LayoutEventArgs levent) {
3938 if (Layout!=null) Layout(this, levent);
3941 [EditorBrowsable(EditorBrowsableState.Advanced)]
3942 protected virtual void OnLeave(EventArgs e) {
3943 if (Leave!=null) Leave(this, e);
3946 [EditorBrowsable(EditorBrowsableState.Advanced)]
3947 protected virtual void OnLocationChanged(EventArgs e) {
3949 if (LocationChanged!=null) LocationChanged(this, e);
3952 [EditorBrowsable(EditorBrowsableState.Advanced)]
3953 protected virtual void OnLostFocus(EventArgs e) {
3954 if (LostFocus!=null) LostFocus(this, e);
3957 [EditorBrowsable(EditorBrowsableState.Advanced)]
3958 protected virtual void OnMouseDown(MouseEventArgs e) {
3959 if (MouseDown!=null) MouseDown(this, e);
3962 [EditorBrowsable(EditorBrowsableState.Advanced)]
3963 protected virtual void OnMouseEnter(EventArgs e) {
3964 if (MouseEnter!=null) MouseEnter(this, e);
3967 [EditorBrowsable(EditorBrowsableState.Advanced)]
3968 protected virtual void OnMouseHover(EventArgs e) {
3969 if (MouseHover!=null) MouseHover(this, e);
3972 [EditorBrowsable(EditorBrowsableState.Advanced)]
3973 protected virtual void OnMouseLeave(EventArgs e) {
3974 if (MouseLeave!=null) MouseLeave(this, e);
3977 [EditorBrowsable(EditorBrowsableState.Advanced)]
3978 protected virtual void OnMouseMove(MouseEventArgs e) {
3979 if (MouseMove!=null) MouseMove(this, e);
3982 [EditorBrowsable(EditorBrowsableState.Advanced)]
3983 protected virtual void OnMouseUp(MouseEventArgs e) {
3984 if (MouseUp!=null) MouseUp(this, e);
3987 [EditorBrowsable(EditorBrowsableState.Advanced)]
3988 protected virtual void OnMouseWheel(MouseEventArgs e) {
3989 if (MouseWheel!=null) MouseWheel(this, e);
3992 [EditorBrowsable(EditorBrowsableState.Advanced)]
3993 protected virtual void OnMove(EventArgs e) {
3994 if (Move!=null) Move(this, e);
3997 [EditorBrowsable(EditorBrowsableState.Advanced)]
3998 protected virtual void OnNotifyMessage(Message m) {
4002 [EditorBrowsable(EditorBrowsableState.Advanced)]
4003 protected virtual void OnPaint(PaintEventArgs e) {
4004 if (Paint!=null) Paint(this, e);
4007 internal virtual void OnPaintInternal(PaintEventArgs e) {
4011 [EditorBrowsable(EditorBrowsableState.Advanced)]
4012 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4013 PaintControlBackground (pevent);
4016 [EditorBrowsable(EditorBrowsableState.Advanced)]
4017 protected virtual void OnParentBackColorChanged(EventArgs e) {
4018 if (background_color.IsEmpty && background_image==null) {
4020 OnBackColorChanged(e);
4024 [EditorBrowsable(EditorBrowsableState.Advanced)]
4025 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4026 if (background_color.IsEmpty && background_image==null) {
4028 OnBackgroundImageChanged(e);
4032 [EditorBrowsable(EditorBrowsableState.Advanced)]
4033 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4034 if (binding_context==null) {
4035 binding_context=Parent.binding_context;
4036 OnBindingContextChanged(e);
4040 [EditorBrowsable(EditorBrowsableState.Advanced)]
4041 protected virtual void OnParentChanged(EventArgs e) {
4042 if (ParentChanged!=null) ParentChanged(this, e);
4045 [EditorBrowsable(EditorBrowsableState.Advanced)]
4046 protected virtual void OnParentEnabledChanged(EventArgs e) {
4047 if (is_enabled != Parent.is_enabled) {
4048 is_enabled=Parent.is_enabled;
4050 if (EnabledChanged != null) {
4051 EnabledChanged(this, e);
4056 [EditorBrowsable(EditorBrowsableState.Advanced)]
4057 protected virtual void OnParentFontChanged(EventArgs e) {
4064 [EditorBrowsable(EditorBrowsableState.Advanced)]
4065 protected virtual void OnParentForeColorChanged(EventArgs e) {
4066 if (foreground_color.IsEmpty) {
4068 OnForeColorChanged(e);
4072 [EditorBrowsable(EditorBrowsableState.Advanced)]
4073 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4074 if (right_to_left==RightToLeft.Inherit) {
4076 OnRightToLeftChanged(e);
4080 [EditorBrowsable(EditorBrowsableState.Advanced)]
4081 protected virtual void OnParentVisibleChanged(EventArgs e) {
4083 OnVisibleChanged(e);
4087 [EditorBrowsable(EditorBrowsableState.Advanced)]
4088 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4089 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
4092 [EditorBrowsable(EditorBrowsableState.Advanced)]
4093 protected virtual void OnResize(EventArgs e) {
4094 if (Resize!=null) Resize(this, e);
4096 PerformLayout(this, "bounds");
4098 if (parent != null) {
4099 parent.PerformLayout();
4103 [EditorBrowsable(EditorBrowsableState.Advanced)]
4104 protected virtual void OnRightToLeftChanged(EventArgs e) {
4105 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
4106 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4109 [EditorBrowsable(EditorBrowsableState.Advanced)]
4110 protected virtual void OnSizeChanged(EventArgs e) {
4111 InvalidateBuffers ();
4113 if (SizeChanged!=null) SizeChanged(this, e);
4116 [EditorBrowsable(EditorBrowsableState.Advanced)]
4117 protected virtual void OnStyleChanged(EventArgs e) {
4118 if (StyleChanged!=null) StyleChanged(this, e);
4121 [EditorBrowsable(EditorBrowsableState.Advanced)]
4122 protected virtual void OnSystemColorsChanged(EventArgs e) {
4123 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
4126 [EditorBrowsable(EditorBrowsableState.Advanced)]
4127 protected virtual void OnTabIndexChanged(EventArgs e) {
4128 if (TabIndexChanged!=null) TabIndexChanged(this, e);
4131 [EditorBrowsable(EditorBrowsableState.Advanced)]
4132 protected virtual void OnTabStopChanged(EventArgs e) {
4133 if (TabStopChanged!=null) TabStopChanged(this, e);
4136 [EditorBrowsable(EditorBrowsableState.Advanced)]
4137 protected virtual void OnTextChanged(EventArgs e) {
4138 if (TextChanged!=null) TextChanged(this, e);
4141 [EditorBrowsable(EditorBrowsableState.Advanced)]
4142 protected virtual void OnValidated(EventArgs e) {
4143 if (Validated!=null) Validated(this, e);
4146 [EditorBrowsable(EditorBrowsableState.Advanced)]
4147 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4148 if (Validating!=null) Validating(this, e);
4151 [EditorBrowsable(EditorBrowsableState.Advanced)]
4152 protected virtual void OnVisibleChanged(EventArgs e) {
4159 if (bmp_mem!=null) {
4165 if (!this.IsHandleCreated) {
4166 this.CreateControl();
4172 if (VisibleChanged!=null) VisibleChanged(this, e);
4174 // We need to tell our kids
4175 for (int i=0; i<child_controls.Count; i++) {
4176 child_controls[i].OnParentVisibleChanged(e);
4179 #endregion // OnXXX methods
4182 public event EventHandler BackColorChanged;
4183 public event EventHandler BackgroundImageChanged;
4184 public event EventHandler BindingContextChanged;
4185 public event EventHandler CausesValidationChanged;
4186 public event UICuesEventHandler ChangeUICues;
4187 public event EventHandler Click;
4188 public event EventHandler ContextMenuChanged;
4190 [EditorBrowsable(EditorBrowsableState.Advanced)]
4192 public event ControlEventHandler ControlAdded;
4194 [EditorBrowsable(EditorBrowsableState.Advanced)]
4196 public event ControlEventHandler ControlRemoved;
4198 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4199 public event EventHandler CursorChanged;
4200 public event EventHandler DockChanged;
4201 public event EventHandler DoubleClick;
4202 public event DragEventHandler DragDrop;
4203 public event DragEventHandler DragEnter;
4204 public event EventHandler DragLeave;
4205 public event DragEventHandler DragOver;
4206 public event EventHandler EnabledChanged;
4207 public event EventHandler Enter;
4208 public event EventHandler FontChanged;
4209 public event EventHandler ForeColorChanged;
4210 public event GiveFeedbackEventHandler GiveFeedback;
4212 [EditorBrowsable(EditorBrowsableState.Advanced)]
4214 public event EventHandler GotFocus;
4216 [EditorBrowsable(EditorBrowsableState.Advanced)]
4218 public event EventHandler HandleCreated;
4220 [EditorBrowsable(EditorBrowsableState.Advanced)]
4222 public event EventHandler HandleDestroyed;
4224 public event HelpEventHandler HelpRequested;
4225 public event EventHandler ImeModeChanged;
4227 [EditorBrowsable(EditorBrowsableState.Advanced)]
4229 public event InvalidateEventHandler Invalidated;
4231 public event KeyEventHandler KeyDown;
4232 public event KeyPressEventHandler KeyPress;
4233 public event KeyEventHandler KeyUp;
4234 public event LayoutEventHandler Layout;
4235 public event EventHandler Leave;
4236 public event EventHandler LocationChanged;
4238 [EditorBrowsable(EditorBrowsableState.Advanced)]
4240 public event EventHandler LostFocus;
4242 public event MouseEventHandler MouseDown;
4243 public event EventHandler MouseEnter;
4244 public event EventHandler MouseHover;
4245 public event EventHandler MouseLeave;
4246 public event MouseEventHandler MouseMove;
4247 public event MouseEventHandler MouseUp;
4249 [EditorBrowsable(EditorBrowsableState.Advanced)]
4251 public event MouseEventHandler MouseWheel;
4253 public event EventHandler Move;
4254 public event PaintEventHandler Paint;
4255 public event EventHandler ParentChanged;
4256 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
4257 public event QueryContinueDragEventHandler QueryContinueDrag;
4258 public event EventHandler Resize;
4259 public event EventHandler RightToLeftChanged;
4260 public event EventHandler SizeChanged;
4261 public event EventHandler StyleChanged;
4262 public event EventHandler SystemColorsChanged;
4263 public event EventHandler TabIndexChanged;
4264 public event EventHandler TabStopChanged;
4265 public event EventHandler TextChanged;
4266 public event EventHandler Validated;
4267 public event CancelEventHandler Validating;
4268 public event EventHandler VisibleChanged;
4269 #endregion // Events