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-2006 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
38 using System.ComponentModel;
39 using System.ComponentModel.Design;
40 using System.ComponentModel.Design.Serialization;
41 using System.Collections;
42 using System.Diagnostics;
44 using System.Drawing.Drawing2D;
45 using System.Reflection;
46 using System.Runtime.InteropServices;
47 using System.Security;
48 using System.Threading;
50 namespace System.Windows.Forms
53 [ClassInterface (ClassInterfaceType.AutoDispatch)]
54 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
55 [DefaultProperty("Text")]
56 [DefaultEvent("Click")]
57 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
58 [ToolboxItemFilter("System.Windows.Forms")]
59 public class Control : Component, ISynchronizeInvoke, IWin32Window
60 , IBindableComponent, IDropTarget, IBounds
62 #region Local Variables
65 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
66 Rectangle explicit_bounds; // explicitly set bounds
67 internal object creator_thread; // thread that created the control
68 internal ControlNativeWindow window; // object for native window handle
69 private IWindowTarget window_target;
70 string name; // for object naming
73 bool is_created; // true if OnCreateControl has been sent
74 internal bool has_focus; // true if control has focus
75 internal bool is_visible; // true if control is visible
76 internal bool is_entered; // is the mouse inside the control?
77 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
78 bool is_accessible; // true if the control is visible to accessibility applications
79 bool is_captured; // tracks if the control has captured the mouse
80 internal bool is_toplevel; // tracks if the control is a toplevel window
81 bool is_recreating; // tracks if the handle for the control is being recreated
82 bool causes_validation; // tracks if validation is executed on changes
83 bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
84 int tab_index; // position in tab order of siblings
85 bool tab_stop; // is the control a tab stop?
86 bool is_disposed; // has the window already been disposed?
87 bool is_disposing; // is the window getting disposed?
88 Size client_size; // size of the client area (window excluding decorations)
89 Rectangle client_rect; // rectangle with the client area (window excluding decorations)
90 ControlStyles control_style; // rather win32-specific, style bits for control
92 object control_tag; // object that contains data about our control
93 internal int mouse_clicks; // Counter for mouse clicks
94 Cursor cursor; // Cursor for the window
95 internal bool allow_drop; // true if the control accepts droping objects on it
96 Region clip_region; // User-specified clip region for the window
99 internal Color foreground_color; // foreground color for control
100 internal Color background_color; // background color for control
101 Image background_image; // background image for control
102 internal Font font; // font for control
103 string text; // window/title text for control
104 internal BorderStyle border_style; // Border style of control
105 bool show_keyboard_cues; // Current keyboard cues
106 internal bool show_focus_cues; // Current focus cues
107 internal bool force_double_buffer; // Always doublebuffer regardless of ControlStyle
110 internal enum LayoutType {
114 Layout.LayoutEngine layout_engine;
115 internal int layout_suspended;
116 bool layout_pending; // true if our parent needs to re-layout us
117 internal AnchorStyles anchor_style; // anchoring requirements for our control
118 internal DockStyle dock_style; // docking requirements for our control
119 LayoutType layout_type;
120 private bool recalculate_distances = true; // Delay anchor calculations
122 // Please leave the next 2 as internal until DefaultLayout (2.0) is rewritten
123 internal int dist_right; // distance to the right border of the parent
124 internal int dist_bottom; // distance to the bottom border of the parent
126 // to be categorized...
127 ControlCollection child_controls; // our children
128 Control parent; // our parent control
129 BindingContext binding_context;
130 RightToLeft right_to_left; // drawing direction for control
131 ContextMenu context_menu; // Context menu associated with the control
132 internal bool use_compatible_text_rendering;
133 private bool use_wait_cursor;
136 string accessible_name;
137 string accessible_description;
138 string accessible_default_action;
139 AccessibleRole accessible_role = AccessibleRole.Default;
140 AccessibleObject accessibility_object; // object that contains accessibility information about our control
143 DoubleBuffer backbuffer;
145 ControlBindingsCollection data_bindings;
147 static bool verify_thread_handle;
149 ImageLayout backgroundimage_layout;
153 private ContextMenuStrip context_menu_strip;
154 private bool nested_layout = false;
155 Point auto_scroll_offset;
156 private AutoSizeMode auto_size_mode;
157 private bool suppressing_key_press;
159 #endregion // Local Variables
161 #region Private Classes
162 // This helper class allows us to dispatch messages to Control.WndProc
163 internal class ControlNativeWindow : NativeWindow {
164 private Control owner;
166 public ControlNativeWindow(Control control) : base() {
171 public Control Owner {
177 protected override void OnHandleChange()
179 this.owner.WindowTarget.OnHandleChange(this.owner.Handle);
182 static internal Control ControlFromHandle(IntPtr hWnd) {
183 ControlNativeWindow window;
185 window = (ControlNativeWindow)NativeWindow.FromHandle (hWnd);
186 if (window != null) {
193 static internal Control ControlFromChildHandle (IntPtr handle) {
194 ControlNativeWindow window;
196 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
197 while (hwnd != null) {
198 window = (ControlNativeWindow)NativeWindow.FromHandle (handle);
199 if (window != null) {
208 protected override void WndProc(ref Message m) {
209 owner.WindowTarget.OnMessage(ref m);
213 private class ControlWindowTarget : IWindowTarget
215 private Control control;
217 public ControlWindowTarget(Control control)
219 this.control = control;
222 public void OnHandleChange(IntPtr newHandle)
226 public void OnMessage(ref Message m)
228 control.WndProc(ref m);
233 #region Public Classes
235 public class ControlAccessibleObject : AccessibleObject {
238 #region ControlAccessibleObject Constructors
239 public ControlAccessibleObject(Control ownerControl)
240 : base (ownerControl)
242 if (ownerControl == null)
243 throw new ArgumentNullException ("owner");
245 handle = ownerControl.Handle;
247 #endregion // ControlAccessibleObject Constructors
249 #region ControlAccessibleObject Public Instance Properties
250 public override string DefaultAction {
252 return base.DefaultAction;
256 public override string Description {
258 return base.Description;
262 public IntPtr Handle {
268 // We don't want to let them set it
272 public override string Help {
278 public override string KeyboardShortcut {
280 return base.KeyboardShortcut;
284 public override string Name {
294 public Control Owner {
300 public override AccessibleObject Parent {
307 public override AccessibleRole Role {
312 #endregion // ControlAccessibleObject Public Instance Properties
314 #region ControlAccessibleObject Public Instance Methods
315 public override int GetHelpTopic (out string fileName)
317 return base.GetHelpTopic (out fileName);
320 [MonoTODO ("Stub, does nothing")]
321 public void NotifyClients (AccessibleEvents accEvent)
325 [MonoTODO ("Stub, does nothing")]
326 public void NotifyClients (AccessibleEvents accEvent, int childID)
330 [MonoTODO ("Stub, does nothing")]
331 public void NotifyClients (AccessibleEvents accEvent, int objectID, int childID)
335 public override string ToString() {
336 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
339 #endregion // ControlAccessibleObject Public Instance Methods
342 private class DoubleBuffer : IDisposable
344 public Region InvalidRegion;
345 private Stack real_graphics;
346 private object back_buffer;
347 private Control parent;
348 private bool pending_disposal;
350 public DoubleBuffer (Control parent) {
351 this.parent = parent;
352 real_graphics = new Stack ();
353 int width = parent.Width;
354 int height = parent.Height;
356 if (width < 1) width = 1;
357 if (height < 1) height = 1;
359 XplatUI.CreateOffscreenDrawable (parent.Handle, width, height, out back_buffer);
363 public void Blit (PaintEventArgs pe) {
364 Graphics buffered_graphics;
365 buffered_graphics = XplatUI.GetOffscreenGraphics (back_buffer);
366 XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
367 buffered_graphics.Dispose ();
370 public void Start (PaintEventArgs pe) {
371 // We need to get the graphics for every paint.
372 real_graphics.Push(pe.SetGraphics (XplatUI.GetOffscreenGraphics (back_buffer)));
375 public void End (PaintEventArgs pe) {
376 Graphics buffered_graphics;
377 buffered_graphics = pe.SetGraphics ((Graphics) real_graphics.Pop ());
379 if (pending_disposal)
382 XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
383 InvalidRegion.Exclude (pe.ClipRectangle);
385 buffered_graphics.Dispose ();
388 public void Invalidate ()
390 if (InvalidRegion != null)
391 InvalidRegion.Dispose ();
392 InvalidRegion = new Region (parent.ClientRectangle);
395 public void Dispose () {
396 if (real_graphics.Count > 0) {
397 pending_disposal = true;
401 XplatUI.DestroyOffscreenDrawable (back_buffer);
403 if (InvalidRegion != null)
404 InvalidRegion.Dispose ();
405 InvalidRegion = null;
407 GC.SuppressFinalize (this);
410 #region IDisposable Members
411 void IDisposable.Dispose () {
421 [ListBindable (false)]
423 public class ControlCollection : Layout.ArrangedElementCollection, IList, ICollection, ICloneable, IEnumerable {
424 #region ControlCollection Local Variables
426 Control [] all_controls;
428 #endregion // ControlCollection Local Variables
430 #region ControlCollection Public Constructor
431 public ControlCollection (Control owner)
437 #region ControlCollection Public Instance Properties
440 public Control Owner {
441 get { return this.owner; }
444 public virtual Control this[string key] {
446 int index = IndexOfKey (key);
455 new public virtual Control this[int index] {
457 if (index < 0 || index >= list.Count) {
458 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
460 return (Control)list[index];
466 #endregion // ControlCollection Public Instance Properties
468 #region ControlCollection Instance Methods
470 public virtual void Add (Control value)
475 Form form_value = value as Form;
476 Form form_owner = owner as Form;
477 bool owner_permits_toplevels = (owner is MdiClient) || (form_owner != null && form_owner.IsMdiContainer);
478 bool child_is_toplevel = value.GetTopLevel();
479 bool child_is_mdichild = form_value != null && form_value.IsMdiChild;
481 if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
482 throw new ArgumentException("Cannot add a top level control to a control.", "value");
484 if (child_is_mdichild && form_value.MdiParent != null && form_value.MdiParent != owner && form_value.MdiParent != owner.Parent) {
485 throw new ArgumentException ("Form cannot be added to the Controls collection that has a valid MDI parent.", "value");
488 value.recalculate_distances = true;
490 if (Contains (value)) {
491 owner.PerformLayout();
495 if (value.tab_index == -1) {
501 end = owner.child_controls.Count;
502 for (int i = 0; i < end; i++) {
503 index = owner.child_controls[i].tab_index;
508 value.tab_index = use;
511 if (value.parent != null) {
512 value.parent.Controls.Remove(value);
518 value.ChangeParent(owner);
523 owner.UpdateChildrenZOrder();
524 owner.PerformLayout(value, "Parent");
525 owner.OnControlAdded(new ControlEventArgs(value));
528 internal void AddToList (Control c)
534 internal virtual void AddImplicit (Control control)
536 if (impl_list == null)
537 impl_list = new ArrayList ();
539 if (AllContains (control)) {
540 owner.PerformLayout ();
544 if (control.parent != null) {
545 control.parent.Controls.Remove(control);
549 impl_list.Add (control);
551 control.ChangeParent (owner);
552 control.InitLayout ();
554 owner.UpdateChildrenZOrder ();
556 // If we are adding a new control that isn't
557 // visible, don't trigger a layout
558 if (control.VisibleInternal)
559 owner.PerformLayout (control, "Parent");
561 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
562 public virtual void AddRange (Control[] controls)
564 if (controls == null)
565 throw new ArgumentNullException ("controls");
567 owner.SuspendLayout ();
570 for (int i = 0; i < controls.Length; i++)
573 owner.ResumeLayout ();
577 internal virtual void AddRangeImplicit (Control [] controls)
579 if (controls == null)
580 throw new ArgumentNullException ("controls");
582 owner.SuspendLayout ();
585 for (int i = 0; i < controls.Length; i++)
586 AddImplicit (controls [i]);
588 owner.ResumeLayout (false);
593 public virtual void Clear ()
597 // MS sends remove events in reverse order
598 while (list.Count > 0) {
599 Remove((Control)list[list.Count - 1]);
603 internal virtual void ClearImplicit ()
605 if (impl_list == null)
611 public bool Contains (Control control)
613 return list.Contains (control);
616 internal bool ImplicitContains (Control value) {
617 if (impl_list == null)
620 return impl_list.Contains (value);
623 internal bool AllContains (Control value) {
624 return Contains (value) || ImplicitContains (value);
628 public virtual bool ContainsKey (string key)
630 return IndexOfKey (key) >= 0;
634 // LAMESPEC: MSDN says AE, MS implementation throws ANE
635 public Control[] Find (string key, bool searchAllChildren)
637 if (string.IsNullOrEmpty (key))
638 throw new ArgumentNullException ("key");
640 ArrayList al = new ArrayList ();
642 foreach (Control c in list) {
643 if (c.Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
646 if (searchAllChildren)
647 al.AddRange (c.Controls.Find (key, true));
650 return (Control[])al.ToArray (typeof (Control));
653 public int GetChildIndex(Control child) {
654 return GetChildIndex(child, false);
657 public virtual int GetChildIndex(Control child, bool throwException) {
660 index=list.IndexOf(child);
662 if (index==-1 && throwException) {
663 throw new ArgumentException("Not a child control", "child");
668 public override IEnumerator
670 return new ControlCollectionEnumerator (list);
673 internal IEnumerator GetAllEnumerator () {
674 Control [] res = GetAllControls ();
675 return res.GetEnumerator ();
678 internal ArrayList ImplicitControls {
679 get { return impl_list; }
682 internal Control [] GetAllControls () {
683 if (all_controls != null)
686 if (impl_list == null) {
687 all_controls = (Control []) list.ToArray (typeof (Control));
691 all_controls = new Control [list.Count + impl_list.Count];
692 impl_list.CopyTo (all_controls);
693 list.CopyTo (all_controls, impl_list.Count);
698 public int IndexOf (Control control)
700 return list.IndexOf (control);
703 public virtual int IndexOfKey (string key)
705 if (string.IsNullOrEmpty (key))
708 for (int i = 0; i < list.Count; i++)
709 if (((Control)list[i]).Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
715 public virtual void Remove (Control value)
723 owner.PerformLayout(value, "Parent");
724 owner.OnControlRemoved(new ControlEventArgs(value));
726 ContainerControl container = owner.InternalGetContainerControl ();
727 if (container != null) {
728 // Inform any container controls about the loss of a child control
729 // so that they can update their active control
730 container.ChildControlRemoved (value);
733 value.ChangeParent(null);
735 owner.UpdateChildrenZOrder();
738 internal virtual void RemoveImplicit (Control control)
740 if (impl_list != null) {
742 impl_list.Remove (control);
743 owner.PerformLayout (control, "Parent");
744 owner.OnControlRemoved (new ControlEventArgs (control));
746 control.ChangeParent (null);
747 owner.UpdateChildrenZOrder ();
750 public void RemoveAt (int index)
752 if (index < 0 || index >= list.Count)
753 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
755 Remove ((Control) list [index]);
758 public virtual void RemoveByKey (string key)
760 int index = IndexOfKey (key);
766 public virtual void SetChildIndex(Control child, int newIndex)
769 throw new ArgumentNullException ("child");
773 old_index=list.IndexOf(child);
775 throw new ArgumentException("Not a child control", "child");
778 if (old_index==newIndex) {
783 list.RemoveAt(old_index);
785 if (newIndex>list.Count) {
788 list.Insert(newIndex, child);
790 child.UpdateZOrder();
791 owner.PerformLayout();
794 #endregion // ControlCollection Private Instance Methods
796 #region ControlCollection Interface Properties
798 #endregion // ControlCollection Interface Properties
800 #region ControlCollection Interface Methods
802 int IList.Add (object control)
804 if (!(control is Control))
805 throw new ArgumentException ("Object of type Control required", "control");
808 throw new ArgumentException ("control", "Cannot add null controls");
810 this.Add ((Control)control);
811 return this.IndexOf ((Control)control);
814 void IList.Remove (object control)
816 if (!(control is Control))
817 throw new ArgumentException ("Object of type Control required", "control");
819 this.Remove ((Control)control);
822 Object ICloneable.Clone ()
824 ControlCollection clone = new ControlCollection (this.owner);
825 clone.list = (ArrayList)list.Clone (); // FIXME: Do we need this?
829 #endregion // ControlCollection Interface Methods
831 internal class ControlCollectionEnumerator : IEnumerator
833 private ArrayList list;
836 public ControlCollectionEnumerator (ArrayList collection)
841 #region IEnumerator Members
842 public object Current {
845 return list[position];
846 } catch (IndexOutOfRangeException) {
847 throw new InvalidOperationException ();
852 public bool MoveNext ()
855 return (position < list.Count);
866 #endregion // ControlCollection Class
868 #region Public Constructors
871 if (WindowsFormsSynchronizationContext.AutoInstall)
872 if (!(SynchronizationContext.Current is WindowsFormsSynchronizationContext))
873 SynchronizationContext.SetSynchronizationContext (new WindowsFormsSynchronizationContext ());
875 layout_type = LayoutType.Anchor;
876 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
884 layout_pending = false;
886 causes_validation = true;
888 layout_suspended = 0;
892 right_to_left = RightToLeft.Inherit;
893 border_style = BorderStyle.None;
894 background_color = Color.Empty;
898 ime_mode = ImeMode.Inherit;
899 use_compatible_text_rendering = true;
900 show_keyboard_cues = false;
901 show_focus_cues = SystemInformation.MenuAccessKeysUnderlined;
902 use_wait_cursor = false;
904 backgroundimage_layout = ImageLayout.Tile;
905 use_compatible_text_rendering = Application.use_compatible_text_rendering;
906 padding = this.DefaultPadding;
907 maximum_size = new Size();
908 minimum_size = new Size();
909 margin = this.DefaultMargin;
910 auto_size_mode = AutoSizeMode.GrowOnly;
912 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
913 ControlStyles.Selectable | ControlStyles.StandardClick |
914 ControlStyles.StandardDoubleClick;
915 control_style |= ControlStyles.UseTextForAccessibility;
918 background_image = null;
922 window_target = new ControlWindowTarget(this);
923 window = new ControlNativeWindow(this);
924 child_controls = CreateControlsInstance();
926 bounds.Size = DefaultSize;
927 client_size = ClientSizeFromSize (bounds.Size);
928 client_rect = new Rectangle (Point.Empty, client_size);
929 explicit_bounds = bounds;
932 public Control (Control parent, string text) : this()
938 public Control (Control parent, string text, int left, int top, int width, int height) : this()
941 SetBounds(left, top, width, height, BoundsSpecified.All);
945 public Control (string text) : this()
950 public Control (string text, int left, int top, int width, int height) : this()
952 SetBounds(left, top, width, height, BoundsSpecified.All);
956 private delegate void RemoveDelegate(object c);
958 protected override void Dispose (bool disposing)
960 if (!is_disposed && disposing) {
964 DisposeBackBuffer ();
966 if (this.InvokeRequired) {
967 if (Application.MessageLoop && IsHandleCreated) {
968 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null);
975 parent.Controls.Remove(this);
977 Control [] children = child_controls.GetAllControls ();
978 for (int i=0; i<children.Length; i++) {
979 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
980 children[i].Dispose();
984 base.Dispose(disposing);
986 #endregion // Public Constructors
988 #region Internal Properties
990 internal Rectangle PaddingClientRectangle
993 return new Rectangle (
994 ClientRectangle.Left + padding.Left,
995 ClientRectangle.Top + padding.Top,
996 ClientRectangle.Width - padding.Horizontal,
997 ClientRectangle.Height - padding.Vertical);
1001 private MenuTracker active_tracker;
1003 internal MenuTracker ActiveTracker {
1004 get { return active_tracker; }
1006 if (value == active_tracker)
1009 Capture = value != null;
1010 active_tracker = value;
1014 // Control is currently selected, like Focused, except maintains state
1015 // when Form loses focus
1016 internal bool InternalSelected {
1018 IContainerControl container;
1020 container = GetContainerControl();
1022 if (container != null && container.ActiveControl == this)
1029 // Looks for focus in child controls
1030 // and also in the implicit ones
1031 internal bool InternalContainsFocus {
1033 IntPtr focused_window;
1035 focused_window = XplatUI.GetFocus();
1036 if (IsHandleCreated) {
1037 if (focused_window == Handle)
1040 foreach (Control child_control in child_controls.GetAllControls ())
1041 if (child_control.InternalContainsFocus)
1049 // Mouse is currently within the control's bounds
1050 internal bool Entered {
1051 get { return this.is_entered; }
1054 internal bool VisibleInternal {
1055 get { return is_visible; }
1058 internal LayoutType ControlLayoutType {
1059 get { return layout_type; }
1062 internal BorderStyle InternalBorderStyle {
1064 return border_style;
1068 if (!Enum.IsDefined (typeof (BorderStyle), value))
1069 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
1071 if (border_style != value) {
1072 border_style = value;
1074 if (IsHandleCreated) {
1075 XplatUI.SetBorderStyle (window.Handle, (FormBorderStyle)border_style);
1079 client_size = ClientSizeFromSize (bounds.Size);
1084 internal Size InternalClientSize { set { this.client_size = value; } }
1085 internal virtual bool ActivateOnShow { get { return true; } }
1086 internal Rectangle ExplicitBounds { get { return this.explicit_bounds; } set { this.explicit_bounds = value; } }
1088 internal bool ValidationFailed {
1090 ContainerControl c = InternalGetContainerControl ();
1092 return c.validation_failed;
1096 ContainerControl c = InternalGetContainerControl ();
1098 c.validation_failed = value;
1101 #endregion // Internal Properties
1103 #region Private & Internal Methods
1105 void IDropTarget.OnDragDrop (DragEventArgs drgEvent)
1107 OnDragDrop (drgEvent);
1110 void IDropTarget.OnDragEnter (DragEventArgs drgEvent)
1112 OnDragEnter (drgEvent);
1115 void IDropTarget.OnDragLeave (EventArgs e)
1120 void IDropTarget.OnDragOver (DragEventArgs drgEvent)
1122 OnDragOver (drgEvent);
1125 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
1126 return BeginInvokeInternal (method, args, FindControlToInvokeOn ());
1129 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, Control control) {
1130 AsyncMethodResult result;
1131 AsyncMethodData data;
1133 result = new AsyncMethodResult ();
1134 data = new AsyncMethodData ();
1136 data.Handle = control.GetInvokableHandle ();
1137 data.Method = method;
1139 data.Result = result;
1141 if (!ExecutionContext.IsFlowSuppressed ()) {
1142 data.Context = ExecutionContext.Capture ();
1145 XplatUI.SendAsyncMethod (data);
1149 // The CheckForIllegalCrossThreadCalls in the #if 2.0 of
1150 // Control.Handle throws an exception when we are trying
1151 // to get the Handle to properly invoke on. This avoids that.
1152 private IntPtr GetInvokableHandle ()
1154 if (!IsHandleCreated)
1157 return window.Handle;
1160 internal void PointToClient (ref int x, ref int y) {
1161 XplatUI.ScreenToClient (Handle, ref x, ref y);
1164 internal void PointToScreen (ref int x, ref int y) {
1165 XplatUI.ClientToScreen (Handle, ref x, ref y);
1168 internal bool IsRecreating {
1170 return is_recreating;
1174 internal Graphics DeviceContext {
1175 get { return Hwnd.GraphicsContext; }
1178 // An internal way to have a fixed height
1179 // Basically for DataTimePicker 2.0
1180 internal virtual int OverrideHeight (int height)
1185 private void ProcessActiveTracker (ref Message m)
1187 bool is_up = ((Msg) m.Msg == Msg.WM_LBUTTONUP) ||
1188 ((Msg) m.Msg == Msg.WM_RBUTTONUP);
1190 MouseButtons mb = FromParamToMouseButtons ((int) m.WParam.ToInt32 ());
1192 // We add in the button that was released (not sent in WParam)
1194 switch ((Msg)m.Msg) {
1195 case Msg.WM_LBUTTONUP:
1196 mb |= MouseButtons.Left;
1198 case Msg.WM_RBUTTONUP:
1199 mb |= MouseButtons.Right;
1204 MouseEventArgs args = new MouseEventArgs (
1207 Control.MousePosition.X,
1208 Control.MousePosition.Y,
1212 active_tracker.OnMouseUp (args);
1215 if (!active_tracker.OnMouseDown (args)) {
1216 Control control = GetRealChildAtPoint (Cursor.Position);
1217 if (control != null) {
1218 Point pt = control.PointToClient (Cursor.Position);
1219 XplatUI.SendMessage (control.Handle,
1222 MakeParam (pt.X, pt.Y));
1228 private Control FindControlToInvokeOn ()
1232 if (p.IsHandleCreated)
1235 } while (p != null);
1237 if (p == null || !p.IsHandleCreated)
1238 throw new InvalidOperationException ("Cannot call Invoke or BeginInvoke on a control until the window handle is created");
1243 private void InvalidateBackBuffer () {
1244 if (backbuffer != null)
1245 backbuffer.Invalidate ();
1248 private DoubleBuffer GetBackBuffer () {
1249 if (backbuffer == null)
1250 backbuffer = new DoubleBuffer (this);
1254 private void DisposeBackBuffer () {
1255 if (backbuffer != null) {
1256 backbuffer.Dispose ();
1261 internal static void SetChildColor(Control parent) {
1264 for (int i=0; i < parent.child_controls.Count; i++) {
1265 child=parent.child_controls[i];
1266 if (child.child_controls.Count>0) {
1267 SetChildColor(child);
1272 internal bool Select(Control control) {
1273 IContainerControl container;
1275 if (control == null) {
1279 container = GetContainerControl();
1280 if (container != null && (Control)container != control) {
1281 container.ActiveControl = control;
1282 if (container.ActiveControl == control && !control.has_focus && control.IsHandleCreated)
1283 XplatUI.SetFocus(control.window.Handle);
1285 else if (control.IsHandleCreated) {
1286 XplatUI.SetFocus(control.window.Handle);
1291 internal virtual void DoDefaultAction() {
1292 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1295 internal static IntPtr MakeParam (int low, int high){
1296 return new IntPtr (high << 16 | low & 0xffff);
1299 internal static int LowOrder (int param) {
1300 return ((int)(short)(param & 0xffff));
1303 internal static int HighOrder (long param) {
1304 return ((int)(short)(param >> 16));
1307 // This method exists so controls overriding OnPaintBackground can have default background painting done
1308 internal virtual void PaintControlBackground (PaintEventArgs pevent) {
1310 bool tbstyle_flat = ((CreateParams.Style & (int) ToolBarStyles.TBSTYLE_FLAT) != 0);
1312 // If we have transparent background
1313 if (((BackColor.A != 0xff) && GetStyle(ControlStyles.SupportsTransparentBackColor)) || tbstyle_flat) {
1314 if (parent != null) {
1315 PaintEventArgs parent_pe;
1316 GraphicsState state;
1318 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1320 state = parent_pe.Graphics.Save();
1321 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1322 parent.OnPaintBackground(parent_pe);
1323 parent_pe.Graphics.Restore(state);
1325 state = parent_pe.Graphics.Save();
1326 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1327 parent.OnPaint(parent_pe);
1328 parent_pe.Graphics.Restore(state);
1329 parent_pe.SetGraphics(null);
1333 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1334 if (parent != null) {
1335 PaintEventArgs parent_pe;
1337 GraphicsState state;
1340 hwnd = Hwnd.ObjectFromHandle(Handle);
1343 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1345 region = new Region ();
1347 region.Union(ClientRectangle);
1349 foreach (Rectangle r in hwnd.ClipRectangles) {
1353 state = parent_pe.Graphics.Save();
1354 parent_pe.Graphics.Clip = region;
1356 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1357 parent.OnPaintBackground(parent_pe);
1358 parent_pe.Graphics.Restore(state);
1360 state = parent_pe.Graphics.Save();
1361 parent_pe.Graphics.Clip = region;
1363 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1364 parent.OnPaint(parent_pe);
1365 parent_pe.Graphics.Restore(state);
1366 parent_pe.SetGraphics(null);
1368 region.Intersect(clip_region);
1369 pevent.Graphics.Clip = region;
1374 if (background_image == null) {
1375 if (!tbstyle_flat) {
1376 Rectangle paintRect = pevent.ClipRectangle;
1377 Brush pen = ThemeEngine.Current.ResPool.GetSolidBrush(BackColor);
1378 pevent.Graphics.FillRectangle(pen, paintRect);
1383 DrawBackgroundImage (pevent.Graphics);
1386 void DrawBackgroundImage (Graphics g) {
1387 Rectangle drawing_rectangle = new Rectangle ();
1388 g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
1390 switch (backgroundimage_layout)
1392 case ImageLayout.Tile:
1393 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1394 g.FillRectangle (b, ClientRectangle);
1397 case ImageLayout.Center:
1398 drawing_rectangle.Location = new Point (ClientSize.Width / 2 - background_image.Width / 2, ClientSize.Height / 2 - background_image.Height / 2);
1399 drawing_rectangle.Size = background_image.Size;
1401 case ImageLayout.None:
1402 drawing_rectangle.Location = Point.Empty;
1403 drawing_rectangle.Size = background_image.Size;
1405 case ImageLayout.Stretch:
1406 drawing_rectangle = ClientRectangle;
1408 case ImageLayout.Zoom:
1409 drawing_rectangle = ClientRectangle;
1410 if ((float)background_image.Width / (float)background_image.Height < (float)drawing_rectangle.Width / (float) drawing_rectangle.Height) {
1411 drawing_rectangle.Width = (int) (background_image.Width * ((float)drawing_rectangle.Height / (float)background_image.Height));
1412 drawing_rectangle.X = (ClientRectangle.Width - drawing_rectangle.Width) / 2;
1414 drawing_rectangle.Height = (int) (background_image.Height * ((float)drawing_rectangle.Width / (float)background_image.Width));
1415 drawing_rectangle.Y = (ClientRectangle.Height - drawing_rectangle.Height) / 2;
1422 g.DrawImage (background_image, drawing_rectangle);
1426 internal virtual void DndEnter (DragEventArgs e) {
1432 internal virtual void DndOver (DragEventArgs e) {
1438 internal virtual void DndDrop (DragEventArgs e) {
1441 } catch (Exception exc) {
1442 Console.Error.WriteLine ("MWF: Exception while dropping:");
1443 Console.Error.WriteLine (exc);
1447 internal virtual void DndLeave (EventArgs e) {
1453 internal virtual void DndFeedback(GiveFeedbackEventArgs e) {
1459 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e) {
1461 OnQueryContinueDrag(e);
1465 internal static MouseButtons FromParamToMouseButtons (long param) {
1466 MouseButtons buttons = MouseButtons.None;
1468 if ((param & (long) MsgButtons.MK_LBUTTON) != 0)
1469 buttons |= MouseButtons.Left;
1471 if ((param & (long)MsgButtons.MK_MBUTTON) != 0)
1472 buttons |= MouseButtons.Middle;
1474 if ((param & (long)MsgButtons.MK_RBUTTON) != 0)
1475 buttons |= MouseButtons.Right;
1480 internal virtual void FireEnter () {
1481 OnEnter (EventArgs.Empty);
1484 internal virtual void FireLeave () {
1485 OnLeave (EventArgs.Empty);
1488 internal virtual void FireValidating (CancelEventArgs ce) {
1492 internal virtual void FireValidated () {
1493 OnValidated (EventArgs.Empty);
1496 internal virtual bool ProcessControlMnemonic(char charCode) {
1497 return ProcessMnemonic(charCode);
1500 private static Control FindFlatForward(Control container, Control start) {
1507 end = container.child_controls.Count;
1510 if (start != null) {
1511 index = start.tab_index;
1516 for (int i = 0; i < end; i++) {
1517 if (start == container.child_controls[i]) {
1522 if (found == null || found.tab_index > container.child_controls[i].tab_index) {
1523 if (container.child_controls[i].tab_index > index || (hit && container.child_controls[i].tab_index == index)) {
1524 found = container.child_controls[i];
1531 private static Control FindControlForward(Control container, Control start) {
1536 if (start == null) {
1537 return FindFlatForward(container, start);
1540 if (start.child_controls != null && start.child_controls.Count > 0 &&
1541 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1542 return FindControlForward(start, null);
1545 while (start != container) {
1546 found = FindFlatForward(start.parent, start);
1547 if (found != null) {
1550 start = start.parent;
1556 private static Control FindFlatBackward(Control container, Control start) {
1563 end = container.child_controls.Count;
1566 if (start != null) {
1567 index = start.tab_index;
1569 index = int.MaxValue;
1572 for (int i = end - 1; i >= 0; i--) {
1573 if (start == container.child_controls[i]) {
1578 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1579 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1580 found = container.child_controls[i];
1587 private static Control FindControlBackward(Control container, Control start) {
1589 Control found = null;
1591 if (start == null) {
1592 found = FindFlatBackward(container, start);
1594 else if (start != container) {
1595 if (start.parent != null) {
1596 found = FindFlatBackward(start.parent, start);
1598 if (found == null) {
1599 if (start.parent != container)
1600 return start.parent;
1606 if (found == null || start.parent == null)
1609 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1610 found.child_controls != null && found.child_controls.Count > 0)) {
1611 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1612 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1613 found = FindFlatBackward(found, null);
1623 if (start != null) {
1624 found = FindFlatBackward(start.parent, start);
1625 if (found == null) {
1626 if (start.parent != container) {
1627 return start.parent;
1631 if (found == null) {
1632 found = FindFlatBackward(container, start);
1635 if (container != start) {
1636 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1637 found = FindControlBackward(found, null);
1638 if (found != null) {
1647 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1648 bool standardclick = GetStyle (ControlStyles.StandardClick);
1649 bool standardclickclick = GetStyle (ControlStyles.StandardDoubleClick);
1650 if ((clicks > 1) && standardclick && standardclickclick) {
1652 OnMouseDoubleClick (me);
1653 } else if (clicks == 1 && standardclick && !ValidationFailed) {
1659 internal void CaptureWithConfine (Control ConfineWindow) {
1660 if (this.IsHandleCreated && !is_captured) {
1662 XplatUI.GrabWindow (this.window.Handle, ConfineWindow.Handle);
1666 private void CheckDataBindings () {
1667 if (data_bindings == null)
1670 foreach (Binding binding in data_bindings) {
1675 private void ChangeParent(Control new_parent) {
1679 Color pre_fore_color;
1680 Color pre_back_color;
1681 RightToLeft pre_rtl;
1683 // These properties are inherited from our parent
1684 // Get them pre parent-change and then send events
1685 // if they are changed after we have our new parent
1686 pre_enabled = Enabled;
1687 pre_visible = Visible;
1689 pre_fore_color = ForeColor;
1690 pre_back_color = BackColor;
1691 pre_rtl = RightToLeft;
1692 // MS doesn't seem to send a CursorChangedEvent
1694 parent = new_parent;
1696 Form frm = this as Form;
1698 frm.ChangingParent (new_parent);
1699 } else if (IsHandleCreated) {
1700 IntPtr parent_handle = IntPtr.Zero;
1701 if (new_parent != null && new_parent.IsHandleCreated)
1702 parent_handle = new_parent.Handle;
1703 XplatUI.SetParent (Handle, parent_handle);
1706 OnParentChanged(EventArgs.Empty);
1708 if (pre_enabled != Enabled) {
1709 OnEnabledChanged(EventArgs.Empty);
1712 if (pre_visible != Visible) {
1713 OnVisibleChanged(EventArgs.Empty);
1716 if (pre_font != Font) {
1717 OnFontChanged(EventArgs.Empty);
1720 if (pre_fore_color != ForeColor) {
1721 OnForeColorChanged(EventArgs.Empty);
1724 if (pre_back_color != BackColor) {
1725 OnBackColorChanged(EventArgs.Empty);
1728 if (pre_rtl != RightToLeft) {
1729 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1730 // because when RTL changes they have to recreate the win32 control
1731 // We don't really need that (until someone runs into compatibility issues)
1732 OnRightToLeftChanged(EventArgs.Empty);
1735 if ((new_parent != null) && new_parent.Created && is_visible && !Created) {
1739 if ((binding_context == null) && Created) {
1740 OnBindingContextChanged(EventArgs.Empty);
1744 // Sometimes we need to do this calculation without it being virtual (constructor)
1745 internal Size InternalSizeFromClientSize (Size clientSize)
1747 Rectangle ClientRect;
1748 Rectangle WindowRect;
1751 ClientRect = new Rectangle (0, 0, clientSize.Width, clientSize.Height);
1752 cp = this.CreateParams;
1754 if (XplatUI.CalculateWindowRect (ref ClientRect, cp, null, out WindowRect))
1755 return new Size (WindowRect.Width, WindowRect.Height);
1760 internal Size ClientSizeFromSize (Size size)
1762 // Calling this gives us the difference in Size and ClientSize.
1763 // We just have to apply that difference to our given size.
1764 Size client_size = this.InternalSizeFromClientSize (size);
1766 if (client_size == Size.Empty)
1769 return new Size (size.Width - (client_size.Width - size.Width), size.Height - (client_size.Height - size.Height));
1772 internal CreateParams GetCreateParams ()
1774 return CreateParams;
1777 internal virtual Size GetPreferredSizeCore (Size proposedSize)
1779 return this.explicit_bounds.Size;
1782 private void UpdateDistances() {
1783 if (parent != null) {
1784 if (bounds.Width >= 0)
1785 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1786 if (bounds.Height >= 0)
1787 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1789 recalculate_distances = false;
1793 private Cursor GetAvailableCursor ()
1795 if (Cursor != null && Enabled) {
1799 if (Parent != null) {
1800 return Parent.GetAvailableCursor ();
1803 return Cursors.Default;
1806 private void UpdateCursor ()
1808 if (!IsHandleCreated)
1812 XplatUI.SetCursor (window.Handle, GetAvailableCursor ().handle);
1816 Point pt = PointToClient (Cursor.Position);
1818 if (!bounds.Contains (pt) && !Capture)
1821 if (cursor != null || use_wait_cursor) {
1822 XplatUI.SetCursor (window.Handle, Cursor.handle);
1824 XplatUI.SetCursor (window.Handle, GetAvailableCursor ().handle);
1828 private bool UseDoubleBuffering {
1830 if (!ThemeEngine.Current.DoubleBufferingSupported)
1833 // Since many of .Net's controls are unmanaged, they are doublebuffered
1834 // even though their bits may not be set in managed land. This allows
1835 // us to doublebuffer as well without affecting public style bits.
1836 if (force_double_buffer)
1841 return (control_style & ControlStyles.DoubleBuffer) != 0;
1845 internal void OnSizeInitializedOrChanged ()
1847 Form form = this as Form;
1848 if (form != null && form.WindowManager != null)
1849 ThemeEngine.Current.ManagedWindowOnSizeInitializedOrChanged (form);
1851 #endregion // Private & Internal Methods
1853 #region Public Static Properties
1854 public static Color DefaultBackColor {
1856 return ThemeEngine.Current.DefaultControlBackColor;
1860 public static Font DefaultFont {
1862 return ThemeEngine.Current.DefaultFont;
1866 public static Color DefaultForeColor {
1868 return ThemeEngine.Current.DefaultControlForeColor;
1872 public static Keys ModifierKeys {
1874 return XplatUI.State.ModifierKeys;
1878 public static MouseButtons MouseButtons {
1880 return XplatUI.State.MouseButtons;
1884 public static Point MousePosition {
1886 return Cursor.Position;
1890 [EditorBrowsable (EditorBrowsableState.Advanced)]
1891 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1893 [MonoTODO ("Stub, value is not used")]
1894 public static bool CheckForIllegalCrossThreadCalls
1897 return verify_thread_handle;
1901 verify_thread_handle = value;
1904 #endregion // Public Static Properties
1906 #region Public Instance Properties
1907 [EditorBrowsable(EditorBrowsableState.Advanced)]
1909 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1910 public AccessibleObject AccessibilityObject {
1912 if (accessibility_object==null) {
1913 accessibility_object=CreateAccessibilityInstance();
1915 return accessibility_object;
1919 [EditorBrowsable(EditorBrowsableState.Advanced)]
1921 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1922 public string AccessibleDefaultActionDescription {
1924 return accessible_default_action;
1928 accessible_default_action = value;
1933 [DefaultValue(null)]
1934 [MWFCategory("Accessibility")]
1935 public string AccessibleDescription {
1937 return accessible_description;
1941 accessible_description = value;
1946 [DefaultValue(null)]
1947 [MWFCategory("Accessibility")]
1948 public string AccessibleName {
1950 return accessible_name;
1954 accessible_name = value;
1958 [DefaultValue(AccessibleRole.Default)]
1959 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1960 public AccessibleRole AccessibleRole {
1962 return accessible_role;
1966 accessible_role = value;
1970 [DefaultValue(false)]
1971 [MWFCategory("Behavior")]
1972 public virtual bool AllowDrop {
1978 if (allow_drop == value)
1981 if (IsHandleCreated) {
1983 XplatUI.SetAllowDrop (Handle, value);
1989 [RefreshProperties(RefreshProperties.Repaint)]
1990 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1991 [MWFCategory("Layout")]
1992 public virtual AnchorStyles Anchor {
1994 return anchor_style;
1998 layout_type = LayoutType.Anchor;
2000 if (anchor_style == value)
2004 dock_style = DockStyle.None;
2009 parent.PerformLayout(this, "Anchor");
2014 [DefaultValue (typeof (Point), "0, 0")]
2015 [EditorBrowsable (EditorBrowsableState.Advanced)]
2016 public virtual Point AutoScrollOffset {
2018 return auto_scroll_offset;
2022 this.auto_scroll_offset = value;
2026 // XXX: Implement me!
2029 [RefreshProperties (RefreshProperties.All)]
2030 [Localizable (true)]
2031 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
2033 [EditorBrowsable (EditorBrowsableState.Never)]
2034 [DefaultValue (false)]
2035 public virtual bool AutoSize {
2036 get { return auto_size; }
2038 if (this.auto_size != value) {
2041 // If we're turning this off, reset our size
2043 Size = explicit_bounds.Size;
2046 Parent.PerformLayout (this, "AutoSize");
2049 OnAutoSizeChanged (EventArgs.Empty);
2054 [AmbientValue ("{Width=0, Height=0}")]
2055 [MWFCategory("Layout")]
2056 public virtual Size MaximumSize {
2058 return maximum_size;
2061 if (maximum_size != value) {
2062 maximum_size = value;
2063 Size = PreferredSize;
2068 internal bool ShouldSerializeMaximumSize ()
2070 return this.MaximumSize != DefaultMaximumSize;
2073 [MWFCategory("Layout")]
2074 public virtual Size MinimumSize {
2076 return minimum_size;
2079 if (minimum_size != value) {
2080 minimum_size = value;
2081 Size = PreferredSize;
2086 internal bool ShouldSerializeMinimumSize ()
2088 return this.MinimumSize != DefaultMinimumSize;
2092 [MWFCategory("Appearance")]
2093 public virtual Color BackColor {
2095 if (background_color.IsEmpty) {
2097 Color pcolor = parent.BackColor;
2098 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
2101 return DefaultBackColor;
2103 return background_color;
2107 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
2108 throw new ArgumentException("Transparent background colors are not supported on this control");
2111 if (background_color != value) {
2112 background_color=value;
2113 SetChildColor(this);
2114 OnBackColorChanged(EventArgs.Empty);
2120 internal bool ShouldSerializeBackColor ()
2122 return this.BackColor != DefaultBackColor;
2126 [DefaultValue(null)]
2127 [MWFCategory("Appearance")]
2128 public virtual Image BackgroundImage {
2130 return background_image;
2134 if (background_image!=value) {
2135 background_image=value;
2136 OnBackgroundImageChanged(EventArgs.Empty);
2142 [DefaultValue (ImageLayout.Tile)]
2143 [Localizable (true)]
2144 [MWFCategory("Appearance")]
2145 public virtual ImageLayout BackgroundImageLayout {
2147 return backgroundimage_layout;
2150 if (Array.IndexOf (Enum.GetValues (typeof (ImageLayout)), value) == -1)
2151 throw new InvalidEnumArgumentException ("value", (int) value, typeof(ImageLayout));
2153 if (value != backgroundimage_layout) {
2154 backgroundimage_layout = value;
2156 OnBackgroundImageLayoutChanged (EventArgs.Empty);
2162 [EditorBrowsable(EditorBrowsableState.Advanced)]
2164 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2165 public virtual BindingContext BindingContext {
2167 if (binding_context != null)
2168 return binding_context;
2171 binding_context = Parent.BindingContext;
2172 return binding_context;
2175 if (binding_context != value) {
2176 binding_context = value;
2177 OnBindingContextChanged(EventArgs.Empty);
2182 [EditorBrowsable(EditorBrowsableState.Advanced)]
2184 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2187 return this.bounds.Bottom;
2191 [EditorBrowsable(EditorBrowsableState.Advanced)]
2193 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2194 public Rectangle Bounds {
2200 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
2204 [EditorBrowsable(EditorBrowsableState.Advanced)]
2206 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2207 public bool CanFocus {
2209 if (IsHandleCreated && Visible && Enabled) {
2216 [EditorBrowsable(EditorBrowsableState.Advanced)]
2218 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2219 public bool CanSelect {
2223 if (!GetStyle(ControlStyles.Selectable)) {
2228 while (parent != null) {
2229 if (!parent.is_visible || !parent.is_enabled) {
2233 parent = parent.parent;
2239 internal virtual bool InternalCapture {
2249 [EditorBrowsable(EditorBrowsableState.Advanced)]
2251 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2252 public bool Capture {
2254 return this.is_captured;
2258 // Call OnMouseCaptureChanged when we get WM_CAPTURECHANGED.
2259 if (value != is_captured) {
2262 XplatUI.GrabWindow(Handle, IntPtr.Zero);
2264 if (IsHandleCreated)
2265 XplatUI.UngrabWindow(Handle);
2266 is_captured = false;
2272 [DefaultValue(true)]
2273 [MWFCategory("Focus")]
2274 public bool CausesValidation {
2276 return this.causes_validation;
2280 if (this.causes_validation != value) {
2281 causes_validation = value;
2282 OnCausesValidationChanged(EventArgs.Empty);
2287 [EditorBrowsable(EditorBrowsableState.Advanced)]
2289 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2290 public Rectangle ClientRectangle {
2292 client_rect.Width = client_size.Width;
2293 client_rect.Height = client_size.Height;
2298 [EditorBrowsable(EditorBrowsableState.Advanced)]
2300 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2301 public Size ClientSize {
2304 if ((this is Form) && (((Form)this).form_parent_window != null)) {
2305 return ((Form)this).form_parent_window.ClientSize;
2313 this.SetClientSizeCore(value.Width, value.Height);
2314 this.OnClientSizeChanged (EventArgs.Empty);
2318 [EditorBrowsable(EditorBrowsableState.Advanced)]
2320 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2321 [DescriptionAttribute("ControlCompanyNameDescr")]
2322 public String CompanyName {
2324 return "Mono Project, Novell, Inc.";
2328 [EditorBrowsable(EditorBrowsableState.Advanced)]
2330 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2331 public bool ContainsFocus {
2333 IntPtr focused_window;
2335 focused_window = XplatUI.GetFocus();
2336 if (IsHandleCreated) {
2337 if (focused_window == Handle) {
2341 for (int i=0; i < child_controls.Count; i++) {
2342 if (child_controls[i].ContainsFocus) {
2351 [DefaultValue(null)]
2352 [MWFCategory("Behavior")]
2353 public virtual ContextMenu ContextMenu {
2355 return ContextMenuInternal;
2359 ContextMenuInternal = value;
2363 internal virtual ContextMenu ContextMenuInternal {
2365 return context_menu;
2368 if (context_menu != value) {
2369 context_menu = value;
2370 OnContextMenuChanged (EventArgs.Empty);
2375 [DefaultValue (null)]
2376 [MWFCategory("Behavior")]
2377 public virtual ContextMenuStrip ContextMenuStrip {
2378 get { return this.context_menu_strip; }
2380 if (this.context_menu_strip != value) {
2381 this.context_menu_strip = value;
2383 value.container = this;
2384 OnContextMenuStripChanged (EventArgs.Empty);
2390 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2391 public ControlCollection Controls {
2393 return this.child_controls;
2397 [EditorBrowsable(EditorBrowsableState.Advanced)]
2399 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2400 public bool Created {
2402 return (!is_disposed && is_created);
2406 [AmbientValue(null)]
2407 [MWFCategory("Appearance")]
2408 public virtual Cursor Cursor {
2410 if (use_wait_cursor)
2411 return Cursors.WaitCursor;
2413 if (cursor != null) {
2417 if (parent != null) {
2418 return parent.Cursor;
2421 return Cursors.Default;
2425 if (cursor == value) {
2432 OnCursorChanged (EventArgs.Empty);
2436 internal bool ShouldSerializeCursor ()
2438 return this.Cursor != Cursors.Default;
2441 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2442 [ParenthesizePropertyName(true)]
2443 [RefreshProperties(RefreshProperties.All)]
2444 [MWFCategory("Data")]
2445 public ControlBindingsCollection DataBindings {
2447 if (data_bindings == null)
2448 data_bindings = new ControlBindingsCollection (this);
2449 return data_bindings;
2453 [EditorBrowsable(EditorBrowsableState.Advanced)]
2455 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2456 public virtual Rectangle DisplayRectangle {
2458 return ClientRectangle;
2462 [EditorBrowsable(EditorBrowsableState.Advanced)]
2464 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2465 public bool Disposing {
2472 [RefreshProperties(RefreshProperties.Repaint)]
2473 [DefaultValue(DockStyle.None)]
2474 [MWFCategory("Layout")]
2475 public virtual DockStyle Dock {
2481 // If the user sets this to None, we need to still use Anchor layout
2482 if (value != DockStyle.None)
2483 layout_type = LayoutType.Dock;
2485 if (dock_style == value) {
2489 if (!Enum.IsDefined (typeof (DockStyle), value)) {
2490 throw new InvalidEnumArgumentException ("value", (int) value,
2491 typeof (DockStyle));
2495 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
2497 if (dock_style == DockStyle.None) {
2498 bounds = explicit_bounds;
2499 layout_type = LayoutType.Anchor;
2503 parent.PerformLayout(this, "Dock");
2504 else if (Controls.Count > 0)
2507 OnDockChanged(EventArgs.Empty);
2511 protected virtual bool DoubleBuffered {
2513 return (control_style & ControlStyles.OptimizedDoubleBuffer) != 0;
2517 if (value == DoubleBuffered)
2520 SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
2522 SetStyle (ControlStyles.OptimizedDoubleBuffer, false);
2528 public void DrawToBitmap (Bitmap bitmap, Rectangle targetBounds)
2530 Graphics g = Graphics.FromImage (bitmap);
2532 // Only draw within the target bouds, and up to the size of the control
2533 g.IntersectClip (targetBounds);
2534 g.IntersectClip (Bounds);
2536 // Logic copied from WmPaint
2537 PaintEventArgs pea = new PaintEventArgs (g, targetBounds);
2539 if (!GetStyle (ControlStyles.Opaque))
2540 OnPaintBackground (pea);
2542 OnPaintBackgroundInternal (pea);
2544 OnPaintInternal (pea);
2554 [MWFCategory("Behavior")]
2555 public bool Enabled {
2561 if (parent != null) {
2562 return parent.Enabled;
2569 if (this.is_enabled == value)
2572 bool old_value = is_enabled;
2579 if (old_value != value && !value && this.has_focus)
2580 SelectNextControl(this, true, true, true, true);
2582 OnEnabledChanged (EventArgs.Empty);
2586 internal bool ShouldSerializeEnabled ()
2588 return this.Enabled != true;
2591 [EditorBrowsable(EditorBrowsableState.Advanced)]
2593 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2594 public virtual bool Focused {
2596 return this.has_focus;
2601 [AmbientValue(null)]
2603 [MWFCategory("Appearance")]
2604 public virtual Font Font {
2605 [return: MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Font))]
2610 if (parent != null) {
2611 Font f = parent.Font;
2620 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2622 if (font != null && font == value) {
2628 OnFontChanged (EventArgs.Empty);
2633 internal bool ShouldSerializeFont ()
2635 return !this.Font.Equals (DefaultFont);
2639 [MWFCategory("Appearance")]
2640 public virtual Color ForeColor {
2642 if (foreground_color.IsEmpty) {
2644 return parent.ForeColor;
2646 return DefaultForeColor;
2648 return foreground_color;
2652 if (foreground_color != value) {
2653 foreground_color=value;
2655 OnForeColorChanged(EventArgs.Empty);
2660 internal bool ShouldSerializeForeColor ()
2662 return this.ForeColor != DefaultForeColor;
2667 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2668 public IntPtr Handle { // IWin32Window
2670 if (verify_thread_handle) {
2671 if (this.InvokeRequired) {
2672 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2675 if (!IsHandleCreated) {
2678 return window.Handle;
2682 [EditorBrowsable(EditorBrowsableState.Advanced)]
2684 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2685 public bool HasChildren {
2687 if (this.child_controls.Count>0) {
2694 [EditorBrowsable(EditorBrowsableState.Always)]
2696 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2698 get { return this.bounds.Height; }
2699 set { SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height); }
2702 [AmbientValue(ImeMode.Inherit)]
2704 [MWFCategory("Behavior")]
2705 public ImeMode ImeMode {
2707 if (ime_mode == ImeMode.Inherit) {
2709 return parent.ImeMode;
2711 return ImeMode.NoControl; // default value
2717 if (ime_mode != value) {
2720 OnImeModeChanged(EventArgs.Empty);
2725 internal bool ShouldSerializeImeMode ()
2727 return this.ImeMode != ImeMode.NoControl;
2730 [EditorBrowsable(EditorBrowsableState.Advanced)]
2732 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2733 public bool InvokeRequired { // ISynchronizeInvoke
2735 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2742 [EditorBrowsable(EditorBrowsableState.Advanced)]
2744 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2745 public bool IsAccessible {
2747 return is_accessible;
2751 is_accessible = value;
2755 [EditorBrowsable(EditorBrowsableState.Advanced)]
2757 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2758 public bool IsDisposed {
2760 return this.is_disposed;
2764 [EditorBrowsable(EditorBrowsableState.Advanced)]
2766 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2767 public bool IsHandleCreated {
2769 if (window == null || window.Handle == IntPtr.Zero)
2772 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2773 if (hwnd != null && hwnd.zombie)
2780 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2781 [EditorBrowsable(EditorBrowsableState.Advanced)]
2783 [MonoNotSupported ("RTL is not supported")]
2784 public bool IsMirrored {
2785 get { return false; }
2789 [EditorBrowsable (EditorBrowsableState.Advanced)]
2790 public virtual Layout.LayoutEngine LayoutEngine {
2792 if (layout_engine == null)
2793 layout_engine = new Layout.DefaultLayout ();
2794 return layout_engine;
2798 [EditorBrowsable(EditorBrowsableState.Always)]
2800 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2803 return this.bounds.Left;
2807 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2812 [MWFCategory("Layout")]
2813 public Point Location {
2815 return this.bounds.Location;
2819 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2823 internal bool ShouldSerializeLocation ()
2825 return this.Location != new Point (0, 0);
2828 [Localizable (true)]
2829 [MWFCategory("Layout")]
2830 public Padding Margin {
2831 get { return this.margin; }
2833 if (this.margin != value) {
2834 this.margin = value;
2836 Parent.PerformLayout (this, "Margin");
2837 OnMarginChanged (EventArgs.Empty);
2842 internal bool ShouldSerializeMargin ()
2844 return this.Margin != DefaultMargin;
2848 public string Name {
2859 [MWFCategory("Layout")]
2860 public Padding Padding {
2866 if (padding != value) {
2868 OnPaddingChanged (EventArgs.Empty);
2870 // Changing padding generally requires a new size
2871 if (this.AutoSize && this.Parent != null)
2872 parent.PerformLayout (this, "Padding");
2874 PerformLayout (this, "Padding");
2879 internal bool ShouldSerializePadding ()
2881 return this.Padding != DefaultPadding;
2885 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2886 public Control Parent {
2892 if (value == this) {
2893 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2896 if (parent!=value) {
2898 parent.Controls.Remove(this);
2903 value.Controls.Add(this);
2909 public Size PreferredSize {
2910 get { return this.GetPreferredSize (Size.Empty); }
2913 [EditorBrowsable(EditorBrowsableState.Advanced)]
2915 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2916 public string ProductName {
2918 Type t = typeof (AssemblyProductAttribute);
2919 Assembly assembly = GetType().Module.Assembly;
2920 object [] attrs = assembly.GetCustomAttributes (t, false);
2921 AssemblyProductAttribute a = null;
2922 // On MS we get a NullRefException if product attribute is not
2924 if (attrs != null && attrs.Length > 0)
2925 a = (AssemblyProductAttribute) attrs [0];
2927 return GetType ().Namespace;
2933 [EditorBrowsable(EditorBrowsableState.Advanced)]
2935 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2936 public string ProductVersion {
2938 Type t = typeof (AssemblyVersionAttribute);
2939 Assembly assembly = GetType().Module.Assembly;
2940 object [] attrs = assembly.GetCustomAttributes (t, false);
2941 if (attrs == null || attrs.Length < 1)
2943 return ((AssemblyVersionAttribute)attrs [0]).Version;
2947 [EditorBrowsable(EditorBrowsableState.Advanced)]
2949 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2950 public bool RecreatingHandle {
2952 return is_recreating;
2956 [EditorBrowsable(EditorBrowsableState.Advanced)]
2958 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2959 public Region Region {
2965 if (clip_region != value) {
2966 if (IsHandleCreated)
2967 XplatUI.SetClipRegion(Handle, value);
2969 clip_region = value;
2971 OnRegionChanged (EventArgs.Empty);
2976 [EditorBrowsable(EditorBrowsableState.Advanced)]
2978 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2981 return this.bounds.Right;
2985 [AmbientValue(RightToLeft.Inherit)]
2987 [MWFCategory("Appearance")]
2988 public virtual RightToLeft RightToLeft {
2990 if (right_to_left == RightToLeft.Inherit) {
2992 return parent.RightToLeft;
2994 return RightToLeft.No; // default value
2996 return right_to_left;
3000 if (value != right_to_left) {
3001 right_to_left = value;
3002 OnRightToLeftChanged(EventArgs.Empty);
3008 internal bool ShouldSerializeRightToLeft ()
3010 return this.RightToLeft != RightToLeft.No;
3013 [EditorBrowsable(EditorBrowsableState.Advanced)]
3014 public override ISite Site {
3022 if (value != null) {
3023 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
3025 BackColor = ap.BackColor;
3026 ForeColor = ap.ForeColor;
3034 internal bool ShouldSerializeSite ()
3040 [MWFCategory("Layout")]
3043 return new Size(Width, Height);
3047 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
3051 internal virtual bool ShouldSerializeSize ()
3053 return this.Size != DefaultSize;
3057 [MergableProperty(false)]
3058 [MWFCategory("Behavior")]
3059 public int TabIndex {
3061 if (tab_index != -1) {
3068 if (tab_index != value) {
3070 OnTabIndexChanged(EventArgs.Empty);
3076 [DefaultValue(true)]
3077 [MWFCategory("Behavior")]
3078 public bool TabStop {
3084 if (tab_stop != value) {
3086 OnTabStopChanged(EventArgs.Empty);
3091 [Localizable(false)]
3093 [TypeConverter(typeof(StringConverter))]
3094 [DefaultValue(null)]
3095 [MWFCategory("Data")]
3102 control_tag = value;
3108 [BindableAttribute(true)]
3109 [MWFCategory("Appearance")]
3110 public virtual string Text {
3112 // Our implementation ignores ControlStyles.CacheText - we always cache
3117 if (value == null) {
3118 value = String.Empty;
3123 UpdateWindowText ();
3124 OnTextChanged (EventArgs.Empty);
3126 // Label has its own AutoSize implementation
3127 if (AutoSize && Parent != null && (!(this is Label)))
3128 Parent.PerformLayout (this, "Text");
3133 internal virtual void UpdateWindowText ()
3135 if (!IsHandleCreated) {
3138 XplatUI.Text (Handle, text);
3141 [EditorBrowsable(EditorBrowsableState.Always)]
3143 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3146 return this.bounds.Top;
3150 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
3154 [EditorBrowsable(EditorBrowsableState.Advanced)]
3156 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3157 public Control TopLevelControl {
3161 while (p.parent != null) {
3165 return p is Form ? p : null;
3169 [EditorBrowsable(EditorBrowsableState.Always)]
3171 [DefaultValue (false)]
3172 [MWFCategory("Appearance")]
3173 public bool UseWaitCursor {
3174 get { return use_wait_cursor; }
3176 if (use_wait_cursor != value) {
3177 use_wait_cursor = value;
3179 OnCursorChanged (EventArgs.Empty);
3185 [MWFCategory("Behavior")]
3186 public bool Visible {
3190 } else if (parent != null) {
3191 return parent.Visible;
3198 if (this.is_visible != value) {
3199 SetVisibleCore(value);
3202 parent.PerformLayout (this, "Visible");
3207 internal bool ShouldSerializeVisible ()
3209 return this.Visible != true;
3212 [EditorBrowsable(EditorBrowsableState.Always)]
3214 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3217 return this.bounds.Width;
3221 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
3225 [EditorBrowsable(EditorBrowsableState.Never)]
3227 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3228 public IWindowTarget WindowTarget {
3229 get { return window_target; }
3230 set { window_target = value; }
3232 #endregion // Public Instance Properties
3234 #region Protected Instance Properties
3235 protected virtual bool CanEnableIme {
3236 get { return false; }
3239 // Is only false in some ActiveX contexts
3240 protected override bool CanRaiseEvents {
3241 get { return true; }
3244 protected virtual CreateParams CreateParams {
3246 CreateParams create_params = new CreateParams();
3249 create_params.Caption = Text;
3252 create_params.Caption = text;
3256 create_params.X = Left;
3259 create_params.X = this.bounds.X;
3263 create_params.Y = Top;
3266 create_params.Y = this.bounds.Y;
3270 create_params.Width = Width;
3273 create_params.Width = this.bounds.Width;
3277 create_params.Height = Height;
3280 create_params.Height = this.bounds.Height;
3284 create_params.ClassName = XplatUI.GetDefaultClassName (GetType ());
3285 create_params.ClassStyle = (int)(XplatUIWin32.ClassStyle.CS_OWNDC | XplatUIWin32.ClassStyle.CS_DBLCLKS);
3286 create_params.ExStyle = 0;
3287 create_params.Param = 0;
3290 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
3293 if ((parent!=null) && (parent.IsHandleCreated)) {
3294 create_params.Parent = parent.Handle;
3297 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
3300 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
3304 create_params.Style |= (int)WindowStyles.WS_DISABLED;
3307 switch (border_style) {
3308 case BorderStyle.FixedSingle:
3309 create_params.Style |= (int) WindowStyles.WS_BORDER;
3311 case BorderStyle.Fixed3D:
3312 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
3316 create_params.control = this;
3318 return create_params;
3322 protected virtual Cursor DefaultCursor { get { return Cursors.Default; } }
3324 protected virtual ImeMode DefaultImeMode {
3326 return ImeMode.Inherit;
3330 protected virtual Padding DefaultMargin {
3331 get { return new Padding (3); }
3334 protected virtual Size DefaultMaximumSize { get { return new Size (); } }
3335 protected virtual Size DefaultMinimumSize { get { return new Size (); } }
3336 protected virtual Padding DefaultPadding { get { return new Padding (); } }
3338 protected virtual Size DefaultSize {
3340 return new Size(0, 0);
3344 protected int FontHeight {
3354 protected bool RenderRightToLeft {
3356 return (this.right_to_left == RightToLeft.Yes);
3360 protected bool ResizeRedraw {
3362 return GetStyle(ControlStyles.ResizeRedraw);
3366 SetStyle(ControlStyles.ResizeRedraw, value);
3370 [EditorBrowsable (EditorBrowsableState.Advanced)]
3371 protected virtual bool ScaleChildren {
3372 get { return ScaleChildrenInternal; }
3375 internal virtual bool ScaleChildrenInternal {
3376 get { return true; }
3379 [EditorBrowsable(EditorBrowsableState.Advanced)]
3381 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3382 protected internal virtual bool ShowFocusCues {
3385 return show_focus_cues;
3387 if (this.parent == null)
3390 Form f = this.FindForm ();
3393 return f.show_focus_cues;
3399 [EditorBrowsable(EditorBrowsableState.Advanced)]
3401 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3402 internal virtual protected bool ShowKeyboardCues {
3404 return ShowKeyboardCuesInternal;
3408 internal bool ShowKeyboardCuesInternal {
3410 if (SystemInformation.MenuAccessKeysUnderlined || DesignMode)
3413 return show_keyboard_cues;
3417 #endregion // Protected Instance Properties
3419 #region Public Static Methods
3420 [EditorBrowsable(EditorBrowsableState.Advanced)]
3421 public static Control FromChildHandle(IntPtr handle) {
3422 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
3425 [EditorBrowsable(EditorBrowsableState.Advanced)]
3426 public static Control FromHandle(IntPtr handle) {
3427 return Control.ControlNativeWindow.ControlFromHandle(handle);
3430 [MonoTODO ("Only implemented for Win32, others always return false")]
3431 public static bool IsKeyLocked (Keys keyVal)
3437 return XplatUI.IsKeyLocked ((VirtualKeys)keyVal);
3439 throw new NotSupportedException ("keyVal must be CapsLock, NumLock, or ScrollLock");
3443 public static bool IsMnemonic(char charCode, string text) {
3446 amp = text.IndexOf('&');
3449 if (amp + 1 < text.Length) {
3450 if (text[amp + 1] != '&') {
3451 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
3461 #region Protected Static Methods
3462 [EditorBrowsable(EditorBrowsableState.Advanced)]
3463 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
3466 c = Control.FromHandle(hWnd);
3476 #region Public Instance Methods
3477 [EditorBrowsable(EditorBrowsableState.Advanced)]
3478 public IAsyncResult BeginInvoke(Delegate method) {
3479 object [] prms = null;
3480 if (method is EventHandler)
3481 prms = new object [] { this, EventArgs.Empty };
3482 return BeginInvokeInternal(method, prms);
3485 [EditorBrowsable(EditorBrowsableState.Advanced)]
3486 public IAsyncResult BeginInvoke (Delegate method, params object[] args)
3488 return BeginInvokeInternal (method, args);
3491 public void BringToFront() {
3492 if (parent != null) {
3493 parent.child_controls.SetChildIndex(this, 0);
3495 else if (IsHandleCreated) {
3496 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
3500 public bool Contains(Control ctl) {
3501 while (ctl != null) {
3510 public void CreateControl () {
3523 if (parent != null && !parent.Created) {
3527 if (!IsHandleCreated) {
3534 // Create all of our children (implicit ones as well) when we are created.
3535 // The child should fire it's OnLoad before the parents, however
3536 // if the child checks Parent.Created in it's OnCreateControl, the
3537 // parent is already created.
3538 foreach (Control c in Controls.GetAllControls ())
3539 if (!c.Created && !c.IsDisposed)
3546 public Graphics CreateGraphics() {
3547 if (!IsHandleCreated) {
3548 this.CreateHandle();
3550 return Graphics.FromHwnd(this.window.Handle);
3553 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
3554 DragDropEffects result = DragDropEffects.None;
3555 if (IsHandleCreated)
3556 result = XplatUI.StartDrag(Handle, data, allowedEffects);
3557 OnDragDropEnd (result);
3561 internal virtual void OnDragDropEnd (DragDropEffects effects)
3565 [EditorBrowsable(EditorBrowsableState.Advanced)]
3566 public object EndInvoke (IAsyncResult asyncResult) {
3567 AsyncMethodResult result = (AsyncMethodResult) asyncResult;
3568 return result.EndInvoke ();
3571 internal Control FindRootParent ()
3575 while (c.Parent != null)
3581 public Form FindForm() {
3593 [EditorBrowsable (EditorBrowsableState.Advanced)]
3594 public bool Focus() {
3595 return FocusInternal (false);
3598 internal virtual bool FocusInternal (bool skip_check) {
3599 if (skip_check || (CanFocus && IsHandleCreated && !has_focus && !is_focusing)) {
3602 is_focusing = false;
3607 internal Control GetRealChildAtPoint (Point pt) {
3608 if (!IsHandleCreated)
3611 foreach (Control control in child_controls.GetAllControls ()) {
3612 if (control.Bounds.Contains (PointToClient (pt))) {
3613 Control child = control.GetRealChildAtPoint (pt);
3624 public Control GetChildAtPoint(Point pt)
3626 return GetChildAtPoint (pt, GetChildAtPointSkip.None);
3629 public Control GetChildAtPoint (Point pt, GetChildAtPointSkip skipValue)
3631 // MS's version causes the handle to be created. The stack trace shows that get_Handle is called here, but
3632 // we'll just call CreateHandle instead.
3633 if (!IsHandleCreated)
3636 // Microsoft's version of this function doesn't seem to work, so I can't check
3637 // if we only consider children or also grandchildren, etc.
3638 // I'm gonna say 'children only'
3639 foreach (Control child in Controls) {
3640 if ((skipValue & GetChildAtPointSkip.Disabled) == GetChildAtPointSkip.Disabled && !child.Enabled)
3642 else if ((skipValue & GetChildAtPointSkip.Invisible) == GetChildAtPointSkip.Invisible && !child.Visible)
3644 else if ((skipValue & GetChildAtPointSkip.Transparent) == GetChildAtPointSkip.Transparent && child.BackColor.A == 0x0)
3646 else if (child.Bounds.Contains (pt))
3653 public IContainerControl GetContainerControl() {
3654 Control current = this;
3656 while (current!=null) {
3657 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
3658 return (IContainerControl)current;
3660 current = current.parent;
3665 internal ContainerControl InternalGetContainerControl() {
3666 Control current = this;
3668 while (current!=null) {
3669 if ((current is ContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
3670 return current as ContainerControl;
3672 current = current.parent;
3677 public Control GetNextControl(Control ctl, bool forward) {
3679 if (!this.Contains(ctl)) {
3684 ctl = FindControlForward(this, ctl);
3687 ctl = FindControlBackward(this, ctl);
3696 [EditorBrowsable (EditorBrowsableState.Advanced)]
3697 public virtual Size GetPreferredSize (Size proposedSize) {
3698 Size retsize = GetPreferredSizeCore (proposedSize);
3700 // If we're bigger than the MaximumSize, fix that
3701 if (this.maximum_size.Width != 0 && retsize.Width > this.maximum_size.Width)
3702 retsize.Width = this.maximum_size.Width;
3703 if (this.maximum_size.Height != 0 && retsize.Height > this.maximum_size.Height)
3704 retsize.Height = this.maximum_size.Height;
3706 // If we're smaller than the MinimumSize, fix that
3707 if (this.minimum_size.Width != 0 && retsize.Width < this.minimum_size.Width)
3708 retsize.Width = this.minimum_size.Width;
3709 if (this.minimum_size.Height != 0 && retsize.Height < this.minimum_size.Height)
3710 retsize.Height = this.minimum_size.Height;
3715 public void Hide() {
3716 this.Visible = false;
3719 public void Invalidate ()
3721 Invalidate (ClientRectangle, false);
3724 public void Invalidate (bool invalidateChildren)
3726 Invalidate (ClientRectangle, invalidateChildren);
3729 public void Invalidate (Rectangle rc)
3731 Invalidate (rc, false);
3734 public void Invalidate (Rectangle rc, bool invalidateChildren)
3736 // Win32 invalidates control including when Width and Height is equal 0
3737 // or is not visible, only Paint event must be care about this.
3738 if (!IsHandleCreated)
3742 rc = ClientRectangle;
3744 if (rc.Width > 0 && rc.Height > 0) {
3746 NotifyInvalidate(rc);
3748 XplatUI.Invalidate(Handle, rc, false);
3750 if (invalidateChildren) {
3751 Control [] controls = child_controls.GetAllControls ();
3752 for (int i=0; i<controls.Length; i++)
3753 controls [i].Invalidate ();
3755 // If any of our children are transparent, we
3756 // have to invalidate them anyways
3757 foreach (Control c in Controls)
3758 if (c.BackColor.A != 255)
3762 OnInvalidated(new InvalidateEventArgs(rc));
3765 public void Invalidate (Region region)
3767 Invalidate (region, false);
3770 public void Invalidate (Region region, bool invalidateChildren)
3772 using (Graphics g = CreateGraphics ()){
3773 RectangleF bounds = region.GetBounds (g);
3774 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height), invalidateChildren);
3778 public object Invoke (Delegate method) {
3779 object [] prms = null;
3780 if (method is EventHandler)
3781 prms = new object [] { this, EventArgs.Empty };
3783 return Invoke(method, prms);
3785 public object Invoke (Delegate method, params object [] args) {
3786 Control control = FindControlToInvokeOn ();
3788 if (!this.InvokeRequired) {
3789 return method.DynamicInvoke(args);
3792 IAsyncResult result = BeginInvokeInternal (method, args, control);
3793 return EndInvoke(result);
3796 [EditorBrowsable(EditorBrowsableState.Advanced)]
3797 public void PerformLayout() {
3798 PerformLayout(null, null);
3801 [EditorBrowsable(EditorBrowsableState.Advanced)]
3802 public void PerformLayout(Control affectedControl, string affectedProperty) {
3803 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
3805 foreach (Control c in Controls.GetAllControls ())
3806 if (c.recalculate_distances)
3807 c.UpdateDistances ();
3809 if (layout_suspended > 0) {
3810 layout_pending = true;
3814 layout_pending = false;
3816 // Prevent us from getting messed up
3819 // Perform all Dock and Anchor calculations
3824 // Need to make sure we decremend layout_suspended
3830 public Point PointToClient (Point p) {
3834 XplatUI.ScreenToClient (Handle, ref x, ref y);
3836 return new Point (x, y);
3839 public Point PointToScreen(Point p) {
3843 XplatUI.ClientToScreen(Handle, ref x, ref y);
3845 return new Point(x, y);
3848 [EditorBrowsable(EditorBrowsableState.Advanced)]
3849 public PreProcessControlState PreProcessControlMessage (ref Message msg)
3851 return PreProcessControlMessageInternal (ref msg);
3854 internal PreProcessControlState PreProcessControlMessageInternal (ref Message msg)
3856 switch ((Msg)msg.Msg) {
3857 case Msg.WM_KEYDOWN:
3858 case Msg.WM_SYSKEYDOWN:
3859 PreviewKeyDownEventArgs e = new PreviewKeyDownEventArgs ((Keys)msg.WParam.ToInt32 () | XplatUI.State.ModifierKeys);
3860 OnPreviewKeyDown (e);
3863 return PreProcessControlState.MessageNeeded;
3865 if (PreProcessMessage (ref msg))
3866 return PreProcessControlState.MessageProcessed;
3868 if (IsInputKey ((Keys)msg.WParam.ToInt32 () | XplatUI.State.ModifierKeys))
3869 return PreProcessControlState.MessageNeeded;
3873 case Msg.WM_SYSCHAR:
3874 if (PreProcessMessage (ref msg))
3875 return PreProcessControlState.MessageProcessed;
3877 if (IsInputChar ((char)msg.WParam))
3878 return PreProcessControlState.MessageNeeded;
3885 return PreProcessControlState.MessageNotNeeded;
3888 public virtual bool PreProcessMessage (ref Message msg)
3890 return InternalPreProcessMessage (ref msg);
3893 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3896 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3897 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3899 if (!ProcessCmdKey(ref msg, key_data)) {
3900 if (IsInputKey(key_data)) {
3904 return ProcessDialogKey(key_data);
3908 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3909 if (IsInputChar((char)msg.WParam)) {
3912 return ProcessDialogChar((char)msg.WParam);
3913 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3914 if (ProcessDialogChar((char)msg.WParam))
3917 return ToolStripManager.ProcessMenuKey (ref msg);
3922 public Rectangle RectangleToClient(Rectangle r) {
3923 return new Rectangle(PointToClient(r.Location), r.Size);
3926 public Rectangle RectangleToScreen(Rectangle r) {
3927 return new Rectangle(PointToScreen(r.Location), r.Size);
3930 public virtual void Refresh() {
3931 if (IsHandleCreated && Visible) {
3937 [EditorBrowsable(EditorBrowsableState.Never)]
3938 public virtual void ResetBackColor() {
3939 BackColor = Color.Empty;
3942 [EditorBrowsable(EditorBrowsableState.Never)]
3943 public void ResetBindings() {
3944 if (data_bindings != null)
3945 data_bindings.Clear();
3948 [EditorBrowsable(EditorBrowsableState.Never)]
3949 public virtual void ResetCursor() {
3953 [EditorBrowsable(EditorBrowsableState.Never)]
3954 public virtual void ResetFont() {
3958 [EditorBrowsable(EditorBrowsableState.Never)]
3959 public virtual void ResetForeColor() {
3960 foreground_color = Color.Empty;
3963 [EditorBrowsable(EditorBrowsableState.Never)]
3964 public void ResetImeMode() {
3965 ime_mode = DefaultImeMode;
3968 [EditorBrowsable(EditorBrowsableState.Never)]
3969 public virtual void ResetRightToLeft() {
3970 right_to_left = RightToLeft.Inherit;
3973 public virtual void ResetText() {
3974 Text = String.Empty;
3977 public void ResumeLayout() {
3978 ResumeLayout (true);
3981 public void ResumeLayout(bool performLayout) {
3982 if (layout_suspended > 0) {
3986 if (layout_suspended == 0) {
3987 if (this is ContainerControl)
3988 (this as ContainerControl).PerformDelayedAutoScale();
3991 foreach (Control c in Controls.GetAllControls ())
3992 c.UpdateDistances ();
3994 if (performLayout && layout_pending) {
3999 [EditorBrowsable (EditorBrowsableState.Never)]
4001 public void Scale(float ratio) {
4002 ScaleCore(ratio, ratio);
4005 [EditorBrowsable (EditorBrowsableState.Never)]
4007 public void Scale(float dx, float dy) {
4011 [EditorBrowsable (EditorBrowsableState.Advanced)]
4012 public void Scale (SizeF factor)
4014 BoundsSpecified bounds_spec = BoundsSpecified.All;
4018 if (this is ContainerControl) {
4019 if ((this as ContainerControl).IsAutoScaling)
4020 bounds_spec = BoundsSpecified.Size;
4021 else if (IsContainerAutoScaling (this.Parent))
4022 bounds_spec = BoundsSpecified.Location;
4025 ScaleControl (factor, bounds_spec);
4028 if ((bounds_spec != BoundsSpecified.Location) && ScaleChildren) {
4029 foreach (Control c in Controls.GetAllControls ()) {
4031 if (c is ContainerControl) {
4032 ContainerControl cc = c as ContainerControl;
4033 if ((cc.AutoScaleMode == AutoScaleMode.Inherit) && IsContainerAutoScaling (this))
4034 cc.PerformAutoScale (true);
4042 internal ContainerControl FindContainer (Control c)
4044 while ((c != null) && !(c is ContainerControl))
4046 return c as ContainerControl;
4049 private bool IsContainerAutoScaling (Control c)
4051 ContainerControl cc = FindContainer (c);
4052 return (cc != null) && cc.IsAutoScaling;
4055 public void Select() {
4056 Select(false, false);
4060 private void printTree(Control c, string t) {
4061 foreach(Control i in c.child_controls) {
4062 Console.WriteLine ("{2}{0}.TabIndex={1}", i, i.tab_index, t);
4063 printTree (i, t+"\t");
4067 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
4071 Console.WriteLine("{0}", this.FindForm());
4072 printTree(this, "\t");
4075 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
4080 c = GetNextControl(c, forward);
4090 Console.WriteLine("{0} {1}", c, c.CanSelect);
4092 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
4093 c.Select (true, true);
4096 } while (c != ctl); // If we wrap back to ourselves we stop
4101 public void SendToBack() {
4102 if (parent != null) {
4103 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
4107 public void SetBounds(int x, int y, int width, int height) {
4108 SetBounds(x, y, width, height, BoundsSpecified.All);
4111 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
4112 // Fill in the values that were not specified
4113 if ((specified & BoundsSpecified.X) == 0)
4115 if ((specified & BoundsSpecified.Y) == 0)
4117 if ((specified & BoundsSpecified.Width) == 0)
4119 if ((specified & BoundsSpecified.Height) == 0)
4122 SetBoundsInternal (x, y, width, height, specified);
4125 internal void SetBoundsInternal (int x, int y, int width, int height, BoundsSpecified specified)
4127 // SetBoundsCore is really expensive to call, so we want to avoid it if we can.
4128 // We can avoid it if:
4129 // - The requested dimensions are the same as our current dimensions
4131 // - Any BoundsSpecified is the same as our current explicit_size
4132 if (bounds.X != x || (explicit_bounds.X != x && (specified & BoundsSpecified.X) == BoundsSpecified.X))
4133 SetBoundsCore (x, y, width, height, specified);
4134 else if (bounds.Y != y || (explicit_bounds.Y != y && (specified & BoundsSpecified.Y) == BoundsSpecified.Y))
4135 SetBoundsCore (x, y, width, height, specified);
4136 else if (bounds.Width != width || (explicit_bounds.Width != width && (specified & BoundsSpecified.Width) == BoundsSpecified.Width))
4137 SetBoundsCore (x, y, width, height, specified);
4138 else if (bounds.Height != height || (explicit_bounds.Height != height && (specified & BoundsSpecified.Height) == BoundsSpecified.Height))
4139 SetBoundsCore (x, y, width, height, specified);
4143 // If the user explicitly moved or resized us, recalculate our anchor distances
4144 if (specified != BoundsSpecified.None)
4148 parent.PerformLayout(this, "Bounds");
4151 public void Show () {
4152 this.Visible = true;
4155 public void SuspendLayout() {
4159 public void Update() {
4160 if (IsHandleCreated) {
4161 XplatUI.UpdateWindow(window.Handle);
4164 #endregion // Public Instance Methods
4166 #region Protected Instance Methods
4167 [EditorBrowsable(EditorBrowsableState.Advanced)]
4168 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
4169 // turns out this method causes handle
4170 // creation in 1.1. at first I thought this
4171 // would be accomplished just by using
4172 // get_AccessibilityObject, which would route
4173 // through CreateAccessibilityInstance, which
4174 // calls CreateControl. This isn't the case,
4175 // though (as overriding
4176 // CreateAccessibilityInstance and adding a
4177 // CWL shows nothing. So we fudge it and put
4178 // a CreateHandle here.
4181 if (accessibility_object != null && accessibility_object is ControlAccessibleObject)
4182 ((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, childID);
4185 [EditorBrowsable (EditorBrowsableState.Advanced)]
4186 protected void AccessibilityNotifyClients (AccessibleEvents accEvent, int objectID, int childID)
4188 if (accessibility_object != null && accessibility_object is ControlAccessibleObject)
4189 ((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, objectID, childID);
4192 [EditorBrowsable(EditorBrowsableState.Advanced)]
4193 protected virtual AccessibleObject CreateAccessibilityInstance() {
4195 return new Control.ControlAccessibleObject(this);
4198 [EditorBrowsable(EditorBrowsableState.Advanced)]
4199 protected virtual ControlCollection CreateControlsInstance() {
4200 return new ControlCollection(this);
4203 [EditorBrowsable(EditorBrowsableState.Advanced)]
4204 protected virtual void CreateHandle() {
4206 throw new ObjectDisposedException(GetType().FullName);
4209 if (IsHandleCreated && !is_recreating) {
4213 CreateParams create_params = CreateParams;
4214 window.CreateHandle(create_params);
4216 if (window.Handle != IntPtr.Zero) {
4217 creator_thread = Thread.CurrentThread;
4219 XplatUI.EnableWindow(window.Handle, is_enabled);
4221 if (clip_region != null) {
4222 XplatUI.SetClipRegion(window.Handle, clip_region);
4225 // Set our handle with our parent
4226 if ((parent != null) && (parent.IsHandleCreated)) {
4227 XplatUI.SetParent(window.Handle, parent.Handle);
4231 XplatUI.SetAllowDrop (window.Handle, allow_drop);
4233 // Find out where the window manager placed us
4234 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
4235 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
4238 Rectangle save_bounds = explicit_bounds;
4240 explicit_bounds = save_bounds;
4244 [EditorBrowsable(EditorBrowsableState.Advanced)]
4245 protected virtual void DefWndProc(ref Message m) {
4246 window.DefWndProc(ref m);
4249 [EditorBrowsable(EditorBrowsableState.Advanced)]
4250 protected virtual void DestroyHandle() {
4251 if (IsHandleCreated) {
4252 if (window != null) {
4253 window.DestroyHandle();
4258 protected virtual AccessibleObject GetAccessibilityObjectById (int objectId)
4260 // XXX need to implement this.
4264 protected internal AutoSizeMode GetAutoSizeMode ()
4266 return auto_size_mode;
4269 [EditorBrowsable (EditorBrowsableState.Advanced)]
4270 protected virtual Rectangle GetScaledBounds (Rectangle bounds, SizeF factor, BoundsSpecified specified)
4272 // Top level controls do not scale location
4274 if ((specified & BoundsSpecified.X) == BoundsSpecified.X)
4275 bounds.X = (int)Math.Round (bounds.X * factor.Width);
4276 if ((specified & BoundsSpecified.Y) == BoundsSpecified.Y)
4277 bounds.Y = (int)Math.Round (bounds.Y * factor.Height);
4280 if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width && !GetStyle (ControlStyles.FixedWidth)) {
4281 int border = (this is ComboBox) ? (ThemeEngine.Current.Border3DSize.Width * 2) :
4282 (this.bounds.Width - this.client_size.Width);
4283 bounds.Width = (int)Math.Round ((bounds.Width - border) * factor.Width + border);
4285 if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height && !GetStyle (ControlStyles.FixedHeight)) {
4286 int border = (this is ComboBox) ? (ThemeEngine.Current.Border3DSize.Height * 2) :
4287 (this.bounds.Height - this.client_size.Height);
4288 bounds.Height = (int)Math.Round ((bounds.Height - border) * factor.Height + border);
4294 private Rectangle GetScaledBoundsOld (Rectangle bounds, SizeF factor, BoundsSpecified specified)
4296 RectangleF new_bounds = new RectangleF(bounds.Location, bounds.Size);
4298 // Top level controls do not scale location
4300 if ((specified & BoundsSpecified.X) == BoundsSpecified.X)
4301 new_bounds.X *= factor.Width;
4302 if ((specified & BoundsSpecified.Y) == BoundsSpecified.Y)
4303 new_bounds.Y *= factor.Height;
4306 if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width && !GetStyle (ControlStyles.FixedWidth)) {
4307 int border = (this is Form) ? (this.bounds.Width - this.client_size.Width) : 0;
4308 new_bounds.Width = ((new_bounds.Width - border) * factor.Width + border);
4310 if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height && !GetStyle (ControlStyles.FixedHeight)) {
4311 int border = (this is Form) ? (this.bounds.Height - this.client_size.Height) : 0;
4312 new_bounds.Height = ((new_bounds.Height - border) * factor.Height + border);
4315 bounds.X = (int)Math.Round (new_bounds.X);
4316 bounds.Y = (int)Math.Round (new_bounds.Y);
4317 bounds.Width = (int)Math.Round (new_bounds.Right) - bounds.X;
4318 bounds.Height = (int)Math.Round (new_bounds.Bottom) - bounds.Y;
4323 protected internal bool GetStyle(ControlStyles flag) {
4324 return (control_style & flag) != 0;
4327 protected bool GetTopLevel() {
4331 [EditorBrowsable(EditorBrowsableState.Advanced)]
4332 protected virtual void InitLayout() {
4335 [EditorBrowsable(EditorBrowsableState.Advanced)]
4336 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
4337 toInvoke.OnGotFocus(e);
4340 [EditorBrowsable(EditorBrowsableState.Advanced)]
4341 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
4342 toInvoke.OnLostFocus(e);
4345 [EditorBrowsable(EditorBrowsableState.Advanced)]
4346 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
4347 toInvoke.OnClick(e);
4350 protected void InvokePaint(Control c, PaintEventArgs e) {
4354 protected void InvokePaintBackground(Control c, PaintEventArgs e) {
4355 c.OnPaintBackground (e);
4358 protected virtual bool IsInputChar (char charCode) {
4359 // XXX on MS.NET this method causes the handle to be created..
4360 if (!IsHandleCreated)
4363 return IsInputCharInternal (charCode);
4366 internal virtual bool IsInputCharInternal (char charCode) {
4370 protected virtual bool IsInputKey (Keys keyData) {
4371 // Doc says this one calls IsInputChar; not sure what to do with that
4375 [EditorBrowsable(EditorBrowsableState.Advanced)]
4376 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
4380 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
4381 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
4385 if (parent != null) {
4386 return parent.ProcessCmdKey(ref msg, keyData);
4392 protected virtual bool ProcessDialogChar(char charCode) {
4393 if (parent != null) {
4394 return parent.ProcessDialogChar (charCode);
4400 protected virtual bool ProcessDialogKey (Keys keyData) {
4401 if (parent != null) {
4402 return parent.ProcessDialogKey (keyData);
4408 protected virtual bool ProcessKeyEventArgs (ref Message m)
4410 KeyEventArgs key_event;
4413 case (int)Msg.WM_SYSKEYDOWN:
4414 case (int)Msg.WM_KEYDOWN: {
4415 key_event = new KeyEventArgs ((Keys) m.WParam.ToInt32 ());
4416 OnKeyDown (key_event);
4417 suppressing_key_press = key_event.SuppressKeyPress;
4418 return key_event.Handled;
4421 case (int)Msg.WM_SYSKEYUP:
4422 case (int)Msg.WM_KEYUP: {
4423 key_event = new KeyEventArgs ((Keys) m.WParam.ToInt32 ());
4424 OnKeyUp (key_event);
4425 return key_event.Handled;
4428 case (int)Msg.WM_SYSCHAR:
4429 case (int)Msg.WM_CHAR: {
4430 if (suppressing_key_press)
4432 KeyPressEventArgs key_press_event;
4434 key_press_event = new KeyPressEventArgs ((char) m.WParam);
4435 OnKeyPress(key_press_event);
4436 m.WParam = (IntPtr) key_press_event.KeyChar;
4437 return key_press_event.Handled;
4448 protected internal virtual bool ProcessKeyMessage (ref Message m)
4450 if (parent != null) {
4451 if (parent.ProcessKeyPreview (ref m))
4455 return ProcessKeyEventArgs (ref m);
4458 protected virtual bool ProcessKeyPreview (ref Message m) {
4460 return parent.ProcessKeyPreview(ref m);
4465 protected virtual bool ProcessMnemonic(char charCode) {
4470 [EditorBrowsable(EditorBrowsableState.Advanced)]
4471 protected void RaiseDragEvent(object key, DragEventArgs e) {
4475 [EditorBrowsable(EditorBrowsableState.Advanced)]
4476 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
4480 [EditorBrowsable(EditorBrowsableState.Advanced)]
4481 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
4485 [EditorBrowsable(EditorBrowsableState.Advanced)]
4486 protected void RaisePaintEvent(object key, PaintEventArgs e) {
4490 private void SetIsRecreating () {
4493 foreach (Control c in Controls.GetAllControls()) {
4494 c.SetIsRecreating ();
4498 [EditorBrowsable(EditorBrowsableState.Advanced)]
4499 protected void RecreateHandle() {
4500 if (!IsHandleCreated)
4504 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
4509 if (IsHandleCreated) {
4511 Console.WriteLine(" + handle is created, destroying it.");
4514 // WM_DESTROY will CreateHandle for us
4517 Console.WriteLine(" + handle is not created, creating it.");
4525 is_recreating = false;
4527 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4533 [EditorBrowsable(EditorBrowsableState.Advanced)]
4534 protected void ResetMouseEventArgs() {
4538 [EditorBrowsable(EditorBrowsableState.Advanced)]
4539 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
4540 if (right_to_left == RightToLeft.No) {
4545 case ContentAlignment.TopLeft: {
4546 return ContentAlignment.TopRight;
4549 case ContentAlignment.TopRight: {
4550 return ContentAlignment.TopLeft;
4553 case ContentAlignment.MiddleLeft: {
4554 return ContentAlignment.MiddleRight;
4557 case ContentAlignment.MiddleRight: {
4558 return ContentAlignment.MiddleLeft;
4561 case ContentAlignment.BottomLeft: {
4562 return ContentAlignment.BottomRight;
4565 case ContentAlignment.BottomRight: {
4566 return ContentAlignment.BottomLeft;
4570 // if it's center it doesn't change
4576 [EditorBrowsable(EditorBrowsableState.Advanced)]
4577 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
4578 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
4582 if (align == HorizontalAlignment.Left) {
4583 return HorizontalAlignment.Right;
4586 // align must be HorizontalAlignment.Right
4587 return HorizontalAlignment.Left;
4590 [EditorBrowsable(EditorBrowsableState.Advanced)]
4591 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
4592 if (right_to_left == RightToLeft.No) {
4596 if (align == LeftRightAlignment.Left) {
4597 return LeftRightAlignment.Right;
4600 // align must be LeftRightAlignment.Right;
4601 return LeftRightAlignment.Left;
4604 [EditorBrowsable(EditorBrowsableState.Advanced)]
4605 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
4606 return RtlTranslateAlignment(align);
4609 [EditorBrowsable(EditorBrowsableState.Advanced)]
4610 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
4611 return RtlTranslateAlignment(align);
4614 [EditorBrowsable(EditorBrowsableState.Advanced)]
4615 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
4616 return RtlTranslateAlignment(align);
4619 [EditorBrowsable (EditorBrowsableState.Advanced)]
4620 protected virtual void ScaleControl (SizeF factor, BoundsSpecified specified)
4622 Rectangle new_bounds = GetScaledBounds (bounds, factor, specified);
4624 SetBounds (new_bounds.X, new_bounds.Y, new_bounds.Width, new_bounds.Height, specified);
4627 [EditorBrowsable (EditorBrowsableState.Never)]
4628 protected virtual void ScaleCore (float dx, float dy)
4630 Rectangle new_bounds = GetScaledBoundsOld (bounds, new SizeF (dx, dy), BoundsSpecified.All);
4634 SetBounds (new_bounds.X, new_bounds.Y, new_bounds.Width, new_bounds.Height, BoundsSpecified.All);
4636 if (ScaleChildrenInternal)
4637 foreach (Control c in Controls.GetAllControls ())
4643 protected virtual void Select(bool directed, bool forward) {
4644 IContainerControl container;
4646 container = GetContainerControl();
4647 if (container != null && (Control)container != this)
4648 container.ActiveControl = this;
4651 protected void SetAutoSizeMode (AutoSizeMode mode)
4653 if (auto_size_mode != mode) {
4654 auto_size_mode = mode;
4655 PerformLayout (this, "AutoSizeMode");
4659 [EditorBrowsable(EditorBrowsableState.Advanced)]
4660 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
4661 SetBoundsCoreInternal (x, y, width, height, specified);
4664 internal virtual void SetBoundsCoreInternal(int x, int y, int width, int height, BoundsSpecified specified) {
4665 // Nasty hack for 2.0 DateTimePicker
4666 height = OverrideHeight (height);
4668 Rectangle old_explicit = explicit_bounds;
4669 Rectangle new_bounds = new Rectangle (x, y, width, height);
4671 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
4672 if (IsHandleCreated) {
4673 XplatUI.SetWindowPos(Handle, x, y, width, height);
4675 // Win32 automatically changes negative width/height to 0.
4676 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
4677 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
4680 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
4683 // BoundsSpecified tells us which variables were programatic (user-set).
4684 // We need to store those in the explicit bounds
4685 if ((specified & BoundsSpecified.X) == BoundsSpecified.X)
4686 explicit_bounds.X = new_bounds.X;
4688 explicit_bounds.X = old_explicit.X;
4690 if ((specified & BoundsSpecified.Y) == BoundsSpecified.Y)
4691 explicit_bounds.Y = new_bounds.Y;
4693 explicit_bounds.Y = old_explicit.Y;
4695 if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width)
4696 explicit_bounds.Width = new_bounds.Width;
4698 explicit_bounds.Width = old_explicit.Width;
4700 if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height)
4701 explicit_bounds.Height = new_bounds.Height;
4703 explicit_bounds.Height = old_explicit.Height;
4705 // We need to store the explicit bounds because UpdateBounds is always going
4706 // to change it, and we have to fix it. However, UpdateBounds also calls
4707 // OnLocationChanged, OnSizeChanged, and OnClientSizeChanged. The user can
4708 // override those or use those events to change the size explicitly, and we
4709 // can't undo those changes. So if the bounds after calling UpdateBounds are
4710 // the same as the ones we sent it, we need to fix the explicit bounds. If
4711 // it's not the same as we sent UpdateBounds, then someone else changed it, and
4712 // we better not mess it up. Fun stuff.
4713 Rectangle stored_explicit_bounds = explicit_bounds;
4715 UpdateBounds(x, y, width, height);
4717 if (explicit_bounds.X == x)
4718 explicit_bounds.X = stored_explicit_bounds.X;
4720 if (explicit_bounds.Y == y)
4721 explicit_bounds.Y = stored_explicit_bounds.Y;
4723 if (explicit_bounds.Width == width)
4724 explicit_bounds.Width = stored_explicit_bounds.Width;
4726 if (explicit_bounds.Height == height)
4727 explicit_bounds.Height = stored_explicit_bounds.Height;
4730 [EditorBrowsable(EditorBrowsableState.Advanced)]
4731 protected virtual void SetClientSizeCore(int x, int y) {
4732 Size NewSize = InternalSizeFromClientSize (new Size (x, y));
4734 if (NewSize != Size.Empty)
4735 SetBounds (bounds.X, bounds.Y, NewSize.Width, NewSize.Height, BoundsSpecified.Size);
4738 [EditorBrowsable(EditorBrowsableState.Advanced)]
4739 protected internal void SetStyle(ControlStyles flag, bool value) {
4741 control_style |= flag;
4743 control_style &= ~flag;
4747 protected void SetTopLevel(bool value) {
4748 if ((GetTopLevel() != value) && (parent != null)) {
4749 throw new ArgumentException ("Cannot change toplevel style of a parented control.");
4753 if (IsHandleCreated && value != Visible) {
4757 // XXX MS.NET causes handle to be created here
4758 if (!IsHandleCreated)
4761 is_toplevel = value;
4764 protected virtual void SetVisibleCore(bool value) {
4765 if (value != is_visible) {
4768 if (is_visible && ((window.Handle == IntPtr.Zero) || !is_created)) {
4770 if (!(this is Form))
4774 if (IsHandleCreated) {
4775 XplatUI.SetVisible (Handle, is_visible, true);
4777 if (parent != null && parent.IsHandleCreated) {
4778 parent.Invalidate (bounds);
4783 } else if (is_visible && this is Form) {
4784 // If we are Min or Max, we won't get a WM_SHOWWINDOW from SetWindowState,
4785 // so we need to manually create our children, and set them visible
4786 // (This normally happens in WmShowWindow.)
4787 if ((this as Form).WindowState != FormWindowState.Normal)
4788 OnVisibleChanged (EventArgs.Empty);
4790 // Explicitly move Toplevel windows to where we want them;
4791 // apparently moving unmapped toplevel windows doesn't work
4792 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
4794 // If we are becoming visible, z-order may have changed while
4795 // we were invisible, so update our z-order position
4797 parent.UpdateZOrderOfChild (this);
4800 if (!(this is Form))
4801 OnVisibleChanged (EventArgs.Empty);
4804 OnVisibleChanged(EventArgs.Empty);
4809 [EditorBrowsable (EditorBrowsableState.Advanced)]
4810 protected virtual Size SizeFromClientSize (Size clientSize) {
4811 return InternalSizeFromClientSize (clientSize);
4814 [EditorBrowsable(EditorBrowsableState.Advanced)]
4815 protected void UpdateBounds() {
4816 if (!IsHandleCreated)
4826 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
4828 UpdateBounds(x, y, width, height, client_width, client_height);
4831 [EditorBrowsable(EditorBrowsableState.Advanced)]
4832 protected void UpdateBounds(int x, int y, int width, int height) {
4836 // Calculate client rectangle
4837 rect = new Rectangle(0, 0, 0, 0);
4840 XplatUI.CalculateWindowRect(ref rect, cp, cp.menu, out rect);
4841 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
4844 [EditorBrowsable(EditorBrowsableState.Advanced)]
4845 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
4846 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
4848 bool resized = false;
4850 // Needed to generate required notifications
4851 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
4855 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
4862 bounds.Height=height;
4864 // Assume explicit bounds set. SetBoundsCore will restore old bounds
4866 explicit_bounds = bounds;
4868 client_size.Width=clientWidth;
4869 client_size.Height=clientHeight;
4872 OnLocationChanged(EventArgs.Empty);
4874 if (!background_color.IsEmpty && background_color.A < byte.MaxValue)
4879 OnSizeInitializedOrChanged ();
4880 OnSizeChanged(EventArgs.Empty);
4881 OnClientSizeChanged (EventArgs.Empty);
4885 [EditorBrowsable(EditorBrowsableState.Advanced)]
4886 protected void UpdateStyles() {
4887 if (!IsHandleCreated) {
4891 XplatUI.SetWindowStyle(window.Handle, CreateParams);
4892 OnStyleChanged(EventArgs.Empty);
4895 private void UpdateZOrderOfChild(Control child) {
4896 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this) && Hwnd.ObjectFromHandle(child.Handle).Mapped) {
4897 // Need to take into account all controls
4898 Control [] all_controls = child_controls.GetAllControls ();
4900 int index = Array.IndexOf (all_controls, child);
4902 for (; index > 0; index--) {
4903 if (!all_controls [index - 1].IsHandleCreated || !all_controls [index - 1].VisibleInternal || !Hwnd.ObjectFromHandle(all_controls [index - 1].Handle).Mapped)
4909 XplatUI.SetZOrder(child.Handle, all_controls [index - 1].Handle, false, false);
4911 IntPtr after = AfterTopMostControl ();
4912 if (after != IntPtr.Zero && after != child.Handle)
4913 XplatUI.SetZOrder (child.Handle, after, false, false);
4915 XplatUI.SetZOrder (child.Handle, IntPtr.Zero, true, false);
4920 // Override this if there is a control that shall always remain on
4921 // top of other controls (such as scrollbars). If there are several
4922 // of these controls, the bottom-most should be returned.
4923 internal virtual IntPtr AfterTopMostControl () {
4927 // internal because we need to call it from ScrollableControl.OnVisibleChanged
4928 internal void UpdateChildrenZOrder() {
4929 Control [] controls;
4931 if (!IsHandleCreated) {
4935 // XXX This code is severely broken. It leaks
4936 // the "zero_sized" abstraction out of the X11
4937 // backend and into Control.cs. It'll work on
4938 // windows simply by virtue of windows never
4939 // setting that field to true.
4941 // basically what we need to guard against is
4942 // calling XplatUI.SetZOrder on an hwnd that
4943 // corresponds to an unmapped X window.
4945 // Also, explicitly send implicit controls to the back.
4946 if (child_controls.ImplicitControls == null) {
4947 controls = new Control [child_controls.Count];
4948 child_controls.CopyTo (controls, 0);
4950 controls = new Control [child_controls.Count + child_controls.ImplicitControls.Count];
4951 child_controls.CopyTo (controls, 0);
4952 child_controls.ImplicitControls.CopyTo (controls, child_controls.Count);
4955 ArrayList children_to_order = new ArrayList ();
4957 for (int i = 0; i < controls.Length; i ++) {
4958 if (!controls[i].IsHandleCreated || !controls[i].VisibleInternal)
4961 Hwnd hwnd = Hwnd.ObjectFromHandle (controls[i].Handle);
4962 if (hwnd == null || hwnd.zero_sized)
4965 children_to_order.Add (controls[i]);
4968 for (int i = 1; i < children_to_order.Count; i ++) {
4969 Control upper = (Control)children_to_order[i-1];
4970 Control lower = (Control)children_to_order[i];
4972 XplatUI.SetZOrder(lower.Handle, upper.Handle, false, false);
4976 [EditorBrowsable(EditorBrowsableState.Advanced)]
4977 protected void UpdateZOrder() {
4978 if (parent != null) {
4979 parent.UpdateZOrderOfChild(this);
4983 protected virtual void WndProc(ref Message m) {
4985 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
4987 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
4991 switch((Msg)m.Msg) {
4992 case Msg.WM_DESTROY: {
4997 case Msg.WM_WINDOWPOSCHANGED: {
4998 WmWindowPosChanged(ref m);
5002 // Nice description of what should happen when handling WM_PAINT
5003 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
5004 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
5005 case Msg.WM_PAINT: {
5010 // The DefWndProc will never have to handle this, we always paint the background in managed code
5011 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
5012 // here but it just makes things more complicated...
5013 case Msg.WM_ERASEBKGND: {
5014 WmEraseBackground (ref m);
5018 case Msg.WM_LBUTTONUP: {
5019 WmLButtonUp (ref m);
5023 case Msg.WM_LBUTTONDOWN: {
5024 WmLButtonDown (ref m);
5028 case Msg.WM_LBUTTONDBLCLK: {
5029 WmLButtonDblClick (ref m);
5033 case Msg.WM_MBUTTONUP: {
5034 WmMButtonUp (ref m);
5038 case Msg.WM_MBUTTONDOWN: {
5039 WmMButtonDown (ref m);
5043 case Msg.WM_MBUTTONDBLCLK: {
5044 WmMButtonDblClick (ref m);
5048 case Msg.WM_RBUTTONUP: {
5049 WmRButtonUp (ref m);
5053 case Msg.WM_RBUTTONDOWN: {
5054 WmRButtonDown (ref m);
5058 case Msg.WM_RBUTTONDBLCLK: {
5059 WmRButtonDblClick (ref m);
5063 case Msg.WM_CONTEXTMENU: {
5064 WmContextMenu (ref m);
5068 case Msg.WM_MOUSEWHEEL: {
5069 WmMouseWheel (ref m);
5073 case Msg.WM_MOUSEMOVE: {
5074 WmMouseMove (ref m);
5078 case Msg.WM_SHOWWINDOW: {
5079 WmShowWindow (ref m);
5083 case Msg.WM_CREATE: {
5088 case Msg.WM_MOUSE_ENTER: {
5089 WmMouseEnter (ref m);
5093 case Msg.WM_MOUSELEAVE: {
5094 WmMouseLeave (ref m);
5098 case Msg.WM_MOUSEHOVER: {
5099 WmMouseHover (ref m);
5103 case Msg.WM_SYSKEYUP: {
5108 case Msg.WM_SYSKEYDOWN:
5109 case Msg.WM_KEYDOWN:
5111 case Msg.WM_SYSCHAR:
5122 case Msg.WM_KILLFOCUS: {
5123 WmKillFocus (ref m);
5127 case Msg.WM_SETFOCUS: {
5132 case Msg.WM_SYSCOLORCHANGE: {
5133 WmSysColorChange (ref m);
5137 case Msg.WM_SETCURSOR: {
5138 WmSetCursor (ref m);
5142 case Msg.WM_CAPTURECHANGED: {
5143 WmCaptureChanged (ref m);
5147 case Msg.WM_CHANGEUISTATE: {
5148 WmChangeUIState (ref m);
5152 case Msg.WM_UPDATEUISTATE: {
5153 WmUpdateUIState (ref m);
5163 #endregion // Public Instance Methods
5167 private void WmDestroy (ref Message m) {
5168 OnHandleDestroyed(EventArgs.Empty);
5170 IntPtr handle = window.Handle;
5172 window.InvalidateHandle();
5175 if (is_recreating) {
5177 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
5181 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
5183 is_recreating = false;
5187 is_disposing = false;
5192 private void WmWindowPosChanged (ref Message m) {
5194 Rectangle save_bounds = explicit_bounds;
5196 explicit_bounds = save_bounds;
5197 if (GetStyle(ControlStyles.ResizeRedraw)) {
5204 // Nice description of what should happen when handling WM_PAINT
5205 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
5206 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
5207 private void WmPaint (ref Message m) {
5208 IntPtr handle = Handle;
5210 PaintEventArgs paint_event = XplatUI.PaintEventStart (ref m, handle, true);
5212 if (paint_event == null)
5215 DoubleBuffer current_buffer = null;
5216 if (UseDoubleBuffering) {
5217 current_buffer = GetBackBuffer ();
5218 // This optimization doesn't work when the area is invalidated
5219 // during a paint operation because finishing the paint operation
5220 // clears the invalidated region and then this thing keeps the new
5221 // invalidate from working. To re-enable this, we would need a
5222 // mechanism to allow for nested invalidates (see bug #328681)
5223 //if (!current_buffer.InvalidRegion.IsVisible (paint_event.ClipRectangle)) {
5224 // // Just blit the previous image
5225 // current_buffer.Blit (paint_event);
5226 // XplatUI.PaintEventEnd (ref m, handle, true);
5229 current_buffer.Start (paint_event);
5231 // If using OptimizedDoubleBuffer, ensure the clip region gets set
5232 if (GetStyle (ControlStyles.OptimizedDoubleBuffer))
5233 paint_event.Graphics.SetClip (Rectangle.Intersect (paint_event.ClipRectangle, this.ClientRectangle));
5235 if (!GetStyle(ControlStyles.Opaque)) {
5236 OnPaintBackground (paint_event);
5239 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
5240 OnPaintBackgroundInternal (paint_event);
5242 OnPaintInternal(paint_event);
5243 if (!paint_event.Handled) {
5244 OnPaint (paint_event);
5247 if (current_buffer != null) {
5248 current_buffer.End (paint_event);
5252 XplatUI.PaintEventEnd (ref m, handle, true);
5255 private void WmEraseBackground (ref Message m) {
5256 // The DefWndProc will never have to handle this, we always paint the background in managed code
5257 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
5258 // here but it just makes things more complicated...
5259 m.Result = (IntPtr)1;
5262 private void WmLButtonUp (ref Message m)
5265 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5266 ProcessActiveTracker (ref m);
5272 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
5274 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5277 HandleClick(mouse_clicks, me);
5280 if (InternalCapture) {
5281 InternalCapture = false;
5284 if (mouse_clicks > 1) {
5289 private void WmLButtonDown (ref Message m)
5292 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5293 ProcessActiveTracker (ref m);
5297 ValidationFailed = false;
5299 Select (true, true);
5301 if (!ValidationFailed) {
5302 InternalCapture = true;
5303 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5304 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5309 private void WmLButtonDblClick (ref Message m) {
5310 InternalCapture = true;
5312 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5313 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5317 private void WmMButtonUp (ref Message m) {
5320 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
5322 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5325 HandleClick(mouse_clicks, me);
5327 if (InternalCapture) {
5328 InternalCapture = false;
5330 if (mouse_clicks > 1) {
5335 private void WmMButtonDown (ref Message m) {
5336 InternalCapture = true;
5337 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5338 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5342 private void WmMButtonDblClick (ref Message m) {
5343 InternalCapture = true;
5345 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5346 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5350 private void WmRButtonUp (ref Message m)
5353 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5354 ProcessActiveTracker (ref m);
5361 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
5362 pt = PointToScreen(pt);
5364 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
5366 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5369 HandleClick(mouse_clicks, me);
5371 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
5374 if (InternalCapture) {
5375 InternalCapture = false;
5378 if (mouse_clicks > 1) {
5383 private void WmRButtonDown (ref Message m)
5386 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5387 ProcessActiveTracker (ref m);
5391 InternalCapture = true;
5392 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5393 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5397 private void WmRButtonDblClick (ref Message m) {
5398 InternalCapture = true;
5400 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5401 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5405 private void WmContextMenu (ref Message m) {
5406 if (context_menu != null) {
5409 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
5411 if (pt.X == -1 || pt.Y == -1) {
5412 pt.X = (this.Width / 2) + this.Left;
5413 pt.Y = (this.Height / 2) + this.Top;
5414 pt = this.PointToScreen (pt);
5417 context_menu.Show (this, PointToClient (pt));
5421 // If there isn't a regular context menu, show the Strip version
5422 if (context_menu == null && context_menu_strip != null) {
5425 pt = new Point (LowOrder ((int)m.LParam.ToInt32 ()), HighOrder ((int)m.LParam.ToInt32 ()));
5427 if (pt.X == -1 || pt.Y == -1) {
5428 pt.X = (this.Width / 2) + this.Left;
5429 pt.Y = (this.Height /2) + this.Top;
5430 pt = this.PointToScreen (pt);
5433 context_menu_strip.SetSourceControl (this);
5434 context_menu_strip.Show (this, PointToClient (pt));
5440 private void WmCreate (ref Message m) {
5441 OnHandleCreated(EventArgs.Empty);
5444 private void WmMouseWheel (ref Message m) {
5446 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((long) m.WParam),
5447 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5448 HighOrder((long)m.WParam)));
5452 private void WmMouseMove (ref Message m) {
5453 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5454 MouseEventArgs args = new MouseEventArgs (
5455 FromParamToMouseButtons ((int)m.WParam.ToInt32 ()),
5457 Control.MousePosition.X,
5458 Control.MousePosition.Y,
5461 active_tracker.OnMotion (args);
5465 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5467 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5471 private void WmMouseEnter (ref Message m) {
5476 OnMouseEnter(EventArgs.Empty);
5479 private void WmMouseLeave (ref Message m) {
5481 OnMouseLeave(EventArgs.Empty);
5484 private void WmMouseHover (ref Message m) {
5485 OnMouseHover(EventArgs.Empty);
5488 private void WmShowWindow (ref Message m) {
5492 Form frm = this as Form;
5493 if (m.WParam.ToInt32() != 0) {
5494 if (m.LParam.ToInt32 () == 0) {
5497 // Make sure all our children are properly parented to us
5498 Control [] controls = child_controls.GetAllControls ();
5499 // bool parented = false;
5500 for (int i=0; i<controls.Length; i++) {
5501 if (controls [i].is_visible && controls[i].IsHandleCreated)
5502 if (XplatUI.GetParent (controls[i].Handle) != window.Handle) {
5503 XplatUI.SetParent(controls[i].Handle, window.Handle);
5510 UpdateChildrenZOrder ();
5513 if (parent != null && Focused) {
5515 // Need to start at parent, GetContainerControl might return ourselves if we're a container
5516 container = (Control)parent.GetContainerControl();
5517 if (container != null && (frm == null || !frm.IsMdiChild)) {
5518 container.SelectNextControl(this, true, true, true, true);
5524 frm.waiting_showwindow = false;
5526 // If the form is Max/Min, it got its OnVisibleChanged in SetVisibleCore
5528 if (!IsRecreating && (frm.IsMdiChild || frm.WindowState == FormWindowState.Normal)) /* XXX make sure this works for mdi forms */
5529 OnVisibleChanged(EventArgs.Empty);
5530 } else if (is_toplevel)
5531 OnVisibleChanged(EventArgs.Empty);
5534 private void WmSysKeyUp (ref Message m) {
5535 if (ProcessKeyMessage(ref m)) {
5536 m.Result = IntPtr.Zero;
5540 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
5544 if (form != null && form.ActiveMenu != null) {
5545 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
5548 if (ToolStripManager.ProcessMenuKey (ref m))
5555 private void WmKeys (ref Message m)
5557 if (ProcessKeyMessage(ref m)) {
5558 m.Result = IntPtr.Zero;
5564 private void WmHelp (ref Message m) {
5566 if (m.LParam != IntPtr.Zero) {
5569 hi = new HELPINFO();
5571 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
5572 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
5574 mouse_pos = Control.MousePosition;
5576 OnHelpRequested(new HelpEventArgs(mouse_pos));
5577 m.Result = (IntPtr)1;
5580 private void WmKillFocus (ref Message m) {
5581 this.has_focus = false;
5582 OnLostFocus (EventArgs.Empty);
5585 private void WmSetFocus (ref Message m) {
5587 this.has_focus = true;
5588 OnGotFocus (EventArgs.Empty);
5592 private void WmSysColorChange (ref Message m) {
5593 ThemeEngine.Current.ResetDefaults();
5594 OnSystemColorsChanged(EventArgs.Empty);
5597 private void WmSetCursor (ref Message m) {
5598 if ((cursor == null && use_wait_cursor == false) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
5603 XplatUI.SetCursor(window.Handle, Cursor.handle);
5604 m.Result = (IntPtr)1;
5607 private void WmCaptureChanged (ref Message m) {
5608 is_captured = false;
5609 OnMouseCaptureChanged (EventArgs.Empty);
5610 m.Result = (IntPtr) 0;
5613 private void WmChangeUIState (ref Message m) {
5614 foreach (Control control in Controls) {
5615 XplatUI.SendMessage (control.Handle, Msg.WM_UPDATEUISTATE, m.WParam, m.LParam);
5619 private void WmUpdateUIState (ref Message m) {
5620 int action = LowOrder (m.WParam.ToInt32 ());
5621 int element = HighOrder (m.WParam.ToInt32 ());
5623 if (action == (int) MsgUIState.UIS_INITIALIZE)
5626 UICues cues = UICues.None;
5628 if ((element & (int) MsgUIState.UISF_HIDEACCEL) != 0) {
5629 if ((action == (int) MsgUIState.UIS_CLEAR) != show_keyboard_cues) {
5630 cues |= UICues.ChangeKeyboard;
5631 show_keyboard_cues = (action == (int) MsgUIState.UIS_CLEAR);
5635 if ((element & (int) MsgUIState.UISF_HIDEFOCUS) != 0) {
5636 if ((action == (int) MsgUIState.UIS_CLEAR) != show_focus_cues) {
5637 cues |= UICues.ChangeFocus;
5638 show_focus_cues = (action == (int) MsgUIState.UIS_CLEAR);
5642 if ((cues & UICues.Changed) != UICues.None) {
5643 OnChangeUICues (new UICuesEventArgs (cues));
5650 #region OnXXX methods
5651 protected virtual void OnAutoSizeChanged (EventArgs e)
5653 EventHandler eh = (EventHandler)(Events[AutoSizeChangedEvent]);
5658 [EditorBrowsable (EditorBrowsableState.Advanced)]
5659 protected virtual void OnBackColorChanged(EventArgs e) {
5660 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
5663 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
5666 [EditorBrowsable(EditorBrowsableState.Advanced)]
5667 protected virtual void OnBackgroundImageChanged(EventArgs e) {
5668 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
5671 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
5674 [EditorBrowsable (EditorBrowsableState.Advanced)]
5675 protected virtual void OnBackgroundImageLayoutChanged (EventArgs e)
5677 EventHandler eh = (EventHandler)(Events[BackgroundImageLayoutChangedEvent]);
5682 [EditorBrowsable(EditorBrowsableState.Advanced)]
5683 protected virtual void OnBindingContextChanged(EventArgs e) {
5684 CheckDataBindings ();
5685 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
5688 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
5691 [EditorBrowsable(EditorBrowsableState.Advanced)]
5692 protected virtual void OnCausesValidationChanged(EventArgs e) {
5693 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
5698 [EditorBrowsable(EditorBrowsableState.Advanced)]
5699 protected virtual void OnChangeUICues(UICuesEventArgs e) {
5700 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
5705 [EditorBrowsable(EditorBrowsableState.Advanced)]
5706 protected virtual void OnClick(EventArgs e) {
5707 EventHandler eh = (EventHandler)(Events [ClickEvent]);
5712 [EditorBrowsable (EditorBrowsableState.Advanced)]
5713 protected virtual void OnClientSizeChanged (EventArgs e)
5715 EventHandler eh = (EventHandler)(Events[ClientSizeChangedEvent]);
5720 [EditorBrowsable(EditorBrowsableState.Advanced)]
5721 protected virtual void OnContextMenuChanged(EventArgs e) {
5722 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
5727 [EditorBrowsable (EditorBrowsableState.Advanced)]
5728 protected virtual void OnContextMenuStripChanged (EventArgs e) {
5729 EventHandler eh = (EventHandler)(Events [ContextMenuStripChangedEvent]);
5734 [EditorBrowsable(EditorBrowsableState.Advanced)]
5735 protected virtual void OnControlAdded(ControlEventArgs e) {
5736 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
5741 [EditorBrowsable(EditorBrowsableState.Advanced)]
5742 protected virtual void OnControlRemoved(ControlEventArgs e) {
5743 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
5748 [EditorBrowsable(EditorBrowsableState.Advanced)]
5749 protected virtual void OnCreateControl() {
5753 [EditorBrowsable(EditorBrowsableState.Advanced)]
5754 protected virtual void OnCursorChanged(EventArgs e) {
5755 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
5759 for (int i = 0; i < child_controls.Count; i++) child_controls[i].OnParentCursorChanged (e);
5762 [EditorBrowsable(EditorBrowsableState.Advanced)]
5763 protected virtual void OnDockChanged(EventArgs e) {
5764 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
5769 [EditorBrowsable(EditorBrowsableState.Advanced)]
5770 protected virtual void OnDoubleClick(EventArgs e) {
5771 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
5776 [EditorBrowsable(EditorBrowsableState.Advanced)]
5777 protected virtual void OnDragDrop(DragEventArgs drgevent) {
5778 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
5780 eh (this, drgevent);
5783 [EditorBrowsable(EditorBrowsableState.Advanced)]
5784 protected virtual void OnDragEnter(DragEventArgs drgevent) {
5785 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
5787 eh (this, drgevent);
5790 [EditorBrowsable(EditorBrowsableState.Advanced)]
5791 protected virtual void OnDragLeave(EventArgs e) {
5792 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
5797 [EditorBrowsable(EditorBrowsableState.Advanced)]
5798 protected virtual void OnDragOver(DragEventArgs drgevent) {
5799 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
5801 eh (this, drgevent);
5804 [EditorBrowsable(EditorBrowsableState.Advanced)]
5805 protected virtual void OnEnabledChanged(EventArgs e) {
5806 if (IsHandleCreated) {
5808 if (((Form)this).context == null) {
5809 XplatUI.EnableWindow(window.Handle, Enabled);
5812 XplatUI.EnableWindow(window.Handle, Enabled);
5817 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
5821 foreach (Control c in Controls.GetAllControls ())
5822 c.OnParentEnabledChanged (e);
5825 [EditorBrowsable(EditorBrowsableState.Advanced)]
5826 protected virtual void OnEnter(EventArgs e) {
5827 EventHandler eh = (EventHandler)(Events [EnterEvent]);
5832 [EditorBrowsable(EditorBrowsableState.Advanced)]
5833 protected virtual void OnFontChanged(EventArgs e) {
5834 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
5837 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
5840 [EditorBrowsable(EditorBrowsableState.Advanced)]
5841 protected virtual void OnForeColorChanged(EventArgs e) {
5842 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
5845 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
5848 [EditorBrowsable(EditorBrowsableState.Advanced)]
5849 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
5850 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
5852 eh (this, gfbevent);
5855 [EditorBrowsable(EditorBrowsableState.Advanced)]
5856 protected virtual void OnGotFocus(EventArgs e) {
5857 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
5862 [EditorBrowsable(EditorBrowsableState.Advanced)]
5863 protected virtual void OnHandleCreated(EventArgs e) {
5864 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
5869 [EditorBrowsable(EditorBrowsableState.Advanced)]
5870 protected virtual void OnHandleDestroyed(EventArgs e) {
5871 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
5876 internal void RaiseHelpRequested (HelpEventArgs hevent) {
5877 OnHelpRequested (hevent);
5880 [EditorBrowsable(EditorBrowsableState.Advanced)]
5881 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
5882 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
5887 protected virtual void OnImeModeChanged(EventArgs e) {
5888 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
5893 [EditorBrowsable(EditorBrowsableState.Advanced)]
5894 protected virtual void OnInvalidated(InvalidateEventArgs e) {
5895 if (UseDoubleBuffering) {
5896 // should this block be here? seems like it
5897 // would be more at home in
5898 // NotifyInvalidated..
5899 if (e.InvalidRect == ClientRectangle) {
5900 InvalidateBackBuffer ();
5901 } else if (backbuffer != null){
5902 // we need this Inflate call here so
5903 // that the border of the rectangle is
5904 // considered Visible (the
5905 // invalid_region.IsVisible call) in
5906 // the WM_PAINT handling below.
5907 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
5908 backbuffer.InvalidRegion.Union (r);
5912 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
5917 [EditorBrowsable(EditorBrowsableState.Advanced)]
5918 protected virtual void OnKeyDown(KeyEventArgs e) {
5919 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
5924 [EditorBrowsable(EditorBrowsableState.Advanced)]
5925 protected virtual void OnKeyPress(KeyPressEventArgs e) {
5926 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
5931 [EditorBrowsable(EditorBrowsableState.Advanced)]
5932 protected virtual void OnKeyUp(KeyEventArgs e) {
5933 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
5938 [EditorBrowsable(EditorBrowsableState.Advanced)]
5939 protected virtual void OnLayout(LayoutEventArgs levent) {
5940 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
5946 // If our layout changed our PreferredSize, our parent
5947 // needs to re-lay us out. However, it's not always possible to
5948 // be our preferred size, so only try once so we don't loop forever.
5949 if (Parent != null && AutoSize && !nested_layout && PreferredSize != s) {
5950 nested_layout = true;
5951 Parent.PerformLayout ();
5952 nested_layout = false;
5955 LayoutEngine.Layout (this, levent);
5958 [EditorBrowsable(EditorBrowsableState.Advanced)]
5959 protected virtual void OnLeave(EventArgs e) {
5960 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
5965 [EditorBrowsable(EditorBrowsableState.Advanced)]
5966 protected virtual void OnLocationChanged(EventArgs e) {
5968 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
5973 [EditorBrowsable(EditorBrowsableState.Advanced)]
5974 protected virtual void OnLostFocus(EventArgs e) {
5975 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
5980 protected virtual void OnMarginChanged (EventArgs e)
5982 EventHandler eh = (EventHandler)(Events[MarginChangedEvent]);
5986 [EditorBrowsable (EditorBrowsableState.Advanced)]
5987 protected virtual void OnMouseCaptureChanged (EventArgs e)
5989 EventHandler eh = (EventHandler)(Events [MouseCaptureChangedEvent]);
5994 [EditorBrowsable (EditorBrowsableState.Advanced)]
5995 protected virtual void OnMouseClick (MouseEventArgs e)
5997 MouseEventHandler eh = (MouseEventHandler)(Events [MouseClickEvent]);
6002 [EditorBrowsable (EditorBrowsableState.Advanced)]
6003 protected virtual void OnMouseDoubleClick (MouseEventArgs e)
6005 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDoubleClickEvent]);
6010 [EditorBrowsable(EditorBrowsableState.Advanced)]
6011 protected virtual void OnMouseDown(MouseEventArgs e) {
6012 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
6017 [EditorBrowsable(EditorBrowsableState.Advanced)]
6018 protected virtual void OnMouseEnter(EventArgs e) {
6019 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
6024 [EditorBrowsable(EditorBrowsableState.Advanced)]
6025 protected virtual void OnMouseHover(EventArgs e) {
6026 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
6031 [EditorBrowsable(EditorBrowsableState.Advanced)]
6032 protected virtual void OnMouseLeave(EventArgs e) {
6033 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
6038 [EditorBrowsable(EditorBrowsableState.Advanced)]
6039 protected virtual void OnMouseMove(MouseEventArgs e) {
6040 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
6045 [EditorBrowsable(EditorBrowsableState.Advanced)]
6046 protected virtual void OnMouseUp(MouseEventArgs e) {
6047 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
6052 [EditorBrowsable(EditorBrowsableState.Advanced)]
6053 protected virtual void OnMouseWheel(MouseEventArgs e) {
6054 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
6059 [EditorBrowsable(EditorBrowsableState.Advanced)]
6060 protected virtual void OnMove(EventArgs e) {
6061 EventHandler eh = (EventHandler)(Events [MoveEvent]);
6066 [EditorBrowsable(EditorBrowsableState.Advanced)]
6067 protected virtual void OnNotifyMessage(Message m) {
6071 protected virtual void OnPaddingChanged (EventArgs e) {
6072 EventHandler eh = (EventHandler) (Events [PaddingChangedEvent]);
6077 [EditorBrowsable(EditorBrowsableState.Advanced)]
6078 protected virtual void OnPaint(PaintEventArgs e) {
6079 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
6084 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
6088 internal virtual void OnPaintInternal(PaintEventArgs e) {
6092 [EditorBrowsable(EditorBrowsableState.Advanced)]
6093 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
6094 PaintControlBackground (pevent);
6097 [EditorBrowsable(EditorBrowsableState.Advanced)]
6098 protected virtual void OnParentBackColorChanged(EventArgs e) {
6099 if (background_color.IsEmpty && background_image==null) {
6101 OnBackColorChanged(e);
6105 [EditorBrowsable(EditorBrowsableState.Advanced)]
6106 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
6108 OnBackgroundImageChanged(e);
6111 [EditorBrowsable(EditorBrowsableState.Advanced)]
6112 protected virtual void OnParentBindingContextChanged(EventArgs e) {
6113 if (binding_context==null && Parent != null) {
6114 binding_context=Parent.binding_context;
6115 OnBindingContextChanged(e);
6119 [EditorBrowsable(EditorBrowsableState.Advanced)]
6120 protected virtual void OnParentChanged(EventArgs e) {
6121 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
6126 [EditorBrowsable (EditorBrowsableState.Advanced)]
6127 protected virtual void OnParentCursorChanged (EventArgs e)
6131 [EditorBrowsable (EditorBrowsableState.Advanced)]
6132 protected virtual void OnParentEnabledChanged(EventArgs e) {
6134 OnEnabledChanged(e);
6138 [EditorBrowsable(EditorBrowsableState.Advanced)]
6139 protected virtual void OnParentFontChanged(EventArgs e) {
6146 [EditorBrowsable(EditorBrowsableState.Advanced)]
6147 protected virtual void OnParentForeColorChanged(EventArgs e) {
6148 if (foreground_color.IsEmpty) {
6150 OnForeColorChanged(e);
6154 [EditorBrowsable(EditorBrowsableState.Advanced)]
6155 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
6156 if (right_to_left==RightToLeft.Inherit) {
6158 OnRightToLeftChanged(e);
6162 [EditorBrowsable(EditorBrowsableState.Advanced)]
6163 protected virtual void OnParentVisibleChanged(EventArgs e) {
6165 OnVisibleChanged(e);
6169 [EditorBrowsable(EditorBrowsableState.Advanced)]
6170 protected virtual void OnQueryContinueDrag (QueryContinueDragEventArgs qcdevent)
6172 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
6174 eh (this, qcdevent);
6177 [EditorBrowsable (EditorBrowsableState.Advanced)]
6178 protected virtual void OnPreviewKeyDown (PreviewKeyDownEventArgs e)
6180 PreviewKeyDownEventHandler eh = (PreviewKeyDownEventHandler)(Events[PreviewKeyDownEvent]);
6185 [EditorBrowsable (EditorBrowsableState.Advanced)]
6186 protected virtual void OnPrint (PaintEventArgs e)
6188 PaintEventHandler eh = (PaintEventHandler)(Events[PaintEvent]);
6193 [EditorBrowsable (EditorBrowsableState.Advanced)]
6194 protected virtual void OnRegionChanged (EventArgs e)
6196 EventHandler eh = (EventHandler)(Events[RegionChangedEvent]);
6201 [EditorBrowsable(EditorBrowsableState.Advanced)]
6202 protected virtual void OnResize(EventArgs e) {
6203 OnResizeInternal (e);
6206 internal virtual void OnResizeInternal (EventArgs e) {
6207 PerformLayout(this, "Bounds");
6209 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
6214 [EditorBrowsable(EditorBrowsableState.Advanced)]
6215 protected virtual void OnRightToLeftChanged(EventArgs e) {
6216 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
6219 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
6222 [EditorBrowsable(EditorBrowsableState.Advanced)]
6223 protected virtual void OnSizeChanged(EventArgs e) {
6224 DisposeBackBuffer ();
6226 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
6231 [EditorBrowsable(EditorBrowsableState.Advanced)]
6232 protected virtual void OnStyleChanged(EventArgs e) {
6233 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
6238 [EditorBrowsable(EditorBrowsableState.Advanced)]
6239 protected virtual void OnSystemColorsChanged(EventArgs e) {
6240 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
6245 [EditorBrowsable(EditorBrowsableState.Advanced)]
6246 protected virtual void OnTabIndexChanged(EventArgs e) {
6247 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
6252 [EditorBrowsable(EditorBrowsableState.Advanced)]
6253 protected virtual void OnTabStopChanged(EventArgs e) {
6254 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
6259 [EditorBrowsable(EditorBrowsableState.Advanced)]
6260 protected virtual void OnTextChanged(EventArgs e) {
6261 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
6266 [EditorBrowsable(EditorBrowsableState.Advanced)]
6267 protected virtual void OnValidated(EventArgs e) {
6268 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
6273 [EditorBrowsable(EditorBrowsableState.Advanced)]
6274 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
6275 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
6280 [EditorBrowsable(EditorBrowsableState.Advanced)]
6281 protected virtual void OnVisibleChanged(EventArgs e) {
6285 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
6289 // We need to tell our kids (including implicit ones)
6290 foreach (Control c in Controls.GetAllControls ())
6292 c.OnParentVisibleChanged (e);
6294 #endregion // OnXXX methods
6297 static object AutoSizeChangedEvent = new object ();
6298 static object BackColorChangedEvent = new object ();
6299 static object BackgroundImageChangedEvent = new object ();
6300 static object BackgroundImageLayoutChangedEvent = new object ();
6301 static object BindingContextChangedEvent = new object ();
6302 static object CausesValidationChangedEvent = new object ();
6303 static object ChangeUICuesEvent = new object ();
6304 static object ClickEvent = new object ();
6305 static object ClientSizeChangedEvent = new object ();
6306 static object ContextMenuChangedEvent = new object ();
6307 static object ContextMenuStripChangedEvent = new object ();
6308 static object ControlAddedEvent = new object ();
6309 static object ControlRemovedEvent = new object ();
6310 static object CursorChangedEvent = new object ();
6311 static object DockChangedEvent = new object ();
6312 static object DoubleClickEvent = new object ();
6313 static object DragDropEvent = new object ();
6314 static object DragEnterEvent = new object ();
6315 static object DragLeaveEvent = new object ();
6316 static object DragOverEvent = new object ();
6317 static object EnabledChangedEvent = new object ();
6318 static object EnterEvent = new object ();
6319 static object FontChangedEvent = new object ();
6320 static object ForeColorChangedEvent = new object ();
6321 static object GiveFeedbackEvent = new object ();
6322 static object GotFocusEvent = new object ();
6323 static object HandleCreatedEvent = new object ();
6324 static object HandleDestroyedEvent = new object ();
6325 static object HelpRequestedEvent = new object ();
6326 static object ImeModeChangedEvent = new object ();
6327 static object InvalidatedEvent = new object ();
6328 static object KeyDownEvent = new object ();
6329 static object KeyPressEvent = new object ();
6330 static object KeyUpEvent = new object ();
6331 static object LayoutEvent = new object ();
6332 static object LeaveEvent = new object ();
6333 static object LocationChangedEvent = new object ();
6334 static object LostFocusEvent = new object ();
6335 static object MarginChangedEvent = new object ();
6336 static object MouseCaptureChangedEvent = new object ();
6337 static object MouseClickEvent = new object ();
6338 static object MouseDoubleClickEvent = new object ();
6339 static object MouseDownEvent = new object ();
6340 static object MouseEnterEvent = new object ();
6341 static object MouseHoverEvent = new object ();
6342 static object MouseLeaveEvent = new object ();
6343 static object MouseMoveEvent = new object ();
6344 static object MouseUpEvent = new object ();
6345 static object MouseWheelEvent = new object ();
6346 static object MoveEvent = new object ();
6347 static object PaddingChangedEvent = new object ();
6348 static object PaintEvent = new object ();
6349 static object ParentChangedEvent = new object ();
6350 static object PreviewKeyDownEvent = new object ();
6351 static object QueryAccessibilityHelpEvent = new object ();
6352 static object QueryContinueDragEvent = new object ();
6353 static object RegionChangedEvent = new object ();
6354 static object ResizeEvent = new object ();
6355 static object RightToLeftChangedEvent = new object ();
6356 static object SizeChangedEvent = new object ();
6357 static object StyleChangedEvent = new object ();
6358 static object SystemColorsChangedEvent = new object ();
6359 static object TabIndexChangedEvent = new object ();
6360 static object TabStopChangedEvent = new object ();
6361 static object TextChangedEvent = new object ();
6362 static object ValidatedEvent = new object ();
6363 static object ValidatingEvent = new object ();
6364 static object VisibleChangedEvent = new object ();
6367 [EditorBrowsable (EditorBrowsableState.Never)]
6368 public event EventHandler AutoSizeChanged {
6369 add { Events.AddHandler (AutoSizeChangedEvent, value);}
6370 remove {Events.RemoveHandler (AutoSizeChangedEvent, value);}
6372 public event EventHandler BackColorChanged {
6373 add { Events.AddHandler (BackColorChangedEvent, value); }
6374 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
6377 public event EventHandler BackgroundImageChanged {
6378 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
6379 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
6382 public event EventHandler BackgroundImageLayoutChanged {
6383 add {Events.AddHandler (BackgroundImageLayoutChangedEvent, value);}
6384 remove {Events.RemoveHandler (BackgroundImageLayoutChangedEvent, value);}
6387 public event EventHandler BindingContextChanged {
6388 add { Events.AddHandler (BindingContextChangedEvent, value); }
6389 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
6392 public event EventHandler CausesValidationChanged {
6393 add { Events.AddHandler (CausesValidationChangedEvent, value); }
6394 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
6397 public event UICuesEventHandler ChangeUICues {
6398 add { Events.AddHandler (ChangeUICuesEvent, value); }
6399 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
6402 public event EventHandler Click {
6403 add { Events.AddHandler (ClickEvent, value); }
6404 remove { Events.RemoveHandler (ClickEvent, value); }
6407 public event EventHandler ClientSizeChanged {
6408 add {Events.AddHandler (ClientSizeChangedEvent, value);}
6409 remove {Events.RemoveHandler (ClientSizeChangedEvent, value);}
6413 public event EventHandler ContextMenuChanged {
6414 add { Events.AddHandler (ContextMenuChangedEvent, value); }
6415 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
6418 public event EventHandler ContextMenuStripChanged {
6419 add { Events.AddHandler (ContextMenuStripChangedEvent, value); }
6420 remove { Events.RemoveHandler (ContextMenuStripChangedEvent, value);}
6424 [EditorBrowsable(EditorBrowsableState.Advanced)]
6426 public event ControlEventHandler ControlAdded {
6427 add { Events.AddHandler (ControlAddedEvent, value); }
6428 remove { Events.RemoveHandler (ControlAddedEvent, value); }
6431 [EditorBrowsable(EditorBrowsableState.Advanced)]
6433 public event ControlEventHandler ControlRemoved {
6434 add { Events.AddHandler (ControlRemovedEvent, value); }
6435 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
6438 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
6439 public event EventHandler CursorChanged {
6440 add { Events.AddHandler (CursorChangedEvent, value); }
6441 remove { Events.RemoveHandler (CursorChangedEvent, value); }
6443 public event EventHandler DockChanged {
6444 add { Events.AddHandler (DockChangedEvent, value); }
6445 remove { Events.RemoveHandler (DockChangedEvent, value); }
6448 public event EventHandler DoubleClick {
6449 add { Events.AddHandler (DoubleClickEvent, value); }
6450 remove { Events.RemoveHandler (DoubleClickEvent, value); }
6453 public event DragEventHandler DragDrop {
6454 add { Events.AddHandler (DragDropEvent, value); }
6455 remove { Events.RemoveHandler (DragDropEvent, value); }
6458 public event DragEventHandler DragEnter {
6459 add { Events.AddHandler (DragEnterEvent, value); }
6460 remove { Events.RemoveHandler (DragEnterEvent, value); }
6463 public event EventHandler DragLeave {
6464 add { Events.AddHandler (DragLeaveEvent, value); }
6465 remove { Events.RemoveHandler (DragLeaveEvent, value); }
6468 public event DragEventHandler DragOver {
6469 add { Events.AddHandler (DragOverEvent, value); }
6470 remove { Events.RemoveHandler (DragOverEvent, value); }
6473 public event EventHandler EnabledChanged {
6474 add { Events.AddHandler (EnabledChangedEvent, value); }
6475 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
6478 public event EventHandler Enter {
6479 add { Events.AddHandler (EnterEvent, value); }
6480 remove { Events.RemoveHandler (EnterEvent, value); }
6483 public event EventHandler FontChanged {
6484 add { Events.AddHandler (FontChangedEvent, value); }
6485 remove { Events.RemoveHandler (FontChangedEvent, value); }
6488 public event EventHandler ForeColorChanged {
6489 add { Events.AddHandler (ForeColorChangedEvent, value); }
6490 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
6493 public event GiveFeedbackEventHandler GiveFeedback {
6494 add { Events.AddHandler (GiveFeedbackEvent, value); }
6495 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
6498 [EditorBrowsable(EditorBrowsableState.Advanced)]
6500 public event EventHandler GotFocus {
6501 add { Events.AddHandler (GotFocusEvent, value); }
6502 remove { Events.RemoveHandler (GotFocusEvent, value); }
6506 [EditorBrowsable(EditorBrowsableState.Advanced)]
6508 public event EventHandler HandleCreated {
6509 add { Events.AddHandler (HandleCreatedEvent, value); }
6510 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
6513 [EditorBrowsable(EditorBrowsableState.Advanced)]
6515 public event EventHandler HandleDestroyed {
6516 add { Events.AddHandler (HandleDestroyedEvent, value); }
6517 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
6520 public event HelpEventHandler HelpRequested {
6521 add { Events.AddHandler (HelpRequestedEvent, value); }
6522 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
6525 public event EventHandler ImeModeChanged {
6526 add { Events.AddHandler (ImeModeChangedEvent, value); }
6527 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
6530 [EditorBrowsable(EditorBrowsableState.Advanced)]
6532 public event InvalidateEventHandler Invalidated {
6533 add { Events.AddHandler (InvalidatedEvent, value); }
6534 remove { Events.RemoveHandler (InvalidatedEvent, value); }
6537 public event KeyEventHandler KeyDown {
6538 add { Events.AddHandler (KeyDownEvent, value); }
6539 remove { Events.RemoveHandler (KeyDownEvent, value); }
6542 public event KeyPressEventHandler KeyPress {
6543 add { Events.AddHandler (KeyPressEvent, value); }
6544 remove { Events.RemoveHandler (KeyPressEvent, value); }
6547 public event KeyEventHandler KeyUp {
6548 add { Events.AddHandler (KeyUpEvent, value); }
6549 remove { Events.RemoveHandler (KeyUpEvent, value); }
6552 public event LayoutEventHandler Layout {
6553 add { Events.AddHandler (LayoutEvent, value); }
6554 remove { Events.RemoveHandler (LayoutEvent, value); }
6557 public event EventHandler Leave {
6558 add { Events.AddHandler (LeaveEvent, value); }
6559 remove { Events.RemoveHandler (LeaveEvent, value); }
6562 public event EventHandler LocationChanged {
6563 add { Events.AddHandler (LocationChangedEvent, value); }
6564 remove { Events.RemoveHandler (LocationChangedEvent, value); }
6567 [EditorBrowsable(EditorBrowsableState.Advanced)]
6569 public event EventHandler LostFocus {
6570 add { Events.AddHandler (LostFocusEvent, value); }
6571 remove { Events.RemoveHandler (LostFocusEvent, value); }
6574 public event EventHandler MarginChanged {
6575 add { Events.AddHandler (MarginChangedEvent, value); }
6576 remove {Events.RemoveHandler (MarginChangedEvent, value); }
6579 public event EventHandler MouseCaptureChanged {
6580 add { Events.AddHandler (MouseCaptureChangedEvent, value); }
6581 remove { Events.RemoveHandler (MouseCaptureChangedEvent, value); }
6583 public event MouseEventHandler MouseClick
6585 add { Events.AddHandler (MouseClickEvent, value); }
6586 remove { Events.RemoveHandler (MouseClickEvent, value); }
6588 public event MouseEventHandler MouseDoubleClick
6590 add { Events.AddHandler (MouseDoubleClickEvent, value); }
6591 remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
6593 public event MouseEventHandler MouseDown {
6594 add { Events.AddHandler (MouseDownEvent, value); }
6595 remove { Events.RemoveHandler (MouseDownEvent, value); }
6598 public event EventHandler MouseEnter {
6599 add { Events.AddHandler (MouseEnterEvent, value); }
6600 remove { Events.RemoveHandler (MouseEnterEvent, value); }
6603 public event EventHandler MouseHover {
6604 add { Events.AddHandler (MouseHoverEvent, value); }
6605 remove { Events.RemoveHandler (MouseHoverEvent, value); }
6608 public event EventHandler MouseLeave {
6609 add { Events.AddHandler (MouseLeaveEvent, value); }
6610 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
6613 public event MouseEventHandler MouseMove {
6614 add { Events.AddHandler (MouseMoveEvent, value); }
6615 remove { Events.RemoveHandler (MouseMoveEvent, value); }
6618 public event MouseEventHandler MouseUp {
6619 add { Events.AddHandler (MouseUpEvent, value); }
6620 remove { Events.RemoveHandler (MouseUpEvent, value); }
6623 [EditorBrowsable(EditorBrowsableState.Advanced)]
6625 public event MouseEventHandler MouseWheel {
6626 add { Events.AddHandler (MouseWheelEvent, value); }
6627 remove { Events.RemoveHandler (MouseWheelEvent, value); }
6630 public event EventHandler Move {
6631 add { Events.AddHandler (MoveEvent, value); }
6632 remove { Events.RemoveHandler (MoveEvent, value); }
6634 public event EventHandler PaddingChanged
6636 add { Events.AddHandler (PaddingChangedEvent, value); }
6637 remove { Events.RemoveHandler (PaddingChangedEvent, value); }
6639 public event PaintEventHandler Paint {
6640 add { Events.AddHandler (PaintEvent, value); }
6641 remove { Events.RemoveHandler (PaintEvent, value); }
6644 public event EventHandler ParentChanged {
6645 add { Events.AddHandler (ParentChangedEvent, value); }
6646 remove { Events.RemoveHandler (ParentChangedEvent, value); }
6649 public event PreviewKeyDownEventHandler PreviewKeyDown {
6650 add { Events.AddHandler (PreviewKeyDownEvent, value); }
6651 remove { Events.RemoveHandler (PreviewKeyDownEvent, value); }
6654 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
6655 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
6656 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
6659 public event QueryContinueDragEventHandler QueryContinueDrag {
6660 add { Events.AddHandler (QueryContinueDragEvent, value); }
6661 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
6664 public event EventHandler RegionChanged {
6665 add { Events.AddHandler (RegionChangedEvent, value); }
6666 remove { Events.RemoveHandler (RegionChangedEvent, value); }
6669 [EditorBrowsable (EditorBrowsableState.Advanced)]
6670 public event EventHandler Resize {
6671 add { Events.AddHandler (ResizeEvent, value); }
6672 remove { Events.RemoveHandler (ResizeEvent, value); }
6675 public event EventHandler RightToLeftChanged {
6676 add { Events.AddHandler (RightToLeftChangedEvent, value); }
6677 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
6680 public event EventHandler SizeChanged {
6681 add { Events.AddHandler (SizeChangedEvent, value); }
6682 remove { Events.RemoveHandler (SizeChangedEvent, value); }
6685 public event EventHandler StyleChanged {
6686 add { Events.AddHandler (StyleChangedEvent, value); }
6687 remove { Events.RemoveHandler (StyleChangedEvent, value); }
6690 public event EventHandler SystemColorsChanged {
6691 add { Events.AddHandler (SystemColorsChangedEvent, value); }
6692 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
6695 public event EventHandler TabIndexChanged {
6696 add { Events.AddHandler (TabIndexChangedEvent, value); }
6697 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
6700 public event EventHandler TabStopChanged {
6701 add { Events.AddHandler (TabStopChangedEvent, value); }
6702 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
6705 public event EventHandler TextChanged {
6706 add { Events.AddHandler (TextChangedEvent, value); }
6707 remove { Events.RemoveHandler (TextChangedEvent, value); }
6710 public event EventHandler Validated {
6711 add { Events.AddHandler (ValidatedEvent, value); }
6712 remove { Events.RemoveHandler (ValidatedEvent, value); }
6715 public event CancelEventHandler Validating {
6716 add { Events.AddHandler (ValidatingEvent, value); }
6717 remove { Events.RemoveHandler (ValidatingEvent, value); }
6720 public event EventHandler VisibleChanged {
6721 add { Events.AddHandler (VisibleChangedEvent, value); }
6722 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
6725 #endregion // Events