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)
717 if (value == null || !list.Contains(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 // for the control class the DisplayRectangle == ClientRectangle
2459 return ClientRectangle;
2463 [EditorBrowsable(EditorBrowsableState.Advanced)]
2465 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2466 public bool Disposing {
2473 [RefreshProperties(RefreshProperties.Repaint)]
2474 [DefaultValue(DockStyle.None)]
2475 [MWFCategory("Layout")]
2476 public virtual DockStyle Dock {
2482 // If the user sets this to None, we need to still use Anchor layout
2483 if (value != DockStyle.None)
2484 layout_type = LayoutType.Dock;
2486 if (dock_style == value) {
2490 if (!Enum.IsDefined (typeof (DockStyle), value)) {
2491 throw new InvalidEnumArgumentException ("value", (int) value,
2492 typeof (DockStyle));
2496 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
2498 if (dock_style == DockStyle.None) {
2499 bounds = explicit_bounds;
2500 layout_type = LayoutType.Anchor;
2504 parent.PerformLayout(this, "Dock");
2505 else if (Controls.Count > 0)
2508 OnDockChanged(EventArgs.Empty);
2512 protected virtual bool DoubleBuffered {
2514 return (control_style & ControlStyles.OptimizedDoubleBuffer) != 0;
2518 if (value == DoubleBuffered)
2521 SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
2523 SetStyle (ControlStyles.OptimizedDoubleBuffer, false);
2529 public void DrawToBitmap (Bitmap bitmap, Rectangle targetBounds)
2531 Graphics g = Graphics.FromImage (bitmap);
2533 // Only draw within the target bouds, and up to the size of the control
2534 g.IntersectClip (targetBounds);
2535 g.IntersectClip (Bounds);
2537 // Logic copied from WmPaint
2538 PaintEventArgs pea = new PaintEventArgs (g, targetBounds);
2540 if (!GetStyle (ControlStyles.Opaque))
2541 OnPaintBackground (pea);
2543 OnPaintBackgroundInternal (pea);
2545 OnPaintInternal (pea);
2555 [MWFCategory("Behavior")]
2556 public bool Enabled {
2562 if (parent != null) {
2563 return parent.Enabled;
2570 if (this.is_enabled == value)
2573 bool old_value = is_enabled;
2580 if (old_value != value && !value && this.has_focus)
2581 SelectNextControl(this, true, true, true, true);
2583 OnEnabledChanged (EventArgs.Empty);
2587 internal bool ShouldSerializeEnabled ()
2589 return this.Enabled != true;
2592 [EditorBrowsable(EditorBrowsableState.Advanced)]
2594 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2595 public virtual bool Focused {
2597 return this.has_focus;
2602 [AmbientValue(null)]
2604 [MWFCategory("Appearance")]
2605 public virtual Font Font {
2606 [return: MarshalAs (UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof (Font))]
2611 if (parent != null) {
2612 Font f = parent.Font;
2621 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2623 if (font != null && font == value) {
2629 OnFontChanged (EventArgs.Empty);
2634 internal bool ShouldSerializeFont ()
2636 return !this.Font.Equals (DefaultFont);
2640 [MWFCategory("Appearance")]
2641 public virtual Color ForeColor {
2643 if (foreground_color.IsEmpty) {
2645 return parent.ForeColor;
2647 return DefaultForeColor;
2649 return foreground_color;
2653 if (foreground_color != value) {
2654 foreground_color=value;
2656 OnForeColorChanged(EventArgs.Empty);
2661 internal bool ShouldSerializeForeColor ()
2663 return this.ForeColor != DefaultForeColor;
2668 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2669 public IntPtr Handle { // IWin32Window
2671 if (verify_thread_handle) {
2672 if (this.InvokeRequired) {
2673 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2676 if (!IsHandleCreated) {
2679 return window.Handle;
2683 [EditorBrowsable(EditorBrowsableState.Advanced)]
2685 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2686 public bool HasChildren {
2688 if (this.child_controls.Count>0) {
2695 [EditorBrowsable(EditorBrowsableState.Always)]
2697 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2699 get { return this.bounds.Height; }
2700 set { SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height); }
2703 [AmbientValue(ImeMode.Inherit)]
2705 [MWFCategory("Behavior")]
2706 public ImeMode ImeMode {
2708 if (ime_mode == ImeMode.Inherit) {
2710 return parent.ImeMode;
2712 return ImeMode.NoControl; // default value
2718 if (ime_mode != value) {
2721 OnImeModeChanged(EventArgs.Empty);
2726 internal bool ShouldSerializeImeMode ()
2728 return this.ImeMode != ImeMode.NoControl;
2731 [EditorBrowsable(EditorBrowsableState.Advanced)]
2733 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2734 public bool InvokeRequired { // ISynchronizeInvoke
2736 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2743 [EditorBrowsable(EditorBrowsableState.Advanced)]
2745 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2746 public bool IsAccessible {
2748 return is_accessible;
2752 is_accessible = value;
2756 [EditorBrowsable(EditorBrowsableState.Advanced)]
2758 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2759 public bool IsDisposed {
2761 return this.is_disposed;
2765 [EditorBrowsable(EditorBrowsableState.Advanced)]
2767 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2768 public bool IsHandleCreated {
2770 if (window == null || window.Handle == IntPtr.Zero)
2773 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2774 if (hwnd != null && hwnd.zombie)
2781 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2782 [EditorBrowsable(EditorBrowsableState.Advanced)]
2784 [MonoNotSupported ("RTL is not supported")]
2785 public bool IsMirrored {
2786 get { return false; }
2790 [EditorBrowsable (EditorBrowsableState.Advanced)]
2791 public virtual Layout.LayoutEngine LayoutEngine {
2793 if (layout_engine == null)
2794 layout_engine = new Layout.DefaultLayout ();
2795 return layout_engine;
2799 [EditorBrowsable(EditorBrowsableState.Always)]
2801 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2804 return this.bounds.Left;
2808 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2813 [MWFCategory("Layout")]
2814 public Point Location {
2816 return this.bounds.Location;
2820 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2824 internal bool ShouldSerializeLocation ()
2826 return this.Location != new Point (0, 0);
2829 [Localizable (true)]
2830 [MWFCategory("Layout")]
2831 public Padding Margin {
2832 get { return this.margin; }
2834 if (this.margin != value) {
2835 this.margin = value;
2837 Parent.PerformLayout (this, "Margin");
2838 OnMarginChanged (EventArgs.Empty);
2843 internal bool ShouldSerializeMargin ()
2845 return this.Margin != DefaultMargin;
2849 public string Name {
2860 [MWFCategory("Layout")]
2861 public Padding Padding {
2867 if (padding != value) {
2869 OnPaddingChanged (EventArgs.Empty);
2871 // Changing padding generally requires a new size
2872 if (this.AutoSize && this.Parent != null)
2873 parent.PerformLayout (this, "Padding");
2875 PerformLayout (this, "Padding");
2880 internal bool ShouldSerializePadding ()
2882 return this.Padding != DefaultPadding;
2886 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2887 public Control Parent {
2893 if (value == this) {
2894 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2897 if (parent!=value) {
2899 parent.Controls.Remove(this);
2904 value.Controls.Add(this);
2910 public Size PreferredSize {
2911 get { return this.GetPreferredSize (Size.Empty); }
2914 [EditorBrowsable(EditorBrowsableState.Advanced)]
2916 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2917 public string ProductName {
2919 Type t = typeof (AssemblyProductAttribute);
2920 Assembly assembly = GetType().Module.Assembly;
2921 object [] attrs = assembly.GetCustomAttributes (t, false);
2922 AssemblyProductAttribute a = null;
2923 // On MS we get a NullRefException if product attribute is not
2925 if (attrs != null && attrs.Length > 0)
2926 a = (AssemblyProductAttribute) attrs [0];
2928 return GetType ().Namespace;
2934 [EditorBrowsable(EditorBrowsableState.Advanced)]
2936 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2937 public string ProductVersion {
2939 Type t = typeof (AssemblyVersionAttribute);
2940 Assembly assembly = GetType().Module.Assembly;
2941 object [] attrs = assembly.GetCustomAttributes (t, false);
2942 if (attrs == null || attrs.Length < 1)
2944 return ((AssemblyVersionAttribute)attrs [0]).Version;
2948 [EditorBrowsable(EditorBrowsableState.Advanced)]
2950 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2951 public bool RecreatingHandle {
2953 return is_recreating;
2957 [EditorBrowsable(EditorBrowsableState.Advanced)]
2959 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2960 public Region Region {
2966 if (clip_region != value) {
2967 if (IsHandleCreated)
2968 XplatUI.SetClipRegion(Handle, value);
2970 clip_region = value;
2972 OnRegionChanged (EventArgs.Empty);
2977 [EditorBrowsable(EditorBrowsableState.Advanced)]
2979 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2982 return this.bounds.Right;
2986 [AmbientValue(RightToLeft.Inherit)]
2988 [MWFCategory("Appearance")]
2989 public virtual RightToLeft RightToLeft {
2991 if (right_to_left == RightToLeft.Inherit) {
2993 return parent.RightToLeft;
2995 return RightToLeft.No; // default value
2997 return right_to_left;
3001 if (value != right_to_left) {
3002 right_to_left = value;
3003 OnRightToLeftChanged(EventArgs.Empty);
3009 internal bool ShouldSerializeRightToLeft ()
3011 return this.RightToLeft != RightToLeft.No;
3014 [EditorBrowsable(EditorBrowsableState.Advanced)]
3015 public override ISite Site {
3023 if (value != null) {
3024 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
3026 BackColor = ap.BackColor;
3027 ForeColor = ap.ForeColor;
3035 internal bool ShouldSerializeSite ()
3041 [MWFCategory("Layout")]
3044 return new Size(Width, Height);
3048 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
3052 internal virtual bool ShouldSerializeSize ()
3054 return this.Size != DefaultSize;
3058 [MergableProperty(false)]
3059 [MWFCategory("Behavior")]
3060 public int TabIndex {
3062 if (tab_index != -1) {
3069 if (tab_index != value) {
3071 OnTabIndexChanged(EventArgs.Empty);
3077 [DefaultValue(true)]
3078 [MWFCategory("Behavior")]
3079 public bool TabStop {
3085 if (tab_stop != value) {
3087 OnTabStopChanged(EventArgs.Empty);
3092 [Localizable(false)]
3094 [TypeConverter(typeof(StringConverter))]
3095 [DefaultValue(null)]
3096 [MWFCategory("Data")]
3103 control_tag = value;
3109 [BindableAttribute(true)]
3110 [MWFCategory("Appearance")]
3111 public virtual string Text {
3113 // Our implementation ignores ControlStyles.CacheText - we always cache
3118 if (value == null) {
3119 value = String.Empty;
3124 UpdateWindowText ();
3125 OnTextChanged (EventArgs.Empty);
3127 // Label has its own AutoSize implementation
3128 if (AutoSize && Parent != null && (!(this is Label)))
3129 Parent.PerformLayout (this, "Text");
3134 internal virtual void UpdateWindowText ()
3136 if (!IsHandleCreated) {
3139 XplatUI.Text (Handle, text);
3142 [EditorBrowsable(EditorBrowsableState.Always)]
3144 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3147 return this.bounds.Top;
3151 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
3155 [EditorBrowsable(EditorBrowsableState.Advanced)]
3157 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3158 public Control TopLevelControl {
3162 while (p.parent != null) {
3166 return p is Form ? p : null;
3170 [EditorBrowsable(EditorBrowsableState.Always)]
3172 [DefaultValue (false)]
3173 [MWFCategory("Appearance")]
3174 public bool UseWaitCursor {
3175 get { return use_wait_cursor; }
3177 if (use_wait_cursor != value) {
3178 use_wait_cursor = value;
3180 OnCursorChanged (EventArgs.Empty);
3186 [MWFCategory("Behavior")]
3187 public bool Visible {
3191 } else if (parent != null) {
3192 return parent.Visible;
3199 if (this.is_visible != value) {
3200 SetVisibleCore(value);
3203 parent.PerformLayout (this, "Visible");
3208 internal bool ShouldSerializeVisible ()
3210 return this.Visible != true;
3213 [EditorBrowsable(EditorBrowsableState.Always)]
3215 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3218 return this.bounds.Width;
3222 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
3226 [EditorBrowsable(EditorBrowsableState.Never)]
3228 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3229 public IWindowTarget WindowTarget {
3230 get { return window_target; }
3231 set { window_target = value; }
3233 #endregion // Public Instance Properties
3235 #region Protected Instance Properties
3236 protected virtual bool CanEnableIme {
3237 get { return false; }
3240 // Is only false in some ActiveX contexts
3241 protected override bool CanRaiseEvents {
3242 get { return true; }
3245 protected virtual CreateParams CreateParams {
3247 CreateParams create_params = new CreateParams();
3250 create_params.Caption = Text;
3253 create_params.Caption = text;
3257 create_params.X = Left;
3260 create_params.X = this.bounds.X;
3264 create_params.Y = Top;
3267 create_params.Y = this.bounds.Y;
3271 create_params.Width = Width;
3274 create_params.Width = this.bounds.Width;
3278 create_params.Height = Height;
3281 create_params.Height = this.bounds.Height;
3285 create_params.ClassName = XplatUI.GetDefaultClassName (GetType ());
3286 create_params.ClassStyle = (int)(XplatUIWin32.ClassStyle.CS_OWNDC | XplatUIWin32.ClassStyle.CS_DBLCLKS);
3287 create_params.ExStyle = 0;
3288 create_params.Param = 0;
3291 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
3294 if ((parent!=null) && (parent.IsHandleCreated)) {
3295 create_params.Parent = parent.Handle;
3298 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
3301 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
3305 create_params.Style |= (int)WindowStyles.WS_DISABLED;
3308 switch (border_style) {
3309 case BorderStyle.FixedSingle:
3310 create_params.Style |= (int) WindowStyles.WS_BORDER;
3312 case BorderStyle.Fixed3D:
3313 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
3317 create_params.control = this;
3319 return create_params;
3323 protected virtual Cursor DefaultCursor { get { return Cursors.Default; } }
3325 protected virtual ImeMode DefaultImeMode {
3327 return ImeMode.Inherit;
3331 protected virtual Padding DefaultMargin {
3332 get { return new Padding (3); }
3335 protected virtual Size DefaultMaximumSize { get { return new Size (); } }
3336 protected virtual Size DefaultMinimumSize { get { return new Size (); } }
3337 protected virtual Padding DefaultPadding { get { return new Padding (); } }
3339 protected virtual Size DefaultSize {
3341 return new Size(0, 0);
3345 protected int FontHeight {
3355 protected bool RenderRightToLeft {
3357 return (this.right_to_left == RightToLeft.Yes);
3361 protected bool ResizeRedraw {
3363 return GetStyle(ControlStyles.ResizeRedraw);
3367 SetStyle(ControlStyles.ResizeRedraw, value);
3371 [EditorBrowsable (EditorBrowsableState.Advanced)]
3372 protected virtual bool ScaleChildren {
3373 get { return ScaleChildrenInternal; }
3376 internal virtual bool ScaleChildrenInternal {
3377 get { return true; }
3380 [EditorBrowsable(EditorBrowsableState.Advanced)]
3382 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3383 protected internal virtual bool ShowFocusCues {
3386 return show_focus_cues;
3388 if (this.parent == null)
3391 Form f = this.FindForm ();
3394 return f.show_focus_cues;
3400 [EditorBrowsable(EditorBrowsableState.Advanced)]
3402 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3403 internal virtual protected bool ShowKeyboardCues {
3405 return ShowKeyboardCuesInternal;
3409 internal bool ShowKeyboardCuesInternal {
3411 if (SystemInformation.MenuAccessKeysUnderlined || DesignMode)
3414 return show_keyboard_cues;
3418 #endregion // Protected Instance Properties
3420 #region Public Static Methods
3421 [EditorBrowsable(EditorBrowsableState.Advanced)]
3422 public static Control FromChildHandle(IntPtr handle) {
3423 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
3426 [EditorBrowsable(EditorBrowsableState.Advanced)]
3427 public static Control FromHandle(IntPtr handle) {
3428 return Control.ControlNativeWindow.ControlFromHandle(handle);
3431 [MonoTODO ("Only implemented for Win32, others always return false")]
3432 public static bool IsKeyLocked (Keys keyVal)
3438 return XplatUI.IsKeyLocked ((VirtualKeys)keyVal);
3440 throw new NotSupportedException ("keyVal must be CapsLock, NumLock, or ScrollLock");
3444 public static bool IsMnemonic(char charCode, string text) {
3447 amp = text.IndexOf('&');
3450 if (amp + 1 < text.Length) {
3451 if (text[amp + 1] != '&') {
3452 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
3462 #region Protected Static Methods
3463 [EditorBrowsable(EditorBrowsableState.Advanced)]
3464 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
3467 c = Control.FromHandle(hWnd);
3477 #region Public Instance Methods
3478 [EditorBrowsable(EditorBrowsableState.Advanced)]
3479 public IAsyncResult BeginInvoke(Delegate method) {
3480 object [] prms = null;
3481 if (method is EventHandler)
3482 prms = new object [] { this, EventArgs.Empty };
3483 return BeginInvokeInternal(method, prms);
3486 [EditorBrowsable(EditorBrowsableState.Advanced)]
3487 public IAsyncResult BeginInvoke (Delegate method, params object[] args)
3489 return BeginInvokeInternal (method, args);
3492 public void BringToFront() {
3493 if (parent != null) {
3494 parent.child_controls.SetChildIndex(this, 0);
3496 else if (IsHandleCreated) {
3497 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
3501 public bool Contains(Control ctl) {
3502 while (ctl != null) {
3511 public void CreateControl () {
3524 if (parent != null && !parent.Created) {
3528 if (!IsHandleCreated) {
3535 // Create all of our children (implicit ones as well) when we are created.
3536 // The child should fire it's OnLoad before the parents, however
3537 // if the child checks Parent.Created in it's OnCreateControl, the
3538 // parent is already created.
3539 foreach (Control c in Controls.GetAllControls ())
3540 if (!c.Created && !c.IsDisposed)
3547 public Graphics CreateGraphics() {
3548 if (!IsHandleCreated) {
3549 this.CreateHandle();
3551 return Graphics.FromHwnd(this.window.Handle);
3554 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
3555 DragDropEffects result = DragDropEffects.None;
3556 if (IsHandleCreated)
3557 result = XplatUI.StartDrag(Handle, data, allowedEffects);
3558 OnDragDropEnd (result);
3562 internal virtual void OnDragDropEnd (DragDropEffects effects)
3566 [EditorBrowsable(EditorBrowsableState.Advanced)]
3567 public object EndInvoke (IAsyncResult asyncResult) {
3568 AsyncMethodResult result = (AsyncMethodResult) asyncResult;
3569 return result.EndInvoke ();
3572 internal Control FindRootParent ()
3576 while (c.Parent != null)
3582 public Form FindForm() {
3594 [EditorBrowsable (EditorBrowsableState.Advanced)]
3595 public bool Focus() {
3596 return FocusInternal (false);
3599 internal virtual bool FocusInternal (bool skip_check) {
3600 if (skip_check || (CanFocus && IsHandleCreated && !has_focus && !is_focusing)) {
3603 is_focusing = false;
3608 internal Control GetRealChildAtPoint (Point pt) {
3609 if (!IsHandleCreated)
3612 foreach (Control control in child_controls.GetAllControls ()) {
3613 if (control.Bounds.Contains (PointToClient (pt))) {
3614 Control child = control.GetRealChildAtPoint (pt);
3625 public Control GetChildAtPoint(Point pt)
3627 return GetChildAtPoint (pt, GetChildAtPointSkip.None);
3630 public Control GetChildAtPoint (Point pt, GetChildAtPointSkip skipValue)
3632 // MS's version causes the handle to be created. The stack trace shows that get_Handle is called here, but
3633 // we'll just call CreateHandle instead.
3634 if (!IsHandleCreated)
3637 // Microsoft's version of this function doesn't seem to work, so I can't check
3638 // if we only consider children or also grandchildren, etc.
3639 // I'm gonna say 'children only'
3640 foreach (Control child in Controls) {
3641 if ((skipValue & GetChildAtPointSkip.Disabled) == GetChildAtPointSkip.Disabled && !child.Enabled)
3643 else if ((skipValue & GetChildAtPointSkip.Invisible) == GetChildAtPointSkip.Invisible && !child.Visible)
3645 else if ((skipValue & GetChildAtPointSkip.Transparent) == GetChildAtPointSkip.Transparent && child.BackColor.A == 0x0)
3647 else if (child.Bounds.Contains (pt))
3654 public IContainerControl GetContainerControl() {
3655 Control current = this;
3657 while (current!=null) {
3658 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
3659 return (IContainerControl)current;
3661 current = current.parent;
3666 internal ContainerControl InternalGetContainerControl() {
3667 Control current = this;
3669 while (current!=null) {
3670 if ((current is ContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
3671 return current as ContainerControl;
3673 current = current.parent;
3678 public Control GetNextControl(Control ctl, bool forward) {
3680 if (!this.Contains(ctl)) {
3685 ctl = FindControlForward(this, ctl);
3688 ctl = FindControlBackward(this, ctl);
3697 [EditorBrowsable (EditorBrowsableState.Advanced)]
3698 public virtual Size GetPreferredSize (Size proposedSize) {
3699 Size retsize = GetPreferredSizeCore (proposedSize);
3701 // If we're bigger than the MaximumSize, fix that
3702 if (this.maximum_size.Width != 0 && retsize.Width > this.maximum_size.Width)
3703 retsize.Width = this.maximum_size.Width;
3704 if (this.maximum_size.Height != 0 && retsize.Height > this.maximum_size.Height)
3705 retsize.Height = this.maximum_size.Height;
3707 // If we're smaller than the MinimumSize, fix that
3708 if (this.minimum_size.Width != 0 && retsize.Width < this.minimum_size.Width)
3709 retsize.Width = this.minimum_size.Width;
3710 if (this.minimum_size.Height != 0 && retsize.Height < this.minimum_size.Height)
3711 retsize.Height = this.minimum_size.Height;
3716 public void Hide() {
3717 this.Visible = false;
3720 public void Invalidate ()
3722 Invalidate (ClientRectangle, false);
3725 public void Invalidate (bool invalidateChildren)
3727 Invalidate (ClientRectangle, invalidateChildren);
3730 public void Invalidate (Rectangle rc)
3732 Invalidate (rc, false);
3735 public void Invalidate (Rectangle rc, bool invalidateChildren)
3737 // Win32 invalidates control including when Width and Height is equal 0
3738 // or is not visible, only Paint event must be care about this.
3739 if (!IsHandleCreated)
3743 rc = ClientRectangle;
3745 if (rc.Width > 0 && rc.Height > 0) {
3747 NotifyInvalidate(rc);
3749 XplatUI.Invalidate(Handle, rc, false);
3751 if (invalidateChildren) {
3752 Control [] controls = child_controls.GetAllControls ();
3753 for (int i=0; i<controls.Length; i++)
3754 controls [i].Invalidate ();
3756 // If any of our children are transparent, we
3757 // have to invalidate them anyways
3758 foreach (Control c in Controls)
3759 if (c.BackColor.A != 255)
3763 OnInvalidated(new InvalidateEventArgs(rc));
3766 public void Invalidate (Region region)
3768 Invalidate (region, false);
3771 public void Invalidate (Region region, bool invalidateChildren)
3773 using (Graphics g = CreateGraphics ()){
3774 RectangleF bounds = region.GetBounds (g);
3775 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height), invalidateChildren);
3779 public object Invoke (Delegate method) {
3780 object [] prms = null;
3781 if (method is EventHandler)
3782 prms = new object [] { this, EventArgs.Empty };
3784 return Invoke(method, prms);
3786 public object Invoke (Delegate method, params object [] args) {
3787 Control control = FindControlToInvokeOn ();
3789 if (!this.InvokeRequired) {
3790 return method.DynamicInvoke(args);
3793 IAsyncResult result = BeginInvokeInternal (method, args, control);
3794 return EndInvoke(result);
3797 [EditorBrowsable(EditorBrowsableState.Advanced)]
3798 public void PerformLayout() {
3799 PerformLayout(null, null);
3802 [EditorBrowsable(EditorBrowsableState.Advanced)]
3803 public void PerformLayout(Control affectedControl, string affectedProperty) {
3804 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
3806 foreach (Control c in Controls.GetAllControls ())
3807 if (c.recalculate_distances)
3808 c.UpdateDistances ();
3810 if (layout_suspended > 0) {
3811 layout_pending = true;
3815 layout_pending = false;
3817 // Prevent us from getting messed up
3820 // Perform all Dock and Anchor calculations
3825 // Need to make sure we decremend layout_suspended
3831 public Point PointToClient (Point p) {
3835 XplatUI.ScreenToClient (Handle, ref x, ref y);
3837 return new Point (x, y);
3840 public Point PointToScreen(Point p) {
3844 XplatUI.ClientToScreen(Handle, ref x, ref y);
3846 return new Point(x, y);
3849 [EditorBrowsable(EditorBrowsableState.Advanced)]
3850 public PreProcessControlState PreProcessControlMessage (ref Message msg)
3852 return PreProcessControlMessageInternal (ref msg);
3855 internal PreProcessControlState PreProcessControlMessageInternal (ref Message msg)
3857 switch ((Msg)msg.Msg) {
3858 case Msg.WM_KEYDOWN:
3859 case Msg.WM_SYSKEYDOWN:
3860 PreviewKeyDownEventArgs e = new PreviewKeyDownEventArgs ((Keys)msg.WParam.ToInt32 () | XplatUI.State.ModifierKeys);
3861 OnPreviewKeyDown (e);
3864 return PreProcessControlState.MessageNeeded;
3866 if (PreProcessMessage (ref msg))
3867 return PreProcessControlState.MessageProcessed;
3869 if (IsInputKey ((Keys)msg.WParam.ToInt32 () | XplatUI.State.ModifierKeys))
3870 return PreProcessControlState.MessageNeeded;
3874 case Msg.WM_SYSCHAR:
3875 if (PreProcessMessage (ref msg))
3876 return PreProcessControlState.MessageProcessed;
3878 if (IsInputChar ((char)msg.WParam))
3879 return PreProcessControlState.MessageNeeded;
3886 return PreProcessControlState.MessageNotNeeded;
3889 public virtual bool PreProcessMessage (ref Message msg)
3891 return InternalPreProcessMessage (ref msg);
3894 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3897 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3898 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3900 if (!ProcessCmdKey(ref msg, key_data)) {
3901 if (IsInputKey(key_data)) {
3905 return ProcessDialogKey(key_data);
3909 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3910 if (IsInputChar((char)msg.WParam)) {
3913 return ProcessDialogChar((char)msg.WParam);
3914 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3915 if (ProcessDialogChar((char)msg.WParam))
3918 return ToolStripManager.ProcessMenuKey (ref msg);
3923 public Rectangle RectangleToClient(Rectangle r) {
3924 return new Rectangle(PointToClient(r.Location), r.Size);
3927 public Rectangle RectangleToScreen(Rectangle r) {
3928 return new Rectangle(PointToScreen(r.Location), r.Size);
3931 public virtual void Refresh() {
3932 if (IsHandleCreated && Visible) {
3938 [EditorBrowsable(EditorBrowsableState.Never)]
3939 public virtual void ResetBackColor() {
3940 BackColor = Color.Empty;
3943 [EditorBrowsable(EditorBrowsableState.Never)]
3944 public void ResetBindings() {
3945 if (data_bindings != null)
3946 data_bindings.Clear();
3949 [EditorBrowsable(EditorBrowsableState.Never)]
3950 public virtual void ResetCursor() {
3954 [EditorBrowsable(EditorBrowsableState.Never)]
3955 public virtual void ResetFont() {
3959 [EditorBrowsable(EditorBrowsableState.Never)]
3960 public virtual void ResetForeColor() {
3961 foreground_color = Color.Empty;
3964 [EditorBrowsable(EditorBrowsableState.Never)]
3965 public void ResetImeMode() {
3966 ime_mode = DefaultImeMode;
3969 [EditorBrowsable(EditorBrowsableState.Never)]
3970 public virtual void ResetRightToLeft() {
3971 right_to_left = RightToLeft.Inherit;
3974 public virtual void ResetText() {
3975 Text = String.Empty;
3978 public void ResumeLayout() {
3979 ResumeLayout (true);
3982 public void ResumeLayout(bool performLayout) {
3983 if (layout_suspended > 0) {
3987 if (layout_suspended == 0) {
3988 if (this is ContainerControl)
3989 (this as ContainerControl).PerformDelayedAutoScale();
3992 foreach (Control c in Controls.GetAllControls ())
3993 c.UpdateDistances ();
3995 if (performLayout && layout_pending) {
4000 [EditorBrowsable (EditorBrowsableState.Never)]
4002 public void Scale(float ratio) {
4003 ScaleCore(ratio, ratio);
4006 [EditorBrowsable (EditorBrowsableState.Never)]
4008 public void Scale(float dx, float dy) {
4012 [EditorBrowsable (EditorBrowsableState.Advanced)]
4013 public void Scale (SizeF factor)
4015 BoundsSpecified bounds_spec = BoundsSpecified.All;
4019 if (this is ContainerControl) {
4020 if ((this as ContainerControl).IsAutoScaling)
4021 bounds_spec = BoundsSpecified.Size;
4022 else if (IsContainerAutoScaling (this.Parent))
4023 bounds_spec = BoundsSpecified.Location;
4026 ScaleControl (factor, bounds_spec);
4029 if ((bounds_spec != BoundsSpecified.Location) && ScaleChildren) {
4030 foreach (Control c in Controls.GetAllControls ()) {
4032 if (c is ContainerControl) {
4033 ContainerControl cc = c as ContainerControl;
4034 if ((cc.AutoScaleMode == AutoScaleMode.Inherit) && IsContainerAutoScaling (this))
4035 cc.PerformAutoScale (true);
4043 internal ContainerControl FindContainer (Control c)
4045 while ((c != null) && !(c is ContainerControl))
4047 return c as ContainerControl;
4050 private bool IsContainerAutoScaling (Control c)
4052 ContainerControl cc = FindContainer (c);
4053 return (cc != null) && cc.IsAutoScaling;
4056 public void Select() {
4057 Select(false, false);
4061 private void printTree(Control c, string t) {
4062 foreach(Control i in c.child_controls) {
4063 Console.WriteLine ("{2}{0}.TabIndex={1}", i, i.tab_index, t);
4064 printTree (i, t+"\t");
4068 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
4072 Console.WriteLine("{0}", this.FindForm());
4073 printTree(this, "\t");
4076 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
4081 c = GetNextControl(c, forward);
4091 Console.WriteLine("{0} {1}", c, c.CanSelect);
4093 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
4094 c.Select (true, true);
4097 } while (c != ctl); // If we wrap back to ourselves we stop
4102 public void SendToBack() {
4103 if (parent != null) {
4104 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
4108 public void SetBounds(int x, int y, int width, int height) {
4109 SetBounds(x, y, width, height, BoundsSpecified.All);
4112 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
4113 // Fill in the values that were not specified
4114 if ((specified & BoundsSpecified.X) == 0)
4116 if ((specified & BoundsSpecified.Y) == 0)
4118 if ((specified & BoundsSpecified.Width) == 0)
4120 if ((specified & BoundsSpecified.Height) == 0)
4123 SetBoundsInternal (x, y, width, height, specified);
4126 internal void SetBoundsInternal (int x, int y, int width, int height, BoundsSpecified specified)
4128 // SetBoundsCore is really expensive to call, so we want to avoid it if we can.
4129 // We can avoid it if:
4130 // - The requested dimensions are the same as our current dimensions
4132 // - Any BoundsSpecified is the same as our current explicit_size
4133 if (bounds.X != x || (explicit_bounds.X != x && (specified & BoundsSpecified.X) == BoundsSpecified.X))
4134 SetBoundsCore (x, y, width, height, specified);
4135 else if (bounds.Y != y || (explicit_bounds.Y != y && (specified & BoundsSpecified.Y) == BoundsSpecified.Y))
4136 SetBoundsCore (x, y, width, height, specified);
4137 else if (bounds.Width != width || (explicit_bounds.Width != width && (specified & BoundsSpecified.Width) == BoundsSpecified.Width))
4138 SetBoundsCore (x, y, width, height, specified);
4139 else if (bounds.Height != height || (explicit_bounds.Height != height && (specified & BoundsSpecified.Height) == BoundsSpecified.Height))
4140 SetBoundsCore (x, y, width, height, specified);
4144 // If the user explicitly moved or resized us, recalculate our anchor distances
4145 if (specified != BoundsSpecified.None)
4149 parent.PerformLayout(this, "Bounds");
4152 public void Show () {
4153 this.Visible = true;
4156 public void SuspendLayout() {
4160 public void Update() {
4161 if (IsHandleCreated) {
4162 XplatUI.UpdateWindow(window.Handle);
4165 #endregion // Public Instance Methods
4167 #region Protected Instance Methods
4168 [EditorBrowsable(EditorBrowsableState.Advanced)]
4169 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
4170 // turns out this method causes handle
4171 // creation in 1.1. at first I thought this
4172 // would be accomplished just by using
4173 // get_AccessibilityObject, which would route
4174 // through CreateAccessibilityInstance, which
4175 // calls CreateControl. This isn't the case,
4176 // though (as overriding
4177 // CreateAccessibilityInstance and adding a
4178 // CWL shows nothing. So we fudge it and put
4179 // a CreateHandle here.
4182 if (accessibility_object != null && accessibility_object is ControlAccessibleObject)
4183 ((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, childID);
4186 [EditorBrowsable (EditorBrowsableState.Advanced)]
4187 protected void AccessibilityNotifyClients (AccessibleEvents accEvent, int objectID, int childID)
4189 if (accessibility_object != null && accessibility_object is ControlAccessibleObject)
4190 ((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, objectID, childID);
4193 [EditorBrowsable(EditorBrowsableState.Advanced)]
4194 protected virtual AccessibleObject CreateAccessibilityInstance() {
4196 return new Control.ControlAccessibleObject(this);
4199 [EditorBrowsable(EditorBrowsableState.Advanced)]
4200 protected virtual ControlCollection CreateControlsInstance() {
4201 return new ControlCollection(this);
4204 [EditorBrowsable(EditorBrowsableState.Advanced)]
4205 protected virtual void CreateHandle() {
4207 throw new ObjectDisposedException(GetType().FullName);
4210 if (IsHandleCreated && !is_recreating) {
4214 CreateParams create_params = CreateParams;
4215 window.CreateHandle(create_params);
4217 if (window.Handle != IntPtr.Zero) {
4218 creator_thread = Thread.CurrentThread;
4220 XplatUI.EnableWindow(window.Handle, is_enabled);
4222 if (clip_region != null) {
4223 XplatUI.SetClipRegion(window.Handle, clip_region);
4226 // Set our handle with our parent
4227 if ((parent != null) && (parent.IsHandleCreated)) {
4228 XplatUI.SetParent(window.Handle, parent.Handle);
4232 XplatUI.SetAllowDrop (window.Handle, allow_drop);
4234 // Find out where the window manager placed us
4235 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
4236 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
4239 Rectangle save_bounds = explicit_bounds;
4241 explicit_bounds = save_bounds;
4245 [EditorBrowsable(EditorBrowsableState.Advanced)]
4246 protected virtual void DefWndProc(ref Message m) {
4247 window.DefWndProc(ref m);
4250 [EditorBrowsable(EditorBrowsableState.Advanced)]
4251 protected virtual void DestroyHandle() {
4252 if (IsHandleCreated) {
4253 if (window != null) {
4254 window.DestroyHandle();
4259 protected virtual AccessibleObject GetAccessibilityObjectById (int objectId)
4261 // XXX need to implement this.
4265 protected internal AutoSizeMode GetAutoSizeMode ()
4267 return auto_size_mode;
4270 [EditorBrowsable (EditorBrowsableState.Advanced)]
4271 protected virtual Rectangle GetScaledBounds (Rectangle bounds, SizeF factor, BoundsSpecified specified)
4273 // Top level controls do not scale location
4275 if ((specified & BoundsSpecified.X) == BoundsSpecified.X)
4276 bounds.X = (int)Math.Round (bounds.X * factor.Width);
4277 if ((specified & BoundsSpecified.Y) == BoundsSpecified.Y)
4278 bounds.Y = (int)Math.Round (bounds.Y * factor.Height);
4281 if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width && !GetStyle (ControlStyles.FixedWidth)) {
4282 int border = (this is ComboBox) ? (ThemeEngine.Current.Border3DSize.Width * 2) :
4283 (this.bounds.Width - this.client_size.Width);
4284 bounds.Width = (int)Math.Round ((bounds.Width - border) * factor.Width + border);
4286 if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height && !GetStyle (ControlStyles.FixedHeight)) {
4287 int border = (this is ComboBox) ? (ThemeEngine.Current.Border3DSize.Height * 2) :
4288 (this.bounds.Height - this.client_size.Height);
4289 bounds.Height = (int)Math.Round ((bounds.Height - border) * factor.Height + border);
4295 private Rectangle GetScaledBoundsOld (Rectangle bounds, SizeF factor, BoundsSpecified specified)
4297 RectangleF new_bounds = new RectangleF(bounds.Location, bounds.Size);
4299 // Top level controls do not scale location
4301 if ((specified & BoundsSpecified.X) == BoundsSpecified.X)
4302 new_bounds.X *= factor.Width;
4303 if ((specified & BoundsSpecified.Y) == BoundsSpecified.Y)
4304 new_bounds.Y *= factor.Height;
4307 if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width && !GetStyle (ControlStyles.FixedWidth)) {
4308 int border = (this is Form) ? (this.bounds.Width - this.client_size.Width) : 0;
4309 new_bounds.Width = ((new_bounds.Width - border) * factor.Width + border);
4311 if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height && !GetStyle (ControlStyles.FixedHeight)) {
4312 int border = (this is Form) ? (this.bounds.Height - this.client_size.Height) : 0;
4313 new_bounds.Height = ((new_bounds.Height - border) * factor.Height + border);
4316 bounds.X = (int)Math.Round (new_bounds.X);
4317 bounds.Y = (int)Math.Round (new_bounds.Y);
4318 bounds.Width = (int)Math.Round (new_bounds.Right) - bounds.X;
4319 bounds.Height = (int)Math.Round (new_bounds.Bottom) - bounds.Y;
4324 protected internal bool GetStyle(ControlStyles flag) {
4325 return (control_style & flag) != 0;
4328 protected bool GetTopLevel() {
4332 [EditorBrowsable(EditorBrowsableState.Advanced)]
4333 protected virtual void InitLayout() {
4336 [EditorBrowsable(EditorBrowsableState.Advanced)]
4337 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
4338 toInvoke.OnGotFocus(e);
4341 [EditorBrowsable(EditorBrowsableState.Advanced)]
4342 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
4343 toInvoke.OnLostFocus(e);
4346 [EditorBrowsable(EditorBrowsableState.Advanced)]
4347 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
4348 toInvoke.OnClick(e);
4351 protected void InvokePaint(Control c, PaintEventArgs e) {
4355 protected void InvokePaintBackground(Control c, PaintEventArgs e) {
4356 c.OnPaintBackground (e);
4359 protected virtual bool IsInputChar (char charCode) {
4360 // XXX on MS.NET this method causes the handle to be created..
4361 if (!IsHandleCreated)
4364 return IsInputCharInternal (charCode);
4367 internal virtual bool IsInputCharInternal (char charCode) {
4371 protected virtual bool IsInputKey (Keys keyData) {
4372 // Doc says this one calls IsInputChar; not sure what to do with that
4376 [EditorBrowsable(EditorBrowsableState.Advanced)]
4377 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
4381 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
4382 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
4386 if (parent != null) {
4387 return parent.ProcessCmdKey(ref msg, keyData);
4393 protected virtual bool ProcessDialogChar(char charCode) {
4394 if (parent != null) {
4395 return parent.ProcessDialogChar (charCode);
4401 protected virtual bool ProcessDialogKey (Keys keyData) {
4402 if (parent != null) {
4403 return parent.ProcessDialogKey (keyData);
4409 protected virtual bool ProcessKeyEventArgs (ref Message m)
4411 KeyEventArgs key_event;
4414 case (int)Msg.WM_SYSKEYDOWN:
4415 case (int)Msg.WM_KEYDOWN: {
4416 key_event = new KeyEventArgs (((Keys) m.WParam.ToInt32 ()) | XplatUI.State.ModifierKeys);
4417 OnKeyDown (key_event);
4418 suppressing_key_press = key_event.SuppressKeyPress;
4419 return key_event.Handled;
4422 case (int)Msg.WM_SYSKEYUP:
4423 case (int)Msg.WM_KEYUP: {
4424 key_event = new KeyEventArgs (((Keys) m.WParam.ToInt32 ()) | XplatUI.State.ModifierKeys);
4425 OnKeyUp (key_event);
4426 return key_event.Handled;
4429 case (int)Msg.WM_SYSCHAR:
4430 case (int)Msg.WM_CHAR: {
4431 if (suppressing_key_press)
4433 KeyPressEventArgs key_press_event;
4435 key_press_event = new KeyPressEventArgs ((char) m.WParam);
4436 OnKeyPress(key_press_event);
4437 m.WParam = (IntPtr) key_press_event.KeyChar;
4438 return key_press_event.Handled;
4449 protected internal virtual bool ProcessKeyMessage (ref Message m)
4451 if (parent != null) {
4452 if (parent.ProcessKeyPreview (ref m))
4456 return ProcessKeyEventArgs (ref m);
4459 protected virtual bool ProcessKeyPreview (ref Message m) {
4461 return parent.ProcessKeyPreview(ref m);
4466 protected virtual bool ProcessMnemonic(char charCode) {
4471 [EditorBrowsable(EditorBrowsableState.Advanced)]
4472 protected void RaiseDragEvent(object key, DragEventArgs e) {
4476 [EditorBrowsable(EditorBrowsableState.Advanced)]
4477 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
4481 [EditorBrowsable(EditorBrowsableState.Advanced)]
4482 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
4486 [EditorBrowsable(EditorBrowsableState.Advanced)]
4487 protected void RaisePaintEvent(object key, PaintEventArgs e) {
4491 private void SetIsRecreating () {
4494 foreach (Control c in Controls.GetAllControls()) {
4495 c.SetIsRecreating ();
4499 [EditorBrowsable(EditorBrowsableState.Advanced)]
4500 protected void RecreateHandle() {
4501 if (!IsHandleCreated)
4505 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
4510 if (IsHandleCreated) {
4512 Console.WriteLine(" + handle is created, destroying it.");
4515 // WM_DESTROY will CreateHandle for us
4518 Console.WriteLine(" + handle is not created, creating it.");
4526 is_recreating = false;
4528 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4534 [EditorBrowsable(EditorBrowsableState.Advanced)]
4535 protected void ResetMouseEventArgs() {
4539 [EditorBrowsable(EditorBrowsableState.Advanced)]
4540 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
4541 if (right_to_left == RightToLeft.No) {
4546 case ContentAlignment.TopLeft: {
4547 return ContentAlignment.TopRight;
4550 case ContentAlignment.TopRight: {
4551 return ContentAlignment.TopLeft;
4554 case ContentAlignment.MiddleLeft: {
4555 return ContentAlignment.MiddleRight;
4558 case ContentAlignment.MiddleRight: {
4559 return ContentAlignment.MiddleLeft;
4562 case ContentAlignment.BottomLeft: {
4563 return ContentAlignment.BottomRight;
4566 case ContentAlignment.BottomRight: {
4567 return ContentAlignment.BottomLeft;
4571 // if it's center it doesn't change
4577 [EditorBrowsable(EditorBrowsableState.Advanced)]
4578 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
4579 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
4583 if (align == HorizontalAlignment.Left) {
4584 return HorizontalAlignment.Right;
4587 // align must be HorizontalAlignment.Right
4588 return HorizontalAlignment.Left;
4591 [EditorBrowsable(EditorBrowsableState.Advanced)]
4592 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
4593 if (right_to_left == RightToLeft.No) {
4597 if (align == LeftRightAlignment.Left) {
4598 return LeftRightAlignment.Right;
4601 // align must be LeftRightAlignment.Right;
4602 return LeftRightAlignment.Left;
4605 [EditorBrowsable(EditorBrowsableState.Advanced)]
4606 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
4607 return RtlTranslateAlignment(align);
4610 [EditorBrowsable(EditorBrowsableState.Advanced)]
4611 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
4612 return RtlTranslateAlignment(align);
4615 [EditorBrowsable(EditorBrowsableState.Advanced)]
4616 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
4617 return RtlTranslateAlignment(align);
4620 [EditorBrowsable (EditorBrowsableState.Advanced)]
4621 protected virtual void ScaleControl (SizeF factor, BoundsSpecified specified)
4623 Rectangle new_bounds = GetScaledBounds (bounds, factor, specified);
4625 SetBounds (new_bounds.X, new_bounds.Y, new_bounds.Width, new_bounds.Height, specified);
4628 [EditorBrowsable (EditorBrowsableState.Never)]
4629 protected virtual void ScaleCore (float dx, float dy)
4631 Rectangle new_bounds = GetScaledBoundsOld (bounds, new SizeF (dx, dy), BoundsSpecified.All);
4635 SetBounds (new_bounds.X, new_bounds.Y, new_bounds.Width, new_bounds.Height, BoundsSpecified.All);
4637 if (ScaleChildrenInternal)
4638 foreach (Control c in Controls.GetAllControls ())
4644 protected virtual void Select(bool directed, bool forward) {
4645 IContainerControl container;
4647 container = GetContainerControl();
4648 if (container != null && (Control)container != this)
4649 container.ActiveControl = this;
4652 protected void SetAutoSizeMode (AutoSizeMode mode)
4654 if (auto_size_mode != mode) {
4655 auto_size_mode = mode;
4656 PerformLayout (this, "AutoSizeMode");
4660 [EditorBrowsable(EditorBrowsableState.Advanced)]
4661 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
4662 SetBoundsCoreInternal (x, y, width, height, specified);
4665 internal virtual void SetBoundsCoreInternal(int x, int y, int width, int height, BoundsSpecified specified) {
4666 // Nasty hack for 2.0 DateTimePicker
4667 height = OverrideHeight (height);
4669 Rectangle old_explicit = explicit_bounds;
4670 Rectangle new_bounds = new Rectangle (x, y, width, height);
4672 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
4673 if (IsHandleCreated) {
4674 XplatUI.SetWindowPos(Handle, x, y, width, height);
4676 // Win32 automatically changes negative width/height to 0.
4677 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
4678 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
4681 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
4684 // BoundsSpecified tells us which variables were programatic (user-set).
4685 // We need to store those in the explicit bounds
4686 if ((specified & BoundsSpecified.X) == BoundsSpecified.X)
4687 explicit_bounds.X = new_bounds.X;
4689 explicit_bounds.X = old_explicit.X;
4691 if ((specified & BoundsSpecified.Y) == BoundsSpecified.Y)
4692 explicit_bounds.Y = new_bounds.Y;
4694 explicit_bounds.Y = old_explicit.Y;
4696 if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width)
4697 explicit_bounds.Width = new_bounds.Width;
4699 explicit_bounds.Width = old_explicit.Width;
4701 if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height)
4702 explicit_bounds.Height = new_bounds.Height;
4704 explicit_bounds.Height = old_explicit.Height;
4706 // We need to store the explicit bounds because UpdateBounds is always going
4707 // to change it, and we have to fix it. However, UpdateBounds also calls
4708 // OnLocationChanged, OnSizeChanged, and OnClientSizeChanged. The user can
4709 // override those or use those events to change the size explicitly, and we
4710 // can't undo those changes. So if the bounds after calling UpdateBounds are
4711 // the same as the ones we sent it, we need to fix the explicit bounds. If
4712 // it's not the same as we sent UpdateBounds, then someone else changed it, and
4713 // we better not mess it up. Fun stuff.
4714 Rectangle stored_explicit_bounds = explicit_bounds;
4716 UpdateBounds(x, y, width, height);
4718 if (explicit_bounds.X == x)
4719 explicit_bounds.X = stored_explicit_bounds.X;
4721 if (explicit_bounds.Y == y)
4722 explicit_bounds.Y = stored_explicit_bounds.Y;
4724 if (explicit_bounds.Width == width)
4725 explicit_bounds.Width = stored_explicit_bounds.Width;
4727 if (explicit_bounds.Height == height)
4728 explicit_bounds.Height = stored_explicit_bounds.Height;
4731 [EditorBrowsable(EditorBrowsableState.Advanced)]
4732 protected virtual void SetClientSizeCore(int x, int y) {
4733 Size NewSize = InternalSizeFromClientSize (new Size (x, y));
4735 if (NewSize != Size.Empty)
4736 SetBounds (bounds.X, bounds.Y, NewSize.Width, NewSize.Height, BoundsSpecified.Size);
4739 [EditorBrowsable(EditorBrowsableState.Advanced)]
4740 protected internal void SetStyle(ControlStyles flag, bool value) {
4742 control_style |= flag;
4744 control_style &= ~flag;
4748 protected void SetTopLevel(bool value) {
4749 if ((GetTopLevel() != value) && (parent != null)) {
4750 throw new ArgumentException ("Cannot change toplevel style of a parented control.");
4754 if (IsHandleCreated && value != Visible) {
4758 // XXX MS.NET causes handle to be created here
4759 if (!IsHandleCreated)
4762 is_toplevel = value;
4765 protected virtual void SetVisibleCore(bool value) {
4766 if (value != is_visible) {
4769 if (is_visible && ((window.Handle == IntPtr.Zero) || !is_created)) {
4771 if (!(this is Form))
4775 if (IsHandleCreated) {
4776 XplatUI.SetVisible (Handle, is_visible, true);
4778 if (parent != null && parent.IsHandleCreated) {
4779 parent.Invalidate (bounds);
4784 } else if (is_visible && this is Form) {
4785 // If we are Min or Max, we won't get a WM_SHOWWINDOW from SetWindowState,
4786 // so we need to manually create our children, and set them visible
4787 // (This normally happens in WmShowWindow.)
4788 if ((this as Form).WindowState != FormWindowState.Normal)
4789 OnVisibleChanged (EventArgs.Empty);
4791 // Explicitly move Toplevel windows to where we want them;
4792 // apparently moving unmapped toplevel windows doesn't work
4793 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
4795 // If we are becoming visible, z-order may have changed while
4796 // we were invisible, so update our z-order position
4798 parent.UpdateZOrderOfChild (this);
4801 if (!(this is Form))
4802 OnVisibleChanged (EventArgs.Empty);
4805 OnVisibleChanged(EventArgs.Empty);
4810 [EditorBrowsable (EditorBrowsableState.Advanced)]
4811 protected virtual Size SizeFromClientSize (Size clientSize) {
4812 return InternalSizeFromClientSize (clientSize);
4815 [EditorBrowsable(EditorBrowsableState.Advanced)]
4816 protected void UpdateBounds() {
4817 if (!IsHandleCreated)
4827 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
4829 UpdateBounds(x, y, width, height, client_width, client_height);
4832 [EditorBrowsable(EditorBrowsableState.Advanced)]
4833 protected void UpdateBounds(int x, int y, int width, int height) {
4837 // Calculate client rectangle
4838 rect = new Rectangle(0, 0, 0, 0);
4841 XplatUI.CalculateWindowRect(ref rect, cp, cp.menu, out rect);
4842 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
4845 [EditorBrowsable(EditorBrowsableState.Advanced)]
4846 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
4847 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
4849 bool resized = false;
4851 // Needed to generate required notifications
4852 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
4856 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
4863 bounds.Height=height;
4865 // Assume explicit bounds set. SetBoundsCore will restore old bounds
4867 explicit_bounds = bounds;
4869 client_size.Width=clientWidth;
4870 client_size.Height=clientHeight;
4873 OnLocationChanged(EventArgs.Empty);
4875 if (!background_color.IsEmpty && background_color.A < byte.MaxValue)
4880 OnSizeInitializedOrChanged ();
4881 OnSizeChanged(EventArgs.Empty);
4882 OnClientSizeChanged (EventArgs.Empty);
4886 [EditorBrowsable(EditorBrowsableState.Advanced)]
4887 protected void UpdateStyles() {
4888 if (!IsHandleCreated) {
4892 XplatUI.SetWindowStyle(window.Handle, CreateParams);
4893 OnStyleChanged(EventArgs.Empty);
4896 private void UpdateZOrderOfChild(Control child) {
4897 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this) && Hwnd.ObjectFromHandle(child.Handle).Mapped) {
4898 // Need to take into account all controls
4899 Control [] all_controls = child_controls.GetAllControls ();
4901 int index = Array.IndexOf (all_controls, child);
4903 for (; index > 0; index--) {
4904 if (!all_controls [index - 1].IsHandleCreated || !all_controls [index - 1].VisibleInternal || !Hwnd.ObjectFromHandle(all_controls [index - 1].Handle).Mapped)
4910 XplatUI.SetZOrder(child.Handle, all_controls [index - 1].Handle, false, false);
4912 IntPtr after = AfterTopMostControl ();
4913 if (after != IntPtr.Zero && after != child.Handle)
4914 XplatUI.SetZOrder (child.Handle, after, false, false);
4916 XplatUI.SetZOrder (child.Handle, IntPtr.Zero, true, false);
4921 // Override this if there is a control that shall always remain on
4922 // top of other controls (such as scrollbars). If there are several
4923 // of these controls, the bottom-most should be returned.
4924 internal virtual IntPtr AfterTopMostControl () {
4928 // internal because we need to call it from ScrollableControl.OnVisibleChanged
4929 internal void UpdateChildrenZOrder() {
4930 Control [] controls;
4932 if (!IsHandleCreated) {
4936 // XXX This code is severely broken. It leaks
4937 // the "zero_sized" abstraction out of the X11
4938 // backend and into Control.cs. It'll work on
4939 // windows simply by virtue of windows never
4940 // setting that field to true.
4942 // basically what we need to guard against is
4943 // calling XplatUI.SetZOrder on an hwnd that
4944 // corresponds to an unmapped X window.
4946 // Also, explicitly send implicit controls to the back.
4947 if (child_controls.ImplicitControls == null) {
4948 controls = new Control [child_controls.Count];
4949 child_controls.CopyTo (controls, 0);
4951 controls = new Control [child_controls.Count + child_controls.ImplicitControls.Count];
4952 child_controls.CopyTo (controls, 0);
4953 child_controls.ImplicitControls.CopyTo (controls, child_controls.Count);
4956 ArrayList children_to_order = new ArrayList ();
4958 for (int i = 0; i < controls.Length; i ++) {
4959 if (!controls[i].IsHandleCreated || !controls[i].VisibleInternal)
4962 Hwnd hwnd = Hwnd.ObjectFromHandle (controls[i].Handle);
4963 if (hwnd == null || hwnd.zero_sized)
4966 children_to_order.Add (controls[i]);
4969 for (int i = 1; i < children_to_order.Count; i ++) {
4970 Control upper = (Control)children_to_order[i-1];
4971 Control lower = (Control)children_to_order[i];
4973 XplatUI.SetZOrder(lower.Handle, upper.Handle, false, false);
4977 [EditorBrowsable(EditorBrowsableState.Advanced)]
4978 protected void UpdateZOrder() {
4979 if (parent != null) {
4980 parent.UpdateZOrderOfChild(this);
4984 protected virtual void WndProc(ref Message m) {
4986 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
4988 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
4992 switch((Msg)m.Msg) {
4993 case Msg.WM_DESTROY: {
4998 case Msg.WM_WINDOWPOSCHANGED: {
4999 WmWindowPosChanged(ref m);
5003 // Nice description of what should happen when handling WM_PAINT
5004 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
5005 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
5006 case Msg.WM_PAINT: {
5011 // The DefWndProc will never have to handle this, we always paint the background in managed code
5012 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
5013 // here but it just makes things more complicated...
5014 case Msg.WM_ERASEBKGND: {
5015 WmEraseBackground (ref m);
5019 case Msg.WM_LBUTTONUP: {
5020 WmLButtonUp (ref m);
5024 case Msg.WM_LBUTTONDOWN: {
5025 WmLButtonDown (ref m);
5029 case Msg.WM_LBUTTONDBLCLK: {
5030 WmLButtonDblClick (ref m);
5034 case Msg.WM_MBUTTONUP: {
5035 WmMButtonUp (ref m);
5039 case Msg.WM_MBUTTONDOWN: {
5040 WmMButtonDown (ref m);
5044 case Msg.WM_MBUTTONDBLCLK: {
5045 WmMButtonDblClick (ref m);
5049 case Msg.WM_RBUTTONUP: {
5050 WmRButtonUp (ref m);
5054 case Msg.WM_RBUTTONDOWN: {
5055 WmRButtonDown (ref m);
5059 case Msg.WM_RBUTTONDBLCLK: {
5060 WmRButtonDblClick (ref m);
5064 case Msg.WM_CONTEXTMENU: {
5065 WmContextMenu (ref m);
5069 case Msg.WM_MOUSEWHEEL: {
5070 WmMouseWheel (ref m);
5074 case Msg.WM_MOUSEMOVE: {
5075 WmMouseMove (ref m);
5079 case Msg.WM_SHOWWINDOW: {
5080 WmShowWindow (ref m);
5084 case Msg.WM_CREATE: {
5089 case Msg.WM_MOUSE_ENTER: {
5090 WmMouseEnter (ref m);
5094 case Msg.WM_MOUSELEAVE: {
5095 WmMouseLeave (ref m);
5099 case Msg.WM_MOUSEHOVER: {
5100 WmMouseHover (ref m);
5104 case Msg.WM_SYSKEYUP: {
5109 case Msg.WM_SYSKEYDOWN:
5110 case Msg.WM_KEYDOWN:
5112 case Msg.WM_SYSCHAR:
5123 case Msg.WM_KILLFOCUS: {
5124 WmKillFocus (ref m);
5128 case Msg.WM_SETFOCUS: {
5133 case Msg.WM_SYSCOLORCHANGE: {
5134 WmSysColorChange (ref m);
5138 case Msg.WM_SETCURSOR: {
5139 WmSetCursor (ref m);
5143 case Msg.WM_CAPTURECHANGED: {
5144 WmCaptureChanged (ref m);
5148 case Msg.WM_CHANGEUISTATE: {
5149 WmChangeUIState (ref m);
5153 case Msg.WM_UPDATEUISTATE: {
5154 WmUpdateUIState (ref m);
5164 #endregion // Public Instance Methods
5168 private void WmDestroy (ref Message m) {
5169 OnHandleDestroyed(EventArgs.Empty);
5171 IntPtr handle = window.Handle;
5173 window.InvalidateHandle();
5176 if (is_recreating) {
5178 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
5182 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
5184 is_recreating = false;
5188 is_disposing = false;
5193 private void WmWindowPosChanged (ref Message m) {
5195 Rectangle save_bounds = explicit_bounds;
5197 explicit_bounds = save_bounds;
5198 if (GetStyle(ControlStyles.ResizeRedraw)) {
5205 // Nice description of what should happen when handling WM_PAINT
5206 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
5207 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
5208 private void WmPaint (ref Message m) {
5209 IntPtr handle = Handle;
5211 PaintEventArgs paint_event = XplatUI.PaintEventStart (ref m, handle, true);
5213 if (paint_event == null)
5216 DoubleBuffer current_buffer = null;
5217 if (UseDoubleBuffering) {
5218 current_buffer = GetBackBuffer ();
5219 // This optimization doesn't work when the area is invalidated
5220 // during a paint operation because finishing the paint operation
5221 // clears the invalidated region and then this thing keeps the new
5222 // invalidate from working. To re-enable this, we would need a
5223 // mechanism to allow for nested invalidates (see bug #328681)
5224 //if (!current_buffer.InvalidRegion.IsVisible (paint_event.ClipRectangle)) {
5225 // // Just blit the previous image
5226 // current_buffer.Blit (paint_event);
5227 // XplatUI.PaintEventEnd (ref m, handle, true);
5230 current_buffer.Start (paint_event);
5232 // If using OptimizedDoubleBuffer, ensure the clip region gets set
5233 if (GetStyle (ControlStyles.OptimizedDoubleBuffer))
5234 paint_event.Graphics.SetClip (Rectangle.Intersect (paint_event.ClipRectangle, this.ClientRectangle));
5236 if (!GetStyle(ControlStyles.Opaque)) {
5237 OnPaintBackground (paint_event);
5240 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
5241 OnPaintBackgroundInternal (paint_event);
5243 OnPaintInternal(paint_event);
5244 if (!paint_event.Handled) {
5245 OnPaint (paint_event);
5248 if (current_buffer != null) {
5249 current_buffer.End (paint_event);
5253 XplatUI.PaintEventEnd (ref m, handle, true);
5256 private void WmEraseBackground (ref Message m) {
5257 // The DefWndProc will never have to handle this, we always paint the background in managed code
5258 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
5259 // here but it just makes things more complicated...
5260 m.Result = (IntPtr)1;
5263 private void WmLButtonUp (ref Message m)
5266 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5267 ProcessActiveTracker (ref m);
5273 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
5275 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5278 HandleClick(mouse_clicks, me);
5281 if (InternalCapture) {
5282 InternalCapture = false;
5285 if (mouse_clicks > 1) {
5290 private void WmLButtonDown (ref Message m)
5293 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5294 ProcessActiveTracker (ref m);
5298 ValidationFailed = false;
5300 Select (true, true);
5302 if (!ValidationFailed) {
5303 InternalCapture = true;
5304 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5305 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5310 private void WmLButtonDblClick (ref Message m) {
5311 InternalCapture = true;
5313 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5314 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5318 private void WmMButtonUp (ref Message m) {
5321 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
5323 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5326 HandleClick(mouse_clicks, me);
5328 if (InternalCapture) {
5329 InternalCapture = false;
5331 if (mouse_clicks > 1) {
5336 private void WmMButtonDown (ref Message m) {
5337 InternalCapture = true;
5338 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5339 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5343 private void WmMButtonDblClick (ref Message m) {
5344 InternalCapture = true;
5346 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5347 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5351 private void WmRButtonUp (ref Message m)
5354 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5355 ProcessActiveTracker (ref m);
5362 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
5363 pt = PointToScreen(pt);
5365 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
5367 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5370 HandleClick(mouse_clicks, me);
5372 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
5375 if (InternalCapture) {
5376 InternalCapture = false;
5379 if (mouse_clicks > 1) {
5384 private void WmRButtonDown (ref Message m)
5387 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5388 ProcessActiveTracker (ref m);
5392 InternalCapture = true;
5393 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5394 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5398 private void WmRButtonDblClick (ref Message m) {
5399 InternalCapture = true;
5401 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5402 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5406 private void WmContextMenu (ref Message m) {
5407 if (context_menu != null) {
5410 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
5412 if (pt.X == -1 || pt.Y == -1) {
5413 pt.X = (this.Width / 2) + this.Left;
5414 pt.Y = (this.Height / 2) + this.Top;
5415 pt = this.PointToScreen (pt);
5418 context_menu.Show (this, PointToClient (pt));
5422 // If there isn't a regular context menu, show the Strip version
5423 if (context_menu == null && context_menu_strip != null) {
5426 pt = new Point (LowOrder ((int)m.LParam.ToInt32 ()), HighOrder ((int)m.LParam.ToInt32 ()));
5428 if (pt.X == -1 || pt.Y == -1) {
5429 pt.X = (this.Width / 2) + this.Left;
5430 pt.Y = (this.Height /2) + this.Top;
5431 pt = this.PointToScreen (pt);
5434 context_menu_strip.SetSourceControl (this);
5435 context_menu_strip.Show (this, PointToClient (pt));
5441 private void WmCreate (ref Message m) {
5442 OnHandleCreated(EventArgs.Empty);
5445 private void WmMouseWheel (ref Message m) {
5447 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((long) m.WParam),
5448 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5449 HighOrder((long)m.WParam)));
5453 private void WmMouseMove (ref Message m) {
5454 if (XplatUI.IsEnabled (Handle) && active_tracker != null) {
5455 MouseEventArgs args = new MouseEventArgs (
5456 FromParamToMouseButtons ((int)m.WParam.ToInt32 ()),
5458 Control.MousePosition.X,
5459 Control.MousePosition.Y,
5462 active_tracker.OnMotion (args);
5466 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
5468 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
5472 private void WmMouseEnter (ref Message m) {
5477 OnMouseEnter(EventArgs.Empty);
5480 private void WmMouseLeave (ref Message m) {
5482 OnMouseLeave(EventArgs.Empty);
5485 private void WmMouseHover (ref Message m) {
5486 OnMouseHover(EventArgs.Empty);
5489 private void WmShowWindow (ref Message m) {
5493 Form frm = this as Form;
5494 if (m.WParam.ToInt32() != 0) {
5495 if (m.LParam.ToInt32 () == 0) {
5498 // Make sure all our children are properly parented to us
5499 Control [] controls = child_controls.GetAllControls ();
5500 // bool parented = false;
5501 for (int i=0; i<controls.Length; i++) {
5502 if (controls [i].is_visible && controls[i].IsHandleCreated)
5503 if (XplatUI.GetParent (controls[i].Handle) != window.Handle) {
5504 XplatUI.SetParent(controls[i].Handle, window.Handle);
5511 UpdateChildrenZOrder ();
5514 if (parent != null && Focused) {
5516 // Need to start at parent, GetContainerControl might return ourselves if we're a container
5517 container = (Control)parent.GetContainerControl();
5518 if (container != null && (frm == null || !frm.IsMdiChild)) {
5519 container.SelectNextControl(this, true, true, true, true);
5525 frm.waiting_showwindow = false;
5527 // If the form is Max/Min, it got its OnVisibleChanged in SetVisibleCore
5529 if (!IsRecreating && (frm.IsMdiChild || frm.WindowState == FormWindowState.Normal)) /* XXX make sure this works for mdi forms */
5530 OnVisibleChanged(EventArgs.Empty);
5531 } else if (is_toplevel)
5532 OnVisibleChanged(EventArgs.Empty);
5535 private void WmSysKeyUp (ref Message m) {
5536 if (ProcessKeyMessage(ref m)) {
5537 m.Result = IntPtr.Zero;
5541 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
5545 if (form != null && form.ActiveMenu != null) {
5546 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
5549 if (ToolStripManager.ProcessMenuKey (ref m))
5556 private void WmKeys (ref Message m)
5558 if (ProcessKeyMessage(ref m)) {
5559 m.Result = IntPtr.Zero;
5565 private void WmHelp (ref Message m) {
5567 if (m.LParam != IntPtr.Zero) {
5570 hi = new HELPINFO();
5572 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
5573 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
5575 mouse_pos = Control.MousePosition;
5577 OnHelpRequested(new HelpEventArgs(mouse_pos));
5578 m.Result = (IntPtr)1;
5581 private void WmKillFocus (ref Message m) {
5582 this.has_focus = false;
5583 OnLostFocus (EventArgs.Empty);
5586 private void WmSetFocus (ref Message m) {
5588 this.has_focus = true;
5589 OnGotFocus (EventArgs.Empty);
5593 private void WmSysColorChange (ref Message m) {
5594 ThemeEngine.Current.ResetDefaults();
5595 OnSystemColorsChanged(EventArgs.Empty);
5598 private void WmSetCursor (ref Message m) {
5599 if ((cursor == null && use_wait_cursor == false) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
5604 XplatUI.SetCursor(window.Handle, Cursor.handle);
5605 m.Result = (IntPtr)1;
5608 private void WmCaptureChanged (ref Message m) {
5609 is_captured = false;
5610 OnMouseCaptureChanged (EventArgs.Empty);
5611 m.Result = (IntPtr) 0;
5614 private void WmChangeUIState (ref Message m) {
5615 foreach (Control control in Controls) {
5616 XplatUI.SendMessage (control.Handle, Msg.WM_UPDATEUISTATE, m.WParam, m.LParam);
5620 private void WmUpdateUIState (ref Message m) {
5621 int action = LowOrder (m.WParam.ToInt32 ());
5622 int element = HighOrder (m.WParam.ToInt32 ());
5624 if (action == (int) MsgUIState.UIS_INITIALIZE)
5627 UICues cues = UICues.None;
5629 if ((element & (int) MsgUIState.UISF_HIDEACCEL) != 0) {
5630 if ((action == (int) MsgUIState.UIS_CLEAR) != show_keyboard_cues) {
5631 cues |= UICues.ChangeKeyboard;
5632 show_keyboard_cues = (action == (int) MsgUIState.UIS_CLEAR);
5636 if ((element & (int) MsgUIState.UISF_HIDEFOCUS) != 0) {
5637 if ((action == (int) MsgUIState.UIS_CLEAR) != show_focus_cues) {
5638 cues |= UICues.ChangeFocus;
5639 show_focus_cues = (action == (int) MsgUIState.UIS_CLEAR);
5643 if ((cues & UICues.Changed) != UICues.None) {
5644 OnChangeUICues (new UICuesEventArgs (cues));
5651 #region OnXXX methods
5652 protected virtual void OnAutoSizeChanged (EventArgs e)
5654 EventHandler eh = (EventHandler)(Events[AutoSizeChangedEvent]);
5659 [EditorBrowsable (EditorBrowsableState.Advanced)]
5660 protected virtual void OnBackColorChanged(EventArgs e) {
5661 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
5664 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
5667 [EditorBrowsable(EditorBrowsableState.Advanced)]
5668 protected virtual void OnBackgroundImageChanged(EventArgs e) {
5669 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
5672 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
5675 [EditorBrowsable (EditorBrowsableState.Advanced)]
5676 protected virtual void OnBackgroundImageLayoutChanged (EventArgs e)
5678 EventHandler eh = (EventHandler)(Events[BackgroundImageLayoutChangedEvent]);
5683 [EditorBrowsable(EditorBrowsableState.Advanced)]
5684 protected virtual void OnBindingContextChanged(EventArgs e) {
5685 CheckDataBindings ();
5686 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
5689 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
5692 [EditorBrowsable(EditorBrowsableState.Advanced)]
5693 protected virtual void OnCausesValidationChanged(EventArgs e) {
5694 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
5699 [EditorBrowsable(EditorBrowsableState.Advanced)]
5700 protected virtual void OnChangeUICues(UICuesEventArgs e) {
5701 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
5706 [EditorBrowsable(EditorBrowsableState.Advanced)]
5707 protected virtual void OnClick(EventArgs e) {
5708 EventHandler eh = (EventHandler)(Events [ClickEvent]);
5713 [EditorBrowsable (EditorBrowsableState.Advanced)]
5714 protected virtual void OnClientSizeChanged (EventArgs e)
5716 EventHandler eh = (EventHandler)(Events[ClientSizeChangedEvent]);
5721 [EditorBrowsable(EditorBrowsableState.Advanced)]
5722 protected virtual void OnContextMenuChanged(EventArgs e) {
5723 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
5728 [EditorBrowsable (EditorBrowsableState.Advanced)]
5729 protected virtual void OnContextMenuStripChanged (EventArgs e) {
5730 EventHandler eh = (EventHandler)(Events [ContextMenuStripChangedEvent]);
5735 [EditorBrowsable(EditorBrowsableState.Advanced)]
5736 protected virtual void OnControlAdded(ControlEventArgs e) {
5737 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
5742 [EditorBrowsable(EditorBrowsableState.Advanced)]
5743 protected virtual void OnControlRemoved(ControlEventArgs e) {
5744 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
5749 [EditorBrowsable(EditorBrowsableState.Advanced)]
5750 protected virtual void OnCreateControl() {
5754 [EditorBrowsable(EditorBrowsableState.Advanced)]
5755 protected virtual void OnCursorChanged(EventArgs e) {
5756 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
5760 for (int i = 0; i < child_controls.Count; i++) child_controls[i].OnParentCursorChanged (e);
5763 [EditorBrowsable(EditorBrowsableState.Advanced)]
5764 protected virtual void OnDockChanged(EventArgs e) {
5765 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
5770 [EditorBrowsable(EditorBrowsableState.Advanced)]
5771 protected virtual void OnDoubleClick(EventArgs e) {
5772 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
5777 [EditorBrowsable(EditorBrowsableState.Advanced)]
5778 protected virtual void OnDragDrop(DragEventArgs drgevent) {
5779 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
5781 eh (this, drgevent);
5784 [EditorBrowsable(EditorBrowsableState.Advanced)]
5785 protected virtual void OnDragEnter(DragEventArgs drgevent) {
5786 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
5788 eh (this, drgevent);
5791 [EditorBrowsable(EditorBrowsableState.Advanced)]
5792 protected virtual void OnDragLeave(EventArgs e) {
5793 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
5798 [EditorBrowsable(EditorBrowsableState.Advanced)]
5799 protected virtual void OnDragOver(DragEventArgs drgevent) {
5800 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
5802 eh (this, drgevent);
5805 [EditorBrowsable(EditorBrowsableState.Advanced)]
5806 protected virtual void OnEnabledChanged(EventArgs e) {
5807 if (IsHandleCreated) {
5809 if (((Form)this).context == null) {
5810 XplatUI.EnableWindow(window.Handle, Enabled);
5813 XplatUI.EnableWindow(window.Handle, Enabled);
5818 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
5822 foreach (Control c in Controls.GetAllControls ())
5823 c.OnParentEnabledChanged (e);
5826 [EditorBrowsable(EditorBrowsableState.Advanced)]
5827 protected virtual void OnEnter(EventArgs e) {
5828 EventHandler eh = (EventHandler)(Events [EnterEvent]);
5833 [EditorBrowsable(EditorBrowsableState.Advanced)]
5834 protected virtual void OnFontChanged(EventArgs e) {
5835 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
5838 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
5841 [EditorBrowsable(EditorBrowsableState.Advanced)]
5842 protected virtual void OnForeColorChanged(EventArgs e) {
5843 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
5846 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
5849 [EditorBrowsable(EditorBrowsableState.Advanced)]
5850 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
5851 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
5853 eh (this, gfbevent);
5856 [EditorBrowsable(EditorBrowsableState.Advanced)]
5857 protected virtual void OnGotFocus(EventArgs e) {
5858 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
5863 [EditorBrowsable(EditorBrowsableState.Advanced)]
5864 protected virtual void OnHandleCreated(EventArgs e) {
5865 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
5870 [EditorBrowsable(EditorBrowsableState.Advanced)]
5871 protected virtual void OnHandleDestroyed(EventArgs e) {
5872 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
5877 internal void RaiseHelpRequested (HelpEventArgs hevent) {
5878 OnHelpRequested (hevent);
5881 [EditorBrowsable(EditorBrowsableState.Advanced)]
5882 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
5883 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
5888 protected virtual void OnImeModeChanged(EventArgs e) {
5889 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
5894 [EditorBrowsable(EditorBrowsableState.Advanced)]
5895 protected virtual void OnInvalidated(InvalidateEventArgs e) {
5896 if (UseDoubleBuffering) {
5897 // should this block be here? seems like it
5898 // would be more at home in
5899 // NotifyInvalidated..
5900 if (e.InvalidRect == ClientRectangle) {
5901 InvalidateBackBuffer ();
5902 } else if (backbuffer != null){
5903 // we need this Inflate call here so
5904 // that the border of the rectangle is
5905 // considered Visible (the
5906 // invalid_region.IsVisible call) in
5907 // the WM_PAINT handling below.
5908 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
5909 backbuffer.InvalidRegion.Union (r);
5913 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
5918 [EditorBrowsable(EditorBrowsableState.Advanced)]
5919 protected virtual void OnKeyDown(KeyEventArgs e) {
5920 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
5925 [EditorBrowsable(EditorBrowsableState.Advanced)]
5926 protected virtual void OnKeyPress(KeyPressEventArgs e) {
5927 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
5932 [EditorBrowsable(EditorBrowsableState.Advanced)]
5933 protected virtual void OnKeyUp(KeyEventArgs e) {
5934 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
5939 [EditorBrowsable(EditorBrowsableState.Advanced)]
5940 protected virtual void OnLayout(LayoutEventArgs levent) {
5941 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
5947 // If our layout changed our PreferredSize, our parent
5948 // needs to re-lay us out. However, it's not always possible to
5949 // be our preferred size, so only try once so we don't loop forever.
5950 if (Parent != null && AutoSize && !nested_layout && PreferredSize != s) {
5951 nested_layout = true;
5952 Parent.PerformLayout ();
5953 nested_layout = false;
5956 LayoutEngine.Layout (this, levent);
5959 [EditorBrowsable(EditorBrowsableState.Advanced)]
5960 protected virtual void OnLeave(EventArgs e) {
5961 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
5966 [EditorBrowsable(EditorBrowsableState.Advanced)]
5967 protected virtual void OnLocationChanged(EventArgs e) {
5969 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
5974 [EditorBrowsable(EditorBrowsableState.Advanced)]
5975 protected virtual void OnLostFocus(EventArgs e) {
5976 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
5981 protected virtual void OnMarginChanged (EventArgs e)
5983 EventHandler eh = (EventHandler)(Events[MarginChangedEvent]);
5987 [EditorBrowsable (EditorBrowsableState.Advanced)]
5988 protected virtual void OnMouseCaptureChanged (EventArgs e)
5990 EventHandler eh = (EventHandler)(Events [MouseCaptureChangedEvent]);
5995 [EditorBrowsable (EditorBrowsableState.Advanced)]
5996 protected virtual void OnMouseClick (MouseEventArgs e)
5998 MouseEventHandler eh = (MouseEventHandler)(Events [MouseClickEvent]);
6003 [EditorBrowsable (EditorBrowsableState.Advanced)]
6004 protected virtual void OnMouseDoubleClick (MouseEventArgs e)
6006 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDoubleClickEvent]);
6011 [EditorBrowsable(EditorBrowsableState.Advanced)]
6012 protected virtual void OnMouseDown(MouseEventArgs e) {
6013 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
6018 [EditorBrowsable(EditorBrowsableState.Advanced)]
6019 protected virtual void OnMouseEnter(EventArgs e) {
6020 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
6025 [EditorBrowsable(EditorBrowsableState.Advanced)]
6026 protected virtual void OnMouseHover(EventArgs e) {
6027 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
6032 [EditorBrowsable(EditorBrowsableState.Advanced)]
6033 protected virtual void OnMouseLeave(EventArgs e) {
6034 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
6039 [EditorBrowsable(EditorBrowsableState.Advanced)]
6040 protected virtual void OnMouseMove(MouseEventArgs e) {
6041 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
6046 [EditorBrowsable(EditorBrowsableState.Advanced)]
6047 protected virtual void OnMouseUp(MouseEventArgs e) {
6048 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
6053 [EditorBrowsable(EditorBrowsableState.Advanced)]
6054 protected virtual void OnMouseWheel(MouseEventArgs e) {
6055 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
6060 [EditorBrowsable(EditorBrowsableState.Advanced)]
6061 protected virtual void OnMove(EventArgs e) {
6062 EventHandler eh = (EventHandler)(Events [MoveEvent]);
6067 [EditorBrowsable(EditorBrowsableState.Advanced)]
6068 protected virtual void OnNotifyMessage(Message m) {
6072 protected virtual void OnPaddingChanged (EventArgs e) {
6073 EventHandler eh = (EventHandler) (Events [PaddingChangedEvent]);
6078 [EditorBrowsable(EditorBrowsableState.Advanced)]
6079 protected virtual void OnPaint(PaintEventArgs e) {
6080 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
6085 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
6089 internal virtual void OnPaintInternal(PaintEventArgs e) {
6093 [EditorBrowsable(EditorBrowsableState.Advanced)]
6094 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
6095 PaintControlBackground (pevent);
6098 [EditorBrowsable(EditorBrowsableState.Advanced)]
6099 protected virtual void OnParentBackColorChanged(EventArgs e) {
6100 if (background_color.IsEmpty && background_image==null) {
6102 OnBackColorChanged(e);
6106 [EditorBrowsable(EditorBrowsableState.Advanced)]
6107 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
6109 OnBackgroundImageChanged(e);
6112 [EditorBrowsable(EditorBrowsableState.Advanced)]
6113 protected virtual void OnParentBindingContextChanged(EventArgs e) {
6114 if (binding_context==null && Parent != null) {
6115 binding_context=Parent.binding_context;
6116 OnBindingContextChanged(e);
6120 [EditorBrowsable(EditorBrowsableState.Advanced)]
6121 protected virtual void OnParentChanged(EventArgs e) {
6122 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
6127 [EditorBrowsable (EditorBrowsableState.Advanced)]
6128 protected virtual void OnParentCursorChanged (EventArgs e)
6132 [EditorBrowsable (EditorBrowsableState.Advanced)]
6133 protected virtual void OnParentEnabledChanged(EventArgs e) {
6135 OnEnabledChanged(e);
6139 [EditorBrowsable(EditorBrowsableState.Advanced)]
6140 protected virtual void OnParentFontChanged(EventArgs e) {
6147 [EditorBrowsable(EditorBrowsableState.Advanced)]
6148 protected virtual void OnParentForeColorChanged(EventArgs e) {
6149 if (foreground_color.IsEmpty) {
6151 OnForeColorChanged(e);
6155 [EditorBrowsable(EditorBrowsableState.Advanced)]
6156 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
6157 if (right_to_left==RightToLeft.Inherit) {
6159 OnRightToLeftChanged(e);
6163 [EditorBrowsable(EditorBrowsableState.Advanced)]
6164 protected virtual void OnParentVisibleChanged(EventArgs e) {
6166 OnVisibleChanged(e);
6170 [EditorBrowsable(EditorBrowsableState.Advanced)]
6171 protected virtual void OnQueryContinueDrag (QueryContinueDragEventArgs qcdevent)
6173 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
6175 eh (this, qcdevent);
6178 [EditorBrowsable (EditorBrowsableState.Advanced)]
6179 protected virtual void OnPreviewKeyDown (PreviewKeyDownEventArgs e)
6181 PreviewKeyDownEventHandler eh = (PreviewKeyDownEventHandler)(Events[PreviewKeyDownEvent]);
6186 [EditorBrowsable (EditorBrowsableState.Advanced)]
6187 protected virtual void OnPrint (PaintEventArgs e)
6189 PaintEventHandler eh = (PaintEventHandler)(Events[PaintEvent]);
6194 [EditorBrowsable (EditorBrowsableState.Advanced)]
6195 protected virtual void OnRegionChanged (EventArgs e)
6197 EventHandler eh = (EventHandler)(Events[RegionChangedEvent]);
6202 [EditorBrowsable(EditorBrowsableState.Advanced)]
6203 protected virtual void OnResize(EventArgs e) {
6204 OnResizeInternal (e);
6207 internal virtual void OnResizeInternal (EventArgs e) {
6208 PerformLayout(this, "Bounds");
6210 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
6215 [EditorBrowsable(EditorBrowsableState.Advanced)]
6216 protected virtual void OnRightToLeftChanged(EventArgs e) {
6217 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
6220 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
6223 [EditorBrowsable(EditorBrowsableState.Advanced)]
6224 protected virtual void OnSizeChanged(EventArgs e) {
6225 DisposeBackBuffer ();
6227 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
6232 [EditorBrowsable(EditorBrowsableState.Advanced)]
6233 protected virtual void OnStyleChanged(EventArgs e) {
6234 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
6239 [EditorBrowsable(EditorBrowsableState.Advanced)]
6240 protected virtual void OnSystemColorsChanged(EventArgs e) {
6241 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
6246 [EditorBrowsable(EditorBrowsableState.Advanced)]
6247 protected virtual void OnTabIndexChanged(EventArgs e) {
6248 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
6253 [EditorBrowsable(EditorBrowsableState.Advanced)]
6254 protected virtual void OnTabStopChanged(EventArgs e) {
6255 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
6260 [EditorBrowsable(EditorBrowsableState.Advanced)]
6261 protected virtual void OnTextChanged(EventArgs e) {
6262 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
6267 [EditorBrowsable(EditorBrowsableState.Advanced)]
6268 protected virtual void OnValidated(EventArgs e) {
6269 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
6274 [EditorBrowsable(EditorBrowsableState.Advanced)]
6275 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
6276 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
6281 [EditorBrowsable(EditorBrowsableState.Advanced)]
6282 protected virtual void OnVisibleChanged(EventArgs e) {
6286 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
6290 // We need to tell our kids (including implicit ones)
6291 foreach (Control c in Controls.GetAllControls ())
6293 c.OnParentVisibleChanged (e);
6295 #endregion // OnXXX methods
6298 static object AutoSizeChangedEvent = new object ();
6299 static object BackColorChangedEvent = new object ();
6300 static object BackgroundImageChangedEvent = new object ();
6301 static object BackgroundImageLayoutChangedEvent = new object ();
6302 static object BindingContextChangedEvent = new object ();
6303 static object CausesValidationChangedEvent = new object ();
6304 static object ChangeUICuesEvent = new object ();
6305 static object ClickEvent = new object ();
6306 static object ClientSizeChangedEvent = new object ();
6307 static object ContextMenuChangedEvent = new object ();
6308 static object ContextMenuStripChangedEvent = new object ();
6309 static object ControlAddedEvent = new object ();
6310 static object ControlRemovedEvent = new object ();
6311 static object CursorChangedEvent = new object ();
6312 static object DockChangedEvent = new object ();
6313 static object DoubleClickEvent = new object ();
6314 static object DragDropEvent = new object ();
6315 static object DragEnterEvent = new object ();
6316 static object DragLeaveEvent = new object ();
6317 static object DragOverEvent = new object ();
6318 static object EnabledChangedEvent = new object ();
6319 static object EnterEvent = new object ();
6320 static object FontChangedEvent = new object ();
6321 static object ForeColorChangedEvent = new object ();
6322 static object GiveFeedbackEvent = new object ();
6323 static object GotFocusEvent = new object ();
6324 static object HandleCreatedEvent = new object ();
6325 static object HandleDestroyedEvent = new object ();
6326 static object HelpRequestedEvent = new object ();
6327 static object ImeModeChangedEvent = new object ();
6328 static object InvalidatedEvent = new object ();
6329 static object KeyDownEvent = new object ();
6330 static object KeyPressEvent = new object ();
6331 static object KeyUpEvent = new object ();
6332 static object LayoutEvent = new object ();
6333 static object LeaveEvent = new object ();
6334 static object LocationChangedEvent = new object ();
6335 static object LostFocusEvent = new object ();
6336 static object MarginChangedEvent = new object ();
6337 static object MouseCaptureChangedEvent = new object ();
6338 static object MouseClickEvent = new object ();
6339 static object MouseDoubleClickEvent = new object ();
6340 static object MouseDownEvent = new object ();
6341 static object MouseEnterEvent = new object ();
6342 static object MouseHoverEvent = new object ();
6343 static object MouseLeaveEvent = new object ();
6344 static object MouseMoveEvent = new object ();
6345 static object MouseUpEvent = new object ();
6346 static object MouseWheelEvent = new object ();
6347 static object MoveEvent = new object ();
6348 static object PaddingChangedEvent = new object ();
6349 static object PaintEvent = new object ();
6350 static object ParentChangedEvent = new object ();
6351 static object PreviewKeyDownEvent = new object ();
6352 static object QueryAccessibilityHelpEvent = new object ();
6353 static object QueryContinueDragEvent = new object ();
6354 static object RegionChangedEvent = new object ();
6355 static object ResizeEvent = new object ();
6356 static object RightToLeftChangedEvent = new object ();
6357 static object SizeChangedEvent = new object ();
6358 static object StyleChangedEvent = new object ();
6359 static object SystemColorsChangedEvent = new object ();
6360 static object TabIndexChangedEvent = new object ();
6361 static object TabStopChangedEvent = new object ();
6362 static object TextChangedEvent = new object ();
6363 static object ValidatedEvent = new object ();
6364 static object ValidatingEvent = new object ();
6365 static object VisibleChangedEvent = new object ();
6368 [EditorBrowsable (EditorBrowsableState.Never)]
6369 public event EventHandler AutoSizeChanged {
6370 add { Events.AddHandler (AutoSizeChangedEvent, value);}
6371 remove {Events.RemoveHandler (AutoSizeChangedEvent, value);}
6373 public event EventHandler BackColorChanged {
6374 add { Events.AddHandler (BackColorChangedEvent, value); }
6375 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
6378 public event EventHandler BackgroundImageChanged {
6379 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
6380 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
6383 public event EventHandler BackgroundImageLayoutChanged {
6384 add {Events.AddHandler (BackgroundImageLayoutChangedEvent, value);}
6385 remove {Events.RemoveHandler (BackgroundImageLayoutChangedEvent, value);}
6388 public event EventHandler BindingContextChanged {
6389 add { Events.AddHandler (BindingContextChangedEvent, value); }
6390 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
6393 public event EventHandler CausesValidationChanged {
6394 add { Events.AddHandler (CausesValidationChangedEvent, value); }
6395 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
6398 public event UICuesEventHandler ChangeUICues {
6399 add { Events.AddHandler (ChangeUICuesEvent, value); }
6400 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
6403 public event EventHandler Click {
6404 add { Events.AddHandler (ClickEvent, value); }
6405 remove { Events.RemoveHandler (ClickEvent, value); }
6408 public event EventHandler ClientSizeChanged {
6409 add {Events.AddHandler (ClientSizeChangedEvent, value);}
6410 remove {Events.RemoveHandler (ClientSizeChangedEvent, value);}
6414 public event EventHandler ContextMenuChanged {
6415 add { Events.AddHandler (ContextMenuChangedEvent, value); }
6416 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
6419 public event EventHandler ContextMenuStripChanged {
6420 add { Events.AddHandler (ContextMenuStripChangedEvent, value); }
6421 remove { Events.RemoveHandler (ContextMenuStripChangedEvent, value);}
6425 [EditorBrowsable(EditorBrowsableState.Advanced)]
6427 public event ControlEventHandler ControlAdded {
6428 add { Events.AddHandler (ControlAddedEvent, value); }
6429 remove { Events.RemoveHandler (ControlAddedEvent, value); }
6432 [EditorBrowsable(EditorBrowsableState.Advanced)]
6434 public event ControlEventHandler ControlRemoved {
6435 add { Events.AddHandler (ControlRemovedEvent, value); }
6436 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
6439 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
6440 public event EventHandler CursorChanged {
6441 add { Events.AddHandler (CursorChangedEvent, value); }
6442 remove { Events.RemoveHandler (CursorChangedEvent, value); }
6444 public event EventHandler DockChanged {
6445 add { Events.AddHandler (DockChangedEvent, value); }
6446 remove { Events.RemoveHandler (DockChangedEvent, value); }
6449 public event EventHandler DoubleClick {
6450 add { Events.AddHandler (DoubleClickEvent, value); }
6451 remove { Events.RemoveHandler (DoubleClickEvent, value); }
6454 public event DragEventHandler DragDrop {
6455 add { Events.AddHandler (DragDropEvent, value); }
6456 remove { Events.RemoveHandler (DragDropEvent, value); }
6459 public event DragEventHandler DragEnter {
6460 add { Events.AddHandler (DragEnterEvent, value); }
6461 remove { Events.RemoveHandler (DragEnterEvent, value); }
6464 public event EventHandler DragLeave {
6465 add { Events.AddHandler (DragLeaveEvent, value); }
6466 remove { Events.RemoveHandler (DragLeaveEvent, value); }
6469 public event DragEventHandler DragOver {
6470 add { Events.AddHandler (DragOverEvent, value); }
6471 remove { Events.RemoveHandler (DragOverEvent, value); }
6474 public event EventHandler EnabledChanged {
6475 add { Events.AddHandler (EnabledChangedEvent, value); }
6476 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
6479 public event EventHandler Enter {
6480 add { Events.AddHandler (EnterEvent, value); }
6481 remove { Events.RemoveHandler (EnterEvent, value); }
6484 public event EventHandler FontChanged {
6485 add { Events.AddHandler (FontChangedEvent, value); }
6486 remove { Events.RemoveHandler (FontChangedEvent, value); }
6489 public event EventHandler ForeColorChanged {
6490 add { Events.AddHandler (ForeColorChangedEvent, value); }
6491 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
6494 public event GiveFeedbackEventHandler GiveFeedback {
6495 add { Events.AddHandler (GiveFeedbackEvent, value); }
6496 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
6499 [EditorBrowsable(EditorBrowsableState.Advanced)]
6501 public event EventHandler GotFocus {
6502 add { Events.AddHandler (GotFocusEvent, value); }
6503 remove { Events.RemoveHandler (GotFocusEvent, value); }
6507 [EditorBrowsable(EditorBrowsableState.Advanced)]
6509 public event EventHandler HandleCreated {
6510 add { Events.AddHandler (HandleCreatedEvent, value); }
6511 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
6514 [EditorBrowsable(EditorBrowsableState.Advanced)]
6516 public event EventHandler HandleDestroyed {
6517 add { Events.AddHandler (HandleDestroyedEvent, value); }
6518 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
6521 public event HelpEventHandler HelpRequested {
6522 add { Events.AddHandler (HelpRequestedEvent, value); }
6523 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
6526 public event EventHandler ImeModeChanged {
6527 add { Events.AddHandler (ImeModeChangedEvent, value); }
6528 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
6531 [EditorBrowsable(EditorBrowsableState.Advanced)]
6533 public event InvalidateEventHandler Invalidated {
6534 add { Events.AddHandler (InvalidatedEvent, value); }
6535 remove { Events.RemoveHandler (InvalidatedEvent, value); }
6538 public event KeyEventHandler KeyDown {
6539 add { Events.AddHandler (KeyDownEvent, value); }
6540 remove { Events.RemoveHandler (KeyDownEvent, value); }
6543 public event KeyPressEventHandler KeyPress {
6544 add { Events.AddHandler (KeyPressEvent, value); }
6545 remove { Events.RemoveHandler (KeyPressEvent, value); }
6548 public event KeyEventHandler KeyUp {
6549 add { Events.AddHandler (KeyUpEvent, value); }
6550 remove { Events.RemoveHandler (KeyUpEvent, value); }
6553 public event LayoutEventHandler Layout {
6554 add { Events.AddHandler (LayoutEvent, value); }
6555 remove { Events.RemoveHandler (LayoutEvent, value); }
6558 public event EventHandler Leave {
6559 add { Events.AddHandler (LeaveEvent, value); }
6560 remove { Events.RemoveHandler (LeaveEvent, value); }
6563 public event EventHandler LocationChanged {
6564 add { Events.AddHandler (LocationChangedEvent, value); }
6565 remove { Events.RemoveHandler (LocationChangedEvent, value); }
6568 [EditorBrowsable(EditorBrowsableState.Advanced)]
6570 public event EventHandler LostFocus {
6571 add { Events.AddHandler (LostFocusEvent, value); }
6572 remove { Events.RemoveHandler (LostFocusEvent, value); }
6575 public event EventHandler MarginChanged {
6576 add { Events.AddHandler (MarginChangedEvent, value); }
6577 remove {Events.RemoveHandler (MarginChangedEvent, value); }
6580 public event EventHandler MouseCaptureChanged {
6581 add { Events.AddHandler (MouseCaptureChangedEvent, value); }
6582 remove { Events.RemoveHandler (MouseCaptureChangedEvent, value); }
6584 public event MouseEventHandler MouseClick
6586 add { Events.AddHandler (MouseClickEvent, value); }
6587 remove { Events.RemoveHandler (MouseClickEvent, value); }
6589 public event MouseEventHandler MouseDoubleClick
6591 add { Events.AddHandler (MouseDoubleClickEvent, value); }
6592 remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
6594 public event MouseEventHandler MouseDown {
6595 add { Events.AddHandler (MouseDownEvent, value); }
6596 remove { Events.RemoveHandler (MouseDownEvent, value); }
6599 public event EventHandler MouseEnter {
6600 add { Events.AddHandler (MouseEnterEvent, value); }
6601 remove { Events.RemoveHandler (MouseEnterEvent, value); }
6604 public event EventHandler MouseHover {
6605 add { Events.AddHandler (MouseHoverEvent, value); }
6606 remove { Events.RemoveHandler (MouseHoverEvent, value); }
6609 public event EventHandler MouseLeave {
6610 add { Events.AddHandler (MouseLeaveEvent, value); }
6611 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
6614 public event MouseEventHandler MouseMove {
6615 add { Events.AddHandler (MouseMoveEvent, value); }
6616 remove { Events.RemoveHandler (MouseMoveEvent, value); }
6619 public event MouseEventHandler MouseUp {
6620 add { Events.AddHandler (MouseUpEvent, value); }
6621 remove { Events.RemoveHandler (MouseUpEvent, value); }
6624 [EditorBrowsable(EditorBrowsableState.Advanced)]
6626 public event MouseEventHandler MouseWheel {
6627 add { Events.AddHandler (MouseWheelEvent, value); }
6628 remove { Events.RemoveHandler (MouseWheelEvent, value); }
6631 public event EventHandler Move {
6632 add { Events.AddHandler (MoveEvent, value); }
6633 remove { Events.RemoveHandler (MoveEvent, value); }
6635 public event EventHandler PaddingChanged
6637 add { Events.AddHandler (PaddingChangedEvent, value); }
6638 remove { Events.RemoveHandler (PaddingChangedEvent, value); }
6640 public event PaintEventHandler Paint {
6641 add { Events.AddHandler (PaintEvent, value); }
6642 remove { Events.RemoveHandler (PaintEvent, value); }
6645 public event EventHandler ParentChanged {
6646 add { Events.AddHandler (ParentChangedEvent, value); }
6647 remove { Events.RemoveHandler (ParentChangedEvent, value); }
6650 public event PreviewKeyDownEventHandler PreviewKeyDown {
6651 add { Events.AddHandler (PreviewKeyDownEvent, value); }
6652 remove { Events.RemoveHandler (PreviewKeyDownEvent, value); }
6655 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
6656 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
6657 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
6660 public event QueryContinueDragEventHandler QueryContinueDrag {
6661 add { Events.AddHandler (QueryContinueDragEvent, value); }
6662 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
6665 public event EventHandler RegionChanged {
6666 add { Events.AddHandler (RegionChangedEvent, value); }
6667 remove { Events.RemoveHandler (RegionChangedEvent, value); }
6670 [EditorBrowsable (EditorBrowsableState.Advanced)]
6671 public event EventHandler Resize {
6672 add { Events.AddHandler (ResizeEvent, value); }
6673 remove { Events.RemoveHandler (ResizeEvent, value); }
6676 public event EventHandler RightToLeftChanged {
6677 add { Events.AddHandler (RightToLeftChangedEvent, value); }
6678 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
6681 public event EventHandler SizeChanged {
6682 add { Events.AddHandler (SizeChangedEvent, value); }
6683 remove { Events.RemoveHandler (SizeChangedEvent, value); }
6686 public event EventHandler StyleChanged {
6687 add { Events.AddHandler (StyleChangedEvent, value); }
6688 remove { Events.RemoveHandler (StyleChangedEvent, value); }
6691 public event EventHandler SystemColorsChanged {
6692 add { Events.AddHandler (SystemColorsChangedEvent, value); }
6693 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
6696 public event EventHandler TabIndexChanged {
6697 add { Events.AddHandler (TabIndexChangedEvent, value); }
6698 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
6701 public event EventHandler TabStopChanged {
6702 add { Events.AddHandler (TabStopChangedEvent, value); }
6703 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
6706 public event EventHandler TextChanged {
6707 add { Events.AddHandler (TextChangedEvent, value); }
6708 remove { Events.RemoveHandler (TextChangedEvent, value); }
6711 public event EventHandler Validated {
6712 add { Events.AddHandler (ValidatedEvent, value); }
6713 remove { Events.RemoveHandler (ValidatedEvent, value); }
6716 public event CancelEventHandler Validating {
6717 add { Events.AddHandler (ValidatingEvent, value); }
6718 remove { Events.RemoveHandler (ValidatingEvent, value); }
6721 public event EventHandler VisibleChanged {
6722 add { Events.AddHandler (VisibleChangedEvent, value); }
6723 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
6726 #endregion // Events