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 [EditorBrowsable(EditorBrowsableState.Advanced)]
3243 protected virtual void SetClientSizeCore(int x, int y) {
3244 // Calculate the actual window size from the client size (it usually stays the same or grows)
3245 Rectangle ClientRect;
3246 Rectangle WindowRect;
3249 ClientRect = new Rectangle(0, 0, x, y);
3250 cp = this.CreateParams;
3252 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
3256 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3259 [EditorBrowsable(EditorBrowsableState.Advanced)]
3260 protected void SetStyle(ControlStyles flag, bool value) {
3262 control_style |= flag;
3264 control_style &= ~flag;
3266 OnStyleChanged(EventArgs.Empty);
3269 protected void SetTopLevel(bool value) {
3270 if ((GetTopLevel() != value) && (parent != null)) {
3271 throw new Exception();
3275 if (value == true) {
3285 is_toplevel = value;
3288 protected virtual void SetVisibleCore(bool value) {
3289 if (value!=is_visible) {
3292 if (IsHandleCreated) {
3293 XplatUI.SetVisible(Handle, value);
3294 // Explicitly move Toplevel windows to where we want them;
3295 // apparently moving unmapped toplevel windows doesn't work
3296 if (is_visible && (this is Form)) {
3297 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3301 OnVisibleChanged(EventArgs.Empty);
3304 if (dc_mem != null) {
3309 if (bmp_mem != null) {
3314 this.CreateBuffers(bounds.Width, bounds.Height);
3318 if (value == false && parent != null) {
3321 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3322 container = (Control)parent.GetContainerControl();
3323 if (container != null) {
3324 container.SelectNextControl(this, true, true, true, true);
3328 if (parent != null) {
3329 parent.PerformLayout(this, "visible");
3331 PerformLayout(this, "visible");
3336 [EditorBrowsable(EditorBrowsableState.Advanced)]
3337 protected void UpdateBounds() {
3345 if (!IsHandleCreated) {
3349 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3351 UpdateBounds(x, y, width, height, client_width, client_height);
3354 [EditorBrowsable(EditorBrowsableState.Advanced)]
3355 protected void UpdateBounds(int x, int y, int width, int height) {
3356 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3358 bool resized = false;
3360 int client_x_diff = this.bounds.Width-this.client_size.Width;
3361 int client_y_diff = this.bounds.Height-this.client_size.Height;
3363 // Needed to generate required notifications
3364 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3368 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3375 bounds.Height=height;
3377 // Update client rectangle as well
3378 client_size.Width=width-client_x_diff;
3379 client_size.Height=height-client_y_diff;
3382 OnLocationChanged(EventArgs.Empty);
3386 OnSizeChanged(EventArgs.Empty);
3390 [EditorBrowsable(EditorBrowsableState.Advanced)]
3391 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3392 UpdateBounds(x, y, width, height);
3394 this.client_size.Width=clientWidth;
3395 this.client_size.Height=clientHeight;
3398 [EditorBrowsable(EditorBrowsableState.Advanced)]
3399 protected void UpdateStyles() {
3400 if (!IsHandleCreated) {
3404 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3407 [EditorBrowsable(EditorBrowsableState.Advanced)]
3408 protected void UpdateZOrder() {
3409 Control [] controls;
3413 if (parent == null) {
3419 controls = ctl.child_controls.GetAllControls ();
3420 for (int i = 1; i < controls.Length; i++ ) {
3421 XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
3424 if (!IsHandleCreated) {
3428 controls = child_controls.GetAllControls ();
3429 for (int i = 1; i < controls.Length; i++ ) {
3430 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3435 protected virtual void WndProc(ref Message m) {
3437 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3439 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3443 switch((Msg)m.Msg) {
3444 case Msg.WM_WINDOWPOSCHANGED: {
3447 if (GetStyle(ControlStyles.ResizeRedraw)) {
3454 case Msg.WM_PAINT: {
3455 PaintEventArgs paint_event;
3457 paint_event = XplatUI.PaintEventStart(Handle, true);
3459 if (!needs_redraw) {
3460 // Just blit the previous image
3461 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3462 XplatUI.PaintEventEnd(Handle, true);
3467 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3468 dc = paint_event.SetGraphics (DeviceContext);
3471 if ((control_style & (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) != (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
3472 OnPaintBackground(paint_event);
3475 OnPaint(paint_event);
3477 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3478 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3479 paint_event.SetGraphics (dc);
3480 needs_redraw = false;
3483 XplatUI.PaintEventEnd(Handle, true);
3485 if (!GetStyle(ControlStyles.UserPaint)) {
3492 case Msg.WM_ERASEBKGND: {
3493 if (GetStyle (ControlStyles.UserPaint)) {
3494 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3495 PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
3496 Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
3497 OnPaintBackground (eraseEventArgs);
3500 // The DefWndProc will never have to handle this, we don't ever set hbr on the window
3501 m.Result = (IntPtr)1;
3505 case Msg.WM_LBUTTONUP: {
3506 HandleClick(mouse_clicks);
3507 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3509 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3511 if (mouse_clicks > 1) {
3517 case Msg.WM_LBUTTONDOWN: {
3518 if (CanSelect && !is_selected) {
3521 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3522 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3528 case Msg.WM_LBUTTONDBLCLK: {
3530 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3531 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3537 case Msg.WM_MBUTTONUP: {
3538 HandleClick(mouse_clicks);
3539 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3541 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3543 if (mouse_clicks > 1) {
3549 case Msg.WM_MBUTTONDOWN: {
3550 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3551 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3557 case Msg.WM_MBUTTONDBLCLK: {
3559 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3560 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3565 case Msg.WM_RBUTTONUP: {
3566 if (context_menu != null) {
3567 context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
3570 HandleClick(mouse_clicks);
3571 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3573 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3575 if (mouse_clicks > 1) {
3581 case Msg.WM_RBUTTONDOWN: {
3582 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3583 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3588 case Msg.WM_RBUTTONDBLCLK: {
3590 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3591 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3596 case Msg.WM_MOUSEWHEEL: {
3598 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3599 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3600 HighOrder(m.WParam.ToInt32())));
3605 case Msg.WM_MOUSEMOVE: {
3606 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3608 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3613 case Msg.WM_MOUSE_ENTER: {
3618 OnMouseEnter(EventArgs.Empty);
3622 case Msg.WM_MOUSE_LEAVE: {
3624 OnMouseLeave(EventArgs.Empty);
3628 case Msg.WM_MOUSEHOVER: {
3629 OnMouseHover(EventArgs.Empty);
3633 case Msg.WM_SYSKEYDOWN:
3634 case Msg.WM_KEYDOWN:
3635 case Msg.WM_SYSKEYUP:
3637 case Msg.WM_SYSCHAR:
3639 Console.WriteLine("Got {0}", (Msg)m.Msg);
3640 if (ProcessKeyEventArgs(ref m)) {
3644 if (PreProcessMessage(ref m)) {
3648 if (ProcessKeyMessage(ref m)) {
3657 if (m.LParam != IntPtr.Zero) {
3660 hi = new HELPINFO();
3662 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3663 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3665 mouse_pos = Control.MousePosition;
3667 OnHelpRequested(new HelpEventArgs(mouse_pos));
3668 m.Result = (IntPtr)1;
3672 case Msg.WM_KILLFOCUS: {
3673 OnLeave(EventArgs.Empty);
3674 if (CausesValidation) {
3676 e = new CancelEventArgs(false);
3685 OnValidated(EventArgs.Empty);
3688 this.has_focus = false;
3689 this.is_selected = false;
3690 OnLostFocus(EventArgs.Empty);
3694 case Msg.WM_SETFOCUS: {
3695 OnEnter(EventArgs.Empty);
3696 this.has_focus = true;
3697 OnGotFocus(EventArgs.Empty);
3702 case Msg.WM_SYSCOLORCHANGE: {
3703 ThemeEngine.Current.ResetDefaults();
3704 OnSystemColorsChanged(EventArgs.Empty);
3709 case Msg.WM_SETCURSOR: {
3710 if (cursor == null) {
3715 XplatUI.SetCursor(window.Handle, cursor.handle);
3716 m.Result = (IntPtr)1;
3727 #endregion // Public Instance Methods
3729 #region OnXXX methods
3730 [EditorBrowsable(EditorBrowsableState.Advanced)]
3731 protected virtual void OnBackColorChanged(EventArgs e) {
3732 if (BackColorChanged!=null) BackColorChanged(this, e);
3733 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3736 [EditorBrowsable(EditorBrowsableState.Advanced)]
3737 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3738 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3739 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3742 [EditorBrowsable(EditorBrowsableState.Advanced)]
3743 protected virtual void OnBindingContextChanged(EventArgs e) {
3744 CheckDataBindings ();
3745 if (BindingContextChanged!=null) {
3746 BindingContextChanged(this, e);
3748 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3751 [EditorBrowsable(EditorBrowsableState.Advanced)]
3752 protected virtual void OnCausesValidationChanged(EventArgs e) {
3753 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3756 [EditorBrowsable(EditorBrowsableState.Advanced)]
3757 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3758 if (ChangeUICues!=null) ChangeUICues(this, e);
3761 [EditorBrowsable(EditorBrowsableState.Advanced)]
3762 protected virtual void OnClick(EventArgs e) {
3763 if (Click!=null) Click(this, e);
3766 [EditorBrowsable(EditorBrowsableState.Advanced)]
3767 protected virtual void OnContextMenuChanged(EventArgs e) {
3768 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3771 [EditorBrowsable(EditorBrowsableState.Advanced)]
3772 protected virtual void OnControlAdded(ControlEventArgs e) {
3773 if (ControlAdded!=null) ControlAdded(this, e);
3776 [EditorBrowsable(EditorBrowsableState.Advanced)]
3777 protected virtual void OnControlRemoved(ControlEventArgs e) {
3778 if (ControlRemoved!=null) ControlRemoved(this, e);
3781 [EditorBrowsable(EditorBrowsableState.Advanced)]
3782 protected virtual void OnCreateControl() {
3786 [EditorBrowsable(EditorBrowsableState.Advanced)]
3787 protected virtual void OnCursorChanged(EventArgs e) {
3788 if (CursorChanged!=null) CursorChanged(this, e);
3791 [EditorBrowsable(EditorBrowsableState.Advanced)]
3792 protected virtual void OnDockChanged(EventArgs e) {
3793 if (DockChanged!=null) DockChanged(this, e);
3796 [EditorBrowsable(EditorBrowsableState.Advanced)]
3797 protected virtual void OnDoubleClick(EventArgs e) {
3798 if (DoubleClick!=null) DoubleClick(this, e);
3801 [EditorBrowsable(EditorBrowsableState.Advanced)]
3802 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3803 if (DragDrop!=null) DragDrop(this, drgevent);
3806 [EditorBrowsable(EditorBrowsableState.Advanced)]
3807 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3808 if (DragEnter!=null) DragEnter(this, drgevent);
3811 [EditorBrowsable(EditorBrowsableState.Advanced)]
3812 protected virtual void OnDragLeave(EventArgs e) {
3813 if (DragLeave!=null) DragLeave(this, e);
3816 [EditorBrowsable(EditorBrowsableState.Advanced)]
3817 protected virtual void OnDragOver(DragEventArgs drgevent) {
3818 if (DragOver!=null) DragOver(this, drgevent);
3821 [EditorBrowsable(EditorBrowsableState.Advanced)]
3822 protected virtual void OnEnabledChanged(EventArgs e) {
3823 if (EnabledChanged!=null) EnabledChanged(this, e);
3824 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3827 [EditorBrowsable(EditorBrowsableState.Advanced)]
3828 protected virtual void OnEnter(EventArgs e) {
3829 if (Enter!=null) Enter(this, e);
3832 [EditorBrowsable(EditorBrowsableState.Advanced)]
3833 protected virtual void OnFontChanged(EventArgs e) {
3834 if (FontChanged!=null) FontChanged(this, e);
3835 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3838 [EditorBrowsable(EditorBrowsableState.Advanced)]
3839 protected virtual void OnForeColorChanged(EventArgs e) {
3840 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3841 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3844 [EditorBrowsable(EditorBrowsableState.Advanced)]
3845 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3846 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3849 [EditorBrowsable(EditorBrowsableState.Advanced)]
3850 protected virtual void OnGotFocus(EventArgs e) {
3851 if (GotFocus!=null) GotFocus(this, e);
3854 [EditorBrowsable(EditorBrowsableState.Advanced)]
3855 protected virtual void OnHandleCreated(EventArgs e) {
3856 if (HandleCreated!=null) HandleCreated(this, e);
3859 [EditorBrowsable(EditorBrowsableState.Advanced)]
3860 protected virtual void OnHandleDestroyed(EventArgs e) {
3861 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3864 [EditorBrowsable(EditorBrowsableState.Advanced)]
3865 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3866 if (HelpRequested!=null) HelpRequested(this, hevent);
3869 protected virtual void OnImeModeChanged(EventArgs e) {
3870 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3873 [EditorBrowsable(EditorBrowsableState.Advanced)]
3874 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3875 needs_redraw = true;
3876 if (Invalidated!=null) Invalidated(this, e);
3879 [EditorBrowsable(EditorBrowsableState.Advanced)]
3880 protected virtual void OnKeyDown(KeyEventArgs e) {
3881 if (KeyDown!=null) KeyDown(this, e);
3884 [EditorBrowsable(EditorBrowsableState.Advanced)]
3885 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3886 if (KeyPress!=null) KeyPress(this, e);
3889 [EditorBrowsable(EditorBrowsableState.Advanced)]
3890 protected virtual void OnKeyUp(KeyEventArgs e) {
3891 if (KeyUp!=null) KeyUp(this, e);
3894 [EditorBrowsable(EditorBrowsableState.Advanced)]
3895 protected virtual void OnLayout(LayoutEventArgs levent) {
3896 if (Layout!=null) Layout(this, levent);
3899 [EditorBrowsable(EditorBrowsableState.Advanced)]
3900 protected virtual void OnLeave(EventArgs e) {
3901 if (Leave!=null) Leave(this, e);
3904 [EditorBrowsable(EditorBrowsableState.Advanced)]
3905 protected virtual void OnLocationChanged(EventArgs e) {
3907 if (LocationChanged!=null) LocationChanged(this, e);
3910 [EditorBrowsable(EditorBrowsableState.Advanced)]
3911 protected virtual void OnLostFocus(EventArgs e) {
3912 if (LostFocus!=null) LostFocus(this, e);
3915 [EditorBrowsable(EditorBrowsableState.Advanced)]
3916 protected virtual void OnMouseDown(MouseEventArgs e) {
3917 if (MouseDown!=null) MouseDown(this, e);
3920 [EditorBrowsable(EditorBrowsableState.Advanced)]
3921 protected virtual void OnMouseEnter(EventArgs e) {
3922 if (MouseEnter!=null) MouseEnter(this, e);
3925 [EditorBrowsable(EditorBrowsableState.Advanced)]
3926 protected virtual void OnMouseHover(EventArgs e) {
3927 if (MouseHover!=null) MouseHover(this, e);
3930 [EditorBrowsable(EditorBrowsableState.Advanced)]
3931 protected virtual void OnMouseLeave(EventArgs e) {
3932 if (MouseLeave!=null) MouseLeave(this, e);
3935 [EditorBrowsable(EditorBrowsableState.Advanced)]
3936 protected virtual void OnMouseMove(MouseEventArgs e) {
3937 if (MouseMove!=null) MouseMove(this, e);
3940 [EditorBrowsable(EditorBrowsableState.Advanced)]
3941 protected virtual void OnMouseUp(MouseEventArgs e) {
3942 if (MouseUp!=null) MouseUp(this, e);
3945 [EditorBrowsable(EditorBrowsableState.Advanced)]
3946 protected virtual void OnMouseWheel(MouseEventArgs e) {
3947 if (MouseWheel!=null) MouseWheel(this, e);
3950 [EditorBrowsable(EditorBrowsableState.Advanced)]
3951 protected virtual void OnMove(EventArgs e) {
3952 if (Move!=null) Move(this, e);
3955 [EditorBrowsable(EditorBrowsableState.Advanced)]
3956 protected virtual void OnNotifyMessage(Message m) {
3960 [EditorBrowsable(EditorBrowsableState.Advanced)]
3961 protected virtual void OnPaint(PaintEventArgs e) {
3962 if (Paint!=null) Paint(this, e);
3965 [EditorBrowsable(EditorBrowsableState.Advanced)]
3966 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3967 PaintControlBackground (pevent);
3970 [EditorBrowsable(EditorBrowsableState.Advanced)]
3971 protected virtual void OnParentBackColorChanged(EventArgs e) {
3972 if (background_color.IsEmpty && background_image==null) {
3974 OnBackColorChanged(e);
3978 [EditorBrowsable(EditorBrowsableState.Advanced)]
3979 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3980 if (background_color.IsEmpty && background_image==null) {
3982 OnBackgroundImageChanged(e);
3986 [EditorBrowsable(EditorBrowsableState.Advanced)]
3987 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3988 if (binding_context==null) {
3989 binding_context=Parent.binding_context;
3990 OnBindingContextChanged(e);
3994 [EditorBrowsable(EditorBrowsableState.Advanced)]
3995 protected virtual void OnParentChanged(EventArgs e) {
3996 if (ParentChanged!=null) ParentChanged(this, e);
3999 [EditorBrowsable(EditorBrowsableState.Advanced)]
4000 protected virtual void OnParentEnabledChanged(EventArgs e) {
4001 if (is_enabled != Parent.is_enabled) {
4002 is_enabled=Parent.is_enabled;
4004 if (EnabledChanged != null) {
4005 EnabledChanged(this, e);
4010 [EditorBrowsable(EditorBrowsableState.Advanced)]
4011 protected virtual void OnParentFontChanged(EventArgs e) {
4018 [EditorBrowsable(EditorBrowsableState.Advanced)]
4019 protected virtual void OnParentForeColorChanged(EventArgs e) {
4020 if (foreground_color.IsEmpty) {
4022 OnForeColorChanged(e);
4026 [EditorBrowsable(EditorBrowsableState.Advanced)]
4027 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4028 if (right_to_left==RightToLeft.Inherit) {
4030 OnRightToLeftChanged(e);
4034 [EditorBrowsable(EditorBrowsableState.Advanced)]
4035 protected virtual void OnParentVisibleChanged(EventArgs e) {
4037 OnVisibleChanged(e);
4041 [EditorBrowsable(EditorBrowsableState.Advanced)]
4042 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4043 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
4046 [EditorBrowsable(EditorBrowsableState.Advanced)]
4047 protected virtual void OnResize(EventArgs e) {
4048 if (Resize!=null) Resize(this, e);
4050 PerformLayout(this, "bounds");
4052 if (parent != null) {
4053 parent.PerformLayout();
4057 [EditorBrowsable(EditorBrowsableState.Advanced)]
4058 protected virtual void OnRightToLeftChanged(EventArgs e) {
4059 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
4060 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4063 [EditorBrowsable(EditorBrowsableState.Advanced)]
4064 protected virtual void OnSizeChanged(EventArgs e) {
4065 InvalidateBuffers ();
4067 if (SizeChanged!=null) SizeChanged(this, e);
4070 [EditorBrowsable(EditorBrowsableState.Advanced)]
4071 protected virtual void OnStyleChanged(EventArgs e) {
4072 if (StyleChanged!=null) StyleChanged(this, e);
4075 [EditorBrowsable(EditorBrowsableState.Advanced)]
4076 protected virtual void OnSystemColorsChanged(EventArgs e) {
4077 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
4080 [EditorBrowsable(EditorBrowsableState.Advanced)]
4081 protected virtual void OnTabIndexChanged(EventArgs e) {
4082 if (TabIndexChanged!=null) TabIndexChanged(this, e);
4085 [EditorBrowsable(EditorBrowsableState.Advanced)]
4086 protected virtual void OnTabStopChanged(EventArgs e) {
4087 if (TabStopChanged!=null) TabStopChanged(this, e);
4090 [EditorBrowsable(EditorBrowsableState.Advanced)]
4091 protected virtual void OnTextChanged(EventArgs e) {
4092 if (TextChanged!=null) TextChanged(this, e);
4095 [EditorBrowsable(EditorBrowsableState.Advanced)]
4096 protected virtual void OnValidated(EventArgs e) {
4097 if (Validated!=null) Validated(this, e);
4100 [EditorBrowsable(EditorBrowsableState.Advanced)]
4101 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4102 if (Validating!=null) Validating(this, e);
4105 [EditorBrowsable(EditorBrowsableState.Advanced)]
4106 protected virtual void OnVisibleChanged(EventArgs e) {
4113 if (bmp_mem!=null) {
4119 if (!this.IsHandleCreated) {
4120 this.CreateControl();
4126 if (VisibleChanged!=null) VisibleChanged(this, e);
4128 // We need to tell our kids
4129 for (int i=0; i<child_controls.Count; i++) {
4130 child_controls[i].OnParentVisibleChanged(e);
4133 #endregion // OnXXX methods
4136 public event EventHandler BackColorChanged;
4137 public event EventHandler BackgroundImageChanged;
4138 public event EventHandler BindingContextChanged;
4139 public event EventHandler CausesValidationChanged;
4140 public event UICuesEventHandler ChangeUICues;
4141 public event EventHandler Click;
4142 public event EventHandler ContextMenuChanged;
4144 [EditorBrowsable(EditorBrowsableState.Advanced)]
4146 public event ControlEventHandler ControlAdded;
4148 [EditorBrowsable(EditorBrowsableState.Advanced)]
4150 public event ControlEventHandler ControlRemoved;
4152 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4153 public event EventHandler CursorChanged;
4154 public event EventHandler DockChanged;
4155 public event EventHandler DoubleClick;
4156 public event DragEventHandler DragDrop;
4157 public event DragEventHandler DragEnter;
4158 public event EventHandler DragLeave;
4159 public event DragEventHandler DragOver;
4160 public event EventHandler EnabledChanged;
4161 public event EventHandler Enter;
4162 public event EventHandler FontChanged;
4163 public event EventHandler ForeColorChanged;
4164 public event GiveFeedbackEventHandler GiveFeedback;
4166 [EditorBrowsable(EditorBrowsableState.Advanced)]
4168 public event EventHandler GotFocus;
4170 [EditorBrowsable(EditorBrowsableState.Advanced)]
4172 public event EventHandler HandleCreated;
4174 [EditorBrowsable(EditorBrowsableState.Advanced)]
4176 public event EventHandler HandleDestroyed;
4178 public event HelpEventHandler HelpRequested;
4179 public event EventHandler ImeModeChanged;
4181 [EditorBrowsable(EditorBrowsableState.Advanced)]
4183 public event InvalidateEventHandler Invalidated;
4185 public event KeyEventHandler KeyDown;
4186 public event KeyPressEventHandler KeyPress;
4187 public event KeyEventHandler KeyUp;
4188 public event LayoutEventHandler Layout;
4189 public event EventHandler Leave;
4190 public event EventHandler LocationChanged;
4192 [EditorBrowsable(EditorBrowsableState.Advanced)]
4194 public event EventHandler LostFocus;
4196 public event MouseEventHandler MouseDown;
4197 public event EventHandler MouseEnter;
4198 public event EventHandler MouseHover;
4199 public event EventHandler MouseLeave;
4200 public event MouseEventHandler MouseMove;
4201 public event MouseEventHandler MouseUp;
4203 [EditorBrowsable(EditorBrowsableState.Advanced)]
4205 public event MouseEventHandler MouseWheel;
4207 public event EventHandler Move;
4208 public event PaintEventHandler Paint;
4209 public event EventHandler ParentChanged;
4210 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
4211 public event QueryContinueDragEventHandler QueryContinueDrag;
4212 public event EventHandler Resize;
4213 public event EventHandler RightToLeftChanged;
4214 public event EventHandler SizeChanged;
4215 public event EventHandler StyleChanged;
4216 public event EventHandler SystemColorsChanged;
4217 public event EventHandler TabIndexChanged;
4218 public event EventHandler TabStopChanged;
4219 public event EventHandler TextChanged;
4220 public event EventHandler Validated;
4221 public event CancelEventHandler Validating;
4222 public event EventHandler VisibleChanged;
4223 #endregion // Events