1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2005 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
25 // Partially based on work by:
26 // Aleksey Ryabchuk ryabchuk@yahoo.com
27 // Alexandre Pigolkine pigolkine@gmx.de
28 // Dennis Hayes dennish@raytek.com
29 // Jaak Simm jaaksimm@firm.ee
30 // John Sohn jsohn@columbus.rr.com
36 using System.ComponentModel;
37 using System.ComponentModel.Design;
38 using System.ComponentModel.Design.Serialization;
39 using System.Collections;
40 using System.Diagnostics;
42 using System.Reflection;
43 using System.Runtime.InteropServices;
44 using System.Security;
45 using System.Threading;
48 namespace System.Windows.Forms
50 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
51 [DefaultProperty("Text")]
52 [DefaultEvent("Click")]
53 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
54 [ToolboxItemFilter("System.Windows.Forms")]
55 public class Control : Component, ISynchronizeInvoke, IWin32Window
57 #region Local Variables
60 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
61 internal object creator_thread; // thread that created the control
62 internal ControlNativeWindow window; // object for native window handle
63 internal string name; // for object naming
66 private bool create_handled; // true if OnCreateControl has been sent
67 internal bool has_focus; // true if control has focus
68 internal bool is_visible; // true if control is visible
69 internal bool is_entered; // is the mouse inside the control?
70 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
71 internal bool is_selected; // true if control is selected
72 internal bool is_accessible; // true if the control is visible to accessibility applications
73 internal bool is_captured; // tracks if the control has captured the mouse
74 internal bool is_toplevel; // tracks if the control is a toplevel window
75 internal bool is_recreating; // tracks if the handle for the control is being recreated
76 internal bool causes_validation; // tracks if validation is executed on changes
77 internal int tab_index; // position in tab order of siblings
78 internal bool tab_stop = true; // is the control a tab stop?
79 internal bool is_disposed; // has the window already been disposed?
80 internal Size client_size; // size of the client area (window excluding decorations)
81 internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
82 internal ControlStyles control_style; // rather win32-specific, style bits for control
83 internal ImeMode ime_mode = ImeMode.Inherit;
84 internal bool layout_pending; // true if our parent needs to re-layout us
85 internal object control_tag; // object that contains data about our control
86 internal int mouse_clicks; // Counter for mouse clicks
87 internal Cursor cursor; // Cursor for the window
88 private bool allow_drop; // true if the control accepts droping objects on it
91 internal Color foreground_color; // foreground color for control
92 internal Color background_color; // background color for control
93 internal Image background_image; // background image for control
94 internal Font font; // font for control
95 internal string text; // window/title text for control
96 internal BorderStyle border_style; // Border style of control
99 internal AnchorStyles anchor_style; // anchoring requirements for our control
100 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
101 internal int dist_left; // distance to the left border of the parent
102 internal int dist_top; // distance to the top border of the parent
103 internal int dist_right; // distance to the right border of the parent
104 internal int dist_bottom; // distance to the bottom border of the parent
106 // to be categorized...
107 static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
108 internal ControlCollection child_controls; // our children
109 internal Control parent; // our parent control
110 internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
111 internal BindingContext binding_context; // TODO
112 internal RightToLeft right_to_left; // drawing direction for control
113 internal int layout_suspended;
114 internal ContextMenu context_menu; // Context menu associated with the control
116 private Graphics dc_mem; // Graphics context for double buffering
117 private Bitmap bmp_mem; // Bitmap for double buffering control
118 private bool needs_redraw = true;
120 private ControlBindingsCollection data_bindings;
122 #endregion // Local Variables
124 #region Private Classes
125 // This helper class allows us to dispatch messages to Control.WndProc
126 internal class ControlNativeWindow : NativeWindow {
127 private Control owner;
129 public ControlNativeWindow(Control control) : base() {
134 public Control Owner {
140 static internal Control ControlFromHandle(IntPtr hWnd) {
141 ControlNativeWindow window;
143 window = (ControlNativeWindow)window_collection[hWnd];
148 protected override void WndProc(ref Message m) {
149 owner.WndProc(ref m);
154 #region Public Classes
156 public class ControlAccessibleObject : AccessibleObject {
157 #region ControlAccessibleObject Local Variables
158 private Control owner;
159 #endregion // ControlAccessibleObject Local Variables
161 #region ControlAccessibleObject Constructors
162 public ControlAccessibleObject(Control ownerControl) {
163 this.owner = ownerControl;
165 #endregion // ControlAccessibleObject Constructors
167 #region ControlAccessibleObject Public Instance Properties
168 public override string DefaultAction {
170 return base.DefaultAction;
174 public override string Description {
176 return base.Description;
180 public IntPtr Handle {
186 // We don't want to let them set it
190 public override string Help {
196 public override string KeyboardShortcut {
198 return base.KeyboardShortcut;
202 public override string Name {
212 public Control Owner {
218 public override AccessibleObject Parent {
225 public override AccessibleRole Role {
230 #endregion // ControlAccessibleObject Public Instance Properties
232 #region ControlAccessibleObject Public Instance Methods
233 public override int GetHelpTopic(out string FileName) {
234 return base.GetHelpTopic (out FileName);
237 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
238 public void NotifyClients(AccessibleEvents accEvent) {
239 throw new NotImplementedException();
242 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
243 public void NotifyClients(AccessibleEvents accEvent, int childID) {
244 throw new NotImplementedException();
247 public override string ToString() {
248 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
251 #endregion // ControlAccessibleObject Public Instance Methods
254 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
255 [ListBindable(false)]
256 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
257 #region ControlCollection Local Variables
258 private ArrayList list;
259 private ArrayList impl_list;
260 private Control [] all_controls;
261 internal Control owner;
262 #endregion // ControlCollection Local Variables
264 #region ControlCollection Public Constructor
265 public ControlCollection(Control owner) {
267 this.list=new ArrayList();
271 #region ControlCollection Public Instance Properties
278 public bool IsReadOnly {
280 return list.IsReadOnly;
284 public virtual Control this[int index] {
286 if (index < 0 || index >= list.Count) {
287 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
289 return (Control)list[index];
292 #endregion // ControlCollection Public Instance Properties
294 #region ControlCollection Private Instance Methods
295 public virtual void Add (Control value)
300 if (Contains (value))
303 if (value.tab_index == -1) {
309 end = owner.child_controls.Count;
310 for (int i = 0; i < end; i++) {
311 index = owner.child_controls[i].tab_index;
316 value.tab_index = use;
321 value.Parent = owner;
322 owner.UpdateZOrder();
323 owner.OnControlAdded(new ControlEventArgs(value));
326 internal void AddToList (Control c)
332 internal virtual void AddImplicit (Control control)
334 if (impl_list == null)
335 impl_list = new ArrayList ();
337 impl_list.Add (control);
338 control.Parent = owner;
339 owner.UpdateZOrder ();
342 public virtual void AddRange (Control[] controls)
344 if (controls == null)
345 throw new ArgumentNullException ("controls");
347 owner.SuspendLayout ();
350 for (int i = 0; i < controls.Length; i++)
353 owner.ResumeLayout ();
357 internal virtual void AddRangeImplicit (Control [] controls)
359 if (controls == null)
360 throw new ArgumentNullException ("controls");
362 owner.SuspendLayout ();
365 for (int i = 0; i < controls.Length; i++)
366 AddImplicit (controls [i]);
368 owner.ResumeLayout ();
372 public virtual void Clear ()
374 owner.SuspendLayout();
376 for (int i = 0; i < list.Count; i++) {
377 owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
380 owner.ResumeLayout();
383 internal virtual void ClearImplicit ()
385 if (impl_list == null)
391 public bool Contains (Control value)
393 for (int i = list.Count; i > 0; ) {
396 if (list [i] == value) {
397 // Do we need to do anything here?
404 internal bool ImplicitContains (Control value)
406 if (impl_list == null)
409 for (int i = impl_list.Count; i > 0; ) {
412 if (impl_list [i] == value) {
413 // Do we need to do anything here?
420 internal bool AllContains (Control value)
422 return Contains (value) || ImplicitContains (value);
425 public void CopyTo (Array array, int index)
427 list.CopyTo(array, index);
430 public override bool Equals(object other) {
431 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
438 public int GetChildIndex(Control child) {
439 return GetChildIndex(child, false);
442 public int GetChildIndex(Control child, bool throwException) {
445 index=list.IndexOf(child);
447 if (index==-1 && throwException) {
448 throw new ArgumentException("Not a child control", "child");
453 public IEnumerator GetEnumerator() {
454 return list.GetEnumerator();
457 internal IEnumerator GetAllEnumerator ()
459 Control [] res = GetAllControls ();
460 return res.GetEnumerator ();
463 internal Control [] GetAllControls ()
465 if (all_controls != null)
468 if (impl_list == null)
469 return (Control []) list.ToArray (typeof (Control));
470 Control [] res = new Control [list.Count + impl_list.Count];
472 impl_list.CopyTo (res, list.Count);
476 public override int GetHashCode() {
477 return base.GetHashCode();
480 public int IndexOf(Control control) {
481 return list.IndexOf(control);
484 public virtual void Remove(Control value) {
487 owner.OnControlRemoved(new ControlEventArgs(value));
490 owner.UpdateZOrder();
493 internal virtual void RemoveImplicit (Control control)
495 if (impl_list != null) {
497 impl_list.Remove (control);
499 control.Parent = null;
500 owner.UpdateZOrder ();
503 public void RemoveAt(int index) {
504 if (index < 0 || index >= list.Count) {
505 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
507 Remove ((Control)list[index]);
510 public void SetChildIndex(Control child, int newIndex) {
513 old_index=list.IndexOf(child);
515 throw new ArgumentException("Not a child control", "child");
518 if (old_index==newIndex) {
524 if (newIndex>list.Count) {
527 list.Insert(newIndex, child);
529 child.parent = owner;
530 owner.UpdateZOrder();
532 #endregion // ControlCollection Private Instance Methods
534 #region ControlCollection Interface Properties
535 object IList.this[int index] {
537 if (index<0 || index>=list.Count) {
538 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
544 if (!(value is Control)) {
545 throw new ArgumentException("Object of type Control required", "value");
548 list[index]=(Control)value;
552 bool IList.IsFixedSize {
558 bool IList.IsReadOnly {
560 return list.IsReadOnly;
564 bool ICollection.IsSynchronized {
566 return list.IsSynchronized;
570 object ICollection.SyncRoot {
572 return list.SyncRoot;
575 #endregion // ControlCollection Interface Properties
577 #region ControlCollection Interface Methods
578 int IList.Add(object value) {
580 throw new ArgumentNullException("value", "Cannot add null controls");
583 if (!(value is Control)) {
584 throw new ArgumentException("Object of type Control required", "value");
587 return list.Add(value);
590 bool IList.Contains(object value) {
591 if (!(value is Control)) {
592 throw new ArgumentException("Object of type Control required", "value");
595 return this.Contains((Control) value);
598 int IList.IndexOf(object value) {
599 if (!(value is Control)) {
600 throw new ArgumentException("Object of type Control required", "value");
603 return this.IndexOf((Control) value);
606 void IList.Insert(int index, object value) {
607 if (!(value is Control)) {
608 throw new ArgumentException("Object of type Control required", "value");
611 list.Insert(index, value);
614 void IList.Remove(object value) {
615 if (!(value is Control)) {
616 throw new ArgumentException("Object of type Control required", "value");
622 void ICollection.CopyTo(Array array, int index) {
624 list.CopyTo(array, index);
628 Object ICloneable.Clone() {
629 ControlCollection clone = new ControlCollection(this.owner);
630 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
633 #endregion // ControlCollection Interface Methods
635 #endregion // ControlCollection Class
637 #region Public Constructors
639 creator_thread = Thread.CurrentThread;
641 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
643 create_handled = false;
649 layout_pending = false;
651 causes_validation = true;
653 layout_suspended = 0;
657 right_to_left = RightToLeft.Inherit;
658 border_style = BorderStyle.None;
659 background_color = Color.Empty;
665 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
666 ControlStyles.Selectable | ControlStyles.StandardClick |
667 ControlStyles.StandardDoubleClick;
670 background_image = null;
674 window = new ControlNativeWindow(this);
675 child_controls = CreateControlsInstance();
676 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
677 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
678 XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, CreateParams.ExStyle, IntPtr.Zero, out bounds);
679 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
685 public Control(Control parent, string text) : this() {
690 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
695 bounds.Height=height;
696 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
700 public Control(string text) : this() {
704 public Control(string text, int left, int top, int width, int height) : this() {
708 bounds.Height=height;
709 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
713 protected override void Dispose(bool disposing) {
726 controls.Remove(this);
728 #endregion // Public Constructors
730 #region Internal Properties
731 internal BorderStyle InternalBorderStyle {
737 if (!Enum.IsDefined (typeof (BorderStyle), value))
738 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
740 if (border_style != value) {
741 border_style = value;
743 if (IsHandleCreated) {
744 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
750 #endregion // Internal Properties
752 #region Private & Internal Methods
753 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
754 AsyncMethodResult result;
755 AsyncMethodData data;
760 if (!p.IsHandleCreated) {
761 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
766 result = new AsyncMethodResult ();
767 data = new AsyncMethodData ();
769 data.Method = method;
771 data.Result = new WeakReference (result);
774 if (!ExecutionContext.IsFlowSuppressed ()) {
775 data.Context = ExecutionContext.Capture ();
778 #if !MWF_ON_MSRUNTIME
779 if (SecurityManager.SecurityEnabled) {
780 data.Stack = CompressedStack.GetCompressedStack ();
785 XplatUI.SendAsyncMethod (data);
789 internal Graphics DeviceContext {
792 CreateBuffers(this.Width, this.Height);
798 private Bitmap ImageBuffer {
801 CreateBuffers(this.Width, this.Height);
807 internal void CreateBuffers (int width, int height) {
808 if (dc_mem != null) {
822 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
823 dc_mem = Graphics.FromImage (bmp_mem);
827 internal void InvalidateBuffers ()
829 if (dc_mem != null) {
840 internal static void SetChildColor(Control parent) {
843 for (int i=0; i < parent.child_controls.Count; i++) {
844 child=parent.child_controls[i];
845 if (child.child_controls.Count>0) {
846 SetChildColor(child);
852 internal bool Select(Control control) {
854 IContainerControl container;
856 if (control == null) {
860 parent = control.parent;
862 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
863 while (parent != null) {
864 if (!parent.Visible || !parent.is_enabled) {
867 parent = parent.parent;
871 control.is_selected = true;
873 container = GetContainerControl();
874 if (container != null) {
875 container.ActiveControl = control;
877 if (control.IsHandleCreated) {
878 XplatUI.SetFocus(control.window.Handle);
883 internal virtual void DoDefaultAction() {
884 // Only here to be overriden by our actual controls; this is needed by the accessibility class
887 internal static int LowOrder (int param) {
888 return ((int)(short)(param & 0xffff));
891 internal static int HighOrder (int param) {
892 return ((int)(short)(param >> 16));
895 // This method exists so controls overriding OnPaintBackground can have default background painting done
896 internal virtual void PaintControlBackground (PaintEventArgs pevent)
898 if (background_image == null) {
899 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));
903 DrawBackgroundImage (pevent.Graphics);
906 void DrawBackgroundImage (Graphics g)
908 using (TextureBrush b = new TextureBrush (background_image)) {
909 g.FillRectangle (b, ClientRectangle);
913 internal void DndEnter (DragEventArgs e)
918 internal void DndOver (DragEventArgs e)
923 internal void DndDrop (DragEventArgs e)
928 internal void DndLeave (EventArgs e)
933 internal void DnDFeedback(GiveFeedbackEventArgs e)
938 internal void DnDContinueDrag(QueryContinueDragEventArgs e) {
939 OnQueryContinueDrag(e);
942 internal static MouseButtons FromParamToMouseButtons (int param) {
943 MouseButtons buttons = MouseButtons.None;
945 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
946 buttons |= MouseButtons.Left;
948 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
949 buttons |= MouseButtons.Middle;
951 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
952 buttons |= MouseButtons.Right;
958 internal virtual bool ProcessControlMnemonic(char charCode) {
959 return ProcessMnemonic(charCode);
962 private static Control FindFlatForward(Control container, Control start) {
968 end = container.child_controls.Count;
971 index = start.tab_index;
976 for (int i = 0; i < end; i++) {
978 if (container.child_controls[i].tab_index > index) {
979 found = container.child_controls[i];
981 } else if (found.tab_index > container.child_controls[i].tab_index) {
982 if (container.child_controls[i].tab_index > index) {
983 found = container.child_controls[i];
990 private static Control FindControlForward(Control container, Control start) {
997 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
998 found = FindControlForward(start, null);
1005 while (p != container) {
1006 found = FindFlatForward(p, start);
1007 if (found != null) {
1014 return FindFlatForward(container, start);
1017 private static Control FindFlatBackward(Control container, Control start) {
1023 end = container.child_controls.Count;
1025 if (start != null) {
1026 index = start.tab_index;
1028 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1030 for (int i = 0; i < end; i++) {
1031 if (container.child_controls[i].tab_index > index) {
1032 index = container.child_controls[i].tab_index;
1038 for (int i = 0; i < end; i++) {
1039 if (found == null) {
1040 if (container.child_controls[i].tab_index < index) {
1041 found = container.child_controls[i];
1043 } else if (found.tab_index < container.child_controls[i].tab_index) {
1044 if (container.child_controls[i].tab_index < index) {
1045 found = container.child_controls[i];
1052 private static Control FindControlBackward(Control container, Control start) {
1057 if (start != null) {
1058 found = FindFlatBackward(start.parent, start);
1059 if (found == null && start.parent != container) {
1060 return start.parent;
1063 if (found == null) {
1064 found = FindFlatBackward(container, start);
1067 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
1068 found = FindControlBackward(found, null);
1069 if (found != null) {
1077 private void HandleClick(int clicks) {
1078 if (GetStyle(ControlStyles.StandardClick)) {
1080 if (GetStyle(ControlStyles.StandardDoubleClick)) {
1081 OnDoubleClick(EventArgs.Empty);
1083 OnClick(EventArgs.Empty);
1086 OnClick(EventArgs.Empty);
1091 private void CheckDataBindings ()
1093 if (data_bindings == null)
1096 BindingContext binding_context = BindingContext;
1097 foreach (Binding binding in data_bindings) {
1098 binding.Check (binding_context);
1101 #endregion // Private & Internal Methods
1103 #region Public Static Properties
1104 public static Color DefaultBackColor {
1106 return ThemeEngine.Current.DefaultControlBackColor;
1110 public static Font DefaultFont {
1112 return ThemeEngine.Current.DefaultFont;
1116 public static Color DefaultForeColor {
1118 return ThemeEngine.Current.DefaultControlForeColor;
1122 public static Keys ModifierKeys {
1124 return XplatUI.State.ModifierKeys;
1128 public static MouseButtons MouseButtons {
1130 return XplatUI.State.MouseButtons;
1134 public static Point MousePosition {
1136 return Cursor.Position;
1142 public static bool CheckForIllegalCrossThreadCalls
1151 #endregion // Public Static Properties
1153 #region Public Instance Properties
1154 [EditorBrowsable(EditorBrowsableState.Advanced)]
1156 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1157 public AccessibleObject AccessibilityObject {
1159 if (accessibility_object==null) {
1160 accessibility_object=CreateAccessibilityInstance();
1162 return accessibility_object;
1166 [EditorBrowsable(EditorBrowsableState.Advanced)]
1168 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1169 public string AccessibleDefaultActionDescription {
1171 return AccessibilityObject.default_action;
1175 AccessibilityObject.default_action=value;
1180 [DefaultValue(null)]
1181 public string AccessibleDescription {
1183 return AccessibilityObject.description;
1187 AccessibilityObject.description=value;
1192 [DefaultValue(null)]
1193 public string AccessibleName {
1195 return AccessibilityObject.Name;
1199 AccessibilityObject.Name=value;
1203 [DefaultValue(AccessibleRole.Default)]
1204 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1205 public AccessibleRole AccessibleRole {
1207 return AccessibilityObject.role;
1211 AccessibilityObject.role=value;
1215 [DefaultValue(false)]
1216 public virtual bool AllowDrop {
1222 if (allow_drop == value)
1226 XplatUI.SetAllowDrop (Handle, value);
1231 [RefreshProperties(RefreshProperties.Repaint)]
1232 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1233 public virtual AnchorStyles Anchor {
1235 return anchor_style;
1241 if (parent != null) {
1242 parent.PerformLayout(this, "Parent");
1248 public virtual Color BackColor {
1250 if (background_color.IsEmpty) {
1252 return parent.BackColor;
1254 return DefaultBackColor;
1256 return background_color;
1260 background_color=value;
1261 SetChildColor(this);
1262 OnBackColorChanged(EventArgs.Empty);
1268 [DefaultValue(null)]
1269 public virtual Image BackgroundImage {
1271 return background_image;
1275 if (background_image!=value) {
1276 background_image=value;
1277 OnBackgroundImageChanged(EventArgs.Empty);
1282 [EditorBrowsable(EditorBrowsableState.Advanced)]
1284 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1285 public virtual BindingContext BindingContext {
1287 if (binding_context != null)
1288 return binding_context;
1291 binding_context = Parent.BindingContext;
1292 return binding_context;
1295 if (binding_context != value) {
1296 binding_context = value;
1297 OnBindingContextChanged(EventArgs.Empty);
1302 [EditorBrowsable(EditorBrowsableState.Advanced)]
1304 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1307 return bounds.Y+bounds.Height;
1311 [EditorBrowsable(EditorBrowsableState.Advanced)]
1313 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1314 public Rectangle Bounds {
1320 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1324 [EditorBrowsable(EditorBrowsableState.Advanced)]
1326 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1327 public bool CanFocus {
1329 if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1336 [EditorBrowsable(EditorBrowsableState.Advanced)]
1338 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1339 public bool CanSelect {
1343 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1347 parent = this.parent;
1348 while (parent != null) {
1349 if (!parent.is_visible || !parent.is_enabled) {
1353 parent = parent.parent;
1359 [EditorBrowsable(EditorBrowsableState.Advanced)]
1361 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1362 public bool Capture {
1364 return this.is_captured;
1368 if (this.IsHandleCreated) {
1369 if (value && !is_captured) {
1371 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1372 } else if (!value && is_captured) {
1373 XplatUI.UngrabWindow(this.window.Handle);
1374 is_captured = false;
1380 [DefaultValue(true)]
1381 public bool CausesValidation {
1383 return this.causes_validation;
1387 if (this.causes_validation != value) {
1388 causes_validation = value;
1389 OnCausesValidationChanged(EventArgs.Empty);
1394 [EditorBrowsable(EditorBrowsableState.Advanced)]
1396 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1397 public Rectangle ClientRectangle {
1399 client_rect.Width = client_size.Width;
1400 client_rect.Height = client_size.Height;
1405 [EditorBrowsable(EditorBrowsableState.Advanced)]
1407 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1408 public Size ClientSize {
1411 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1412 return ((Form)this).form_parent_window.ClientSize;
1420 this.SetClientSizeCore(value.Width, value.Height);
1424 [EditorBrowsable(EditorBrowsableState.Advanced)]
1426 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1427 [DescriptionAttribute("ControlCompanyNameDescr")]
1428 public String CompanyName {
1430 return "Mono Project, Novell, Inc.";
1434 [EditorBrowsable(EditorBrowsableState.Advanced)]
1436 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1437 public bool ContainsFocus {
1443 for (int i=0; i < child_controls.Count; i++) {
1444 if (child_controls[i].ContainsFocus) {
1452 [DefaultValue(null)]
1453 public virtual ContextMenu ContextMenu {
1455 return context_menu;
1459 if (context_menu != value) {
1460 context_menu = value;
1461 OnContextMenuChanged(EventArgs.Empty);
1467 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1468 public ControlCollection Controls {
1470 return this.child_controls;
1474 [EditorBrowsable(EditorBrowsableState.Advanced)]
1476 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1477 public bool Created {
1479 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1486 [AmbientValue(null)]
1487 public virtual Cursor Cursor {
1489 if (cursor != null) {
1493 if (parent != null) {
1494 return parent.Cursor;
1497 return Cursors.Default;
1501 if (cursor != value) {
1506 pt = Cursor.Position;
1507 if (bounds.Contains(pt)) {
1508 if (GetChildAtPoint(pt) == null) {
1509 if (cursor != null) {
1510 XplatUI.SetCursor(window.Handle, cursor.handle);
1512 if (parent != null) {
1513 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1515 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1521 OnCursorChanged(EventArgs.Empty);
1527 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1528 [ParenthesizePropertyName(true)]
1529 [RefreshProperties(RefreshProperties.All)]
1530 public ControlBindingsCollection DataBindings {
1532 if (data_bindings == null)
1533 data_bindings = new ControlBindingsCollection (this);
1534 return data_bindings;
1538 [EditorBrowsable(EditorBrowsableState.Advanced)]
1540 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1541 public virtual Rectangle DisplayRectangle {
1543 return ClientRectangle;
1547 [EditorBrowsable(EditorBrowsableState.Advanced)]
1549 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1550 public bool Disposing {
1557 [RefreshProperties(RefreshProperties.Repaint)]
1558 [DefaultValue(DockStyle.None)]
1559 public virtual DockStyle Dock {
1565 if (dock_style == value) {
1571 if (parent != null) {
1572 parent.PerformLayout(this, "Parent");
1575 OnDockChanged(EventArgs.Empty);
1581 public bool Enabled {
1587 if (is_enabled == value) {
1593 OnEnabledChanged (EventArgs.Empty);
1597 [EditorBrowsable(EditorBrowsableState.Advanced)]
1599 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1600 public virtual bool Focused {
1602 return this.has_focus;
1607 [AmbientValue(null)]
1609 public virtual Font Font {
1615 if (Parent != null && Parent.Font != null) {
1623 if (font != null && font.Equals (value)) {
1629 OnFontChanged (EventArgs.Empty);
1634 public virtual Color ForeColor {
1636 if (foreground_color.IsEmpty) {
1638 return parent.ForeColor;
1640 return DefaultForeColor;
1642 return foreground_color;
1646 if (foreground_color != value) {
1647 foreground_color=value;
1649 OnForeColorChanged(EventArgs.Empty);
1656 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1657 public IntPtr Handle { // IWin32Window
1659 if (!IsHandleCreated) {
1662 return window.Handle;
1666 [EditorBrowsable(EditorBrowsableState.Advanced)]
1668 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1669 public bool HasChildren {
1671 if (this.child_controls.Count>0) {
1678 [EditorBrowsable(EditorBrowsableState.Always)]
1680 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1683 return this.bounds.Height;
1687 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1691 [AmbientValue(ImeMode.Inherit)]
1693 public ImeMode ImeMode {
1695 if (ime_mode == DefaultImeMode) {
1697 return parent.ImeMode;
1699 return ImeMode.NoControl; // default value
1705 if (ime_mode != value) {
1708 OnImeModeChanged(EventArgs.Empty);
1713 [EditorBrowsable(EditorBrowsableState.Advanced)]
1715 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1716 public bool InvokeRequired { // ISynchronizeInvoke
1718 if (creator_thread!=Thread.CurrentThread) {
1725 [EditorBrowsable(EditorBrowsableState.Advanced)]
1727 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1728 public bool IsAccessible {
1730 return is_accessible;
1734 is_accessible = value;
1738 [EditorBrowsable(EditorBrowsableState.Advanced)]
1740 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1741 public bool IsDisposed {
1743 return this.is_disposed;
1747 [EditorBrowsable(EditorBrowsableState.Advanced)]
1749 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1750 public bool IsHandleCreated {
1752 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1760 [EditorBrowsable(EditorBrowsableState.Always)]
1762 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1765 return this.bounds.X;
1769 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1774 public Point Location {
1776 return new Point(bounds.X, bounds.Y);
1780 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1785 public string Name {
1796 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1797 public Control Parent {
1803 if (value == this) {
1804 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1807 if (parent!=value) {
1809 parent.Controls.Remove(this);
1815 if (!parent.Controls.AllContains (this)) {
1816 Console.WriteLine ("Adding child: " + this);
1817 parent.Controls.Add(this);
1820 if (IsHandleCreated) {
1821 XplatUI.SetParent(Handle, value.Handle);
1824 OnParentChanged(EventArgs.Empty);
1830 [EditorBrowsable(EditorBrowsableState.Advanced)]
1832 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1833 public string ProductName {
1835 Type t = typeof (AssemblyProductAttribute);
1836 Assembly assembly = GetType().Module.Assembly;
1837 object [] attrs = assembly.GetCustomAttributes (t, false);
1838 AssemblyProductAttribute a = null;
1839 // On MS we get a NullRefException if product attribute is not
1841 if (attrs != null && attrs.Length > 0)
1842 a = (AssemblyProductAttribute) attrs [0];
1847 [EditorBrowsable(EditorBrowsableState.Advanced)]
1849 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1850 public string ProductVersion {
1852 Type t = typeof (AssemblyVersionAttribute);
1853 Assembly assembly = GetType().Module.Assembly;
1854 object [] attrs = assembly.GetCustomAttributes (t, false);
1855 if (attrs == null || attrs.Length < 1)
1857 return ((AssemblyVersionAttribute)attrs [0]).Version;
1861 [EditorBrowsable(EditorBrowsableState.Advanced)]
1863 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1864 public bool RecreatingHandle {
1866 return is_recreating;
1870 [EditorBrowsable(EditorBrowsableState.Advanced)]
1872 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1873 public Region Region {
1875 return new Region(this.bounds);
1882 g = this.CreateGraphics();
1883 r = value.GetBounds(g);
1885 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1891 [EditorBrowsable(EditorBrowsableState.Advanced)]
1893 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1896 return this.bounds.X+this.bounds.Width;
1900 [AmbientValue(RightToLeft.Inherit)]
1902 public virtual RightToLeft RightToLeft {
1904 if (right_to_left == RightToLeft.Inherit) {
1906 return parent.RightToLeft;
1908 return RightToLeft.No; // default value
1910 return right_to_left;
1914 if (value != right_to_left) {
1915 right_to_left = value;
1916 OnRightToLeftChanged(EventArgs.Empty);
1921 [EditorBrowsable(EditorBrowsableState.Advanced)]
1922 public override ISite Site {
1935 return new Size(Width, Height);
1939 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1944 [MergableProperty(false)]
1945 public int TabIndex {
1947 if (tab_index != -1) {
1954 if (tab_index != value) {
1956 OnTabIndexChanged(EventArgs.Empty);
1962 [DefaultValue(true)]
1963 public bool TabStop {
1969 if (tab_stop != value) {
1971 OnTabStopChanged(EventArgs.Empty);
1976 [Localizable(false)]
1978 [TypeConverter(typeof(StringConverter))]
1979 [DefaultValue(null)]
1986 control_tag = value;
1992 [BindableAttribute(true)]
1993 public virtual string Text {
1995 // Our implementation ignores ControlStyles.CacheText - we always cache
2000 if (value == null) {
2001 value = String.Empty;
2006 if (IsHandleCreated) {
2007 XplatUI.Text(Handle, text);
2009 OnTextChanged (EventArgs.Empty);
2014 [EditorBrowsable(EditorBrowsableState.Always)]
2016 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2019 return this.bounds.Y;
2023 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2027 [EditorBrowsable(EditorBrowsableState.Advanced)]
2029 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2030 public Control TopLevelControl {
2034 while (p.parent != null) {
2043 public bool Visible {
2047 } else if (parent != null) {
2048 return parent.Visible;
2055 SetVisibleCore(value);
2059 [EditorBrowsable(EditorBrowsableState.Always)]
2061 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2064 return this.bounds.Width;
2068 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2072 [EditorBrowsable(EditorBrowsableState.Never)]
2074 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2075 public IWindowTarget WindowTarget {
2084 #endregion // Public Instance Properties
2086 #region Protected Instance Properties
2087 protected virtual CreateParams CreateParams {
2089 CreateParams create_params = new CreateParams();
2092 create_params.Caption = Text;
2095 create_params.Caption = text;
2099 create_params.X = Left;
2102 create_params.X = this.bounds.X;
2106 create_params.Y = Top;
2109 create_params.Y = this.bounds.Y;
2113 create_params.Width = Width;
2116 create_params.Width = this.bounds.Width;
2120 create_params.Height = Height;
2123 create_params.Height = this.bounds.Height;
2127 create_params.ClassName = XplatUI.DefaultClassName;
2128 create_params.ClassStyle = 0;
2129 create_params.ExStyle = 0;
2130 create_params.Param = 0;
2133 create_params.ExStyle |= (int)WindowStyles.WS_EX_ACCEPTFILES;
2137 create_params.Parent = parent.Handle;
2140 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2143 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2146 return create_params;
2150 protected virtual ImeMode DefaultImeMode {
2152 return ImeMode.Inherit;
2156 protected virtual Size DefaultSize {
2158 return new Size(100, 23);
2162 protected int FontHeight {
2172 protected bool RenderRightToLeft {
2174 return (this.right_to_left == RightToLeft.Yes);
2178 protected bool ResizeRedraw {
2180 return GetStyle(ControlStyles.ResizeRedraw);
2184 SetStyle(ControlStyles.ResizeRedraw, value);
2188 [EditorBrowsable(EditorBrowsableState.Advanced)]
2190 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2191 protected virtual bool ShowFocusCues {
2197 [EditorBrowsable(EditorBrowsableState.Advanced)]
2199 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2200 protected bool ShowKeyboardCues {
2205 #endregion // Protected Instance Properties
2207 #region Public Static Methods
2208 [EditorBrowsable(EditorBrowsableState.Advanced)]
2209 public static Control FromChildHandle(IntPtr handle) {
2210 IEnumerator control = Control.controls.GetEnumerator();
2212 while (control.MoveNext()) {
2213 if (((Control)control.Current).window.Handle == handle) {
2215 if (((Control)control.Current).Parent != null) {
2216 return ((Control)control.Current).Parent;
2223 [EditorBrowsable(EditorBrowsableState.Advanced)]
2224 public static Control FromHandle(IntPtr handle) {
2225 IEnumerator control = Control.controls.GetEnumerator();
2227 while (control.MoveNext()) {
2228 if (((Control)control.Current).window.Handle == handle) {
2230 return ((Control)control.Current);
2236 public static bool IsMnemonic(char charCode, string text) {
2239 amp = text.IndexOf('&');
2242 if (amp + 1 < text.Length) {
2243 if (text[amp + 1] != '&') {
2244 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2254 #region Protected Static Methods
2255 [EditorBrowsable(EditorBrowsableState.Advanced)]
2256 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2259 c = Control.FromHandle(hWnd);
2269 #region Public Instance Methods
2270 [EditorBrowsable(EditorBrowsableState.Advanced)]
2271 public IAsyncResult BeginInvoke(Delegate method) {
2272 return BeginInvokeInternal(method, null);
2275 [EditorBrowsable(EditorBrowsableState.Advanced)]
2276 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2277 return BeginInvokeInternal (method, args);
2280 public void BringToFront() {
2281 if ((parent != null) && (parent.child_controls[0]!=this)) {
2282 if (parent.child_controls.Contains(this)) {
2283 parent.child_controls.SetChildIndex(this, 0);
2287 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
2289 if (parent != null) {
2294 public bool Contains(Control ctl) {
2295 while (ctl != null) {
2304 public void CreateControl() {
2306 if (!IsHandleCreated) {
2310 if (!create_handled) {
2311 create_handled = true;
2315 Control [] controls = child_controls.GetAllControls ();
2316 for (int i=0; i<controls.Length; i++) {
2317 controls [i].CreateControl ();
2321 public Graphics CreateGraphics() {
2322 if (!IsHandleCreated) {
2323 this.CreateControl();
2325 return Graphics.FromHwnd(this.window.Handle);
2328 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2329 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2332 [EditorBrowsable(EditorBrowsableState.Advanced)]
2333 public object EndInvoke (IAsyncResult async_result) {
2334 AsyncMethodResult result = (AsyncMethodResult) async_result;
2335 return result.EndInvoke ();
2338 public Form FindForm() {
2351 public bool Focus() {
2352 if (IsHandleCreated && !has_focus) {
2354 XplatUI.SetFocus(window.Handle);
2359 public Control GetChildAtPoint(Point pt) {
2360 // Microsoft's version of this function doesn't seem to work, so I can't check
2361 // if we only consider children or also grandchildren, etc.
2362 // I'm gonna say 'children only'
2363 for (int i=0; i<child_controls.Count; i++) {
2364 if (child_controls[i].Bounds.Contains(pt)) {
2365 return child_controls[i];
2371 public IContainerControl GetContainerControl() {
2372 Control current = this;
2374 while (current!=null) {
2375 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2376 return (IContainerControl)current;
2378 current = current.parent;
2383 public Control GetNextControl(Control ctl, bool forward) {
2384 // If we're not a container we don't play
2385 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2389 // If ctl is not contained by this, we start at the first child of this
2390 if (!this.Contains(ctl)) {
2394 // Search through our controls, starting at ctl, stepping into children as we encounter them
2395 // try to find the control with the tabindex closest to our own, or, if we're looking into
2396 // child controls, the one with the smallest tabindex
2398 return FindControlForward(this, ctl);
2400 return FindControlBackward(this, ctl);
2403 public void Hide() {
2404 this.Visible = false;
2407 public void Invalidate() {
2408 Invalidate(ClientRectangle, false);
2411 public void Invalidate(bool invalidateChildren) {
2412 Invalidate(ClientRectangle, invalidateChildren);
2415 public void Invalidate(System.Drawing.Rectangle rc) {
2416 Invalidate(rc, false);
2419 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2420 if (!IsHandleCreated || !Visible) {
2424 NotifyInvalidate(rc);
2426 XplatUI.Invalidate(Handle, rc, false);
2428 if (invalidateChildren) {
2429 Control [] controls = child_controls.GetAllControls ();
2430 for (int i=0; i<controls.Length; i++)
2431 controls [i].Invalidate ();
2433 OnInvalidated(new InvalidateEventArgs(rc));
2436 public void Invalidate(System.Drawing.Region region) {
2437 Invalidate(region, false);
2440 [MonoTODO("Figure out if GetRegionScans is usable")]
2441 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2442 throw new NotImplementedException();
2444 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2445 //if (invalidateChildren) {
2446 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2450 public object Invoke (Delegate method) {
2451 return Invoke(method, null);
2454 public object Invoke (Delegate method, object[] args) {
2455 if (!this.InvokeRequired) {
2456 return method.DynamicInvoke(args);
2459 IAsyncResult result = BeginInvoke (method, args);
2460 return EndInvoke(result);
2463 [EditorBrowsable(EditorBrowsableState.Advanced)]
2464 public void PerformLayout() {
2465 PerformLayout(null, null);
2468 [EditorBrowsable(EditorBrowsableState.Advanced)]
2469 public void PerformLayout(Control affectedControl, string affectedProperty) {
2470 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2472 if (layout_suspended > 0) {
2473 layout_pending = true;
2477 layout_pending = false;
2479 // Prevent us from getting messed up
2482 // Perform all Dock and Anchor calculations
2485 AnchorStyles anchor;
2488 space=this.DisplayRectangle;
2490 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2491 Control [] controls = child_controls.GetAllControls ();
2492 for (int i = controls.Length - 1; i >= 0; i--) {
2493 child = controls [i];
2494 switch (child.Dock) {
2495 case DockStyle.None: {
2500 case DockStyle.Left: {
2501 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2502 space.X+=child.Width;
2503 space.Width-=child.Width;
2507 case DockStyle.Top: {
2508 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2509 space.Y+=child.Height;
2510 space.Height-=child.Height;
2514 case DockStyle.Right: {
2515 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2516 space.Width-=child.Width;
2520 case DockStyle.Bottom: {
2521 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2522 space.Height-=child.Height;
2528 for (int i = controls.Length - 1; i >= 0; i--) {
2531 if (child.Dock == DockStyle.Fill) {
2532 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2538 space=this.DisplayRectangle;
2540 for (int i=0; i < controls.Length; i++) {
2546 child = controls[i];
2547 anchor = child.Anchor;
2551 width = child.Width;
2552 height = child.Height;
2554 // If the control is docked we don't need to do anything
2555 if (child.Dock != DockStyle.None) {
2559 if ((anchor & AnchorStyles.Left) !=0 ) {
2560 if ((anchor & AnchorStyles.Right) != 0) {
2561 width = client_size.Width - child.dist_right - left;
2563 ; // Left anchored only, nothing to be done
2565 } else if ((anchor & AnchorStyles.Right) != 0) {
2566 left = client_size.Width - child.dist_right - width;
2568 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
2569 // This calculates from scratch every time:
2570 left = child.dist_left + (client_size.Width - (child.dist_left + width + child.dist_right)) / 2;
2573 if ((anchor & AnchorStyles.Top) !=0 ) {
2574 if ((anchor & AnchorStyles.Bottom) != 0) {
2575 height = client_size.Height - child.dist_bottom - top;
2577 ; // Top anchored only, nothing to be done
2579 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2580 top = client_size.Height - child.dist_bottom - height;
2582 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
2583 // This calculates from scratch every time:
2584 top = child.dist_top + (client_size.Height - (child.dist_top + height + child.dist_bottom)) / 2;
2596 child.SetBounds(left, top, width, height);
2599 // Let everyone know
2603 // Need to make sure we decremend layout_suspended
2609 public Point PointToClient (Point p) {
2613 XplatUI.ScreenToClient (Handle, ref x, ref y);
2615 return new Point (x, y);
2618 public Point PointToScreen(Point p) {
2622 XplatUI.ClientToScreen(Handle, ref x, ref y);
2624 return new Point(x, y);
2627 public virtual bool PreProcessMessage(ref Message msg) {
2630 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
2631 key_data = (Keys)msg.WParam.ToInt32();
2632 if (!ProcessCmdKey(ref msg, key_data)) {
2633 if (IsInputKey(key_data)) {
2637 return ProcessDialogKey(key_data);
2641 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2642 if (IsInputChar((char)msg.WParam)) {
2645 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
2646 if (IsInputChar((char)msg.WParam)) {
2649 return ProcessDialogChar((char)msg.WParam);
2654 public Rectangle RectangleToClient(Rectangle r) {
2655 return new Rectangle(PointToClient(r.Location), r.Size);
2658 public Rectangle RectangleToScreen(Rectangle r) {
2659 return new Rectangle(PointToScreen(r.Location), r.Size);
2662 public virtual void Refresh() {
2663 if (IsHandleCreated == true) {
2666 XplatUI.UpdateWindow(window.Handle);
2668 Control [] controls = child_controls.GetAllControls ();
2669 for (int i=0; i < controls.Length; i++) {
2670 controls[i].Refresh();
2676 [EditorBrowsable(EditorBrowsableState.Never)]
2677 public virtual void ResetBackColor() {
2678 background_color = Color.Empty;
2681 [EditorBrowsable(EditorBrowsableState.Never)]
2683 public void ResetBindings() {
2687 [EditorBrowsable(EditorBrowsableState.Never)]
2688 public virtual void ResetCursor() {
2692 [EditorBrowsable(EditorBrowsableState.Never)]
2693 public virtual void ResetFont() {
2697 [EditorBrowsable(EditorBrowsableState.Never)]
2698 public virtual void ResetForeColor() {
2699 foreground_color = Color.Empty;
2702 [EditorBrowsable(EditorBrowsableState.Never)]
2703 public void ResetImeMode() {
2704 ime_mode = DefaultImeMode;
2707 [EditorBrowsable(EditorBrowsableState.Never)]
2708 public virtual void ResetRightToLeft() {
2709 right_to_left = RightToLeft.Inherit;
2712 public virtual void ResetText() {
2713 text = String.Empty;
2716 public void ResumeLayout() {
2717 ResumeLayout (true);
2720 public void ResumeLayout(bool performLayout) {
2723 if (layout_suspended > 0) {
2727 if (performLayout || layout_pending) {
2732 public void Scale(float ratio) {
2733 ScaleCore(ratio, ratio);
2736 public void Scale(float dx, float dy) {
2740 public void Select() {
2741 Select(false, false);
2744 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2749 c = GetNextControl(c, forward);
2758 if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
2762 } while (c != ctl); // If we wrap back to ourselves we stop
2767 public void SendToBack() {
2768 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2769 if (parent.child_controls.Contains(this)) {
2770 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2774 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2775 if (parent != null) {
2780 public void SetBounds(int x, int y, int width, int height) {
2781 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2784 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2785 SetBoundsCore(x, y, width, height, specified);
2788 public void Show() {
2789 if (!IsHandleCreated) {
2790 this.CreateControl();
2796 public void SuspendLayout() {
2800 public void Update() {
2801 needs_redraw = true;
2802 if (IsHandleCreated) {
2803 XplatUI.UpdateWindow(window.Handle);
2806 #endregion // Public Instance Methods
2808 #region Protected Instance Methods
2809 [EditorBrowsable(EditorBrowsableState.Advanced)]
2810 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2811 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2812 throw new NotImplementedException();
2815 [EditorBrowsable(EditorBrowsableState.Advanced)]
2816 protected virtual AccessibleObject CreateAccessibilityInstance() {
2817 return new Control.ControlAccessibleObject(this);
2820 [EditorBrowsable(EditorBrowsableState.Advanced)]
2821 protected virtual ControlCollection CreateControlsInstance() {
2822 return new ControlCollection(this);
2825 [EditorBrowsable(EditorBrowsableState.Advanced)]
2826 protected virtual void CreateHandle() {
2828 throw new ObjectDisposedException(Name);
2831 if (IsHandleCreated) {
2835 window.CreateHandle(CreateParams);
2837 // Find out where the window manager placed us
2839 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
2840 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
2844 if (window.Handle!=IntPtr.Zero) {
2845 if (!controls.Contains(window.Handle)) {
2849 creator_thread = Thread.CurrentThread;
2851 OnHandleCreated(EventArgs.Empty);
2855 [EditorBrowsable(EditorBrowsableState.Advanced)]
2856 protected virtual void DefWndProc(ref Message m) {
2857 window.DefWndProc(ref m);
2860 [EditorBrowsable(EditorBrowsableState.Advanced)]
2861 protected virtual void DestroyHandle() {
2862 if (IsHandleCreated) {
2863 // Destroy our children before we destroy ourselves, to prevent them from
2864 // being implictly (without us knowing) destroyed
2865 Control [] controls = child_controls.GetAllControls ();
2866 for (int i=0; i < controls.Length; i++) {
2867 controls[i].DestroyHandle();
2871 if (window != null) {
2872 window.DestroyHandle();
2874 OnHandleDestroyed(EventArgs.Empty);
2878 protected bool GetStyle(ControlStyles flag) {
2879 return (control_style & flag) != 0;
2882 protected bool GetTopLevel() {
2886 [EditorBrowsable(EditorBrowsableState.Advanced)]
2887 protected virtual void InitLayout() {
2888 dist_left = bounds.X;
2889 dist_top = bounds.Y;
2890 if (parent != null) {
2891 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
2892 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
2896 [EditorBrowsable(EditorBrowsableState.Advanced)]
2897 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2898 toInvoke.OnGotFocus(e);
2901 [EditorBrowsable(EditorBrowsableState.Advanced)]
2902 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2903 toInvoke.OnLostFocus(e);
2906 [EditorBrowsable(EditorBrowsableState.Advanced)]
2907 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2908 toInvoke.OnClick(e);
2911 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2912 toInvoke.OnPaint(e);
2915 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2916 toInvoke.OnPaintBackground(e);
2919 protected virtual bool IsInputChar (char charCode) {
2920 if (parent != null) {
2921 return parent.IsInputChar(charCode);
2927 protected virtual bool IsInputKey (Keys keyData) {
2928 // Doc says this one calls IsInputChar; not sure what to do with that
2932 [EditorBrowsable(EditorBrowsableState.Advanced)]
2933 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2937 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2938 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2942 if (parent != null) {
2943 return parent.ProcessCmdKey(ref msg, keyData);
2949 protected virtual bool ProcessDialogChar(char charCode) {
2950 if (parent != null) {
2951 return parent.ProcessDialogChar (charCode);
2957 protected virtual bool ProcessDialogKey (Keys keyData) {
2958 if (parent != null) {
2959 return parent.ProcessDialogKey (keyData);
2965 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2967 KeyEventArgs key_event;
2970 case (int)Msg.WM_KEYDOWN: {
2971 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2972 OnKeyDown (key_event);
2973 return key_event.Handled;
2975 case (int)Msg.WM_KEYUP: {
2976 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2977 OnKeyUp (key_event);
2978 return key_event.Handled;
2981 case (int)Msg.WM_CHAR: {
2982 KeyPressEventArgs key_press_event;
2984 key_press_event = new KeyPressEventArgs((char)msg.WParam);
2985 OnKeyPress(key_press_event);
2986 return key_press_event.Handled;
2997 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
2998 if (parent != null) {
2999 if (parent.ProcessKeyPreview(ref msg)) {
3007 protected virtual bool ProcessKeyPreview(ref Message msg) {
3008 if (parent != null) {
3009 return parent.ProcessKeyPreview(ref msg);
3015 protected virtual bool ProcessMnemonic(char charCode) {
3020 [EditorBrowsable(EditorBrowsableState.Advanced)]
3021 protected void RaiseDragEvent(object key, DragEventArgs e) {
3025 [EditorBrowsable(EditorBrowsableState.Advanced)]
3026 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3030 [EditorBrowsable(EditorBrowsableState.Advanced)]
3031 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3035 [EditorBrowsable(EditorBrowsableState.Advanced)]
3036 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3040 [EditorBrowsable(EditorBrowsableState.Advanced)]
3041 protected void RecreateHandle() {
3042 IEnumerator child = child_controls.GetAllEnumerator();
3046 if (IsHandleCreated) {
3052 while (child.MoveNext()) {
3053 ((Control)child.Current).RecreateHandle();
3059 is_recreating = false;
3062 [EditorBrowsable(EditorBrowsableState.Advanced)]
3063 protected void ResetMouseEventArgs() {
3067 [EditorBrowsable(EditorBrowsableState.Advanced)]
3068 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3069 if (right_to_left == RightToLeft.No) {
3074 case ContentAlignment.TopLeft: {
3075 return ContentAlignment.TopRight;
3078 case ContentAlignment.TopRight: {
3079 return ContentAlignment.TopLeft;
3082 case ContentAlignment.MiddleLeft: {
3083 return ContentAlignment.MiddleRight;
3086 case ContentAlignment.MiddleRight: {
3087 return ContentAlignment.MiddleLeft;
3090 case ContentAlignment.BottomLeft: {
3091 return ContentAlignment.BottomRight;
3094 case ContentAlignment.BottomRight: {
3095 return ContentAlignment.BottomLeft;
3099 // if it's center it doesn't change
3105 [EditorBrowsable(EditorBrowsableState.Advanced)]
3106 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3107 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3111 if (align == HorizontalAlignment.Left) {
3112 return HorizontalAlignment.Right;
3115 // align must be HorizontalAlignment.Right
3116 return HorizontalAlignment.Left;
3119 [EditorBrowsable(EditorBrowsableState.Advanced)]
3120 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3121 if (right_to_left == RightToLeft.No) {
3125 if (align == LeftRightAlignment.Left) {
3126 return LeftRightAlignment.Right;
3129 // align must be LeftRightAlignment.Right;
3130 return LeftRightAlignment.Left;
3133 [EditorBrowsable(EditorBrowsableState.Advanced)]
3134 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3135 return RtlTranslateAlignment(align);
3138 [EditorBrowsable(EditorBrowsableState.Advanced)]
3139 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3140 return RtlTranslateAlignment(align);
3143 [EditorBrowsable(EditorBrowsableState.Advanced)]
3144 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3145 return RtlTranslateAlignment(align);
3148 [EditorBrowsable(EditorBrowsableState.Advanced)]
3149 protected virtual void ScaleCore(float dx, float dy) {
3155 location = new Point((int)(Left * dx), (int)(Top * dy));
3156 size = this.ClientSize;
3159 if (!GetStyle(ControlStyles.FixedWidth)) {
3160 size.Width = (int)(size.Width * dx);
3163 if (!GetStyle(ControlStyles.FixedHeight)) {
3164 size.Height = (int)(size.Height * dy);
3167 Location = location;
3170 /* Now scale our children */
3171 Control [] controls = child_controls.GetAllControls ();
3172 for (int i=0; i < controls.Length; i++) {
3173 controls[i].Scale(dx, dy);
3179 protected virtual void Select(bool directed, bool forward) {
3184 // Select this control
3189 if (parent == null) {
3193 // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
3195 index = parent.child_controls.IndexOf(this);
3200 if ((index+1) < parent.child_controls.Count) {
3209 index = parent.child_controls.Count-1;
3212 result = Select(parent.child_controls[index]);
3213 } while (!result && parent.child_controls[index] != this);
3216 [EditorBrowsable(EditorBrowsableState.Advanced)]
3217 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3218 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3219 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3223 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3227 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3231 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3235 if (IsHandleCreated) {
3236 XplatUI.SetWindowPos(Handle, x, y, width, height);
3239 UpdateBounds(x, y, width, height);
3242 Control [] controls = child_controls.GetAllControls ();
3243 for (int i = controls.Length - 1; i >= 0; i--) {
3244 controls[i].InitLayout();
3248 [EditorBrowsable(EditorBrowsableState.Advanced)]
3249 protected virtual void SetClientSizeCore(int x, int y) {
3250 // Calculate the actual window size from the client size (it usually stays the same or grows)
3251 Rectangle ClientRect;
3252 Rectangle WindowRect;
3255 ClientRect = new Rectangle(0, 0, x, y);
3256 cp = this.CreateParams;
3258 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
3262 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3265 [EditorBrowsable(EditorBrowsableState.Advanced)]
3266 protected void SetStyle(ControlStyles flag, bool value) {
3268 control_style |= flag;
3270 control_style &= ~flag;
3272 OnStyleChanged(EventArgs.Empty);
3275 protected void SetTopLevel(bool value) {
3276 if ((GetTopLevel() != value) && (parent != null)) {
3277 throw new Exception();
3281 if (value == true) {
3291 is_toplevel = value;
3294 protected virtual void SetVisibleCore(bool value) {
3295 if (value!=is_visible) {
3298 if (IsHandleCreated) {
3299 XplatUI.SetVisible(Handle, value);
3300 // Explicitly move Toplevel windows to where we want them;
3301 // apparently moving unmapped toplevel windows doesn't work
3302 if (is_visible && (this is Form)) {
3303 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3307 OnVisibleChanged(EventArgs.Empty);
3310 if (dc_mem != null) {
3315 if (bmp_mem != null) {
3320 this.CreateBuffers(bounds.Width, bounds.Height);
3324 if (value == false && parent != null) {
3327 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3328 container = (Control)parent.GetContainerControl();
3329 if (container != null) {
3330 container.SelectNextControl(this, true, true, true, true);
3334 if (parent != null) {
3335 parent.PerformLayout(this, "visible");
3337 PerformLayout(this, "visible");
3342 [EditorBrowsable(EditorBrowsableState.Advanced)]
3343 protected void UpdateBounds() {
3351 if (!IsHandleCreated) {
3355 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3357 UpdateBounds(x, y, width, height, client_width, client_height);
3360 [EditorBrowsable(EditorBrowsableState.Advanced)]
3361 protected void UpdateBounds(int x, int y, int width, int height) {
3362 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3364 bool resized = false;
3366 int client_x_diff = this.bounds.Width-this.client_size.Width;
3367 int client_y_diff = this.bounds.Height-this.client_size.Height;
3369 // Needed to generate required notifications
3370 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3374 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3381 bounds.Height=height;
3383 // Update client rectangle as well
3384 client_size.Width=width-client_x_diff;
3385 client_size.Height=height-client_y_diff;
3388 OnLocationChanged(EventArgs.Empty);
3392 OnSizeChanged(EventArgs.Empty);
3396 [EditorBrowsable(EditorBrowsableState.Advanced)]
3397 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3398 UpdateBounds(x, y, width, height);
3400 this.client_size.Width=clientWidth;
3401 this.client_size.Height=clientHeight;
3404 [EditorBrowsable(EditorBrowsableState.Advanced)]
3405 protected void UpdateStyles() {
3406 if (!IsHandleCreated) {
3410 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3413 [EditorBrowsable(EditorBrowsableState.Advanced)]
3414 protected void UpdateZOrder() {
3415 Control [] controls;
3419 if (parent == null) {
3425 controls = ctl.child_controls.GetAllControls ();
3426 for (int i = 1; i < controls.Length; i++ ) {
3427 XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
3430 if (!IsHandleCreated) {
3434 controls = child_controls.GetAllControls ();
3435 for (int i = 1; i < controls.Length; i++ ) {
3436 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3441 protected virtual void WndProc(ref Message m) {
3443 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3445 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3449 switch((Msg)m.Msg) {
3450 case Msg.WM_WINDOWPOSCHANGED: {
3453 if (GetStyle(ControlStyles.ResizeRedraw)) {
3460 case Msg.WM_PAINT: {
3461 PaintEventArgs paint_event;
3463 paint_event = XplatUI.PaintEventStart(Handle, true);
3465 if (!needs_redraw) {
3466 // Just blit the previous image
3467 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3468 XplatUI.PaintEventEnd(Handle, true);
3473 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3474 dc = paint_event.SetGraphics (DeviceContext);
3477 if ((control_style & (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) != (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
3478 OnPaintBackground(paint_event);
3481 OnPaint(paint_event);
3483 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3484 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3485 paint_event.SetGraphics (dc);
3486 needs_redraw = false;
3489 XplatUI.PaintEventEnd(Handle, true);
3491 if (!GetStyle(ControlStyles.UserPaint)) {
3498 case Msg.WM_ERASEBKGND: {
3499 if (GetStyle (ControlStyles.UserPaint)) {
3500 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3501 PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
3502 Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
3503 OnPaintBackground (eraseEventArgs);
3506 // The DefWndProc will never have to handle this, we don't ever set hbr on the window
3507 m.Result = (IntPtr)1;
3511 case Msg.WM_LBUTTONUP: {
3512 HandleClick(mouse_clicks);
3513 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3515 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3517 if (mouse_clicks > 1) {
3523 case Msg.WM_LBUTTONDOWN: {
3524 if (CanSelect && !is_selected) {
3527 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3528 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3534 case Msg.WM_LBUTTONDBLCLK: {
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_MBUTTONUP: {
3544 HandleClick(mouse_clicks);
3545 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3547 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3549 if (mouse_clicks > 1) {
3555 case Msg.WM_MBUTTONDOWN: {
3556 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3557 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3563 case Msg.WM_MBUTTONDBLCLK: {
3565 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3566 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3571 case Msg.WM_RBUTTONUP: {
3572 if (context_menu != null) {
3573 context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
3576 HandleClick(mouse_clicks);
3577 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3579 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3581 if (mouse_clicks > 1) {
3587 case Msg.WM_RBUTTONDOWN: {
3588 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3589 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3594 case Msg.WM_RBUTTONDBLCLK: {
3596 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3597 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3602 case Msg.WM_MOUSEWHEEL: {
3604 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3605 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3606 HighOrder(m.WParam.ToInt32())));
3611 case Msg.WM_MOUSEMOVE: {
3612 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3614 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3619 case Msg.WM_MOUSE_ENTER: {
3624 OnMouseEnter(EventArgs.Empty);
3628 case Msg.WM_MOUSE_LEAVE: {
3630 OnMouseLeave(EventArgs.Empty);
3634 case Msg.WM_MOUSEHOVER: {
3635 OnMouseHover(EventArgs.Empty);
3639 case Msg.WM_SYSKEYDOWN:
3640 case Msg.WM_KEYDOWN:
3641 case Msg.WM_SYSKEYUP:
3643 case Msg.WM_SYSCHAR:
3645 Console.WriteLine("Got {0}", (Msg)m.Msg);
3646 if (ProcessKeyEventArgs(ref m)) {
3650 if (PreProcessMessage(ref m)) {
3654 if (ProcessKeyMessage(ref m)) {
3663 if (m.LParam != IntPtr.Zero) {
3666 hi = new HELPINFO();
3668 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3669 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3671 mouse_pos = Control.MousePosition;
3673 OnHelpRequested(new HelpEventArgs(mouse_pos));
3674 m.Result = (IntPtr)1;
3678 case Msg.WM_KILLFOCUS: {
3679 OnLeave(EventArgs.Empty);
3680 if (CausesValidation) {
3682 e = new CancelEventArgs(false);
3691 OnValidated(EventArgs.Empty);
3694 this.has_focus = false;
3695 this.is_selected = false;
3696 OnLostFocus(EventArgs.Empty);
3700 case Msg.WM_SETFOCUS: {
3701 OnEnter(EventArgs.Empty);
3702 this.has_focus = true;
3703 OnGotFocus(EventArgs.Empty);
3708 case Msg.WM_SYSCOLORCHANGE: {
3709 ThemeEngine.Current.ResetDefaults();
3710 OnSystemColorsChanged(EventArgs.Empty);
3715 case Msg.WM_SETCURSOR: {
3716 if (cursor == null) {
3721 XplatUI.SetCursor(window.Handle, cursor.handle);
3722 m.Result = (IntPtr)1;
3733 #endregion // Public Instance Methods
3735 #region OnXXX methods
3736 [EditorBrowsable(EditorBrowsableState.Advanced)]
3737 protected virtual void OnBackColorChanged(EventArgs e) {
3738 if (BackColorChanged!=null) BackColorChanged(this, e);
3739 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3742 [EditorBrowsable(EditorBrowsableState.Advanced)]
3743 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3744 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3745 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3748 [EditorBrowsable(EditorBrowsableState.Advanced)]
3749 protected virtual void OnBindingContextChanged(EventArgs e) {
3750 CheckDataBindings ();
3751 if (BindingContextChanged!=null) {
3752 BindingContextChanged(this, e);
3754 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3757 [EditorBrowsable(EditorBrowsableState.Advanced)]
3758 protected virtual void OnCausesValidationChanged(EventArgs e) {
3759 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3762 [EditorBrowsable(EditorBrowsableState.Advanced)]
3763 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3764 if (ChangeUICues!=null) ChangeUICues(this, e);
3767 [EditorBrowsable(EditorBrowsableState.Advanced)]
3768 protected virtual void OnClick(EventArgs e) {
3769 if (Click!=null) Click(this, e);
3772 [EditorBrowsable(EditorBrowsableState.Advanced)]
3773 protected virtual void OnContextMenuChanged(EventArgs e) {
3774 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3777 [EditorBrowsable(EditorBrowsableState.Advanced)]
3778 protected virtual void OnControlAdded(ControlEventArgs e) {
3779 if (ControlAdded!=null) ControlAdded(this, e);
3782 [EditorBrowsable(EditorBrowsableState.Advanced)]
3783 protected virtual void OnControlRemoved(ControlEventArgs e) {
3784 if (ControlRemoved!=null) ControlRemoved(this, e);
3787 [EditorBrowsable(EditorBrowsableState.Advanced)]
3788 protected virtual void OnCreateControl() {
3792 [EditorBrowsable(EditorBrowsableState.Advanced)]
3793 protected virtual void OnCursorChanged(EventArgs e) {
3794 if (CursorChanged!=null) CursorChanged(this, e);
3797 [EditorBrowsable(EditorBrowsableState.Advanced)]
3798 protected virtual void OnDockChanged(EventArgs e) {
3799 if (DockChanged!=null) DockChanged(this, e);
3802 [EditorBrowsable(EditorBrowsableState.Advanced)]
3803 protected virtual void OnDoubleClick(EventArgs e) {
3804 if (DoubleClick!=null) DoubleClick(this, e);
3807 [EditorBrowsable(EditorBrowsableState.Advanced)]
3808 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3809 if (DragDrop!=null) DragDrop(this, drgevent);
3812 [EditorBrowsable(EditorBrowsableState.Advanced)]
3813 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3814 if (DragEnter!=null) DragEnter(this, drgevent);
3817 [EditorBrowsable(EditorBrowsableState.Advanced)]
3818 protected virtual void OnDragLeave(EventArgs e) {
3819 if (DragLeave!=null) DragLeave(this, e);
3822 [EditorBrowsable(EditorBrowsableState.Advanced)]
3823 protected virtual void OnDragOver(DragEventArgs drgevent) {
3824 if (DragOver!=null) DragOver(this, drgevent);
3827 [EditorBrowsable(EditorBrowsableState.Advanced)]
3828 protected virtual void OnEnabledChanged(EventArgs e) {
3829 if (EnabledChanged!=null) EnabledChanged(this, e);
3830 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3833 [EditorBrowsable(EditorBrowsableState.Advanced)]
3834 protected virtual void OnEnter(EventArgs e) {
3835 if (Enter!=null) Enter(this, e);
3838 [EditorBrowsable(EditorBrowsableState.Advanced)]
3839 protected virtual void OnFontChanged(EventArgs e) {
3840 if (FontChanged!=null) FontChanged(this, e);
3841 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3844 [EditorBrowsable(EditorBrowsableState.Advanced)]
3845 protected virtual void OnForeColorChanged(EventArgs e) {
3846 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3847 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3850 [EditorBrowsable(EditorBrowsableState.Advanced)]
3851 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3852 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3855 [EditorBrowsable(EditorBrowsableState.Advanced)]
3856 protected virtual void OnGotFocus(EventArgs e) {
3857 if (GotFocus!=null) GotFocus(this, e);
3860 [EditorBrowsable(EditorBrowsableState.Advanced)]
3861 protected virtual void OnHandleCreated(EventArgs e) {
3862 if (HandleCreated!=null) HandleCreated(this, e);
3865 [EditorBrowsable(EditorBrowsableState.Advanced)]
3866 protected virtual void OnHandleDestroyed(EventArgs e) {
3867 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3870 [EditorBrowsable(EditorBrowsableState.Advanced)]
3871 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3872 if (HelpRequested!=null) HelpRequested(this, hevent);
3875 protected virtual void OnImeModeChanged(EventArgs e) {
3876 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3879 [EditorBrowsable(EditorBrowsableState.Advanced)]
3880 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3881 needs_redraw = true;
3882 if (Invalidated!=null) Invalidated(this, e);
3885 [EditorBrowsable(EditorBrowsableState.Advanced)]
3886 protected virtual void OnKeyDown(KeyEventArgs e) {
3887 if (KeyDown!=null) KeyDown(this, e);
3890 [EditorBrowsable(EditorBrowsableState.Advanced)]
3891 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3892 if (KeyPress!=null) KeyPress(this, e);
3895 [EditorBrowsable(EditorBrowsableState.Advanced)]
3896 protected virtual void OnKeyUp(KeyEventArgs e) {
3897 if (KeyUp!=null) KeyUp(this, e);
3900 [EditorBrowsable(EditorBrowsableState.Advanced)]
3901 protected virtual void OnLayout(LayoutEventArgs levent) {
3902 if (Layout!=null) Layout(this, levent);
3905 [EditorBrowsable(EditorBrowsableState.Advanced)]
3906 protected virtual void OnLeave(EventArgs e) {
3907 if (Leave!=null) Leave(this, e);
3910 [EditorBrowsable(EditorBrowsableState.Advanced)]
3911 protected virtual void OnLocationChanged(EventArgs e) {
3913 if (LocationChanged!=null) LocationChanged(this, e);
3916 [EditorBrowsable(EditorBrowsableState.Advanced)]
3917 protected virtual void OnLostFocus(EventArgs e) {
3918 if (LostFocus!=null) LostFocus(this, e);
3921 [EditorBrowsable(EditorBrowsableState.Advanced)]
3922 protected virtual void OnMouseDown(MouseEventArgs e) {
3923 if (MouseDown!=null) MouseDown(this, e);
3926 [EditorBrowsable(EditorBrowsableState.Advanced)]
3927 protected virtual void OnMouseEnter(EventArgs e) {
3928 if (MouseEnter!=null) MouseEnter(this, e);
3931 [EditorBrowsable(EditorBrowsableState.Advanced)]
3932 protected virtual void OnMouseHover(EventArgs e) {
3933 if (MouseHover!=null) MouseHover(this, e);
3936 [EditorBrowsable(EditorBrowsableState.Advanced)]
3937 protected virtual void OnMouseLeave(EventArgs e) {
3938 if (MouseLeave!=null) MouseLeave(this, e);
3941 [EditorBrowsable(EditorBrowsableState.Advanced)]
3942 protected virtual void OnMouseMove(MouseEventArgs e) {
3943 if (MouseMove!=null) MouseMove(this, e);
3946 [EditorBrowsable(EditorBrowsableState.Advanced)]
3947 protected virtual void OnMouseUp(MouseEventArgs e) {
3948 if (MouseUp!=null) MouseUp(this, e);
3951 [EditorBrowsable(EditorBrowsableState.Advanced)]
3952 protected virtual void OnMouseWheel(MouseEventArgs e) {
3953 if (MouseWheel!=null) MouseWheel(this, e);
3956 [EditorBrowsable(EditorBrowsableState.Advanced)]
3957 protected virtual void OnMove(EventArgs e) {
3958 if (Move!=null) Move(this, e);
3961 [EditorBrowsable(EditorBrowsableState.Advanced)]
3962 protected virtual void OnNotifyMessage(Message m) {
3966 [EditorBrowsable(EditorBrowsableState.Advanced)]
3967 protected virtual void OnPaint(PaintEventArgs e) {
3968 if (Paint!=null) Paint(this, e);
3971 [EditorBrowsable(EditorBrowsableState.Advanced)]
3972 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3973 PaintControlBackground (pevent);
3976 [EditorBrowsable(EditorBrowsableState.Advanced)]
3977 protected virtual void OnParentBackColorChanged(EventArgs e) {
3978 if (background_color.IsEmpty && background_image==null) {
3980 OnBackColorChanged(e);
3984 [EditorBrowsable(EditorBrowsableState.Advanced)]
3985 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3986 if (background_color.IsEmpty && background_image==null) {
3988 OnBackgroundImageChanged(e);
3992 [EditorBrowsable(EditorBrowsableState.Advanced)]
3993 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3994 if (binding_context==null) {
3995 binding_context=Parent.binding_context;
3996 OnBindingContextChanged(e);
4000 [EditorBrowsable(EditorBrowsableState.Advanced)]
4001 protected virtual void OnParentChanged(EventArgs e) {
4002 if (ParentChanged!=null) ParentChanged(this, e);
4005 [EditorBrowsable(EditorBrowsableState.Advanced)]
4006 protected virtual void OnParentEnabledChanged(EventArgs e) {
4007 if (is_enabled != Parent.is_enabled) {
4008 is_enabled=Parent.is_enabled;
4010 if (EnabledChanged != null) {
4011 EnabledChanged(this, e);
4016 [EditorBrowsable(EditorBrowsableState.Advanced)]
4017 protected virtual void OnParentFontChanged(EventArgs e) {
4024 [EditorBrowsable(EditorBrowsableState.Advanced)]
4025 protected virtual void OnParentForeColorChanged(EventArgs e) {
4026 if (foreground_color.IsEmpty) {
4028 OnForeColorChanged(e);
4032 [EditorBrowsable(EditorBrowsableState.Advanced)]
4033 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4034 if (right_to_left==RightToLeft.Inherit) {
4036 OnRightToLeftChanged(e);
4040 [EditorBrowsable(EditorBrowsableState.Advanced)]
4041 protected virtual void OnParentVisibleChanged(EventArgs e) {
4043 OnVisibleChanged(e);
4047 [EditorBrowsable(EditorBrowsableState.Advanced)]
4048 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4049 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
4052 [EditorBrowsable(EditorBrowsableState.Advanced)]
4053 protected virtual void OnResize(EventArgs e) {
4054 if (Resize!=null) Resize(this, e);
4056 PerformLayout(this, "bounds");
4058 if (parent != null) {
4059 parent.PerformLayout();
4063 [EditorBrowsable(EditorBrowsableState.Advanced)]
4064 protected virtual void OnRightToLeftChanged(EventArgs e) {
4065 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
4066 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4069 [EditorBrowsable(EditorBrowsableState.Advanced)]
4070 protected virtual void OnSizeChanged(EventArgs e) {
4071 InvalidateBuffers ();
4073 if (SizeChanged!=null) SizeChanged(this, e);
4076 [EditorBrowsable(EditorBrowsableState.Advanced)]
4077 protected virtual void OnStyleChanged(EventArgs e) {
4078 if (StyleChanged!=null) StyleChanged(this, e);
4081 [EditorBrowsable(EditorBrowsableState.Advanced)]
4082 protected virtual void OnSystemColorsChanged(EventArgs e) {
4083 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
4086 [EditorBrowsable(EditorBrowsableState.Advanced)]
4087 protected virtual void OnTabIndexChanged(EventArgs e) {
4088 if (TabIndexChanged!=null) TabIndexChanged(this, e);
4091 [EditorBrowsable(EditorBrowsableState.Advanced)]
4092 protected virtual void OnTabStopChanged(EventArgs e) {
4093 if (TabStopChanged!=null) TabStopChanged(this, e);
4096 [EditorBrowsable(EditorBrowsableState.Advanced)]
4097 protected virtual void OnTextChanged(EventArgs e) {
4098 if (TextChanged!=null) TextChanged(this, e);
4101 [EditorBrowsable(EditorBrowsableState.Advanced)]
4102 protected virtual void OnValidated(EventArgs e) {
4103 if (Validated!=null) Validated(this, e);
4106 [EditorBrowsable(EditorBrowsableState.Advanced)]
4107 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4108 if (Validating!=null) Validating(this, e);
4111 [EditorBrowsable(EditorBrowsableState.Advanced)]
4112 protected virtual void OnVisibleChanged(EventArgs e) {
4119 if (bmp_mem!=null) {
4125 if (!this.IsHandleCreated) {
4126 this.CreateControl();
4132 if (VisibleChanged!=null) VisibleChanged(this, e);
4134 // We need to tell our kids
4135 for (int i=0; i<child_controls.Count; i++) {
4136 child_controls[i].OnParentVisibleChanged(e);
4139 #endregion // OnXXX methods
4142 public event EventHandler BackColorChanged;
4143 public event EventHandler BackgroundImageChanged;
4144 public event EventHandler BindingContextChanged;
4145 public event EventHandler CausesValidationChanged;
4146 public event UICuesEventHandler ChangeUICues;
4147 public event EventHandler Click;
4148 public event EventHandler ContextMenuChanged;
4150 [EditorBrowsable(EditorBrowsableState.Advanced)]
4152 public event ControlEventHandler ControlAdded;
4154 [EditorBrowsable(EditorBrowsableState.Advanced)]
4156 public event ControlEventHandler ControlRemoved;
4158 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4159 public event EventHandler CursorChanged;
4160 public event EventHandler DockChanged;
4161 public event EventHandler DoubleClick;
4162 public event DragEventHandler DragDrop;
4163 public event DragEventHandler DragEnter;
4164 public event EventHandler DragLeave;
4165 public event DragEventHandler DragOver;
4166 public event EventHandler EnabledChanged;
4167 public event EventHandler Enter;
4168 public event EventHandler FontChanged;
4169 public event EventHandler ForeColorChanged;
4170 public event GiveFeedbackEventHandler GiveFeedback;
4172 [EditorBrowsable(EditorBrowsableState.Advanced)]
4174 public event EventHandler GotFocus;
4176 [EditorBrowsable(EditorBrowsableState.Advanced)]
4178 public event EventHandler HandleCreated;
4180 [EditorBrowsable(EditorBrowsableState.Advanced)]
4182 public event EventHandler HandleDestroyed;
4184 public event HelpEventHandler HelpRequested;
4185 public event EventHandler ImeModeChanged;
4187 [EditorBrowsable(EditorBrowsableState.Advanced)]
4189 public event InvalidateEventHandler Invalidated;
4191 public event KeyEventHandler KeyDown;
4192 public event KeyPressEventHandler KeyPress;
4193 public event KeyEventHandler KeyUp;
4194 public event LayoutEventHandler Layout;
4195 public event EventHandler Leave;
4196 public event EventHandler LocationChanged;
4198 [EditorBrowsable(EditorBrowsableState.Advanced)]
4200 public event EventHandler LostFocus;
4202 public event MouseEventHandler MouseDown;
4203 public event EventHandler MouseEnter;
4204 public event EventHandler MouseHover;
4205 public event EventHandler MouseLeave;
4206 public event MouseEventHandler MouseMove;
4207 public event MouseEventHandler MouseUp;
4209 [EditorBrowsable(EditorBrowsableState.Advanced)]
4211 public event MouseEventHandler MouseWheel;
4213 public event EventHandler Move;
4214 public event PaintEventHandler Paint;
4215 public event EventHandler ParentChanged;
4216 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
4217 public event QueryContinueDragEventHandler QueryContinueDrag;
4218 public event EventHandler Resize;
4219 public event EventHandler RightToLeftChanged;
4220 public event EventHandler SizeChanged;
4221 public event EventHandler StyleChanged;
4222 public event EventHandler SystemColorsChanged;
4223 public event EventHandler TabIndexChanged;
4224 public event EventHandler TabStopChanged;
4225 public event EventHandler TextChanged;
4226 public event EventHandler Validated;
4227 public event CancelEventHandler Validating;
4228 public event EventHandler VisibleChanged;
4229 #endregion // Events