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 SizeF size_ratio; // size ratio of our control to it's parent; required for anchoring
102 internal Size prev_size; // previous size of the control; required for anchoring
104 // to be categorized...
105 static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
106 internal ControlCollection child_controls; // our children
107 internal Control parent; // our parent control
108 internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
109 internal BindingContext binding_context; // TODO
110 internal RightToLeft right_to_left; // drawing direction for control
111 internal int layout_suspended;
112 internal ContextMenu context_menu; // Context menu associated with the control
114 private Graphics dc_mem; // Graphics context for double buffering
115 private Bitmap bmp_mem; // Bitmap for double buffering control
116 private bool needs_redraw = true;
118 private ControlBindingsCollection data_bindings;
120 #endregion // Local Variables
122 #region Private Classes
123 // This helper class allows us to dispatch messages to Control.WndProc
124 internal class ControlNativeWindow : NativeWindow {
125 private Control owner;
127 public ControlNativeWindow(Control control) : base() {
132 public Control Owner {
138 static internal Control ControlFromHandle(IntPtr hWnd) {
139 ControlNativeWindow window;
141 window = (ControlNativeWindow)window_collection[hWnd];
146 protected override void WndProc(ref Message m) {
147 owner.WndProc(ref m);
152 #region Public Classes
154 public class ControlAccessibleObject : AccessibleObject {
155 #region ControlAccessibleObject Local Variables
156 private Control owner;
157 #endregion // ControlAccessibleObject Local Variables
159 #region ControlAccessibleObject Constructors
160 public ControlAccessibleObject(Control ownerControl) {
161 this.owner = ownerControl;
163 #endregion // ControlAccessibleObject Constructors
165 #region ControlAccessibleObject Public Instance Properties
166 public override string DefaultAction {
168 return base.DefaultAction;
172 public override string Description {
174 return base.Description;
178 public IntPtr Handle {
184 // We don't want to let them set it
188 public override string Help {
194 public override string KeyboardShortcut {
196 return base.KeyboardShortcut;
200 public override string Name {
210 public Control Owner {
216 public override AccessibleObject Parent {
223 public override AccessibleRole Role {
228 #endregion // ControlAccessibleObject Public Instance Properties
230 #region ControlAccessibleObject Public Instance Methods
231 public override int GetHelpTopic(out string FileName) {
232 return base.GetHelpTopic (out FileName);
235 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
236 public void NotifyClients(AccessibleEvents accEvent) {
237 throw new NotImplementedException();
240 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
241 public void NotifyClients(AccessibleEvents accEvent, int childID) {
242 throw new NotImplementedException();
245 public override string ToString() {
246 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
249 #endregion // ControlAccessibleObject Public Instance Methods
252 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
253 [ListBindable(false)]
254 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
255 #region ControlCollection Local Variables
256 private ArrayList list;
257 private ArrayList impl_list;
258 private Control [] all_controls;
259 internal Control owner;
260 #endregion // ControlCollection Local Variables
262 #region ControlCollection Public Constructor
263 public ControlCollection(Control owner) {
265 this.list=new ArrayList();
269 #region ControlCollection Public Instance Properties
276 public bool IsReadOnly {
278 return list.IsReadOnly;
282 public virtual Control this[int index] {
284 if (index < 0 || index >= list.Count) {
285 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
287 return (Control)list[index];
290 #endregion // ControlCollection Public Instance Properties
292 #region ControlCollection Private Instance Methods
293 public virtual void Add (Control value)
298 if (Contains (value))
301 if (value.tab_index == -1) {
307 end = owner.child_controls.Count;
308 for (int i = 0; i < end; i++) {
309 index = owner.child_controls[i].tab_index;
314 value.tab_index = use;
319 value.Parent = owner;
320 owner.UpdateZOrder();
321 owner.OnControlAdded(new ControlEventArgs(value));
324 internal void AddToList (Control c)
330 internal virtual void AddImplicit (Control control)
332 if (impl_list == null)
333 impl_list = new ArrayList ();
335 impl_list.Add (control);
336 control.Parent = owner;
337 owner.UpdateZOrder ();
340 public virtual void AddRange (Control[] controls)
342 if (controls == null)
343 throw new ArgumentNullException ("controls");
345 owner.SuspendLayout ();
348 for (int i = 0; i < controls.Length; i++)
351 owner.ResumeLayout ();
355 internal virtual void AddRangeImplicit (Control [] controls)
357 if (controls == null)
358 throw new ArgumentNullException ("controls");
360 owner.SuspendLayout ();
363 for (int i = 0; i < controls.Length; i++)
364 AddImplicit (controls [i]);
366 owner.ResumeLayout ();
370 public virtual void Clear ()
372 owner.SuspendLayout();
374 for (int i = 0; i < list.Count; i++) {
375 owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
378 owner.ResumeLayout();
381 internal virtual void ClearImplicit ()
383 if (impl_list == null)
389 public bool Contains (Control value)
391 for (int i = list.Count; i > 0; ) {
394 if (list [i] == value) {
395 // Do we need to do anything here?
402 internal bool ImplicitContains (Control value)
404 if (impl_list == null)
407 for (int i = impl_list.Count; i > 0; ) {
410 if (impl_list [i] == value) {
411 // Do we need to do anything here?
418 internal bool AllContains (Control value)
420 return Contains (value) || ImplicitContains (value);
423 public void CopyTo (Array array, int index)
425 list.CopyTo(array, index);
428 public override bool Equals(object other) {
429 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
436 public int GetChildIndex(Control child) {
437 return GetChildIndex(child, false);
440 public int GetChildIndex(Control child, bool throwException) {
443 index=list.IndexOf(child);
445 if (index==-1 && throwException) {
446 throw new ArgumentException("Not a child control", "child");
451 public IEnumerator GetEnumerator() {
452 return list.GetEnumerator();
455 internal IEnumerator GetAllEnumerator ()
457 Control [] res = GetAllControls ();
458 return res.GetEnumerator ();
461 internal Control [] GetAllControls ()
463 if (all_controls != null)
466 if (impl_list == null)
467 return (Control []) list.ToArray (typeof (Control));
468 Control [] res = new Control [list.Count + impl_list.Count];
470 impl_list.CopyTo (res, list.Count);
474 public override int GetHashCode() {
475 return base.GetHashCode();
478 public int IndexOf(Control control) {
479 return list.IndexOf(control);
482 public virtual void Remove(Control value) {
485 owner.OnControlRemoved(new ControlEventArgs(value));
488 owner.UpdateZOrder();
491 internal virtual void RemoveImplicit (Control control)
493 if (impl_list != null) {
495 impl_list.Remove (control);
497 control.Parent = null;
498 owner.UpdateZOrder ();
501 public void RemoveAt(int index) {
502 if (index < 0 || index >= list.Count) {
503 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
505 Remove ((Control)list[index]);
508 public void SetChildIndex(Control child, int newIndex) {
511 old_index=list.IndexOf(child);
513 throw new ArgumentException("Not a child control", "child");
516 if (old_index==newIndex) {
522 if (newIndex>list.Count) {
525 list.Insert(newIndex, child);
527 child.parent = owner;
528 owner.UpdateZOrder();
530 #endregion // ControlCollection Private Instance Methods
532 #region ControlCollection Interface Properties
533 object IList.this[int index] {
535 if (index<0 || index>=list.Count) {
536 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
542 if (!(value is Control)) {
543 throw new ArgumentException("Object of type Control required", "value");
546 list[index]=(Control)value;
550 bool IList.IsFixedSize {
556 bool IList.IsReadOnly {
558 return list.IsReadOnly;
562 bool ICollection.IsSynchronized {
564 return list.IsSynchronized;
568 object ICollection.SyncRoot {
570 return list.SyncRoot;
573 #endregion // ControlCollection Interface Properties
575 #region ControlCollection Interface Methods
576 int IList.Add(object value) {
578 throw new ArgumentNullException("value", "Cannot add null controls");
581 if (!(value is Control)) {
582 throw new ArgumentException("Object of type Control required", "value");
585 return list.Add(value);
588 bool IList.Contains(object value) {
589 if (!(value is Control)) {
590 throw new ArgumentException("Object of type Control required", "value");
593 return this.Contains((Control) value);
596 int IList.IndexOf(object value) {
597 if (!(value is Control)) {
598 throw new ArgumentException("Object of type Control required", "value");
601 return this.IndexOf((Control) value);
604 void IList.Insert(int index, object value) {
605 if (!(value is Control)) {
606 throw new ArgumentException("Object of type Control required", "value");
609 list.Insert(index, value);
612 void IList.Remove(object value) {
613 if (!(value is Control)) {
614 throw new ArgumentException("Object of type Control required", "value");
620 void ICollection.CopyTo(Array array, int index) {
622 list.CopyTo(array, index);
626 Object ICloneable.Clone() {
627 ControlCollection clone = new ControlCollection(this.owner);
628 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
631 #endregion // ControlCollection Interface Methods
633 #endregion // ControlCollection Class
635 #region Public Constructors
637 creator_thread = Thread.CurrentThread;
639 prev_size = Size.Empty;
640 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
642 create_handled = false;
648 layout_pending = false;
650 causes_validation = true;
652 layout_suspended = 0;
656 right_to_left = RightToLeft.Inherit;
657 border_style = BorderStyle.None;
658 background_color = Color.Empty;
660 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
661 ControlStyles.Selectable | ControlStyles.StandardClick |
662 ControlStyles.StandardDoubleClick;
665 background_image = null;
669 window = new ControlNativeWindow(this);
670 child_controls = CreateControlsInstance();
671 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
672 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
673 XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, CreateParams.ExStyle, IntPtr.Zero, out bounds);
674 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
680 public Control(Control parent, string text) : this() {
685 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
690 bounds.Height=height;
691 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
695 public Control(string text) : this() {
699 public Control(string text, int left, int top, int width, int height) : this() {
703 bounds.Height=height;
704 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
708 protected override void Dispose(bool disposing) {
721 controls.Remove(this);
723 #endregion // Public Constructors
725 #region Internal Properties
726 internal BorderStyle InternalBorderStyle {
732 if (!Enum.IsDefined (typeof (BorderStyle), value))
733 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
735 if (border_style != value) {
736 border_style = value;
738 if (IsHandleCreated) {
739 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
745 #endregion // Internal Properties
747 #region Private & Internal Methods
748 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
749 AsyncMethodResult result;
750 AsyncMethodData data;
755 if (!p.IsHandleCreated) {
756 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
761 result = new AsyncMethodResult ();
762 data = new AsyncMethodData ();
764 data.Method = method;
766 data.Result = new WeakReference (result);
769 if (!ExecutionContext.IsFlowSuppressed ()) {
770 data.Context = ExecutionContext.Capture ();
773 #if !MWF_ON_MSRUNTIME
774 if (SecurityManager.SecurityEnabled) {
775 data.Stack = CompressedStack.GetCompressedStack ();
780 XplatUI.SendAsyncMethod (data);
784 internal Graphics DeviceContext {
787 CreateBuffers(this.Width, this.Height);
793 private Bitmap ImageBuffer {
796 CreateBuffers(this.Width, this.Height);
802 internal void CreateBuffers (int width, int height) {
803 if (dc_mem != null) {
817 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
818 dc_mem = Graphics.FromImage (bmp_mem);
822 internal void InvalidateBuffers ()
824 if (dc_mem != null) {
835 internal static void SetChildColor(Control parent) {
838 for (int i=0; i < parent.child_controls.Count; i++) {
839 child=parent.child_controls[i];
840 if (child.child_controls.Count>0) {
841 SetChildColor(child);
847 internal bool Select(Control control) {
849 IContainerControl container;
851 if (control == null) {
855 parent = control.parent;
857 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
858 while (parent != null) {
859 if (!parent.Visible || !parent.is_enabled) {
862 parent = parent.parent;
866 control.is_selected = true;
868 container = GetContainerControl();
869 if (container != null) {
870 container.ActiveControl = control;
872 if (control.IsHandleCreated) {
873 XplatUI.SetFocus(control.window.Handle);
878 internal virtual void DoDefaultAction() {
879 // Only here to be overriden by our actual controls; this is needed by the accessibility class
882 internal static int LowOrder (int param) {
883 return ((int)(short)(param & 0xffff));
886 internal static int HighOrder (int param) {
887 return ((int)(short)(param >> 16));
890 // This method exists so controls overriding OnPaintBackground can have default background painting done
891 internal virtual void PaintControlBackground (PaintEventArgs pevent)
893 if (background_image == null) {
894 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));
898 DrawBackgroundImage (pevent.Graphics);
901 void DrawBackgroundImage (Graphics g)
903 using (TextureBrush b = new TextureBrush (background_image)) {
904 g.FillRectangle (b, ClientRectangle);
908 internal void DndEnter (DragEventArgs e)
913 internal void DndOver (DragEventArgs e)
918 internal void DndDrop (DragEventArgs e)
923 internal void DndLeave (EventArgs e)
928 internal void DnDFeedback(GiveFeedbackEventArgs e)
933 internal void DnDContinueDrag(QueryContinueDragEventArgs e) {
934 OnQueryContinueDrag(e);
937 internal static MouseButtons FromParamToMouseButtons (int param) {
938 MouseButtons buttons = MouseButtons.None;
940 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
941 buttons |= MouseButtons.Left;
943 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
944 buttons |= MouseButtons.Middle;
946 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
947 buttons |= MouseButtons.Right;
953 internal virtual bool ProcessControlMnemonic(char charCode) {
954 return ProcessMnemonic(charCode);
957 private static Control FindFlatForward(Control container, Control start) {
963 end = container.child_controls.Count;
966 index = start.tab_index;
971 for (int i = 0; i < end; i++) {
973 if (container.child_controls[i].tab_index > index) {
974 found = container.child_controls[i];
976 } else if (found.tab_index > container.child_controls[i].tab_index) {
977 if (container.child_controls[i].tab_index > index) {
978 found = container.child_controls[i];
985 private static Control FindControlForward(Control container, Control start) {
992 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
993 found = FindControlForward(start, null);
1000 while (p != container) {
1001 found = FindFlatForward(p, start);
1002 if (found != null) {
1009 return FindFlatForward(container, start);
1012 private static Control FindFlatBackward(Control container, Control start) {
1018 end = container.child_controls.Count;
1020 if (start != null) {
1021 index = start.tab_index;
1023 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1025 for (int i = 0; i < end; i++) {
1026 if (container.child_controls[i].tab_index > index) {
1027 index = container.child_controls[i].tab_index;
1033 for (int i = 0; i < end; i++) {
1034 if (found == null) {
1035 if (container.child_controls[i].tab_index < index) {
1036 found = container.child_controls[i];
1038 } else if (found.tab_index < container.child_controls[i].tab_index) {
1039 if (container.child_controls[i].tab_index < index) {
1040 found = container.child_controls[i];
1047 private static Control FindControlBackward(Control container, Control start) {
1052 if (start != null) {
1053 found = FindFlatBackward(start.parent, start);
1054 if (found == null && start.parent != container) {
1055 return start.parent;
1058 if (found == null) {
1059 found = FindFlatBackward(container, start);
1062 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
1063 found = FindControlBackward(found, null);
1064 if (found != null) {
1072 private void HandleClick(int clicks) {
1073 if (GetStyle(ControlStyles.StandardClick)) {
1075 if (GetStyle(ControlStyles.StandardDoubleClick)) {
1076 OnDoubleClick(EventArgs.Empty);
1078 OnClick(EventArgs.Empty);
1081 OnClick(EventArgs.Empty);
1086 private void CheckDataBindings ()
1088 if (data_bindings == null)
1091 BindingContext binding_context = BindingContext;
1092 foreach (Binding binding in data_bindings) {
1093 binding.Check (binding_context);
1097 #endregion // Private & Internal Methods
1099 #region Public Static Properties
1100 public static Color DefaultBackColor {
1102 return ThemeEngine.Current.DefaultControlBackColor;
1106 public static Font DefaultFont {
1108 return ThemeEngine.Current.DefaultFont;
1112 public static Color DefaultForeColor {
1114 return ThemeEngine.Current.DefaultControlForeColor;
1118 public static Keys ModifierKeys {
1120 return XplatUI.State.ModifierKeys;
1124 public static MouseButtons MouseButtons {
1126 return XplatUI.State.MouseButtons;
1130 public static Point MousePosition {
1132 return Cursor.Position;
1138 public static bool CheckForIllegalCrossThreadCalls
1147 #endregion // Public Static Properties
1149 #region Public Instance Properties
1150 [EditorBrowsable(EditorBrowsableState.Advanced)]
1152 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1153 public AccessibleObject AccessibilityObject {
1155 if (accessibility_object==null) {
1156 accessibility_object=CreateAccessibilityInstance();
1158 return accessibility_object;
1162 [EditorBrowsable(EditorBrowsableState.Advanced)]
1164 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1165 public string AccessibleDefaultActionDescription {
1167 return AccessibilityObject.default_action;
1171 AccessibilityObject.default_action=value;
1176 [DefaultValue(null)]
1177 public string AccessibleDescription {
1179 return AccessibilityObject.description;
1183 AccessibilityObject.description=value;
1188 [DefaultValue(null)]
1189 public string AccessibleName {
1191 return AccessibilityObject.Name;
1195 AccessibilityObject.Name=value;
1199 [DefaultValue(AccessibleRole.Default)]
1200 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1201 public AccessibleRole AccessibleRole {
1203 return AccessibilityObject.role;
1207 AccessibilityObject.role=value;
1211 [DefaultValue(false)]
1212 public virtual bool AllowDrop {
1218 if (allow_drop == value)
1222 XplatUI.SetAllowDrop (Handle, value);
1227 [RefreshProperties(RefreshProperties.Repaint)]
1228 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1229 public virtual AnchorStyles Anchor {
1231 return anchor_style;
1237 if (parent != null) {
1238 parent.PerformLayout(this, "Parent");
1244 public virtual Color BackColor {
1246 if (background_color.IsEmpty) {
1248 return parent.BackColor;
1250 return DefaultBackColor;
1252 return background_color;
1256 background_color=value;
1257 SetChildColor(this);
1258 OnBackColorChanged(EventArgs.Empty);
1264 [DefaultValue(null)]
1265 public virtual Image BackgroundImage {
1267 return background_image;
1271 if (background_image!=value) {
1272 background_image=value;
1273 OnBackgroundImageChanged(EventArgs.Empty);
1278 [EditorBrowsable(EditorBrowsableState.Advanced)]
1280 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1281 public virtual BindingContext BindingContext {
1283 if (binding_context != null)
1284 return binding_context;
1287 binding_context = Parent.BindingContext;
1288 return binding_context;
1291 if (binding_context != value) {
1292 binding_context = value;
1293 OnBindingContextChanged(EventArgs.Empty);
1298 [EditorBrowsable(EditorBrowsableState.Advanced)]
1300 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1303 return bounds.Y+bounds.Height;
1307 [EditorBrowsable(EditorBrowsableState.Advanced)]
1309 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1310 public Rectangle Bounds {
1316 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1320 [EditorBrowsable(EditorBrowsableState.Advanced)]
1322 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1323 public bool CanFocus {
1325 if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1332 [EditorBrowsable(EditorBrowsableState.Advanced)]
1334 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1335 public bool CanSelect {
1339 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1343 parent = this.parent;
1344 while (parent != null) {
1345 if (!parent.is_visible || !parent.is_enabled) {
1349 parent = parent.parent;
1355 [EditorBrowsable(EditorBrowsableState.Advanced)]
1357 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1358 public bool Capture {
1360 return this.is_captured;
1364 if (this.IsHandleCreated) {
1365 if (value && !is_captured) {
1367 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1368 } else if (!value && is_captured) {
1369 XplatUI.UngrabWindow(this.window.Handle);
1370 is_captured = false;
1376 [DefaultValue(true)]
1377 public bool CausesValidation {
1379 return this.causes_validation;
1383 if (this.causes_validation != value) {
1384 causes_validation = value;
1385 OnCausesValidationChanged(EventArgs.Empty);
1390 [EditorBrowsable(EditorBrowsableState.Advanced)]
1392 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1393 public Rectangle ClientRectangle {
1395 client_rect.Width = client_size.Width;
1396 client_rect.Height = client_size.Height;
1401 [EditorBrowsable(EditorBrowsableState.Advanced)]
1403 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1404 public Size ClientSize {
1407 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1408 return ((Form)this).form_parent_window.ClientSize;
1416 this.SetClientSizeCore(value.Width, value.Height);
1420 [EditorBrowsable(EditorBrowsableState.Advanced)]
1422 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1423 [DescriptionAttribute("ControlCompanyNameDescr")]
1424 public String CompanyName {
1426 return "Mono Project, Novell, Inc.";
1430 [EditorBrowsable(EditorBrowsableState.Advanced)]
1432 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1433 public bool ContainsFocus {
1439 for (int i=0; i < child_controls.Count; i++) {
1440 if (child_controls[i].ContainsFocus) {
1448 [DefaultValue(null)]
1449 public virtual ContextMenu ContextMenu {
1451 return context_menu;
1455 if (context_menu != value) {
1456 context_menu = value;
1457 OnContextMenuChanged(EventArgs.Empty);
1463 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1464 public ControlCollection Controls {
1466 return this.child_controls;
1470 [EditorBrowsable(EditorBrowsableState.Advanced)]
1472 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1473 public bool Created {
1475 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1482 [AmbientValue(null)]
1483 public virtual Cursor Cursor {
1485 if (cursor != null) {
1489 if (parent != null) {
1490 return parent.Cursor;
1493 return Cursors.Default;
1497 if (cursor != value) {
1502 pt = Cursor.Position;
1503 if (bounds.Contains(pt)) {
1504 if (GetChildAtPoint(pt) == null) {
1505 if (cursor != null) {
1506 XplatUI.SetCursor(window.Handle, cursor.handle);
1508 if (parent != null) {
1509 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1511 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1517 OnCursorChanged(EventArgs.Empty);
1523 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1524 [ParenthesizePropertyName(true)]
1525 [RefreshProperties(RefreshProperties.All)]
1526 public ControlBindingsCollection DataBindings {
1528 if (data_bindings == null)
1529 data_bindings = new ControlBindingsCollection (this);
1530 return data_bindings;
1534 [EditorBrowsable(EditorBrowsableState.Advanced)]
1536 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1537 public virtual Rectangle DisplayRectangle {
1539 return ClientRectangle;
1543 [EditorBrowsable(EditorBrowsableState.Advanced)]
1545 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1546 public bool Disposing {
1553 [RefreshProperties(RefreshProperties.Repaint)]
1554 [DefaultValue(DockStyle.None)]
1555 public virtual DockStyle Dock {
1561 if (dock_style == value) {
1567 if (parent != null) {
1568 parent.PerformLayout(this, "Parent");
1571 OnDockChanged(EventArgs.Empty);
1577 public bool Enabled {
1583 if (is_enabled == value) {
1589 OnEnabledChanged (EventArgs.Empty);
1593 [EditorBrowsable(EditorBrowsableState.Advanced)]
1595 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1596 public virtual bool Focused {
1598 return this.has_focus;
1603 [AmbientValue(null)]
1605 public virtual Font Font {
1611 if (Parent != null && Parent.Font != null) {
1619 if (font != null && font.Equals (value)) {
1625 OnFontChanged (EventArgs.Empty);
1630 public virtual Color ForeColor {
1632 if (foreground_color.IsEmpty) {
1634 return parent.ForeColor;
1636 return DefaultForeColor;
1638 return foreground_color;
1642 if (foreground_color != value) {
1643 foreground_color=value;
1645 OnForeColorChanged(EventArgs.Empty);
1652 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1653 public IntPtr Handle { // IWin32Window
1655 if (!IsHandleCreated) {
1658 return window.Handle;
1662 [EditorBrowsable(EditorBrowsableState.Advanced)]
1664 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1665 public bool HasChildren {
1667 if (this.child_controls.Count>0) {
1674 [EditorBrowsable(EditorBrowsableState.Always)]
1676 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1679 return this.bounds.Height;
1683 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1687 [AmbientValue(ImeMode.Inherit)]
1689 public ImeMode ImeMode {
1691 if (ime_mode == DefaultImeMode) {
1693 return parent.ImeMode;
1695 return ImeMode.NoControl; // default value
1701 if (ime_mode != value) {
1704 OnImeModeChanged(EventArgs.Empty);
1709 [EditorBrowsable(EditorBrowsableState.Advanced)]
1711 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1712 public bool InvokeRequired { // ISynchronizeInvoke
1714 if (creator_thread!=Thread.CurrentThread) {
1721 [EditorBrowsable(EditorBrowsableState.Advanced)]
1723 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1724 public bool IsAccessible {
1726 return is_accessible;
1730 is_accessible = value;
1734 [EditorBrowsable(EditorBrowsableState.Advanced)]
1736 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1737 public bool IsDisposed {
1739 return this.is_disposed;
1743 [EditorBrowsable(EditorBrowsableState.Advanced)]
1745 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1746 public bool IsHandleCreated {
1748 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1756 [EditorBrowsable(EditorBrowsableState.Always)]
1758 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1761 return this.bounds.X;
1765 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1770 public Point Location {
1772 return new Point(bounds.X, bounds.Y);
1776 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1781 public string Name {
1792 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1793 public Control Parent {
1799 if (value == this) {
1800 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1803 if (parent!=value) {
1805 parent.Controls.Remove(this);
1811 if (!parent.Controls.AllContains (this)) {
1812 Console.WriteLine ("Adding child: " + this);
1813 parent.Controls.Add(this);
1816 if (IsHandleCreated) {
1817 XplatUI.SetParent(Handle, value.Handle);
1820 OnParentChanged(EventArgs.Empty);
1826 [EditorBrowsable(EditorBrowsableState.Advanced)]
1828 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1829 public string ProductName {
1831 Type t = typeof (AssemblyProductAttribute);
1832 Assembly assembly = GetType().Module.Assembly;
1833 object [] attrs = assembly.GetCustomAttributes (t, false);
1834 AssemblyProductAttribute a = null;
1835 // On MS we get a NullRefException if product attribute is not
1837 if (attrs != null && attrs.Length > 0)
1838 a = (AssemblyProductAttribute) attrs [0];
1843 [EditorBrowsable(EditorBrowsableState.Advanced)]
1845 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1846 public string ProductVersion {
1848 Type t = typeof (AssemblyVersionAttribute);
1849 Assembly assembly = GetType().Module.Assembly;
1850 object [] attrs = assembly.GetCustomAttributes (t, false);
1851 if (attrs == null || attrs.Length < 1)
1853 return ((AssemblyVersionAttribute)attrs [0]).Version;
1857 [EditorBrowsable(EditorBrowsableState.Advanced)]
1859 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1860 public bool RecreatingHandle {
1862 return is_recreating;
1866 [EditorBrowsable(EditorBrowsableState.Advanced)]
1868 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1869 public Region Region {
1871 return new Region(this.bounds);
1878 g = this.CreateGraphics();
1879 r = value.GetBounds(g);
1881 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1887 [EditorBrowsable(EditorBrowsableState.Advanced)]
1889 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1892 return this.bounds.X+this.bounds.Width;
1896 [AmbientValue(RightToLeft.Inherit)]
1898 public virtual RightToLeft RightToLeft {
1900 if (right_to_left == RightToLeft.Inherit) {
1902 return parent.RightToLeft;
1904 return RightToLeft.No; // default value
1906 return right_to_left;
1910 if (value != right_to_left) {
1911 right_to_left = value;
1912 OnRightToLeftChanged(EventArgs.Empty);
1917 [EditorBrowsable(EditorBrowsableState.Advanced)]
1918 public override ISite Site {
1931 return new Size(Width, Height);
1935 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1940 [MergableProperty(false)]
1941 public int TabIndex {
1943 if (tab_index != -1) {
1950 if (tab_index != value) {
1952 OnTabIndexChanged(EventArgs.Empty);
1958 [DefaultValue(true)]
1959 public bool TabStop {
1965 if (tab_stop != value) {
1967 OnTabStopChanged(EventArgs.Empty);
1972 [Localizable(false)]
1974 [TypeConverter(typeof(StringConverter))]
1975 [DefaultValue(null)]
1982 control_tag = value;
1988 [BindableAttribute(true)]
1989 public virtual string Text {
1991 // Our implementation ignores ControlStyles.CacheText - we always cache
1996 if (value == null) {
1997 value = String.Empty;
2002 if (IsHandleCreated) {
2003 XplatUI.Text(Handle, text);
2005 OnTextChanged (EventArgs.Empty);
2010 [EditorBrowsable(EditorBrowsableState.Always)]
2012 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2015 return this.bounds.Y;
2019 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2023 [EditorBrowsable(EditorBrowsableState.Advanced)]
2025 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2026 public Control TopLevelControl {
2030 while (p.parent != null) {
2039 public bool Visible {
2043 } else if (parent != null) {
2044 return parent.Visible;
2051 SetVisibleCore(value);
2055 [EditorBrowsable(EditorBrowsableState.Always)]
2057 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2060 return this.bounds.Width;
2064 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2068 [EditorBrowsable(EditorBrowsableState.Never)]
2070 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2071 public IWindowTarget WindowTarget {
2080 #endregion // Public Instance Properties
2082 #region Protected Instance Properties
2083 protected virtual CreateParams CreateParams {
2085 CreateParams create_params = new CreateParams();
2088 create_params.Caption = Text;
2091 create_params.Caption = text;
2095 create_params.X = Left;
2098 create_params.X = this.bounds.X;
2102 create_params.Y = Top;
2105 create_params.Y = this.bounds.Y;
2109 create_params.Width = Width;
2112 create_params.Width = this.bounds.Width;
2116 create_params.Height = Height;
2119 create_params.Height = this.bounds.Height;
2123 create_params.ClassName = XplatUI.DefaultClassName;
2124 create_params.ClassStyle = 0;
2125 create_params.ExStyle = 0;
2126 create_params.Param = 0;
2129 create_params.ExStyle |= (int)WindowStyles.WS_EX_ACCEPTFILES;
2133 create_params.Parent = parent.Handle;
2136 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2139 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2142 return create_params;
2146 protected virtual ImeMode DefaultImeMode {
2148 return ImeMode.Inherit;
2152 protected virtual Size DefaultSize {
2154 return new Size(100, 23);
2158 protected int FontHeight {
2168 protected bool RenderRightToLeft {
2170 return (this.right_to_left == RightToLeft.Yes);
2174 protected bool ResizeRedraw {
2176 return GetStyle(ControlStyles.ResizeRedraw);
2180 SetStyle(ControlStyles.ResizeRedraw, value);
2184 [EditorBrowsable(EditorBrowsableState.Advanced)]
2186 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2187 protected virtual bool ShowFocusCues {
2193 [EditorBrowsable(EditorBrowsableState.Advanced)]
2195 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2196 protected bool ShowKeyboardCues {
2201 #endregion // Protected Instance Properties
2203 #region Public Static Methods
2204 [EditorBrowsable(EditorBrowsableState.Advanced)]
2205 public static Control FromChildHandle(IntPtr handle) {
2206 IEnumerator control = Control.controls.GetEnumerator();
2208 while (control.MoveNext()) {
2209 if (((Control)control.Current).window.Handle == handle) {
2211 if (((Control)control.Current).Parent != null) {
2212 return ((Control)control.Current).Parent;
2219 [EditorBrowsable(EditorBrowsableState.Advanced)]
2220 public static Control FromHandle(IntPtr handle) {
2221 IEnumerator control = Control.controls.GetEnumerator();
2223 while (control.MoveNext()) {
2224 if (((Control)control.Current).window.Handle == handle) {
2226 return ((Control)control.Current);
2232 public static bool IsMnemonic(char charCode, string text) {
2235 amp = text.IndexOf('&');
2238 if (amp + 1 < text.Length) {
2239 if (text[amp + 1] != '&') {
2240 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2250 #region Protected Static Methods
2251 [EditorBrowsable(EditorBrowsableState.Advanced)]
2252 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2255 c = Control.FromHandle(hWnd);
2265 #region Public Instance Methods
2266 [EditorBrowsable(EditorBrowsableState.Advanced)]
2267 public IAsyncResult BeginInvoke(Delegate method) {
2268 return BeginInvokeInternal(method, null);
2271 [EditorBrowsable(EditorBrowsableState.Advanced)]
2272 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2273 return BeginInvokeInternal (method, args);
2276 public void BringToFront() {
2277 if ((parent != null) && (parent.child_controls[0]!=this)) {
2278 if (parent.child_controls.Contains(this)) {
2279 parent.child_controls.SetChildIndex(this, 0);
2283 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
2285 if (parent != null) {
2290 public bool Contains(Control ctl) {
2291 while (ctl != null) {
2300 public void CreateControl() {
2302 if (!IsHandleCreated) {
2306 if (!create_handled) {
2307 create_handled = true;
2311 Control [] controls = child_controls.GetAllControls ();
2312 for (int i=0; i<controls.Length; i++) {
2313 controls [i].CreateControl ();
2317 public Graphics CreateGraphics() {
2318 if (!IsHandleCreated) {
2319 this.CreateControl();
2321 return Graphics.FromHwnd(this.window.Handle);
2324 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2325 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2328 [EditorBrowsable(EditorBrowsableState.Advanced)]
2329 public object EndInvoke (IAsyncResult async_result) {
2330 AsyncMethodResult result = (AsyncMethodResult) async_result;
2331 return result.EndInvoke ();
2334 public Form FindForm() {
2347 public bool Focus() {
2348 if (IsHandleCreated && !has_focus) {
2350 XplatUI.SetFocus(window.Handle);
2355 public Control GetChildAtPoint(Point pt) {
2356 // Microsoft's version of this function doesn't seem to work, so I can't check
2357 // if we only consider children or also grandchildren, etc.
2358 // I'm gonna say 'children only'
2359 for (int i=0; i<child_controls.Count; i++) {
2360 if (child_controls[i].Bounds.Contains(pt)) {
2361 return child_controls[i];
2367 public IContainerControl GetContainerControl() {
2368 Control current = this;
2370 while (current!=null) {
2371 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2372 return (IContainerControl)current;
2374 current = current.parent;
2379 public Control GetNextControl(Control ctl, bool forward) {
2380 // If we're not a container we don't play
2381 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2385 // If ctl is not contained by this, we start at the first child of this
2386 if (!this.Contains(ctl)) {
2390 // Search through our controls, starting at ctl, stepping into children as we encounter them
2391 // try to find the control with the tabindex closest to our own, or, if we're looking into
2392 // child controls, the one with the smallest tabindex
2394 return FindControlForward(this, ctl);
2396 return FindControlBackward(this, ctl);
2399 public void Hide() {
2400 this.Visible = false;
2403 public void Invalidate() {
2404 Invalidate(ClientRectangle, false);
2407 public void Invalidate(bool invalidateChildren) {
2408 Invalidate(ClientRectangle, invalidateChildren);
2411 public void Invalidate(System.Drawing.Rectangle rc) {
2412 Invalidate(rc, false);
2415 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2416 if (!IsHandleCreated || !Visible) {
2420 NotifyInvalidate(rc);
2422 XplatUI.Invalidate(Handle, rc, false);
2424 if (invalidateChildren) {
2425 Control [] controls = child_controls.GetAllControls ();
2426 for (int i=0; i<controls.Length; i++)
2427 controls [i].Invalidate ();
2429 OnInvalidated(new InvalidateEventArgs(rc));
2432 public void Invalidate(System.Drawing.Region region) {
2433 Invalidate(region, false);
2436 [MonoTODO("Figure out if GetRegionScans is usable")]
2437 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2438 throw new NotImplementedException();
2440 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2441 //if (invalidateChildren) {
2442 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2446 public object Invoke (Delegate method) {
2447 return Invoke(method, null);
2450 public object Invoke (Delegate method, object[] args) {
2451 if (!this.InvokeRequired) {
2452 return method.DynamicInvoke(args);
2455 IAsyncResult result = BeginInvoke (method, args);
2456 return EndInvoke(result);
2459 [EditorBrowsable(EditorBrowsableState.Advanced)]
2460 public void PerformLayout() {
2461 PerformLayout(null, null);
2464 [EditorBrowsable(EditorBrowsableState.Advanced)]
2465 public void PerformLayout(Control affectedControl, string affectedProperty) {
2466 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2468 if (layout_suspended>0) {
2469 layout_pending = true;
2473 layout_pending = false;
2475 // Prevent us from getting messed up
2478 // Perform all Dock and Anchor calculations
2481 AnchorStyles anchor;
2486 space=this.DisplayRectangle;
2487 if (prev_size != Size.Empty) {
2488 diff_width = space.Width - prev_size.Width;
2489 diff_height = space.Height - prev_size.Height;
2495 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2496 Control [] controls = child_controls.GetAllControls ();
2497 for (int i = controls.Length - 1; i >= 0; i--) {
2498 child = controls [i];
2499 switch (child.Dock) {
2500 case DockStyle.None: {
2505 case DockStyle.Left: {
2506 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2507 space.X+=child.Width;
2508 space.Width-=child.Width;
2512 case DockStyle.Top: {
2513 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2514 space.Y+=child.Height;
2515 space.Height-=child.Height;
2519 case DockStyle.Right: {
2520 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2521 space.Width-=child.Width;
2525 case DockStyle.Bottom: {
2526 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2527 space.Height-=child.Height;
2533 for (int i = controls.Length - 1; i >= 0; i--) {
2536 if (child.Dock == DockStyle.Fill) {
2537 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2543 space=this.DisplayRectangle;
2545 // Deal with anchoring
2546 for (int i=0; i < controls.Length; i++) {
2553 anchor=child.Anchor;
2558 height=child.Height;
2560 // If the control is docked we don't need to do anything
2561 if (child.Dock != DockStyle.None) {
2565 if ((anchor & AnchorStyles.Left) !=0 ) {
2566 if ((anchor & AnchorStyles.Right) != 0) {
2567 // Anchoring to left and right
2568 width=width+diff_width;
2572 } else if ((anchor & AnchorStyles.Right) != 0) {
2578 if ((anchor & AnchorStyles.Top) !=0 ) {
2579 if ((anchor & AnchorStyles.Bottom) != 0) {
2580 height+=diff_height;
2584 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2599 child.SetBounds(left, top, width, height);
2602 // Let everyone know
2606 // Need to make sure we decremend layout_suspended
2612 public Point PointToClient (Point p) {
2616 XplatUI.ScreenToClient (Handle, ref x, ref y);
2618 return new Point (x, y);
2621 public Point PointToScreen(Point p) {
2625 XplatUI.ClientToScreen(Handle, ref x, ref y);
2627 return new Point(x, y);
2630 public virtual bool PreProcessMessage(ref Message msg) {
2633 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
2634 key_data = (Keys)msg.WParam.ToInt32();
2635 if (!ProcessCmdKey(ref msg, key_data)) {
2636 if (IsInputKey(key_data)) {
2640 return ProcessDialogKey(key_data);
2644 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2645 if (IsInputChar((char)msg.WParam)) {
2648 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
2649 if (IsInputChar((char)msg.WParam)) {
2652 return ProcessDialogChar((char)msg.WParam);
2657 public Rectangle RectangleToClient(Rectangle r) {
2658 return new Rectangle(PointToClient(r.Location), r.Size);
2661 public Rectangle RectangleToScreen(Rectangle r) {
2662 return new Rectangle(PointToScreen(r.Location), r.Size);
2665 public virtual void Refresh() {
2666 if (IsHandleCreated == true) {
2669 XplatUI.UpdateWindow(window.Handle);
2671 Control [] controls = child_controls.GetAllControls ();
2672 for (int i=0; i < controls.Length; i++) {
2673 controls[i].Refresh();
2679 [EditorBrowsable(EditorBrowsableState.Never)]
2680 public virtual void ResetBackColor() {
2681 background_color = Color.Empty;
2684 [EditorBrowsable(EditorBrowsableState.Never)]
2686 public void ResetBindings() {
2690 [EditorBrowsable(EditorBrowsableState.Never)]
2691 public virtual void ResetCursor() {
2695 [EditorBrowsable(EditorBrowsableState.Never)]
2696 public virtual void ResetFont() {
2700 [EditorBrowsable(EditorBrowsableState.Never)]
2701 public virtual void ResetForeColor() {
2702 foreground_color = Color.Empty;
2705 [EditorBrowsable(EditorBrowsableState.Never)]
2706 public void ResetImeMode() {
2707 ime_mode = DefaultImeMode;
2710 [EditorBrowsable(EditorBrowsableState.Never)]
2711 public virtual void ResetRightToLeft() {
2712 right_to_left = RightToLeft.Inherit;
2715 public virtual void ResetText() {
2716 text = String.Empty;
2719 public void ResumeLayout() {
2720 ResumeLayout (true);
2723 public void ResumeLayout(bool performLayout) {
2726 if (layout_suspended > 0) {
2730 if (performLayout || layout_pending) {
2735 public void Scale(float ratio) {
2736 ScaleCore(ratio, ratio);
2739 public void Scale(float dx, float dy) {
2743 public void Select() {
2744 Select(false, false);
2747 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2752 c = GetNextControl(c, forward);
2761 if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
2765 } while (c != ctl); // If we wrap back to ourselves we stop
2770 public void SendToBack() {
2771 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2772 if (parent.child_controls.Contains(this)) {
2773 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2777 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2778 if (parent != null) {
2783 public void SetBounds(int x, int y, int width, int height) {
2784 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2787 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2788 SetBoundsCore(x, y, width, height, specified);
2791 public void Show() {
2792 if (!IsHandleCreated) {
2793 this.CreateControl();
2799 public void SuspendLayout() {
2803 public void Update() {
2804 needs_redraw = true;
2805 if (IsHandleCreated) {
2806 XplatUI.UpdateWindow(window.Handle);
2809 #endregion // Public Instance Methods
2811 #region Protected Instance Methods
2812 [EditorBrowsable(EditorBrowsableState.Advanced)]
2813 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2814 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2815 throw new NotImplementedException();
2818 [EditorBrowsable(EditorBrowsableState.Advanced)]
2819 protected virtual AccessibleObject CreateAccessibilityInstance() {
2820 return new Control.ControlAccessibleObject(this);
2823 [EditorBrowsable(EditorBrowsableState.Advanced)]
2824 protected virtual ControlCollection CreateControlsInstance() {
2825 return new ControlCollection(this);
2828 [EditorBrowsable(EditorBrowsableState.Advanced)]
2829 protected virtual void CreateHandle() {
2831 throw new ObjectDisposedException(Name);
2834 if (IsHandleCreated) {
2838 window.CreateHandle(CreateParams);
2840 // Find out where the window manager placed us
2842 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
2843 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
2847 if (window.Handle!=IntPtr.Zero) {
2848 if (!controls.Contains(window.Handle)) {
2852 creator_thread = Thread.CurrentThread;
2854 OnHandleCreated(EventArgs.Empty);
2858 [EditorBrowsable(EditorBrowsableState.Advanced)]
2859 protected virtual void DefWndProc(ref Message m) {
2860 window.DefWndProc(ref m);
2863 [EditorBrowsable(EditorBrowsableState.Advanced)]
2864 protected virtual void DestroyHandle() {
2865 if (IsHandleCreated) {
2866 // Destroy our children before we destroy ourselves, to prevent them from
2867 // being implictly (without us knowing) destroyed
2868 Control [] controls = child_controls.GetAllControls ();
2869 for (int i=0; i < controls.Length; i++) {
2870 controls[i].DestroyHandle();
2874 if (window != null) {
2875 window.DestroyHandle();
2877 OnHandleDestroyed(EventArgs.Empty);
2881 protected bool GetStyle(ControlStyles flag) {
2882 return (control_style & flag) != 0;
2885 protected bool GetTopLevel() {
2889 [EditorBrowsable(EditorBrowsableState.Advanced)]
2890 protected virtual void InitLayout() {
2891 if (parent != null) {
2892 parent.PerformLayout(this, "parent");
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);
3238 UpdateBounds(x, y, width, height);
3241 [EditorBrowsable(EditorBrowsableState.Advanced)]
3242 protected virtual void SetClientSizeCore(int x, int y) {
3243 // Calculate the actual window size from the client size (it usually stays the same or grows)
3244 Rectangle ClientRect;
3245 Rectangle WindowRect;
3248 ClientRect = new Rectangle(0, 0, x, y);
3249 cp = this.CreateParams;
3251 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
3255 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3258 [EditorBrowsable(EditorBrowsableState.Advanced)]
3259 protected void SetStyle(ControlStyles flag, bool value) {
3261 control_style |= flag;
3263 control_style &= ~flag;
3265 OnStyleChanged(EventArgs.Empty);
3268 protected void SetTopLevel(bool value) {
3269 if ((GetTopLevel() != value) && (parent != null)) {
3270 throw new Exception();
3274 if (value == true) {
3284 is_toplevel = value;
3287 protected virtual void SetVisibleCore(bool value) {
3288 if (value!=is_visible) {
3291 if (IsHandleCreated) {
3292 XplatUI.SetVisible(Handle, value);
3293 // Explicitly move Toplevel windows to where we want them;
3294 // apparently moving unmapped toplevel windows doesn't work
3295 if (is_visible && (this is Form)) {
3296 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3300 OnVisibleChanged(EventArgs.Empty);
3303 if (dc_mem != null) {
3308 if (bmp_mem != null) {
3313 this.CreateBuffers(bounds.Width, bounds.Height);
3317 if (value == false && parent != null) {
3320 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3321 container = (Control)parent.GetContainerControl();
3322 if (container != null) {
3323 container.SelectNextControl(this, true, true, true, true);
3327 if (parent != null) {
3328 parent.PerformLayout(this, "visible");
3330 PerformLayout(this, "visible");
3335 [EditorBrowsable(EditorBrowsableState.Advanced)]
3336 protected void UpdateBounds() {
3344 if (!IsHandleCreated) {
3348 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3350 UpdateBounds(x, y, width, height, client_width, client_height);
3353 [EditorBrowsable(EditorBrowsableState.Advanced)]
3354 protected void UpdateBounds(int x, int y, int width, int height) {
3355 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3357 bool resized = false;
3359 int client_x_diff = this.bounds.Width-this.client_size.Width;
3360 int client_y_diff = this.bounds.Height-this.client_size.Height;
3362 // Needed to generate required notifications
3363 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3367 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3374 bounds.Height=height;
3376 // Update client rectangle as well
3377 if (this.layout_suspended==0) {
3378 prev_size.Width=client_size.Width;
3379 prev_size.Height=client_size.Height;
3382 client_size.Width=width-client_x_diff;
3383 client_size.Height=height-client_y_diff;
3386 OnLocationChanged(EventArgs.Empty);
3390 OnSizeChanged(EventArgs.Empty);
3394 [EditorBrowsable(EditorBrowsableState.Advanced)]
3395 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3396 UpdateBounds(x, y, width, height);
3398 this.client_size.Width=clientWidth;
3399 this.client_size.Height=clientHeight;
3402 [EditorBrowsable(EditorBrowsableState.Advanced)]
3403 protected void UpdateStyles() {
3404 if (!IsHandleCreated) {
3408 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3411 [EditorBrowsable(EditorBrowsableState.Advanced)]
3412 protected void UpdateZOrder() {
3413 Control [] controls;
3417 if (parent == null) {
3423 controls = ctl.child_controls.GetAllControls ();
3424 for (int i = 1; i < controls.Length; i++ ) {
3425 XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
3428 if (!IsHandleCreated) {
3432 controls = child_controls.GetAllControls ();
3433 for (int i = 1; i < controls.Length; i++ ) {
3434 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3439 protected virtual void WndProc(ref Message m) {
3441 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3443 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3447 switch((Msg)m.Msg) {
3448 case Msg.WM_WINDOWPOSCHANGED: {
3451 if (GetStyle(ControlStyles.ResizeRedraw)) {
3458 case Msg.WM_PAINT: {
3459 PaintEventArgs paint_event;
3461 paint_event = XplatUI.PaintEventStart(Handle, true);
3463 if (!needs_redraw) {
3464 // Just blit the previous image
3465 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3466 XplatUI.PaintEventEnd(Handle, true);
3471 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3472 dc = paint_event.SetGraphics (DeviceContext);
3475 if ((control_style & (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) != (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
3476 OnPaintBackground(paint_event);
3479 OnPaint(paint_event);
3481 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3482 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3483 paint_event.SetGraphics (dc);
3484 needs_redraw = false;
3487 XplatUI.PaintEventEnd(Handle, true);
3489 if (!GetStyle(ControlStyles.UserPaint)) {
3496 case Msg.WM_ERASEBKGND: {
3497 if (GetStyle (ControlStyles.UserPaint)) {
3498 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3499 PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
3500 Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
3501 OnPaintBackground (eraseEventArgs);
3504 // The DefWndProc will never have to handle this, we don't ever set hbr on the window
3505 m.Result = (IntPtr)1;
3509 case Msg.WM_LBUTTONUP: {
3510 HandleClick(mouse_clicks);
3511 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3513 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3515 if (mouse_clicks > 1) {
3521 case Msg.WM_LBUTTONDOWN: {
3522 if (CanSelect && !is_selected) {
3525 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3526 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3532 case Msg.WM_LBUTTONDBLCLK: {
3534 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3535 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3541 case Msg.WM_MBUTTONUP: {
3542 HandleClick(mouse_clicks);
3543 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3545 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3547 if (mouse_clicks > 1) {
3553 case Msg.WM_MBUTTONDOWN: {
3554 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3555 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3561 case Msg.WM_MBUTTONDBLCLK: {
3563 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3564 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3569 case Msg.WM_RBUTTONUP: {
3570 if (context_menu != null) {
3571 context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
3574 HandleClick(mouse_clicks);
3575 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3577 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3579 if (mouse_clicks > 1) {
3585 case Msg.WM_RBUTTONDOWN: {
3586 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3587 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3592 case Msg.WM_RBUTTONDBLCLK: {
3594 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3595 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3600 case Msg.WM_MOUSEWHEEL: {
3602 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3603 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3604 HighOrder(m.WParam.ToInt32())));
3609 case Msg.WM_MOUSEMOVE: {
3610 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3612 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3617 case Msg.WM_MOUSE_ENTER: {
3622 OnMouseEnter(EventArgs.Empty);
3626 case Msg.WM_MOUSE_LEAVE: {
3628 OnMouseLeave(EventArgs.Empty);
3632 case Msg.WM_MOUSEHOVER: {
3633 OnMouseHover(EventArgs.Empty);
3637 case Msg.WM_SYSKEYDOWN:
3638 case Msg.WM_KEYDOWN:
3639 case Msg.WM_SYSKEYUP:
3641 case Msg.WM_SYSCHAR:
3643 Console.WriteLine("Got {0}", (Msg)m.Msg);
3644 if (ProcessKeyEventArgs(ref m)) {
3648 if (PreProcessMessage(ref m)) {
3652 if (ProcessKeyMessage(ref m)) {
3661 if (m.LParam != IntPtr.Zero) {
3664 hi = new HELPINFO();
3666 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3667 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3669 mouse_pos = Control.MousePosition;
3671 OnHelpRequested(new HelpEventArgs(mouse_pos));
3672 m.Result = (IntPtr)1;
3676 case Msg.WM_KILLFOCUS: {
3677 OnLeave(EventArgs.Empty);
3678 if (CausesValidation) {
3680 e = new CancelEventArgs(false);
3689 OnValidated(EventArgs.Empty);
3692 this.has_focus = false;
3693 this.is_selected = false;
3694 OnLostFocus(EventArgs.Empty);
3698 case Msg.WM_SETFOCUS: {
3699 OnEnter(EventArgs.Empty);
3700 this.has_focus = true;
3701 OnGotFocus(EventArgs.Empty);
3706 case Msg.WM_SYSCOLORCHANGE: {
3707 ThemeEngine.Current.ResetDefaults();
3708 OnSystemColorsChanged(EventArgs.Empty);
3713 case Msg.WM_SETCURSOR: {
3714 if (cursor == null) {
3719 XplatUI.SetCursor(window.Handle, cursor.handle);
3720 m.Result = (IntPtr)1;
3731 #endregion // Public Instance Methods
3733 #region OnXXX methods
3734 [EditorBrowsable(EditorBrowsableState.Advanced)]
3735 protected virtual void OnBackColorChanged(EventArgs e) {
3736 if (BackColorChanged!=null) BackColorChanged(this, e);
3737 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3740 [EditorBrowsable(EditorBrowsableState.Advanced)]
3741 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3742 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3743 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3746 [EditorBrowsable(EditorBrowsableState.Advanced)]
3747 protected virtual void OnBindingContextChanged(EventArgs e) {
3748 CheckDataBindings ();
3749 if (BindingContextChanged!=null) {
3750 BindingContextChanged(this, e);
3752 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3755 [EditorBrowsable(EditorBrowsableState.Advanced)]
3756 protected virtual void OnCausesValidationChanged(EventArgs e) {
3757 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3760 [EditorBrowsable(EditorBrowsableState.Advanced)]
3761 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3762 if (ChangeUICues!=null) ChangeUICues(this, e);
3765 [EditorBrowsable(EditorBrowsableState.Advanced)]
3766 protected virtual void OnClick(EventArgs e) {
3767 if (Click!=null) Click(this, e);
3770 [EditorBrowsable(EditorBrowsableState.Advanced)]
3771 protected virtual void OnContextMenuChanged(EventArgs e) {
3772 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3775 [EditorBrowsable(EditorBrowsableState.Advanced)]
3776 protected virtual void OnControlAdded(ControlEventArgs e) {
3777 if (ControlAdded!=null) ControlAdded(this, e);
3780 [EditorBrowsable(EditorBrowsableState.Advanced)]
3781 protected virtual void OnControlRemoved(ControlEventArgs e) {
3782 if (ControlRemoved!=null) ControlRemoved(this, e);
3785 [EditorBrowsable(EditorBrowsableState.Advanced)]
3786 protected virtual void OnCreateControl() {
3790 [EditorBrowsable(EditorBrowsableState.Advanced)]
3791 protected virtual void OnCursorChanged(EventArgs e) {
3792 if (CursorChanged!=null) CursorChanged(this, e);
3795 [EditorBrowsable(EditorBrowsableState.Advanced)]
3796 protected virtual void OnDockChanged(EventArgs e) {
3797 if (DockChanged!=null) DockChanged(this, e);
3800 [EditorBrowsable(EditorBrowsableState.Advanced)]
3801 protected virtual void OnDoubleClick(EventArgs e) {
3802 if (DoubleClick!=null) DoubleClick(this, e);
3805 [EditorBrowsable(EditorBrowsableState.Advanced)]
3806 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3807 if (DragDrop!=null) DragDrop(this, drgevent);
3810 [EditorBrowsable(EditorBrowsableState.Advanced)]
3811 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3812 if (DragEnter!=null) DragEnter(this, drgevent);
3815 [EditorBrowsable(EditorBrowsableState.Advanced)]
3816 protected virtual void OnDragLeave(EventArgs e) {
3817 if (DragLeave!=null) DragLeave(this, e);
3820 [EditorBrowsable(EditorBrowsableState.Advanced)]
3821 protected virtual void OnDragOver(DragEventArgs drgevent) {
3822 if (DragOver!=null) DragOver(this, drgevent);
3825 [EditorBrowsable(EditorBrowsableState.Advanced)]
3826 protected virtual void OnEnabledChanged(EventArgs e) {
3827 if (EnabledChanged!=null) EnabledChanged(this, e);
3828 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3831 [EditorBrowsable(EditorBrowsableState.Advanced)]
3832 protected virtual void OnEnter(EventArgs e) {
3833 if (Enter!=null) Enter(this, e);
3836 [EditorBrowsable(EditorBrowsableState.Advanced)]
3837 protected virtual void OnFontChanged(EventArgs e) {
3838 if (FontChanged!=null) FontChanged(this, e);
3839 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3842 [EditorBrowsable(EditorBrowsableState.Advanced)]
3843 protected virtual void OnForeColorChanged(EventArgs e) {
3844 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3845 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3848 [EditorBrowsable(EditorBrowsableState.Advanced)]
3849 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3850 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3853 [EditorBrowsable(EditorBrowsableState.Advanced)]
3854 protected virtual void OnGotFocus(EventArgs e) {
3855 if (GotFocus!=null) GotFocus(this, e);
3858 [EditorBrowsable(EditorBrowsableState.Advanced)]
3859 protected virtual void OnHandleCreated(EventArgs e) {
3860 if (HandleCreated!=null) HandleCreated(this, e);
3863 [EditorBrowsable(EditorBrowsableState.Advanced)]
3864 protected virtual void OnHandleDestroyed(EventArgs e) {
3865 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3868 [EditorBrowsable(EditorBrowsableState.Advanced)]
3869 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3870 if (HelpRequested!=null) HelpRequested(this, hevent);
3873 protected virtual void OnImeModeChanged(EventArgs e) {
3874 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3877 [EditorBrowsable(EditorBrowsableState.Advanced)]
3878 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3879 needs_redraw = true;
3880 if (Invalidated!=null) Invalidated(this, e);
3883 [EditorBrowsable(EditorBrowsableState.Advanced)]
3884 protected virtual void OnKeyDown(KeyEventArgs e) {
3885 if (KeyDown!=null) KeyDown(this, e);
3888 [EditorBrowsable(EditorBrowsableState.Advanced)]
3889 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3890 if (KeyPress!=null) KeyPress(this, e);
3893 [EditorBrowsable(EditorBrowsableState.Advanced)]
3894 protected virtual void OnKeyUp(KeyEventArgs e) {
3895 if (KeyUp!=null) KeyUp(this, e);
3898 [EditorBrowsable(EditorBrowsableState.Advanced)]
3899 protected virtual void OnLayout(LayoutEventArgs levent) {
3900 if (Layout!=null) Layout(this, levent);
3903 [EditorBrowsable(EditorBrowsableState.Advanced)]
3904 protected virtual void OnLeave(EventArgs e) {
3905 if (Leave!=null) Leave(this, e);
3908 [EditorBrowsable(EditorBrowsableState.Advanced)]
3909 protected virtual void OnLocationChanged(EventArgs e) {
3911 if (LocationChanged!=null) LocationChanged(this, e);
3914 [EditorBrowsable(EditorBrowsableState.Advanced)]
3915 protected virtual void OnLostFocus(EventArgs e) {
3916 if (LostFocus!=null) LostFocus(this, e);
3919 [EditorBrowsable(EditorBrowsableState.Advanced)]
3920 protected virtual void OnMouseDown(MouseEventArgs e) {
3921 if (MouseDown!=null) MouseDown(this, e);
3924 [EditorBrowsable(EditorBrowsableState.Advanced)]
3925 protected virtual void OnMouseEnter(EventArgs e) {
3926 if (MouseEnter!=null) MouseEnter(this, e);
3929 [EditorBrowsable(EditorBrowsableState.Advanced)]
3930 protected virtual void OnMouseHover(EventArgs e) {
3931 if (MouseHover!=null) MouseHover(this, e);
3934 [EditorBrowsable(EditorBrowsableState.Advanced)]
3935 protected virtual void OnMouseLeave(EventArgs e) {
3936 if (MouseLeave!=null) MouseLeave(this, e);
3939 [EditorBrowsable(EditorBrowsableState.Advanced)]
3940 protected virtual void OnMouseMove(MouseEventArgs e) {
3941 if (MouseMove!=null) MouseMove(this, e);
3944 [EditorBrowsable(EditorBrowsableState.Advanced)]
3945 protected virtual void OnMouseUp(MouseEventArgs e) {
3946 if (MouseUp!=null) MouseUp(this, e);
3949 [EditorBrowsable(EditorBrowsableState.Advanced)]
3950 protected virtual void OnMouseWheel(MouseEventArgs e) {
3951 if (MouseWheel!=null) MouseWheel(this, e);
3954 [EditorBrowsable(EditorBrowsableState.Advanced)]
3955 protected virtual void OnMove(EventArgs e) {
3956 if (Move!=null) Move(this, e);
3959 [EditorBrowsable(EditorBrowsableState.Advanced)]
3960 protected virtual void OnNotifyMessage(Message m) {
3964 [EditorBrowsable(EditorBrowsableState.Advanced)]
3965 protected virtual void OnPaint(PaintEventArgs e) {
3966 if (Paint!=null) Paint(this, e);
3969 [EditorBrowsable(EditorBrowsableState.Advanced)]
3970 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3971 PaintControlBackground (pevent);
3974 [EditorBrowsable(EditorBrowsableState.Advanced)]
3975 protected virtual void OnParentBackColorChanged(EventArgs e) {
3976 if (background_color.IsEmpty && background_image==null) {
3978 OnBackColorChanged(e);
3982 [EditorBrowsable(EditorBrowsableState.Advanced)]
3983 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3984 if (background_color.IsEmpty && background_image==null) {
3986 OnBackgroundImageChanged(e);
3990 [EditorBrowsable(EditorBrowsableState.Advanced)]
3991 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3992 if (binding_context==null) {
3993 binding_context=Parent.binding_context;
3994 OnBindingContextChanged(e);
3998 [EditorBrowsable(EditorBrowsableState.Advanced)]
3999 protected virtual void OnParentChanged(EventArgs e) {
4000 if (ParentChanged!=null) ParentChanged(this, e);
4003 [EditorBrowsable(EditorBrowsableState.Advanced)]
4004 protected virtual void OnParentEnabledChanged(EventArgs e) {
4005 if (is_enabled != Parent.is_enabled) {
4006 is_enabled=Parent.is_enabled;
4008 if (EnabledChanged != null) {
4009 EnabledChanged(this, e);
4014 [EditorBrowsable(EditorBrowsableState.Advanced)]
4015 protected virtual void OnParentFontChanged(EventArgs e) {
4022 [EditorBrowsable(EditorBrowsableState.Advanced)]
4023 protected virtual void OnParentForeColorChanged(EventArgs e) {
4024 if (foreground_color.IsEmpty) {
4026 OnForeColorChanged(e);
4030 [EditorBrowsable(EditorBrowsableState.Advanced)]
4031 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4032 if (right_to_left==RightToLeft.Inherit) {
4034 OnRightToLeftChanged(e);
4038 [EditorBrowsable(EditorBrowsableState.Advanced)]
4039 protected virtual void OnParentVisibleChanged(EventArgs e) {
4041 OnVisibleChanged(e);
4045 [EditorBrowsable(EditorBrowsableState.Advanced)]
4046 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4047 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
4050 [EditorBrowsable(EditorBrowsableState.Advanced)]
4051 protected virtual void OnResize(EventArgs e) {
4052 if (Resize!=null) Resize(this, e);
4054 PerformLayout(this, "bounds");
4056 if (parent != null) {
4057 parent.PerformLayout();
4061 [EditorBrowsable(EditorBrowsableState.Advanced)]
4062 protected virtual void OnRightToLeftChanged(EventArgs e) {
4063 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
4064 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4067 [EditorBrowsable(EditorBrowsableState.Advanced)]
4068 protected virtual void OnSizeChanged(EventArgs e) {
4069 InvalidateBuffers ();
4071 if (SizeChanged!=null) SizeChanged(this, e);
4074 [EditorBrowsable(EditorBrowsableState.Advanced)]
4075 protected virtual void OnStyleChanged(EventArgs e) {
4076 if (StyleChanged!=null) StyleChanged(this, e);
4079 [EditorBrowsable(EditorBrowsableState.Advanced)]
4080 protected virtual void OnSystemColorsChanged(EventArgs e) {
4081 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
4084 [EditorBrowsable(EditorBrowsableState.Advanced)]
4085 protected virtual void OnTabIndexChanged(EventArgs e) {
4086 if (TabIndexChanged!=null) TabIndexChanged(this, e);
4089 [EditorBrowsable(EditorBrowsableState.Advanced)]
4090 protected virtual void OnTabStopChanged(EventArgs e) {
4091 if (TabStopChanged!=null) TabStopChanged(this, e);
4094 [EditorBrowsable(EditorBrowsableState.Advanced)]
4095 protected virtual void OnTextChanged(EventArgs e) {
4096 if (TextChanged!=null) TextChanged(this, e);
4099 [EditorBrowsable(EditorBrowsableState.Advanced)]
4100 protected virtual void OnValidated(EventArgs e) {
4101 if (Validated!=null) Validated(this, e);
4104 [EditorBrowsable(EditorBrowsableState.Advanced)]
4105 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4106 if (Validating!=null) Validating(this, e);
4109 [EditorBrowsable(EditorBrowsableState.Advanced)]
4110 protected virtual void OnVisibleChanged(EventArgs e) {
4117 if (bmp_mem!=null) {
4123 if (!this.IsHandleCreated) {
4124 this.CreateControl();
4130 if (VisibleChanged!=null) VisibleChanged(this, e);
4132 // We need to tell our kids
4133 for (int i=0; i<child_controls.Count; i++) {
4134 child_controls[i].OnParentVisibleChanged(e);
4137 #endregion // OnXXX methods
4140 public event EventHandler BackColorChanged;
4141 public event EventHandler BackgroundImageChanged;
4142 public event EventHandler BindingContextChanged;
4143 public event EventHandler CausesValidationChanged;
4144 public event UICuesEventHandler ChangeUICues;
4145 public event EventHandler Click;
4146 public event EventHandler ContextMenuChanged;
4148 [EditorBrowsable(EditorBrowsableState.Advanced)]
4150 public event ControlEventHandler ControlAdded;
4152 [EditorBrowsable(EditorBrowsableState.Advanced)]
4154 public event ControlEventHandler ControlRemoved;
4156 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4157 public event EventHandler CursorChanged;
4158 public event EventHandler DockChanged;
4159 public event EventHandler DoubleClick;
4160 public event DragEventHandler DragDrop;
4161 public event DragEventHandler DragEnter;
4162 public event EventHandler DragLeave;
4163 public event DragEventHandler DragOver;
4164 public event EventHandler EnabledChanged;
4165 public event EventHandler Enter;
4166 public event EventHandler FontChanged;
4167 public event EventHandler ForeColorChanged;
4168 public event GiveFeedbackEventHandler GiveFeedback;
4170 [EditorBrowsable(EditorBrowsableState.Advanced)]
4172 public event EventHandler GotFocus;
4174 [EditorBrowsable(EditorBrowsableState.Advanced)]
4176 public event EventHandler HandleCreated;
4178 [EditorBrowsable(EditorBrowsableState.Advanced)]
4180 public event EventHandler HandleDestroyed;
4182 public event HelpEventHandler HelpRequested;
4183 public event EventHandler ImeModeChanged;
4185 [EditorBrowsable(EditorBrowsableState.Advanced)]
4187 public event InvalidateEventHandler Invalidated;
4189 public event KeyEventHandler KeyDown;
4190 public event KeyPressEventHandler KeyPress;
4191 public event KeyEventHandler KeyUp;
4192 public event LayoutEventHandler Layout;
4193 public event EventHandler Leave;
4194 public event EventHandler LocationChanged;
4196 [EditorBrowsable(EditorBrowsableState.Advanced)]
4198 public event EventHandler LostFocus;
4200 public event MouseEventHandler MouseDown;
4201 public event EventHandler MouseEnter;
4202 public event EventHandler MouseHover;
4203 public event EventHandler MouseLeave;
4204 public event MouseEventHandler MouseMove;
4205 public event MouseEventHandler MouseUp;
4207 [EditorBrowsable(EditorBrowsableState.Advanced)]
4209 public event MouseEventHandler MouseWheel;
4211 public event EventHandler Move;
4212 public event PaintEventHandler Paint;
4213 public event EventHandler ParentChanged;
4214 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
4215 public event QueryContinueDragEventHandler QueryContinueDrag;
4216 public event EventHandler Resize;
4217 public event EventHandler RightToLeftChanged;
4218 public event EventHandler SizeChanged;
4219 public event EventHandler StyleChanged;
4220 public event EventHandler SystemColorsChanged;
4221 public event EventHandler TabIndexChanged;
4222 public event EventHandler TabStopChanged;
4223 public event EventHandler TextChanged;
4224 public event EventHandler Validated;
4225 public event CancelEventHandler Validating;
4226 public event EventHandler VisibleChanged;
4227 #endregion // Events