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 void DndEnter (DragEventArgs e)
927 internal void DndOver (DragEventArgs e)
934 internal void DndDrop (DragEventArgs e)
938 } catch (Exception exc) {
939 Console.Error.WriteLine ("MWF: Exception while dropping:");
940 Console.Error.WriteLine (exc);
944 internal void DndLeave (EventArgs e)
951 internal void DnDFeedback(GiveFeedbackEventArgs e)
956 internal void DnDContinueDrag(QueryContinueDragEventArgs e) {
957 OnQueryContinueDrag(e);
960 internal static MouseButtons FromParamToMouseButtons (int param) {
961 MouseButtons buttons = MouseButtons.None;
963 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
964 buttons |= MouseButtons.Left;
966 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
967 buttons |= MouseButtons.Middle;
969 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
970 buttons |= MouseButtons.Right;
976 internal virtual bool ProcessControlMnemonic(char charCode) {
977 return ProcessMnemonic(charCode);
980 private static Control FindFlatForward(Control container, Control start) {
986 end = container.child_controls.Count;
989 index = start.tab_index;
994 for (int i = 0; i < end; i++) {
996 if (container.child_controls[i].tab_index > index) {
997 found = container.child_controls[i];
999 } else if (found.tab_index > container.child_controls[i].tab_index) {
1000 if (container.child_controls[i].tab_index > index) {
1001 found = container.child_controls[i];
1008 private static Control FindControlForward(Control container, Control start) {
1014 if (start != null) {
1015 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
1016 found = FindControlForward(start, null);
1017 if (found != null) {
1023 while (p != container) {
1024 found = FindFlatForward(p, start);
1025 if (found != null) {
1032 return FindFlatForward(container, start);
1035 private static Control FindFlatBackward(Control container, Control start) {
1041 end = container.child_controls.Count;
1043 if (start != null) {
1044 index = start.tab_index;
1046 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1048 for (int i = 0; i < end; i++) {
1049 if (container.child_controls[i].tab_index > index) {
1050 index = container.child_controls[i].tab_index;
1056 for (int i = 0; i < end; i++) {
1057 if (found == null) {
1058 if (container.child_controls[i].tab_index < index) {
1059 found = container.child_controls[i];
1061 } else if (found.tab_index < container.child_controls[i].tab_index) {
1062 if (container.child_controls[i].tab_index < index) {
1063 found = container.child_controls[i];
1070 private static Control FindControlBackward(Control container, Control start) {
1075 if (start != null) {
1076 found = FindFlatBackward(start.parent, start);
1077 if (found == null && start.parent != container) {
1078 return start.parent;
1081 if (found == null) {
1082 found = FindFlatBackward(container, start);
1085 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
1086 found = FindControlBackward(found, null);
1087 if (found != null) {
1095 private void HandleClick(int clicks) {
1096 if (GetStyle(ControlStyles.StandardClick)) {
1098 if (GetStyle(ControlStyles.StandardDoubleClick)) {
1099 OnDoubleClick(EventArgs.Empty);
1101 OnClick(EventArgs.Empty);
1104 OnClick(EventArgs.Empty);
1109 private void CheckDataBindings ()
1111 if (data_bindings == null)
1114 BindingContext binding_context = BindingContext;
1115 foreach (Binding binding in data_bindings) {
1116 binding.Check (binding_context);
1119 #endregion // Private & Internal Methods
1121 #region Public Static Properties
1122 public static Color DefaultBackColor {
1124 return ThemeEngine.Current.DefaultControlBackColor;
1128 public static Font DefaultFont {
1130 return ThemeEngine.Current.DefaultFont;
1134 public static Color DefaultForeColor {
1136 return ThemeEngine.Current.DefaultControlForeColor;
1140 public static Keys ModifierKeys {
1142 return XplatUI.State.ModifierKeys;
1146 public static MouseButtons MouseButtons {
1148 return XplatUI.State.MouseButtons;
1152 public static Point MousePosition {
1154 return Cursor.Position;
1160 public static bool CheckForIllegalCrossThreadCalls
1169 #endregion // Public Static Properties
1171 #region Public Instance Properties
1172 [EditorBrowsable(EditorBrowsableState.Advanced)]
1174 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1175 public AccessibleObject AccessibilityObject {
1177 if (accessibility_object==null) {
1178 accessibility_object=CreateAccessibilityInstance();
1180 return accessibility_object;
1184 [EditorBrowsable(EditorBrowsableState.Advanced)]
1186 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1187 public string AccessibleDefaultActionDescription {
1189 return AccessibilityObject.default_action;
1193 AccessibilityObject.default_action=value;
1198 [DefaultValue(null)]
1199 public string AccessibleDescription {
1201 return AccessibilityObject.description;
1205 AccessibilityObject.description=value;
1210 [DefaultValue(null)]
1211 public string AccessibleName {
1213 return AccessibilityObject.Name;
1217 AccessibilityObject.Name=value;
1221 [DefaultValue(AccessibleRole.Default)]
1222 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1223 public AccessibleRole AccessibleRole {
1225 return AccessibilityObject.role;
1229 AccessibilityObject.role=value;
1233 [DefaultValue(false)]
1234 public virtual bool AllowDrop {
1240 if (allow_drop == value)
1244 XplatUI.SetAllowDrop (Handle, value);
1249 [RefreshProperties(RefreshProperties.Repaint)]
1250 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1251 public virtual AnchorStyles Anchor {
1253 return anchor_style;
1259 if (parent != null) {
1260 parent.PerformLayout(this, "Parent");
1266 public virtual Color BackColor {
1268 if (background_color.IsEmpty) {
1270 return parent.BackColor;
1272 return DefaultBackColor;
1274 return background_color;
1278 background_color=value;
1279 SetChildColor(this);
1280 OnBackColorChanged(EventArgs.Empty);
1286 [DefaultValue(null)]
1287 public virtual Image BackgroundImage {
1289 return background_image;
1293 if (background_image!=value) {
1294 background_image=value;
1295 OnBackgroundImageChanged(EventArgs.Empty);
1300 [EditorBrowsable(EditorBrowsableState.Advanced)]
1302 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1303 public virtual BindingContext BindingContext {
1305 if (binding_context != null)
1306 return binding_context;
1309 binding_context = Parent.BindingContext;
1310 return binding_context;
1313 if (binding_context != value) {
1314 binding_context = value;
1315 OnBindingContextChanged(EventArgs.Empty);
1320 [EditorBrowsable(EditorBrowsableState.Advanced)]
1322 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1325 return bounds.Y+bounds.Height;
1329 [EditorBrowsable(EditorBrowsableState.Advanced)]
1331 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1332 public Rectangle Bounds {
1338 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1342 [EditorBrowsable(EditorBrowsableState.Advanced)]
1344 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1345 public bool CanFocus {
1347 if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1354 [EditorBrowsable(EditorBrowsableState.Advanced)]
1356 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1357 public bool CanSelect {
1361 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1365 parent = this.parent;
1366 while (parent != null) {
1367 if (!parent.is_visible || !parent.is_enabled) {
1371 parent = parent.parent;
1377 [EditorBrowsable(EditorBrowsableState.Advanced)]
1379 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1380 public bool Capture {
1382 return this.is_captured;
1386 if (this.IsHandleCreated) {
1387 if (value && !is_captured) {
1389 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1390 } else if (!value && is_captured) {
1391 XplatUI.UngrabWindow(this.window.Handle);
1392 is_captured = false;
1398 [DefaultValue(true)]
1399 public bool CausesValidation {
1401 return this.causes_validation;
1405 if (this.causes_validation != value) {
1406 causes_validation = value;
1407 OnCausesValidationChanged(EventArgs.Empty);
1412 [EditorBrowsable(EditorBrowsableState.Advanced)]
1414 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1415 public Rectangle ClientRectangle {
1417 client_rect.Width = client_size.Width;
1418 client_rect.Height = client_size.Height;
1423 [EditorBrowsable(EditorBrowsableState.Advanced)]
1425 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1426 public Size ClientSize {
1429 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1430 return ((Form)this).form_parent_window.ClientSize;
1438 this.SetClientSizeCore(value.Width, value.Height);
1442 [EditorBrowsable(EditorBrowsableState.Advanced)]
1444 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1445 [DescriptionAttribute("ControlCompanyNameDescr")]
1446 public String CompanyName {
1448 return "Mono Project, Novell, Inc.";
1452 [EditorBrowsable(EditorBrowsableState.Advanced)]
1454 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1455 public bool ContainsFocus {
1461 for (int i=0; i < child_controls.Count; i++) {
1462 if (child_controls[i].ContainsFocus) {
1470 [DefaultValue(null)]
1471 public virtual ContextMenu ContextMenu {
1473 return context_menu;
1477 if (context_menu != value) {
1478 context_menu = value;
1479 OnContextMenuChanged(EventArgs.Empty);
1485 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1486 public ControlCollection Controls {
1488 return this.child_controls;
1492 [EditorBrowsable(EditorBrowsableState.Advanced)]
1494 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1495 public bool Created {
1497 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1504 [AmbientValue(null)]
1505 public virtual Cursor Cursor {
1507 if (cursor != null) {
1511 if (parent != null) {
1512 return parent.Cursor;
1515 return Cursors.Default;
1519 if (cursor != value) {
1524 pt = Cursor.Position;
1525 if (bounds.Contains(pt)) {
1526 if (GetChildAtPoint(pt) == null) {
1527 if (cursor != null) {
1528 XplatUI.SetCursor(window.Handle, cursor.handle);
1530 if (parent != null) {
1531 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1533 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1539 OnCursorChanged(EventArgs.Empty);
1545 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1546 [ParenthesizePropertyName(true)]
1547 [RefreshProperties(RefreshProperties.All)]
1548 public ControlBindingsCollection DataBindings {
1550 if (data_bindings == null)
1551 data_bindings = new ControlBindingsCollection (this);
1552 return data_bindings;
1556 [EditorBrowsable(EditorBrowsableState.Advanced)]
1558 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1559 public virtual Rectangle DisplayRectangle {
1561 return ClientRectangle;
1565 [EditorBrowsable(EditorBrowsableState.Advanced)]
1567 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1568 public bool Disposing {
1575 [RefreshProperties(RefreshProperties.Repaint)]
1576 [DefaultValue(DockStyle.None)]
1577 public virtual DockStyle Dock {
1583 if (dock_style == value) {
1589 if (parent != null) {
1590 parent.PerformLayout(this, "Parent");
1593 OnDockChanged(EventArgs.Empty);
1599 public bool Enabled {
1605 if (is_enabled == value) {
1611 OnEnabledChanged (EventArgs.Empty);
1615 [EditorBrowsable(EditorBrowsableState.Advanced)]
1617 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1618 public virtual bool Focused {
1620 return this.has_focus;
1625 [AmbientValue(null)]
1627 public virtual Font Font {
1633 if (Parent != null && Parent.Font != null) {
1641 if (font != null && font.Equals (value)) {
1647 OnFontChanged (EventArgs.Empty);
1652 public virtual Color ForeColor {
1654 if (foreground_color.IsEmpty) {
1656 return parent.ForeColor;
1658 return DefaultForeColor;
1660 return foreground_color;
1664 if (foreground_color != value) {
1665 foreground_color=value;
1667 OnForeColorChanged(EventArgs.Empty);
1674 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1675 public IntPtr Handle { // IWin32Window
1677 if (!IsHandleCreated) {
1680 return window.Handle;
1684 [EditorBrowsable(EditorBrowsableState.Advanced)]
1686 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1687 public bool HasChildren {
1689 if (this.child_controls.Count>0) {
1696 [EditorBrowsable(EditorBrowsableState.Always)]
1698 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1701 return this.bounds.Height;
1705 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1709 [AmbientValue(ImeMode.Inherit)]
1711 public ImeMode ImeMode {
1713 if (ime_mode == DefaultImeMode) {
1715 return parent.ImeMode;
1717 return ImeMode.NoControl; // default value
1723 if (ime_mode != value) {
1726 OnImeModeChanged(EventArgs.Empty);
1731 [EditorBrowsable(EditorBrowsableState.Advanced)]
1733 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1734 public bool InvokeRequired { // ISynchronizeInvoke
1736 if (creator_thread!=Thread.CurrentThread) {
1743 [EditorBrowsable(EditorBrowsableState.Advanced)]
1745 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1746 public bool IsAccessible {
1748 return is_accessible;
1752 is_accessible = value;
1756 [EditorBrowsable(EditorBrowsableState.Advanced)]
1758 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1759 public bool IsDisposed {
1761 return this.is_disposed;
1765 [EditorBrowsable(EditorBrowsableState.Advanced)]
1767 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1768 public bool IsHandleCreated {
1770 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1778 [EditorBrowsable(EditorBrowsableState.Always)]
1780 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1783 return this.bounds.X;
1787 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1792 public Point Location {
1794 return new Point(bounds.X, bounds.Y);
1798 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1803 public string Name {
1814 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1815 public Control Parent {
1821 if (value == this) {
1822 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1825 if (parent!=value) {
1827 parent.Controls.Remove(this);
1833 if (!parent.Controls.AllContains (this)) {
1834 Console.WriteLine ("Adding child: " + this);
1835 parent.Controls.Add(this);
1838 if (IsHandleCreated) {
1839 XplatUI.SetParent(Handle, value.Handle);
1842 OnParentChanged(EventArgs.Empty);
1848 [EditorBrowsable(EditorBrowsableState.Advanced)]
1850 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1851 public string ProductName {
1853 Type t = typeof (AssemblyProductAttribute);
1854 Assembly assembly = GetType().Module.Assembly;
1855 object [] attrs = assembly.GetCustomAttributes (t, false);
1856 AssemblyProductAttribute a = null;
1857 // On MS we get a NullRefException if product attribute is not
1859 if (attrs != null && attrs.Length > 0)
1860 a = (AssemblyProductAttribute) attrs [0];
1865 [EditorBrowsable(EditorBrowsableState.Advanced)]
1867 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1868 public string ProductVersion {
1870 Type t = typeof (AssemblyVersionAttribute);
1871 Assembly assembly = GetType().Module.Assembly;
1872 object [] attrs = assembly.GetCustomAttributes (t, false);
1873 if (attrs == null || attrs.Length < 1)
1875 return ((AssemblyVersionAttribute)attrs [0]).Version;
1879 [EditorBrowsable(EditorBrowsableState.Advanced)]
1881 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1882 public bool RecreatingHandle {
1884 return is_recreating;
1888 [EditorBrowsable(EditorBrowsableState.Advanced)]
1890 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1891 public Region Region {
1893 return new Region(this.bounds);
1900 g = this.CreateGraphics();
1901 r = value.GetBounds(g);
1903 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1909 [EditorBrowsable(EditorBrowsableState.Advanced)]
1911 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1914 return this.bounds.X+this.bounds.Width;
1918 [AmbientValue(RightToLeft.Inherit)]
1920 public virtual RightToLeft RightToLeft {
1922 if (right_to_left == RightToLeft.Inherit) {
1924 return parent.RightToLeft;
1926 return RightToLeft.No; // default value
1928 return right_to_left;
1932 if (value != right_to_left) {
1933 right_to_left = value;
1934 OnRightToLeftChanged(EventArgs.Empty);
1939 [EditorBrowsable(EditorBrowsableState.Advanced)]
1940 public override ISite Site {
1953 return new Size(Width, Height);
1957 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1962 [MergableProperty(false)]
1963 public int TabIndex {
1965 if (tab_index != -1) {
1972 if (tab_index != value) {
1974 OnTabIndexChanged(EventArgs.Empty);
1980 [DefaultValue(true)]
1981 public bool TabStop {
1987 if (tab_stop != value) {
1989 OnTabStopChanged(EventArgs.Empty);
1994 [Localizable(false)]
1996 [TypeConverter(typeof(StringConverter))]
1997 [DefaultValue(null)]
2004 control_tag = value;
2010 [BindableAttribute(true)]
2011 public virtual string Text {
2013 // Our implementation ignores ControlStyles.CacheText - we always cache
2018 if (value == null) {
2019 value = String.Empty;
2024 if (IsHandleCreated) {
2025 XplatUI.Text(Handle, text);
2027 OnTextChanged (EventArgs.Empty);
2032 [EditorBrowsable(EditorBrowsableState.Always)]
2034 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2037 return this.bounds.Y;
2041 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2045 [EditorBrowsable(EditorBrowsableState.Advanced)]
2047 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2048 public Control TopLevelControl {
2052 while (p.parent != null) {
2061 public bool Visible {
2065 } else if (parent != null) {
2066 return parent.Visible;
2073 SetVisibleCore(value);
2077 [EditorBrowsable(EditorBrowsableState.Always)]
2079 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2082 return this.bounds.Width;
2086 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2090 [EditorBrowsable(EditorBrowsableState.Never)]
2092 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2093 public IWindowTarget WindowTarget {
2102 #endregion // Public Instance Properties
2104 #region Protected Instance Properties
2105 protected virtual CreateParams CreateParams {
2107 CreateParams create_params = new CreateParams();
2110 create_params.Caption = Text;
2113 create_params.Caption = text;
2117 create_params.X = Left;
2120 create_params.X = this.bounds.X;
2124 create_params.Y = Top;
2127 create_params.Y = this.bounds.Y;
2131 create_params.Width = Width;
2134 create_params.Width = this.bounds.Width;
2138 create_params.Height = Height;
2141 create_params.Height = this.bounds.Height;
2145 create_params.ClassName = XplatUI.DefaultClassName;
2146 create_params.ClassStyle = 0;
2147 create_params.ExStyle = 0;
2148 create_params.Param = 0;
2151 create_params.ExStyle |= (int)WindowStyles.WS_EX_ACCEPTFILES;
2155 create_params.Parent = parent.Handle;
2158 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2161 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2164 return create_params;
2168 protected virtual ImeMode DefaultImeMode {
2170 return ImeMode.Inherit;
2174 protected virtual Size DefaultSize {
2176 return new Size(100, 23);
2180 protected int FontHeight {
2190 protected bool RenderRightToLeft {
2192 return (this.right_to_left == RightToLeft.Yes);
2196 protected bool ResizeRedraw {
2198 return GetStyle(ControlStyles.ResizeRedraw);
2202 SetStyle(ControlStyles.ResizeRedraw, value);
2206 [EditorBrowsable(EditorBrowsableState.Advanced)]
2208 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2209 protected virtual bool ShowFocusCues {
2215 [EditorBrowsable(EditorBrowsableState.Advanced)]
2217 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2218 protected bool ShowKeyboardCues {
2223 #endregion // Protected Instance Properties
2225 #region Public Static Methods
2226 [EditorBrowsable(EditorBrowsableState.Advanced)]
2227 public static Control FromChildHandle(IntPtr handle) {
2228 IEnumerator control = Control.controls.GetEnumerator();
2230 while (control.MoveNext()) {
2231 if (((Control)control.Current).window.Handle == handle) {
2233 if (((Control)control.Current).Parent != null) {
2234 return ((Control)control.Current).Parent;
2241 [EditorBrowsable(EditorBrowsableState.Advanced)]
2242 public static Control FromHandle(IntPtr handle) {
2243 IEnumerator control = Control.controls.GetEnumerator();
2245 while (control.MoveNext()) {
2246 if (((Control)control.Current).window.Handle == handle) {
2248 return ((Control)control.Current);
2254 public static bool IsMnemonic(char charCode, string text) {
2257 amp = text.IndexOf('&');
2260 if (amp + 1 < text.Length) {
2261 if (text[amp + 1] != '&') {
2262 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2272 #region Protected Static Methods
2273 [EditorBrowsable(EditorBrowsableState.Advanced)]
2274 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2277 c = Control.FromHandle(hWnd);
2287 #region Public Instance Methods
2288 [EditorBrowsable(EditorBrowsableState.Advanced)]
2289 public IAsyncResult BeginInvoke(Delegate method) {
2290 return BeginInvokeInternal(method, null);
2293 [EditorBrowsable(EditorBrowsableState.Advanced)]
2294 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2295 return BeginInvokeInternal (method, args);
2298 public void BringToFront() {
2299 if ((parent != null) && (parent.child_controls[0]!=this)) {
2300 if (parent.child_controls.Contains(this)) {
2301 parent.child_controls.SetChildIndex(this, 0);
2305 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
2307 if (parent != null) {
2312 public bool Contains(Control ctl) {
2313 while (ctl != null) {
2322 public void CreateControl() {
2324 if (!IsHandleCreated) {
2328 if (!create_handled) {
2329 create_handled = true;
2333 Control [] controls = child_controls.GetAllControls ();
2334 for (int i=0; i<controls.Length; i++) {
2335 controls [i].CreateControl ();
2339 public Graphics CreateGraphics() {
2340 if (!IsHandleCreated) {
2341 this.CreateControl();
2343 return Graphics.FromHwnd(this.window.Handle);
2346 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2347 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2350 [EditorBrowsable(EditorBrowsableState.Advanced)]
2351 public object EndInvoke (IAsyncResult async_result) {
2352 AsyncMethodResult result = (AsyncMethodResult) async_result;
2353 return result.EndInvoke ();
2356 public Form FindForm() {
2369 public bool Focus() {
2370 if (IsHandleCreated && !has_focus) {
2372 XplatUI.SetFocus(window.Handle);
2377 public Control GetChildAtPoint(Point pt) {
2378 // Microsoft's version of this function doesn't seem to work, so I can't check
2379 // if we only consider children or also grandchildren, etc.
2380 // I'm gonna say 'children only'
2381 for (int i=0; i<child_controls.Count; i++) {
2382 if (child_controls[i].Bounds.Contains(pt)) {
2383 return child_controls[i];
2389 public IContainerControl GetContainerControl() {
2390 Control current = this;
2392 while (current!=null) {
2393 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2394 return (IContainerControl)current;
2396 current = current.parent;
2401 public Control GetNextControl(Control ctl, bool forward) {
2402 // If we're not a container we don't play
2403 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2407 // If ctl is not contained by this, we start at the first child of this
2408 if (!this.Contains(ctl)) {
2412 // Search through our controls, starting at ctl, stepping into children as we encounter them
2413 // try to find the control with the tabindex closest to our own, or, if we're looking into
2414 // child controls, the one with the smallest tabindex
2416 return FindControlForward(this, ctl);
2418 return FindControlBackward(this, ctl);
2421 public void Hide() {
2422 this.Visible = false;
2425 public void Invalidate() {
2426 Invalidate(ClientRectangle, false);
2429 public void Invalidate(bool invalidateChildren) {
2430 Invalidate(ClientRectangle, invalidateChildren);
2433 public void Invalidate(System.Drawing.Rectangle rc) {
2434 Invalidate(rc, false);
2437 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2438 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2442 NotifyInvalidate(rc);
2444 XplatUI.Invalidate(Handle, rc, false);
2446 if (invalidateChildren) {
2447 Control [] controls = child_controls.GetAllControls ();
2448 for (int i=0; i<controls.Length; i++)
2449 controls [i].Invalidate ();
2451 OnInvalidated(new InvalidateEventArgs(rc));
2454 public void Invalidate(System.Drawing.Region region) {
2455 Invalidate(region, false);
2458 [MonoTODO("Figure out if GetRegionScans is usable")]
2459 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2460 throw new NotImplementedException();
2462 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2463 //if (invalidateChildren) {
2464 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2468 public object Invoke (Delegate method) {
2469 return Invoke(method, null);
2472 public object Invoke (Delegate method, object[] args) {
2473 if (!this.InvokeRequired) {
2474 return method.DynamicInvoke(args);
2477 IAsyncResult result = BeginInvoke (method, args);
2478 return EndInvoke(result);
2481 [EditorBrowsable(EditorBrowsableState.Advanced)]
2482 public void PerformLayout() {
2483 PerformLayout(null, null);
2486 [EditorBrowsable(EditorBrowsableState.Advanced)]
2487 public void PerformLayout(Control affectedControl, string affectedProperty) {
2488 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2490 if (layout_suspended > 0) {
2491 layout_pending = true;
2495 layout_pending = false;
2497 // Prevent us from getting messed up
2500 // Perform all Dock and Anchor calculations
2503 AnchorStyles anchor;
2506 space=this.DisplayRectangle;
2508 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2509 Control [] controls = child_controls.GetAllControls ();
2510 for (int i = controls.Length - 1; i >= 0; i--) {
2511 child = controls [i];
2512 switch (child.Dock) {
2513 case DockStyle.None: {
2518 case DockStyle.Left: {
2519 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2520 space.X+=child.Width;
2521 space.Width-=child.Width;
2525 case DockStyle.Top: {
2526 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2527 space.Y+=child.Height;
2528 space.Height-=child.Height;
2532 case DockStyle.Right: {
2533 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2534 space.Width-=child.Width;
2538 case DockStyle.Bottom: {
2539 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2540 space.Height-=child.Height;
2546 for (int i = controls.Length - 1; i >= 0; i--) {
2549 if (child.Dock == DockStyle.Fill) {
2550 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2556 space=this.DisplayRectangle;
2558 for (int i=0; i < controls.Length; i++) {
2564 child = controls[i];
2565 anchor = child.Anchor;
2569 width = child.Width;
2570 height = child.Height;
2572 // If the control is docked we don't need to do anything
2573 if (child.Dock != DockStyle.None) {
2577 if ((anchor & AnchorStyles.Left) !=0 ) {
2578 if ((anchor & AnchorStyles.Right) != 0) {
2579 width = client_size.Width - child.dist_right - left;
2581 ; // Left anchored only, nothing to be done
2583 } else if ((anchor & AnchorStyles.Right) != 0) {
2584 left = client_size.Width - child.dist_right - width;
2586 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
2587 // This calculates from scratch every time:
2588 left = child.dist_left + (client_size.Width - (child.dist_left + width + child.dist_right)) / 2;
2591 if ((anchor & AnchorStyles.Top) !=0 ) {
2592 if ((anchor & AnchorStyles.Bottom) != 0) {
2593 height = client_size.Height - child.dist_bottom - top;
2595 ; // Top anchored only, nothing to be done
2597 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2598 top = client_size.Height - child.dist_bottom - height;
2600 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
2601 // This calculates from scratch every time:
2602 top = child.dist_top + (client_size.Height - (child.dist_top + height + child.dist_bottom)) / 2;
2614 child.SetBounds(left, top, width, height);
2617 // Let everyone know
2621 // Need to make sure we decremend layout_suspended
2627 public Point PointToClient (Point p) {
2631 XplatUI.ScreenToClient (Handle, ref x, ref y);
2633 return new Point (x, y);
2636 public Point PointToScreen(Point p) {
2640 XplatUI.ClientToScreen(Handle, ref x, ref y);
2642 return new Point(x, y);
2645 public virtual bool PreProcessMessage(ref Message msg) {
2648 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
2649 key_data = (Keys)msg.WParam.ToInt32();
2650 if (!ProcessCmdKey(ref msg, key_data)) {
2651 if (IsInputKey(key_data)) {
2655 return ProcessDialogKey(key_data);
2659 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2660 if (IsInputChar((char)msg.WParam)) {
2663 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
2664 if (IsInputChar((char)msg.WParam)) {
2667 return ProcessDialogChar((char)msg.WParam);
2672 public Rectangle RectangleToClient(Rectangle r) {
2673 return new Rectangle(PointToClient(r.Location), r.Size);
2676 public Rectangle RectangleToScreen(Rectangle r) {
2677 return new Rectangle(PointToScreen(r.Location), r.Size);
2680 public virtual void Refresh() {
2681 if (IsHandleCreated == true) {
2684 XplatUI.UpdateWindow(window.Handle);
2686 Control [] controls = child_controls.GetAllControls ();
2687 for (int i=0; i < controls.Length; i++) {
2688 controls[i].Refresh();
2694 [EditorBrowsable(EditorBrowsableState.Never)]
2695 public virtual void ResetBackColor() {
2696 background_color = Color.Empty;
2699 [EditorBrowsable(EditorBrowsableState.Never)]
2701 public void ResetBindings() {
2705 [EditorBrowsable(EditorBrowsableState.Never)]
2706 public virtual void ResetCursor() {
2710 [EditorBrowsable(EditorBrowsableState.Never)]
2711 public virtual void ResetFont() {
2715 [EditorBrowsable(EditorBrowsableState.Never)]
2716 public virtual void ResetForeColor() {
2717 foreground_color = Color.Empty;
2720 [EditorBrowsable(EditorBrowsableState.Never)]
2721 public void ResetImeMode() {
2722 ime_mode = DefaultImeMode;
2725 [EditorBrowsable(EditorBrowsableState.Never)]
2726 public virtual void ResetRightToLeft() {
2727 right_to_left = RightToLeft.Inherit;
2730 public virtual void ResetText() {
2731 text = String.Empty;
2734 public void ResumeLayout() {
2735 ResumeLayout (true);
2738 public void ResumeLayout(bool performLayout) {
2741 if (layout_suspended > 0) {
2745 if (performLayout || layout_pending) {
2750 public void Scale(float ratio) {
2751 ScaleCore(ratio, ratio);
2754 public void Scale(float dx, float dy) {
2758 public void Select() {
2759 Select(false, false);
2762 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2767 c = GetNextControl(c, forward);
2776 if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
2780 } while (c != ctl); // If we wrap back to ourselves we stop
2785 public void SendToBack() {
2786 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2787 if (parent.child_controls.Contains(this)) {
2788 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2792 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2793 if (parent != null) {
2798 public void SetBounds(int x, int y, int width, int height) {
2799 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2802 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2803 SetBoundsCore(x, y, width, height, specified);
2806 public void Show() {
2807 if (!IsHandleCreated) {
2808 this.CreateControl();
2814 public void SuspendLayout() {
2818 public void Update() {
2819 needs_redraw = true;
2820 if (IsHandleCreated) {
2821 XplatUI.UpdateWindow(window.Handle);
2824 #endregion // Public Instance Methods
2826 #region Protected Instance Methods
2827 [EditorBrowsable(EditorBrowsableState.Advanced)]
2828 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2829 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2830 throw new NotImplementedException();
2833 [EditorBrowsable(EditorBrowsableState.Advanced)]
2834 protected virtual AccessibleObject CreateAccessibilityInstance() {
2835 return new Control.ControlAccessibleObject(this);
2838 [EditorBrowsable(EditorBrowsableState.Advanced)]
2839 protected virtual ControlCollection CreateControlsInstance() {
2840 return new ControlCollection(this);
2843 [EditorBrowsable(EditorBrowsableState.Advanced)]
2844 protected virtual void CreateHandle() {
2846 throw new ObjectDisposedException(Name);
2849 if (IsHandleCreated) {
2853 window.CreateHandle(CreateParams);
2855 // Find out where the window manager placed us
2857 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
2858 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
2862 if (window.Handle!=IntPtr.Zero) {
2863 if (!controls.Contains(window.Handle)) {
2867 creator_thread = Thread.CurrentThread;
2869 OnHandleCreated(EventArgs.Empty);
2873 [EditorBrowsable(EditorBrowsableState.Advanced)]
2874 protected virtual void DefWndProc(ref Message m) {
2875 window.DefWndProc(ref m);
2878 [EditorBrowsable(EditorBrowsableState.Advanced)]
2879 protected virtual void DestroyHandle() {
2880 if (IsHandleCreated) {
2881 // Destroy our children before we destroy ourselves, to prevent them from
2882 // being implictly (without us knowing) destroyed
2883 Control [] controls = child_controls.GetAllControls ();
2884 for (int i=0; i < controls.Length; i++) {
2885 controls[i].DestroyHandle();
2889 if (window != null) {
2890 window.DestroyHandle();
2892 OnHandleDestroyed(EventArgs.Empty);
2896 protected bool GetStyle(ControlStyles flag) {
2897 return (control_style & flag) != 0;
2900 protected bool GetTopLevel() {
2904 [EditorBrowsable(EditorBrowsableState.Advanced)]
2905 protected virtual void InitLayout() {
2906 dist_left = bounds.X;
2907 dist_top = bounds.Y;
2908 if (parent != null) {
2909 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
2910 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
2914 [EditorBrowsable(EditorBrowsableState.Advanced)]
2915 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2916 toInvoke.OnGotFocus(e);
2919 [EditorBrowsable(EditorBrowsableState.Advanced)]
2920 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2921 toInvoke.OnLostFocus(e);
2924 [EditorBrowsable(EditorBrowsableState.Advanced)]
2925 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2926 toInvoke.OnClick(e);
2929 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2930 toInvoke.OnPaint(e);
2933 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2934 toInvoke.OnPaintBackground(e);
2937 protected virtual bool IsInputChar (char charCode) {
2938 if (parent != null) {
2939 return parent.IsInputChar(charCode);
2945 protected virtual bool IsInputKey (Keys keyData) {
2946 // Doc says this one calls IsInputChar; not sure what to do with that
2950 [EditorBrowsable(EditorBrowsableState.Advanced)]
2951 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2955 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2956 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2960 if (parent != null) {
2961 return parent.ProcessCmdKey(ref msg, keyData);
2967 protected virtual bool ProcessDialogChar(char charCode) {
2968 if (parent != null) {
2969 return parent.ProcessDialogChar (charCode);
2975 protected virtual bool ProcessDialogKey (Keys keyData) {
2976 if (parent != null) {
2977 return parent.ProcessDialogKey (keyData);
2983 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2985 KeyEventArgs key_event;
2988 case (int)Msg.WM_KEYDOWN: {
2989 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2990 OnKeyDown (key_event);
2991 return key_event.Handled;
2993 case (int)Msg.WM_KEYUP: {
2994 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2995 OnKeyUp (key_event);
2996 return key_event.Handled;
2999 case (int)Msg.WM_CHAR: {
3000 KeyPressEventArgs key_press_event;
3002 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3003 OnKeyPress(key_press_event);
3004 return key_press_event.Handled;
3015 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3016 if (parent != null) {
3017 if (parent.ProcessKeyPreview(ref msg)) {
3025 protected virtual bool ProcessKeyPreview(ref Message msg) {
3026 if (parent != null) {
3027 return parent.ProcessKeyPreview(ref msg);
3033 protected virtual bool ProcessMnemonic(char charCode) {
3038 [EditorBrowsable(EditorBrowsableState.Advanced)]
3039 protected void RaiseDragEvent(object key, DragEventArgs e) {
3043 [EditorBrowsable(EditorBrowsableState.Advanced)]
3044 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3048 [EditorBrowsable(EditorBrowsableState.Advanced)]
3049 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3053 [EditorBrowsable(EditorBrowsableState.Advanced)]
3054 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3058 [EditorBrowsable(EditorBrowsableState.Advanced)]
3059 protected void RecreateHandle() {
3060 IEnumerator child = child_controls.GetAllEnumerator();
3064 if (IsHandleCreated) {
3070 while (child.MoveNext()) {
3071 ((Control)child.Current).RecreateHandle();
3077 is_recreating = false;
3080 [EditorBrowsable(EditorBrowsableState.Advanced)]
3081 protected void ResetMouseEventArgs() {
3085 [EditorBrowsable(EditorBrowsableState.Advanced)]
3086 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3087 if (right_to_left == RightToLeft.No) {
3092 case ContentAlignment.TopLeft: {
3093 return ContentAlignment.TopRight;
3096 case ContentAlignment.TopRight: {
3097 return ContentAlignment.TopLeft;
3100 case ContentAlignment.MiddleLeft: {
3101 return ContentAlignment.MiddleRight;
3104 case ContentAlignment.MiddleRight: {
3105 return ContentAlignment.MiddleLeft;
3108 case ContentAlignment.BottomLeft: {
3109 return ContentAlignment.BottomRight;
3112 case ContentAlignment.BottomRight: {
3113 return ContentAlignment.BottomLeft;
3117 // if it's center it doesn't change
3123 [EditorBrowsable(EditorBrowsableState.Advanced)]
3124 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3125 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3129 if (align == HorizontalAlignment.Left) {
3130 return HorizontalAlignment.Right;
3133 // align must be HorizontalAlignment.Right
3134 return HorizontalAlignment.Left;
3137 [EditorBrowsable(EditorBrowsableState.Advanced)]
3138 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3139 if (right_to_left == RightToLeft.No) {
3143 if (align == LeftRightAlignment.Left) {
3144 return LeftRightAlignment.Right;
3147 // align must be LeftRightAlignment.Right;
3148 return LeftRightAlignment.Left;
3151 [EditorBrowsable(EditorBrowsableState.Advanced)]
3152 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3153 return RtlTranslateAlignment(align);
3156 [EditorBrowsable(EditorBrowsableState.Advanced)]
3157 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3158 return RtlTranslateAlignment(align);
3161 [EditorBrowsable(EditorBrowsableState.Advanced)]
3162 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3163 return RtlTranslateAlignment(align);
3166 [EditorBrowsable(EditorBrowsableState.Advanced)]
3167 protected virtual void ScaleCore(float dx, float dy) {
3173 location = new Point((int)(Left * dx), (int)(Top * dy));
3174 size = this.ClientSize;
3177 if (!GetStyle(ControlStyles.FixedWidth)) {
3178 size.Width = (int)(size.Width * dx);
3181 if (!GetStyle(ControlStyles.FixedHeight)) {
3182 size.Height = (int)(size.Height * dy);
3185 Location = location;
3188 /* Now scale our children */
3189 Control [] controls = child_controls.GetAllControls ();
3190 for (int i=0; i < controls.Length; i++) {
3191 controls[i].Scale(dx, dy);
3197 protected virtual void Select(bool directed, bool forward) {
3202 // Select this control
3207 if (parent == null) {
3211 // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
3213 index = parent.child_controls.IndexOf(this);
3218 if ((index+1) < parent.child_controls.Count) {
3227 index = parent.child_controls.Count-1;
3230 result = Select(parent.child_controls[index]);
3231 } while (!result && parent.child_controls[index] != this);
3234 [EditorBrowsable(EditorBrowsableState.Advanced)]
3235 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3236 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3237 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3241 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3245 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3249 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3253 if (IsHandleCreated) {
3254 XplatUI.SetWindowPos(Handle, x, y, width, height);
3257 UpdateBounds(x, y, width, height);
3260 Control [] controls = child_controls.GetAllControls ();
3261 for (int i = controls.Length - 1; i >= 0; i--) {
3262 controls[i].InitLayout();
3266 [EditorBrowsable(EditorBrowsableState.Advanced)]
3267 protected virtual void SetClientSizeCore(int x, int y) {
3268 // Calculate the actual window size from the client size (it usually stays the same or grows)
3269 Rectangle ClientRect;
3270 Rectangle WindowRect;
3273 ClientRect = new Rectangle(0, 0, x, y);
3274 cp = this.CreateParams;
3276 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
3280 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3283 [EditorBrowsable(EditorBrowsableState.Advanced)]
3284 protected void SetStyle(ControlStyles flag, bool value) {
3286 control_style |= flag;
3288 control_style &= ~flag;
3290 OnStyleChanged(EventArgs.Empty);
3293 protected void SetTopLevel(bool value) {
3294 if ((GetTopLevel() != value) && (parent != null)) {
3295 throw new Exception();
3299 if (value == true) {
3309 is_toplevel = value;
3312 protected virtual void SetVisibleCore(bool value) {
3313 if (value!=is_visible) {
3316 if (IsHandleCreated) {
3317 XplatUI.SetVisible(Handle, value);
3318 // Explicitly move Toplevel windows to where we want them;
3319 // apparently moving unmapped toplevel windows doesn't work
3320 if (is_visible && (this is Form)) {
3321 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3325 OnVisibleChanged(EventArgs.Empty);
3328 if (dc_mem != null) {
3333 if (bmp_mem != null) {
3338 this.CreateBuffers(bounds.Width, bounds.Height);
3342 if (value == false && parent != null) {
3345 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3346 container = (Control)parent.GetContainerControl();
3347 if (container != null) {
3348 container.SelectNextControl(this, true, true, true, true);
3352 if (parent != null) {
3353 parent.PerformLayout(this, "visible");
3355 PerformLayout(this, "visible");
3360 [EditorBrowsable(EditorBrowsableState.Advanced)]
3361 protected void UpdateBounds() {
3369 if (!IsHandleCreated) {
3373 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3375 UpdateBounds(x, y, width, height, client_width, client_height);
3378 [EditorBrowsable(EditorBrowsableState.Advanced)]
3379 protected void UpdateBounds(int x, int y, int width, int height) {
3380 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3382 bool resized = false;
3384 int client_x_diff = this.bounds.Width-this.client_size.Width;
3385 int client_y_diff = this.bounds.Height-this.client_size.Height;
3387 // Needed to generate required notifications
3388 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3392 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3399 bounds.Height=height;
3401 // Update client rectangle as well
3402 client_size.Width=width-client_x_diff;
3403 client_size.Height=height-client_y_diff;
3406 OnLocationChanged(EventArgs.Empty);
3410 OnSizeChanged(EventArgs.Empty);
3414 [EditorBrowsable(EditorBrowsableState.Advanced)]
3415 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3416 UpdateBounds(x, y, width, height);
3418 this.client_size.Width=clientWidth;
3419 this.client_size.Height=clientHeight;
3422 [EditorBrowsable(EditorBrowsableState.Advanced)]
3423 protected void UpdateStyles() {
3424 if (!IsHandleCreated) {
3428 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3431 [EditorBrowsable(EditorBrowsableState.Advanced)]
3432 protected void UpdateZOrder() {
3433 Control [] controls;
3437 if (parent == null) {
3443 controls = ctl.child_controls.GetAllControls ();
3444 for (int i = 1; i < controls.Length; i++ ) {
3445 XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
3448 if (!IsHandleCreated) {
3452 controls = child_controls.GetAllControls ();
3453 for (int i = 1; i < controls.Length; i++ ) {
3454 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3459 protected virtual void WndProc(ref Message m) {
3461 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3463 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3467 switch((Msg)m.Msg) {
3468 case Msg.WM_WINDOWPOSCHANGED: {
3471 if (GetStyle(ControlStyles.ResizeRedraw)) {
3478 case Msg.WM_PAINT: {
3479 PaintEventArgs paint_event;
3481 paint_event = XplatUI.PaintEventStart(Handle, true);
3483 if (!needs_redraw) {
3484 // Just blit the previous image
3485 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3486 XplatUI.PaintEventEnd(Handle, true);
3491 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3492 dc = paint_event.SetGraphics (DeviceContext);
3495 if ((control_style & (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) == (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
3496 OnPaintBackground(paint_event);
3498 PaintControlBackground(paint_event);
3501 OnPaint(paint_event);
3503 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3504 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3505 paint_event.SetGraphics (dc);
3506 needs_redraw = false;
3509 XplatUI.PaintEventEnd(Handle, true);
3514 case Msg.WM_ERASEBKGND: {
3515 // The DefWndProc will never have to handle this, we always paint the background in managed code
3516 m.Result = (IntPtr)1;
3520 case Msg.WM_LBUTTONUP: {
3521 HandleClick(mouse_clicks);
3522 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3524 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3526 if (mouse_clicks > 1) {
3532 case Msg.WM_LBUTTONDOWN: {
3533 if (CanSelect && !is_selected) {
3536 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3537 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3543 case Msg.WM_LBUTTONDBLCLK: {
3545 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3546 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3552 case Msg.WM_MBUTTONUP: {
3553 HandleClick(mouse_clicks);
3554 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3556 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3558 if (mouse_clicks > 1) {
3564 case Msg.WM_MBUTTONDOWN: {
3565 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3566 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3572 case Msg.WM_MBUTTONDBLCLK: {
3574 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3575 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3580 case Msg.WM_RBUTTONUP: {
3581 if (context_menu != null) {
3582 context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
3585 HandleClick(mouse_clicks);
3586 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3588 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3590 if (mouse_clicks > 1) {
3596 case Msg.WM_RBUTTONDOWN: {
3597 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3598 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3603 case Msg.WM_RBUTTONDBLCLK: {
3605 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3606 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3611 case Msg.WM_MOUSEWHEEL: {
3613 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3614 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3615 HighOrder(m.WParam.ToInt32())));
3620 case Msg.WM_MOUSEMOVE: {
3621 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3623 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3628 case Msg.WM_MOUSE_ENTER: {
3633 OnMouseEnter(EventArgs.Empty);
3637 case Msg.WM_MOUSE_LEAVE: {
3639 OnMouseLeave(EventArgs.Empty);
3643 case Msg.WM_MOUSEHOVER: {
3644 OnMouseHover(EventArgs.Empty);
3648 case Msg.WM_SYSKEYDOWN:
3649 case Msg.WM_KEYDOWN:
3650 case Msg.WM_SYSKEYUP:
3652 case Msg.WM_SYSCHAR:
3654 Console.WriteLine("Got {0}", (Msg)m.Msg);
3655 if (ProcessKeyEventArgs(ref m)) {
3659 if (PreProcessMessage(ref m)) {
3663 if (ProcessKeyMessage(ref m)) {
3672 if (m.LParam != IntPtr.Zero) {
3675 hi = new HELPINFO();
3677 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3678 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3680 mouse_pos = Control.MousePosition;
3682 OnHelpRequested(new HelpEventArgs(mouse_pos));
3683 m.Result = (IntPtr)1;
3687 case Msg.WM_KILLFOCUS: {
3688 OnLeave(EventArgs.Empty);
3689 if (CausesValidation) {
3691 e = new CancelEventArgs(false);
3700 OnValidated(EventArgs.Empty);
3703 this.has_focus = false;
3704 this.is_selected = false;
3705 OnLostFocus(EventArgs.Empty);
3709 case Msg.WM_SETFOCUS: {
3710 OnEnter(EventArgs.Empty);
3711 this.has_focus = true;
3712 OnGotFocus(EventArgs.Empty);
3717 case Msg.WM_SYSCOLORCHANGE: {
3718 ThemeEngine.Current.ResetDefaults();
3719 OnSystemColorsChanged(EventArgs.Empty);
3724 case Msg.WM_SETCURSOR: {
3725 if (cursor == null) {
3730 XplatUI.SetCursor(window.Handle, cursor.handle);
3731 m.Result = (IntPtr)1;
3742 #endregion // Public Instance Methods
3744 #region OnXXX methods
3745 [EditorBrowsable(EditorBrowsableState.Advanced)]
3746 protected virtual void OnBackColorChanged(EventArgs e) {
3747 if (BackColorChanged!=null) BackColorChanged(this, e);
3748 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3751 [EditorBrowsable(EditorBrowsableState.Advanced)]
3752 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3753 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3754 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3757 [EditorBrowsable(EditorBrowsableState.Advanced)]
3758 protected virtual void OnBindingContextChanged(EventArgs e) {
3759 CheckDataBindings ();
3760 if (BindingContextChanged!=null) {
3761 BindingContextChanged(this, e);
3763 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3766 [EditorBrowsable(EditorBrowsableState.Advanced)]
3767 protected virtual void OnCausesValidationChanged(EventArgs e) {
3768 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3771 [EditorBrowsable(EditorBrowsableState.Advanced)]
3772 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3773 if (ChangeUICues!=null) ChangeUICues(this, e);
3776 [EditorBrowsable(EditorBrowsableState.Advanced)]
3777 protected virtual void OnClick(EventArgs e) {
3778 if (Click!=null) Click(this, e);
3781 [EditorBrowsable(EditorBrowsableState.Advanced)]
3782 protected virtual void OnContextMenuChanged(EventArgs e) {
3783 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3786 [EditorBrowsable(EditorBrowsableState.Advanced)]
3787 protected virtual void OnControlAdded(ControlEventArgs e) {
3788 if (ControlAdded!=null) ControlAdded(this, e);
3791 [EditorBrowsable(EditorBrowsableState.Advanced)]
3792 protected virtual void OnControlRemoved(ControlEventArgs e) {
3793 if (ControlRemoved!=null) ControlRemoved(this, e);
3796 [EditorBrowsable(EditorBrowsableState.Advanced)]
3797 protected virtual void OnCreateControl() {
3801 [EditorBrowsable(EditorBrowsableState.Advanced)]
3802 protected virtual void OnCursorChanged(EventArgs e) {
3803 if (CursorChanged!=null) CursorChanged(this, e);
3806 [EditorBrowsable(EditorBrowsableState.Advanced)]
3807 protected virtual void OnDockChanged(EventArgs e) {
3808 if (DockChanged!=null) DockChanged(this, e);
3811 [EditorBrowsable(EditorBrowsableState.Advanced)]
3812 protected virtual void OnDoubleClick(EventArgs e) {
3813 if (DoubleClick!=null) DoubleClick(this, e);
3816 [EditorBrowsable(EditorBrowsableState.Advanced)]
3817 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3818 if (DragDrop!=null) DragDrop(this, drgevent);
3821 [EditorBrowsable(EditorBrowsableState.Advanced)]
3822 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3823 if (DragEnter!=null) DragEnter(this, drgevent);
3826 [EditorBrowsable(EditorBrowsableState.Advanced)]
3827 protected virtual void OnDragLeave(EventArgs e) {
3828 if (DragLeave!=null) DragLeave(this, e);
3831 [EditorBrowsable(EditorBrowsableState.Advanced)]
3832 protected virtual void OnDragOver(DragEventArgs drgevent) {
3833 if (DragOver!=null) DragOver(this, drgevent);
3836 [EditorBrowsable(EditorBrowsableState.Advanced)]
3837 protected virtual void OnEnabledChanged(EventArgs e) {
3838 if (EnabledChanged!=null) EnabledChanged(this, e);
3839 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3842 [EditorBrowsable(EditorBrowsableState.Advanced)]
3843 protected virtual void OnEnter(EventArgs e) {
3844 if (Enter!=null) Enter(this, e);
3847 [EditorBrowsable(EditorBrowsableState.Advanced)]
3848 protected virtual void OnFontChanged(EventArgs e) {
3849 if (FontChanged!=null) FontChanged(this, e);
3850 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3853 [EditorBrowsable(EditorBrowsableState.Advanced)]
3854 protected virtual void OnForeColorChanged(EventArgs e) {
3855 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3856 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3859 [EditorBrowsable(EditorBrowsableState.Advanced)]
3860 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3861 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3864 [EditorBrowsable(EditorBrowsableState.Advanced)]
3865 protected virtual void OnGotFocus(EventArgs e) {
3866 if (GotFocus!=null) GotFocus(this, e);
3869 [EditorBrowsable(EditorBrowsableState.Advanced)]
3870 protected virtual void OnHandleCreated(EventArgs e) {
3871 if (HandleCreated!=null) HandleCreated(this, e);
3874 [EditorBrowsable(EditorBrowsableState.Advanced)]
3875 protected virtual void OnHandleDestroyed(EventArgs e) {
3876 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3879 [EditorBrowsable(EditorBrowsableState.Advanced)]
3880 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3881 if (HelpRequested!=null) HelpRequested(this, hevent);
3884 protected virtual void OnImeModeChanged(EventArgs e) {
3885 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3888 [EditorBrowsable(EditorBrowsableState.Advanced)]
3889 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3890 needs_redraw = true;
3891 if (Invalidated!=null) Invalidated(this, e);
3894 [EditorBrowsable(EditorBrowsableState.Advanced)]
3895 protected virtual void OnKeyDown(KeyEventArgs e) {
3896 if (KeyDown!=null) KeyDown(this, e);
3899 [EditorBrowsable(EditorBrowsableState.Advanced)]
3900 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3901 if (KeyPress!=null) KeyPress(this, e);
3904 [EditorBrowsable(EditorBrowsableState.Advanced)]
3905 protected virtual void OnKeyUp(KeyEventArgs e) {
3906 if (KeyUp!=null) KeyUp(this, e);
3909 [EditorBrowsable(EditorBrowsableState.Advanced)]
3910 protected virtual void OnLayout(LayoutEventArgs levent) {
3911 if (Layout!=null) Layout(this, levent);
3914 [EditorBrowsable(EditorBrowsableState.Advanced)]
3915 protected virtual void OnLeave(EventArgs e) {
3916 if (Leave!=null) Leave(this, e);
3919 [EditorBrowsable(EditorBrowsableState.Advanced)]
3920 protected virtual void OnLocationChanged(EventArgs e) {
3922 if (LocationChanged!=null) LocationChanged(this, e);
3925 [EditorBrowsable(EditorBrowsableState.Advanced)]
3926 protected virtual void OnLostFocus(EventArgs e) {
3927 if (LostFocus!=null) LostFocus(this, e);
3930 [EditorBrowsable(EditorBrowsableState.Advanced)]
3931 protected virtual void OnMouseDown(MouseEventArgs e) {
3932 if (MouseDown!=null) MouseDown(this, e);
3935 [EditorBrowsable(EditorBrowsableState.Advanced)]
3936 protected virtual void OnMouseEnter(EventArgs e) {
3937 if (MouseEnter!=null) MouseEnter(this, e);
3940 [EditorBrowsable(EditorBrowsableState.Advanced)]
3941 protected virtual void OnMouseHover(EventArgs e) {
3942 if (MouseHover!=null) MouseHover(this, e);
3945 [EditorBrowsable(EditorBrowsableState.Advanced)]
3946 protected virtual void OnMouseLeave(EventArgs e) {
3947 if (MouseLeave!=null) MouseLeave(this, e);
3950 [EditorBrowsable(EditorBrowsableState.Advanced)]
3951 protected virtual void OnMouseMove(MouseEventArgs e) {
3952 if (MouseMove!=null) MouseMove(this, e);
3955 [EditorBrowsable(EditorBrowsableState.Advanced)]
3956 protected virtual void OnMouseUp(MouseEventArgs e) {
3957 if (MouseUp!=null) MouseUp(this, e);
3960 [EditorBrowsable(EditorBrowsableState.Advanced)]
3961 protected virtual void OnMouseWheel(MouseEventArgs e) {
3962 if (MouseWheel!=null) MouseWheel(this, e);
3965 [EditorBrowsable(EditorBrowsableState.Advanced)]
3966 protected virtual void OnMove(EventArgs e) {
3967 if (Move!=null) Move(this, e);
3970 [EditorBrowsable(EditorBrowsableState.Advanced)]
3971 protected virtual void OnNotifyMessage(Message m) {
3975 [EditorBrowsable(EditorBrowsableState.Advanced)]
3976 protected virtual void OnPaint(PaintEventArgs e) {
3977 if (Paint!=null) Paint(this, e);
3980 [EditorBrowsable(EditorBrowsableState.Advanced)]
3981 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3982 PaintControlBackground (pevent);
3985 [EditorBrowsable(EditorBrowsableState.Advanced)]
3986 protected virtual void OnParentBackColorChanged(EventArgs e) {
3987 if (background_color.IsEmpty && background_image==null) {
3989 OnBackColorChanged(e);
3993 [EditorBrowsable(EditorBrowsableState.Advanced)]
3994 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3995 if (background_color.IsEmpty && background_image==null) {
3997 OnBackgroundImageChanged(e);
4001 [EditorBrowsable(EditorBrowsableState.Advanced)]
4002 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4003 if (binding_context==null) {
4004 binding_context=Parent.binding_context;
4005 OnBindingContextChanged(e);
4009 [EditorBrowsable(EditorBrowsableState.Advanced)]
4010 protected virtual void OnParentChanged(EventArgs e) {
4011 if (ParentChanged!=null) ParentChanged(this, e);
4014 [EditorBrowsable(EditorBrowsableState.Advanced)]
4015 protected virtual void OnParentEnabledChanged(EventArgs e) {
4016 if (is_enabled != Parent.is_enabled) {
4017 is_enabled=Parent.is_enabled;
4019 if (EnabledChanged != null) {
4020 EnabledChanged(this, e);
4025 [EditorBrowsable(EditorBrowsableState.Advanced)]
4026 protected virtual void OnParentFontChanged(EventArgs e) {
4033 [EditorBrowsable(EditorBrowsableState.Advanced)]
4034 protected virtual void OnParentForeColorChanged(EventArgs e) {
4035 if (foreground_color.IsEmpty) {
4037 OnForeColorChanged(e);
4041 [EditorBrowsable(EditorBrowsableState.Advanced)]
4042 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4043 if (right_to_left==RightToLeft.Inherit) {
4045 OnRightToLeftChanged(e);
4049 [EditorBrowsable(EditorBrowsableState.Advanced)]
4050 protected virtual void OnParentVisibleChanged(EventArgs e) {
4052 OnVisibleChanged(e);
4056 [EditorBrowsable(EditorBrowsableState.Advanced)]
4057 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4058 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
4061 [EditorBrowsable(EditorBrowsableState.Advanced)]
4062 protected virtual void OnResize(EventArgs e) {
4063 if (Resize!=null) Resize(this, e);
4065 PerformLayout(this, "bounds");
4067 if (parent != null) {
4068 parent.PerformLayout();
4072 [EditorBrowsable(EditorBrowsableState.Advanced)]
4073 protected virtual void OnRightToLeftChanged(EventArgs e) {
4074 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
4075 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4078 [EditorBrowsable(EditorBrowsableState.Advanced)]
4079 protected virtual void OnSizeChanged(EventArgs e) {
4080 InvalidateBuffers ();
4082 if (SizeChanged!=null) SizeChanged(this, e);
4085 [EditorBrowsable(EditorBrowsableState.Advanced)]
4086 protected virtual void OnStyleChanged(EventArgs e) {
4087 if (StyleChanged!=null) StyleChanged(this, e);
4090 [EditorBrowsable(EditorBrowsableState.Advanced)]
4091 protected virtual void OnSystemColorsChanged(EventArgs e) {
4092 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
4095 [EditorBrowsable(EditorBrowsableState.Advanced)]
4096 protected virtual void OnTabIndexChanged(EventArgs e) {
4097 if (TabIndexChanged!=null) TabIndexChanged(this, e);
4100 [EditorBrowsable(EditorBrowsableState.Advanced)]
4101 protected virtual void OnTabStopChanged(EventArgs e) {
4102 if (TabStopChanged!=null) TabStopChanged(this, e);
4105 [EditorBrowsable(EditorBrowsableState.Advanced)]
4106 protected virtual void OnTextChanged(EventArgs e) {
4107 if (TextChanged!=null) TextChanged(this, e);
4110 [EditorBrowsable(EditorBrowsableState.Advanced)]
4111 protected virtual void OnValidated(EventArgs e) {
4112 if (Validated!=null) Validated(this, e);
4115 [EditorBrowsable(EditorBrowsableState.Advanced)]
4116 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4117 if (Validating!=null) Validating(this, e);
4120 [EditorBrowsable(EditorBrowsableState.Advanced)]
4121 protected virtual void OnVisibleChanged(EventArgs e) {
4128 if (bmp_mem!=null) {
4134 if (!this.IsHandleCreated) {
4135 this.CreateControl();
4141 if (VisibleChanged!=null) VisibleChanged(this, e);
4143 // We need to tell our kids
4144 for (int i=0; i<child_controls.Count; i++) {
4145 child_controls[i].OnParentVisibleChanged(e);
4148 #endregion // OnXXX methods
4151 public event EventHandler BackColorChanged;
4152 public event EventHandler BackgroundImageChanged;
4153 public event EventHandler BindingContextChanged;
4154 public event EventHandler CausesValidationChanged;
4155 public event UICuesEventHandler ChangeUICues;
4156 public event EventHandler Click;
4157 public event EventHandler ContextMenuChanged;
4159 [EditorBrowsable(EditorBrowsableState.Advanced)]
4161 public event ControlEventHandler ControlAdded;
4163 [EditorBrowsable(EditorBrowsableState.Advanced)]
4165 public event ControlEventHandler ControlRemoved;
4167 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4168 public event EventHandler CursorChanged;
4169 public event EventHandler DockChanged;
4170 public event EventHandler DoubleClick;
4171 public event DragEventHandler DragDrop;
4172 public event DragEventHandler DragEnter;
4173 public event EventHandler DragLeave;
4174 public event DragEventHandler DragOver;
4175 public event EventHandler EnabledChanged;
4176 public event EventHandler Enter;
4177 public event EventHandler FontChanged;
4178 public event EventHandler ForeColorChanged;
4179 public event GiveFeedbackEventHandler GiveFeedback;
4181 [EditorBrowsable(EditorBrowsableState.Advanced)]
4183 public event EventHandler GotFocus;
4185 [EditorBrowsable(EditorBrowsableState.Advanced)]
4187 public event EventHandler HandleCreated;
4189 [EditorBrowsable(EditorBrowsableState.Advanced)]
4191 public event EventHandler HandleDestroyed;
4193 public event HelpEventHandler HelpRequested;
4194 public event EventHandler ImeModeChanged;
4196 [EditorBrowsable(EditorBrowsableState.Advanced)]
4198 public event InvalidateEventHandler Invalidated;
4200 public event KeyEventHandler KeyDown;
4201 public event KeyPressEventHandler KeyPress;
4202 public event KeyEventHandler KeyUp;
4203 public event LayoutEventHandler Layout;
4204 public event EventHandler Leave;
4205 public event EventHandler LocationChanged;
4207 [EditorBrowsable(EditorBrowsableState.Advanced)]
4209 public event EventHandler LostFocus;
4211 public event MouseEventHandler MouseDown;
4212 public event EventHandler MouseEnter;
4213 public event EventHandler MouseHover;
4214 public event EventHandler MouseLeave;
4215 public event MouseEventHandler MouseMove;
4216 public event MouseEventHandler MouseUp;
4218 [EditorBrowsable(EditorBrowsableState.Advanced)]
4220 public event MouseEventHandler MouseWheel;
4222 public event EventHandler Move;
4223 public event PaintEventHandler Paint;
4224 public event EventHandler ParentChanged;
4225 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
4226 public event QueryContinueDragEventHandler QueryContinueDrag;
4227 public event EventHandler Resize;
4228 public event EventHandler RightToLeftChanged;
4229 public event EventHandler SizeChanged;
4230 public event EventHandler StyleChanged;
4231 public event EventHandler SystemColorsChanged;
4232 public event EventHandler TabIndexChanged;
4233 public event EventHandler TabStopChanged;
4234 public event EventHandler TextChanged;
4235 public event EventHandler Validated;
4236 public event CancelEventHandler Validating;
4237 public event EventHandler VisibleChanged;
4238 #endregion // Events