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 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 virtual void DndEnter (DragEventArgs e)
927 internal virtual void DndOver (DragEventArgs e)
934 internal virtual void DndDrop (DragEventArgs e)
938 } catch (Exception exc) {
939 Console.Error.WriteLine ("MWF: Exception while dropping:");
940 Console.Error.WriteLine (exc);
944 internal virtual void DndLeave (EventArgs e)
951 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
958 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
961 OnQueryContinueDrag(e);
965 internal static MouseButtons FromParamToMouseButtons (int param) {
966 MouseButtons buttons = MouseButtons.None;
968 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
969 buttons |= MouseButtons.Left;
971 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
972 buttons |= MouseButtons.Middle;
974 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
975 buttons |= MouseButtons.Right;
981 internal virtual bool ProcessControlMnemonic(char charCode) {
982 return ProcessMnemonic(charCode);
985 private static Control FindFlatForward(Control container, Control start) {
991 end = container.child_controls.Count;
994 index = start.tab_index;
999 for (int i = 0; i < end; i++) {
1000 if (found == null) {
1001 if (container.child_controls[i].tab_index > index) {
1002 found = container.child_controls[i];
1004 } else if (found.tab_index > container.child_controls[i].tab_index) {
1005 if (container.child_controls[i].tab_index > index) {
1006 found = container.child_controls[i];
1013 private static Control FindControlForward(Control container, Control start) {
1019 if (start != null) {
1020 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
1021 found = FindControlForward(start, null);
1022 if (found != null) {
1028 while (p != container) {
1029 found = FindFlatForward(p, start);
1030 if (found != null) {
1037 return FindFlatForward(container, start);
1040 private static Control FindFlatBackward(Control container, Control start) {
1046 end = container.child_controls.Count;
1048 if (start != null) {
1049 index = start.tab_index;
1051 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1053 for (int i = 0; i < end; i++) {
1054 if (container.child_controls[i].tab_index > index) {
1055 index = container.child_controls[i].tab_index;
1061 for (int i = 0; i < end; i++) {
1062 if (found == null) {
1063 if (container.child_controls[i].tab_index < index) {
1064 found = container.child_controls[i];
1066 } else if (found.tab_index < container.child_controls[i].tab_index) {
1067 if (container.child_controls[i].tab_index < index) {
1068 found = container.child_controls[i];
1075 private static Control FindControlBackward(Control container, Control start) {
1080 if (start != null) {
1081 found = FindFlatBackward(start.parent, start);
1082 if (found == null && start.parent != container) {
1083 return start.parent;
1086 if (found == null) {
1087 found = FindFlatBackward(container, start);
1090 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
1091 found = FindControlBackward(found, null);
1092 if (found != null) {
1100 private void HandleClick(int clicks) {
1101 if (GetStyle(ControlStyles.StandardClick)) {
1103 if (GetStyle(ControlStyles.StandardDoubleClick)) {
1104 OnDoubleClick(EventArgs.Empty);
1106 OnClick(EventArgs.Empty);
1109 OnClick(EventArgs.Empty);
1114 private void CheckDataBindings ()
1116 if (data_bindings == null)
1119 BindingContext binding_context = BindingContext;
1120 foreach (Binding binding in data_bindings) {
1121 binding.Check (binding_context);
1124 #endregion // Private & Internal Methods
1126 #region Public Static Properties
1127 public static Color DefaultBackColor {
1129 return ThemeEngine.Current.DefaultControlBackColor;
1133 public static Font DefaultFont {
1135 return ThemeEngine.Current.DefaultFont;
1139 public static Color DefaultForeColor {
1141 return ThemeEngine.Current.DefaultControlForeColor;
1145 public static Keys ModifierKeys {
1147 return XplatUI.State.ModifierKeys;
1151 public static MouseButtons MouseButtons {
1153 return XplatUI.State.MouseButtons;
1157 public static Point MousePosition {
1159 return Cursor.Position;
1165 public static bool CheckForIllegalCrossThreadCalls
1174 #endregion // Public Static Properties
1176 #region Public Instance Properties
1177 [EditorBrowsable(EditorBrowsableState.Advanced)]
1179 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1180 public AccessibleObject AccessibilityObject {
1182 if (accessibility_object==null) {
1183 accessibility_object=CreateAccessibilityInstance();
1185 return accessibility_object;
1189 [EditorBrowsable(EditorBrowsableState.Advanced)]
1191 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1192 public string AccessibleDefaultActionDescription {
1194 return AccessibilityObject.default_action;
1198 AccessibilityObject.default_action=value;
1203 [DefaultValue(null)]
1204 public string AccessibleDescription {
1206 return AccessibilityObject.description;
1210 AccessibilityObject.description=value;
1215 [DefaultValue(null)]
1216 public string AccessibleName {
1218 return AccessibilityObject.Name;
1222 AccessibilityObject.Name=value;
1226 [DefaultValue(AccessibleRole.Default)]
1227 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1228 public AccessibleRole AccessibleRole {
1230 return AccessibilityObject.role;
1234 AccessibilityObject.role=value;
1238 [DefaultValue(false)]
1239 public virtual bool AllowDrop {
1245 if (allow_drop == value)
1249 XplatUI.SetAllowDrop (Handle, value);
1254 [RefreshProperties(RefreshProperties.Repaint)]
1255 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1256 public virtual AnchorStyles Anchor {
1258 return anchor_style;
1264 if (parent != null) {
1265 parent.PerformLayout(this, "Parent");
1271 public virtual Color BackColor {
1273 if (background_color.IsEmpty) {
1275 return parent.BackColor;
1277 return DefaultBackColor;
1279 return background_color;
1283 background_color=value;
1284 SetChildColor(this);
1285 OnBackColorChanged(EventArgs.Empty);
1291 [DefaultValue(null)]
1292 public virtual Image BackgroundImage {
1294 return background_image;
1298 if (background_image!=value) {
1299 background_image=value;
1300 OnBackgroundImageChanged(EventArgs.Empty);
1305 [EditorBrowsable(EditorBrowsableState.Advanced)]
1307 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1308 public virtual BindingContext BindingContext {
1310 if (binding_context != null)
1311 return binding_context;
1314 binding_context = Parent.BindingContext;
1315 return binding_context;
1318 if (binding_context != value) {
1319 binding_context = value;
1320 OnBindingContextChanged(EventArgs.Empty);
1325 [EditorBrowsable(EditorBrowsableState.Advanced)]
1327 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1330 return bounds.Y+bounds.Height;
1334 [EditorBrowsable(EditorBrowsableState.Advanced)]
1336 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1337 public Rectangle Bounds {
1343 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1347 [EditorBrowsable(EditorBrowsableState.Advanced)]
1349 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1350 public bool CanFocus {
1352 if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1359 [EditorBrowsable(EditorBrowsableState.Advanced)]
1361 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1362 public bool CanSelect {
1366 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1370 parent = this.parent;
1371 while (parent != null) {
1372 if (!parent.is_visible || !parent.is_enabled) {
1376 parent = parent.parent;
1382 [EditorBrowsable(EditorBrowsableState.Advanced)]
1384 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1385 public bool Capture {
1387 return this.is_captured;
1391 if (this.IsHandleCreated) {
1392 if (value && !is_captured) {
1394 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1395 } else if (!value && is_captured) {
1396 XplatUI.UngrabWindow(this.window.Handle);
1397 is_captured = false;
1403 [DefaultValue(true)]
1404 public bool CausesValidation {
1406 return this.causes_validation;
1410 if (this.causes_validation != value) {
1411 causes_validation = value;
1412 OnCausesValidationChanged(EventArgs.Empty);
1417 [EditorBrowsable(EditorBrowsableState.Advanced)]
1419 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1420 public Rectangle ClientRectangle {
1422 client_rect.Width = client_size.Width;
1423 client_rect.Height = client_size.Height;
1428 [EditorBrowsable(EditorBrowsableState.Advanced)]
1430 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1431 public Size ClientSize {
1434 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1435 return ((Form)this).form_parent_window.ClientSize;
1443 this.SetClientSizeCore(value.Width, value.Height);
1447 [EditorBrowsable(EditorBrowsableState.Advanced)]
1449 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1450 [DescriptionAttribute("ControlCompanyNameDescr")]
1451 public String CompanyName {
1453 return "Mono Project, Novell, Inc.";
1457 [EditorBrowsable(EditorBrowsableState.Advanced)]
1459 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1460 public bool ContainsFocus {
1466 for (int i=0; i < child_controls.Count; i++) {
1467 if (child_controls[i].ContainsFocus) {
1475 [DefaultValue(null)]
1476 public virtual ContextMenu ContextMenu {
1478 return context_menu;
1482 if (context_menu != value) {
1483 context_menu = value;
1484 OnContextMenuChanged(EventArgs.Empty);
1490 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1491 public ControlCollection Controls {
1493 return this.child_controls;
1497 [EditorBrowsable(EditorBrowsableState.Advanced)]
1499 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1500 public bool Created {
1502 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1509 [AmbientValue(null)]
1510 public virtual Cursor Cursor {
1512 if (cursor != null) {
1516 if (parent != null) {
1517 return parent.Cursor;
1520 return Cursors.Default;
1524 if (cursor != value) {
1529 pt = Cursor.Position;
1530 if (bounds.Contains(pt)) {
1531 if (GetChildAtPoint(pt) == null) {
1532 if (cursor != null) {
1533 XplatUI.SetCursor(window.Handle, cursor.handle);
1535 if (parent != null) {
1536 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1538 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1544 OnCursorChanged(EventArgs.Empty);
1550 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1551 [ParenthesizePropertyName(true)]
1552 [RefreshProperties(RefreshProperties.All)]
1553 public ControlBindingsCollection DataBindings {
1555 if (data_bindings == null)
1556 data_bindings = new ControlBindingsCollection (this);
1557 return data_bindings;
1561 [EditorBrowsable(EditorBrowsableState.Advanced)]
1563 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1564 public virtual Rectangle DisplayRectangle {
1566 return ClientRectangle;
1570 [EditorBrowsable(EditorBrowsableState.Advanced)]
1572 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1573 public bool Disposing {
1580 [RefreshProperties(RefreshProperties.Repaint)]
1581 [DefaultValue(DockStyle.None)]
1582 public virtual DockStyle Dock {
1588 if (dock_style == value) {
1594 if (parent != null) {
1595 parent.PerformLayout(this, "Parent");
1598 OnDockChanged(EventArgs.Empty);
1604 public bool Enabled {
1610 if (is_enabled == value) {
1616 OnEnabledChanged (EventArgs.Empty);
1620 [EditorBrowsable(EditorBrowsableState.Advanced)]
1622 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1623 public virtual bool Focused {
1625 return this.has_focus;
1630 [AmbientValue(null)]
1632 public virtual Font Font {
1638 if (Parent != null && Parent.Font != null) {
1646 if (font != null && font.Equals (value)) {
1652 OnFontChanged (EventArgs.Empty);
1657 public virtual Color ForeColor {
1659 if (foreground_color.IsEmpty) {
1661 return parent.ForeColor;
1663 return DefaultForeColor;
1665 return foreground_color;
1669 if (foreground_color != value) {
1670 foreground_color=value;
1672 OnForeColorChanged(EventArgs.Empty);
1679 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1680 public IntPtr Handle { // IWin32Window
1682 if (!IsHandleCreated) {
1685 return window.Handle;
1689 [EditorBrowsable(EditorBrowsableState.Advanced)]
1691 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1692 public bool HasChildren {
1694 if (this.child_controls.Count>0) {
1701 [EditorBrowsable(EditorBrowsableState.Always)]
1703 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1706 return this.bounds.Height;
1710 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1714 [AmbientValue(ImeMode.Inherit)]
1716 public ImeMode ImeMode {
1718 if (ime_mode == DefaultImeMode) {
1720 return parent.ImeMode;
1722 return ImeMode.NoControl; // default value
1728 if (ime_mode != value) {
1731 OnImeModeChanged(EventArgs.Empty);
1736 [EditorBrowsable(EditorBrowsableState.Advanced)]
1738 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1739 public bool InvokeRequired { // ISynchronizeInvoke
1741 if (creator_thread!=Thread.CurrentThread) {
1748 [EditorBrowsable(EditorBrowsableState.Advanced)]
1750 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1751 public bool IsAccessible {
1753 return is_accessible;
1757 is_accessible = value;
1761 [EditorBrowsable(EditorBrowsableState.Advanced)]
1763 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1764 public bool IsDisposed {
1766 return this.is_disposed;
1770 [EditorBrowsable(EditorBrowsableState.Advanced)]
1772 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1773 public bool IsHandleCreated {
1775 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1783 [EditorBrowsable(EditorBrowsableState.Always)]
1785 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1788 return this.bounds.X;
1792 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1797 public Point Location {
1799 return new Point(bounds.X, bounds.Y);
1803 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1808 public string Name {
1819 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1820 public Control Parent {
1826 if (value == this) {
1827 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1830 if (parent!=value) {
1832 parent.Controls.Remove(this);
1838 if (!parent.Controls.AllContains (this)) {
1839 Console.WriteLine ("Adding child: " + this);
1840 parent.Controls.Add(this);
1843 if (IsHandleCreated) {
1844 XplatUI.SetParent(Handle, value.Handle);
1847 OnParentChanged(EventArgs.Empty);
1853 [EditorBrowsable(EditorBrowsableState.Advanced)]
1855 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1856 public string ProductName {
1858 Type t = typeof (AssemblyProductAttribute);
1859 Assembly assembly = GetType().Module.Assembly;
1860 object [] attrs = assembly.GetCustomAttributes (t, false);
1861 AssemblyProductAttribute a = null;
1862 // On MS we get a NullRefException if product attribute is not
1864 if (attrs != null && attrs.Length > 0)
1865 a = (AssemblyProductAttribute) attrs [0];
1870 [EditorBrowsable(EditorBrowsableState.Advanced)]
1872 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1873 public string ProductVersion {
1875 Type t = typeof (AssemblyVersionAttribute);
1876 Assembly assembly = GetType().Module.Assembly;
1877 object [] attrs = assembly.GetCustomAttributes (t, false);
1878 if (attrs == null || attrs.Length < 1)
1880 return ((AssemblyVersionAttribute)attrs [0]).Version;
1884 [EditorBrowsable(EditorBrowsableState.Advanced)]
1886 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1887 public bool RecreatingHandle {
1889 return is_recreating;
1893 [EditorBrowsable(EditorBrowsableState.Advanced)]
1895 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1896 public Region Region {
1898 return new Region(this.bounds);
1905 g = this.CreateGraphics();
1906 r = value.GetBounds(g);
1908 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1914 [EditorBrowsable(EditorBrowsableState.Advanced)]
1916 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1919 return this.bounds.X+this.bounds.Width;
1923 [AmbientValue(RightToLeft.Inherit)]
1925 public virtual RightToLeft RightToLeft {
1927 if (right_to_left == RightToLeft.Inherit) {
1929 return parent.RightToLeft;
1931 return RightToLeft.No; // default value
1933 return right_to_left;
1937 if (value != right_to_left) {
1938 right_to_left = value;
1939 OnRightToLeftChanged(EventArgs.Empty);
1944 [EditorBrowsable(EditorBrowsableState.Advanced)]
1945 public override ISite Site {
1958 return new Size(Width, Height);
1962 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1967 [MergableProperty(false)]
1968 public int TabIndex {
1970 if (tab_index != -1) {
1977 if (tab_index != value) {
1979 OnTabIndexChanged(EventArgs.Empty);
1985 [DefaultValue(true)]
1986 public bool TabStop {
1992 if (tab_stop != value) {
1994 OnTabStopChanged(EventArgs.Empty);
1999 [Localizable(false)]
2001 [TypeConverter(typeof(StringConverter))]
2002 [DefaultValue(null)]
2009 control_tag = value;
2015 [BindableAttribute(true)]
2016 public virtual string Text {
2018 // Our implementation ignores ControlStyles.CacheText - we always cache
2023 if (value == null) {
2024 value = String.Empty;
2029 if (IsHandleCreated) {
2030 XplatUI.Text(Handle, text);
2032 OnTextChanged (EventArgs.Empty);
2037 [EditorBrowsable(EditorBrowsableState.Always)]
2039 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2042 return this.bounds.Y;
2046 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2050 [EditorBrowsable(EditorBrowsableState.Advanced)]
2052 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2053 public Control TopLevelControl {
2057 while (p.parent != null) {
2066 public bool Visible {
2070 } else if (parent != null) {
2071 return parent.Visible;
2078 SetVisibleCore(value);
2082 [EditorBrowsable(EditorBrowsableState.Always)]
2084 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2087 return this.bounds.Width;
2091 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2095 [EditorBrowsable(EditorBrowsableState.Never)]
2097 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2098 public IWindowTarget WindowTarget {
2107 #endregion // Public Instance Properties
2109 #region Protected Instance Properties
2110 protected virtual CreateParams CreateParams {
2112 CreateParams create_params = new CreateParams();
2115 create_params.Caption = Text;
2118 create_params.Caption = text;
2122 create_params.X = Left;
2125 create_params.X = this.bounds.X;
2129 create_params.Y = Top;
2132 create_params.Y = this.bounds.Y;
2136 create_params.Width = Width;
2139 create_params.Width = this.bounds.Width;
2143 create_params.Height = Height;
2146 create_params.Height = this.bounds.Height;
2150 create_params.ClassName = XplatUI.DefaultClassName;
2151 create_params.ClassStyle = 0;
2152 create_params.ExStyle = 0;
2153 create_params.Param = 0;
2156 create_params.ExStyle |= (int)WindowStyles.WS_EX_ACCEPTFILES;
2160 create_params.Parent = parent.Handle;
2163 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2166 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2169 return create_params;
2173 protected virtual ImeMode DefaultImeMode {
2175 return ImeMode.Inherit;
2179 protected virtual Size DefaultSize {
2181 return new Size(100, 23);
2185 protected int FontHeight {
2195 protected bool RenderRightToLeft {
2197 return (this.right_to_left == RightToLeft.Yes);
2201 protected bool ResizeRedraw {
2203 return GetStyle(ControlStyles.ResizeRedraw);
2207 SetStyle(ControlStyles.ResizeRedraw, value);
2211 [EditorBrowsable(EditorBrowsableState.Advanced)]
2213 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2214 protected virtual bool ShowFocusCues {
2220 [EditorBrowsable(EditorBrowsableState.Advanced)]
2222 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2223 protected bool ShowKeyboardCues {
2228 #endregion // Protected Instance Properties
2230 #region Public Static Methods
2231 [EditorBrowsable(EditorBrowsableState.Advanced)]
2232 public static Control FromChildHandle(IntPtr handle) {
2233 IEnumerator control = Control.controls.GetEnumerator();
2235 while (control.MoveNext()) {
2236 if (((Control)control.Current).window.Handle == handle) {
2238 if (((Control)control.Current).Parent != null) {
2239 return ((Control)control.Current).Parent;
2246 [EditorBrowsable(EditorBrowsableState.Advanced)]
2247 public static Control FromHandle(IntPtr handle) {
2248 IEnumerator control = Control.controls.GetEnumerator();
2250 while (control.MoveNext()) {
2251 if (((Control)control.Current).window.Handle == handle) {
2253 return ((Control)control.Current);
2259 public static bool IsMnemonic(char charCode, string text) {
2262 amp = text.IndexOf('&');
2265 if (amp + 1 < text.Length) {
2266 if (text[amp + 1] != '&') {
2267 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2277 #region Protected Static Methods
2278 [EditorBrowsable(EditorBrowsableState.Advanced)]
2279 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2282 c = Control.FromHandle(hWnd);
2292 #region Public Instance Methods
2293 [EditorBrowsable(EditorBrowsableState.Advanced)]
2294 public IAsyncResult BeginInvoke(Delegate method) {
2295 return BeginInvokeInternal(method, null);
2298 [EditorBrowsable(EditorBrowsableState.Advanced)]
2299 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2300 return BeginInvokeInternal (method, args);
2303 public void BringToFront() {
2304 if ((parent != null) && (parent.child_controls[0]!=this)) {
2305 if (parent.child_controls.Contains(this)) {
2306 parent.child_controls.SetChildIndex(this, 0);
2310 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
2312 if (parent != null) {
2317 public bool Contains(Control ctl) {
2318 while (ctl != null) {
2327 public void CreateControl() {
2329 if (!IsHandleCreated) {
2333 if (!create_handled) {
2334 create_handled = true;
2338 Control [] controls = child_controls.GetAllControls ();
2339 for (int i=0; i<controls.Length; i++) {
2340 controls [i].CreateControl ();
2344 public Graphics CreateGraphics() {
2345 if (!IsHandleCreated) {
2346 this.CreateControl();
2348 return Graphics.FromHwnd(this.window.Handle);
2351 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2352 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2355 [EditorBrowsable(EditorBrowsableState.Advanced)]
2356 public object EndInvoke (IAsyncResult async_result) {
2357 AsyncMethodResult result = (AsyncMethodResult) async_result;
2358 return result.EndInvoke ();
2361 public Form FindForm() {
2374 public bool Focus() {
2375 if (IsHandleCreated && !has_focus) {
2377 XplatUI.SetFocus(window.Handle);
2382 public Control GetChildAtPoint(Point pt) {
2383 // Microsoft's version of this function doesn't seem to work, so I can't check
2384 // if we only consider children or also grandchildren, etc.
2385 // I'm gonna say 'children only'
2386 for (int i=0; i<child_controls.Count; i++) {
2387 if (child_controls[i].Bounds.Contains(pt)) {
2388 return child_controls[i];
2394 public IContainerControl GetContainerControl() {
2395 Control current = this;
2397 while (current!=null) {
2398 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2399 return (IContainerControl)current;
2401 current = current.parent;
2406 public Control GetNextControl(Control ctl, bool forward) {
2407 // If we're not a container we don't play
2408 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2412 // If ctl is not contained by this, we start at the first child of this
2413 if (!this.Contains(ctl)) {
2417 // Search through our controls, starting at ctl, stepping into children as we encounter them
2418 // try to find the control with the tabindex closest to our own, or, if we're looking into
2419 // child controls, the one with the smallest tabindex
2421 return FindControlForward(this, ctl);
2423 return FindControlBackward(this, ctl);
2426 public void Hide() {
2427 this.Visible = false;
2430 public void Invalidate() {
2431 Invalidate(ClientRectangle, false);
2434 public void Invalidate(bool invalidateChildren) {
2435 Invalidate(ClientRectangle, invalidateChildren);
2438 public void Invalidate(System.Drawing.Rectangle rc) {
2439 Invalidate(rc, false);
2442 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2443 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2447 NotifyInvalidate(rc);
2449 XplatUI.Invalidate(Handle, rc, false);
2451 if (invalidateChildren) {
2452 Control [] controls = child_controls.GetAllControls ();
2453 for (int i=0; i<controls.Length; i++)
2454 controls [i].Invalidate ();
2456 OnInvalidated(new InvalidateEventArgs(rc));
2459 public void Invalidate(System.Drawing.Region region) {
2460 Invalidate(region, false);
2463 [MonoTODO("Figure out if GetRegionScans is usable")]
2464 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2465 throw new NotImplementedException();
2467 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2468 //if (invalidateChildren) {
2469 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2473 public object Invoke (Delegate method) {
2474 return Invoke(method, null);
2477 public object Invoke (Delegate method, object[] args) {
2478 if (!this.InvokeRequired) {
2479 return method.DynamicInvoke(args);
2482 IAsyncResult result = BeginInvoke (method, args);
2483 return EndInvoke(result);
2486 [EditorBrowsable(EditorBrowsableState.Advanced)]
2487 public void PerformLayout() {
2488 PerformLayout(null, null);
2491 [EditorBrowsable(EditorBrowsableState.Advanced)]
2492 public void PerformLayout(Control affectedControl, string affectedProperty) {
2493 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2495 if (layout_suspended > 0) {
2496 layout_pending = true;
2500 layout_pending = false;
2502 // Prevent us from getting messed up
2505 // Perform all Dock and Anchor calculations
2508 AnchorStyles anchor;
2511 space=this.DisplayRectangle;
2513 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2514 Control [] controls = child_controls.GetAllControls ();
2515 for (int i = controls.Length - 1; i >= 0; i--) {
2516 child = controls [i];
2517 switch (child.Dock) {
2518 case DockStyle.None: {
2523 case DockStyle.Left: {
2524 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2525 space.X+=child.Width;
2526 space.Width-=child.Width;
2530 case DockStyle.Top: {
2531 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2532 space.Y+=child.Height;
2533 space.Height-=child.Height;
2537 case DockStyle.Right: {
2538 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2539 space.Width-=child.Width;
2543 case DockStyle.Bottom: {
2544 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2545 space.Height-=child.Height;
2551 for (int i = controls.Length - 1; i >= 0; i--) {
2554 if (child.Dock == DockStyle.Fill) {
2555 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2561 space=this.DisplayRectangle;
2563 for (int i=0; i < controls.Length; i++) {
2569 child = controls[i];
2570 anchor = child.Anchor;
2574 width = child.Width;
2575 height = child.Height;
2577 // If the control is docked we don't need to do anything
2578 if (child.Dock != DockStyle.None) {
2582 if ((anchor & AnchorStyles.Left) !=0 ) {
2583 if ((anchor & AnchorStyles.Right) != 0) {
2584 width = client_size.Width - child.dist_right - left;
2586 ; // Left anchored only, nothing to be done
2588 } else if ((anchor & AnchorStyles.Right) != 0) {
2589 left = client_size.Width - child.dist_right - width;
2591 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
2592 // This calculates from scratch every time:
2593 left = child.dist_left + (client_size.Width - (child.dist_left + width + child.dist_right)) / 2;
2596 if ((anchor & AnchorStyles.Top) !=0 ) {
2597 if ((anchor & AnchorStyles.Bottom) != 0) {
2598 height = client_size.Height - child.dist_bottom - top;
2600 ; // Top anchored only, nothing to be done
2602 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2603 top = client_size.Height - child.dist_bottom - height;
2605 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
2606 // This calculates from scratch every time:
2607 top = child.dist_top + (client_size.Height - (child.dist_top + height + child.dist_bottom)) / 2;
2619 child.SetBounds(left, top, width, height);
2622 // Let everyone know
2626 // Need to make sure we decremend layout_suspended
2632 public Point PointToClient (Point p) {
2636 XplatUI.ScreenToClient (Handle, ref x, ref y);
2638 return new Point (x, y);
2641 public Point PointToScreen(Point p) {
2645 XplatUI.ClientToScreen(Handle, ref x, ref y);
2647 return new Point(x, y);
2650 public virtual bool PreProcessMessage(ref Message msg) {
2653 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
2654 key_data = (Keys)msg.WParam.ToInt32();
2655 if (!ProcessCmdKey(ref msg, key_data)) {
2656 if (IsInputKey(key_data)) {
2660 return ProcessDialogKey(key_data);
2664 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2665 if (IsInputChar((char)msg.WParam)) {
2668 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
2669 if (IsInputChar((char)msg.WParam)) {
2672 return ProcessDialogChar((char)msg.WParam);
2677 public Rectangle RectangleToClient(Rectangle r) {
2678 return new Rectangle(PointToClient(r.Location), r.Size);
2681 public Rectangle RectangleToScreen(Rectangle r) {
2682 return new Rectangle(PointToScreen(r.Location), r.Size);
2685 public virtual void Refresh() {
2686 if (IsHandleCreated == true) {
2689 XplatUI.UpdateWindow(window.Handle);
2691 Control [] controls = child_controls.GetAllControls ();
2692 for (int i=0; i < controls.Length; i++) {
2693 controls[i].Refresh();
2699 [EditorBrowsable(EditorBrowsableState.Never)]
2700 public virtual void ResetBackColor() {
2701 background_color = Color.Empty;
2704 [EditorBrowsable(EditorBrowsableState.Never)]
2706 public void ResetBindings() {
2710 [EditorBrowsable(EditorBrowsableState.Never)]
2711 public virtual void ResetCursor() {
2715 [EditorBrowsable(EditorBrowsableState.Never)]
2716 public virtual void ResetFont() {
2720 [EditorBrowsable(EditorBrowsableState.Never)]
2721 public virtual void ResetForeColor() {
2722 foreground_color = Color.Empty;
2725 [EditorBrowsable(EditorBrowsableState.Never)]
2726 public void ResetImeMode() {
2727 ime_mode = DefaultImeMode;
2730 [EditorBrowsable(EditorBrowsableState.Never)]
2731 public virtual void ResetRightToLeft() {
2732 right_to_left = RightToLeft.Inherit;
2735 public virtual void ResetText() {
2736 text = String.Empty;
2739 public void ResumeLayout() {
2740 ResumeLayout (true);
2743 public void ResumeLayout(bool performLayout) {
2746 if (layout_suspended > 0) {
2750 if (performLayout || layout_pending) {
2755 public void Scale(float ratio) {
2756 ScaleCore(ratio, ratio);
2759 public void Scale(float dx, float dy) {
2763 public void Select() {
2764 Select(false, false);
2767 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2772 c = GetNextControl(c, forward);
2781 if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
2785 } while (c != ctl); // If we wrap back to ourselves we stop
2790 public void SendToBack() {
2791 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2792 if (parent.child_controls.Contains(this)) {
2793 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2797 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2798 if (parent != null) {
2803 public void SetBounds(int x, int y, int width, int height) {
2804 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2807 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2808 SetBoundsCore(x, y, width, height, specified);
2811 public void Show() {
2812 if (!IsHandleCreated) {
2813 this.CreateControl();
2819 public void SuspendLayout() {
2823 public void Update() {
2824 needs_redraw = true;
2825 if (IsHandleCreated) {
2826 XplatUI.UpdateWindow(window.Handle);
2829 #endregion // Public Instance Methods
2831 #region Protected Instance Methods
2832 [EditorBrowsable(EditorBrowsableState.Advanced)]
2833 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2834 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2835 throw new NotImplementedException();
2838 [EditorBrowsable(EditorBrowsableState.Advanced)]
2839 protected virtual AccessibleObject CreateAccessibilityInstance() {
2840 return new Control.ControlAccessibleObject(this);
2843 [EditorBrowsable(EditorBrowsableState.Advanced)]
2844 protected virtual ControlCollection CreateControlsInstance() {
2845 return new ControlCollection(this);
2848 [EditorBrowsable(EditorBrowsableState.Advanced)]
2849 protected virtual void CreateHandle() {
2851 throw new ObjectDisposedException(Name);
2854 if (IsHandleCreated) {
2858 window.CreateHandle(CreateParams);
2860 // Find out where the window manager placed us
2862 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
2863 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
2867 if (window.Handle!=IntPtr.Zero) {
2868 if (!controls.Contains(window.Handle)) {
2872 creator_thread = Thread.CurrentThread;
2874 OnHandleCreated(EventArgs.Empty);
2878 [EditorBrowsable(EditorBrowsableState.Advanced)]
2879 protected virtual void DefWndProc(ref Message m) {
2880 window.DefWndProc(ref m);
2883 [EditorBrowsable(EditorBrowsableState.Advanced)]
2884 protected virtual void DestroyHandle() {
2885 if (IsHandleCreated) {
2886 // Destroy our children before we destroy ourselves, to prevent them from
2887 // being implictly (without us knowing) destroyed
2888 Control [] controls = child_controls.GetAllControls ();
2889 for (int i=0; i < controls.Length; i++) {
2890 controls[i].DestroyHandle();
2894 if (window != null) {
2895 window.DestroyHandle();
2897 OnHandleDestroyed(EventArgs.Empty);
2901 protected bool GetStyle(ControlStyles flag) {
2902 return (control_style & flag) != 0;
2905 protected bool GetTopLevel() {
2909 [EditorBrowsable(EditorBrowsableState.Advanced)]
2910 protected virtual void InitLayout() {
2911 dist_left = bounds.X;
2912 dist_top = bounds.Y;
2913 if (parent != null) {
2914 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
2915 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
2919 [EditorBrowsable(EditorBrowsableState.Advanced)]
2920 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2921 toInvoke.OnGotFocus(e);
2924 [EditorBrowsable(EditorBrowsableState.Advanced)]
2925 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2926 toInvoke.OnLostFocus(e);
2929 [EditorBrowsable(EditorBrowsableState.Advanced)]
2930 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2931 toInvoke.OnClick(e);
2934 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2935 toInvoke.OnPaint(e);
2938 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2939 toInvoke.OnPaintBackground(e);
2942 protected virtual bool IsInputChar (char charCode) {
2943 if (parent != null) {
2944 return parent.IsInputChar(charCode);
2950 protected virtual bool IsInputKey (Keys keyData) {
2951 // Doc says this one calls IsInputChar; not sure what to do with that
2955 [EditorBrowsable(EditorBrowsableState.Advanced)]
2956 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2960 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2961 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2965 if (parent != null) {
2966 return parent.ProcessCmdKey(ref msg, keyData);
2972 protected virtual bool ProcessDialogChar(char charCode) {
2973 if (parent != null) {
2974 return parent.ProcessDialogChar (charCode);
2980 protected virtual bool ProcessDialogKey (Keys keyData) {
2981 if (parent != null) {
2982 return parent.ProcessDialogKey (keyData);
2988 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2990 KeyEventArgs key_event;
2993 case (int)Msg.WM_KEYDOWN: {
2994 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2995 OnKeyDown (key_event);
2996 return key_event.Handled;
2998 case (int)Msg.WM_KEYUP: {
2999 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3000 OnKeyUp (key_event);
3001 return key_event.Handled;
3004 case (int)Msg.WM_CHAR: {
3005 KeyPressEventArgs key_press_event;
3007 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3008 OnKeyPress(key_press_event);
3009 return key_press_event.Handled;
3020 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3021 if (parent != null) {
3022 if (parent.ProcessKeyPreview(ref msg)) {
3030 protected virtual bool ProcessKeyPreview(ref Message msg) {
3031 if (parent != null) {
3032 return parent.ProcessKeyPreview(ref msg);
3038 protected virtual bool ProcessMnemonic(char charCode) {
3043 [EditorBrowsable(EditorBrowsableState.Advanced)]
3044 protected void RaiseDragEvent(object key, DragEventArgs e) {
3048 [EditorBrowsable(EditorBrowsableState.Advanced)]
3049 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3053 [EditorBrowsable(EditorBrowsableState.Advanced)]
3054 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3058 [EditorBrowsable(EditorBrowsableState.Advanced)]
3059 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3063 [EditorBrowsable(EditorBrowsableState.Advanced)]
3064 protected void RecreateHandle() {
3065 IEnumerator child = child_controls.GetAllEnumerator();
3069 if (IsHandleCreated) {
3075 while (child.MoveNext()) {
3076 ((Control)child.Current).RecreateHandle();
3082 is_recreating = false;
3085 [EditorBrowsable(EditorBrowsableState.Advanced)]
3086 protected void ResetMouseEventArgs() {
3090 [EditorBrowsable(EditorBrowsableState.Advanced)]
3091 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3092 if (right_to_left == RightToLeft.No) {
3097 case ContentAlignment.TopLeft: {
3098 return ContentAlignment.TopRight;
3101 case ContentAlignment.TopRight: {
3102 return ContentAlignment.TopLeft;
3105 case ContentAlignment.MiddleLeft: {
3106 return ContentAlignment.MiddleRight;
3109 case ContentAlignment.MiddleRight: {
3110 return ContentAlignment.MiddleLeft;
3113 case ContentAlignment.BottomLeft: {
3114 return ContentAlignment.BottomRight;
3117 case ContentAlignment.BottomRight: {
3118 return ContentAlignment.BottomLeft;
3122 // if it's center it doesn't change
3128 [EditorBrowsable(EditorBrowsableState.Advanced)]
3129 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3130 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3134 if (align == HorizontalAlignment.Left) {
3135 return HorizontalAlignment.Right;
3138 // align must be HorizontalAlignment.Right
3139 return HorizontalAlignment.Left;
3142 [EditorBrowsable(EditorBrowsableState.Advanced)]
3143 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3144 if (right_to_left == RightToLeft.No) {
3148 if (align == LeftRightAlignment.Left) {
3149 return LeftRightAlignment.Right;
3152 // align must be LeftRightAlignment.Right;
3153 return LeftRightAlignment.Left;
3156 [EditorBrowsable(EditorBrowsableState.Advanced)]
3157 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3158 return RtlTranslateAlignment(align);
3161 [EditorBrowsable(EditorBrowsableState.Advanced)]
3162 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3163 return RtlTranslateAlignment(align);
3166 [EditorBrowsable(EditorBrowsableState.Advanced)]
3167 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3168 return RtlTranslateAlignment(align);
3171 [EditorBrowsable(EditorBrowsableState.Advanced)]
3172 protected virtual void ScaleCore(float dx, float dy) {
3178 location = new Point((int)(Left * dx), (int)(Top * dy));
3179 size = this.ClientSize;
3182 if (!GetStyle(ControlStyles.FixedWidth)) {
3183 size.Width = (int)(size.Width * dx);
3186 if (!GetStyle(ControlStyles.FixedHeight)) {
3187 size.Height = (int)(size.Height * dy);
3190 Location = location;
3193 /* Now scale our children */
3194 Control [] controls = child_controls.GetAllControls ();
3195 for (int i=0; i < controls.Length; i++) {
3196 controls[i].Scale(dx, dy);
3202 protected virtual void Select(bool directed, bool forward) {
3207 // Select this control
3212 if (parent == null) {
3216 // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
3218 index = parent.child_controls.IndexOf(this);
3223 if ((index+1) < parent.child_controls.Count) {
3232 index = parent.child_controls.Count-1;
3235 result = Select(parent.child_controls[index]);
3236 } while (!result && parent.child_controls[index] != this);
3239 [EditorBrowsable(EditorBrowsableState.Advanced)]
3240 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3241 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3242 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3246 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3250 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3254 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3258 if (IsHandleCreated) {
3259 XplatUI.SetWindowPos(Handle, x, y, width, height);
3262 UpdateBounds(x, y, width, height);
3265 Control [] controls = child_controls.GetAllControls ();
3266 for (int i = controls.Length - 1; i >= 0; i--) {
3267 controls[i].InitLayout();
3271 [EditorBrowsable(EditorBrowsableState.Advanced)]
3272 protected virtual void SetClientSizeCore(int x, int y) {
3273 // Calculate the actual window size from the client size (it usually stays the same or grows)
3274 Rectangle ClientRect;
3275 Rectangle WindowRect;
3278 ClientRect = new Rectangle(0, 0, x, y);
3279 cp = this.CreateParams;
3281 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
3285 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3288 [EditorBrowsable(EditorBrowsableState.Advanced)]
3289 protected void SetStyle(ControlStyles flag, bool value) {
3291 control_style |= flag;
3293 control_style &= ~flag;
3295 OnStyleChanged(EventArgs.Empty);
3298 protected void SetTopLevel(bool value) {
3299 if ((GetTopLevel() != value) && (parent != null)) {
3300 throw new Exception();
3304 if (value == true) {
3314 is_toplevel = value;
3317 protected virtual void SetVisibleCore(bool value) {
3318 if (value!=is_visible) {
3321 if (IsHandleCreated) {
3322 XplatUI.SetVisible(Handle, value);
3323 // Explicitly move Toplevel windows to where we want them;
3324 // apparently moving unmapped toplevel windows doesn't work
3325 if (is_visible && (this is Form)) {
3326 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3330 OnVisibleChanged(EventArgs.Empty);
3333 if (dc_mem != null) {
3338 if (bmp_mem != null) {
3343 this.CreateBuffers(bounds.Width, bounds.Height);
3347 if (value == false && parent != null) {
3350 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3351 container = (Control)parent.GetContainerControl();
3352 if (container != null) {
3353 container.SelectNextControl(this, true, true, true, true);
3357 if (parent != null) {
3358 parent.PerformLayout(this, "visible");
3360 PerformLayout(this, "visible");
3365 [EditorBrowsable(EditorBrowsableState.Advanced)]
3366 protected void UpdateBounds() {
3374 if (!IsHandleCreated) {
3378 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3380 UpdateBounds(x, y, width, height, client_width, client_height);
3383 [EditorBrowsable(EditorBrowsableState.Advanced)]
3384 protected void UpdateBounds(int x, int y, int width, int height) {
3385 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3387 bool resized = false;
3389 int client_x_diff = this.bounds.Width-this.client_size.Width;
3390 int client_y_diff = this.bounds.Height-this.client_size.Height;
3392 // Needed to generate required notifications
3393 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3397 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3404 bounds.Height=height;
3406 // Update client rectangle as well
3407 client_size.Width=width-client_x_diff;
3408 client_size.Height=height-client_y_diff;
3411 OnLocationChanged(EventArgs.Empty);
3415 OnSizeChanged(EventArgs.Empty);
3419 [EditorBrowsable(EditorBrowsableState.Advanced)]
3420 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3421 UpdateBounds(x, y, width, height);
3423 this.client_size.Width=clientWidth;
3424 this.client_size.Height=clientHeight;
3427 [EditorBrowsable(EditorBrowsableState.Advanced)]
3428 protected void UpdateStyles() {
3429 if (!IsHandleCreated) {
3433 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3436 [EditorBrowsable(EditorBrowsableState.Advanced)]
3437 protected void UpdateZOrder() {
3438 Control [] controls;
3442 if (parent == null) {
3448 controls = ctl.child_controls.GetAllControls ();
3449 for (int i = 1; i < controls.Length; i++ ) {
3450 XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
3453 if (!IsHandleCreated) {
3457 controls = child_controls.GetAllControls ();
3458 for (int i = 1; i < controls.Length; i++ ) {
3459 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3464 protected virtual void WndProc(ref Message m) {
3466 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3468 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3472 switch((Msg)m.Msg) {
3473 case Msg.WM_WINDOWPOSCHANGED: {
3476 if (GetStyle(ControlStyles.ResizeRedraw)) {
3483 case Msg.WM_PAINT: {
3484 PaintEventArgs paint_event;
3486 paint_event = XplatUI.PaintEventStart(Handle, true);
3488 if (!needs_redraw) {
3489 // Just blit the previous image
3490 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3491 XplatUI.PaintEventEnd(Handle, true);
3496 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3497 dc = paint_event.SetGraphics (DeviceContext);
3500 if ((control_style & (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) == (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
3501 OnPaintBackground(paint_event);
3503 PaintControlBackground(paint_event);
3506 OnPaint(paint_event);
3508 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3509 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3510 paint_event.SetGraphics (dc);
3511 needs_redraw = false;
3514 XplatUI.PaintEventEnd(Handle, true);
3519 case Msg.WM_ERASEBKGND: {
3520 // The DefWndProc will never have to handle this, we always paint the background in managed code
3521 m.Result = (IntPtr)1;
3525 case Msg.WM_LBUTTONUP: {
3526 HandleClick(mouse_clicks);
3527 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3529 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3531 if (mouse_clicks > 1) {
3537 case Msg.WM_LBUTTONDOWN: {
3538 if (CanSelect && !is_selected) {
3541 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3542 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3548 case Msg.WM_LBUTTONDBLCLK: {
3550 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3551 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3557 case Msg.WM_MBUTTONUP: {
3558 HandleClick(mouse_clicks);
3559 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3561 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3563 if (mouse_clicks > 1) {
3569 case Msg.WM_MBUTTONDOWN: {
3570 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3571 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3577 case Msg.WM_MBUTTONDBLCLK: {
3579 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3580 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3585 case Msg.WM_RBUTTONUP: {
3586 if (context_menu != null) {
3587 context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
3590 HandleClick(mouse_clicks);
3591 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3593 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3595 if (mouse_clicks > 1) {
3601 case Msg.WM_RBUTTONDOWN: {
3602 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3603 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3608 case Msg.WM_RBUTTONDBLCLK: {
3610 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3611 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3616 case Msg.WM_MOUSEWHEEL: {
3618 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3619 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3620 HighOrder(m.WParam.ToInt32())));
3625 case Msg.WM_MOUSEMOVE: {
3626 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3628 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3633 case Msg.WM_MOUSE_ENTER: {
3638 OnMouseEnter(EventArgs.Empty);
3642 case Msg.WM_MOUSE_LEAVE: {
3644 OnMouseLeave(EventArgs.Empty);
3648 case Msg.WM_MOUSEHOVER: {
3649 OnMouseHover(EventArgs.Empty);
3653 case Msg.WM_SYSKEYDOWN:
3654 case Msg.WM_KEYDOWN:
3655 case Msg.WM_SYSKEYUP:
3657 case Msg.WM_SYSCHAR:
3659 Console.WriteLine("Got {0}", (Msg)m.Msg);
3660 if (ProcessKeyEventArgs(ref m)) {
3664 if (PreProcessMessage(ref m)) {
3668 if (ProcessKeyMessage(ref m)) {
3677 if (m.LParam != IntPtr.Zero) {
3680 hi = new HELPINFO();
3682 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3683 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3685 mouse_pos = Control.MousePosition;
3687 OnHelpRequested(new HelpEventArgs(mouse_pos));
3688 m.Result = (IntPtr)1;
3692 case Msg.WM_KILLFOCUS: {
3693 OnLeave(EventArgs.Empty);
3694 if (CausesValidation) {
3696 e = new CancelEventArgs(false);
3705 OnValidated(EventArgs.Empty);
3708 this.has_focus = false;
3709 this.is_selected = false;
3710 OnLostFocus(EventArgs.Empty);
3714 case Msg.WM_SETFOCUS: {
3715 OnEnter(EventArgs.Empty);
3716 this.has_focus = true;
3717 OnGotFocus(EventArgs.Empty);
3722 case Msg.WM_SYSCOLORCHANGE: {
3723 ThemeEngine.Current.ResetDefaults();
3724 OnSystemColorsChanged(EventArgs.Empty);
3729 case Msg.WM_SETCURSOR: {
3730 if (cursor == null) {
3735 XplatUI.SetCursor(window.Handle, cursor.handle);
3736 m.Result = (IntPtr)1;
3747 #endregion // Public Instance Methods
3749 #region OnXXX methods
3750 [EditorBrowsable(EditorBrowsableState.Advanced)]
3751 protected virtual void OnBackColorChanged(EventArgs e) {
3752 if (BackColorChanged!=null) BackColorChanged(this, e);
3753 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3756 [EditorBrowsable(EditorBrowsableState.Advanced)]
3757 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3758 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3759 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3762 [EditorBrowsable(EditorBrowsableState.Advanced)]
3763 protected virtual void OnBindingContextChanged(EventArgs e) {
3764 CheckDataBindings ();
3765 if (BindingContextChanged!=null) {
3766 BindingContextChanged(this, e);
3768 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3771 [EditorBrowsable(EditorBrowsableState.Advanced)]
3772 protected virtual void OnCausesValidationChanged(EventArgs e) {
3773 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3776 [EditorBrowsable(EditorBrowsableState.Advanced)]
3777 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3778 if (ChangeUICues!=null) ChangeUICues(this, e);
3781 [EditorBrowsable(EditorBrowsableState.Advanced)]
3782 protected virtual void OnClick(EventArgs e) {
3783 if (Click!=null) Click(this, e);
3786 [EditorBrowsable(EditorBrowsableState.Advanced)]
3787 protected virtual void OnContextMenuChanged(EventArgs e) {
3788 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3791 [EditorBrowsable(EditorBrowsableState.Advanced)]
3792 protected virtual void OnControlAdded(ControlEventArgs e) {
3793 if (ControlAdded!=null) ControlAdded(this, e);
3796 [EditorBrowsable(EditorBrowsableState.Advanced)]
3797 protected virtual void OnControlRemoved(ControlEventArgs e) {
3798 if (ControlRemoved!=null) ControlRemoved(this, e);
3801 [EditorBrowsable(EditorBrowsableState.Advanced)]
3802 protected virtual void OnCreateControl() {
3806 [EditorBrowsable(EditorBrowsableState.Advanced)]
3807 protected virtual void OnCursorChanged(EventArgs e) {
3808 if (CursorChanged!=null) CursorChanged(this, e);
3811 [EditorBrowsable(EditorBrowsableState.Advanced)]
3812 protected virtual void OnDockChanged(EventArgs e) {
3813 if (DockChanged!=null) DockChanged(this, e);
3816 [EditorBrowsable(EditorBrowsableState.Advanced)]
3817 protected virtual void OnDoubleClick(EventArgs e) {
3818 if (DoubleClick!=null) DoubleClick(this, e);
3821 [EditorBrowsable(EditorBrowsableState.Advanced)]
3822 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3823 if (DragDrop!=null) DragDrop(this, drgevent);
3826 [EditorBrowsable(EditorBrowsableState.Advanced)]
3827 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3828 if (DragEnter!=null) DragEnter(this, drgevent);
3831 [EditorBrowsable(EditorBrowsableState.Advanced)]
3832 protected virtual void OnDragLeave(EventArgs e) {
3833 if (DragLeave!=null) DragLeave(this, e);
3836 [EditorBrowsable(EditorBrowsableState.Advanced)]
3837 protected virtual void OnDragOver(DragEventArgs drgevent) {
3838 if (DragOver!=null) DragOver(this, drgevent);
3841 [EditorBrowsable(EditorBrowsableState.Advanced)]
3842 protected virtual void OnEnabledChanged(EventArgs e) {
3843 if (EnabledChanged!=null) EnabledChanged(this, e);
3844 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3847 [EditorBrowsable(EditorBrowsableState.Advanced)]
3848 protected virtual void OnEnter(EventArgs e) {
3849 if (Enter!=null) Enter(this, e);
3852 [EditorBrowsable(EditorBrowsableState.Advanced)]
3853 protected virtual void OnFontChanged(EventArgs e) {
3854 if (FontChanged!=null) FontChanged(this, e);
3855 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3858 [EditorBrowsable(EditorBrowsableState.Advanced)]
3859 protected virtual void OnForeColorChanged(EventArgs e) {
3860 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3861 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3864 [EditorBrowsable(EditorBrowsableState.Advanced)]
3865 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3866 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3869 [EditorBrowsable(EditorBrowsableState.Advanced)]
3870 protected virtual void OnGotFocus(EventArgs e) {
3871 if (GotFocus!=null) GotFocus(this, e);
3874 [EditorBrowsable(EditorBrowsableState.Advanced)]
3875 protected virtual void OnHandleCreated(EventArgs e) {
3876 if (HandleCreated!=null) HandleCreated(this, e);
3879 [EditorBrowsable(EditorBrowsableState.Advanced)]
3880 protected virtual void OnHandleDestroyed(EventArgs e) {
3881 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3884 [EditorBrowsable(EditorBrowsableState.Advanced)]
3885 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3886 if (HelpRequested!=null) HelpRequested(this, hevent);
3889 protected virtual void OnImeModeChanged(EventArgs e) {
3890 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3893 [EditorBrowsable(EditorBrowsableState.Advanced)]
3894 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3895 needs_redraw = true;
3896 if (Invalidated!=null) Invalidated(this, e);
3899 [EditorBrowsable(EditorBrowsableState.Advanced)]
3900 protected virtual void OnKeyDown(KeyEventArgs e) {
3901 if (KeyDown!=null) KeyDown(this, e);
3904 [EditorBrowsable(EditorBrowsableState.Advanced)]
3905 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3906 if (KeyPress!=null) KeyPress(this, e);
3909 [EditorBrowsable(EditorBrowsableState.Advanced)]
3910 protected virtual void OnKeyUp(KeyEventArgs e) {
3911 if (KeyUp!=null) KeyUp(this, e);
3914 [EditorBrowsable(EditorBrowsableState.Advanced)]
3915 protected virtual void OnLayout(LayoutEventArgs levent) {
3916 if (Layout!=null) Layout(this, levent);
3919 [EditorBrowsable(EditorBrowsableState.Advanced)]
3920 protected virtual void OnLeave(EventArgs e) {
3921 if (Leave!=null) Leave(this, e);
3924 [EditorBrowsable(EditorBrowsableState.Advanced)]
3925 protected virtual void OnLocationChanged(EventArgs e) {
3927 if (LocationChanged!=null) LocationChanged(this, e);
3930 [EditorBrowsable(EditorBrowsableState.Advanced)]
3931 protected virtual void OnLostFocus(EventArgs e) {
3932 if (LostFocus!=null) LostFocus(this, e);
3935 [EditorBrowsable(EditorBrowsableState.Advanced)]
3936 protected virtual void OnMouseDown(MouseEventArgs e) {
3937 if (MouseDown!=null) MouseDown(this, e);
3940 [EditorBrowsable(EditorBrowsableState.Advanced)]
3941 protected virtual void OnMouseEnter(EventArgs e) {
3942 if (MouseEnter!=null) MouseEnter(this, e);
3945 [EditorBrowsable(EditorBrowsableState.Advanced)]
3946 protected virtual void OnMouseHover(EventArgs e) {
3947 if (MouseHover!=null) MouseHover(this, e);
3950 [EditorBrowsable(EditorBrowsableState.Advanced)]
3951 protected virtual void OnMouseLeave(EventArgs e) {
3952 if (MouseLeave!=null) MouseLeave(this, e);
3955 [EditorBrowsable(EditorBrowsableState.Advanced)]
3956 protected virtual void OnMouseMove(MouseEventArgs e) {
3957 if (MouseMove!=null) MouseMove(this, e);
3960 [EditorBrowsable(EditorBrowsableState.Advanced)]
3961 protected virtual void OnMouseUp(MouseEventArgs e) {
3962 if (MouseUp!=null) MouseUp(this, e);
3965 [EditorBrowsable(EditorBrowsableState.Advanced)]
3966 protected virtual void OnMouseWheel(MouseEventArgs e) {
3967 if (MouseWheel!=null) MouseWheel(this, e);
3970 [EditorBrowsable(EditorBrowsableState.Advanced)]
3971 protected virtual void OnMove(EventArgs e) {
3972 if (Move!=null) Move(this, e);
3975 [EditorBrowsable(EditorBrowsableState.Advanced)]
3976 protected virtual void OnNotifyMessage(Message m) {
3980 [EditorBrowsable(EditorBrowsableState.Advanced)]
3981 protected virtual void OnPaint(PaintEventArgs e) {
3982 if (Paint!=null) Paint(this, e);
3985 [EditorBrowsable(EditorBrowsableState.Advanced)]
3986 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3987 PaintControlBackground (pevent);
3990 [EditorBrowsable(EditorBrowsableState.Advanced)]
3991 protected virtual void OnParentBackColorChanged(EventArgs e) {
3992 if (background_color.IsEmpty && background_image==null) {
3994 OnBackColorChanged(e);
3998 [EditorBrowsable(EditorBrowsableState.Advanced)]
3999 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4000 if (background_color.IsEmpty && background_image==null) {
4002 OnBackgroundImageChanged(e);
4006 [EditorBrowsable(EditorBrowsableState.Advanced)]
4007 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4008 if (binding_context==null) {
4009 binding_context=Parent.binding_context;
4010 OnBindingContextChanged(e);
4014 [EditorBrowsable(EditorBrowsableState.Advanced)]
4015 protected virtual void OnParentChanged(EventArgs e) {
4016 if (ParentChanged!=null) ParentChanged(this, e);
4019 [EditorBrowsable(EditorBrowsableState.Advanced)]
4020 protected virtual void OnParentEnabledChanged(EventArgs e) {
4021 if (is_enabled != Parent.is_enabled) {
4022 is_enabled=Parent.is_enabled;
4024 if (EnabledChanged != null) {
4025 EnabledChanged(this, e);
4030 [EditorBrowsable(EditorBrowsableState.Advanced)]
4031 protected virtual void OnParentFontChanged(EventArgs e) {
4038 [EditorBrowsable(EditorBrowsableState.Advanced)]
4039 protected virtual void OnParentForeColorChanged(EventArgs e) {
4040 if (foreground_color.IsEmpty) {
4042 OnForeColorChanged(e);
4046 [EditorBrowsable(EditorBrowsableState.Advanced)]
4047 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4048 if (right_to_left==RightToLeft.Inherit) {
4050 OnRightToLeftChanged(e);
4054 [EditorBrowsable(EditorBrowsableState.Advanced)]
4055 protected virtual void OnParentVisibleChanged(EventArgs e) {
4057 OnVisibleChanged(e);
4061 [EditorBrowsable(EditorBrowsableState.Advanced)]
4062 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4063 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
4066 [EditorBrowsable(EditorBrowsableState.Advanced)]
4067 protected virtual void OnResize(EventArgs e) {
4068 if (Resize!=null) Resize(this, e);
4070 PerformLayout(this, "bounds");
4072 if (parent != null) {
4073 parent.PerformLayout();
4077 [EditorBrowsable(EditorBrowsableState.Advanced)]
4078 protected virtual void OnRightToLeftChanged(EventArgs e) {
4079 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
4080 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4083 [EditorBrowsable(EditorBrowsableState.Advanced)]
4084 protected virtual void OnSizeChanged(EventArgs e) {
4085 InvalidateBuffers ();
4087 if (SizeChanged!=null) SizeChanged(this, e);
4090 [EditorBrowsable(EditorBrowsableState.Advanced)]
4091 protected virtual void OnStyleChanged(EventArgs e) {
4092 if (StyleChanged!=null) StyleChanged(this, e);
4095 [EditorBrowsable(EditorBrowsableState.Advanced)]
4096 protected virtual void OnSystemColorsChanged(EventArgs e) {
4097 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
4100 [EditorBrowsable(EditorBrowsableState.Advanced)]
4101 protected virtual void OnTabIndexChanged(EventArgs e) {
4102 if (TabIndexChanged!=null) TabIndexChanged(this, e);
4105 [EditorBrowsable(EditorBrowsableState.Advanced)]
4106 protected virtual void OnTabStopChanged(EventArgs e) {
4107 if (TabStopChanged!=null) TabStopChanged(this, e);
4110 [EditorBrowsable(EditorBrowsableState.Advanced)]
4111 protected virtual void OnTextChanged(EventArgs e) {
4112 if (TextChanged!=null) TextChanged(this, e);
4115 [EditorBrowsable(EditorBrowsableState.Advanced)]
4116 protected virtual void OnValidated(EventArgs e) {
4117 if (Validated!=null) Validated(this, e);
4120 [EditorBrowsable(EditorBrowsableState.Advanced)]
4121 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4122 if (Validating!=null) Validating(this, e);
4125 [EditorBrowsable(EditorBrowsableState.Advanced)]
4126 protected virtual void OnVisibleChanged(EventArgs e) {
4133 if (bmp_mem!=null) {
4139 if (!this.IsHandleCreated) {
4140 this.CreateControl();
4146 if (VisibleChanged!=null) VisibleChanged(this, e);
4148 // We need to tell our kids
4149 for (int i=0; i<child_controls.Count; i++) {
4150 child_controls[i].OnParentVisibleChanged(e);
4153 #endregion // OnXXX methods
4156 public event EventHandler BackColorChanged;
4157 public event EventHandler BackgroundImageChanged;
4158 public event EventHandler BindingContextChanged;
4159 public event EventHandler CausesValidationChanged;
4160 public event UICuesEventHandler ChangeUICues;
4161 public event EventHandler Click;
4162 public event EventHandler ContextMenuChanged;
4164 [EditorBrowsable(EditorBrowsableState.Advanced)]
4166 public event ControlEventHandler ControlAdded;
4168 [EditorBrowsable(EditorBrowsableState.Advanced)]
4170 public event ControlEventHandler ControlRemoved;
4172 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4173 public event EventHandler CursorChanged;
4174 public event EventHandler DockChanged;
4175 public event EventHandler DoubleClick;
4176 public event DragEventHandler DragDrop;
4177 public event DragEventHandler DragEnter;
4178 public event EventHandler DragLeave;
4179 public event DragEventHandler DragOver;
4180 public event EventHandler EnabledChanged;
4181 public event EventHandler Enter;
4182 public event EventHandler FontChanged;
4183 public event EventHandler ForeColorChanged;
4184 public event GiveFeedbackEventHandler GiveFeedback;
4186 [EditorBrowsable(EditorBrowsableState.Advanced)]
4188 public event EventHandler GotFocus;
4190 [EditorBrowsable(EditorBrowsableState.Advanced)]
4192 public event EventHandler HandleCreated;
4194 [EditorBrowsable(EditorBrowsableState.Advanced)]
4196 public event EventHandler HandleDestroyed;
4198 public event HelpEventHandler HelpRequested;
4199 public event EventHandler ImeModeChanged;
4201 [EditorBrowsable(EditorBrowsableState.Advanced)]
4203 public event InvalidateEventHandler Invalidated;
4205 public event KeyEventHandler KeyDown;
4206 public event KeyPressEventHandler KeyPress;
4207 public event KeyEventHandler KeyUp;
4208 public event LayoutEventHandler Layout;
4209 public event EventHandler Leave;
4210 public event EventHandler LocationChanged;
4212 [EditorBrowsable(EditorBrowsableState.Advanced)]
4214 public event EventHandler LostFocus;
4216 public event MouseEventHandler MouseDown;
4217 public event EventHandler MouseEnter;
4218 public event EventHandler MouseHover;
4219 public event EventHandler MouseLeave;
4220 public event MouseEventHandler MouseMove;
4221 public event MouseEventHandler MouseUp;
4223 [EditorBrowsable(EditorBrowsableState.Advanced)]
4225 public event MouseEventHandler MouseWheel;
4227 public event EventHandler Move;
4228 public event PaintEventHandler Paint;
4229 public event EventHandler ParentChanged;
4230 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
4231 public event QueryContinueDragEventHandler QueryContinueDrag;
4232 public event EventHandler Resize;
4233 public event EventHandler RightToLeftChanged;
4234 public event EventHandler SizeChanged;
4235 public event EventHandler StyleChanged;
4236 public event EventHandler SystemColorsChanged;
4237 public event EventHandler TabIndexChanged;
4238 public event EventHandler TabStopChanged;
4239 public event EventHandler TextChanged;
4240 public event EventHandler Validated;
4241 public event CancelEventHandler Validating;
4242 public event EventHandler VisibleChanged;
4243 #endregion // Events