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;
658 control_style = ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick;
661 background_image = null;
665 window = new ControlNativeWindow(this);
666 child_controls = CreateControlsInstance();
667 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
668 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
669 XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, CreateParams.ExStyle, IntPtr.Zero, out bounds);
670 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
676 public Control(Control parent, string text) : this() {
681 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
686 bounds.Height=height;
687 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
691 public Control(string text) : this() {
695 public Control(string text, int left, int top, int width, int height) : this() {
699 bounds.Height=height;
700 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
704 protected override void Dispose(bool disposing) {
717 controls.Remove(this);
719 #endregion // Public Constructors
721 #region Internal Properties
722 internal BorderStyle InternalBorderStyle {
728 if (border_style != value) {
729 border_style = value;
732 XplatUI.SetBorderStyle(window.Handle,
737 #endregion // Internal Properties
739 #region Private & Internal Methods
740 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
741 AsyncMethodResult result;
742 AsyncMethodData data;
747 if (!p.IsHandleCreated) {
748 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
753 result = new AsyncMethodResult ();
754 data = new AsyncMethodData ();
756 data.Method = method;
758 data.Result = new WeakReference (result);
761 if (!ExecutionContext.IsFlowSuppressed ()) {
762 data.Context = ExecutionContext.Capture ();
765 #if !MWF_ON_MSRUNTIME
766 if (SecurityManager.SecurityEnabled) {
767 data.Stack = CompressedStack.GetCompressedStack ();
772 XplatUI.SendAsyncMethod (data);
776 internal Graphics DeviceContext {
779 CreateBuffers(this.Width, this.Height);
785 private Bitmap ImageBuffer {
788 CreateBuffers(this.Width, this.Height);
794 internal void CreateBuffers (int width, int height) {
795 if (dc_mem != null) {
809 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
810 dc_mem = Graphics.FromImage (bmp_mem);
814 internal void InvalidateBuffers ()
816 if (dc_mem != null) {
827 internal static void SetChildColor(Control parent) {
830 for (int i=0; i < parent.child_controls.Count; i++) {
831 child=parent.child_controls[i];
832 if (child.IsHandleCreated) {
833 if (!child.GetStyle (ControlStyles.UserPaint)) {
834 XplatUI.SetWindowBackground(child.window.Handle, child.BackColor);
837 if (child.child_controls.Count>0) {
838 SetChildColor(child);
844 internal bool Select(Control control) {
846 IContainerControl container;
848 if (control == null) {
852 parent = control.parent;
854 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
855 while (parent != null) {
856 if (!parent.Visible || !parent.is_enabled) {
859 parent = parent.parent;
863 control.is_selected = true;
865 container = GetContainerControl();
866 if (container != null) {
867 container.ActiveControl = control;
869 if (control.IsHandleCreated) {
870 XplatUI.SetFocus(control.window.Handle);
875 internal virtual void DoDefaultAction() {
876 // Only here to be overriden by our actual controls; this is needed by the accessibility class
879 internal static int LowOrder (int param) {
880 return ((int)(short)(param & 0xffff));
883 internal static int HighOrder (int param) {
884 return ((int)(short)(param >> 16));
887 // This method exists so controls overriding OnPaintBackground can have default background painting done
888 internal void PaintControlBackground (PaintEventArgs pevent)
890 if (background_image == null)
893 DrawBackgroundImage (pevent.Graphics);
896 void DrawBackgroundImage (Graphics g)
898 using (TextureBrush b = new TextureBrush (background_image)) {
899 g.FillRectangle (b, ClientRectangle);
903 internal void DndEnter (DragEventArgs e)
908 internal void DndOver (DragEventArgs e)
913 internal void DndDrop (DragEventArgs e)
918 internal void DndLeave (EventArgs e)
923 internal void DnDFeedback(GiveFeedbackEventArgs e)
928 internal void DnDContinueDrag(QueryContinueDragEventArgs e) {
929 OnQueryContinueDrag(e);
932 internal static MouseButtons FromParamToMouseButtons (int param) {
933 MouseButtons buttons = MouseButtons.None;
935 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
936 buttons |= MouseButtons.Left;
938 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
939 buttons |= MouseButtons.Middle;
941 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
942 buttons |= MouseButtons.Right;
948 internal virtual bool ProcessControlMnemonic(char charCode) {
949 return ProcessMnemonic(charCode);
952 private static Control FindFlatForward(Control container, Control start) {
958 end = container.child_controls.Count;
961 index = start.tab_index;
966 for (int i = 0; i < end; i++) {
968 if (container.child_controls[i].tab_index > index) {
969 found = container.child_controls[i];
971 } else if (found.tab_index > container.child_controls[i].tab_index) {
972 if (container.child_controls[i].tab_index > index) {
973 found = container.child_controls[i];
980 private static Control FindControlForward(Control container, Control start) {
987 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
988 found = FindControlForward(start, null);
995 while (p != container) {
996 found = FindFlatForward(p, start);
1004 return FindFlatForward(container, start);
1007 private static Control FindFlatBackward(Control container, Control start) {
1013 end = container.child_controls.Count;
1015 if (start != null) {
1016 index = start.tab_index;
1018 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1020 for (int i = 0; i < end; i++) {
1021 if (container.child_controls[i].tab_index > index) {
1022 index = container.child_controls[i].tab_index;
1028 for (int i = 0; i < end; i++) {
1029 if (found == null) {
1030 if (container.child_controls[i].tab_index < index) {
1031 found = container.child_controls[i];
1033 } else if (found.tab_index < container.child_controls[i].tab_index) {
1034 if (container.child_controls[i].tab_index < index) {
1035 found = container.child_controls[i];
1042 private static Control FindControlBackward(Control container, Control start) {
1047 if (start != null) {
1048 found = FindFlatBackward(start.parent, start);
1049 if (found == null && start.parent != container) {
1050 return start.parent;
1053 if (found == null) {
1054 found = FindFlatBackward(container, start);
1057 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
1058 found = FindControlBackward(found, null);
1059 if (found != null) {
1067 private void HandleClick(int clicks) {
1068 if (GetStyle(ControlStyles.StandardClick)) {
1070 if (GetStyle(ControlStyles.StandardDoubleClick)) {
1071 OnDoubleClick(EventArgs.Empty);
1073 OnClick(EventArgs.Empty);
1076 OnClick(EventArgs.Empty);
1081 private void CheckDataBindings ()
1083 if (data_bindings == null)
1086 BindingContext binding_context = BindingContext;
1087 foreach (Binding binding in data_bindings) {
1088 binding.Check (binding_context);
1092 #endregion // Private & Internal Methods
1094 #region Public Static Properties
1095 public static Color DefaultBackColor {
1097 return ThemeEngine.Current.DefaultControlBackColor;
1101 public static Font DefaultFont {
1103 return ThemeEngine.Current.DefaultFont;
1107 public static Color DefaultForeColor {
1109 return ThemeEngine.Current.DefaultControlForeColor;
1113 public static Keys ModifierKeys {
1115 return XplatUI.State.ModifierKeys;
1119 public static MouseButtons MouseButtons {
1121 return XplatUI.State.MouseButtons;
1125 public static Point MousePosition {
1127 return Cursor.Position;
1133 public static bool CheckForIllegalCrossThreadCalls
1142 #endregion // Public Static Properties
1144 #region Public Instance Properties
1145 [EditorBrowsable(EditorBrowsableState.Advanced)]
1147 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1148 public AccessibleObject AccessibilityObject {
1150 if (accessibility_object==null) {
1151 accessibility_object=CreateAccessibilityInstance();
1153 return accessibility_object;
1157 [EditorBrowsable(EditorBrowsableState.Advanced)]
1159 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1160 public string AccessibleDefaultActionDescription {
1162 return AccessibilityObject.default_action;
1166 AccessibilityObject.default_action=value;
1171 [DefaultValue(null)]
1172 public string AccessibleDescription {
1174 return AccessibilityObject.description;
1178 AccessibilityObject.description=value;
1183 [DefaultValue(null)]
1184 public string AccessibleName {
1186 return AccessibilityObject.Name;
1190 AccessibilityObject.Name=value;
1194 [DefaultValue(AccessibleRole.Default)]
1195 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1196 public AccessibleRole AccessibleRole {
1198 return AccessibilityObject.role;
1202 AccessibilityObject.role=value;
1206 [DefaultValue(false)]
1207 public virtual bool AllowDrop {
1213 if (allow_drop == value)
1217 XplatUI.SetAllowDrop (Handle, value);
1222 [RefreshProperties(RefreshProperties.Repaint)]
1223 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1224 public virtual AnchorStyles Anchor {
1226 return anchor_style;
1232 if (parent != null) {
1233 parent.PerformLayout(this, "Parent");
1239 public virtual Color BackColor {
1241 if (background_color.IsEmpty) {
1243 return parent.BackColor;
1245 return DefaultBackColor;
1247 return background_color;
1251 background_color=value;
1252 if (this.IsHandleCreated && !GetStyle (ControlStyles.UserPaint)) {
1253 XplatUI.SetWindowBackground(this.window.Handle, value);
1255 SetChildColor(this);
1256 OnBackColorChanged(EventArgs.Empty);
1262 [DefaultValue(null)]
1263 public virtual Image BackgroundImage {
1265 return background_image;
1269 if (background_image!=value) {
1270 background_image=value;
1271 OnBackgroundImageChanged(EventArgs.Empty);
1276 [EditorBrowsable(EditorBrowsableState.Advanced)]
1278 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1279 public virtual BindingContext BindingContext {
1281 if (binding_context != null)
1282 return binding_context;
1285 binding_context = Parent.BindingContext;
1286 return binding_context;
1289 if (binding_context != value) {
1290 binding_context = value;
1291 OnBindingContextChanged(EventArgs.Empty);
1296 [EditorBrowsable(EditorBrowsableState.Advanced)]
1298 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1301 return bounds.Y+bounds.Height;
1305 [EditorBrowsable(EditorBrowsableState.Advanced)]
1307 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1308 public Rectangle Bounds {
1314 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1318 [EditorBrowsable(EditorBrowsableState.Advanced)]
1320 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1321 public bool CanFocus {
1323 if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1330 [EditorBrowsable(EditorBrowsableState.Advanced)]
1332 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1333 public bool CanSelect {
1337 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1341 parent = this.parent;
1342 while (parent != null) {
1343 if (!parent.is_visible || !parent.is_enabled) {
1347 parent = parent.parent;
1353 [EditorBrowsable(EditorBrowsableState.Advanced)]
1355 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1356 public bool Capture {
1358 return this.is_captured;
1362 if (this.IsHandleCreated) {
1363 if (value && !is_captured) {
1365 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1366 } else if (!value && is_captured) {
1367 XplatUI.UngrabWindow(this.window.Handle);
1368 is_captured = false;
1374 [DefaultValue(true)]
1375 public bool CausesValidation {
1377 return this.causes_validation;
1381 if (this.causes_validation != value) {
1382 causes_validation = value;
1383 OnCausesValidationChanged(EventArgs.Empty);
1388 [EditorBrowsable(EditorBrowsableState.Advanced)]
1390 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1391 public Rectangle ClientRectangle {
1393 client_rect.Width = client_size.Width;
1394 client_rect.Height = client_size.Height;
1399 [EditorBrowsable(EditorBrowsableState.Advanced)]
1401 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1402 public Size ClientSize {
1405 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1406 return ((Form)this).form_parent_window.ClientSize;
1414 this.SetClientSizeCore(value.Width, value.Height);
1418 [EditorBrowsable(EditorBrowsableState.Advanced)]
1420 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1421 [DescriptionAttribute("ControlCompanyNameDescr")]
1422 public String CompanyName {
1424 return "Mono Project, Novell, Inc.";
1428 [EditorBrowsable(EditorBrowsableState.Advanced)]
1430 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1431 public bool ContainsFocus {
1437 for (int i=0; i < child_controls.Count; i++) {
1438 if (child_controls[i].ContainsFocus) {
1446 [DefaultValue(null)]
1447 public virtual ContextMenu ContextMenu {
1449 return context_menu;
1453 if (context_menu != value) {
1454 context_menu = value;
1455 OnContextMenuChanged(EventArgs.Empty);
1461 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1462 public ControlCollection Controls {
1464 return this.child_controls;
1468 [EditorBrowsable(EditorBrowsableState.Advanced)]
1470 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1471 public bool Created {
1473 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1480 [AmbientValue(null)]
1481 public virtual Cursor Cursor {
1483 if (cursor != null) {
1487 if (parent != null) {
1488 return parent.Cursor;
1491 return Cursors.Default;
1495 if (cursor != value) {
1500 pt = Cursor.Position;
1501 if (bounds.Contains(pt)) {
1502 if (GetChildAtPoint(pt) == null) {
1503 if (cursor != null) {
1504 XplatUI.SetCursor(window.Handle, cursor.handle);
1506 if (parent != null) {
1507 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1509 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1515 OnCursorChanged(EventArgs.Empty);
1521 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1522 [ParenthesizePropertyName(true)]
1523 [RefreshProperties(RefreshProperties.All)]
1524 public ControlBindingsCollection DataBindings {
1526 if (data_bindings == null)
1527 data_bindings = new ControlBindingsCollection (this);
1528 return data_bindings;
1532 [EditorBrowsable(EditorBrowsableState.Advanced)]
1534 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1535 public virtual Rectangle DisplayRectangle {
1537 return ClientRectangle;
1541 [EditorBrowsable(EditorBrowsableState.Advanced)]
1543 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1544 public bool Disposing {
1551 [RefreshProperties(RefreshProperties.Repaint)]
1552 [DefaultValue(DockStyle.None)]
1553 public virtual DockStyle Dock {
1559 if (dock_style == value) {
1565 if (parent != null) {
1566 parent.PerformLayout(this, "Parent");
1569 OnDockChanged(EventArgs.Empty);
1575 public bool Enabled {
1581 if (is_enabled == value) {
1587 OnEnabledChanged (EventArgs.Empty);
1591 [EditorBrowsable(EditorBrowsableState.Advanced)]
1593 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1594 public virtual bool Focused {
1596 return this.has_focus;
1601 [AmbientValue(null)]
1603 public virtual Font Font {
1609 if (Parent != null && Parent.Font != null) {
1617 if (font != null && font.Equals (value)) {
1623 OnFontChanged (EventArgs.Empty);
1628 public virtual Color ForeColor {
1630 if (foreground_color.IsEmpty) {
1632 return parent.ForeColor;
1634 return DefaultForeColor;
1636 return foreground_color;
1640 if (foreground_color != value) {
1641 foreground_color=value;
1643 OnForeColorChanged(EventArgs.Empty);
1650 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1651 public IntPtr Handle { // IWin32Window
1653 if (!IsHandleCreated) {
1656 return window.Handle;
1660 [EditorBrowsable(EditorBrowsableState.Advanced)]
1662 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1663 public bool HasChildren {
1665 if (this.child_controls.Count>0) {
1672 [EditorBrowsable(EditorBrowsableState.Always)]
1674 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1677 return this.bounds.Height;
1681 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1685 [AmbientValue(ImeMode.Inherit)]
1687 public ImeMode ImeMode {
1689 if (ime_mode == DefaultImeMode) {
1691 return parent.ImeMode;
1693 return ImeMode.NoControl; // default value
1699 if (ime_mode != value) {
1702 OnImeModeChanged(EventArgs.Empty);
1707 [EditorBrowsable(EditorBrowsableState.Advanced)]
1709 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1710 public bool InvokeRequired { // ISynchronizeInvoke
1712 if (creator_thread!=Thread.CurrentThread) {
1719 [EditorBrowsable(EditorBrowsableState.Advanced)]
1721 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1722 public bool IsAccessible {
1724 return is_accessible;
1728 is_accessible = value;
1732 [EditorBrowsable(EditorBrowsableState.Advanced)]
1734 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1735 public bool IsDisposed {
1737 return this.is_disposed;
1741 [EditorBrowsable(EditorBrowsableState.Advanced)]
1743 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1744 public bool IsHandleCreated {
1746 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1754 [EditorBrowsable(EditorBrowsableState.Always)]
1756 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1759 return this.bounds.X;
1763 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1768 public Point Location {
1770 return new Point(bounds.X, bounds.Y);
1774 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1779 public string Name {
1790 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1791 public Control Parent {
1797 if (value == this) {
1798 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1801 if (parent!=value) {
1803 parent.Controls.Remove(this);
1809 if (!parent.Controls.AllContains (this)) {
1810 Console.WriteLine ("Adding child: " + this);
1811 parent.Controls.Add(this);
1814 if (IsHandleCreated) {
1815 XplatUI.SetParent(Handle, value.Handle);
1818 OnParentChanged(EventArgs.Empty);
1824 [EditorBrowsable(EditorBrowsableState.Advanced)]
1826 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1827 public string ProductName {
1829 Type t = typeof (AssemblyProductAttribute);
1830 Assembly assembly = GetType().Module.Assembly;
1831 object [] attrs = assembly.GetCustomAttributes (t, false);
1832 AssemblyProductAttribute a = null;
1833 // On MS we get a NullRefException if product attribute is not
1835 if (attrs != null && attrs.Length > 0)
1836 a = (AssemblyProductAttribute) attrs [0];
1841 [EditorBrowsable(EditorBrowsableState.Advanced)]
1843 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1844 public string ProductVersion {
1846 Type t = typeof (AssemblyVersionAttribute);
1847 Assembly assembly = GetType().Module.Assembly;
1848 object [] attrs = assembly.GetCustomAttributes (t, false);
1849 if (attrs == null || attrs.Length < 1)
1851 return ((AssemblyVersionAttribute)attrs [0]).Version;
1855 [EditorBrowsable(EditorBrowsableState.Advanced)]
1857 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1858 public bool RecreatingHandle {
1860 return is_recreating;
1864 [EditorBrowsable(EditorBrowsableState.Advanced)]
1866 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1867 public Region Region {
1869 return new Region(this.bounds);
1876 g = this.CreateGraphics();
1877 r = value.GetBounds(g);
1879 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1885 [EditorBrowsable(EditorBrowsableState.Advanced)]
1887 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1890 return this.bounds.X+this.bounds.Width;
1894 [AmbientValue(RightToLeft.Inherit)]
1896 public virtual RightToLeft RightToLeft {
1898 if (right_to_left == RightToLeft.Inherit) {
1900 return parent.RightToLeft;
1902 return RightToLeft.No; // default value
1904 return right_to_left;
1908 if (value != right_to_left) {
1909 right_to_left = value;
1910 OnRightToLeftChanged(EventArgs.Empty);
1915 [EditorBrowsable(EditorBrowsableState.Advanced)]
1916 public override ISite Site {
1929 return new Size(Width, Height);
1933 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1938 [MergableProperty(false)]
1939 public int TabIndex {
1941 if (tab_index != -1) {
1948 if (tab_index != value) {
1950 OnTabIndexChanged(EventArgs.Empty);
1956 [DefaultValue(true)]
1957 public bool TabStop {
1963 if (tab_stop != value) {
1965 OnTabStopChanged(EventArgs.Empty);
1970 [Localizable(false)]
1972 [TypeConverter(typeof(StringConverter))]
1973 [DefaultValue(null)]
1980 control_tag = value;
1986 [BindableAttribute(true)]
1987 public virtual string Text {
1993 if (value == null) {
1994 value = String.Empty;
1999 if (IsHandleCreated) {
2000 XplatUI.Text(Handle, text);
2002 // FIXME: Do we need a Refresh() here?
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
2844 if (window.Handle!=IntPtr.Zero) {
2845 if (!controls.Contains(window.Handle)) {
2849 creator_thread = Thread.CurrentThread;
2851 if (!GetStyle (ControlStyles.UserPaint)) {
2852 XplatUI.SetWindowBackground(window.Handle, this.BackColor);
2855 OnHandleCreated(EventArgs.Empty);
2859 [EditorBrowsable(EditorBrowsableState.Advanced)]
2860 protected virtual void DefWndProc(ref Message m) {
2861 window.DefWndProc(ref m);
2864 [EditorBrowsable(EditorBrowsableState.Advanced)]
2865 protected virtual void DestroyHandle() {
2866 if (IsHandleCreated) {
2867 // Destroy our children before we destroy ourselves, to prevent them from
2868 // being implictly (without us knowing) destroyed
2869 Control [] controls = child_controls.GetAllControls ();
2870 for (int i=0; i < controls.Length; i++) {
2871 controls[i].DestroyHandle();
2875 if (window != null) {
2876 window.DestroyHandle();
2878 OnHandleDestroyed(EventArgs.Empty);
2882 protected bool GetStyle(ControlStyles flag) {
2883 return (control_style & flag) != 0;
2886 protected bool GetTopLevel() {
2890 [EditorBrowsable(EditorBrowsableState.Advanced)]
2891 protected virtual void InitLayout() {
2892 if (parent != null) {
2893 parent.PerformLayout(this, "parent");
2897 [EditorBrowsable(EditorBrowsableState.Advanced)]
2898 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2899 toInvoke.OnGotFocus(e);
2902 [EditorBrowsable(EditorBrowsableState.Advanced)]
2903 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2904 toInvoke.OnLostFocus(e);
2907 [EditorBrowsable(EditorBrowsableState.Advanced)]
2908 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2909 toInvoke.OnClick(e);
2912 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2913 toInvoke.OnPaint(e);
2916 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2917 toInvoke.OnPaintBackground(e);
2920 protected virtual bool IsInputChar (char charCode) {
2921 if (parent != null) {
2922 return parent.IsInputChar(charCode);
2928 protected virtual bool IsInputKey (Keys keyData) {
2929 // Doc says this one calls IsInputChar; not sure what to do with that
2933 [EditorBrowsable(EditorBrowsableState.Advanced)]
2934 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2938 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2939 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2943 if (parent != null) {
2944 return parent.ProcessCmdKey(ref msg, keyData);
2950 protected virtual bool ProcessDialogChar(char charCode) {
2951 if (parent != null) {
2952 return parent.ProcessDialogChar (charCode);
2958 protected virtual bool ProcessDialogKey (Keys keyData) {
2959 if (parent != null) {
2960 return parent.ProcessDialogKey (keyData);
2966 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2968 KeyEventArgs key_event;
2971 case (int)Msg.WM_KEYDOWN: {
2972 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2973 OnKeyDown (key_event);
2974 return key_event.Handled;
2976 case (int)Msg.WM_KEYUP: {
2977 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2978 OnKeyUp (key_event);
2979 return key_event.Handled;
2982 case (int)Msg.WM_CHAR: {
2983 KeyPressEventArgs key_press_event;
2985 key_press_event = new KeyPressEventArgs((char)msg.WParam);
2986 OnKeyPress(key_press_event);
2987 return key_press_event.Handled;
2998 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
2999 if (parent != null) {
3000 if (parent.ProcessKeyPreview(ref msg)) {
3008 protected virtual bool ProcessKeyPreview(ref Message msg) {
3009 if (parent != null) {
3010 return parent.ProcessKeyPreview(ref msg);
3016 protected virtual bool ProcessMnemonic(char charCode) {
3021 [EditorBrowsable(EditorBrowsableState.Advanced)]
3022 protected void RaiseDragEvent(object key, DragEventArgs e) {
3026 [EditorBrowsable(EditorBrowsableState.Advanced)]
3027 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3031 [EditorBrowsable(EditorBrowsableState.Advanced)]
3032 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3036 [EditorBrowsable(EditorBrowsableState.Advanced)]
3037 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3041 [EditorBrowsable(EditorBrowsableState.Advanced)]
3042 protected void RecreateHandle() {
3043 IEnumerator child = child_controls.GetAllEnumerator();
3047 if (IsHandleCreated) {
3053 while (child.MoveNext()) {
3054 ((Control)child.Current).RecreateHandle();
3060 is_recreating = false;
3063 [EditorBrowsable(EditorBrowsableState.Advanced)]
3064 protected void ResetMouseEventArgs() {
3068 [EditorBrowsable(EditorBrowsableState.Advanced)]
3069 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3070 if (right_to_left == RightToLeft.No) {
3075 case ContentAlignment.TopLeft: {
3076 return ContentAlignment.TopRight;
3079 case ContentAlignment.TopRight: {
3080 return ContentAlignment.TopLeft;
3083 case ContentAlignment.MiddleLeft: {
3084 return ContentAlignment.MiddleRight;
3087 case ContentAlignment.MiddleRight: {
3088 return ContentAlignment.MiddleLeft;
3091 case ContentAlignment.BottomLeft: {
3092 return ContentAlignment.BottomRight;
3095 case ContentAlignment.BottomRight: {
3096 return ContentAlignment.BottomLeft;
3100 // if it's center it doesn't change
3106 [EditorBrowsable(EditorBrowsableState.Advanced)]
3107 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3108 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3112 if (align == HorizontalAlignment.Left) {
3113 return HorizontalAlignment.Right;
3116 // align must be HorizontalAlignment.Right
3117 return HorizontalAlignment.Left;
3120 [EditorBrowsable(EditorBrowsableState.Advanced)]
3121 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3122 if (right_to_left == RightToLeft.No) {
3126 if (align == LeftRightAlignment.Left) {
3127 return LeftRightAlignment.Right;
3130 // align must be LeftRightAlignment.Right;
3131 return LeftRightAlignment.Left;
3134 [EditorBrowsable(EditorBrowsableState.Advanced)]
3135 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3136 return RtlTranslateAlignment(align);
3139 [EditorBrowsable(EditorBrowsableState.Advanced)]
3140 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3141 return RtlTranslateAlignment(align);
3144 [EditorBrowsable(EditorBrowsableState.Advanced)]
3145 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3146 return RtlTranslateAlignment(align);
3149 [EditorBrowsable(EditorBrowsableState.Advanced)]
3150 protected virtual void ScaleCore(float dx, float dy) {
3156 location = new Point((int)(Left * dx), (int)(Top * dy));
3157 size = this.ClientSize;
3160 if (!GetStyle(ControlStyles.FixedWidth)) {
3161 size.Width = (int)(size.Width * dx);
3164 if (!GetStyle(ControlStyles.FixedHeight)) {
3165 size.Height = (int)(size.Height * dy);
3168 Location = location;
3171 /* Now scale our children */
3172 Control [] controls = child_controls.GetAllControls ();
3173 for (int i=0; i < controls.Length; i++) {
3174 controls[i].Scale(dx, dy);
3180 protected virtual void Select(bool directed, bool forward) {
3185 // Select this control
3190 if (parent == null) {
3194 // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
3196 index = parent.child_controls.IndexOf(this);
3201 if ((index+1) < parent.child_controls.Count) {
3210 index = parent.child_controls.Count-1;
3213 result = Select(parent.child_controls[index]);
3214 } while (!result && parent.child_controls[index] != this);
3217 [EditorBrowsable(EditorBrowsableState.Advanced)]
3218 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3219 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3220 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3224 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3228 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3232 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3236 if (IsHandleCreated) {
3237 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 if (this.layout_suspended==0) {
3379 prev_size.Width=client_size.Width;
3380 prev_size.Height=client_size.Height;
3383 client_size.Width=width-client_x_diff;
3384 client_size.Height=height-client_y_diff;
3387 OnLocationChanged(EventArgs.Empty);
3391 OnSizeChanged(EventArgs.Empty);
3395 [EditorBrowsable(EditorBrowsableState.Advanced)]
3396 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3397 UpdateBounds(x, y, width, height);
3399 this.client_size.Width=clientWidth;
3400 this.client_size.Height=clientHeight;
3403 [EditorBrowsable(EditorBrowsableState.Advanced)]
3404 protected void UpdateStyles() {
3405 if (!IsHandleCreated) {
3409 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3412 [EditorBrowsable(EditorBrowsableState.Advanced)]
3413 protected void UpdateZOrder() {
3414 Control [] controls;
3418 if (parent == null) {
3424 controls = ctl.child_controls.GetAllControls ();
3425 for (int i = 1; i < controls.Length; i++ ) {
3426 XplatUI.SetZOrder(controls[i].window.Handle, controls[i-1].window.Handle, false, false);
3429 if (!IsHandleCreated) {
3433 controls = child_controls.GetAllControls ();
3434 for (int i = 1; i < controls.Length; i++ ) {
3435 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3440 protected virtual void WndProc(ref Message m) {
3442 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3444 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3448 switch((Msg)m.Msg) {
3449 case Msg.WM_WINDOWPOSCHANGED: {
3452 if (GetStyle(ControlStyles.ResizeRedraw)) {
3459 case Msg.WM_PAINT: {
3460 PaintEventArgs paint_event;
3462 paint_event = XplatUI.PaintEventStart(Handle, true);
3464 if (!needs_redraw) {
3465 // Just blit the previous image
3466 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3467 XplatUI.PaintEventEnd(Handle, true);
3472 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3473 dc = paint_event.SetGraphics (DeviceContext);
3476 if ((control_style & (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) != (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
3477 OnPaintBackground(paint_event);
3480 OnPaint(paint_event);
3482 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
3483 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
3484 paint_event.SetGraphics (dc);
3485 needs_redraw = false;
3488 XplatUI.PaintEventEnd(Handle, true);
3490 if (!GetStyle(ControlStyles.UserPaint)) {
3497 case Msg.WM_ERASEBKGND: {
3498 if (GetStyle (ControlStyles.UserPaint)) {
3499 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3500 PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
3501 Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
3502 OnPaintBackground (eraseEventArgs);
3505 XplatUI.EraseWindowBackground(m.HWnd, m.WParam);
3507 // The DefWndProc will never have to handle this, we don't ever set hbr on the window
3508 m.Result = (IntPtr)1;
3512 case Msg.WM_LBUTTONUP: {
3513 HandleClick(mouse_clicks);
3514 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3516 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3518 if (mouse_clicks > 1) {
3524 case Msg.WM_LBUTTONDOWN: {
3525 if (CanSelect && !is_selected) {
3528 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3529 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3535 case Msg.WM_LBUTTONDBLCLK: {
3537 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3538 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3544 case Msg.WM_MBUTTONUP: {
3545 HandleClick(mouse_clicks);
3546 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3548 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3550 if (mouse_clicks > 1) {
3556 case Msg.WM_MBUTTONDOWN: {
3557 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3558 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3564 case Msg.WM_MBUTTONDBLCLK: {
3566 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3567 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3572 case Msg.WM_RBUTTONUP: {
3573 if (context_menu != null) {
3574 context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
3577 HandleClick(mouse_clicks);
3578 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3580 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3582 if (mouse_clicks > 1) {
3588 case Msg.WM_RBUTTONDOWN: {
3589 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3590 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3595 case Msg.WM_RBUTTONDBLCLK: {
3597 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3598 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3603 case Msg.WM_MOUSEWHEEL: {
3605 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3606 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3607 HighOrder(m.WParam.ToInt32())));
3612 case Msg.WM_MOUSEMOVE: {
3613 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3615 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3620 case Msg.WM_MOUSE_ENTER: {
3625 OnMouseEnter(EventArgs.Empty);
3629 case Msg.WM_MOUSE_LEAVE: {
3631 OnMouseLeave(EventArgs.Empty);
3635 case Msg.WM_MOUSEHOVER: {
3636 OnMouseHover(EventArgs.Empty);
3640 case Msg.WM_SYSKEYDOWN:
3641 case Msg.WM_KEYDOWN:
3642 case Msg.WM_SYSKEYUP:
3644 case Msg.WM_SYSCHAR:
3646 Console.WriteLine("Got {0}", (Msg)m.Msg);
3647 if (ProcessKeyEventArgs(ref m)) {
3651 if (PreProcessMessage(ref m)) {
3655 if (ProcessKeyMessage(ref m)) {
3664 if (m.LParam != IntPtr.Zero) {
3667 hi = new HELPINFO();
3669 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3670 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3672 mouse_pos = Control.MousePosition;
3674 OnHelpRequested(new HelpEventArgs(mouse_pos));
3675 m.Result = (IntPtr)1;
3679 case Msg.WM_KILLFOCUS: {
3680 OnLeave(EventArgs.Empty);
3681 if (CausesValidation) {
3683 e = new CancelEventArgs(false);
3692 OnValidated(EventArgs.Empty);
3695 this.has_focus = false;
3696 this.is_selected = false;
3697 OnLostFocus(EventArgs.Empty);
3701 case Msg.WM_SETFOCUS: {
3702 OnEnter(EventArgs.Empty);
3703 this.has_focus = true;
3704 OnGotFocus(EventArgs.Empty);
3709 case Msg.WM_SYSCOLORCHANGE: {
3710 ThemeEngine.Current.ResetDefaults();
3711 OnSystemColorsChanged(EventArgs.Empty);
3716 case Msg.WM_SETCURSOR: {
3717 if (cursor == null) {
3722 XplatUI.SetCursor(window.Handle, cursor.handle);
3723 m.Result = (IntPtr)1;
3734 #endregion // Public Instance Methods
3736 #region OnXXX methods
3737 [EditorBrowsable(EditorBrowsableState.Advanced)]
3738 protected virtual void OnBackColorChanged(EventArgs e) {
3739 if (BackColorChanged!=null) BackColorChanged(this, e);
3740 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3743 [EditorBrowsable(EditorBrowsableState.Advanced)]
3744 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3745 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3746 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3749 [EditorBrowsable(EditorBrowsableState.Advanced)]
3750 protected virtual void OnBindingContextChanged(EventArgs e) {
3751 CheckDataBindings ();
3752 if (BindingContextChanged!=null) {
3753 BindingContextChanged(this, e);
3755 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3758 [EditorBrowsable(EditorBrowsableState.Advanced)]
3759 protected virtual void OnCausesValidationChanged(EventArgs e) {
3760 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3763 [EditorBrowsable(EditorBrowsableState.Advanced)]
3764 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3765 if (ChangeUICues!=null) ChangeUICues(this, e);
3768 [EditorBrowsable(EditorBrowsableState.Advanced)]
3769 protected virtual void OnClick(EventArgs e) {
3770 if (Click!=null) Click(this, e);
3773 [EditorBrowsable(EditorBrowsableState.Advanced)]
3774 protected virtual void OnContextMenuChanged(EventArgs e) {
3775 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3778 [EditorBrowsable(EditorBrowsableState.Advanced)]
3779 protected virtual void OnControlAdded(ControlEventArgs e) {
3780 if (ControlAdded!=null) ControlAdded(this, e);
3783 [EditorBrowsable(EditorBrowsableState.Advanced)]
3784 protected virtual void OnControlRemoved(ControlEventArgs e) {
3785 if (ControlRemoved!=null) ControlRemoved(this, e);
3788 [EditorBrowsable(EditorBrowsableState.Advanced)]
3789 protected virtual void OnCreateControl() {
3793 [EditorBrowsable(EditorBrowsableState.Advanced)]
3794 protected virtual void OnCursorChanged(EventArgs e) {
3795 if (CursorChanged!=null) CursorChanged(this, e);
3798 [EditorBrowsable(EditorBrowsableState.Advanced)]
3799 protected virtual void OnDockChanged(EventArgs e) {
3800 if (DockChanged!=null) DockChanged(this, e);
3803 [EditorBrowsable(EditorBrowsableState.Advanced)]
3804 protected virtual void OnDoubleClick(EventArgs e) {
3805 if (DoubleClick!=null) DoubleClick(this, e);
3808 [EditorBrowsable(EditorBrowsableState.Advanced)]
3809 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3810 if (DragDrop!=null) DragDrop(this, drgevent);
3813 [EditorBrowsable(EditorBrowsableState.Advanced)]
3814 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3815 if (DragEnter!=null) DragEnter(this, drgevent);
3818 [EditorBrowsable(EditorBrowsableState.Advanced)]
3819 protected virtual void OnDragLeave(EventArgs e) {
3820 if (DragLeave!=null) DragLeave(this, e);
3823 [EditorBrowsable(EditorBrowsableState.Advanced)]
3824 protected virtual void OnDragOver(DragEventArgs drgevent) {
3825 if (DragOver!=null) DragOver(this, drgevent);
3828 [EditorBrowsable(EditorBrowsableState.Advanced)]
3829 protected virtual void OnEnabledChanged(EventArgs e) {
3830 if (EnabledChanged!=null) EnabledChanged(this, e);
3831 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3834 [EditorBrowsable(EditorBrowsableState.Advanced)]
3835 protected virtual void OnEnter(EventArgs e) {
3836 if (Enter!=null) Enter(this, e);
3839 [EditorBrowsable(EditorBrowsableState.Advanced)]
3840 protected virtual void OnFontChanged(EventArgs e) {
3841 if (FontChanged!=null) FontChanged(this, e);
3842 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3845 [EditorBrowsable(EditorBrowsableState.Advanced)]
3846 protected virtual void OnForeColorChanged(EventArgs e) {
3847 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3848 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3851 [EditorBrowsable(EditorBrowsableState.Advanced)]
3852 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3853 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3856 [EditorBrowsable(EditorBrowsableState.Advanced)]
3857 protected virtual void OnGotFocus(EventArgs e) {
3858 if (GotFocus!=null) GotFocus(this, e);
3861 [EditorBrowsable(EditorBrowsableState.Advanced)]
3862 protected virtual void OnHandleCreated(EventArgs e) {
3863 if (HandleCreated!=null) HandleCreated(this, e);
3866 [EditorBrowsable(EditorBrowsableState.Advanced)]
3867 protected virtual void OnHandleDestroyed(EventArgs e) {
3868 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3871 [EditorBrowsable(EditorBrowsableState.Advanced)]
3872 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3873 if (HelpRequested!=null) HelpRequested(this, hevent);
3876 protected virtual void OnImeModeChanged(EventArgs e) {
3877 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3880 [EditorBrowsable(EditorBrowsableState.Advanced)]
3881 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3882 needs_redraw = true;
3883 if (Invalidated!=null) Invalidated(this, e);
3886 [EditorBrowsable(EditorBrowsableState.Advanced)]
3887 protected virtual void OnKeyDown(KeyEventArgs e) {
3888 if (KeyDown!=null) KeyDown(this, e);
3891 [EditorBrowsable(EditorBrowsableState.Advanced)]
3892 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3893 if (KeyPress!=null) KeyPress(this, e);
3896 [EditorBrowsable(EditorBrowsableState.Advanced)]
3897 protected virtual void OnKeyUp(KeyEventArgs e) {
3898 if (KeyUp!=null) KeyUp(this, e);
3901 [EditorBrowsable(EditorBrowsableState.Advanced)]
3902 protected virtual void OnLayout(LayoutEventArgs levent) {
3903 if (Layout!=null) Layout(this, levent);
3906 [EditorBrowsable(EditorBrowsableState.Advanced)]
3907 protected virtual void OnLeave(EventArgs e) {
3908 if (Leave!=null) Leave(this, e);
3911 [EditorBrowsable(EditorBrowsableState.Advanced)]
3912 protected virtual void OnLocationChanged(EventArgs e) {
3914 if (LocationChanged!=null) LocationChanged(this, e);
3917 [EditorBrowsable(EditorBrowsableState.Advanced)]
3918 protected virtual void OnLostFocus(EventArgs e) {
3919 if (LostFocus!=null) LostFocus(this, e);
3922 [EditorBrowsable(EditorBrowsableState.Advanced)]
3923 protected virtual void OnMouseDown(MouseEventArgs e) {
3924 if (MouseDown!=null) MouseDown(this, e);
3927 [EditorBrowsable(EditorBrowsableState.Advanced)]
3928 protected virtual void OnMouseEnter(EventArgs e) {
3929 if (MouseEnter!=null) MouseEnter(this, e);
3932 [EditorBrowsable(EditorBrowsableState.Advanced)]
3933 protected virtual void OnMouseHover(EventArgs e) {
3934 if (MouseHover!=null) MouseHover(this, e);
3937 [EditorBrowsable(EditorBrowsableState.Advanced)]
3938 protected virtual void OnMouseLeave(EventArgs e) {
3939 if (MouseLeave!=null) MouseLeave(this, e);
3942 [EditorBrowsable(EditorBrowsableState.Advanced)]
3943 protected virtual void OnMouseMove(MouseEventArgs e) {
3944 if (MouseMove!=null) MouseMove(this, e);
3947 [EditorBrowsable(EditorBrowsableState.Advanced)]
3948 protected virtual void OnMouseUp(MouseEventArgs e) {
3949 if (MouseUp!=null) MouseUp(this, e);
3952 [EditorBrowsable(EditorBrowsableState.Advanced)]
3953 protected virtual void OnMouseWheel(MouseEventArgs e) {
3954 if (MouseWheel!=null) MouseWheel(this, e);
3957 [EditorBrowsable(EditorBrowsableState.Advanced)]
3958 protected virtual void OnMove(EventArgs e) {
3959 if (Move!=null) Move(this, e);
3962 [EditorBrowsable(EditorBrowsableState.Advanced)]
3963 protected virtual void OnNotifyMessage(Message m) {
3967 [EditorBrowsable(EditorBrowsableState.Advanced)]
3968 protected virtual void OnPaint(PaintEventArgs e) {
3969 if (Paint!=null) Paint(this, e);
3972 [EditorBrowsable(EditorBrowsableState.Advanced)]
3973 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3974 PaintControlBackground (pevent);
3977 [EditorBrowsable(EditorBrowsableState.Advanced)]
3978 protected virtual void OnParentBackColorChanged(EventArgs e) {
3979 if (background_color.IsEmpty && background_image==null) {
3981 OnBackColorChanged(e);
3985 [EditorBrowsable(EditorBrowsableState.Advanced)]
3986 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3987 if (background_color.IsEmpty && background_image==null) {
3989 OnBackgroundImageChanged(e);
3993 [EditorBrowsable(EditorBrowsableState.Advanced)]
3994 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3995 if (binding_context==null) {
3996 binding_context=Parent.binding_context;
3997 OnBindingContextChanged(e);
4001 [EditorBrowsable(EditorBrowsableState.Advanced)]
4002 protected virtual void OnParentChanged(EventArgs e) {
4003 if (ParentChanged!=null) ParentChanged(this, e);
4006 [EditorBrowsable(EditorBrowsableState.Advanced)]
4007 protected virtual void OnParentEnabledChanged(EventArgs e) {
4008 if (is_enabled != Parent.is_enabled) {
4009 is_enabled=Parent.is_enabled;
4011 if (EnabledChanged != null) {
4012 EnabledChanged(this, e);
4017 [EditorBrowsable(EditorBrowsableState.Advanced)]
4018 protected virtual void OnParentFontChanged(EventArgs e) {
4025 [EditorBrowsable(EditorBrowsableState.Advanced)]
4026 protected virtual void OnParentForeColorChanged(EventArgs e) {
4027 if (foreground_color.IsEmpty) {
4029 OnForeColorChanged(e);
4033 [EditorBrowsable(EditorBrowsableState.Advanced)]
4034 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4035 if (right_to_left==RightToLeft.Inherit) {
4037 OnRightToLeftChanged(e);
4041 [EditorBrowsable(EditorBrowsableState.Advanced)]
4042 protected virtual void OnParentVisibleChanged(EventArgs e) {
4044 OnVisibleChanged(e);
4048 [EditorBrowsable(EditorBrowsableState.Advanced)]
4049 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4050 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
4053 [EditorBrowsable(EditorBrowsableState.Advanced)]
4054 protected virtual void OnResize(EventArgs e) {
4055 if (Resize!=null) Resize(this, e);
4057 PerformLayout(this, "bounds");
4059 if (parent != null) {
4060 parent.PerformLayout();
4064 [EditorBrowsable(EditorBrowsableState.Advanced)]
4065 protected virtual void OnRightToLeftChanged(EventArgs e) {
4066 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
4067 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4070 [EditorBrowsable(EditorBrowsableState.Advanced)]
4071 protected virtual void OnSizeChanged(EventArgs e) {
4072 InvalidateBuffers ();
4074 if (SizeChanged!=null) SizeChanged(this, e);
4077 [EditorBrowsable(EditorBrowsableState.Advanced)]
4078 protected virtual void OnStyleChanged(EventArgs e) {
4079 if (StyleChanged!=null) StyleChanged(this, e);
4082 [EditorBrowsable(EditorBrowsableState.Advanced)]
4083 protected virtual void OnSystemColorsChanged(EventArgs e) {
4084 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
4087 [EditorBrowsable(EditorBrowsableState.Advanced)]
4088 protected virtual void OnTabIndexChanged(EventArgs e) {
4089 if (TabIndexChanged!=null) TabIndexChanged(this, e);
4092 [EditorBrowsable(EditorBrowsableState.Advanced)]
4093 protected virtual void OnTabStopChanged(EventArgs e) {
4094 if (TabStopChanged!=null) TabStopChanged(this, e);
4097 [EditorBrowsable(EditorBrowsableState.Advanced)]
4098 protected virtual void OnTextChanged(EventArgs e) {
4099 if (TextChanged!=null) TextChanged(this, e);
4102 [EditorBrowsable(EditorBrowsableState.Advanced)]
4103 protected virtual void OnValidated(EventArgs e) {
4104 if (Validated!=null) Validated(this, e);
4107 [EditorBrowsable(EditorBrowsableState.Advanced)]
4108 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4109 if (Validating!=null) Validating(this, e);
4112 [EditorBrowsable(EditorBrowsableState.Advanced)]
4113 protected virtual void OnVisibleChanged(EventArgs e) {
4120 if (bmp_mem!=null) {
4126 if (!this.IsHandleCreated) {
4127 this.CreateControl();
4133 if (VisibleChanged!=null) VisibleChanged(this, e);
4135 // We need to tell our kids
4136 for (int i=0; i<child_controls.Count; i++) {
4137 child_controls[i].OnParentVisibleChanged(e);
4140 #endregion // OnXXX methods
4143 public event EventHandler BackColorChanged;
4144 public event EventHandler BackgroundImageChanged;
4145 public event EventHandler BindingContextChanged;
4146 public event EventHandler CausesValidationChanged;
4147 public event UICuesEventHandler ChangeUICues;
4148 public event EventHandler Click;
4149 public event EventHandler ContextMenuChanged;
4151 [EditorBrowsable(EditorBrowsableState.Advanced)]
4153 public event ControlEventHandler ControlAdded;
4155 [EditorBrowsable(EditorBrowsableState.Advanced)]
4157 public event ControlEventHandler ControlRemoved;
4159 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4160 public event EventHandler CursorChanged;
4161 public event EventHandler DockChanged;
4162 public event EventHandler DoubleClick;
4163 public event DragEventHandler DragDrop;
4164 public event DragEventHandler DragEnter;
4165 public event EventHandler DragLeave;
4166 public event DragEventHandler DragOver;
4167 public event EventHandler EnabledChanged;
4168 public event EventHandler Enter;
4169 public event EventHandler FontChanged;
4170 public event EventHandler ForeColorChanged;
4171 public event GiveFeedbackEventHandler GiveFeedback;
4173 [EditorBrowsable(EditorBrowsableState.Advanced)]
4175 public event EventHandler GotFocus;
4177 [EditorBrowsable(EditorBrowsableState.Advanced)]
4179 public event EventHandler HandleCreated;
4181 [EditorBrowsable(EditorBrowsableState.Advanced)]
4183 public event EventHandler HandleDestroyed;
4185 public event HelpEventHandler HelpRequested;
4186 public event EventHandler ImeModeChanged;
4188 [EditorBrowsable(EditorBrowsableState.Advanced)]
4190 public event InvalidateEventHandler Invalidated;
4192 public event KeyEventHandler KeyDown;
4193 public event KeyPressEventHandler KeyPress;
4194 public event KeyEventHandler KeyUp;
4195 public event LayoutEventHandler Layout;
4196 public event EventHandler Leave;
4197 public event EventHandler LocationChanged;
4199 [EditorBrowsable(EditorBrowsableState.Advanced)]
4201 public event EventHandler LostFocus;
4203 public event MouseEventHandler MouseDown;
4204 public event EventHandler MouseEnter;
4205 public event EventHandler MouseHover;
4206 public event EventHandler MouseLeave;
4207 public event MouseEventHandler MouseMove;
4208 public event MouseEventHandler MouseUp;
4210 [EditorBrowsable(EditorBrowsableState.Advanced)]
4212 public event MouseEventHandler MouseWheel;
4214 public event EventHandler Move;
4215 public event PaintEventHandler Paint;
4216 public event EventHandler ParentChanged;
4217 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
4218 public event QueryContinueDragEventHandler QueryContinueDrag;
4219 public event EventHandler Resize;
4220 public event EventHandler RightToLeftChanged;
4221 public event EventHandler SizeChanged;
4222 public event EventHandler StyleChanged;
4223 public event EventHandler SystemColorsChanged;
4224 public event EventHandler TabIndexChanged;
4225 public event EventHandler TabStopChanged;
4226 public event EventHandler TextChanged;
4227 public event EventHandler Validated;
4228 public event CancelEventHandler Validating;
4229 public event EventHandler VisibleChanged;
4230 #endregion // Events