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
37 using System.ComponentModel;
38 using System.ComponentModel.Design;
39 using System.ComponentModel.Design.Serialization;
40 using System.Collections;
41 using System.Diagnostics;
43 using System.Drawing.Drawing2D;
44 using System.Reflection;
45 using System.Runtime.InteropServices;
46 using System.Security;
47 using System.Threading;
49 namespace System.Windows.Forms
53 [ClassInterface (ClassInterfaceType.AutoDispatch)]
55 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
56 [DefaultProperty("Text")]
57 [DefaultEvent("Click")]
58 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
59 [ToolboxItemFilter("System.Windows.Forms")]
60 public class Control : Component, ISynchronizeInvoke, IWin32Window
62 , IBindableComponent, IDropTarget
65 #region Local Variables
68 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
69 Rectangle explicit_bounds; // explicitly set bounds
70 internal object creator_thread; // thread that created the control
71 internal ControlNativeWindow window; // object for native window handle
72 private IWindowTarget window_target;
73 string name; // for object naming
76 bool is_created; // true if OnCreateControl has been sent
77 internal bool has_focus; // true if control has focus
78 internal bool is_visible; // true if control is visible
79 internal bool is_entered; // is the mouse inside the control?
80 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
81 bool is_accessible; // true if the control is visible to accessibility applications
82 bool is_captured; // tracks if the control has captured the mouse
83 internal bool is_toplevel; // tracks if the control is a toplevel window
84 bool is_recreating; // tracks if the handle for the control is being recreated
85 bool causes_validation; // tracks if validation is executed on changes
86 bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
87 int tab_index; // position in tab order of siblings
88 bool tab_stop; // is the control a tab stop?
89 bool is_disposed; // has the window already been disposed?
90 Size client_size; // size of the client area (window excluding decorations)
91 Rectangle client_rect; // rectangle with the client area (window excluding decorations)
92 ControlStyles control_style; // rather win32-specific, style bits for control
94 object control_tag; // object that contains data about our control
95 internal int mouse_clicks; // Counter for mouse clicks
96 Cursor cursor; // Cursor for the window
97 internal bool allow_drop; // true if the control accepts droping objects on it
98 Region clip_region; // User-specified clip region for the window
101 internal Color foreground_color; // foreground color for control
102 internal Color background_color; // background color for control
103 Image background_image; // background image for control
104 internal Font font; // font for control
105 string text; // window/title text for control
106 internal BorderStyle border_style; // Border style of control
109 internal enum LayoutType {
113 Layout.LayoutEngine layout_engine;
114 int layout_suspended;
115 bool layout_pending; // true if our parent needs to re-layout us
116 internal AnchorStyles anchor_style; // anchoring requirements for our control
117 internal DockStyle dock_style; // docking requirements for our control
118 LayoutType layout_type;
120 // Please leave the next 2 as internal until DefaultLayout (2.0) is rewritten
121 internal int dist_right; // distance to the right border of the parent
122 internal int dist_bottom; // distance to the bottom border of the parent
124 // to be categorized...
125 ControlCollection child_controls; // our children
126 Control parent; // our parent control
127 AccessibleObject accessibility_object; // object that contains accessibility information about our control
128 BindingContext binding_context;
129 RightToLeft right_to_left; // drawing direction for control
130 ContextMenu context_menu; // Context menu associated with the control
131 internal bool use_compatible_text_rendering;
134 DoubleBuffer backbuffer;
136 // to implement DeviceContext without depending on double buffering
140 ControlBindingsCollection data_bindings;
143 static bool verify_thread_handle;
145 ImageLayout backgroundimage_layout;
149 private ContextMenuStrip context_menu_strip;
150 Point auto_scroll_offset;
153 #endregion // Local Variables
155 #region Private Classes
156 // This helper class allows us to dispatch messages to Control.WndProc
157 internal class ControlNativeWindow : NativeWindow {
158 private Control owner;
160 public ControlNativeWindow(Control control) : base() {
165 public Control Owner {
171 protected override void OnHandleChange()
173 this.owner.WindowTarget.OnHandleChange(this.owner.Handle);
176 static internal Control ControlFromHandle(IntPtr hWnd) {
177 ControlNativeWindow window;
179 window = (ControlNativeWindow)window_collection[hWnd];
180 if (window != null) {
187 static internal Control ControlFromChildHandle (IntPtr handle) {
188 ControlNativeWindow window;
190 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
191 while (hwnd != null) {
192 window = (ControlNativeWindow)window_collection[hwnd.Handle];
193 if (window != null) {
202 protected override void WndProc(ref Message m) {
203 owner.WindowTarget.OnMessage(ref m);
207 private class ControlWindowTarget : IWindowTarget
209 private Control control;
211 public ControlWindowTarget(Control control)
213 this.control = control;
216 public void OnHandleChange(IntPtr newHandle)
220 public void OnMessage(ref Message m)
222 control.WndProc(ref m);
227 #region Public Classes
229 public class ControlAccessibleObject : AccessibleObject {
232 #region ControlAccessibleObject Constructors
233 public ControlAccessibleObject(Control ownerControl)
234 : base (ownerControl)
236 if (ownerControl == null)
237 throw new ArgumentNullException ("owner");
239 handle = ownerControl.Handle;
241 #endregion // ControlAccessibleObject Constructors
243 #region ControlAccessibleObject Public Instance Properties
244 public override string DefaultAction {
246 return base.DefaultAction;
250 public override string Description {
252 return base.Description;
256 public IntPtr Handle {
262 // We don't want to let them set it
266 public override string Help {
272 public override string KeyboardShortcut {
274 return base.KeyboardShortcut;
278 public override string Name {
288 public Control Owner {
294 public override AccessibleObject Parent {
301 public override AccessibleRole Role {
306 #endregion // ControlAccessibleObject Public Instance Properties
308 #region ControlAccessibleObject Public Instance Methods
309 public override int GetHelpTopic(out string FileName) {
310 return base.GetHelpTopic (out FileName);
313 [MonoTODO ("Implement this")]
314 public void NotifyClients(AccessibleEvents accEvent) {
315 throw new NotImplementedException();
318 [MonoTODO ("Implement this")]
319 public void NotifyClients(AccessibleEvents accEvent, int childID) {
322 public override string ToString() {
323 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
326 #endregion // ControlAccessibleObject Public Instance Methods
329 private class DoubleBuffer : IDisposable
331 public Region InvalidRegion;
332 private Stack real_graphics;
333 private object back_buffer;
334 private Control parent;
335 private bool pending_disposal;
337 public DoubleBuffer (Control parent) {
338 this.parent = parent;
339 real_graphics = new Stack ();
340 int width = parent.Width;
341 int height = parent.Height;
343 if (width < 1) width = 1;
344 if (height < 1) height = 1;
346 XplatUI.CreateOffscreenDrawable (parent.Handle, width, height, out back_buffer);
350 public void Blit (PaintEventArgs pe) {
351 Graphics buffered_graphics;
352 buffered_graphics = XplatUI.GetOffscreenGraphics (back_buffer);
353 XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
354 buffered_graphics.Dispose ();
357 public void Start (PaintEventArgs pe) {
358 // We need to get the graphics for every paint.
359 real_graphics.Push(pe.SetGraphics (XplatUI.GetOffscreenGraphics (back_buffer)));
362 public void End (PaintEventArgs pe) {
363 Graphics buffered_graphics;
364 buffered_graphics = pe.SetGraphics ((Graphics) real_graphics.Pop ());
366 if (pending_disposal)
369 XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
370 InvalidRegion.Exclude (pe.ClipRectangle);
372 buffered_graphics.Dispose ();
375 public void Invalidate () {
376 if (InvalidRegion != null)
377 InvalidRegion.Dispose ();
378 InvalidRegion = new Region (parent.ClientRectangle);
381 public void Dispose () {
382 if (real_graphics.Count > 0) {
383 pending_disposal = true;
387 XplatUI.DestroyOffscreenDrawable (back_buffer);
389 if (InvalidRegion != null)
390 InvalidRegion.Dispose ();
391 InvalidRegion = null;
393 GC.SuppressFinalize (this);
396 #region IDisposable Members
397 void IDisposable.Dispose () {
407 [ListBindable (false)]
410 public class ControlCollection : Layout.ArrangedElementCollection, IList, ICollection, ICloneable, IEnumerable {
412 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
413 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
415 #region ControlCollection Local Variables
420 Control[] all_controls;
422 #endregion // ControlCollection Local Variables
424 #region ControlCollection Public Constructor
425 public ControlCollection(Control owner) {
428 this.list=new ArrayList();
433 #region ControlCollection Public Instance Properties
434 int ICollection.Count {
435 get { return Count; }
441 get { return list.Count; }
446 bool IList.IsReadOnly
448 public bool IsReadOnly
452 return list.IsReadOnly;
457 public Control Owner { get { return this.owner; } }
459 public virtual Control this[string key] {
461 int index = IndexOfKey (key);
472 public virtual Control this[int index] {
474 if (index < 0 || index >= list.Count) {
475 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
477 return (Control)list[index];
482 #endregion // ControlCollection Public Instance Properties
484 #region ControlCollection Instance Methods
485 public virtual void Add (Control value) {
489 Form form_value = value as Form;
490 Form form_owner = owner as Form;
491 bool owner_permits_toplevels = (owner is MdiClient) || (form_owner != null && form_owner.IsMdiContainer);
492 bool child_is_toplevel = value.GetTopLevel();
493 bool child_is_mdichild = form_value != null && form_value.IsMdiChild;
495 if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
496 throw new ArgumentException("Cannot add a top level control to a control.", "value");
498 if (child_is_mdichild && form_value.MdiParent != null && form_value.MdiParent != owner && form_value.MdiParent != owner.Parent) {
499 throw new ArgumentException ("Form cannot be added to the Controls collection that has a valid MDI parent.", "value");
502 if (Contains (value)) {
503 owner.PerformLayout();
507 if (value.tab_index == -1) {
513 end = owner.child_controls.Count;
514 for (int i = 0; i < end; i++) {
515 index = owner.child_controls[i].tab_index;
520 value.tab_index = use;
523 if (value.parent != null) {
524 value.parent.Controls.Remove(value);
530 value.ChangeParent(owner);
535 owner.UpdateChildrenZOrder();
536 owner.PerformLayout(value, "Parent");
537 owner.OnControlAdded(new ControlEventArgs(value));
540 internal void AddToList (Control c) {
545 internal virtual void AddImplicit (Control control) {
546 if (impl_list == null)
547 impl_list = new ArrayList ();
549 if (AllContains (control)) {
550 owner.PerformLayout ();
554 if (control.parent != null) {
555 control.parent.Controls.Remove(control);
559 impl_list.Add (control);
561 control.ChangeParent (owner);
562 control.InitLayout ();
564 owner.UpdateChildrenZOrder ();
566 // If we are adding a new control that isn't
567 // visible, don't trigger a layout
568 if (control.VisibleInternal)
569 owner.PerformLayout (control, "Parent");
572 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
574 public virtual void AddRange (Control[] controls) {
575 if (controls == null)
576 throw new ArgumentNullException ("controls");
578 owner.SuspendLayout ();
581 for (int i = 0; i < controls.Length; i++)
584 owner.ResumeLayout ();
588 internal virtual void AddRangeImplicit (Control [] controls) {
589 if (controls == null)
590 throw new ArgumentNullException ("controls");
592 owner.SuspendLayout ();
595 for (int i = 0; i < controls.Length; i++)
596 AddImplicit (controls [i]);
598 owner.ResumeLayout ();
605 public virtual void Clear () {
608 // MS sends remove events in reverse order
609 while (list.Count > 0) {
610 Remove((Control)list[list.Count - 1]);
614 internal virtual void ClearImplicit () {
615 if (impl_list == null)
621 public bool Contains (Control value) {
622 for (int i = list.Count; i > 0; ) {
625 if (list [i] == value) {
626 // Do we need to do anything here?
633 internal bool ImplicitContains (Control value) {
634 if (impl_list == null)
637 for (int i = impl_list.Count; i > 0; ) {
640 if (impl_list [i] == value) {
641 // Do we need to do anything here?
648 internal bool AllContains (Control value) {
649 return Contains (value) || ImplicitContains (value);
653 public virtual bool ContainsKey (string key)
655 return IndexOfKey (key) >= 0;
659 void ICollection.CopyTo (Array array, int index) {
660 CopyTo (array, index);
664 public void CopyTo (Array array, int index) {
665 list.CopyTo(array, index);
668 public override bool Equals (object other) {
669 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
678 // LAMESPEC: MSDN says AE, MS implementation throws ANE
679 public Control[] Find (string key, bool searchAllChildren)
681 if (string.IsNullOrEmpty (key))
682 throw new ArgumentNullException ("key");
684 ArrayList al = new ArrayList ();
686 foreach (Control c in list) {
687 if (c.Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
690 if (searchAllChildren)
691 al.AddRange (c.Controls.Find (key, true));
694 return (Control[])al.ToArray (typeof (Control));
698 public int GetChildIndex(Control child) {
699 return GetChildIndex(child, false);
707 GetChildIndex(Control child, bool throwException) {
710 index=list.IndexOf(child);
712 if (index==-1 && throwException) {
713 throw new ArgumentException("Not a child control", "child");
719 public override IEnumerator
724 return list.GetEnumerator();
727 internal IEnumerator GetAllEnumerator () {
728 Control [] res = GetAllControls ();
729 return res.GetEnumerator ();
732 internal Control [] GetAllControls () {
733 if (all_controls != null)
736 if (impl_list == null) {
737 all_controls = (Control []) list.ToArray (typeof (Control));
741 all_controls = new Control [list.Count + impl_list.Count];
742 impl_list.CopyTo (all_controls);
743 list.CopyTo (all_controls, impl_list.Count);
749 public override int GetHashCode() {
750 return base.GetHashCode();
754 public int IndexOf(Control control) {
755 return list.IndexOf(control);
759 public virtual int IndexOfKey (string key)
761 if (string.IsNullOrEmpty (key))
764 for (int i = 0; i < list.Count; i++)
765 if (((Control)list[i]).Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
772 public virtual void Remove(Control value) {
776 owner.PerformLayout(value, "Parent");
777 owner.OnControlRemoved(new ControlEventArgs(value));
782 ContainerControl container = owner as ContainerControl;
783 if (container != null) {
784 // Inform any container controls about the loss of a child control
785 // so that they can update their active control
786 container.ChildControlRemoved (value);
789 value.ChangeParent(null);
791 owner.UpdateChildrenZOrder();
794 internal virtual void RemoveImplicit (Control control) {
795 if (impl_list != null) {
797 owner.PerformLayout (control, "Parent");
798 owner.OnControlRemoved (new ControlEventArgs (control));
799 impl_list.Remove (control);
801 control.ChangeParent (null);
802 owner.UpdateChildrenZOrder ();
808 public void RemoveAt(int index) {
809 if (index < 0 || index >= list.Count) {
810 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
812 Remove ((Control)list[index]);
816 public virtual void RemoveByKey (string key)
818 int index = IndexOfKey (key);
830 SetChildIndex(Control child, int newIndex) {
832 throw new ArgumentNullException ("child");
836 old_index=list.IndexOf(child);
838 throw new ArgumentException("Not a child control", "child");
841 if (old_index==newIndex) {
846 list.RemoveAt(old_index);
848 if (newIndex>list.Count) {
851 list.Insert(newIndex, child);
853 child.UpdateZOrder();
854 owner.PerformLayout();
856 #endregion // ControlCollection Private Instance Methods
858 #region ControlCollection Interface Properties
859 object IList.this[int index] {
861 if (index<0 || index>=list.Count) {
862 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
868 if (!(value is Control)) {
869 throw new ArgumentException("Object of type Control required", "value");
873 Control ctrl = (Control) value;
876 ctrl.ChangeParent(owner);
880 owner.UpdateChildrenZOrder();
881 owner.PerformLayout(ctrl, "Parent");
885 bool IList.IsFixedSize {
891 bool ICollection.IsSynchronized {
893 return list.IsSynchronized;
897 object ICollection.SyncRoot {
899 return list.SyncRoot;
902 #endregion // ControlCollection Interface Properties
904 #region ControlCollection Interface Methods
905 int IList.Add(object value) {
906 if (!(value is Control)) {
907 throw new ArgumentException("Object of type Control required", "value");
911 throw new ArgumentException("value", "Cannot add null controls");
914 bool owner_permits_toplevels = (owner is MdiClient) || (owner is Form && ((Form)owner).IsMdiContainer);
915 bool child_is_toplevel = ((Control)value).GetTopLevel();
916 bool child_is_mdichild = (value is Form && ((Form)value).IsMdiChild);
918 if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
919 throw new ArgumentException("Cannot add a top level control to a control.", "value");
921 return list.Add(value);
924 bool IList.Contains(object value) {
925 if (!(value is Control)) {
926 throw new ArgumentException("Object of type Control required", "value");
929 return this.Contains((Control) value);
932 int IList.IndexOf(object value) {
933 if (!(value is Control)) {
934 throw new ArgumentException("Object of type Control required", "value");
937 return this.IndexOf((Control) value);
940 void IList.Insert(int index, object value) {
941 if (!(value is Control)) {
942 throw new ArgumentException("Object of type Control required", "value");
945 list.Insert(index, value);
948 void IList.Remove(object value) {
949 if (!(value is Control)) {
950 throw new ArgumentException("Object of type Control required", "value");
956 Object ICloneable.Clone() {
957 ControlCollection clone = new ControlCollection(this.owner);
958 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
961 #endregion // ControlCollection Interface Methods
963 #endregion // ControlCollection Class
965 #region Public Constructors
968 layout_type = LayoutType.Anchor;
969 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
977 layout_pending = false;
979 causes_validation = true;
981 layout_suspended = 0;
985 right_to_left = RightToLeft.Inherit;
986 border_style = BorderStyle.None;
987 background_color = Color.Empty;
991 ime_mode = ImeMode.Inherit;
992 use_compatible_text_rendering = true;
995 backgroundimage_layout = ImageLayout.Tile;
996 use_compatible_text_rendering = Application.use_compatible_text_rendering;
997 padding = new Padding(0);
998 maximum_size = new Size();
999 minimum_size = new Size();
1000 margin = this.DefaultMargin;
1003 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
1004 ControlStyles.Selectable | ControlStyles.StandardClick |
1005 ControlStyles.StandardDoubleClick;
1007 control_style |= ControlStyles.UseTextForAccessibility;
1011 background_image = null;
1012 text = string.Empty;
1013 name = string.Empty;
1015 window_target = new ControlWindowTarget(this);
1016 window = new ControlNativeWindow(this);
1017 child_controls = CreateControlsInstance();
1018 client_size = DefaultSize;
1019 client_rect = new Rectangle (Point.Empty, client_size);
1020 bounds.Size = InternalSizeFromClientSize (client_size);
1021 explicit_bounds = bounds;
1024 public Control (Control parent, string text) : this()
1030 public Control (Control parent, string text, int left, int top, int width, int height) : this()
1036 bounds.Height=height;
1037 SetBounds(left, top, width, height, BoundsSpecified.All);
1041 public Control (string text) : this()
1046 public Control (string text, int left, int top, int width, int height) : this()
1051 bounds.Height=height;
1052 SetBounds(left, top, width, height, BoundsSpecified.All);
1056 private delegate void RemoveDelegate(object c);
1058 protected override void Dispose (bool disposing)
1060 if (!is_disposed && disposing) {
1063 DisposeBackBuffer ();
1069 if (bmp_g != null) {
1074 if (this.InvokeRequired) {
1075 if (Application.MessageLoop && IsHandleCreated) {
1076 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null);
1082 if (parent != null) {
1083 parent.Controls.Remove(this);
1086 Control [] children = child_controls.GetAllControls ();
1087 for (int i=0; i<children.Length; i++) {
1088 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
1089 children[i].Dispose();
1094 base.Dispose(disposing);
1096 #endregion // Public Constructors
1098 #region Internal Properties
1099 // Control is currently selected, like Focused, except maintains state
1100 // when Form loses focus
1101 internal bool InternalSelected {
1103 IContainerControl container;
1105 container = GetContainerControl();
1107 if (container != null && container.ActiveControl == this)
1114 // Mouse is currently within the control's bounds
1115 internal bool Entered {
1116 get { return this.is_entered; }
1119 internal bool VisibleInternal {
1120 get { return is_visible; }
1123 internal LayoutType ControlLayoutType {
1124 get { return layout_type; }
1127 internal BorderStyle InternalBorderStyle {
1129 return border_style;
1133 if (!Enum.IsDefined (typeof (BorderStyle), value))
1134 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
1136 if (border_style != value) {
1137 border_style = value;
1139 if (IsHandleCreated) {
1140 XplatUI.SetBorderStyle (window.Handle, (FormBorderStyle)border_style);
1148 internal Size InternalClientSize { set { this.client_size = value; } }
1149 internal virtual bool ActivateOnShow { get { return true; } }
1150 #endregion // Internal Properties
1152 #region Private & Internal Methods
1155 void IDropTarget.OnDragDrop (DragEventArgs e)
1160 void IDropTarget.OnDragEnter (DragEventArgs e)
1165 void IDropTarget.OnDragLeave (EventArgs e)
1170 void IDropTarget.OnDragOver (DragEventArgs e)
1176 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
1177 return BeginInvokeInternal (method, args, FindControlToInvokeOn ());
1180 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, Control control) {
1181 AsyncMethodResult result;
1182 AsyncMethodData data;
1184 result = new AsyncMethodResult ();
1185 data = new AsyncMethodData ();
1187 data.Handle = control.Handle;
1188 data.Method = method;
1190 data.Result = result;
1193 if (!ExecutionContext.IsFlowSuppressed ()) {
1194 data.Context = ExecutionContext.Capture ();
1197 #if !MWF_ON_MSRUNTIME
1198 if (SecurityManager.SecurityEnabled) {
1199 data.Stack = CompressedStack.GetCompressedStack ();
1204 XplatUI.SendAsyncMethod (data);
1209 internal void PointToClient (ref int x, ref int y) {
1210 XplatUI.ScreenToClient (Handle, ref x, ref y);
1213 internal void PointToScreen (ref int x, ref int y) {
1214 XplatUI.ClientToScreen (Handle, ref x, ref y);
1217 internal bool IsRecreating {
1219 return is_recreating;
1223 internal Graphics DeviceContext {
1225 if (bmp_g == null) {
1226 bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
1227 bmp_g = Graphics.FromImage (bmp);
1233 private Control FindControlToInvokeOn ()
1237 if (p.IsHandleCreated)
1240 } while (p != null);
1242 if (p == null || !p.IsHandleCreated)
1243 throw new InvalidOperationException ("Cannot call Invoke or BeginInvoke on a control until the window handle is created");
1248 private void InvalidateBackBuffer () {
1249 if (backbuffer != null)
1250 backbuffer.Invalidate ();
1253 private DoubleBuffer GetBackBuffer () {
1254 if (backbuffer == null)
1255 backbuffer = new DoubleBuffer (this);
1259 private void DisposeBackBuffer () {
1260 if (backbuffer != null) {
1261 backbuffer.Dispose ();
1266 internal static void SetChildColor(Control parent) {
1269 for (int i=0; i < parent.child_controls.Count; i++) {
1270 child=parent.child_controls[i];
1271 if (child.child_controls.Count>0) {
1272 SetChildColor(child);
1277 internal bool Select(Control control) {
1278 IContainerControl container;
1280 if (control == null) {
1284 container = GetContainerControl();
1285 if (container != null && (Control)container != control) {
1286 container.ActiveControl = control;
1288 else if (control.IsHandleCreated) {
1289 XplatUI.SetFocus(control.window.Handle);
1294 internal virtual void DoDefaultAction() {
1295 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1298 internal static IntPtr MakeParam (int low, int high){
1299 return new IntPtr (high << 16 | low & 0xffff);
1302 internal static int LowOrder (int param) {
1303 return ((int)(short)(param & 0xffff));
1306 internal static int HighOrder (int param) {
1307 return ((int)(short)(param >> 16));
1310 // This method exists so controls overriding OnPaintBackground can have default background painting done
1311 internal virtual void PaintControlBackground (PaintEventArgs pevent) {
1312 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1313 if (parent != null) {
1314 PaintEventArgs parent_pe;
1315 GraphicsState state;
1317 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1319 state = parent_pe.Graphics.Save();
1320 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1321 parent.OnPaintBackground(parent_pe);
1322 parent_pe.Graphics.Restore(state);
1324 state = parent_pe.Graphics.Save();
1325 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1326 parent.OnPaint(parent_pe);
1327 parent_pe.Graphics.Restore(state);
1328 parent_pe.SetGraphics(null);
1332 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1333 if (parent != null) {
1334 PaintEventArgs parent_pe;
1336 GraphicsState state;
1339 hwnd = Hwnd.ObjectFromHandle(Handle);
1342 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1344 region = new Region ();
1346 region.Union(ClientRectangle);
1348 foreach (Rectangle r in hwnd.ClipRectangles) {
1352 state = parent_pe.Graphics.Save();
1353 parent_pe.Graphics.Clip = region;
1355 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1356 parent.OnPaintBackground(parent_pe);
1357 parent_pe.Graphics.Restore(state);
1359 state = parent_pe.Graphics.Save();
1360 parent_pe.Graphics.Clip = region;
1362 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1363 parent.OnPaint(parent_pe);
1364 parent_pe.Graphics.Restore(state);
1365 parent_pe.SetGraphics(null);
1367 region.Intersect(clip_region);
1368 pevent.Graphics.Clip = region;
1373 if (background_image == null) {
1374 Rectangle paintRect = new Rectangle(pevent.ClipRectangle.X, pevent.ClipRectangle.Y, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height);
1375 Brush pen = ThemeEngine.Current.ResPool.GetSolidBrush(BackColor);
1376 pevent.Graphics.FillRectangle(pen, paintRect);
1380 DrawBackgroundImage (pevent.Graphics);
1383 void DrawBackgroundImage (Graphics g) {
1385 Rectangle drawing_rectangle = new Rectangle ();
1386 g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
1388 switch (backgroundimage_layout)
1390 case ImageLayout.Tile:
1391 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1392 g.FillRectangle (b, ClientRectangle);
1395 case ImageLayout.Center:
1396 drawing_rectangle.Location = new Point (ClientSize.Width / 2 - background_image.Width / 2, ClientSize.Height / 2 - background_image.Height / 2);
1397 drawing_rectangle.Size = background_image.Size;
1399 case ImageLayout.None:
1400 drawing_rectangle.Location = Point.Empty;
1401 drawing_rectangle.Size = background_image.Size;
1403 case ImageLayout.Stretch:
1404 drawing_rectangle = ClientRectangle;
1406 case ImageLayout.Zoom:
1407 drawing_rectangle = ClientRectangle;
1408 if ((float)background_image.Width / (float)background_image.Height < (float)drawing_rectangle.Width / (float) drawing_rectangle.Height) {
1409 drawing_rectangle.Width = (int) (background_image.Width * ((float)drawing_rectangle.Height / (float)background_image.Height));
1410 drawing_rectangle.X = (ClientRectangle.Width - drawing_rectangle.Width) / 2;
1412 drawing_rectangle.Height = (int) (background_image.Height * ((float)drawing_rectangle.Width / (float)background_image.Width));
1413 drawing_rectangle.Y = (ClientRectangle.Height - drawing_rectangle.Height) / 2;
1420 g.DrawImage (background_image, drawing_rectangle);
1423 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1424 g.FillRectangle (b, ClientRectangle);
1429 internal virtual void DndEnter (DragEventArgs e) {
1435 internal virtual void DndOver (DragEventArgs e) {
1441 internal virtual void DndDrop (DragEventArgs e) {
1444 } catch (Exception exc) {
1445 Console.Error.WriteLine ("MWF: Exception while dropping:");
1446 Console.Error.WriteLine (exc);
1450 internal virtual void DndLeave (EventArgs e) {
1456 internal virtual void DndFeedback(GiveFeedbackEventArgs e) {
1462 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e) {
1464 OnQueryContinueDrag(e);
1468 internal static MouseButtons FromParamToMouseButtons (int param) {
1469 MouseButtons buttons = MouseButtons.None;
1471 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1472 buttons |= MouseButtons.Left;
1474 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1475 buttons |= MouseButtons.Middle;
1477 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1478 buttons |= MouseButtons.Right;
1484 internal virtual void FireEnter () {
1485 OnEnter (EventArgs.Empty);
1488 internal virtual void FireLeave () {
1489 OnLeave (EventArgs.Empty);
1492 internal virtual void FireValidating (CancelEventArgs ce) {
1496 internal virtual void FireValidated () {
1497 OnValidated (EventArgs.Empty);
1500 internal virtual bool ProcessControlMnemonic(char charCode) {
1501 return ProcessMnemonic(charCode);
1504 private static Control FindFlatForward(Control container, Control start) {
1510 end = container.child_controls.Count;
1512 if (start != null) {
1513 index = start.tab_index;
1518 for (int i = 0, pos = -1; i < end; i++) {
1519 if (start == container.child_controls[i]) {
1524 if (found == null) {
1525 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1526 found = container.child_controls[i];
1528 } else if (found.tab_index > container.child_controls[i].tab_index) {
1529 if (container.child_controls[i].tab_index > index) {
1530 found = container.child_controls[i];
1537 private static Control FindControlForward(Control container, Control start) {
1542 if (start == null) {
1543 return FindFlatForward(container, start);
1546 if (start.child_controls != null && start.child_controls.Count > 0 &&
1547 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1548 return FindControlForward(start, null);
1551 while (start != container) {
1552 found = FindFlatForward(start.parent, start);
1553 if (found != null) {
1556 start = start.parent;
1562 private static Control FindFlatBackward(Control container, Control start) {
1568 end = container.child_controls.Count;
1570 if (start != null) {
1571 index = start.tab_index;
1573 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1575 for (int i = 0; i < end; i++) {
1576 if (container.child_controls[i].tab_index > index) {
1577 index = container.child_controls[i].tab_index;
1585 for (int i = end - 1; i >= 0; i--) {
1586 if (start == container.child_controls[i]) {
1591 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1592 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1593 found = container.child_controls[i];
1600 private static Control FindControlBackward(Control container, Control start) {
1602 Control found = null;
1604 if (start == null) {
1605 found = FindFlatBackward(container, start);
1607 else if (start != container) {
1608 if (start.parent != null) {
1609 found = FindFlatBackward(start.parent, start);
1611 if (found == null) {
1612 if (start.parent != container)
1613 return start.parent;
1619 if (found == null || start.parent == null)
1622 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1623 found.child_controls != null && found.child_controls.Count > 0)) {
1624 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1625 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1626 found = FindFlatBackward(found, null);
1636 if (start != null) {
1637 found = FindFlatBackward(start.parent, start);
1638 if (found == null) {
1639 if (start.parent != container) {
1640 return start.parent;
1644 if (found == null) {
1645 found = FindFlatBackward(container, start);
1648 if (container != start) {
1649 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1650 found = FindControlBackward(found, null);
1651 if (found != null) {
1660 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1661 if (GetStyle(ControlStyles.StandardClick)) {
1662 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1664 OnDoubleClick(EventArgs.Empty);
1666 OnClick(EventArgs.Empty);
1669 OnMouseDoubleClick (me);
1678 internal void CaptureWithConfine (Control ConfineWindow) {
1679 if (this.IsHandleCreated && !is_captured) {
1681 XplatUI.GrabWindow (this.window.Handle, ConfineWindow.Handle);
1685 private void CheckDataBindings () {
1686 if (data_bindings == null)
1689 BindingContext binding_context = BindingContext;
1690 foreach (Binding binding in data_bindings) {
1691 binding.Check (binding_context);
1695 private void ChangeParent(Control new_parent) {
1699 Color pre_fore_color;
1700 Color pre_back_color;
1701 RightToLeft pre_rtl;
1703 // These properties are inherited from our parent
1704 // Get them pre parent-change and then send events
1705 // if they are changed after we have our new parent
1706 pre_enabled = Enabled;
1707 pre_visible = Visible;
1709 pre_fore_color = ForeColor;
1710 pre_back_color = BackColor;
1711 pre_rtl = RightToLeft;
1712 // MS doesn't seem to send a CursorChangedEvent
1714 parent = new_parent;
1716 if (IsHandleCreated) {
1717 XplatUI.SetParent(Handle,
1718 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1721 ((Form)this).ChangingParent (new_parent);
1724 OnParentChanged(EventArgs.Empty);
1726 if (pre_enabled != Enabled) {
1727 OnEnabledChanged(EventArgs.Empty);
1730 if (pre_visible != Visible) {
1731 OnVisibleChanged(EventArgs.Empty);
1734 if (pre_font != Font) {
1735 OnFontChanged(EventArgs.Empty);
1738 if (pre_fore_color != ForeColor) {
1739 OnForeColorChanged(EventArgs.Empty);
1742 if (pre_back_color != BackColor) {
1743 OnBackColorChanged(EventArgs.Empty);
1746 if (pre_rtl != RightToLeft) {
1747 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1748 // because when RTL changes they have to recreate the win32 control
1749 // We don't really need that (until someone runs into compatibility issues)
1750 OnRightToLeftChanged(EventArgs.Empty);
1753 if ((new_parent != null) && new_parent.Created && is_visible && !Created) {
1757 if ((binding_context == null) && Created) {
1758 OnBindingContextChanged(EventArgs.Empty);
1762 // Sometimes we need to do this calculation without it being virtual (constructor)
1763 internal Size InternalSizeFromClientSize (Size clientSize)
1765 Rectangle ClientRect;
1766 Rectangle WindowRect;
1769 ClientRect = new Rectangle (0, 0, clientSize.Width, clientSize.Height);
1770 cp = this.CreateParams;
1772 if (XplatUI.CalculateWindowRect (ref ClientRect, cp, null, out WindowRect))
1773 return new Size (WindowRect.Width, WindowRect.Height);
1778 internal CreateParams GetCreateParams ()
1780 return CreateParams;
1783 private void UpdateDistances() {
1784 if (parent != null) {
1785 if (bounds.Width >= 0)
1786 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1787 if (bounds.Height >= 0)
1788 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1792 private Cursor GetAvailableCursor ()
1794 if (Cursor != null && Enabled) {
1798 if (Parent != null) {
1799 return Parent.GetAvailableCursor ();
1802 return Cursors.Default;
1805 private void UpdateCursor ()
1807 if (!IsHandleCreated)
1811 XplatUI.SetCursor (window.Handle, GetAvailableCursor ().handle);
1815 Point pt = PointToClient (Cursor.Position);
1817 if ((!bounds.Contains (pt) && !Capture) || (GetChildAtPoint (pt) != null))
1820 if (cursor != null) {
1821 XplatUI.SetCursor (window.Handle, cursor.handle);
1823 XplatUI.SetCursor (window.Handle, GetAvailableCursor ().handle);
1827 private bool UseDoubleBuffering {
1829 if (!ThemeEngine.Current.DoubleBufferingSupported)
1836 return (control_style & ControlStyles.DoubleBuffer) != 0;
1839 #endregion // Private & Internal Methods
1841 #region Public Static Properties
1842 public static Color DefaultBackColor {
1844 return ThemeEngine.Current.DefaultControlBackColor;
1848 public static Font DefaultFont {
1850 return ThemeEngine.Current.DefaultFont;
1854 public static Color DefaultForeColor {
1856 return ThemeEngine.Current.DefaultControlForeColor;
1860 public static Keys ModifierKeys {
1862 return XplatUI.State.ModifierKeys;
1866 public static MouseButtons MouseButtons {
1868 return XplatUI.State.MouseButtons;
1872 public static Point MousePosition {
1874 return Cursor.Position;
1879 [EditorBrowsable (EditorBrowsableState.Advanced)]
1880 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1883 public static bool CheckForIllegalCrossThreadCalls
1886 return verify_thread_handle;
1890 verify_thread_handle = value;
1894 #endregion // Public Static Properties
1896 #region Public Instance Properties
1897 [EditorBrowsable(EditorBrowsableState.Advanced)]
1899 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1900 public AccessibleObject AccessibilityObject {
1902 if (accessibility_object==null) {
1903 accessibility_object=CreateAccessibilityInstance();
1905 return accessibility_object;
1909 [EditorBrowsable(EditorBrowsableState.Advanced)]
1911 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1912 public string AccessibleDefaultActionDescription {
1914 if (accessibility_object != null)
1915 return accessibility_object.default_action;
1921 if (accessibility_object != null)
1922 accessibility_object.default_action = value;
1927 [DefaultValue(null)]
1928 [MWFCategory("Accessibility")]
1929 public string AccessibleDescription {
1931 if (accessibility_object != null)
1932 return accessibility_object.description;
1938 if (accessibility_object != null)
1939 accessibility_object.description = value;
1944 [DefaultValue(null)]
1945 [MWFCategory("Accessibility")]
1946 public string AccessibleName {
1948 if (accessibility_object != null)
1949 return accessibility_object.Name;
1955 if (accessibility_object != null)
1956 accessibility_object.Name = value;
1960 [DefaultValue(AccessibleRole.Default)]
1961 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1962 public AccessibleRole AccessibleRole {
1964 if (accessibility_object != null)
1965 return accessibility_object.role;
1967 return AccessibleRole.Default;
1971 if (accessibility_object != null)
1972 accessibility_object.role = value;
1976 [DefaultValue(false)]
1977 [MWFCategory("Behavior")]
1978 public virtual bool AllowDrop {
1984 if (allow_drop == value)
1987 if (IsHandleCreated) {
1989 XplatUI.SetAllowDrop (Handle, value);
1995 [RefreshProperties(RefreshProperties.Repaint)]
1996 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1997 [MWFCategory("Layout")]
1998 public virtual AnchorStyles Anchor {
2000 return anchor_style;
2004 layout_type = LayoutType.Anchor;
2006 if (anchor_style == value)
2010 dock_style = DockStyle.None;
2015 parent.PerformLayout(this, "Anchor");
2021 public virtual Point AutoScrollOffset {
2023 return auto_scroll_offset;
2027 this.auto_scroll_offset = value;
2031 // XXX: Implement me!
2034 [RefreshProperties (RefreshProperties.All)]
2035 [Localizable (true)]
2036 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
2038 [EditorBrowsable (EditorBrowsableState.Never)]
2039 [DefaultValue (false)]
2040 [MonoTODO("This method currently does nothing")]
2041 public virtual bool AutoSize {
2042 get { return auto_size; }
2044 if (this.auto_size != value) {
2046 OnAutoSizeChanged (EventArgs.Empty);
2052 [AmbientValue ("{Width=0, Height=0}")]
2054 [AmbientValue (typeof(Size), "0, 0")]
2056 public virtual Size MaximumSize {
2058 return maximum_size;
2061 if (maximum_size != value) {
2062 maximum_size = value;
2063 Size = PreferredSize;
2068 public virtual Size MinimumSize {
2070 return minimum_size;
2073 if (minimum_size != value) {
2074 minimum_size = value;
2075 Size = PreferredSize;
2082 [MWFCategory("Appearance")]
2083 public virtual Color BackColor {
2085 if (background_color.IsEmpty) {
2087 Color pcolor = parent.BackColor;
2088 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
2091 return DefaultBackColor;
2093 return background_color;
2097 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
2098 throw new ArgumentException("Transparent background colors are not supported on this control");
2101 if (background_color != value) {
2102 background_color=value;
2103 SetChildColor(this);
2104 OnBackColorChanged(EventArgs.Empty);
2111 [DefaultValue(null)]
2112 [MWFCategory("Appearance")]
2113 public virtual Image BackgroundImage {
2115 return background_image;
2119 if (background_image!=value) {
2120 background_image=value;
2121 OnBackgroundImageChanged(EventArgs.Empty);
2128 [DefaultValue (ImageLayout.Tile)]
2129 [Localizable (true)]
2130 public virtual ImageLayout BackgroundImageLayout {
2132 return backgroundimage_layout;
2135 if (Array.IndexOf (Enum.GetValues (typeof (ImageLayout)), value) == -1)
2136 throw new InvalidEnumArgumentException ("value", (int) value, typeof(ImageLayout));
2138 if (value != backgroundimage_layout) {
2139 backgroundimage_layout = value;
2141 OnBackgroundImageLayoutChanged (EventArgs.Empty);
2147 [EditorBrowsable(EditorBrowsableState.Advanced)]
2149 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2150 public virtual BindingContext BindingContext {
2152 if (binding_context != null)
2153 return binding_context;
2156 binding_context = Parent.BindingContext;
2157 return binding_context;
2160 if (binding_context != value) {
2161 binding_context = value;
2162 OnBindingContextChanged(EventArgs.Empty);
2167 [EditorBrowsable(EditorBrowsableState.Advanced)]
2169 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2172 return bounds.Y+bounds.Height;
2176 [EditorBrowsable(EditorBrowsableState.Advanced)]
2178 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2179 public Rectangle Bounds {
2185 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
2189 [EditorBrowsable(EditorBrowsableState.Advanced)]
2191 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2192 public bool CanFocus {
2194 if (IsHandleCreated && Visible && Enabled) {
2201 [EditorBrowsable(EditorBrowsableState.Advanced)]
2203 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2204 public bool CanSelect {
2208 if (!GetStyle(ControlStyles.Selectable)) {
2213 while (parent != null) {
2214 if (!parent.is_visible || !parent.is_enabled) {
2218 parent = parent.parent;
2224 internal virtual bool InternalCapture {
2234 [EditorBrowsable(EditorBrowsableState.Advanced)]
2236 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2237 public bool Capture {
2239 return this.is_captured;
2243 // Call OnMouseCaptureChanged when we get WM_CAPTURECHANGED.
2244 if (value != is_captured) {
2247 XplatUI.GrabWindow(Handle, IntPtr.Zero);
2249 if (IsHandleCreated)
2250 XplatUI.UngrabWindow(Handle);
2251 is_captured = false;
2257 [DefaultValue(true)]
2258 [MWFCategory("Focus")]
2259 public bool CausesValidation {
2261 return this.causes_validation;
2265 if (this.causes_validation != value) {
2266 causes_validation = value;
2267 OnCausesValidationChanged(EventArgs.Empty);
2272 [EditorBrowsable(EditorBrowsableState.Advanced)]
2274 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2275 public Rectangle ClientRectangle {
2277 client_rect.Width = client_size.Width;
2278 client_rect.Height = client_size.Height;
2283 [EditorBrowsable(EditorBrowsableState.Advanced)]
2285 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2286 public Size ClientSize {
2289 if ((this is Form) && (((Form)this).form_parent_window != null)) {
2290 return ((Form)this).form_parent_window.ClientSize;
2298 this.SetClientSizeCore(value.Width, value.Height);
2300 this.OnClientSizeChanged (EventArgs.Empty);
2305 [EditorBrowsable(EditorBrowsableState.Advanced)]
2307 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2308 [DescriptionAttribute("ControlCompanyNameDescr")]
2309 public String CompanyName {
2311 return "Mono Project, Novell, Inc.";
2315 [EditorBrowsable(EditorBrowsableState.Advanced)]
2317 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2318 public bool ContainsFocus {
2320 IntPtr focused_window;
2322 focused_window = XplatUI.GetFocus();
2323 if (IsHandleCreated) {
2324 if (focused_window == Handle) {
2328 for (int i=0; i < child_controls.Count; i++) {
2329 if (child_controls[i].ContainsFocus) {
2340 [DefaultValue(null)]
2341 [MWFCategory("Behavior")]
2342 public virtual ContextMenu ContextMenu {
2344 return GetContextMenuInternal ();
2348 if (context_menu != value) {
2349 context_menu = value;
2350 OnContextMenuChanged(EventArgs.Empty);
2355 internal virtual ContextMenu GetContextMenuInternal () {
2356 return context_menu;
2360 [DefaultValue (null)]
2361 public virtual ContextMenuStrip ContextMenuStrip {
2362 get { return this.context_menu_strip; }
2364 if (this.context_menu_strip != value) {
2365 this.context_menu_strip = value;
2366 OnContextMenuStripChanged (EventArgs.Empty);
2373 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2374 public ControlCollection Controls {
2376 return this.child_controls;
2380 [EditorBrowsable(EditorBrowsableState.Advanced)]
2382 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2383 public bool Created {
2385 return (!is_disposed && is_created);
2389 [AmbientValue(null)]
2390 [MWFCategory("Appearance")]
2391 public virtual Cursor Cursor {
2393 if (cursor != null) {
2397 if (parent != null) {
2398 return parent.Cursor;
2401 return Cursors.Default;
2405 if (cursor == value) {
2412 OnCursorChanged (EventArgs.Empty);
2417 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2418 [ParenthesizePropertyName(true)]
2419 [RefreshProperties(RefreshProperties.All)]
2420 [MWFCategory("Data")]
2421 public ControlBindingsCollection DataBindings {
2423 if (data_bindings == null)
2424 data_bindings = new ControlBindingsCollection (this);
2425 return data_bindings;
2429 [EditorBrowsable(EditorBrowsableState.Advanced)]
2431 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2432 public virtual Rectangle DisplayRectangle {
2434 return ClientRectangle;
2438 [EditorBrowsable(EditorBrowsableState.Advanced)]
2440 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2441 public bool Disposing {
2448 [RefreshProperties(RefreshProperties.Repaint)]
2449 [DefaultValue(DockStyle.None)]
2450 [MWFCategory("Layout")]
2451 public virtual DockStyle Dock {
2457 layout_type = LayoutType.Dock;
2459 if (dock_style == value) {
2463 if (!Enum.IsDefined (typeof (DockStyle), value)) {
2464 throw new InvalidEnumArgumentException ("value", (int) value,
2465 typeof (DockStyle));
2469 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
2471 if (dock_style == DockStyle.None) {
2472 Bounds = explicit_bounds;
2475 if (parent != null) {
2476 parent.PerformLayout(this, "Dock");
2479 OnDockChanged(EventArgs.Empty);
2484 protected virtual bool DoubleBuffered {
2486 return (control_style & ControlStyles.OptimizedDoubleBuffer) != 0;
2490 if (value == DoubleBuffered)
2493 SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
2495 SetStyle (ControlStyles.OptimizedDoubleBuffer, false);
2504 [MWFCategory("Behavior")]
2505 public bool Enabled {
2511 if (parent != null) {
2512 return parent.Enabled;
2519 if (this.is_enabled == value)
2522 bool old_value = is_enabled;
2529 if (old_value != value && !value && this.has_focus)
2530 SelectNextControl(this, true, true, true, true);
2532 OnEnabledChanged (EventArgs.Empty);
2536 [EditorBrowsable(EditorBrowsableState.Advanced)]
2538 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2539 public virtual bool Focused {
2541 return this.has_focus;
2546 [AmbientValue(null)]
2548 [MWFCategory("Appearance")]
2549 public virtual Font Font {
2555 if (Parent != null && Parent.Font != null) {
2562 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2564 if (font != null && font.Equals (value)) {
2570 OnFontChanged (EventArgs.Empty);
2576 [MWFCategory("Appearance")]
2577 public virtual Color ForeColor {
2579 if (foreground_color.IsEmpty) {
2581 return parent.ForeColor;
2583 return DefaultForeColor;
2585 return foreground_color;
2589 if (foreground_color != value) {
2590 foreground_color=value;
2592 OnForeColorChanged(EventArgs.Empty);
2599 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2600 public IntPtr Handle { // IWin32Window
2603 if (verify_thread_handle) {
2604 if (this.InvokeRequired) {
2605 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2609 if (!IsHandleCreated) {
2612 return window.Handle;
2616 [EditorBrowsable(EditorBrowsableState.Advanced)]
2618 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2619 public bool HasChildren {
2621 if (this.child_controls.Count>0) {
2628 [EditorBrowsable(EditorBrowsableState.Always)]
2630 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2633 return this.bounds.Height;
2637 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2641 [AmbientValue(ImeMode.Inherit)]
2643 [MWFCategory("Behavior")]
2644 public ImeMode ImeMode {
2646 if (ime_mode == ImeMode.Inherit) {
2648 return parent.ImeMode;
2650 return ImeMode.NoControl; // default value
2656 if (ime_mode != value) {
2659 OnImeModeChanged(EventArgs.Empty);
2664 [EditorBrowsable(EditorBrowsableState.Advanced)]
2666 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2667 public bool InvokeRequired { // ISynchronizeInvoke
2669 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2676 [EditorBrowsable(EditorBrowsableState.Advanced)]
2678 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2679 public bool IsAccessible {
2681 return is_accessible;
2685 is_accessible = value;
2689 [EditorBrowsable(EditorBrowsableState.Advanced)]
2691 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2692 public bool IsDisposed {
2694 return this.is_disposed;
2698 [EditorBrowsable(EditorBrowsableState.Advanced)]
2700 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2701 public bool IsHandleCreated {
2703 if (window == null || window.Handle == IntPtr.Zero)
2706 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2707 if (hwnd != null && hwnd.zombie)
2715 [EditorBrowsable (EditorBrowsableState.Advanced)]
2719 Layout.LayoutEngine LayoutEngine {
2721 if (layout_engine == null)
2722 layout_engine = new Layout.DefaultLayout ();
2723 return layout_engine;
2727 [EditorBrowsable(EditorBrowsableState.Always)]
2729 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2732 return this.bounds.X;
2736 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2741 [MWFCategory("Layout")]
2742 public Point Location {
2744 return new Point(bounds.X, bounds.Y);
2748 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2753 [Localizable (true)]
2754 public Padding Margin {
2755 get { return this.margin; }
2757 if (this.margin != value) {
2758 this.margin = value;
2759 OnMarginChanged (EventArgs.Empty);
2766 public string Name {
2778 public Padding Padding {
2784 if (padding != value) {
2786 OnPaddingChanged (EventArgs.Empty);
2794 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2795 public Control Parent {
2801 if (value == this) {
2802 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2805 if (parent!=value) {
2807 parent.Controls.Remove(this);
2812 value.Controls.Add(this);
2819 public Size PreferredSize {
2820 get { return this.GetPreferredSize (Size.Empty); }
2824 [EditorBrowsable(EditorBrowsableState.Advanced)]
2826 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2827 public string ProductName {
2829 Type t = typeof (AssemblyProductAttribute);
2830 Assembly assembly = GetType().Module.Assembly;
2831 object [] attrs = assembly.GetCustomAttributes (t, false);
2832 AssemblyProductAttribute a = null;
2833 // On MS we get a NullRefException if product attribute is not
2835 if (attrs != null && attrs.Length > 0)
2836 a = (AssemblyProductAttribute) attrs [0];
2838 return GetType ().Namespace;
2844 [EditorBrowsable(EditorBrowsableState.Advanced)]
2846 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2847 public string ProductVersion {
2849 Type t = typeof (AssemblyVersionAttribute);
2850 Assembly assembly = GetType().Module.Assembly;
2851 object [] attrs = assembly.GetCustomAttributes (t, false);
2852 if (attrs == null || attrs.Length < 1)
2854 return ((AssemblyVersionAttribute)attrs [0]).Version;
2858 [EditorBrowsable(EditorBrowsableState.Advanced)]
2860 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2861 public bool RecreatingHandle {
2863 return is_recreating;
2867 [EditorBrowsable(EditorBrowsableState.Advanced)]
2869 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2870 public Region Region {
2876 if (clip_region != value) {
2877 if (value != null && IsHandleCreated)
2878 XplatUI.SetClipRegion(Handle, value);
2880 clip_region = value;
2882 OnRegionChanged (EventArgs.Empty);
2888 [EditorBrowsable(EditorBrowsableState.Advanced)]
2890 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2893 return this.bounds.X+this.bounds.Width;
2897 [AmbientValue(RightToLeft.Inherit)]
2899 [MWFCategory("Appearance")]
2900 public virtual RightToLeft RightToLeft {
2902 if (right_to_left == RightToLeft.Inherit) {
2904 return parent.RightToLeft;
2906 return RightToLeft.No; // default value
2908 return right_to_left;
2912 if (value != right_to_left) {
2913 right_to_left = value;
2914 OnRightToLeftChanged(EventArgs.Empty);
2920 [EditorBrowsable(EditorBrowsableState.Advanced)]
2921 public override ISite Site {
2929 if (value != null) {
2930 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2932 BackColor = ap.BackColor;
2933 ForeColor = ap.ForeColor;
2942 [MWFCategory("Layout")]
2945 return new Size(Width, Height);
2949 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2954 [MergableProperty(false)]
2955 [MWFCategory("Behavior")]
2956 public int TabIndex {
2958 if (tab_index != -1) {
2965 if (tab_index != value) {
2967 OnTabIndexChanged(EventArgs.Empty);
2973 [DefaultValue(true)]
2974 [MWFCategory("Behavior")]
2975 public bool TabStop {
2981 if (tab_stop != value) {
2983 OnTabStopChanged(EventArgs.Empty);
2988 [Localizable(false)]
2990 [TypeConverter(typeof(StringConverter))]
2991 [DefaultValue(null)]
2992 [MWFCategory("Data")]
2999 control_tag = value;
3005 [BindableAttribute(true)]
3006 [MWFCategory("Appearance")]
3007 public virtual string Text {
3009 // Our implementation ignores ControlStyles.CacheText - we always cache
3014 if (value == null) {
3015 value = String.Empty;
3020 if (IsHandleCreated) {
3021 /* we need to call .SetWindowStyle here instead of just .Text
3022 because the presence/absence of Text (== "" or not) can cause
3023 other window style things to appear/disappear */
3024 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3025 XplatUI.Text(Handle, text);
3027 OnTextChanged (EventArgs.Empty);
3032 [EditorBrowsable(EditorBrowsableState.Always)]
3034 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3037 return this.bounds.Y;
3041 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
3045 [EditorBrowsable(EditorBrowsableState.Advanced)]
3047 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3048 public Control TopLevelControl {
3052 while (p.parent != null) {
3056 return p is Form ? p : null;
3061 [MWFCategory("Behavior")]
3062 public bool Visible {
3066 } else if (parent != null) {
3067 return parent.Visible;
3074 SetVisibleCore(value);
3078 [EditorBrowsable(EditorBrowsableState.Always)]
3080 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3083 return this.bounds.Width;
3087 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
3091 [EditorBrowsable(EditorBrowsableState.Never)]
3093 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3094 public IWindowTarget WindowTarget {
3095 get { return window_target; }
3096 set { window_target = value; }
3098 #endregion // Public Instance Properties
3100 #region Protected Instance Properties
3101 protected virtual CreateParams CreateParams {
3103 CreateParams create_params = new CreateParams();
3106 create_params.Caption = Text;
3109 create_params.Caption = text;
3113 create_params.X = Left;
3116 create_params.X = this.bounds.X;
3120 create_params.Y = Top;
3123 create_params.Y = this.bounds.Y;
3127 create_params.Width = Width;
3130 create_params.Width = this.bounds.Width;
3134 create_params.Height = Height;
3137 create_params.Height = this.bounds.Height;
3141 create_params.ClassName = XplatUI.DefaultClassName;
3142 create_params.ClassStyle = (int)(XplatUIWin32.ClassStyle.CS_OWNDC | XplatUIWin32.ClassStyle.CS_DBLCLKS);
3143 create_params.ExStyle = 0;
3144 create_params.Param = 0;
3147 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
3150 if ((parent!=null) && (parent.IsHandleCreated)) {
3151 create_params.Parent = parent.Handle;
3154 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
3157 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
3161 create_params.Style |= (int)WindowStyles.WS_DISABLED;
3164 switch (border_style) {
3165 case BorderStyle.FixedSingle:
3166 create_params.Style |= (int) WindowStyles.WS_BORDER;
3168 case BorderStyle.Fixed3D:
3169 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
3173 create_params.control = this;
3175 return create_params;
3180 protected virtual Cursor DefaultCursor { get { return Cursors.Default; } }
3183 protected virtual ImeMode DefaultImeMode {
3185 return ImeMode.Inherit;
3190 protected virtual Padding DefaultMargin {
3191 get { return new Padding (3); }
3194 protected virtual Size DefaultMaximumSize { get { return new Size (); } }
3195 protected virtual Size DefaultMinimumSize { get { return new Size (); } }
3196 protected virtual Padding DefaultPadding { get { return new Padding (); } }
3199 protected virtual Size DefaultSize {
3201 return new Size(0, 0);
3205 protected int FontHeight {
3217 protected bool RenderRightToLeft {
3219 return (this.right_to_left == RightToLeft.Yes);
3223 protected bool ResizeRedraw {
3225 return GetStyle(ControlStyles.ResizeRedraw);
3229 SetStyle(ControlStyles.ResizeRedraw, value);
3233 [EditorBrowsable(EditorBrowsableState.Advanced)]
3235 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3236 protected virtual bool ShowFocusCues {
3242 [EditorBrowsable(EditorBrowsableState.Advanced)]
3244 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3248 protected bool ShowKeyboardCues {
3253 #endregion // Protected Instance Properties
3255 #region Public Static Methods
3256 [EditorBrowsable(EditorBrowsableState.Advanced)]
3257 public static Control FromChildHandle(IntPtr handle) {
3258 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
3261 [EditorBrowsable(EditorBrowsableState.Advanced)]
3262 public static Control FromHandle(IntPtr handle) {
3263 return Control.ControlNativeWindow.ControlFromHandle(handle);
3266 public static bool IsMnemonic(char charCode, string text) {
3269 amp = text.IndexOf('&');
3272 if (amp + 1 < text.Length) {
3273 if (text[amp + 1] != '&') {
3274 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
3284 #region Protected Static Methods
3285 [EditorBrowsable(EditorBrowsableState.Advanced)]
3286 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
3289 c = Control.FromHandle(hWnd);
3299 #region Public Instance Methods
3300 [EditorBrowsable(EditorBrowsableState.Advanced)]
3301 public IAsyncResult BeginInvoke(Delegate method) {
3302 object [] prms = null;
3303 if (method is EventHandler)
3304 prms = new object [] { this, EventArgs.Empty };
3305 return BeginInvokeInternal(method, prms);
3308 [EditorBrowsable(EditorBrowsableState.Advanced)]
3310 public IAsyncResult BeginInvoke (Delegate method, params object[] args)
3312 public IAsyncResult BeginInvoke (Delegate method, object[] args)
3315 return BeginInvokeInternal (method, args);
3318 public void BringToFront() {
3319 if (parent != null) {
3320 parent.child_controls.SetChildIndex(this, 0);
3322 else if (IsHandleCreated) {
3323 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
3327 public bool Contains(Control ctl) {
3328 while (ctl != null) {
3337 public void CreateControl () {
3339 throw new ObjectDisposedException(GetType().FullName.ToString());
3349 if (!IsHandleCreated) {
3356 if (binding_context == null) { // seem to be sent whenever it's null?
3357 OnBindingContextChanged(EventArgs.Empty);
3364 public Graphics CreateGraphics() {
3365 if (!IsHandleCreated) {
3366 this.CreateHandle();
3368 return Graphics.FromHwnd(this.window.Handle);
3371 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
3372 if (IsHandleCreated)
3373 return XplatUI.StartDrag(Handle, data, allowedEffects);
3375 return DragDropEffects.None;
3378 [EditorBrowsable(EditorBrowsableState.Advanced)]
3379 public object EndInvoke (IAsyncResult async_result) {
3380 AsyncMethodResult result = (AsyncMethodResult) async_result;
3381 return result.EndInvoke ();
3384 public Form FindForm() {
3397 [EditorBrowsable (EditorBrowsableState.Advanced)]
3399 public bool Focus() {
3400 return FocusInternal (false);
3403 internal virtual bool FocusInternal (bool skip_check) {
3404 if (skip_check || (CanFocus && IsHandleCreated && !has_focus && !is_focusing)) {
3407 is_focusing = false;
3412 public Control GetChildAtPoint(Point pt) {
3413 // MS's version causes the handle to be created. The stack trace shows that get_Handle is called here, but
3414 // we'll just call CreateHandle instead.
3415 if (!IsHandleCreated)
3418 // Microsoft's version of this function doesn't seem to work, so I can't check
3419 // if we only consider children or also grandchildren, etc.
3420 // I'm gonna say 'children only'
3421 for (int i=0; i<child_controls.Count; i++) {
3422 if (child_controls[i].Bounds.Contains(pt)) {
3423 return child_controls[i];
3429 public IContainerControl GetContainerControl() {
3430 Control current = this;
3432 while (current!=null) {
3433 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
3434 return (IContainerControl)current;
3436 current = current.parent;
3441 public Control GetNextControl(Control ctl, bool forward) {
3443 if (!this.Contains(ctl)) {
3448 ctl = FindControlForward(this, ctl);
3451 ctl = FindControlBackward(this, ctl);
3461 [EditorBrowsable (EditorBrowsableState.Advanced)]
3462 public virtual Size GetPreferredSize (Size proposedSize) {
3463 Size retsize = this.explicit_bounds.Size;
3465 // If we're bigger than the MaximumSize, fix that
3466 if (this.maximum_size.Width != 0 && retsize.Width > this.maximum_size.Width)
3467 retsize.Width = this.maximum_size.Width;
3468 if (this.maximum_size.Height != 0 && retsize.Height > this.maximum_size.Height)
3469 retsize.Height = this.maximum_size.Height;
3471 // If we're smaller than the MinimumSize, fix that
3472 if (this.minimum_size.Width != 0 && retsize.Width < this.minimum_size.Width)
3473 retsize.Width = this.minimum_size.Width;
3474 if (this.minimum_size.Height != 0 && retsize.Height < this.minimum_size.Height)
3475 retsize.Height = this.minimum_size.Height;
3481 public void Hide() {
3482 this.Visible = false;
3485 public void Invalidate() {
3486 Invalidate(ClientRectangle, false);
3489 public void Invalidate(bool invalidateChildren) {
3490 Invalidate(ClientRectangle, invalidateChildren);
3493 public void Invalidate(System.Drawing.Rectangle rc) {
3494 Invalidate(rc, false);
3497 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
3498 // Win32 invalidates control including when Width and Height is equal 0
3499 // or is not visible, only Paint event must be care about this.
3500 if (!IsHandleCreated)
3503 if (rc.Width > 0 && rc.Height > 0) {
3505 NotifyInvalidate(rc);
3507 XplatUI.Invalidate(Handle, rc, false);
3509 if (invalidateChildren) {
3510 Control [] controls = child_controls.GetAllControls ();
3511 for (int i=0; i<controls.Length; i++)
3512 controls [i].Invalidate ();
3515 OnInvalidated(new InvalidateEventArgs(rc));
3518 public void Invalidate(System.Drawing.Region region) {
3519 Invalidate(region, false);
3522 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
3523 RectangleF bounds = region.GetBounds (CreateGraphics ());
3524 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
3525 invalidateChildren);
3528 public object Invoke (Delegate method) {
3529 object [] prms = null;
3530 if (method is EventHandler)
3531 prms = new object [] { this, EventArgs.Empty };
3533 return Invoke(method, prms);
3536 public object Invoke (Delegate method, params object [] args) {
3538 public object Invoke (Delegate method, object[] args) {
3540 Control control = FindControlToInvokeOn ();
3542 if (!this.InvokeRequired) {
3543 return method.DynamicInvoke(args);
3546 IAsyncResult result = BeginInvokeInternal (method, args, control);
3547 return EndInvoke(result);
3550 [EditorBrowsable(EditorBrowsableState.Advanced)]
3551 public void PerformLayout() {
3552 PerformLayout(null, null);
3555 [EditorBrowsable(EditorBrowsableState.Advanced)]
3556 public void PerformLayout(Control affectedControl, string affectedProperty) {
3557 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
3559 if (layout_suspended > 0) {
3560 layout_pending = true;
3564 layout_pending = false;
3566 // Prevent us from getting messed up
3569 // Perform all Dock and Anchor calculations
3574 // Need to make sure we decremend layout_suspended
3580 public Point PointToClient (Point p) {
3584 XplatUI.ScreenToClient (Handle, ref x, ref y);
3586 return new Point (x, y);
3589 public Point PointToScreen(Point p) {
3593 XplatUI.ClientToScreen(Handle, ref x, ref y);
3595 return new Point(x, y);
3598 public virtual bool PreProcessMessage(ref Message msg) {
3599 return InternalPreProcessMessage (ref msg);
3602 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3605 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3606 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3608 if (!ProcessCmdKey(ref msg, key_data)) {
3609 if (IsInputKey(key_data)) {
3613 return ProcessDialogKey(key_data);
3617 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3618 if (IsInputChar((char)msg.WParam)) {
3621 return ProcessDialogChar((char)msg.WParam);
3622 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3623 return ProcessDialogChar((char)msg.WParam);
3628 public Rectangle RectangleToClient(Rectangle r) {
3629 return new Rectangle(PointToClient(r.Location), r.Size);
3632 public Rectangle RectangleToScreen(Rectangle r) {
3633 return new Rectangle(PointToScreen(r.Location), r.Size);
3636 public virtual void Refresh() {
3637 if (IsHandleCreated && Visible) {
3639 XplatUI.UpdateWindow(window.Handle);
3641 Control [] controls = child_controls.GetAllControls ();
3642 for (int i=0; i < controls.Length; i++) {
3643 controls[i].Refresh();
3649 [EditorBrowsable(EditorBrowsableState.Never)]
3650 public virtual void ResetBackColor() {
3651 BackColor = Color.Empty;
3654 [EditorBrowsable(EditorBrowsableState.Never)]
3655 public void ResetBindings() {
3656 if (data_bindings != null)
3657 data_bindings.Clear();
3660 [EditorBrowsable(EditorBrowsableState.Never)]
3661 public virtual void ResetCursor() {
3665 [EditorBrowsable(EditorBrowsableState.Never)]
3666 public virtual void ResetFont() {
3670 [EditorBrowsable(EditorBrowsableState.Never)]
3671 public virtual void ResetForeColor() {
3672 foreground_color = Color.Empty;
3675 [EditorBrowsable(EditorBrowsableState.Never)]
3676 public void ResetImeMode() {
3677 ime_mode = DefaultImeMode;
3680 [EditorBrowsable(EditorBrowsableState.Never)]
3681 public virtual void ResetRightToLeft() {
3682 right_to_left = RightToLeft.Inherit;
3685 public virtual void ResetText() {
3686 text = String.Empty;
3689 public void ResumeLayout() {
3690 ResumeLayout (true);
3693 public void ResumeLayout(bool performLayout) {
3694 if (layout_suspended > 0) {
3698 if (layout_suspended == 0) {
3699 if (performLayout && layout_pending) {
3705 [EditorBrowsable (EditorBrowsableState.Never)]
3708 public void Scale(float ratio) {
3709 ScaleCore(ratio, ratio);
3713 [EditorBrowsable (EditorBrowsableState.Never)]
3716 public void Scale(float dx, float dy) {
3721 [EditorBrowsable (EditorBrowsableState.Advanced)]
3722 public void Scale(SizeF factor) {
3723 ScaleCore(factor.Width, factor.Height);
3727 public void Select() {
3728 Select(false, false);
3732 private void printTree(Control c, string t) {
3733 foreach(Control i in c.child_controls) {
3734 Console.WriteLine ("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3735 printTree (i, t+"\t");
3739 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3743 Console.WriteLine("{0}", this.FindForm());
3744 printTree(this, "\t");
3747 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3752 c = GetNextControl(c, forward);
3761 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3762 c.Select (true, true);
3765 } while (c != ctl); // If we wrap back to ourselves we stop
3770 public void SendToBack() {
3771 if (parent != null) {
3772 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3776 public void SetBounds(int x, int y, int width, int height) {
3777 SetBounds(x, y, width, height, BoundsSpecified.All);
3780 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3781 // SetBoundsCore is really expensive to call, so we want to avoid it if we can.
3782 // We can avoid it if:
3783 // - The requested dimensions are the same as our current dimensions
3785 // - Any BoundsSpecified is the same as our current explicit_size
3786 if (bounds.X != x || (explicit_bounds.X != x && (specified & BoundsSpecified.X) == BoundsSpecified.X))
3787 SetBoundsCore (x, y, width, height, specified);
3788 else if (bounds.Y != y || (explicit_bounds.Y != y && (specified & BoundsSpecified.Y) == BoundsSpecified.Y))
3789 SetBoundsCore (x, y, width, height, specified);
3790 else if (bounds.Width != width || (explicit_bounds.Width != width && (specified & BoundsSpecified.Width) == BoundsSpecified.Width))
3791 SetBoundsCore (x, y, width, height, specified);
3792 else if (bounds.Height != height || (explicit_bounds.Height != height && (specified & BoundsSpecified.Height) == BoundsSpecified.Height))
3793 SetBoundsCore (x, y, width, height, specified);
3798 parent.PerformLayout(this, "Bounds");
3801 public void Show () {
3802 this.Visible = true;
3805 public void SuspendLayout() {
3809 public void Update() {
3810 if (IsHandleCreated) {
3811 XplatUI.UpdateWindow(window.Handle);
3814 #endregion // Public Instance Methods
3816 #region Protected Instance Methods
3817 [EditorBrowsable(EditorBrowsableState.Advanced)]
3818 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3819 // turns out this method causes handle
3820 // creation in 1.1. at first I thought this
3821 // would be accomplished just by using
3822 // get_AccessibilityObject, which would route
3823 // through CreateAccessibilityInstance, which
3824 // calls CreateControl. This isn't the case,
3825 // though (as overriding
3826 // CreateAccessibilityInstance and adding a
3827 // CWL shows nothing. So we fudge it and put
3828 // a CreateHandle here.
3834 if (accessibility_object != null && accessibility_object is ControlAccessibleObject)
3835 ((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, childID);
3838 [EditorBrowsable(EditorBrowsableState.Advanced)]
3839 protected virtual AccessibleObject CreateAccessibilityInstance() {
3841 return new Control.ControlAccessibleObject(this);
3844 [EditorBrowsable(EditorBrowsableState.Advanced)]
3845 protected virtual ControlCollection CreateControlsInstance() {
3846 return new ControlCollection(this);
3849 [EditorBrowsable(EditorBrowsableState.Advanced)]
3850 protected virtual void CreateHandle() {
3852 throw new ObjectDisposedException(GetType().FullName.ToString());
3855 if (IsHandleCreated && !is_recreating) {
3859 CreateParams create_params = CreateParams;
3860 window.CreateHandle(create_params);
3862 if (window.Handle != IntPtr.Zero) {
3863 creator_thread = Thread.CurrentThread;
3865 XplatUI.EnableWindow(window.Handle, is_enabled);
3867 if (clip_region != null) {
3868 XplatUI.SetClipRegion(window.Handle, clip_region);
3871 // Set our handle with our parent
3872 if ((parent != null) && (parent.IsHandleCreated)) {
3873 XplatUI.SetParent(window.Handle, parent.Handle);
3877 XplatUI.SetAllowDrop (window.Handle, allow_drop);
3879 // Find out where the window manager placed us
3880 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3881 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3887 [EditorBrowsable(EditorBrowsableState.Advanced)]
3888 protected virtual void DefWndProc(ref Message m) {
3889 window.DefWndProc(ref m);
3892 [EditorBrowsable(EditorBrowsableState.Advanced)]
3893 protected virtual void DestroyHandle() {
3894 if (IsHandleCreated) {
3895 if (window != null) {
3896 window.DestroyHandle();
3902 protected virtual AccessibleObject GetAccessibilityObjectById (int objectId)
3904 // XXX need to implement this.
3909 protected internal bool GetStyle(ControlStyles flag) {
3910 return (control_style & flag) != 0;
3913 protected bool GetTopLevel() {
3917 [EditorBrowsable(EditorBrowsableState.Advanced)]
3918 protected virtual void InitLayout() {
3922 [EditorBrowsable(EditorBrowsableState.Advanced)]
3923 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3924 toInvoke.OnGotFocus(e);
3927 [EditorBrowsable(EditorBrowsableState.Advanced)]
3928 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3929 toInvoke.OnLostFocus(e);
3932 [EditorBrowsable(EditorBrowsableState.Advanced)]
3933 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3934 toInvoke.OnClick(e);
3937 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3938 toInvoke.OnPaint(e);
3941 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3942 toInvoke.OnPaintBackground(e);
3945 protected virtual bool IsInputChar (char charCode) {
3946 // XXX on MS.NET this method causes the handle to be created..
3947 if (!IsHandleCreated)
3953 protected virtual bool IsInputKey (Keys keyData) {
3954 // Doc says this one calls IsInputChar; not sure what to do with that
3958 [EditorBrowsable(EditorBrowsableState.Advanced)]
3959 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3963 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3964 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3968 if (parent != null) {
3969 return parent.ProcessCmdKey(ref msg, keyData);
3975 protected virtual bool ProcessDialogChar(char charCode) {
3976 if (parent != null) {
3977 return parent.ProcessDialogChar (charCode);
3983 protected virtual bool ProcessDialogKey (Keys keyData) {
3984 if (parent != null) {
3985 return parent.ProcessDialogKey (keyData);
3991 protected virtual bool ProcessKeyEventArgs (ref Message msg) {
3992 KeyEventArgs key_event;
3995 case (int)Msg.WM_SYSKEYDOWN:
3996 case (int)Msg.WM_KEYDOWN: {
3997 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3998 OnKeyDown (key_event);
3999 return key_event.Handled;
4002 case (int)Msg.WM_SYSKEYUP:
4003 case (int)Msg.WM_KEYUP: {
4004 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
4005 OnKeyUp (key_event);
4006 return key_event.Handled;
4009 case (int)Msg.WM_SYSCHAR:
4010 case (int)Msg.WM_CHAR: {
4011 KeyPressEventArgs key_press_event;
4013 key_press_event = new KeyPressEventArgs((char)msg.WParam);
4014 OnKeyPress(key_press_event);
4016 msg.WParam = (IntPtr)key_press_event.KeyChar;
4018 return key_press_event.Handled;
4029 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
4030 if (parent != null) {
4031 if (parent.ProcessKeyPreview(ref msg)) {
4036 return ProcessKeyEventArgs(ref msg);
4039 protected virtual bool ProcessKeyPreview(ref Message msg) {
4040 if (parent != null) {
4041 return parent.ProcessKeyPreview(ref msg);
4047 protected virtual bool ProcessMnemonic(char charCode) {
4052 [EditorBrowsable(EditorBrowsableState.Advanced)]
4053 protected void RaiseDragEvent(object key, DragEventArgs e) {
4057 [EditorBrowsable(EditorBrowsableState.Advanced)]
4058 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
4062 [EditorBrowsable(EditorBrowsableState.Advanced)]
4063 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
4067 [EditorBrowsable(EditorBrowsableState.Advanced)]
4068 protected void RaisePaintEvent(object key, PaintEventArgs e) {
4072 private void SetIsRecreating () {
4075 foreach (Control c in Controls.GetAllControls()) {
4076 c.SetIsRecreating ();
4080 [EditorBrowsable(EditorBrowsableState.Advanced)]
4081 protected void RecreateHandle() {
4082 if (!IsHandleCreated)
4086 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
4091 if (IsHandleCreated) {
4093 Console.WriteLine(" + handle is created, destroying it.");
4096 // WM_DESTROY will CreateHandle for us
4099 Console.WriteLine(" + handle is not created, creating it.");
4107 is_recreating = false;
4109 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4115 [EditorBrowsable(EditorBrowsableState.Advanced)]
4116 protected void ResetMouseEventArgs() {
4120 [EditorBrowsable(EditorBrowsableState.Advanced)]
4121 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
4122 if (right_to_left == RightToLeft.No) {
4127 case ContentAlignment.TopLeft: {
4128 return ContentAlignment.TopRight;
4131 case ContentAlignment.TopRight: {
4132 return ContentAlignment.TopLeft;
4135 case ContentAlignment.MiddleLeft: {
4136 return ContentAlignment.MiddleRight;
4139 case ContentAlignment.MiddleRight: {
4140 return ContentAlignment.MiddleLeft;
4143 case ContentAlignment.BottomLeft: {
4144 return ContentAlignment.BottomRight;
4147 case ContentAlignment.BottomRight: {
4148 return ContentAlignment.BottomLeft;
4152 // if it's center it doesn't change
4158 [EditorBrowsable(EditorBrowsableState.Advanced)]
4159 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
4160 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
4164 if (align == HorizontalAlignment.Left) {
4165 return HorizontalAlignment.Right;
4168 // align must be HorizontalAlignment.Right
4169 return HorizontalAlignment.Left;
4172 [EditorBrowsable(EditorBrowsableState.Advanced)]
4173 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
4174 if (right_to_left == RightToLeft.No) {
4178 if (align == LeftRightAlignment.Left) {
4179 return LeftRightAlignment.Right;
4182 // align must be LeftRightAlignment.Right;
4183 return LeftRightAlignment.Left;
4186 [EditorBrowsable(EditorBrowsableState.Advanced)]
4187 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
4188 return RtlTranslateAlignment(align);
4191 [EditorBrowsable(EditorBrowsableState.Advanced)]
4192 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
4193 return RtlTranslateAlignment(align);
4196 [EditorBrowsable(EditorBrowsableState.Advanced)]
4197 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
4198 return RtlTranslateAlignment(align);
4202 [EditorBrowsable (EditorBrowsableState.Never)]
4204 [EditorBrowsable(EditorBrowsableState.Advanced)]
4206 protected virtual void ScaleCore(float dx, float dy) {
4212 location = new Point((int)(Left * dx), (int)(Top * dy));
4213 size = this.ClientSize;
4215 if (!GetStyle(ControlStyles.FixedWidth)) {
4216 size.Width = (int)(size.Width * dx);
4219 if (!GetStyle(ControlStyles.FixedHeight)) {
4220 size.Height = (int)(size.Height * dy);
4223 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
4225 /* Now scale our children */
4226 Control [] controls = child_controls.GetAllControls ();
4227 for (int i=0; i < controls.Length; i++) {
4228 controls[i].Scale(dx, dy);
4234 protected virtual void Select(bool directed, bool forward) {
4235 IContainerControl container;
4237 container = GetContainerControl();
4238 if (container != null && (Control)container != this)
4239 container.ActiveControl = this;
4242 [EditorBrowsable(EditorBrowsableState.Advanced)]
4243 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
4244 Rectangle old_explicit = explicit_bounds;
4245 Rectangle new_bounds = new Rectangle (x, y, width, height);
4247 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
4248 if (IsHandleCreated) {
4249 XplatUI.SetWindowPos(Handle, x, y, width, height);
4251 // Win32 automatically changes negative width/height to 0.
4252 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
4253 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
4255 if (width < 0 || height < 0) {
4257 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
4261 // BoundsSpecified tells us which variables were programatic (user-set).
4262 // We need to store those in the explicit bounds
4263 if ((specified & BoundsSpecified.X) == BoundsSpecified.X)
4264 explicit_bounds.X = new_bounds.X;
4266 explicit_bounds.X = old_explicit.X;
4268 if ((specified & BoundsSpecified.Y) == BoundsSpecified.Y)
4269 explicit_bounds.Y = new_bounds.Y;
4271 explicit_bounds.Y = old_explicit.Y;
4273 if ((specified & BoundsSpecified.Width) == BoundsSpecified.Width)
4274 explicit_bounds.Width = new_bounds.Width;
4276 explicit_bounds.Width = old_explicit.Width;
4278 if ((specified & BoundsSpecified.Height) == BoundsSpecified.Height)
4279 explicit_bounds.Height = new_bounds.Height;
4281 explicit_bounds.Height = old_explicit.Height;
4283 // We need to store the explicit bounds because UpdateBounds is always going
4284 // to change it, and we have to fix it. However, UpdateBounds also calls
4285 // OnLocationChanged, OnSizeChanged, and OnClientSizeChanged. The user can
4286 // override those or use those events to change the size explicitly, and we
4287 // can't undo those changes. So if the bounds after calling UpdateBounds are
4288 // the same as the ones we sent it, we need to fix the explicit bounds. If
4289 // it's not the same as we sent UpdateBounds, then someone else changed it, and
4290 // we better not mess it up. Fun stuff.
4291 Rectangle stored_explicit_bounds = explicit_bounds;
4293 UpdateBounds(x, y, width, height);
4295 if (explicit_bounds.X == x)
4296 explicit_bounds.X = stored_explicit_bounds.X;
4298 if (explicit_bounds.Y == y)
4299 explicit_bounds.Y = stored_explicit_bounds.Y;
4301 if (explicit_bounds.Width == width)
4302 explicit_bounds.Width = stored_explicit_bounds.Width;
4304 if (explicit_bounds.Height == height)
4305 explicit_bounds.Height = stored_explicit_bounds.Height;
4310 [EditorBrowsable(EditorBrowsableState.Advanced)]
4311 protected virtual void SetClientSizeCore(int x, int y) {
4312 Size NewSize = InternalSizeFromClientSize (new Size (x, y));
4314 if (NewSize != Size.Empty)
4315 SetBounds (bounds.X, bounds.Y, NewSize.Width, NewSize.Height, BoundsSpecified.Size);
4318 [EditorBrowsable(EditorBrowsableState.Advanced)]
4319 protected internal void SetStyle(ControlStyles flag, bool value) {
4321 control_style |= flag;
4323 control_style &= ~flag;
4327 protected void SetTopLevel(bool value) {
4328 if ((GetTopLevel() != value) && (parent != null)) {
4329 throw new ArgumentException ("Cannot change toplevel style of a parented control.");
4333 if (IsHandleCreated && value != Visible) {
4337 // XXX MS.NET causes handle to be created here
4338 if (!IsHandleCreated)
4341 is_toplevel = value;
4344 protected virtual void SetVisibleCore(bool value) {
4345 if (value != is_visible) {
4348 if (is_visible && ((window.Handle == IntPtr.Zero) || !is_created)) {
4352 if (IsHandleCreated) {
4353 XplatUI.SetVisible (Handle, is_visible, true);
4355 if (is_visible && this is Form) {
4356 // If we are Min or Max, we won't get a WM_SHOWWINDOW from SetWindowState,
4357 // so we need to manually create our children, and set them visible
4358 // (This normally happens in WmShowWindow.)
4359 if ((this as Form).WindowState != FormWindowState.Normal)
4360 OnVisibleChanged (EventArgs.Empty);
4362 // Explicitly move Toplevel windows to where we want them;
4363 // apparently moving unmapped toplevel windows doesn't work
4364 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
4367 if (!(this is Form))
4368 OnVisibleChanged (EventArgs.Empty);
4371 OnVisibleChanged(EventArgs.Empty);
4376 [EditorBrowsable (EditorBrowsableState.Advanced)]
4382 virtual Size SizeFromClientSize (Size clientSize) {
4383 return InternalSizeFromClientSize (clientSize);
4386 [EditorBrowsable(EditorBrowsableState.Advanced)]
4387 protected void UpdateBounds() {
4388 if (!IsHandleCreated)
4398 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
4400 UpdateBounds(x, y, width, height, client_width, client_height);
4403 [EditorBrowsable(EditorBrowsableState.Advanced)]
4404 protected void UpdateBounds(int x, int y, int width, int height) {
4408 // Calculate client rectangle
4409 rect = new Rectangle(0, 0, 0, 0);
4412 XplatUI.CalculateWindowRect(ref rect, cp, cp.menu, out rect);
4413 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
4416 [EditorBrowsable(EditorBrowsableState.Advanced)]
4417 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
4418 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
4420 bool resized = false;
4422 // Needed to generate required notifications
4423 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
4427 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
4434 bounds.Height=height;
4436 // Assume explicit bounds set. SetBoundsCore will restore old bounds
4438 explicit_bounds = bounds;
4440 client_size.Width=clientWidth;
4441 client_size.Height=clientHeight;
4444 OnLocationChanged(EventArgs.Empty);
4446 if (!background_color.IsEmpty && background_color.A < byte.MaxValue)
4451 OnSizeChanged(EventArgs.Empty);
4453 OnClientSizeChanged (EventArgs.Empty);
4458 [EditorBrowsable(EditorBrowsableState.Advanced)]
4459 protected void UpdateStyles() {
4460 if (!IsHandleCreated) {
4464 XplatUI.SetWindowStyle(window.Handle, CreateParams);
4465 OnStyleChanged(EventArgs.Empty);
4468 private void UpdateZOrderOfChild(Control child) {
4469 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
4472 index = child_controls.IndexOf(child);
4475 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
4477 IntPtr after = AfterTopMostControl ();
4478 if (after != IntPtr.Zero)
4479 XplatUI.SetZOrder (child.Handle, after, false, false);
4481 XplatUI.SetZOrder (child.Handle, IntPtr.Zero, true, false);
4486 // Override this if there is a control that shall always remain on
4487 // top of other controls (such as scrollbars). If there are several
4488 // of these controls, the bottom-most should be returned.
4489 internal virtual IntPtr AfterTopMostControl () {
4493 // internal because we need to call it from ScrollableControl.OnVisibleChanged
4494 internal void UpdateChildrenZOrder() {
4495 Control [] controls;
4497 if (!IsHandleCreated) {
4501 // XXX This code is severely broken. It leaks
4502 // the "zero_sized" abstraction out of the X11
4503 // backend and into Control.cs. It'll work on
4504 // windows simply by virtue of windows never
4505 // setting that field to true.
4507 // basically what we need to guard against is
4508 // calling XplatUI.SetZOrder on an hwnd that
4509 // corresponds to an unmapped X window.
4510 controls = child_controls.GetAllControls ();
4512 ArrayList children_to_order = new ArrayList ();
4514 for (int i = 0; i < controls.Length; i ++) {
4515 if (!controls[i].IsHandleCreated || !controls[i].VisibleInternal)
4518 Hwnd hwnd = Hwnd.ObjectFromHandle (controls[i].Handle);
4519 if (hwnd.zero_sized)
4522 children_to_order.Add (controls[i]);
4525 for (int i = 1; i < children_to_order.Count; i ++) {
4526 Control upper = (Control)children_to_order[i-1];
4527 Control lower = (Control)children_to_order[i];
4529 XplatUI.SetZOrder(lower.Handle, upper.Handle, false, false);
4533 [EditorBrowsable(EditorBrowsableState.Advanced)]
4534 protected void UpdateZOrder() {
4535 if (parent != null) {
4536 parent.UpdateZOrderOfChild(this);
4540 protected virtual void WndProc(ref Message m) {
4542 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
4544 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
4548 switch((Msg)m.Msg) {
4549 case Msg.WM_DESTROY: {
4554 case Msg.WM_WINDOWPOSCHANGED: {
4555 WmWindowPosChanged(ref m);
4559 // Nice description of what should happen when handling WM_PAINT
4560 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4561 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4562 case Msg.WM_PAINT: {
4567 // The DefWndProc will never have to handle this, we always paint the background in managed code
4568 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4569 // here but it just makes things more complicated...
4570 case Msg.WM_ERASEBKGND: {
4571 WmEraseBackground (ref m);
4575 case Msg.WM_LBUTTONUP: {
4576 WmLButtonUp (ref m);
4580 case Msg.WM_LBUTTONDOWN: {
4581 WmLButtonDown (ref m);
4585 case Msg.WM_LBUTTONDBLCLK: {
4586 WmLButtonDblClick (ref m);
4590 case Msg.WM_MBUTTONUP: {
4591 WmMButtonUp (ref m);
4595 case Msg.WM_MBUTTONDOWN: {
4596 WmMButtonDown (ref m);
4600 case Msg.WM_MBUTTONDBLCLK: {
4601 WmMButtonDblClick (ref m);
4605 case Msg.WM_RBUTTONUP: {
4606 WmRButtonUp (ref m);
4610 case Msg.WM_RBUTTONDOWN: {
4611 WmRButtonDown (ref m);
4615 case Msg.WM_RBUTTONDBLCLK: {
4616 WmRButtonDblClick (ref m);
4620 case Msg.WM_CONTEXTMENU: {
4621 WmContextMenu (ref m);
4625 case Msg.WM_MOUSEWHEEL: {
4626 WmMouseWheel (ref m);
4631 case Msg.WM_MOUSEMOVE: {
4632 WmMouseMove (ref m);
4636 case Msg.WM_SHOWWINDOW: {
4637 WmShowWindow (ref m);
4641 case Msg.WM_CREATE: {
4646 case Msg.WM_MOUSE_ENTER: {
4647 WmMouseEnter (ref m);
4651 case Msg.WM_MOUSELEAVE: {
4652 WmMouseLeave (ref m);
4656 case Msg.WM_MOUSEHOVER: {
4657 WmMouseHover (ref m);
4661 case Msg.WM_SYSKEYUP: {
4666 case Msg.WM_SYSKEYDOWN:
4667 case Msg.WM_KEYDOWN:
4669 case Msg.WM_SYSCHAR:
4680 case Msg.WM_KILLFOCUS: {
4681 WmKillFocus (ref m);
4685 case Msg.WM_SETFOCUS: {
4690 case Msg.WM_SYSCOLORCHANGE: {
4691 WmSysColorChange (ref m);
4695 case Msg.WM_SETCURSOR: {
4696 WmSetCursor (ref m);
4700 case Msg.WM_CAPTURECHANGED: {
4701 WmCaptureChanged (ref m);
4710 #endregion // Public Instance Methods
4714 private void WmDestroy (ref Message m) {
4715 OnHandleDestroyed(EventArgs.Empty);
4717 IntPtr handle = window.Handle;
4719 window.InvalidateHandle();
4721 if (is_recreating) {
4723 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4727 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4729 is_recreating = false;
4733 private void WmWindowPosChanged (ref Message m) {
4735 Rectangle save_bounds = explicit_bounds;
4737 explicit_bounds = save_bounds;
4738 if (GetStyle(ControlStyles.ResizeRedraw)) {
4745 // Nice description of what should happen when handling WM_PAINT
4746 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4747 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4748 private void WmPaint (ref Message m) {
4749 PaintEventArgs paint_event;
4751 IntPtr handle = Handle;
4753 paint_event = XplatUI.PaintEventStart (handle, true);
4755 if (paint_event == null)
4758 DoubleBuffer current_buffer = null;
4759 if (UseDoubleBuffering) {
4760 current_buffer = GetBackBuffer ();
4761 if (!current_buffer.InvalidRegion.IsVisible (paint_event.ClipRectangle)) {
4762 // Just blit the previous image
4763 current_buffer.Blit (paint_event);
4764 XplatUI.PaintEventEnd (handle, true);
4767 current_buffer.Start (paint_event);
4770 if (!GetStyle(ControlStyles.Opaque)) {
4771 OnPaintBackground (paint_event);
4774 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4775 OnPaintBackgroundInternal (paint_event);
4777 OnPaintInternal(paint_event);
4778 if (!paint_event.Handled) {
4779 OnPaint (paint_event);
4782 if (current_buffer != null) {
4783 current_buffer.End (paint_event);
4787 XplatUI.PaintEventEnd (handle, true);
4790 private void WmEraseBackground (ref Message m) {
4791 // The DefWndProc will never have to handle this, we always paint the background in managed code
4792 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4793 // here but it just makes things more complicated...
4794 m.Result = (IntPtr)1;
4797 private void WmLButtonUp (ref Message m) {
4800 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4802 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4805 HandleClick(mouse_clicks, me);
4808 if (InternalCapture) {
4809 InternalCapture = false;
4812 if (mouse_clicks > 1) {
4817 private void WmLButtonDown (ref Message m) {
4819 Select (true, true);
4821 InternalCapture = true;
4822 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4823 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4827 private void WmLButtonDblClick (ref Message m) {
4828 InternalCapture = true;
4830 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4831 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4835 private void WmMButtonUp (ref Message m) {
4838 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4840 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4843 HandleClick(mouse_clicks, me);
4845 if (InternalCapture) {
4846 InternalCapture = false;
4848 if (mouse_clicks > 1) {
4853 private void WmMButtonDown (ref Message m) {
4854 InternalCapture = true;
4855 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4856 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4860 private void WmMButtonDblClick (ref Message m) {
4861 InternalCapture = true;
4863 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4864 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4868 private void WmRButtonUp (ref Message m) {
4872 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4873 pt = PointToScreen(pt);
4875 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4877 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4879 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4882 HandleClick(mouse_clicks, me);
4885 if (InternalCapture) {
4886 InternalCapture = false;
4889 if (mouse_clicks > 1) {
4894 private void WmRButtonDown (ref Message m) {
4895 InternalCapture = true;
4896 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4897 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4901 private void WmRButtonDblClick (ref Message m) {
4902 InternalCapture = true;
4904 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4905 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4909 private void WmContextMenu (ref Message m) {
4910 if (context_menu != null) {
4913 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4915 if (pt.X == -1 || pt.Y == -1) {
4916 pt.X = (this.Width / 2) + this.Left;
4917 pt.Y = (this.Height / 2) + this.Top;
4918 pt = this.PointToScreen (pt);
4921 context_menu.Show (this, PointToClient (pt));
4926 // If there isn't a regular context menu, show the Strip version
4927 if (context_menu == null && context_menu_strip != null) {
4930 pt = new Point (LowOrder ((int)m.LParam.ToInt32 ()), HighOrder ((int)m.LParam.ToInt32 ()));
4932 if (pt.X == -1 || pt.Y == -1) {
4933 pt.X = (this.Width / 2) + this.Left;
4934 pt.Y = (this.Height /2) + this.Top;
4935 pt = this.PointToScreen (pt);
4938 context_menu_strip.Show (this, PointToClient (pt));
4945 private void WmCreate (ref Message m) {
4946 OnHandleCreated(EventArgs.Empty);
4949 private void WmMouseWheel (ref Message m) {
4951 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4952 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4953 HighOrder(m.WParam.ToInt32())));
4957 private void WmMouseMove (ref Message m) {
4958 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4960 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4964 private void WmMouseEnter (ref Message m) {
4969 OnMouseEnter(EventArgs.Empty);
4972 private void WmMouseLeave (ref Message m) {
4974 OnMouseLeave(EventArgs.Empty);
4977 private void WmMouseHover (ref Message m) {
4978 OnMouseHover(EventArgs.Empty);
4981 private void WmShowWindow (ref Message m) {
4982 if (m.WParam.ToInt32() != 0) {
4983 if (m.LParam.ToInt32 () == 0) {
4986 // Make sure all our children are properly parented to us
4987 Control [] controls = child_controls.GetAllControls ();
4988 for (int i=0; i<controls.Length; i++) {
4989 if (controls [i].is_visible && controls[i].IsHandleCreated)
4990 XplatUI.SetParent(controls[i].Handle, window.Handle);
4995 if (parent != null && Focused) {
4998 // Need to start at parent, GetContainerControl might return ourselves if we're a container
4999 container = (Control)parent.GetContainerControl();
5000 if (container != null) {
5001 container.SelectNextControl(this, true, true, true, true);
5006 // If the form is Max/Min, it got its OnVisibleChanged in SetVisibleCore
5008 Form f = (Form)this;
5010 if (f.IsMdiChild || f.WindowState == FormWindowState.Normal) /* XXX make sure this works for mdi forms */
5011 OnVisibleChanged(EventArgs.Empty);
5012 } else if (is_toplevel)
5013 OnVisibleChanged(EventArgs.Empty);
5016 private void WmSysKeyUp (ref Message m) {
5017 if (ProcessKeyMessage(ref m)) {
5018 m.Result = IntPtr.Zero;
5022 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
5026 if (form != null && form.ActiveMenu != null) {
5027 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
5034 private void WmKeys (ref Message m) {
5035 if (ProcessKeyMessage(ref m)) {
5036 m.Result = IntPtr.Zero;
5042 private void WmHelp (ref Message m) {
5044 if (m.LParam != IntPtr.Zero) {
5047 hi = new HELPINFO();
5049 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
5050 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
5052 mouse_pos = Control.MousePosition;
5054 OnHelpRequested(new HelpEventArgs(mouse_pos));
5055 m.Result = (IntPtr)1;
5058 private void WmKillFocus (ref Message m) {
5059 this.has_focus = false;
5060 OnLostFocus (EventArgs.Empty);
5063 private void WmSetFocus (ref Message m) {
5065 this.has_focus = true;
5066 OnGotFocus (EventArgs.Empty);
5070 private void WmSysColorChange (ref Message m) {
5071 ThemeEngine.Current.ResetDefaults();
5072 OnSystemColorsChanged(EventArgs.Empty);
5075 private void WmSetCursor (ref Message m) {
5076 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
5081 XplatUI.SetCursor(window.Handle, cursor.handle);
5082 m.Result = (IntPtr)1;
5085 private void WmCaptureChanged (ref Message m) {
5086 is_captured = false;
5087 OnMouseCaptureChanged (EventArgs.Empty);
5088 m.Result = (IntPtr) 0;
5094 #region OnXXX methods
5096 protected virtual void OnAutoSizeChanged (EventArgs e)
5098 EventHandler eh = (EventHandler)(Events[AutoSizeChangedEvent]);
5104 [EditorBrowsable (EditorBrowsableState.Advanced)]
5105 protected virtual void OnBackColorChanged(EventArgs e) {
5106 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
5109 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
5112 [EditorBrowsable(EditorBrowsableState.Advanced)]
5113 protected virtual void OnBackgroundImageChanged(EventArgs e) {
5114 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
5117 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
5121 [EditorBrowsable (EditorBrowsableState.Advanced)]
5122 protected virtual void OnBackgroundImageLayoutChanged (EventArgs e)
5124 EventHandler eh = (EventHandler)(Events[BackgroundImageLayoutChangedEvent]);
5130 [EditorBrowsable(EditorBrowsableState.Advanced)]
5131 protected virtual void OnBindingContextChanged(EventArgs e) {
5132 CheckDataBindings ();
5133 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
5136 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
5139 [EditorBrowsable(EditorBrowsableState.Advanced)]
5140 protected virtual void OnCausesValidationChanged(EventArgs e) {
5141 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
5146 [EditorBrowsable(EditorBrowsableState.Advanced)]
5147 protected virtual void OnChangeUICues(UICuesEventArgs e) {
5148 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
5153 [EditorBrowsable(EditorBrowsableState.Advanced)]
5154 protected virtual void OnClick(EventArgs e) {
5155 EventHandler eh = (EventHandler)(Events [ClickEvent]);
5161 [EditorBrowsable (EditorBrowsableState.Advanced)]
5162 protected virtual void OnClientSizeChanged (EventArgs e)
5164 EventHandler eh = (EventHandler)(Events[ClientSizeChangedEvent]);
5170 [EditorBrowsable(EditorBrowsableState.Advanced)]
5171 protected virtual void OnContextMenuChanged(EventArgs e) {
5172 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
5178 [EditorBrowsable (EditorBrowsableState.Advanced)]
5179 protected virtual void OnContextMenuStripChanged (EventArgs e) {
5180 EventHandler eh = (EventHandler)(Events [ContextMenuStripChangedEvent]);
5186 [EditorBrowsable(EditorBrowsableState.Advanced)]
5187 protected virtual void OnControlAdded(ControlEventArgs e) {
5188 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
5193 [EditorBrowsable(EditorBrowsableState.Advanced)]
5194 protected virtual void OnControlRemoved(ControlEventArgs e) {
5195 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
5200 [EditorBrowsable(EditorBrowsableState.Advanced)]
5201 protected virtual void OnCreateControl() {
5205 [EditorBrowsable(EditorBrowsableState.Advanced)]
5206 protected virtual void OnCursorChanged(EventArgs e) {
5207 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
5212 [EditorBrowsable(EditorBrowsableState.Advanced)]
5213 protected virtual void OnDockChanged(EventArgs e) {
5214 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
5219 [EditorBrowsable(EditorBrowsableState.Advanced)]
5220 protected virtual void OnDoubleClick(EventArgs e) {
5221 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
5226 [EditorBrowsable(EditorBrowsableState.Advanced)]
5227 protected virtual void OnDragDrop(DragEventArgs drgevent) {
5228 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
5230 eh (this, drgevent);
5233 [EditorBrowsable(EditorBrowsableState.Advanced)]
5234 protected virtual void OnDragEnter(DragEventArgs drgevent) {
5235 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
5237 eh (this, drgevent);
5240 [EditorBrowsable(EditorBrowsableState.Advanced)]
5241 protected virtual void OnDragLeave(EventArgs e) {
5242 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
5247 [EditorBrowsable(EditorBrowsableState.Advanced)]
5248 protected virtual void OnDragOver(DragEventArgs drgevent) {
5249 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
5251 eh (this, drgevent);
5254 [EditorBrowsable(EditorBrowsableState.Advanced)]
5255 protected virtual void OnEnabledChanged(EventArgs e) {
5256 if (IsHandleCreated) {
5258 if (((Form)this).context == null) {
5259 XplatUI.EnableWindow(window.Handle, Enabled);
5262 XplatUI.EnableWindow(window.Handle, Enabled);
5267 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
5271 for (int i=0; i<child_controls.Count; i++) {
5272 child_controls[i].OnParentEnabledChanged(e);
5276 [EditorBrowsable(EditorBrowsableState.Advanced)]
5277 protected virtual void OnEnter(EventArgs e) {
5278 EventHandler eh = (EventHandler)(Events [EnterEvent]);
5283 [EditorBrowsable(EditorBrowsableState.Advanced)]
5284 protected virtual void OnFontChanged(EventArgs e) {
5285 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
5288 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
5291 [EditorBrowsable(EditorBrowsableState.Advanced)]
5292 protected virtual void OnForeColorChanged(EventArgs e) {
5293 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
5296 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
5299 [EditorBrowsable(EditorBrowsableState.Advanced)]
5300 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
5301 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
5303 eh (this, gfbevent);
5306 [EditorBrowsable(EditorBrowsableState.Advanced)]
5307 protected virtual void OnGotFocus(EventArgs e) {
5308 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
5313 [EditorBrowsable(EditorBrowsableState.Advanced)]
5314 protected virtual void OnHandleCreated(EventArgs e) {
5315 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
5320 [EditorBrowsable(EditorBrowsableState.Advanced)]
5321 protected virtual void OnHandleDestroyed(EventArgs e) {
5322 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
5327 internal void RaiseHelpRequested (HelpEventArgs hevent) {
5328 OnHelpRequested (hevent);
5331 [EditorBrowsable(EditorBrowsableState.Advanced)]
5332 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
5333 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
5338 protected virtual void OnImeModeChanged(EventArgs e) {
5339 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
5344 [EditorBrowsable(EditorBrowsableState.Advanced)]
5345 protected virtual void OnInvalidated(InvalidateEventArgs e) {
5346 if (UseDoubleBuffering) {
5347 // should this block be here? seems like it
5348 // would be more at home in
5349 // NotifyInvalidated..
5350 if (e.InvalidRect == ClientRectangle) {
5351 InvalidateBackBuffer ();
5352 } else if (backbuffer != null){
5353 // we need this Inflate call here so
5354 // that the border of the rectangle is
5355 // considered Visible (the
5356 // invalid_region.IsVisible call) in
5357 // the WM_PAINT handling below.
5358 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
5359 backbuffer.InvalidRegion.Union (r);
5363 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
5368 [EditorBrowsable(EditorBrowsableState.Advanced)]
5369 protected virtual void OnKeyDown(KeyEventArgs e) {
5370 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
5375 [EditorBrowsable(EditorBrowsableState.Advanced)]
5376 protected virtual void OnKeyPress(KeyPressEventArgs e) {
5377 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
5382 [EditorBrowsable(EditorBrowsableState.Advanced)]
5383 protected virtual void OnKeyUp(KeyEventArgs e) {
5384 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
5389 [EditorBrowsable(EditorBrowsableState.Advanced)]
5390 protected virtual void OnLayout(LayoutEventArgs levent) {
5391 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
5395 LayoutEngine.Layout (this, levent);
5398 [EditorBrowsable(EditorBrowsableState.Advanced)]
5399 protected virtual void OnLeave(EventArgs e) {
5400 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
5405 [EditorBrowsable(EditorBrowsableState.Advanced)]
5406 protected virtual void OnLocationChanged(EventArgs e) {
5408 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
5413 [EditorBrowsable(EditorBrowsableState.Advanced)]
5414 protected virtual void OnLostFocus(EventArgs e) {
5415 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
5421 protected virtual void OnMarginChanged (EventArgs e)
5423 EventHandler eh = (EventHandler)(Events[MarginChangedEvent]);
5428 [EditorBrowsable (EditorBrowsableState.Advanced)]
5430 protected virtual void OnMouseCaptureChanged (EventArgs e)
5432 internal virtual void OnMouseCaptureChanged (EventArgs e)
5435 EventHandler eh = (EventHandler)(Events [MouseCaptureChangedEvent]);
5441 [EditorBrowsable (EditorBrowsableState.Advanced)]
5442 protected virtual void OnMouseClick (MouseEventArgs e)
5444 MouseEventHandler eh = (MouseEventHandler)(Events [MouseClickEvent]);
5449 [EditorBrowsable (EditorBrowsableState.Advanced)]
5450 protected virtual void OnMouseDoubleClick (MouseEventArgs e)
5452 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDoubleClickEvent]);
5458 [EditorBrowsable(EditorBrowsableState.Advanced)]
5459 protected virtual void OnMouseDown(MouseEventArgs e) {
5460 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
5465 [EditorBrowsable(EditorBrowsableState.Advanced)]
5466 protected virtual void OnMouseEnter(EventArgs e) {
5467 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
5472 [EditorBrowsable(EditorBrowsableState.Advanced)]
5473 protected virtual void OnMouseHover(EventArgs e) {
5474 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
5479 [EditorBrowsable(EditorBrowsableState.Advanced)]
5480 protected virtual void OnMouseLeave(EventArgs e) {
5481 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
5486 [EditorBrowsable(EditorBrowsableState.Advanced)]
5487 protected virtual void OnMouseMove(MouseEventArgs e) {
5488 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
5493 [EditorBrowsable(EditorBrowsableState.Advanced)]
5494 protected virtual void OnMouseUp(MouseEventArgs e) {
5495 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
5500 [EditorBrowsable(EditorBrowsableState.Advanced)]
5501 protected virtual void OnMouseWheel(MouseEventArgs e) {
5502 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
5507 [EditorBrowsable(EditorBrowsableState.Advanced)]
5508 protected virtual void OnMove(EventArgs e) {
5509 EventHandler eh = (EventHandler)(Events [MoveEvent]);
5514 [EditorBrowsable(EditorBrowsableState.Advanced)]
5515 protected virtual void OnNotifyMessage(Message m) {
5520 protected virtual void OnPaddingChanged (EventArgs e) {
5521 EventHandler eh = (EventHandler) (Events [PaddingChangedEvent]);
5527 [EditorBrowsable(EditorBrowsableState.Advanced)]
5528 protected virtual void OnPaint(PaintEventArgs e) {
5529 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
5534 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
5538 internal virtual void OnPaintInternal(PaintEventArgs e) {
5542 [EditorBrowsable(EditorBrowsableState.Advanced)]
5543 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
5544 PaintControlBackground (pevent);
5547 [EditorBrowsable(EditorBrowsableState.Advanced)]
5548 protected virtual void OnParentBackColorChanged(EventArgs e) {
5549 if (background_color.IsEmpty && background_image==null) {
5551 OnBackColorChanged(e);
5555 [EditorBrowsable(EditorBrowsableState.Advanced)]
5556 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
5558 OnBackgroundImageChanged(e);
5561 [EditorBrowsable(EditorBrowsableState.Advanced)]
5562 protected virtual void OnParentBindingContextChanged(EventArgs e) {
5563 if (binding_context==null) {
5564 binding_context=Parent.binding_context;
5565 OnBindingContextChanged(e);
5569 [EditorBrowsable(EditorBrowsableState.Advanced)]
5570 protected virtual void OnParentChanged(EventArgs e) {
5571 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
5576 [EditorBrowsable(EditorBrowsableState.Advanced)]
5577 protected virtual void OnParentEnabledChanged(EventArgs e) {
5579 OnEnabledChanged(e);
5583 [EditorBrowsable(EditorBrowsableState.Advanced)]
5584 protected virtual void OnParentFontChanged(EventArgs e) {
5591 [EditorBrowsable(EditorBrowsableState.Advanced)]
5592 protected virtual void OnParentForeColorChanged(EventArgs e) {
5593 if (foreground_color.IsEmpty) {
5595 OnForeColorChanged(e);
5599 [EditorBrowsable(EditorBrowsableState.Advanced)]
5600 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
5601 if (right_to_left==RightToLeft.Inherit) {
5603 OnRightToLeftChanged(e);
5607 [EditorBrowsable(EditorBrowsableState.Advanced)]
5608 protected virtual void OnParentVisibleChanged(EventArgs e) {
5610 OnVisibleChanged(e);
5614 [EditorBrowsable(EditorBrowsableState.Advanced)]
5615 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
5616 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
5622 [EditorBrowsable (EditorBrowsableState.Advanced)]
5623 protected virtual void OnRegionChanged (EventArgs e)
5625 EventHandler eh = (EventHandler)(Events[RegionChangedEvent]);
5631 [EditorBrowsable(EditorBrowsableState.Advanced)]
5632 protected virtual void OnResize(EventArgs e) {
5633 PerformLayout(this, "Bounds");
5635 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
5640 [EditorBrowsable(EditorBrowsableState.Advanced)]
5641 protected virtual void OnRightToLeftChanged(EventArgs e) {
5642 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
5645 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
5648 [EditorBrowsable(EditorBrowsableState.Advanced)]
5649 protected virtual void OnSizeChanged(EventArgs e) {
5650 DisposeBackBuffer ();
5652 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
5657 [EditorBrowsable(EditorBrowsableState.Advanced)]
5658 protected virtual void OnStyleChanged(EventArgs e) {
5659 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
5664 [EditorBrowsable(EditorBrowsableState.Advanced)]
5665 protected virtual void OnSystemColorsChanged(EventArgs e) {
5666 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
5671 [EditorBrowsable(EditorBrowsableState.Advanced)]
5672 protected virtual void OnTabIndexChanged(EventArgs e) {
5673 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
5678 [EditorBrowsable(EditorBrowsableState.Advanced)]
5679 protected virtual void OnTabStopChanged(EventArgs e) {
5680 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
5685 [EditorBrowsable(EditorBrowsableState.Advanced)]
5686 protected virtual void OnTextChanged(EventArgs e) {
5687 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
5692 [EditorBrowsable(EditorBrowsableState.Advanced)]
5693 protected virtual void OnValidated(EventArgs e) {
5694 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
5699 [EditorBrowsable(EditorBrowsableState.Advanced)]
5700 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
5701 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
5706 [EditorBrowsable(EditorBrowsableState.Advanced)]
5707 protected virtual void OnVisibleChanged(EventArgs e) {
5711 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
5715 // We need to tell our kids (including implicit ones)
5716 foreach (Control c in Controls.GetAllControls ())
5718 c.OnParentVisibleChanged (e);
5720 #endregion // OnXXX methods
5724 static object AutoSizeChangedEvent = new object ();
5726 static object BackColorChangedEvent = new object ();
5727 static object BackgroundImageChangedEvent = new object ();
5729 static object BackgroundImageLayoutChangedEvent = new object ();
5731 static object BindingContextChangedEvent = new object ();
5732 static object CausesValidationChangedEvent = new object ();
5733 static object ChangeUICuesEvent = new object ();
5734 static object ClickEvent = new object ();
5736 static object ClientSizeChangedEvent = new object ();
5738 static object ContextMenuChangedEvent = new object ();
5740 static object ContextMenuStripChangedEvent = new object ();
5742 static object ControlAddedEvent = new object ();
5743 static object ControlRemovedEvent = new object ();
5744 static object CursorChangedEvent = new object ();
5745 static object DockChangedEvent = new object ();
5746 static object DoubleClickEvent = new object ();
5747 static object DragDropEvent = new object ();
5748 static object DragEnterEvent = new object ();
5749 static object DragLeaveEvent = new object ();
5750 static object DragOverEvent = new object ();
5751 static object EnabledChangedEvent = new object ();
5752 static object EnterEvent = new object ();
5753 static object FontChangedEvent = new object ();
5754 static object ForeColorChangedEvent = new object ();
5755 static object GiveFeedbackEvent = new object ();
5756 static object GotFocusEvent = new object ();
5757 static object HandleCreatedEvent = new object ();
5758 static object HandleDestroyedEvent = new object ();
5759 static object HelpRequestedEvent = new object ();
5760 static object ImeModeChangedEvent = new object ();
5761 static object InvalidatedEvent = new object ();
5762 static object KeyDownEvent = new object ();
5763 static object KeyPressEvent = new object ();
5764 static object KeyUpEvent = new object ();
5765 static object LayoutEvent = new object ();
5766 static object LeaveEvent = new object ();
5767 static object LocationChangedEvent = new object ();
5768 static object LostFocusEvent = new object ();
5770 static object MarginChangedEvent = new object ();
5772 static object MouseCaptureChangedEvent = new object ();
5774 static object MouseClickEvent = new object ();
5775 static object MouseDoubleClickEvent = new object ();
5777 static object MouseDownEvent = new object ();
5778 static object MouseEnterEvent = new object ();
5779 static object MouseHoverEvent = new object ();
5780 static object MouseLeaveEvent = new object ();
5781 static object MouseMoveEvent = new object ();
5782 static object MouseUpEvent = new object ();
5783 static object MouseWheelEvent = new object ();
5784 static object MoveEvent = new object ();
5786 static object PaddingChangedEvent = new object ();
5788 static object PaintEvent = new object ();
5789 static object ParentChangedEvent = new object ();
5791 static object PreviewKeyDownEvent = new object ();
5793 static object QueryAccessibilityHelpEvent = new object ();
5794 static object QueryContinueDragEvent = new object ();
5796 static object RegionChangedEvent = new object ();
5798 static object ResizeEvent = new object ();
5799 static object RightToLeftChangedEvent = new object ();
5800 static object SizeChangedEvent = new object ();
5801 static object StyleChangedEvent = new object ();
5802 static object SystemColorsChangedEvent = new object ();
5803 static object TabIndexChangedEvent = new object ();
5804 static object TabStopChangedEvent = new object ();
5805 static object TextChangedEvent = new object ();
5806 static object ValidatedEvent = new object ();
5807 static object ValidatingEvent = new object ();
5808 static object VisibleChangedEvent = new object ();
5812 [EditorBrowsable (EditorBrowsableState.Never)]
5813 public event EventHandler AutoSizeChanged {
5814 add { Events.AddHandler (AutoSizeChangedEvent, value);}
5815 remove {Events.RemoveHandler (AutoSizeChangedEvent, value);}
5818 public event EventHandler BackColorChanged {
5819 add { Events.AddHandler (BackColorChangedEvent, value); }
5820 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
5823 public event EventHandler BackgroundImageChanged {
5824 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
5825 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
5829 public event EventHandler BackgroundImageLayoutChanged {
5830 add {Events.AddHandler (BackgroundImageLayoutChangedEvent, value);}
5831 remove {Events.RemoveHandler (BackgroundImageLayoutChangedEvent, value);}
5835 public event EventHandler BindingContextChanged {
5836 add { Events.AddHandler (BindingContextChangedEvent, value); }
5837 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
5840 public event EventHandler CausesValidationChanged {
5841 add { Events.AddHandler (CausesValidationChangedEvent, value); }
5842 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
5845 public event UICuesEventHandler ChangeUICues {
5846 add { Events.AddHandler (ChangeUICuesEvent, value); }
5847 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
5850 public event EventHandler Click {
5851 add { Events.AddHandler (ClickEvent, value); }
5852 remove { Events.RemoveHandler (ClickEvent, value); }
5856 public event EventHandler ClientSizeChanged {
5857 add {Events.AddHandler (ClientSizeChangedEvent, value);}
5858 remove {Events.RemoveHandler (ClientSizeChangedEvent, value);}
5865 public event EventHandler ContextMenuChanged {
5866 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5867 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5871 public event EventHandler ContextMenuStripChanged {
5872 add { Events.AddHandler (ContextMenuStripChangedEvent, value); }
5873 remove { Events.RemoveHandler (ContextMenuStripChangedEvent, value);}
5878 [EditorBrowsable(EditorBrowsableState.Advanced)]
5884 public event ControlEventHandler ControlAdded {
5885 add { Events.AddHandler (ControlAddedEvent, value); }
5886 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5889 [EditorBrowsable(EditorBrowsableState.Advanced)]
5895 public event ControlEventHandler ControlRemoved {
5896 add { Events.AddHandler (ControlRemovedEvent, value); }
5897 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5900 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5901 public event EventHandler CursorChanged {
5902 add { Events.AddHandler (CursorChangedEvent, value); }
5903 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5905 public event EventHandler DockChanged {
5906 add { Events.AddHandler (DockChangedEvent, value); }
5907 remove { Events.RemoveHandler (DockChangedEvent, value); }
5910 public event EventHandler DoubleClick {
5911 add { Events.AddHandler (DoubleClickEvent, value); }
5912 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5915 public event DragEventHandler DragDrop {
5916 add { Events.AddHandler (DragDropEvent, value); }
5917 remove { Events.RemoveHandler (DragDropEvent, value); }
5920 public event DragEventHandler DragEnter {
5921 add { Events.AddHandler (DragEnterEvent, value); }
5922 remove { Events.RemoveHandler (DragEnterEvent, value); }
5925 public event EventHandler DragLeave {
5926 add { Events.AddHandler (DragLeaveEvent, value); }
5927 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5930 public event DragEventHandler DragOver {
5931 add { Events.AddHandler (DragOverEvent, value); }
5932 remove { Events.RemoveHandler (DragOverEvent, value); }
5935 public event EventHandler EnabledChanged {
5936 add { Events.AddHandler (EnabledChangedEvent, value); }
5937 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5940 public event EventHandler Enter {
5941 add { Events.AddHandler (EnterEvent, value); }
5942 remove { Events.RemoveHandler (EnterEvent, value); }
5945 public event EventHandler FontChanged {
5946 add { Events.AddHandler (FontChangedEvent, value); }
5947 remove { Events.RemoveHandler (FontChangedEvent, value); }
5950 public event EventHandler ForeColorChanged {
5951 add { Events.AddHandler (ForeColorChangedEvent, value); }
5952 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5955 public event GiveFeedbackEventHandler GiveFeedback {
5956 add { Events.AddHandler (GiveFeedbackEvent, value); }
5957 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5960 [EditorBrowsable(EditorBrowsableState.Advanced)]
5962 public event EventHandler GotFocus {
5963 add { Events.AddHandler (GotFocusEvent, value); }
5964 remove { Events.RemoveHandler (GotFocusEvent, value); }
5968 [EditorBrowsable(EditorBrowsableState.Advanced)]
5970 public event EventHandler HandleCreated {
5971 add { Events.AddHandler (HandleCreatedEvent, value); }
5972 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5975 [EditorBrowsable(EditorBrowsableState.Advanced)]
5977 public event EventHandler HandleDestroyed {
5978 add { Events.AddHandler (HandleDestroyedEvent, value); }
5979 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5982 public event HelpEventHandler HelpRequested {
5983 add { Events.AddHandler (HelpRequestedEvent, value); }
5984 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5987 public event EventHandler ImeModeChanged {
5988 add { Events.AddHandler (ImeModeChangedEvent, value); }
5989 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5992 [EditorBrowsable(EditorBrowsableState.Advanced)]
5994 public event InvalidateEventHandler Invalidated {
5995 add { Events.AddHandler (InvalidatedEvent, value); }
5996 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5999 public event KeyEventHandler KeyDown {
6000 add { Events.AddHandler (KeyDownEvent, value); }
6001 remove { Events.RemoveHandler (KeyDownEvent, value); }
6004 public event KeyPressEventHandler KeyPress {
6005 add { Events.AddHandler (KeyPressEvent, value); }
6006 remove { Events.RemoveHandler (KeyPressEvent, value); }
6009 public event KeyEventHandler KeyUp {
6010 add { Events.AddHandler (KeyUpEvent, value); }
6011 remove { Events.RemoveHandler (KeyUpEvent, value); }
6014 public event LayoutEventHandler Layout {
6015 add { Events.AddHandler (LayoutEvent, value); }
6016 remove { Events.RemoveHandler (LayoutEvent, value); }
6019 public event EventHandler Leave {
6020 add { Events.AddHandler (LeaveEvent, value); }
6021 remove { Events.RemoveHandler (LeaveEvent, value); }
6024 public event EventHandler LocationChanged {
6025 add { Events.AddHandler (LocationChangedEvent, value); }
6026 remove { Events.RemoveHandler (LocationChangedEvent, value); }
6029 [EditorBrowsable(EditorBrowsableState.Advanced)]
6031 public event EventHandler LostFocus {
6032 add { Events.AddHandler (LostFocusEvent, value); }
6033 remove { Events.RemoveHandler (LostFocusEvent, value); }
6037 public event EventHandler MarginChanged {
6038 add { Events.AddHandler (MarginChangedEvent, value); }
6039 remove {Events.RemoveHandler (MarginChangedEvent, value); }
6043 public event EventHandler MouseCaptureChanged {
6045 internal event EventHandler MouseCaptureChanged {
6047 add { Events.AddHandler (MouseCaptureChangedEvent, value); }
6048 remove { Events.RemoveHandler (MouseCaptureChangedEvent, value); }
6051 public event MouseEventHandler MouseClick
6053 add { Events.AddHandler (MouseClickEvent, value); }
6054 remove { Events.RemoveHandler (MouseClickEvent, value); }
6056 public event MouseEventHandler MouseDoubleClick
6058 add { Events.AddHandler (MouseDoubleClickEvent, value); }
6059 remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
6062 public event MouseEventHandler MouseDown {
6063 add { Events.AddHandler (MouseDownEvent, value); }
6064 remove { Events.RemoveHandler (MouseDownEvent, value); }
6067 public event EventHandler MouseEnter {
6068 add { Events.AddHandler (MouseEnterEvent, value); }
6069 remove { Events.RemoveHandler (MouseEnterEvent, value); }
6072 public event EventHandler MouseHover {
6073 add { Events.AddHandler (MouseHoverEvent, value); }
6074 remove { Events.RemoveHandler (MouseHoverEvent, value); }
6077 public event EventHandler MouseLeave {
6078 add { Events.AddHandler (MouseLeaveEvent, value); }
6079 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
6082 public event MouseEventHandler MouseMove {
6083 add { Events.AddHandler (MouseMoveEvent, value); }
6084 remove { Events.RemoveHandler (MouseMoveEvent, value); }
6087 public event MouseEventHandler MouseUp {
6088 add { Events.AddHandler (MouseUpEvent, value); }
6089 remove { Events.RemoveHandler (MouseUpEvent, value); }
6092 [EditorBrowsable(EditorBrowsableState.Advanced)]
6094 public event MouseEventHandler MouseWheel {
6095 add { Events.AddHandler (MouseWheelEvent, value); }
6096 remove { Events.RemoveHandler (MouseWheelEvent, value); }
6099 public event EventHandler Move {
6100 add { Events.AddHandler (MoveEvent, value); }
6101 remove { Events.RemoveHandler (MoveEvent, value); }
6104 public event EventHandler PaddingChanged
6106 add { Events.AddHandler (PaddingChangedEvent, value); }
6107 remove { Events.RemoveHandler (PaddingChangedEvent, value); }
6110 public event PaintEventHandler Paint {
6111 add { Events.AddHandler (PaintEvent, value); }
6112 remove { Events.RemoveHandler (PaintEvent, value); }
6115 public event EventHandler ParentChanged {
6116 add { Events.AddHandler (ParentChangedEvent, value); }
6117 remove { Events.RemoveHandler (ParentChangedEvent, value); }
6121 public event PreviewKeyDownEventHandler PreviewKeyDown {
6122 add { Events.AddHandler (PreviewKeyDownEvent, value); }
6123 remove { Events.RemoveHandler (PreviewKeyDownEvent, value); }
6127 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
6128 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
6129 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
6132 public event QueryContinueDragEventHandler QueryContinueDrag {
6133 add { Events.AddHandler (QueryContinueDragEvent, value); }
6134 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
6138 public event EventHandler RegionChanged {
6139 add { Events.AddHandler (RegionChangedEvent, value); }
6140 remove { Events.RemoveHandler (RegionChangedEvent, value); }
6145 [EditorBrowsable (EditorBrowsableState.Advanced)]
6147 public event EventHandler Resize {
6148 add { Events.AddHandler (ResizeEvent, value); }
6149 remove { Events.RemoveHandler (ResizeEvent, value); }
6152 public event EventHandler RightToLeftChanged {
6153 add { Events.AddHandler (RightToLeftChangedEvent, value); }
6154 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
6157 public event EventHandler SizeChanged {
6158 add { Events.AddHandler (SizeChangedEvent, value); }
6159 remove { Events.RemoveHandler (SizeChangedEvent, value); }
6162 public event EventHandler StyleChanged {
6163 add { Events.AddHandler (StyleChangedEvent, value); }
6164 remove { Events.RemoveHandler (StyleChangedEvent, value); }
6167 public event EventHandler SystemColorsChanged {
6168 add { Events.AddHandler (SystemColorsChangedEvent, value); }
6169 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
6172 public event EventHandler TabIndexChanged {
6173 add { Events.AddHandler (TabIndexChangedEvent, value); }
6174 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
6177 public event EventHandler TabStopChanged {
6178 add { Events.AddHandler (TabStopChangedEvent, value); }
6179 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
6182 public event EventHandler TextChanged {
6183 add { Events.AddHandler (TextChangedEvent, value); }
6184 remove { Events.RemoveHandler (TextChangedEvent, value); }
6187 public event EventHandler Validated {
6188 add { Events.AddHandler (ValidatedEvent, value); }
6189 remove { Events.RemoveHandler (ValidatedEvent, value); }
6192 public event CancelEventHandler Validating {
6193 add { Events.AddHandler (ValidatingEvent, value); }
6194 remove { Events.RemoveHandler (ValidatingEvent, value); }
6197 public event EventHandler VisibleChanged {
6198 add { Events.AddHandler (VisibleChangedEvent, value); }
6199 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
6202 #endregion // Events