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;
152 #endregion // Local Variables
154 #region Private Classes
155 // This helper class allows us to dispatch messages to Control.WndProc
156 internal class ControlNativeWindow : NativeWindow {
157 private Control owner;
159 public ControlNativeWindow(Control control) : base() {
164 public Control Owner {
170 protected override void OnHandleChange()
172 this.owner.WindowTarget.OnHandleChange(this.owner.Handle);
175 static internal Control ControlFromHandle(IntPtr hWnd) {
176 ControlNativeWindow window;
178 window = (ControlNativeWindow)window_collection[hWnd];
179 if (window != null) {
186 static internal Control ControlFromChildHandle (IntPtr handle) {
187 ControlNativeWindow window;
189 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
190 while (hwnd != null) {
191 window = (ControlNativeWindow)window_collection[hwnd.Handle];
192 if (window != null) {
201 protected override void WndProc(ref Message m) {
202 owner.WindowTarget.OnMessage(ref m);
206 private class ControlWindowTarget : IWindowTarget
208 private Control control;
210 public ControlWindowTarget(Control control)
212 this.control = control;
215 public void OnHandleChange(IntPtr newHandle)
219 public void OnMessage(ref Message m)
221 control.WndProc(ref m);
226 #region Public Classes
228 public class ControlAccessibleObject : AccessibleObject {
231 #region ControlAccessibleObject Constructors
232 public ControlAccessibleObject(Control ownerControl)
233 : base (ownerControl)
235 if (ownerControl == null)
236 throw new ArgumentNullException ("owner");
238 handle = ownerControl.Handle;
240 #endregion // ControlAccessibleObject Constructors
242 #region ControlAccessibleObject Public Instance Properties
243 public override string DefaultAction {
245 return base.DefaultAction;
249 public override string Description {
251 return base.Description;
255 public IntPtr Handle {
261 // We don't want to let them set it
265 public override string Help {
271 public override string KeyboardShortcut {
273 return base.KeyboardShortcut;
277 public override string Name {
287 public Control Owner {
293 public override AccessibleObject Parent {
300 public override AccessibleRole Role {
305 #endregion // ControlAccessibleObject Public Instance Properties
307 #region ControlAccessibleObject Public Instance Methods
308 public override int GetHelpTopic(out string FileName) {
309 return base.GetHelpTopic (out FileName);
312 [MonoTODO ("Implement this")]
313 public void NotifyClients(AccessibleEvents accEvent) {
314 throw new NotImplementedException();
317 [MonoTODO ("Implement this")]
318 public void NotifyClients(AccessibleEvents accEvent, int childID) {
321 public override string ToString() {
322 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
325 #endregion // ControlAccessibleObject Public Instance Methods
328 private class DoubleBuffer : IDisposable
330 public Region InvalidRegion;
331 private Stack real_graphics;
332 private object back_buffer;
333 private Control parent;
334 private bool pending_disposal;
336 public DoubleBuffer (Control parent) {
337 this.parent = parent;
338 real_graphics = new Stack ();
339 int width = parent.Width;
340 int height = parent.Height;
342 if (width < 1) width = 1;
343 if (height < 1) height = 1;
345 XplatUI.CreateOffscreenDrawable (parent.Handle, width, height, out back_buffer);
349 public void Blit (PaintEventArgs pe) {
350 Graphics buffered_graphics;
351 buffered_graphics = XplatUI.GetOffscreenGraphics (back_buffer);
352 XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
353 buffered_graphics.Dispose ();
356 public void Start (PaintEventArgs pe) {
357 // We need to get the graphics for every paint.
358 real_graphics.Push(pe.SetGraphics (XplatUI.GetOffscreenGraphics (back_buffer)));
361 public void End (PaintEventArgs pe) {
362 Graphics buffered_graphics;
363 buffered_graphics = pe.SetGraphics ((Graphics) real_graphics.Pop ());
365 if (pending_disposal)
368 XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
369 InvalidRegion.Exclude (pe.ClipRectangle);
371 buffered_graphics.Dispose ();
374 public void Invalidate () {
375 if (InvalidRegion != null)
376 InvalidRegion.Dispose ();
377 InvalidRegion = new Region (parent.ClientRectangle);
380 public void Dispose () {
381 if (real_graphics.Count > 0) {
382 pending_disposal = true;
386 XplatUI.DestroyOffscreenDrawable (back_buffer);
388 if (InvalidRegion != null)
389 InvalidRegion.Dispose ();
390 InvalidRegion = null;
392 GC.SuppressFinalize (this);
395 #region IDisposable Members
396 void IDisposable.Dispose () {
406 [ListBindable (false)]
409 public class ControlCollection : Layout.ArrangedElementCollection, IList, ICollection, ICloneable, IEnumerable {
411 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
412 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
414 #region ControlCollection Local Variables
419 Control[] all_controls;
421 #endregion // ControlCollection Local Variables
423 #region ControlCollection Public Constructor
424 public ControlCollection(Control owner) {
427 this.list=new ArrayList();
432 #region ControlCollection Public Instance Properties
433 int ICollection.Count {
434 get { return Count; }
440 get { return list.Count; }
445 bool IList.IsReadOnly
447 public bool IsReadOnly
451 return list.IsReadOnly;
456 public Control Owner { get { return this.owner; } }
458 public virtual Control this[string key] {
460 int index = IndexOfKey (key);
471 public virtual Control this[int index] {
473 if (index < 0 || index >= list.Count) {
474 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
476 return (Control)list[index];
481 #endregion // ControlCollection Public Instance Properties
483 #region ControlCollection Instance Methods
484 public virtual void Add (Control value) {
488 Form form_value = value as Form;
489 Form form_owner = owner as Form;
490 bool owner_permits_toplevels = (owner is MdiClient) || (form_owner != null && form_owner.IsMdiContainer);
491 bool child_is_toplevel = value.GetTopLevel();
492 bool child_is_mdichild = form_value != null && form_value.IsMdiChild;
494 if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
495 throw new ArgumentException("Cannot add a top level control to a control.", "value");
497 if (child_is_mdichild && form_value.MdiParent != null && form_value.MdiParent != owner && form_value.MdiParent != owner.Parent) {
498 throw new ArgumentException ("Form cannot be added to the Controls collection that has a valid MDI parent.", "value");
501 if (Contains (value)) {
502 owner.PerformLayout();
506 if (value.tab_index == -1) {
512 end = owner.child_controls.Count;
513 for (int i = 0; i < end; i++) {
514 index = owner.child_controls[i].tab_index;
519 value.tab_index = use;
522 if (value.parent != null) {
523 value.parent.Controls.Remove(value);
529 value.ChangeParent(owner);
534 owner.UpdateChildrenZOrder();
535 owner.PerformLayout(value, "Parent");
536 owner.OnControlAdded(new ControlEventArgs(value));
539 internal void AddToList (Control c) {
544 internal virtual void AddImplicit (Control control) {
545 if (impl_list == null)
546 impl_list = new ArrayList ();
548 if (AllContains (control)) {
549 owner.PerformLayout ();
553 if (control.parent != null) {
554 control.parent.Controls.Remove(control);
558 impl_list.Add (control);
560 control.ChangeParent (owner);
561 control.InitLayout ();
563 owner.UpdateChildrenZOrder ();
565 // If we are adding a new control that isn't
566 // visible, don't trigger a layout
567 if (control.VisibleInternal)
568 owner.PerformLayout (control, "Parent");
571 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
573 public virtual void AddRange (Control[] controls) {
574 if (controls == null)
575 throw new ArgumentNullException ("controls");
577 owner.SuspendLayout ();
580 for (int i = 0; i < controls.Length; i++)
583 owner.ResumeLayout ();
587 internal virtual void AddRangeImplicit (Control [] controls) {
588 if (controls == null)
589 throw new ArgumentNullException ("controls");
591 owner.SuspendLayout ();
594 for (int i = 0; i < controls.Length; i++)
595 AddImplicit (controls [i]);
597 owner.ResumeLayout ();
604 public virtual void Clear () {
607 // MS sends remove events in reverse order
608 while (list.Count > 0) {
609 Remove((Control)list[list.Count - 1]);
613 internal virtual void ClearImplicit () {
614 if (impl_list == null)
620 public bool Contains (Control value) {
621 for (int i = list.Count; i > 0; ) {
624 if (list [i] == value) {
625 // Do we need to do anything here?
632 internal bool ImplicitContains (Control value) {
633 if (impl_list == null)
636 for (int i = impl_list.Count; i > 0; ) {
639 if (impl_list [i] == value) {
640 // Do we need to do anything here?
647 internal bool AllContains (Control value) {
648 return Contains (value) || ImplicitContains (value);
652 public virtual bool ContainsKey (string key)
654 return IndexOfKey (key) >= 0;
658 void ICollection.CopyTo (Array array, int index) {
659 CopyTo (array, index);
663 public void CopyTo (Array array, int index) {
664 list.CopyTo(array, index);
667 public override bool Equals (object other) {
668 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
677 // LAMESPEC: MSDN says AE, MS implementation throws ANE
678 public Control[] Find (string key, bool searchAllChildren)
680 if (string.IsNullOrEmpty (key))
681 throw new ArgumentNullException ("key");
683 ArrayList al = new ArrayList ();
685 foreach (Control c in list) {
686 if (c.Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
689 if (searchAllChildren)
690 al.AddRange (c.Controls.Find (key, true));
693 return (Control[])al.ToArray (typeof (Control));
697 public int GetChildIndex(Control child) {
698 return GetChildIndex(child, false);
706 GetChildIndex(Control child, bool throwException) {
709 index=list.IndexOf(child);
711 if (index==-1 && throwException) {
712 throw new ArgumentException("Not a child control", "child");
718 public override IEnumerator
723 return list.GetEnumerator();
726 internal IEnumerator GetAllEnumerator () {
727 Control [] res = GetAllControls ();
728 return res.GetEnumerator ();
731 internal Control [] GetAllControls () {
732 if (all_controls != null)
735 if (impl_list == null) {
736 all_controls = (Control []) list.ToArray (typeof (Control));
740 all_controls = new Control [list.Count + impl_list.Count];
741 impl_list.CopyTo (all_controls);
742 list.CopyTo (all_controls, impl_list.Count);
748 public override int GetHashCode() {
749 return base.GetHashCode();
753 public int IndexOf(Control control) {
754 return list.IndexOf(control);
758 public virtual int IndexOfKey (string key)
760 if (string.IsNullOrEmpty (key))
763 for (int i = 0; i < list.Count; i++)
764 if (((Control)list[i]).Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
771 public virtual void Remove(Control value) {
775 owner.PerformLayout(value, "Parent");
776 owner.OnControlRemoved(new ControlEventArgs(value));
781 value.ChangeParent(null);
783 owner.UpdateChildrenZOrder();
786 internal virtual void RemoveImplicit (Control control) {
787 if (impl_list != null) {
789 owner.PerformLayout (control, "Parent");
790 owner.OnControlRemoved (new ControlEventArgs (control));
791 impl_list.Remove (control);
793 control.ChangeParent (null);
794 owner.UpdateChildrenZOrder ();
800 public void RemoveAt(int index) {
801 if (index < 0 || index >= list.Count) {
802 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
804 Remove ((Control)list[index]);
808 public virtual void RemoveByKey (string key)
810 int index = IndexOfKey (key);
822 SetChildIndex(Control child, int newIndex) {
824 throw new ArgumentNullException ("child");
828 old_index=list.IndexOf(child);
830 throw new ArgumentException("Not a child control", "child");
833 if (old_index==newIndex) {
838 list.RemoveAt(old_index);
840 if (newIndex>list.Count) {
843 list.Insert(newIndex, child);
845 child.UpdateZOrder();
846 owner.PerformLayout();
848 #endregion // ControlCollection Private Instance Methods
850 #region ControlCollection Interface Properties
851 object IList.this[int index] {
853 if (index<0 || index>=list.Count) {
854 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
860 if (!(value is Control)) {
861 throw new ArgumentException("Object of type Control required", "value");
865 Control ctrl = (Control) value;
868 ctrl.ChangeParent(owner);
872 owner.UpdateChildrenZOrder();
873 owner.PerformLayout(ctrl, "Parent");
877 bool IList.IsFixedSize {
883 bool ICollection.IsSynchronized {
885 return list.IsSynchronized;
889 object ICollection.SyncRoot {
891 return list.SyncRoot;
894 #endregion // ControlCollection Interface Properties
896 #region ControlCollection Interface Methods
897 int IList.Add(object value) {
898 if (!(value is Control)) {
899 throw new ArgumentException("Object of type Control required", "value");
903 throw new ArgumentException("value", "Cannot add null controls");
906 bool owner_permits_toplevels = (owner is MdiClient) || (owner is Form && ((Form)owner).IsMdiContainer);
907 bool child_is_toplevel = ((Control)value).GetTopLevel();
908 bool child_is_mdichild = (value is Form && ((Form)value).IsMdiChild);
910 if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
911 throw new ArgumentException("Cannot add a top level control to a control.", "value");
913 return list.Add(value);
916 bool IList.Contains(object value) {
917 if (!(value is Control)) {
918 throw new ArgumentException("Object of type Control required", "value");
921 return this.Contains((Control) value);
924 int IList.IndexOf(object value) {
925 if (!(value is Control)) {
926 throw new ArgumentException("Object of type Control required", "value");
929 return this.IndexOf((Control) value);
932 void IList.Insert(int index, object value) {
933 if (!(value is Control)) {
934 throw new ArgumentException("Object of type Control required", "value");
937 list.Insert(index, value);
940 void IList.Remove(object value) {
941 if (!(value is Control)) {
942 throw new ArgumentException("Object of type Control required", "value");
948 Object ICloneable.Clone() {
949 ControlCollection clone = new ControlCollection(this.owner);
950 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
953 #endregion // ControlCollection Interface Methods
955 #endregion // ControlCollection Class
957 #region Public Constructors
960 layout_type = LayoutType.Anchor;
961 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
969 layout_pending = false;
971 causes_validation = true;
973 layout_suspended = 0;
977 right_to_left = RightToLeft.Inherit;
978 border_style = BorderStyle.None;
979 background_color = Color.Empty;
983 ime_mode = ImeMode.Inherit;
984 use_compatible_text_rendering = true;
987 backgroundimage_layout = ImageLayout.Tile;
988 use_compatible_text_rendering = Application.use_compatible_text_rendering;
989 padding = new Padding(0);
990 maximum_size = new Size();
991 minimum_size = new Size();
992 margin = this.DefaultMargin;
995 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
996 ControlStyles.Selectable | ControlStyles.StandardClick |
997 ControlStyles.StandardDoubleClick;
999 control_style |= ControlStyles.UseTextForAccessibility;
1003 background_image = null;
1004 text = string.Empty;
1005 name = string.Empty;
1007 window_target = new ControlWindowTarget(this);
1008 window = new ControlNativeWindow(this);
1009 child_controls = CreateControlsInstance();
1010 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
1011 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
1012 bounds.Size = InternalSizeFromClientSize (client_size);
1013 explicit_bounds = bounds;
1016 public Control (Control parent, string text) : this()
1022 public Control (Control parent, string text, int left, int top, int width, int height) : this()
1028 bounds.Height=height;
1029 SetBounds(left, top, width, height, BoundsSpecified.All);
1033 public Control (string text) : this()
1038 public Control (string text, int left, int top, int width, int height) : this()
1043 bounds.Height=height;
1044 SetBounds(left, top, width, height, BoundsSpecified.All);
1048 private delegate void RemoveDelegate(object c);
1050 protected override void Dispose (bool disposing)
1052 if (!is_disposed && disposing) {
1055 DisposeBackBuffer ();
1061 if (bmp_g != null) {
1066 if (this.InvokeRequired) {
1067 if (Application.MessageLoop && IsHandleCreated) {
1068 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null);
1074 if (parent != null) {
1075 parent.Controls.Remove(this);
1078 Control [] children = child_controls.GetAllControls ();
1079 for (int i=0; i<children.Length; i++) {
1080 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
1081 children[i].Dispose();
1086 base.Dispose(disposing);
1088 #endregion // Public Constructors
1090 #region Internal Properties
1091 // Control is currently selected, like Focused, except maintains state
1092 // when Form loses focus
1093 internal bool InternalSelected {
1095 IContainerControl container;
1097 container = GetContainerControl();
1099 if (container != null && container.ActiveControl == this)
1106 // Mouse is currently within the control's bounds
1107 internal bool Entered {
1108 get { return this.is_entered; }
1111 internal bool VisibleInternal {
1112 get { return is_visible; }
1115 internal LayoutType ControlLayoutType {
1116 get { return layout_type; }
1119 internal BorderStyle InternalBorderStyle {
1121 return border_style;
1125 if (!Enum.IsDefined (typeof (BorderStyle), value))
1126 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
1128 if (border_style != value) {
1129 border_style = value;
1131 if (IsHandleCreated) {
1132 XplatUI.SetBorderStyle (window.Handle, (FormBorderStyle)border_style);
1140 internal Size InternalClientSize { set { this.client_size = value; } }
1141 internal virtual bool ActivateOnShow { get { return true; } }
1142 #endregion // Internal Properties
1144 #region Private & Internal Methods
1147 void IDropTarget.OnDragDrop (DragEventArgs e)
1152 void IDropTarget.OnDragEnter (DragEventArgs e)
1157 void IDropTarget.OnDragLeave (EventArgs e)
1162 void IDropTarget.OnDragOver (DragEventArgs e)
1168 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
1169 return BeginInvokeInternal (method, args, FindControlToInvokeOn ());
1172 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, Control control) {
1173 AsyncMethodResult result;
1174 AsyncMethodData data;
1176 result = new AsyncMethodResult ();
1177 data = new AsyncMethodData ();
1179 data.Handle = control.Handle;
1180 data.Method = method;
1182 data.Result = result;
1185 if (!ExecutionContext.IsFlowSuppressed ()) {
1186 data.Context = ExecutionContext.Capture ();
1189 #if !MWF_ON_MSRUNTIME
1190 if (SecurityManager.SecurityEnabled) {
1191 data.Stack = CompressedStack.GetCompressedStack ();
1196 XplatUI.SendAsyncMethod (data);
1201 internal void PointToClient (ref int x, ref int y) {
1202 XplatUI.ScreenToClient (Handle, ref x, ref y);
1205 internal void PointToScreen (ref int x, ref int y) {
1206 XplatUI.ClientToScreen (Handle, ref x, ref y);
1209 internal bool IsRecreating {
1211 return is_recreating;
1215 internal Graphics DeviceContext {
1217 if (bmp_g == null) {
1218 bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
1219 bmp_g = Graphics.FromImage (bmp);
1225 private Control FindControlToInvokeOn ()
1229 if (p.IsHandleCreated)
1232 } while (p != null);
1234 if (p == null || !p.IsHandleCreated)
1235 throw new InvalidOperationException ("Cannot call Invoke or BeginInvoke on a control until the window handle is created");
1240 private void InvalidateBackBuffer () {
1241 if (backbuffer != null)
1242 backbuffer.Invalidate ();
1245 private DoubleBuffer GetBackBuffer () {
1246 if (backbuffer == null)
1247 backbuffer = new DoubleBuffer (this);
1251 private void DisposeBackBuffer () {
1252 if (backbuffer != null) {
1253 backbuffer.Dispose ();
1258 internal static void SetChildColor(Control parent) {
1261 for (int i=0; i < parent.child_controls.Count; i++) {
1262 child=parent.child_controls[i];
1263 if (child.child_controls.Count>0) {
1264 SetChildColor(child);
1269 internal bool Select(Control control) {
1270 IContainerControl container;
1272 if (control == null) {
1276 container = GetContainerControl();
1277 if (container != null && (Control)container != control) {
1278 container.ActiveControl = control;
1280 else if (control.IsHandleCreated) {
1281 XplatUI.SetFocus(control.window.Handle);
1286 internal virtual void DoDefaultAction() {
1287 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1290 internal static IntPtr MakeParam (int low, int high){
1291 return new IntPtr (high << 16 | low & 0xffff);
1294 internal static int LowOrder (int param) {
1295 return ((int)(short)(param & 0xffff));
1298 internal static int HighOrder (int param) {
1299 return ((int)(short)(param >> 16));
1302 // This method exists so controls overriding OnPaintBackground can have default background painting done
1303 internal virtual void PaintControlBackground (PaintEventArgs pevent) {
1304 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1305 if (parent != null) {
1306 PaintEventArgs parent_pe;
1307 GraphicsState state;
1309 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1311 state = parent_pe.Graphics.Save();
1312 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1313 parent.OnPaintBackground(parent_pe);
1314 parent_pe.Graphics.Restore(state);
1316 state = parent_pe.Graphics.Save();
1317 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1318 parent.OnPaint(parent_pe);
1319 parent_pe.Graphics.Restore(state);
1320 parent_pe.SetGraphics(null);
1324 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1325 if (parent != null) {
1326 PaintEventArgs parent_pe;
1328 GraphicsState state;
1331 hwnd = Hwnd.ObjectFromHandle(Handle);
1334 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1336 region = new Region ();
1338 region.Union(ClientRectangle);
1340 foreach (Rectangle r in hwnd.ClipRectangles) {
1344 state = parent_pe.Graphics.Save();
1345 parent_pe.Graphics.Clip = region;
1347 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1348 parent.OnPaintBackground(parent_pe);
1349 parent_pe.Graphics.Restore(state);
1351 state = parent_pe.Graphics.Save();
1352 parent_pe.Graphics.Clip = region;
1354 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1355 parent.OnPaint(parent_pe);
1356 parent_pe.Graphics.Restore(state);
1357 parent_pe.SetGraphics(null);
1359 region.Intersect(clip_region);
1360 pevent.Graphics.Clip = region;
1365 if (background_image == null) {
1366 pevent.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), new Rectangle(pevent.ClipRectangle.X - 1, pevent.ClipRectangle.Y - 1, pevent.ClipRectangle.Width + 2, pevent.ClipRectangle.Height + 2));
1370 DrawBackgroundImage (pevent.Graphics);
1373 void DrawBackgroundImage (Graphics g) {
1375 Rectangle drawing_rectangle = new Rectangle ();
1376 g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
1378 switch (backgroundimage_layout)
1380 case ImageLayout.Tile:
1381 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1382 g.FillRectangle (b, ClientRectangle);
1385 case ImageLayout.Center:
1386 drawing_rectangle.Location = new Point (ClientSize.Width / 2 - background_image.Width / 2, ClientSize.Height / 2 - background_image.Height / 2);
1387 drawing_rectangle.Size = background_image.Size;
1389 case ImageLayout.None:
1390 drawing_rectangle.Location = Point.Empty;
1391 drawing_rectangle.Size = background_image.Size;
1393 case ImageLayout.Stretch:
1394 drawing_rectangle = ClientRectangle;
1396 case ImageLayout.Zoom:
1397 drawing_rectangle = ClientRectangle;
1398 if ((float)background_image.Width / (float)background_image.Height < (float)drawing_rectangle.Width / (float) drawing_rectangle.Height) {
1399 drawing_rectangle.Width = (int) (background_image.Width * ((float)drawing_rectangle.Height / (float)background_image.Height));
1400 drawing_rectangle.X = (ClientRectangle.Width - drawing_rectangle.Width) / 2;
1402 drawing_rectangle.Height = (int) (background_image.Height * ((float)drawing_rectangle.Width / (float)background_image.Width));
1403 drawing_rectangle.Y = (ClientRectangle.Height - drawing_rectangle.Height) / 2;
1410 g.DrawImage (background_image, drawing_rectangle);
1413 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1414 g.FillRectangle (b, ClientRectangle);
1419 internal virtual void DndEnter (DragEventArgs e) {
1425 internal virtual void DndOver (DragEventArgs e) {
1431 internal virtual void DndDrop (DragEventArgs e) {
1434 } catch (Exception exc) {
1435 Console.Error.WriteLine ("MWF: Exception while dropping:");
1436 Console.Error.WriteLine (exc);
1440 internal virtual void DndLeave (EventArgs e) {
1446 internal virtual void DndFeedback(GiveFeedbackEventArgs e) {
1452 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e) {
1454 OnQueryContinueDrag(e);
1458 internal static MouseButtons FromParamToMouseButtons (int param) {
1459 MouseButtons buttons = MouseButtons.None;
1461 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1462 buttons |= MouseButtons.Left;
1464 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1465 buttons |= MouseButtons.Middle;
1467 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1468 buttons |= MouseButtons.Right;
1474 internal virtual void FireEnter () {
1475 OnEnter (EventArgs.Empty);
1478 internal virtual void FireLeave () {
1479 OnLeave (EventArgs.Empty);
1482 internal virtual void FireValidating (CancelEventArgs ce) {
1486 internal virtual void FireValidated () {
1487 OnValidated (EventArgs.Empty);
1490 internal virtual bool ProcessControlMnemonic(char charCode) {
1491 return ProcessMnemonic(charCode);
1494 private static Control FindFlatForward(Control container, Control start) {
1500 end = container.child_controls.Count;
1502 if (start != null) {
1503 index = start.tab_index;
1508 for (int i = 0, pos = -1; i < end; i++) {
1509 if (start == container.child_controls[i]) {
1514 if (found == null) {
1515 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1516 found = container.child_controls[i];
1518 } else if (found.tab_index > container.child_controls[i].tab_index) {
1519 if (container.child_controls[i].tab_index > index) {
1520 found = container.child_controls[i];
1527 private static Control FindControlForward(Control container, Control start) {
1532 if (start == null) {
1533 return FindFlatForward(container, start);
1536 if (start.child_controls != null && start.child_controls.Count > 0 &&
1537 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1538 return FindControlForward(start, null);
1541 while (start != container) {
1542 found = FindFlatForward(start.parent, start);
1543 if (found != null) {
1546 start = start.parent;
1552 private static Control FindFlatBackward(Control container, Control start) {
1558 end = container.child_controls.Count;
1560 if (start != null) {
1561 index = start.tab_index;
1563 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1565 for (int i = 0; i < end; i++) {
1566 if (container.child_controls[i].tab_index > index) {
1567 index = container.child_controls[i].tab_index;
1575 for (int i = end - 1; i >= 0; i--) {
1576 if (start == container.child_controls[i]) {
1581 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1582 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1583 found = container.child_controls[i];
1590 private static Control FindControlBackward(Control container, Control start) {
1592 Control found = null;
1594 if (start == null) {
1595 found = FindFlatBackward(container, start);
1597 else if (start != container) {
1598 if (start.parent != null) {
1599 found = FindFlatBackward(start.parent, start);
1601 if (found == null) {
1602 if (start.parent != container)
1603 return start.parent;
1609 if (found == null || start.parent == null)
1612 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1613 found.child_controls != null && found.child_controls.Count > 0)) {
1614 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1615 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1616 found = FindFlatBackward(found, null);
1626 if (start != null) {
1627 found = FindFlatBackward(start.parent, start);
1628 if (found == null) {
1629 if (start.parent != container) {
1630 return start.parent;
1634 if (found == null) {
1635 found = FindFlatBackward(container, start);
1638 if (container != start) {
1639 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1640 found = FindControlBackward(found, null);
1641 if (found != null) {
1650 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1651 if (GetStyle(ControlStyles.StandardClick)) {
1652 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1654 OnDoubleClick(EventArgs.Empty);
1656 OnClick(EventArgs.Empty);
1659 OnMouseDoubleClick (me);
1668 internal void CaptureWithConfine (Control ConfineWindow) {
1669 if (this.IsHandleCreated && !is_captured) {
1671 XplatUI.GrabWindow (this.window.Handle, ConfineWindow.Handle);
1675 private void CheckDataBindings () {
1676 if (data_bindings == null)
1679 BindingContext binding_context = BindingContext;
1680 foreach (Binding binding in data_bindings) {
1681 binding.Check (binding_context);
1685 private void ChangeParent(Control new_parent) {
1689 Color pre_fore_color;
1690 Color pre_back_color;
1691 RightToLeft pre_rtl;
1693 // These properties are inherited from our parent
1694 // Get them pre parent-change and then send events
1695 // if they are changed after we have our new parent
1696 pre_enabled = Enabled;
1697 pre_visible = Visible;
1699 pre_fore_color = ForeColor;
1700 pre_back_color = BackColor;
1701 pre_rtl = RightToLeft;
1702 // MS doesn't seem to send a CursorChangedEvent
1704 parent = new_parent;
1706 if (IsHandleCreated) {
1707 XplatUI.SetParent(Handle,
1708 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1709 if (this is Form ) {
1710 ((Form) this).ChangingParent (new_parent);
1714 OnParentChanged(EventArgs.Empty);
1716 if (pre_enabled != Enabled) {
1717 OnEnabledChanged(EventArgs.Empty);
1720 if (pre_visible != Visible) {
1721 OnVisibleChanged(EventArgs.Empty);
1724 if (pre_font != Font) {
1725 OnFontChanged(EventArgs.Empty);
1728 if (pre_fore_color != ForeColor) {
1729 OnForeColorChanged(EventArgs.Empty);
1732 if (pre_back_color != BackColor) {
1733 OnBackColorChanged(EventArgs.Empty);
1736 if (pre_rtl != RightToLeft) {
1737 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1738 // because when RTL changes they have to recreate the win32 control
1739 // We don't really need that (until someone runs into compatibility issues)
1740 OnRightToLeftChanged(EventArgs.Empty);
1743 if ((new_parent != null) && new_parent.Created && is_visible && !Created) {
1747 if ((binding_context == null) && Created) {
1748 OnBindingContextChanged(EventArgs.Empty);
1752 // Sometimes we need to do this calculation without it being virtual (constructor)
1753 internal Size InternalSizeFromClientSize (Size clientSize)
1755 Rectangle ClientRect;
1756 Rectangle WindowRect;
1759 ClientRect = new Rectangle (0, 0, clientSize.Width, clientSize.Height);
1760 cp = this.CreateParams;
1762 if (XplatUI.CalculateWindowRect (ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect))
1763 return new Size (WindowRect.Width, WindowRect.Height);
1768 private void UpdateDistances() {
1769 if (parent != null) {
1770 if (bounds.Width >= 0)
1771 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1772 if (bounds.Height >= 0)
1773 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1777 private bool UseDoubleBuffering {
1779 if (!ThemeEngine.Current.DoubleBufferingSupported)
1786 return (control_style & ControlStyles.DoubleBuffer) != 0;
1789 #endregion // Private & Internal Methods
1791 #region Public Static Properties
1792 public static Color DefaultBackColor {
1794 return ThemeEngine.Current.DefaultControlBackColor;
1798 public static Font DefaultFont {
1800 return ThemeEngine.Current.DefaultFont;
1804 public static Color DefaultForeColor {
1806 return ThemeEngine.Current.DefaultControlForeColor;
1810 public static Keys ModifierKeys {
1812 return XplatUI.State.ModifierKeys;
1816 public static MouseButtons MouseButtons {
1818 return XplatUI.State.MouseButtons;
1822 public static Point MousePosition {
1824 return Cursor.Position;
1829 [EditorBrowsable (EditorBrowsableState.Advanced)]
1830 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1833 public static bool CheckForIllegalCrossThreadCalls
1836 return verify_thread_handle;
1840 verify_thread_handle = value;
1844 #endregion // Public Static Properties
1846 #region Public Instance Properties
1847 [EditorBrowsable(EditorBrowsableState.Advanced)]
1849 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1850 public AccessibleObject AccessibilityObject {
1852 if (accessibility_object==null) {
1853 accessibility_object=CreateAccessibilityInstance();
1855 return accessibility_object;
1859 [EditorBrowsable(EditorBrowsableState.Advanced)]
1861 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1862 public string AccessibleDefaultActionDescription {
1864 if (accessibility_object != null)
1865 return accessibility_object.default_action;
1871 if (accessibility_object != null)
1872 accessibility_object.default_action = value;
1877 [DefaultValue(null)]
1878 [MWFCategory("Accessibility")]
1879 public string AccessibleDescription {
1881 if (accessibility_object != null)
1882 return accessibility_object.description;
1888 if (accessibility_object != null)
1889 accessibility_object.description = value;
1894 [DefaultValue(null)]
1895 [MWFCategory("Accessibility")]
1896 public string AccessibleName {
1898 if (accessibility_object != null)
1899 return accessibility_object.Name;
1905 if (accessibility_object != null)
1906 accessibility_object.Name = value;
1910 [DefaultValue(AccessibleRole.Default)]
1911 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1912 public AccessibleRole AccessibleRole {
1914 if (accessibility_object != null)
1915 return accessibility_object.role;
1917 return AccessibleRole.Default;
1921 if (accessibility_object != null)
1922 accessibility_object.role = value;
1926 [DefaultValue(false)]
1927 [MWFCategory("Behavior")]
1928 public virtual bool AllowDrop {
1934 if (allow_drop == value)
1937 if (IsHandleCreated) {
1939 XplatUI.SetAllowDrop (Handle, value);
1945 [RefreshProperties(RefreshProperties.Repaint)]
1946 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1947 [MWFCategory("Layout")]
1948 public virtual AnchorStyles Anchor {
1950 return anchor_style;
1954 layout_type = LayoutType.Anchor;
1956 if (anchor_style == value)
1960 dock_style = DockStyle.None;
1965 parent.PerformLayout(this, "Anchor");
1970 // XXX: Implement me!
1973 [RefreshProperties (RefreshProperties.All)]
1974 [Localizable (true)]
1975 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1977 [EditorBrowsable (EditorBrowsableState.Never)]
1978 [DefaultValue (false)]
1979 [MonoTODO("This method currently does nothing")]
1980 public virtual bool AutoSize {
1981 get { return auto_size; }
1983 if (this.auto_size != value) {
1985 OnAutoSizeChanged (EventArgs.Empty);
1991 [AmbientValue ("{Width=0, Height=0}")]
1993 [AmbientValue (typeof(Size), "0, 0")]
1995 public virtual Size MaximumSize {
1997 return maximum_size;
2000 if (maximum_size != value) {
2001 maximum_size = value;
2002 Size = PreferredSize;
2007 public virtual Size MinimumSize {
2009 return minimum_size;
2012 if (minimum_size != value) {
2013 minimum_size = value;
2014 Size = PreferredSize;
2021 [MWFCategory("Appearance")]
2022 public virtual Color BackColor {
2024 if (background_color.IsEmpty) {
2026 Color pcolor = parent.BackColor;
2027 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
2030 return DefaultBackColor;
2032 return background_color;
2036 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
2037 throw new ArgumentException("Transparent background colors are not supported on this control");
2040 if (background_color != value) {
2041 background_color=value;
2042 SetChildColor(this);
2043 OnBackColorChanged(EventArgs.Empty);
2050 [DefaultValue(null)]
2051 [MWFCategory("Appearance")]
2052 public virtual Image BackgroundImage {
2054 return background_image;
2058 if (background_image!=value) {
2059 background_image=value;
2060 OnBackgroundImageChanged(EventArgs.Empty);
2067 [DefaultValue (ImageLayout.Tile)]
2068 [Localizable (true)]
2069 public virtual ImageLayout BackgroundImageLayout {
2071 return backgroundimage_layout;
2074 if (Array.IndexOf (Enum.GetValues (typeof (ImageLayout)), value) == -1)
2075 throw new InvalidEnumArgumentException ("value", (int) value, typeof(ImageLayout));
2077 if (value != backgroundimage_layout) {
2078 backgroundimage_layout = value;
2080 OnBackgroundImageLayoutChanged (EventArgs.Empty);
2086 [EditorBrowsable(EditorBrowsableState.Advanced)]
2088 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2089 public virtual BindingContext BindingContext {
2091 if (binding_context != null)
2092 return binding_context;
2095 binding_context = Parent.BindingContext;
2096 return binding_context;
2099 if (binding_context != value) {
2100 binding_context = value;
2101 OnBindingContextChanged(EventArgs.Empty);
2106 [EditorBrowsable(EditorBrowsableState.Advanced)]
2108 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2111 return bounds.Y+bounds.Height;
2115 [EditorBrowsable(EditorBrowsableState.Advanced)]
2117 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2118 public Rectangle Bounds {
2124 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
2128 [EditorBrowsable(EditorBrowsableState.Advanced)]
2130 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2131 public bool CanFocus {
2133 if (IsHandleCreated && Visible && Enabled) {
2140 [EditorBrowsable(EditorBrowsableState.Advanced)]
2142 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2143 public bool CanSelect {
2147 if (!GetStyle(ControlStyles.Selectable)) {
2152 while (parent != null) {
2153 if (!parent.is_visible || !parent.is_enabled) {
2157 parent = parent.parent;
2163 internal virtual bool InternalCapture {
2173 [EditorBrowsable(EditorBrowsableState.Advanced)]
2175 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2176 public bool Capture {
2178 return this.is_captured;
2182 // Call OnMouseCaptureChanged when we get WM_CAPTURECHANGED.
2183 if (value != is_captured) {
2186 XplatUI.GrabWindow(Handle, IntPtr.Zero);
2188 if (IsHandleCreated)
2189 XplatUI.UngrabWindow(Handle);
2190 is_captured = false;
2196 [DefaultValue(true)]
2197 [MWFCategory("Focus")]
2198 public bool CausesValidation {
2200 return this.causes_validation;
2204 if (this.causes_validation != value) {
2205 causes_validation = value;
2206 OnCausesValidationChanged(EventArgs.Empty);
2211 [EditorBrowsable(EditorBrowsableState.Advanced)]
2213 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2214 public Rectangle ClientRectangle {
2216 client_rect.Width = client_size.Width;
2217 client_rect.Height = client_size.Height;
2222 [EditorBrowsable(EditorBrowsableState.Advanced)]
2224 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2225 public Size ClientSize {
2228 if ((this is Form) && (((Form)this).form_parent_window != null)) {
2229 return ((Form)this).form_parent_window.ClientSize;
2237 this.SetClientSizeCore(value.Width, value.Height);
2239 this.OnClientSizeChanged (EventArgs.Empty);
2244 [EditorBrowsable(EditorBrowsableState.Advanced)]
2246 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2247 [DescriptionAttribute("ControlCompanyNameDescr")]
2248 public String CompanyName {
2250 return "Mono Project, Novell, Inc.";
2254 [EditorBrowsable(EditorBrowsableState.Advanced)]
2256 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2257 public bool ContainsFocus {
2259 IntPtr focused_window;
2261 focused_window = XplatUI.GetFocus();
2262 if (IsHandleCreated) {
2263 if (focused_window == Handle) {
2267 for (int i=0; i < child_controls.Count; i++) {
2268 if (child_controls[i].ContainsFocus) {
2279 [DefaultValue(null)]
2280 [MWFCategory("Behavior")]
2281 public virtual ContextMenu ContextMenu {
2283 return GetContextMenuInternal ();
2287 if (context_menu != value) {
2288 context_menu = value;
2289 OnContextMenuChanged(EventArgs.Empty);
2294 internal virtual ContextMenu GetContextMenuInternal () {
2295 return context_menu;
2299 [DefaultValue (null)]
2300 public virtual ContextMenuStrip ContextMenuStrip {
2301 get { return this.context_menu_strip; }
2303 if (this.context_menu_strip != value) {
2304 this.context_menu_strip = value;
2305 OnContextMenuStripChanged (EventArgs.Empty);
2312 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2313 public ControlCollection Controls {
2315 return this.child_controls;
2319 [EditorBrowsable(EditorBrowsableState.Advanced)]
2321 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2322 public bool Created {
2324 return (!is_disposed && is_created);
2328 [AmbientValue(null)]
2329 [MWFCategory("Appearance")]
2330 public virtual Cursor Cursor {
2332 if (cursor != null) {
2336 if (parent != null) {
2337 return parent.Cursor;
2340 return Cursors.Default;
2344 if (cursor != value) {
2349 if (IsHandleCreated) {
2350 pt = Cursor.Position;
2352 if (bounds.Contains(pt) || Capture) {
2353 if (GetChildAtPoint(pt) == null) {
2354 if (cursor != null) {
2355 XplatUI.SetCursor(window.Handle, cursor.handle);
2357 if (parent != null) {
2358 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
2360 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
2367 OnCursorChanged(EventArgs.Empty);
2373 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2374 [ParenthesizePropertyName(true)]
2375 [RefreshProperties(RefreshProperties.All)]
2376 [MWFCategory("Data")]
2377 public ControlBindingsCollection DataBindings {
2379 if (data_bindings == null)
2380 data_bindings = new ControlBindingsCollection (this);
2381 return data_bindings;
2385 [EditorBrowsable(EditorBrowsableState.Advanced)]
2387 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2388 public virtual Rectangle DisplayRectangle {
2390 return ClientRectangle;
2394 [EditorBrowsable(EditorBrowsableState.Advanced)]
2396 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2397 public bool Disposing {
2404 [RefreshProperties(RefreshProperties.Repaint)]
2405 [DefaultValue(DockStyle.None)]
2406 [MWFCategory("Layout")]
2407 public virtual DockStyle Dock {
2413 layout_type = LayoutType.Dock;
2415 if (dock_style == value) {
2419 if (!Enum.IsDefined (typeof (DockStyle), value)) {
2420 throw new InvalidEnumArgumentException ("value", (int) value,
2421 typeof (DockStyle));
2425 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
2427 if (dock_style == DockStyle.None) {
2428 if (explicit_bounds == Rectangle.Empty)
2429 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
2431 Bounds = explicit_bounds;
2434 if (parent != null) {
2435 parent.PerformLayout(this, "Dock");
2438 OnDockChanged(EventArgs.Empty);
2443 protected virtual bool DoubleBuffered {
2445 return (control_style & ControlStyles.OptimizedDoubleBuffer) != 0;
2449 if (value == DoubleBuffered)
2452 SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
2454 SetStyle (ControlStyles.OptimizedDoubleBuffer, false);
2463 [MWFCategory("Behavior")]
2464 public bool Enabled {
2470 if (parent != null) {
2471 return parent.Enabled;
2478 if (this.is_enabled != value) {
2479 bool old_value = is_enabled;
2482 if (old_value != value && !value && this.has_focus)
2483 SelectNextControl(this, true, true, true, true);
2485 OnEnabledChanged (EventArgs.Empty);
2490 [EditorBrowsable(EditorBrowsableState.Advanced)]
2492 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2493 public virtual bool Focused {
2495 return this.has_focus;
2500 [AmbientValue(null)]
2502 [MWFCategory("Appearance")]
2503 public virtual Font Font {
2509 if (Parent != null && Parent.Font != null) {
2516 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2518 if (font != null && font.Equals (value)) {
2524 OnFontChanged (EventArgs.Empty);
2530 [MWFCategory("Appearance")]
2531 public virtual Color ForeColor {
2533 if (foreground_color.IsEmpty) {
2535 return parent.ForeColor;
2537 return DefaultForeColor;
2539 return foreground_color;
2543 if (foreground_color != value) {
2544 foreground_color=value;
2546 OnForeColorChanged(EventArgs.Empty);
2553 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2554 public IntPtr Handle { // IWin32Window
2557 if (verify_thread_handle) {
2558 if (this.InvokeRequired) {
2559 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2563 if (!IsHandleCreated) {
2566 return window.Handle;
2570 [EditorBrowsable(EditorBrowsableState.Advanced)]
2572 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2573 public bool HasChildren {
2575 if (this.child_controls.Count>0) {
2582 [EditorBrowsable(EditorBrowsableState.Always)]
2584 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2587 return this.bounds.Height;
2591 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2595 [AmbientValue(ImeMode.Inherit)]
2597 [MWFCategory("Behavior")]
2598 public ImeMode ImeMode {
2600 if (ime_mode == ImeMode.Inherit) {
2602 return parent.ImeMode;
2604 return ImeMode.NoControl; // default value
2610 if (ime_mode != value) {
2613 OnImeModeChanged(EventArgs.Empty);
2618 [EditorBrowsable(EditorBrowsableState.Advanced)]
2620 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2621 public bool InvokeRequired { // ISynchronizeInvoke
2623 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2630 [EditorBrowsable(EditorBrowsableState.Advanced)]
2632 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2633 public bool IsAccessible {
2635 return is_accessible;
2639 is_accessible = value;
2643 [EditorBrowsable(EditorBrowsableState.Advanced)]
2645 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2646 public bool IsDisposed {
2648 return this.is_disposed;
2652 [EditorBrowsable(EditorBrowsableState.Advanced)]
2654 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2655 public bool IsHandleCreated {
2657 if (window == null || window.Handle == IntPtr.Zero)
2660 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2661 if (hwnd != null && hwnd.zombie)
2669 [EditorBrowsable (EditorBrowsableState.Advanced)]
2673 Layout.LayoutEngine LayoutEngine {
2675 if (layout_engine == null)
2676 layout_engine = new Layout.DefaultLayout ();
2677 return layout_engine;
2681 [EditorBrowsable(EditorBrowsableState.Always)]
2683 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2686 return this.bounds.X;
2690 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2695 [MWFCategory("Layout")]
2696 public Point Location {
2698 return new Point(bounds.X, bounds.Y);
2702 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2707 [Localizable (true)]
2708 public Padding Margin {
2709 get { return this.margin; }
2711 if (this.margin != value) {
2712 this.margin = value;
2713 OnMarginChanged (EventArgs.Empty);
2720 public string Name {
2732 public Padding Padding {
2738 if (padding != value) {
2740 OnPaddingChanged (EventArgs.Empty);
2748 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2749 public Control Parent {
2755 if (value == this) {
2756 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2759 if (parent!=value) {
2761 parent.Controls.Remove(this);
2766 value.Controls.Add(this);
2773 public Size PreferredSize {
2774 get { return this.GetPreferredSize (Size.Empty); }
2778 [EditorBrowsable(EditorBrowsableState.Advanced)]
2780 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2781 public string ProductName {
2783 Type t = typeof (AssemblyProductAttribute);
2784 Assembly assembly = GetType().Module.Assembly;
2785 object [] attrs = assembly.GetCustomAttributes (t, false);
2786 AssemblyProductAttribute a = null;
2787 // On MS we get a NullRefException if product attribute is not
2789 if (attrs != null && attrs.Length > 0)
2790 a = (AssemblyProductAttribute) attrs [0];
2792 return GetType ().Namespace;
2798 [EditorBrowsable(EditorBrowsableState.Advanced)]
2800 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2801 public string ProductVersion {
2803 Type t = typeof (AssemblyVersionAttribute);
2804 Assembly assembly = GetType().Module.Assembly;
2805 object [] attrs = assembly.GetCustomAttributes (t, false);
2806 if (attrs == null || attrs.Length < 1)
2808 return ((AssemblyVersionAttribute)attrs [0]).Version;
2812 [EditorBrowsable(EditorBrowsableState.Advanced)]
2814 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2815 public bool RecreatingHandle {
2817 return is_recreating;
2821 [EditorBrowsable(EditorBrowsableState.Advanced)]
2823 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2824 public Region Region {
2830 if (clip_region != value) {
2831 if (value != null && IsHandleCreated)
2832 XplatUI.SetClipRegion(Handle, value);
2834 clip_region = value;
2836 OnRegionChanged (EventArgs.Empty);
2842 [EditorBrowsable(EditorBrowsableState.Advanced)]
2844 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2847 return this.bounds.X+this.bounds.Width;
2851 [AmbientValue(RightToLeft.Inherit)]
2853 [MWFCategory("Appearance")]
2854 public virtual RightToLeft RightToLeft {
2856 if (right_to_left == RightToLeft.Inherit) {
2858 return parent.RightToLeft;
2860 return RightToLeft.No; // default value
2862 return right_to_left;
2866 if (value != right_to_left) {
2867 right_to_left = value;
2868 OnRightToLeftChanged(EventArgs.Empty);
2874 [EditorBrowsable(EditorBrowsableState.Advanced)]
2875 public override ISite Site {
2883 if (value != null) {
2884 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2886 BackColor = ap.BackColor;
2887 ForeColor = ap.ForeColor;
2896 [MWFCategory("Layout")]
2899 return new Size(Width, Height);
2903 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2908 [MergableProperty(false)]
2909 [MWFCategory("Behavior")]
2910 public int TabIndex {
2912 if (tab_index != -1) {
2919 if (tab_index != value) {
2921 OnTabIndexChanged(EventArgs.Empty);
2927 [DefaultValue(true)]
2928 [MWFCategory("Behavior")]
2929 public bool TabStop {
2935 if (tab_stop != value) {
2937 OnTabStopChanged(EventArgs.Empty);
2942 [Localizable(false)]
2944 [TypeConverter(typeof(StringConverter))]
2945 [DefaultValue(null)]
2946 [MWFCategory("Data")]
2953 control_tag = value;
2959 [BindableAttribute(true)]
2960 [MWFCategory("Appearance")]
2961 public virtual string Text {
2963 // Our implementation ignores ControlStyles.CacheText - we always cache
2968 if (value == null) {
2969 value = String.Empty;
2974 if (IsHandleCreated) {
2975 /* we need to call .SetWindowStyle here instead of just .Text
2976 because the presence/absence of Text (== "" or not) can cause
2977 other window style things to appear/disappear */
2978 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2979 XplatUI.Text(Handle, text);
2981 OnTextChanged (EventArgs.Empty);
2986 [EditorBrowsable(EditorBrowsableState.Always)]
2988 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2991 return this.bounds.Y;
2995 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2999 [EditorBrowsable(EditorBrowsableState.Advanced)]
3001 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3002 public Control TopLevelControl {
3006 while (p.parent != null) {
3010 return p is Form ? p : null;
3015 [MWFCategory("Behavior")]
3016 public bool Visible {
3020 } else if (parent != null) {
3021 return parent.Visible;
3028 SetVisibleCore(value);
3032 [EditorBrowsable(EditorBrowsableState.Always)]
3034 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3037 return this.bounds.Width;
3041 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
3045 [EditorBrowsable(EditorBrowsableState.Never)]
3047 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3048 public IWindowTarget WindowTarget {
3049 get { return window_target; }
3050 set { window_target = value; }
3052 #endregion // Public Instance Properties
3054 #region Protected Instance Properties
3055 protected virtual CreateParams CreateParams {
3057 CreateParams create_params = new CreateParams();
3060 create_params.Caption = Text;
3063 create_params.Caption = text;
3067 create_params.X = Left;
3070 create_params.X = this.bounds.X;
3074 create_params.Y = Top;
3077 create_params.Y = this.bounds.Y;
3081 create_params.Width = Width;
3084 create_params.Width = this.bounds.Width;
3088 create_params.Height = Height;
3091 create_params.Height = this.bounds.Height;
3095 create_params.ClassName = XplatUI.DefaultClassName;
3096 create_params.ClassStyle = (int)(XplatUIWin32.ClassStyle.CS_OWNDC | XplatUIWin32.ClassStyle.CS_DBLCLKS);
3097 create_params.ExStyle = 0;
3098 create_params.Param = 0;
3101 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
3104 if ((parent!=null) && (parent.IsHandleCreated)) {
3105 create_params.Parent = parent.Handle;
3108 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
3111 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
3115 create_params.Style |= (int)WindowStyles.WS_DISABLED;
3118 switch (border_style) {
3119 case BorderStyle.FixedSingle:
3120 create_params.Style |= (int) WindowStyles.WS_BORDER;
3122 case BorderStyle.Fixed3D:
3123 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
3127 return create_params;
3132 protected virtual Cursor DefaultCursor { get { return Cursors.Default; } }
3135 protected virtual ImeMode DefaultImeMode {
3137 return ImeMode.Inherit;
3142 protected virtual Padding DefaultMargin {
3143 get { return new Padding (3); }
3146 protected virtual Size DefaultMaximumSize { get { return new Size (); } }
3147 protected virtual Size DefaultMinimumSize { get { return new Size (); } }
3148 protected virtual Padding DefaultPadding { get { return new Padding (); } }
3151 protected virtual Size DefaultSize {
3153 return new Size(0, 0);
3157 protected int FontHeight {
3169 protected bool RenderRightToLeft {
3171 return (this.right_to_left == RightToLeft.Yes);
3175 protected bool ResizeRedraw {
3177 return GetStyle(ControlStyles.ResizeRedraw);
3181 SetStyle(ControlStyles.ResizeRedraw, value);
3185 [EditorBrowsable(EditorBrowsableState.Advanced)]
3187 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3188 protected virtual bool ShowFocusCues {
3194 [EditorBrowsable(EditorBrowsableState.Advanced)]
3196 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3200 protected bool ShowKeyboardCues {
3205 #endregion // Protected Instance Properties
3207 #region Public Static Methods
3208 [EditorBrowsable(EditorBrowsableState.Advanced)]
3209 public static Control FromChildHandle(IntPtr handle) {
3210 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
3213 [EditorBrowsable(EditorBrowsableState.Advanced)]
3214 public static Control FromHandle(IntPtr handle) {
3215 return Control.ControlNativeWindow.ControlFromHandle(handle);
3218 public static bool IsMnemonic(char charCode, string text) {
3221 amp = text.IndexOf('&');
3224 if (amp + 1 < text.Length) {
3225 if (text[amp + 1] != '&') {
3226 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
3236 #region Protected Static Methods
3237 [EditorBrowsable(EditorBrowsableState.Advanced)]
3238 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
3241 c = Control.FromHandle(hWnd);
3251 #region Public Instance Methods
3252 [EditorBrowsable(EditorBrowsableState.Advanced)]
3253 public IAsyncResult BeginInvoke(Delegate method) {
3254 object [] prms = null;
3255 if (method is EventHandler)
3256 prms = new object [] { this, EventArgs.Empty };
3257 return BeginInvokeInternal(method, prms);
3260 [EditorBrowsable(EditorBrowsableState.Advanced)]
3262 public IAsyncResult BeginInvoke (Delegate method, params object[] args)
3264 public IAsyncResult BeginInvoke (Delegate method, object[] args)
3267 return BeginInvokeInternal (method, args);
3270 public void BringToFront() {
3271 if (parent != null) {
3272 parent.child_controls.SetChildIndex(this, 0);
3274 else if (IsHandleCreated) {
3275 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
3279 public bool Contains(Control ctl) {
3280 while (ctl != null) {
3289 public void CreateControl () {
3291 throw new ObjectDisposedException(GetType().FullName.ToString());
3301 if (!IsHandleCreated) {
3308 if (binding_context == null) { // seem to be sent whenever it's null?
3309 OnBindingContextChanged(EventArgs.Empty);
3316 public Graphics CreateGraphics() {
3317 if (!IsHandleCreated) {
3318 this.CreateHandle();
3320 return Graphics.FromHwnd(this.window.Handle);
3323 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
3324 if (IsHandleCreated)
3325 return XplatUI.StartDrag(Handle, data, allowedEffects);
3327 return DragDropEffects.None;
3330 [EditorBrowsable(EditorBrowsableState.Advanced)]
3331 public object EndInvoke (IAsyncResult async_result) {
3332 AsyncMethodResult result = (AsyncMethodResult) async_result;
3333 return result.EndInvoke ();
3336 public Form FindForm() {
3349 [EditorBrowsable (EditorBrowsableState.Advanced)]
3351 public bool Focus() {
3352 return FocusInternal (false);
3355 internal virtual bool FocusInternal (bool skip_check) {
3356 if (skip_check || (CanFocus && IsHandleCreated && !has_focus && !is_focusing)) {
3359 is_focusing = false;
3364 public Control GetChildAtPoint(Point pt) {
3365 // MS's version causes the handle to be created. The stack trace shows that get_Handle is called here, but
3366 // we'll just call CreateHandle instead.
3369 // Microsoft's version of this function doesn't seem to work, so I can't check
3370 // if we only consider children or also grandchildren, etc.
3371 // I'm gonna say 'children only'
3372 for (int i=0; i<child_controls.Count; i++) {
3373 if (child_controls[i].Bounds.Contains(pt)) {
3374 return child_controls[i];
3380 public IContainerControl GetContainerControl() {
3381 Control current = this;
3383 while (current!=null) {
3384 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
3385 return (IContainerControl)current;
3387 current = current.parent;
3392 public Control GetNextControl(Control ctl, bool forward) {
3394 if (!this.Contains(ctl)) {
3399 ctl = FindControlForward(this, ctl);
3402 ctl = FindControlBackward(this, ctl);
3412 [EditorBrowsable (EditorBrowsableState.Advanced)]
3413 public virtual Size GetPreferredSize (Size proposedSize) {
3414 Size retsize = this.explicit_bounds.Size;
3416 // If we're bigger than the MaximumSize, fix that
3417 if (this.maximum_size.Width != 0 && retsize.Width > this.maximum_size.Width)
3418 retsize.Width = this.maximum_size.Width;
3419 if (this.maximum_size.Height != 0 && retsize.Height > this.maximum_size.Height)
3420 retsize.Height = this.maximum_size.Height;
3422 // If we're smaller than the MinimumSize, fix that
3423 if (this.minimum_size.Width != 0 && retsize.Width < this.minimum_size.Width)
3424 retsize.Width = this.minimum_size.Width;
3425 if (this.minimum_size.Height != 0 && retsize.Height < this.minimum_size.Height)
3426 retsize.Height = this.minimum_size.Height;
3432 public void Hide() {
3433 this.Visible = false;
3436 public void Invalidate() {
3437 Invalidate(ClientRectangle, false);
3440 public void Invalidate(bool invalidateChildren) {
3441 Invalidate(ClientRectangle, invalidateChildren);
3444 public void Invalidate(System.Drawing.Rectangle rc) {
3445 Invalidate(rc, false);
3448 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
3449 // Win32 invalidates control including when Width and Height is equal 0
3450 // or is not visible, only Paint event must be care about this.
3451 if (!IsHandleCreated)
3454 if (rc.Width > 0 && rc.Height > 0) {
3456 NotifyInvalidate(rc);
3458 XplatUI.Invalidate(Handle, rc, false);
3460 if (invalidateChildren) {
3461 Control [] controls = child_controls.GetAllControls ();
3462 for (int i=0; i<controls.Length; i++)
3463 controls [i].Invalidate ();
3466 OnInvalidated(new InvalidateEventArgs(rc));
3469 public void Invalidate(System.Drawing.Region region) {
3470 Invalidate(region, false);
3473 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
3474 RectangleF bounds = region.GetBounds (CreateGraphics ());
3475 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
3476 invalidateChildren);
3479 public object Invoke (Delegate method) {
3480 object [] prms = null;
3481 if (method is EventHandler)
3482 prms = new object [] { this, EventArgs.Empty };
3484 return Invoke(method, prms);
3487 public object Invoke (Delegate method, params object [] args) {
3489 public object Invoke (Delegate method, object[] args) {
3491 Control control = FindControlToInvokeOn ();
3493 if (!this.InvokeRequired) {
3494 return method.DynamicInvoke(args);
3497 IAsyncResult result = BeginInvokeInternal (method, args, control);
3498 return EndInvoke(result);
3501 [EditorBrowsable(EditorBrowsableState.Advanced)]
3502 public void PerformLayout() {
3503 PerformLayout(null, null);
3506 internal void SetImplicitBounds (int x, int y, int width, int height) {
3507 Rectangle saved_bounds = explicit_bounds;
3508 SetBounds (x, y, width, height);
3509 explicit_bounds = saved_bounds;
3512 [EditorBrowsable(EditorBrowsableState.Advanced)]
3513 public void PerformLayout(Control affectedControl, string affectedProperty) {
3514 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
3516 if (layout_suspended > 0) {
3517 layout_pending = true;
3521 layout_pending = false;
3523 // Prevent us from getting messed up
3526 // Perform all Dock and Anchor calculations
3531 // Need to make sure we decremend layout_suspended
3537 public Point PointToClient (Point p) {
3541 XplatUI.ScreenToClient (Handle, ref x, ref y);
3543 return new Point (x, y);
3546 public Point PointToScreen(Point p) {
3550 XplatUI.ClientToScreen(Handle, ref x, ref y);
3552 return new Point(x, y);
3555 public virtual bool PreProcessMessage(ref Message msg) {
3556 return InternalPreProcessMessage (ref msg);
3559 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3562 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3563 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3565 if (!ProcessCmdKey(ref msg, key_data)) {
3566 if (IsInputKey(key_data)) {
3570 return ProcessDialogKey(key_data);
3574 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3575 if (IsInputChar((char)msg.WParam)) {
3578 return ProcessDialogChar((char)msg.WParam);
3579 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3580 return ProcessDialogChar((char)msg.WParam);
3585 public Rectangle RectangleToClient(Rectangle r) {
3586 return new Rectangle(PointToClient(r.Location), r.Size);
3589 public Rectangle RectangleToScreen(Rectangle r) {
3590 return new Rectangle(PointToScreen(r.Location), r.Size);
3593 public virtual void Refresh() {
3594 if (IsHandleCreated && Visible) {
3596 XplatUI.UpdateWindow(window.Handle);
3598 Control [] controls = child_controls.GetAllControls ();
3599 for (int i=0; i < controls.Length; i++) {
3600 controls[i].Refresh();
3606 [EditorBrowsable(EditorBrowsableState.Never)]
3607 public virtual void ResetBackColor() {
3608 BackColor = Color.Empty;
3611 [EditorBrowsable(EditorBrowsableState.Never)]
3612 public void ResetBindings() {
3613 if (data_bindings != null)
3614 data_bindings.Clear();
3617 [EditorBrowsable(EditorBrowsableState.Never)]
3618 public virtual void ResetCursor() {
3622 [EditorBrowsable(EditorBrowsableState.Never)]
3623 public virtual void ResetFont() {
3627 [EditorBrowsable(EditorBrowsableState.Never)]
3628 public virtual void ResetForeColor() {
3629 foreground_color = Color.Empty;
3632 [EditorBrowsable(EditorBrowsableState.Never)]
3633 public void ResetImeMode() {
3634 ime_mode = DefaultImeMode;
3637 [EditorBrowsable(EditorBrowsableState.Never)]
3638 public virtual void ResetRightToLeft() {
3639 right_to_left = RightToLeft.Inherit;
3642 public virtual void ResetText() {
3643 text = String.Empty;
3646 public void ResumeLayout() {
3647 ResumeLayout (true);
3650 public void ResumeLayout(bool performLayout) {
3651 if (layout_suspended > 0) {
3655 if (layout_suspended == 0) {
3656 if (performLayout && layout_pending) {
3662 [EditorBrowsable (EditorBrowsableState.Never)]
3665 public void Scale(float ratio) {
3666 ScaleCore(ratio, ratio);
3670 [EditorBrowsable (EditorBrowsableState.Never)]
3673 public void Scale(float dx, float dy) {
3678 [EditorBrowsable (EditorBrowsableState.Advanced)]
3679 public void Scale(SizeF factor) {
3680 ScaleCore(factor.Width, factor.Height);
3684 public void Select() {
3685 Select(false, false);
3689 private void printTree(Control c, string t) {
3690 foreach(Control i in c.child_controls) {
3691 Console.WriteLine ("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3692 printTree (i, t+"\t");
3696 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3700 Console.WriteLine("{0}", this.FindForm());
3701 printTree(this, "\t");
3704 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3709 c = GetNextControl(c, forward);
3718 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3719 c.Select (true, true);
3722 } while (c != ctl); // If we wrap back to ourselves we stop
3727 public void SendToBack() {
3728 if (parent != null) {
3729 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3733 public void SetBounds(int x, int y, int width, int height) {
3734 SetBounds(x, y, width, height, BoundsSpecified.All);
3737 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3738 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3742 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3746 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3750 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3754 SetBoundsCore(x, y, width, height, specified);
3756 parent.PerformLayout(this, "Bounds");
3759 public void Show () {
3760 this.Visible = true;
3763 public void SuspendLayout() {
3767 public void Update() {
3768 if (IsHandleCreated) {
3769 XplatUI.UpdateWindow(window.Handle);
3772 #endregion // Public Instance Methods
3774 #region Protected Instance Methods
3775 [EditorBrowsable(EditorBrowsableState.Advanced)]
3776 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3777 // turns out this method causes handle
3778 // creation in 1.1. at first I thought this
3779 // would be accomplished just by using
3780 // get_AccessibilityObject, which would route
3781 // through CreateAccessibilityInstance, which
3782 // calls CreateControl. This isn't the case,
3783 // though (as overriding
3784 // CreateAccessibilityInstance and adding a
3785 // CWL shows nothing. So we fudge it and put
3786 // a CreateHandle here.
3792 if (accessibility_object != null && accessibility_object is ControlAccessibleObject)
3793 ((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, childID);
3796 [EditorBrowsable(EditorBrowsableState.Advanced)]
3797 protected virtual AccessibleObject CreateAccessibilityInstance() {
3799 return new Control.ControlAccessibleObject(this);
3802 [EditorBrowsable(EditorBrowsableState.Advanced)]
3803 protected virtual ControlCollection CreateControlsInstance() {
3804 return new ControlCollection(this);
3807 [EditorBrowsable(EditorBrowsableState.Advanced)]
3808 protected virtual void CreateHandle() {
3810 throw new ObjectDisposedException(GetType().FullName.ToString());
3813 if (IsHandleCreated && !is_recreating) {
3817 CreateParams create_params = CreateParams;
3818 window.CreateHandle(create_params);
3820 if (window.Handle != IntPtr.Zero) {
3821 creator_thread = Thread.CurrentThread;
3823 XplatUI.EnableWindow(window.Handle, is_enabled);
3825 if (clip_region != null) {
3826 XplatUI.SetClipRegion(window.Handle, clip_region);
3829 // Set our handle with our parent
3830 if ((parent != null) && (parent.IsHandleCreated)) {
3831 XplatUI.SetParent(window.Handle, parent.Handle);
3835 XplatUI.SetAllowDrop (window.Handle, allow_drop);
3837 // Find out where the window manager placed us
3838 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3839 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3845 [EditorBrowsable(EditorBrowsableState.Advanced)]
3846 protected virtual void DefWndProc(ref Message m) {
3847 window.DefWndProc(ref m);
3850 [EditorBrowsable(EditorBrowsableState.Advanced)]
3851 protected virtual void DestroyHandle() {
3852 if (IsHandleCreated) {
3853 if (window != null) {
3854 window.DestroyHandle();
3860 protected virtual AccessibleObject GetAccessibilityObjectById (int objectId)
3862 // XXX need to implement this.
3867 protected internal bool GetStyle(ControlStyles flag) {
3868 return (control_style & flag) != 0;
3871 protected bool GetTopLevel() {
3875 [EditorBrowsable(EditorBrowsableState.Advanced)]
3876 protected virtual void InitLayout() {
3880 [EditorBrowsable(EditorBrowsableState.Advanced)]
3881 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3882 toInvoke.OnGotFocus(e);
3885 [EditorBrowsable(EditorBrowsableState.Advanced)]
3886 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3887 toInvoke.OnLostFocus(e);
3890 [EditorBrowsable(EditorBrowsableState.Advanced)]
3891 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3892 toInvoke.OnClick(e);
3895 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3896 toInvoke.OnPaint(e);
3899 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3900 toInvoke.OnPaintBackground(e);
3903 protected virtual bool IsInputChar (char charCode) {
3904 // XXX on MS.NET this method causes the handle to be created..
3910 protected virtual bool IsInputKey (Keys keyData) {
3911 // Doc says this one calls IsInputChar; not sure what to do with that
3915 [EditorBrowsable(EditorBrowsableState.Advanced)]
3916 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3920 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3921 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3925 if (parent != null) {
3926 return parent.ProcessCmdKey(ref msg, keyData);
3932 protected virtual bool ProcessDialogChar(char charCode) {
3933 if (parent != null) {
3934 return parent.ProcessDialogChar (charCode);
3940 protected virtual bool ProcessDialogKey (Keys keyData) {
3941 if (parent != null) {
3942 return parent.ProcessDialogKey (keyData);
3948 protected virtual bool ProcessKeyEventArgs (ref Message msg) {
3949 KeyEventArgs key_event;
3952 case (int)Msg.WM_SYSKEYDOWN:
3953 case (int)Msg.WM_KEYDOWN: {
3954 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3955 OnKeyDown (key_event);
3956 return key_event.Handled;
3959 case (int)Msg.WM_SYSKEYUP:
3960 case (int)Msg.WM_KEYUP: {
3961 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3962 OnKeyUp (key_event);
3963 return key_event.Handled;
3966 case (int)Msg.WM_SYSCHAR:
3967 case (int)Msg.WM_CHAR: {
3968 KeyPressEventArgs key_press_event;
3970 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3971 OnKeyPress(key_press_event);
3973 msg.WParam = (IntPtr)key_press_event.KeyChar;
3975 return key_press_event.Handled;
3986 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3987 if (parent != null) {
3988 if (parent.ProcessKeyPreview(ref msg)) {
3993 return ProcessKeyEventArgs(ref msg);
3996 protected virtual bool ProcessKeyPreview(ref Message msg) {
3997 if (parent != null) {
3998 return parent.ProcessKeyPreview(ref msg);
4004 protected virtual bool ProcessMnemonic(char charCode) {
4009 [EditorBrowsable(EditorBrowsableState.Advanced)]
4010 protected void RaiseDragEvent(object key, DragEventArgs e) {
4014 [EditorBrowsable(EditorBrowsableState.Advanced)]
4015 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
4019 [EditorBrowsable(EditorBrowsableState.Advanced)]
4020 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
4024 [EditorBrowsable(EditorBrowsableState.Advanced)]
4025 protected void RaisePaintEvent(object key, PaintEventArgs e) {
4029 private void SetIsRecreating () {
4032 foreach (Control c in Controls.GetAllControls()) {
4033 c.SetIsRecreating ();
4037 [EditorBrowsable(EditorBrowsableState.Advanced)]
4038 protected void RecreateHandle() {
4039 if (!IsHandleCreated)
4043 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
4048 if (IsHandleCreated) {
4050 Console.WriteLine(" + handle is created, destroying it.");
4053 // WM_DESTROY will CreateHandle for us
4056 Console.WriteLine(" + handle is not created, creating it.");
4064 is_recreating = false;
4066 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4072 [EditorBrowsable(EditorBrowsableState.Advanced)]
4073 protected void ResetMouseEventArgs() {
4077 [EditorBrowsable(EditorBrowsableState.Advanced)]
4078 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
4079 if (right_to_left == RightToLeft.No) {
4084 case ContentAlignment.TopLeft: {
4085 return ContentAlignment.TopRight;
4088 case ContentAlignment.TopRight: {
4089 return ContentAlignment.TopLeft;
4092 case ContentAlignment.MiddleLeft: {
4093 return ContentAlignment.MiddleRight;
4096 case ContentAlignment.MiddleRight: {
4097 return ContentAlignment.MiddleLeft;
4100 case ContentAlignment.BottomLeft: {
4101 return ContentAlignment.BottomRight;
4104 case ContentAlignment.BottomRight: {
4105 return ContentAlignment.BottomLeft;
4109 // if it's center it doesn't change
4115 [EditorBrowsable(EditorBrowsableState.Advanced)]
4116 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
4117 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
4121 if (align == HorizontalAlignment.Left) {
4122 return HorizontalAlignment.Right;
4125 // align must be HorizontalAlignment.Right
4126 return HorizontalAlignment.Left;
4129 [EditorBrowsable(EditorBrowsableState.Advanced)]
4130 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
4131 if (right_to_left == RightToLeft.No) {
4135 if (align == LeftRightAlignment.Left) {
4136 return LeftRightAlignment.Right;
4139 // align must be LeftRightAlignment.Right;
4140 return LeftRightAlignment.Left;
4143 [EditorBrowsable(EditorBrowsableState.Advanced)]
4144 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
4145 return RtlTranslateAlignment(align);
4148 [EditorBrowsable(EditorBrowsableState.Advanced)]
4149 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
4150 return RtlTranslateAlignment(align);
4153 [EditorBrowsable(EditorBrowsableState.Advanced)]
4154 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
4155 return RtlTranslateAlignment(align);
4159 [EditorBrowsable (EditorBrowsableState.Never)]
4161 [EditorBrowsable(EditorBrowsableState.Advanced)]
4163 protected virtual void ScaleCore(float dx, float dy) {
4169 location = new Point((int)(Left * dx), (int)(Top * dy));
4170 size = this.ClientSize;
4172 if (!GetStyle(ControlStyles.FixedWidth)) {
4173 size.Width = (int)(size.Width * dx);
4176 if (!GetStyle(ControlStyles.FixedHeight)) {
4177 size.Height = (int)(size.Height * dy);
4180 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
4182 /* Now scale our children */
4183 Control [] controls = child_controls.GetAllControls ();
4184 for (int i=0; i < controls.Length; i++) {
4185 controls[i].Scale(dx, dy);
4191 protected virtual void Select(bool directed, bool forward) {
4192 IContainerControl container;
4194 container = GetContainerControl();
4195 if (container != null && (Control)container != this)
4196 container.ActiveControl = this;
4199 [EditorBrowsable(EditorBrowsableState.Advanced)]
4200 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
4201 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
4202 if (IsHandleCreated) {
4203 XplatUI.SetWindowPos(Handle, x, y, width, height);
4205 // Win32 automatically changes negative width/height to 0.
4206 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
4207 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
4209 if (width < 0 || height < 0) {
4211 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
4215 UpdateBounds(x, y, width, height);
4220 [EditorBrowsable(EditorBrowsableState.Advanced)]
4221 protected virtual void SetClientSizeCore(int x, int y) {
4222 Size NewSize = InternalSizeFromClientSize (new Size (x, y));
4224 if (NewSize != Size.Empty)
4225 SetBounds (bounds.X, bounds.Y, NewSize.Width, NewSize.Height, BoundsSpecified.Size);
4228 [EditorBrowsable(EditorBrowsableState.Advanced)]
4229 protected internal void SetStyle(ControlStyles flag, bool value) {
4231 control_style |= flag;
4233 control_style &= ~flag;
4237 protected void SetTopLevel(bool value) {
4238 if ((GetTopLevel() != value) && (parent != null)) {
4239 throw new ArgumentException ("Cannot change toplevel style of a parented control.");
4243 if (IsHandleCreated && value != Visible) {
4247 // XXX MS.NET causes handle to be created here
4250 is_toplevel = value;
4253 protected virtual void SetVisibleCore(bool value) {
4254 if (value != is_visible) {
4257 if (is_visible && ((window.Handle == IntPtr.Zero) || !is_created)) {
4261 if (IsHandleCreated) {
4262 XplatUI.SetVisible(Handle, is_visible, true);
4263 // Explicitly move Toplevel windows to where we want them;
4264 // apparently moving unmapped toplevel windows doesn't work
4265 if (is_visible && (this is Form)) {
4266 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
4270 OnVisibleChanged(EventArgs.Empty);
4275 [EditorBrowsable (EditorBrowsableState.Advanced)]
4281 virtual Size SizeFromClientSize (Size clientSize) {
4282 return InternalSizeFromClientSize (clientSize);
4285 [EditorBrowsable(EditorBrowsableState.Advanced)]
4286 protected void UpdateBounds() {
4287 if (!IsHandleCreated)
4297 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
4299 UpdateBounds(x, y, width, height, client_width, client_height);
4302 [EditorBrowsable(EditorBrowsableState.Advanced)]
4303 protected void UpdateBounds(int x, int y, int width, int height) {
4307 // Calculate client rectangle
4308 rect = new Rectangle(0, 0, 0, 0);
4311 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
4312 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
4315 [EditorBrowsable(EditorBrowsableState.Advanced)]
4316 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
4317 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
4319 bool resized = false;
4321 // Needed to generate required notifications
4322 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
4326 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
4333 bounds.Height=height;
4335 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
4336 explicit_bounds = bounds;
4338 client_size.Width=clientWidth;
4339 client_size.Height=clientHeight;
4342 OnLocationChanged(EventArgs.Empty);
4344 if (!background_color.IsEmpty && background_color.A < byte.MaxValue)
4349 OnSizeChanged(EventArgs.Empty);
4351 OnClientSizeChanged (EventArgs.Empty);
4356 [EditorBrowsable(EditorBrowsableState.Advanced)]
4357 protected void UpdateStyles() {
4358 if (!IsHandleCreated) {
4362 XplatUI.SetWindowStyle(window.Handle, CreateParams);
4363 OnStyleChanged(EventArgs.Empty);
4366 private void UpdateZOrderOfChild(Control child) {
4367 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
4370 index = child_controls.IndexOf(child);
4373 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
4375 IntPtr after = AfterTopMostControl ();
4376 if (after != IntPtr.Zero)
4377 XplatUI.SetZOrder (child.Handle, after, false, false);
4379 XplatUI.SetZOrder (child.Handle, IntPtr.Zero, true, false);
4384 // Override this if there is a control that shall always remain on
4385 // top of other controls (such as scrollbars). If there are several
4386 // of these controls, the bottom-most should be returned.
4387 internal virtual IntPtr AfterTopMostControl () {
4391 // internal because we need to call it from ScrollableControl.OnVisibleChanged
4392 internal void UpdateChildrenZOrder() {
4393 Control [] controls;
4395 if (!IsHandleCreated) {
4399 // XXX This code is severely broken. It leaks
4400 // the "zero_sized" abstraction out of the X11
4401 // backend and into Control.cs. It'll work on
4402 // windows simply by virtue of windows never
4403 // setting that field to true.
4405 // basically what we need to guard against is
4406 // calling XplatUI.SetZOrder on an hwnd that
4407 // corresponds to an unmapped X window.
4408 controls = child_controls.GetAllControls ();
4410 ArrayList children_to_order = new ArrayList ();
4412 for (int i = 0; i < controls.Length; i ++) {
4413 if (!controls[i].IsHandleCreated || !controls[i].VisibleInternal)
4416 Hwnd hwnd = Hwnd.ObjectFromHandle (controls[i].Handle);
4417 if (hwnd.zero_sized)
4420 children_to_order.Add (controls[i]);
4423 for (int i = 1; i < children_to_order.Count; i ++) {
4424 Control upper = (Control)children_to_order[i-1];
4425 Control lower = (Control)children_to_order[i];
4427 XplatUI.SetZOrder(lower.Handle, upper.Handle, false, false);
4431 [EditorBrowsable(EditorBrowsableState.Advanced)]
4432 protected void UpdateZOrder() {
4433 if (parent != null) {
4434 parent.UpdateZOrderOfChild(this);
4438 protected virtual void WndProc(ref Message m) {
4440 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
4442 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
4446 switch((Msg)m.Msg) {
4447 case Msg.WM_DESTROY: {
4452 case Msg.WM_WINDOWPOSCHANGED: {
4453 WmWindowPosChanged(ref m);
4457 // Nice description of what should happen when handling WM_PAINT
4458 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4459 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4460 case Msg.WM_PAINT: {
4465 // The DefWndProc will never have to handle this, we always paint the background in managed code
4466 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4467 // here but it just makes things more complicated...
4468 case Msg.WM_ERASEBKGND: {
4469 WmEraseBackground (ref m);
4473 case Msg.WM_LBUTTONUP: {
4474 WmLButtonUp (ref m);
4478 case Msg.WM_LBUTTONDOWN: {
4479 WmLButtonDown (ref m);
4483 case Msg.WM_LBUTTONDBLCLK: {
4484 WmLButtonDblClick (ref m);
4488 case Msg.WM_MBUTTONUP: {
4489 WmMButtonUp (ref m);
4493 case Msg.WM_MBUTTONDOWN: {
4494 WmMButtonDown (ref m);
4498 case Msg.WM_MBUTTONDBLCLK: {
4499 WmMButtonDblClick (ref m);
4503 case Msg.WM_RBUTTONUP: {
4504 WmRButtonUp (ref m);
4508 case Msg.WM_RBUTTONDOWN: {
4509 WmRButtonDown (ref m);
4513 case Msg.WM_RBUTTONDBLCLK: {
4514 WmRButtonDblClick (ref m);
4518 case Msg.WM_CONTEXTMENU: {
4519 WmContextMenu (ref m);
4523 case Msg.WM_MOUSEWHEEL: {
4524 WmMouseWheel (ref m);
4529 case Msg.WM_MOUSEMOVE: {
4530 WmMouseMove (ref m);
4534 case Msg.WM_SHOWWINDOW: {
4535 WmShowWindow (ref m);
4539 case Msg.WM_CREATE: {
4544 case Msg.WM_MOUSE_ENTER: {
4545 WmMouseEnter (ref m);
4549 case Msg.WM_MOUSELEAVE: {
4550 WmMouseLeave (ref m);
4554 case Msg.WM_MOUSEHOVER: {
4555 WmMouseHover (ref m);
4559 case Msg.WM_SYSKEYUP: {
4564 case Msg.WM_SYSKEYDOWN:
4565 case Msg.WM_KEYDOWN:
4567 case Msg.WM_SYSCHAR:
4578 case Msg.WM_KILLFOCUS: {
4579 WmKillFocus (ref m);
4583 case Msg.WM_SETFOCUS: {
4588 case Msg.WM_SYSCOLORCHANGE: {
4589 WmSysColorChange (ref m);
4593 case Msg.WM_SETCURSOR: {
4594 WmSetCursor (ref m);
4598 case Msg.WM_CAPTURECHANGED: {
4599 WmCaptureChanged (ref m);
4608 #endregion // Public Instance Methods
4612 private void WmDestroy (ref Message m) {
4613 OnHandleDestroyed(EventArgs.Empty);
4615 IntPtr handle = window.Handle;
4617 window.InvalidateHandle();
4619 if (is_recreating) {
4621 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4625 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4627 is_recreating = false;
4631 private void WmWindowPosChanged (ref Message m) {
4633 Rectangle save_bounds = explicit_bounds;
4635 explicit_bounds = save_bounds;
4636 if (GetStyle(ControlStyles.ResizeRedraw)) {
4643 // Nice description of what should happen when handling WM_PAINT
4644 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4645 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4646 private void WmPaint (ref Message m) {
4647 PaintEventArgs paint_event;
4649 IntPtr handle = Handle;
4651 paint_event = XplatUI.PaintEventStart (handle, true);
4653 if (paint_event == null)
4656 DoubleBuffer current_buffer = null;
4657 if (UseDoubleBuffering) {
4658 current_buffer = GetBackBuffer ();
4659 if (!current_buffer.InvalidRegion.IsVisible (paint_event.ClipRectangle)) {
4660 // Just blit the previous image
4661 current_buffer.Blit (paint_event);
4662 XplatUI.PaintEventEnd (handle, true);
4665 current_buffer.Start (paint_event);
4668 if (!GetStyle(ControlStyles.Opaque)) {
4669 OnPaintBackground (paint_event);
4672 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4673 OnPaintBackgroundInternal (paint_event);
4675 OnPaintInternal(paint_event);
4676 if (!paint_event.Handled) {
4677 OnPaint (paint_event);
4680 if (current_buffer != null) {
4681 current_buffer.End (paint_event);
4685 XplatUI.PaintEventEnd (handle, true);
4688 private void WmEraseBackground (ref Message m) {
4689 // The DefWndProc will never have to handle this, we always paint the background in managed code
4690 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4691 // here but it just makes things more complicated...
4692 m.Result = (IntPtr)1;
4695 private void WmLButtonUp (ref Message m) {
4698 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4700 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4703 HandleClick(mouse_clicks, me);
4706 if (InternalCapture) {
4707 InternalCapture = false;
4710 if (mouse_clicks > 1) {
4715 private void WmLButtonDown (ref Message m) {
4717 Select (true, true);
4719 InternalCapture = true;
4720 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4721 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4725 private void WmLButtonDblClick (ref Message m) {
4726 InternalCapture = true;
4728 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4729 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4733 private void WmMButtonUp (ref Message m) {
4736 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4738 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4741 HandleClick(mouse_clicks, me);
4743 if (InternalCapture) {
4744 InternalCapture = false;
4746 if (mouse_clicks > 1) {
4751 private void WmMButtonDown (ref Message m) {
4752 InternalCapture = true;
4753 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4754 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4758 private void WmMButtonDblClick (ref Message m) {
4759 InternalCapture = true;
4761 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4762 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4766 private void WmRButtonUp (ref Message m) {
4770 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4771 pt = PointToScreen(pt);
4773 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4775 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4777 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4780 HandleClick(mouse_clicks, me);
4783 if (InternalCapture) {
4784 InternalCapture = false;
4787 if (mouse_clicks > 1) {
4792 private void WmRButtonDown (ref Message m) {
4793 InternalCapture = true;
4794 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4795 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4799 private void WmRButtonDblClick (ref Message m) {
4800 InternalCapture = true;
4802 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4803 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4807 private void WmContextMenu (ref Message m) {
4808 if (context_menu != null) {
4811 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4813 if (pt.X == -1 || pt.Y == -1) {
4814 pt.X = (this.Width / 2) + this.Left;
4815 pt.Y = (this.Height / 2) + this.Top;
4816 pt = this.PointToScreen (pt);
4819 context_menu.Show (this, PointToClient (pt));
4824 // If there isn't a regular context menu, show the Strip version
4825 if (context_menu == null && context_menu_strip != null) {
4828 pt = new Point (LowOrder ((int)m.LParam.ToInt32 ()), HighOrder ((int)m.LParam.ToInt32 ()));
4830 if (pt.X == -1 || pt.Y == -1) {
4831 pt.X = (this.Width / 2) + this.Left;
4832 pt.Y = (this.Height /2) + this.Top;
4833 pt = this.PointToScreen (pt);
4836 context_menu_strip.Show (this, PointToClient (pt));
4843 private void WmCreate (ref Message m) {
4844 OnHandleCreated(EventArgs.Empty);
4847 private void WmMouseWheel (ref Message m) {
4849 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4850 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4851 HighOrder(m.WParam.ToInt32())));
4855 private void WmMouseMove (ref Message m) {
4856 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4858 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4862 private void WmMouseEnter (ref Message m) {
4867 OnMouseEnter(EventArgs.Empty);
4870 private void WmMouseLeave (ref Message m) {
4872 OnMouseLeave(EventArgs.Empty);
4875 private void WmMouseHover (ref Message m) {
4876 OnMouseHover(EventArgs.Empty);
4879 private void WmShowWindow (ref Message m) {
4880 if (m.WParam.ToInt32() != 0) {
4882 /* if we're being shown, make sure our child controls all have their handles created */
4883 Control [] controls = child_controls.GetAllControls ();
4884 for (int i=0; i<controls.Length; i++) {
4885 if (controls [i].is_visible) {
4886 controls [i].CreateControl ();
4887 XplatUI.SetParent(controls[i].Handle, window.Handle);
4892 if (parent != null && Focused) {
4895 // Need to start at parent, GetContainerControl might return ourselves if we're a container
4896 container = (Control)parent.GetContainerControl();
4897 if (container != null) {
4898 container.SelectNextControl(this, true, true, true, true);
4903 if (is_toplevel || (this is Form && ((Form) this).IsMdiChild)) /* XXX make sure this works for mdi forms */
4904 OnVisibleChanged(EventArgs.Empty);
4907 private void WmSysKeyUp (ref Message m) {
4908 if (ProcessKeyMessage(ref m)) {
4909 m.Result = IntPtr.Zero;
4913 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4917 if (form != null && form.ActiveMenu != null) {
4918 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4925 private void WmKeys (ref Message m) {
4926 if (ProcessKeyMessage(ref m)) {
4927 m.Result = IntPtr.Zero;
4933 private void WmHelp (ref Message m) {
4935 if (m.LParam != IntPtr.Zero) {
4938 hi = new HELPINFO();
4940 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4941 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4943 mouse_pos = Control.MousePosition;
4945 OnHelpRequested(new HelpEventArgs(mouse_pos));
4946 m.Result = (IntPtr)1;
4949 private void WmKillFocus (ref Message m) {
4950 this.has_focus = false;
4951 OnLostFocus (EventArgs.Empty);
4954 private void WmSetFocus (ref Message m) {
4956 this.has_focus = true;
4957 OnGotFocus (EventArgs.Empty);
4961 private void WmSysColorChange (ref Message m) {
4962 ThemeEngine.Current.ResetDefaults();
4963 OnSystemColorsChanged(EventArgs.Empty);
4966 private void WmSetCursor (ref Message m) {
4967 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4972 XplatUI.SetCursor(window.Handle, cursor.handle);
4973 m.Result = (IntPtr)1;
4976 private void WmCaptureChanged (ref Message m) {
4977 is_captured = false;
4978 OnMouseCaptureChanged (EventArgs.Empty);
4979 m.Result = (IntPtr) 0;
4985 #region OnXXX methods
4987 protected virtual void OnAutoSizeChanged (EventArgs e)
4989 EventHandler eh = (EventHandler)(Events[AutoSizeChangedEvent]);
4995 [EditorBrowsable (EditorBrowsableState.Advanced)]
4996 protected virtual void OnBackColorChanged(EventArgs e) {
4997 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
5000 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
5003 [EditorBrowsable(EditorBrowsableState.Advanced)]
5004 protected virtual void OnBackgroundImageChanged(EventArgs e) {
5005 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
5008 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
5012 [EditorBrowsable (EditorBrowsableState.Advanced)]
5013 protected virtual void OnBackgroundImageLayoutChanged (EventArgs e)
5015 EventHandler eh = (EventHandler)(Events[BackgroundImageLayoutChangedEvent]);
5021 [EditorBrowsable(EditorBrowsableState.Advanced)]
5022 protected virtual void OnBindingContextChanged(EventArgs e) {
5023 CheckDataBindings ();
5024 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
5027 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
5030 [EditorBrowsable(EditorBrowsableState.Advanced)]
5031 protected virtual void OnCausesValidationChanged(EventArgs e) {
5032 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
5037 [EditorBrowsable(EditorBrowsableState.Advanced)]
5038 protected virtual void OnChangeUICues(UICuesEventArgs e) {
5039 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
5044 [EditorBrowsable(EditorBrowsableState.Advanced)]
5045 protected virtual void OnClick(EventArgs e) {
5046 EventHandler eh = (EventHandler)(Events [ClickEvent]);
5052 [EditorBrowsable (EditorBrowsableState.Advanced)]
5053 protected virtual void OnClientSizeChanged (EventArgs e)
5055 EventHandler eh = (EventHandler)(Events[ClientSizeChangedEvent]);
5061 [EditorBrowsable(EditorBrowsableState.Advanced)]
5062 protected virtual void OnContextMenuChanged(EventArgs e) {
5063 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
5069 [EditorBrowsable (EditorBrowsableState.Advanced)]
5070 protected virtual void OnContextMenuStripChanged (EventArgs e) {
5071 EventHandler eh = (EventHandler)(Events [ContextMenuStripChangedEvent]);
5077 [EditorBrowsable(EditorBrowsableState.Advanced)]
5078 protected virtual void OnControlAdded(ControlEventArgs e) {
5079 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
5084 [EditorBrowsable(EditorBrowsableState.Advanced)]
5085 protected virtual void OnControlRemoved(ControlEventArgs e) {
5086 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
5091 [EditorBrowsable(EditorBrowsableState.Advanced)]
5092 protected virtual void OnCreateControl() {
5096 [EditorBrowsable(EditorBrowsableState.Advanced)]
5097 protected virtual void OnCursorChanged(EventArgs e) {
5098 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
5103 [EditorBrowsable(EditorBrowsableState.Advanced)]
5104 protected virtual void OnDockChanged(EventArgs e) {
5105 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
5110 [EditorBrowsable(EditorBrowsableState.Advanced)]
5111 protected virtual void OnDoubleClick(EventArgs e) {
5112 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
5117 [EditorBrowsable(EditorBrowsableState.Advanced)]
5118 protected virtual void OnDragDrop(DragEventArgs drgevent) {
5119 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
5121 eh (this, drgevent);
5124 [EditorBrowsable(EditorBrowsableState.Advanced)]
5125 protected virtual void OnDragEnter(DragEventArgs drgevent) {
5126 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
5128 eh (this, drgevent);
5131 [EditorBrowsable(EditorBrowsableState.Advanced)]
5132 protected virtual void OnDragLeave(EventArgs e) {
5133 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
5138 [EditorBrowsable(EditorBrowsableState.Advanced)]
5139 protected virtual void OnDragOver(DragEventArgs drgevent) {
5140 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
5142 eh (this, drgevent);
5145 [EditorBrowsable(EditorBrowsableState.Advanced)]
5146 protected virtual void OnEnabledChanged(EventArgs e) {
5147 if (IsHandleCreated) {
5149 if (((Form)this).context == null) {
5150 XplatUI.EnableWindow(window.Handle, Enabled);
5153 XplatUI.EnableWindow(window.Handle, Enabled);
5158 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
5162 for (int i=0; i<child_controls.Count; i++) {
5163 child_controls[i].OnParentEnabledChanged(e);
5167 [EditorBrowsable(EditorBrowsableState.Advanced)]
5168 protected virtual void OnEnter(EventArgs e) {
5169 EventHandler eh = (EventHandler)(Events [EnterEvent]);
5174 [EditorBrowsable(EditorBrowsableState.Advanced)]
5175 protected virtual void OnFontChanged(EventArgs e) {
5176 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
5179 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
5182 [EditorBrowsable(EditorBrowsableState.Advanced)]
5183 protected virtual void OnForeColorChanged(EventArgs e) {
5184 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
5187 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
5190 [EditorBrowsable(EditorBrowsableState.Advanced)]
5191 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
5192 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
5194 eh (this, gfbevent);
5197 [EditorBrowsable(EditorBrowsableState.Advanced)]
5198 protected virtual void OnGotFocus(EventArgs e) {
5199 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
5204 [EditorBrowsable(EditorBrowsableState.Advanced)]
5205 protected virtual void OnHandleCreated(EventArgs e) {
5206 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
5211 [EditorBrowsable(EditorBrowsableState.Advanced)]
5212 protected virtual void OnHandleDestroyed(EventArgs e) {
5213 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
5218 internal void RaiseHelpRequested (HelpEventArgs hevent) {
5219 OnHelpRequested (hevent);
5222 [EditorBrowsable(EditorBrowsableState.Advanced)]
5223 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
5224 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
5229 protected virtual void OnImeModeChanged(EventArgs e) {
5230 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
5235 [EditorBrowsable(EditorBrowsableState.Advanced)]
5236 protected virtual void OnInvalidated(InvalidateEventArgs e) {
5237 if (UseDoubleBuffering) {
5238 // should this block be here? seems like it
5239 // would be more at home in
5240 // NotifyInvalidated..
5241 if (e.InvalidRect == ClientRectangle) {
5242 InvalidateBackBuffer ();
5243 } else if (backbuffer != null){
5244 // we need this Inflate call here so
5245 // that the border of the rectangle is
5246 // considered Visible (the
5247 // invalid_region.IsVisible call) in
5248 // the WM_PAINT handling below.
5249 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
5250 backbuffer.InvalidRegion.Union (r);
5254 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
5259 [EditorBrowsable(EditorBrowsableState.Advanced)]
5260 protected virtual void OnKeyDown(KeyEventArgs e) {
5261 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
5266 [EditorBrowsable(EditorBrowsableState.Advanced)]
5267 protected virtual void OnKeyPress(KeyPressEventArgs e) {
5268 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
5273 [EditorBrowsable(EditorBrowsableState.Advanced)]
5274 protected virtual void OnKeyUp(KeyEventArgs e) {
5275 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
5280 [EditorBrowsable(EditorBrowsableState.Advanced)]
5281 protected virtual void OnLayout(LayoutEventArgs levent) {
5282 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
5286 LayoutEngine.Layout (this, levent);
5289 [EditorBrowsable(EditorBrowsableState.Advanced)]
5290 protected virtual void OnLeave(EventArgs e) {
5291 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
5296 [EditorBrowsable(EditorBrowsableState.Advanced)]
5297 protected virtual void OnLocationChanged(EventArgs e) {
5299 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
5304 [EditorBrowsable(EditorBrowsableState.Advanced)]
5305 protected virtual void OnLostFocus(EventArgs e) {
5306 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
5312 protected virtual void OnMarginChanged (EventArgs e)
5314 EventHandler eh = (EventHandler)(Events[MarginChangedEvent]);
5319 [EditorBrowsable (EditorBrowsableState.Advanced)]
5321 protected virtual void OnMouseCaptureChanged (EventArgs e)
5323 internal virtual void OnMouseCaptureChanged (EventArgs e)
5326 EventHandler eh = (EventHandler)(Events [MouseCaptureChangedEvent]);
5332 [EditorBrowsable (EditorBrowsableState.Advanced)]
5333 protected virtual void OnMouseClick (MouseEventArgs e)
5335 MouseEventHandler eh = (MouseEventHandler)(Events [MouseClickEvent]);
5340 [EditorBrowsable (EditorBrowsableState.Advanced)]
5341 protected virtual void OnMouseDoubleClick (MouseEventArgs e)
5343 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDoubleClickEvent]);
5349 [EditorBrowsable(EditorBrowsableState.Advanced)]
5350 protected virtual void OnMouseDown(MouseEventArgs e) {
5351 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
5356 [EditorBrowsable(EditorBrowsableState.Advanced)]
5357 protected virtual void OnMouseEnter(EventArgs e) {
5358 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
5363 [EditorBrowsable(EditorBrowsableState.Advanced)]
5364 protected virtual void OnMouseHover(EventArgs e) {
5365 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
5370 [EditorBrowsable(EditorBrowsableState.Advanced)]
5371 protected virtual void OnMouseLeave(EventArgs e) {
5372 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
5377 [EditorBrowsable(EditorBrowsableState.Advanced)]
5378 protected virtual void OnMouseMove(MouseEventArgs e) {
5379 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
5384 [EditorBrowsable(EditorBrowsableState.Advanced)]
5385 protected virtual void OnMouseUp(MouseEventArgs e) {
5386 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
5391 [EditorBrowsable(EditorBrowsableState.Advanced)]
5392 protected virtual void OnMouseWheel(MouseEventArgs e) {
5393 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
5398 [EditorBrowsable(EditorBrowsableState.Advanced)]
5399 protected virtual void OnMove(EventArgs e) {
5400 EventHandler eh = (EventHandler)(Events [MoveEvent]);
5405 [EditorBrowsable(EditorBrowsableState.Advanced)]
5406 protected virtual void OnNotifyMessage(Message m) {
5411 protected virtual void OnPaddingChanged (EventArgs e) {
5412 EventHandler eh = (EventHandler) (Events [PaddingChangedEvent]);
5418 [EditorBrowsable(EditorBrowsableState.Advanced)]
5419 protected virtual void OnPaint(PaintEventArgs e) {
5420 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
5425 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
5429 internal virtual void OnPaintInternal(PaintEventArgs e) {
5433 [EditorBrowsable(EditorBrowsableState.Advanced)]
5434 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
5435 PaintControlBackground (pevent);
5438 [EditorBrowsable(EditorBrowsableState.Advanced)]
5439 protected virtual void OnParentBackColorChanged(EventArgs e) {
5440 if (background_color.IsEmpty && background_image==null) {
5442 OnBackColorChanged(e);
5446 [EditorBrowsable(EditorBrowsableState.Advanced)]
5447 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
5449 OnBackgroundImageChanged(e);
5452 [EditorBrowsable(EditorBrowsableState.Advanced)]
5453 protected virtual void OnParentBindingContextChanged(EventArgs e) {
5454 if (binding_context==null) {
5455 binding_context=Parent.binding_context;
5456 OnBindingContextChanged(e);
5460 [EditorBrowsable(EditorBrowsableState.Advanced)]
5461 protected virtual void OnParentChanged(EventArgs e) {
5462 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
5467 [EditorBrowsable(EditorBrowsableState.Advanced)]
5468 protected virtual void OnParentEnabledChanged(EventArgs e) {
5470 OnEnabledChanged(e);
5474 [EditorBrowsable(EditorBrowsableState.Advanced)]
5475 protected virtual void OnParentFontChanged(EventArgs e) {
5482 [EditorBrowsable(EditorBrowsableState.Advanced)]
5483 protected virtual void OnParentForeColorChanged(EventArgs e) {
5484 if (foreground_color.IsEmpty) {
5486 OnForeColorChanged(e);
5490 [EditorBrowsable(EditorBrowsableState.Advanced)]
5491 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
5492 if (right_to_left==RightToLeft.Inherit) {
5494 OnRightToLeftChanged(e);
5498 [EditorBrowsable(EditorBrowsableState.Advanced)]
5499 protected virtual void OnParentVisibleChanged(EventArgs e) {
5501 OnVisibleChanged(e);
5505 [EditorBrowsable(EditorBrowsableState.Advanced)]
5506 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
5507 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
5513 [EditorBrowsable (EditorBrowsableState.Advanced)]
5514 protected virtual void OnRegionChanged (EventArgs e)
5516 EventHandler eh = (EventHandler)(Events[RegionChangedEvent]);
5522 [EditorBrowsable(EditorBrowsableState.Advanced)]
5523 protected virtual void OnResize(EventArgs e) {
5524 PerformLayout(this, "Bounds");
5526 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
5531 [EditorBrowsable(EditorBrowsableState.Advanced)]
5532 protected virtual void OnRightToLeftChanged(EventArgs e) {
5533 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
5536 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
5539 [EditorBrowsable(EditorBrowsableState.Advanced)]
5540 protected virtual void OnSizeChanged(EventArgs e) {
5541 DisposeBackBuffer ();
5543 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
5548 [EditorBrowsable(EditorBrowsableState.Advanced)]
5549 protected virtual void OnStyleChanged(EventArgs e) {
5550 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
5555 [EditorBrowsable(EditorBrowsableState.Advanced)]
5556 protected virtual void OnSystemColorsChanged(EventArgs e) {
5557 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
5562 [EditorBrowsable(EditorBrowsableState.Advanced)]
5563 protected virtual void OnTabIndexChanged(EventArgs e) {
5564 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
5569 [EditorBrowsable(EditorBrowsableState.Advanced)]
5570 protected virtual void OnTabStopChanged(EventArgs e) {
5571 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
5576 [EditorBrowsable(EditorBrowsableState.Advanced)]
5577 protected virtual void OnTextChanged(EventArgs e) {
5578 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
5583 [EditorBrowsable(EditorBrowsableState.Advanced)]
5584 protected virtual void OnValidated(EventArgs e) {
5585 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
5590 [EditorBrowsable(EditorBrowsableState.Advanced)]
5591 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
5592 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
5597 [EditorBrowsable(EditorBrowsableState.Advanced)]
5598 protected virtual void OnVisibleChanged(EventArgs e) {
5599 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
5603 // We need to tell our kids
5604 for (int i=0; i<child_controls.Count; i++) {
5605 if (child_controls[i].Visible) {
5606 child_controls[i].OnParentVisibleChanged(e);
5610 #endregion // OnXXX methods
5614 static object AutoSizeChangedEvent = new object ();
5616 static object BackColorChangedEvent = new object ();
5617 static object BackgroundImageChangedEvent = new object ();
5619 static object BackgroundImageLayoutChangedEvent = new object ();
5621 static object BindingContextChangedEvent = new object ();
5622 static object CausesValidationChangedEvent = new object ();
5623 static object ChangeUICuesEvent = new object ();
5624 static object ClickEvent = new object ();
5626 static object ClientSizeChangedEvent = new object ();
5628 static object ContextMenuChangedEvent = new object ();
5630 static object ContextMenuStripChangedEvent = new object ();
5632 static object ControlAddedEvent = new object ();
5633 static object ControlRemovedEvent = new object ();
5634 static object CursorChangedEvent = new object ();
5635 static object DockChangedEvent = new object ();
5636 static object DoubleClickEvent = new object ();
5637 static object DragDropEvent = new object ();
5638 static object DragEnterEvent = new object ();
5639 static object DragLeaveEvent = new object ();
5640 static object DragOverEvent = new object ();
5641 static object EnabledChangedEvent = new object ();
5642 static object EnterEvent = new object ();
5643 static object FontChangedEvent = new object ();
5644 static object ForeColorChangedEvent = new object ();
5645 static object GiveFeedbackEvent = new object ();
5646 static object GotFocusEvent = new object ();
5647 static object HandleCreatedEvent = new object ();
5648 static object HandleDestroyedEvent = new object ();
5649 static object HelpRequestedEvent = new object ();
5650 static object ImeModeChangedEvent = new object ();
5651 static object InvalidatedEvent = new object ();
5652 static object KeyDownEvent = new object ();
5653 static object KeyPressEvent = new object ();
5654 static object KeyUpEvent = new object ();
5655 static object LayoutEvent = new object ();
5656 static object LeaveEvent = new object ();
5657 static object LocationChangedEvent = new object ();
5658 static object LostFocusEvent = new object ();
5660 static object MarginChangedEvent = new object ();
5662 static object MouseCaptureChangedEvent = new object ();
5664 static object MouseClickEvent = new object ();
5665 static object MouseDoubleClickEvent = new object ();
5667 static object MouseDownEvent = new object ();
5668 static object MouseEnterEvent = new object ();
5669 static object MouseHoverEvent = new object ();
5670 static object MouseLeaveEvent = new object ();
5671 static object MouseMoveEvent = new object ();
5672 static object MouseUpEvent = new object ();
5673 static object MouseWheelEvent = new object ();
5674 static object MoveEvent = new object ();
5676 static object PaddingChangedEvent = new object ();
5678 static object PaintEvent = new object ();
5679 static object ParentChangedEvent = new object ();
5681 static object PreviewKeyDownEvent = new object ();
5683 static object QueryAccessibilityHelpEvent = new object ();
5684 static object QueryContinueDragEvent = new object ();
5686 static object RegionChangedEvent = new object ();
5688 static object ResizeEvent = new object ();
5689 static object RightToLeftChangedEvent = new object ();
5690 static object SizeChangedEvent = new object ();
5691 static object StyleChangedEvent = new object ();
5692 static object SystemColorsChangedEvent = new object ();
5693 static object TabIndexChangedEvent = new object ();
5694 static object TabStopChangedEvent = new object ();
5695 static object TextChangedEvent = new object ();
5696 static object ValidatedEvent = new object ();
5697 static object ValidatingEvent = new object ();
5698 static object VisibleChangedEvent = new object ();
5702 [EditorBrowsable (EditorBrowsableState.Never)]
5703 public event EventHandler AutoSizeChanged {
5704 add { Events.AddHandler (AutoSizeChangedEvent, value);}
5705 remove {Events.RemoveHandler (AutoSizeChangedEvent, value);}
5708 public event EventHandler BackColorChanged {
5709 add { Events.AddHandler (BackColorChangedEvent, value); }
5710 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
5713 public event EventHandler BackgroundImageChanged {
5714 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
5715 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
5719 public event EventHandler BackgroundImageLayoutChanged {
5720 add {Events.AddHandler (BackgroundImageLayoutChangedEvent, value);}
5721 remove {Events.RemoveHandler (BackgroundImageLayoutChangedEvent, value);}
5725 public event EventHandler BindingContextChanged {
5726 add { Events.AddHandler (BindingContextChangedEvent, value); }
5727 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
5730 public event EventHandler CausesValidationChanged {
5731 add { Events.AddHandler (CausesValidationChangedEvent, value); }
5732 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
5735 public event UICuesEventHandler ChangeUICues {
5736 add { Events.AddHandler (ChangeUICuesEvent, value); }
5737 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
5740 public event EventHandler Click {
5741 add { Events.AddHandler (ClickEvent, value); }
5742 remove { Events.RemoveHandler (ClickEvent, value); }
5746 public event EventHandler ClientSizeChanged {
5747 add {Events.AddHandler (ClientSizeChangedEvent, value);}
5748 remove {Events.RemoveHandler (ClientSizeChangedEvent, value);}
5755 public event EventHandler ContextMenuChanged {
5756 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5757 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5761 public event EventHandler ContextMenuStripChanged {
5762 add { Events.AddHandler (ContextMenuStripChangedEvent, value); }
5763 remove { Events.RemoveHandler (ContextMenuStripChangedEvent, value);}
5768 [EditorBrowsable(EditorBrowsableState.Advanced)]
5774 public event ControlEventHandler ControlAdded {
5775 add { Events.AddHandler (ControlAddedEvent, value); }
5776 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5779 [EditorBrowsable(EditorBrowsableState.Advanced)]
5785 public event ControlEventHandler ControlRemoved {
5786 add { Events.AddHandler (ControlRemovedEvent, value); }
5787 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5790 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5791 public event EventHandler CursorChanged {
5792 add { Events.AddHandler (CursorChangedEvent, value); }
5793 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5795 public event EventHandler DockChanged {
5796 add { Events.AddHandler (DockChangedEvent, value); }
5797 remove { Events.RemoveHandler (DockChangedEvent, value); }
5800 public event EventHandler DoubleClick {
5801 add { Events.AddHandler (DoubleClickEvent, value); }
5802 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5805 public event DragEventHandler DragDrop {
5806 add { Events.AddHandler (DragDropEvent, value); }
5807 remove { Events.RemoveHandler (DragDropEvent, value); }
5810 public event DragEventHandler DragEnter {
5811 add { Events.AddHandler (DragEnterEvent, value); }
5812 remove { Events.RemoveHandler (DragEnterEvent, value); }
5815 public event EventHandler DragLeave {
5816 add { Events.AddHandler (DragLeaveEvent, value); }
5817 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5820 public event DragEventHandler DragOver {
5821 add { Events.AddHandler (DragOverEvent, value); }
5822 remove { Events.RemoveHandler (DragOverEvent, value); }
5825 public event EventHandler EnabledChanged {
5826 add { Events.AddHandler (EnabledChangedEvent, value); }
5827 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5830 public event EventHandler Enter {
5831 add { Events.AddHandler (EnterEvent, value); }
5832 remove { Events.RemoveHandler (EnterEvent, value); }
5835 public event EventHandler FontChanged {
5836 add { Events.AddHandler (FontChangedEvent, value); }
5837 remove { Events.RemoveHandler (FontChangedEvent, value); }
5840 public event EventHandler ForeColorChanged {
5841 add { Events.AddHandler (ForeColorChangedEvent, value); }
5842 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5845 public event GiveFeedbackEventHandler GiveFeedback {
5846 add { Events.AddHandler (GiveFeedbackEvent, value); }
5847 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5850 [EditorBrowsable(EditorBrowsableState.Advanced)]
5852 public event EventHandler GotFocus {
5853 add { Events.AddHandler (GotFocusEvent, value); }
5854 remove { Events.RemoveHandler (GotFocusEvent, value); }
5858 [EditorBrowsable(EditorBrowsableState.Advanced)]
5860 public event EventHandler HandleCreated {
5861 add { Events.AddHandler (HandleCreatedEvent, value); }
5862 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5865 [EditorBrowsable(EditorBrowsableState.Advanced)]
5867 public event EventHandler HandleDestroyed {
5868 add { Events.AddHandler (HandleDestroyedEvent, value); }
5869 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5872 public event HelpEventHandler HelpRequested {
5873 add { Events.AddHandler (HelpRequestedEvent, value); }
5874 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5877 public event EventHandler ImeModeChanged {
5878 add { Events.AddHandler (ImeModeChangedEvent, value); }
5879 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5882 [EditorBrowsable(EditorBrowsableState.Advanced)]
5884 public event InvalidateEventHandler Invalidated {
5885 add { Events.AddHandler (InvalidatedEvent, value); }
5886 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5889 public event KeyEventHandler KeyDown {
5890 add { Events.AddHandler (KeyDownEvent, value); }
5891 remove { Events.RemoveHandler (KeyDownEvent, value); }
5894 public event KeyPressEventHandler KeyPress {
5895 add { Events.AddHandler (KeyPressEvent, value); }
5896 remove { Events.RemoveHandler (KeyPressEvent, value); }
5899 public event KeyEventHandler KeyUp {
5900 add { Events.AddHandler (KeyUpEvent, value); }
5901 remove { Events.RemoveHandler (KeyUpEvent, value); }
5904 public event LayoutEventHandler Layout {
5905 add { Events.AddHandler (LayoutEvent, value); }
5906 remove { Events.RemoveHandler (LayoutEvent, value); }
5909 public event EventHandler Leave {
5910 add { Events.AddHandler (LeaveEvent, value); }
5911 remove { Events.RemoveHandler (LeaveEvent, value); }
5914 public event EventHandler LocationChanged {
5915 add { Events.AddHandler (LocationChangedEvent, value); }
5916 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5919 [EditorBrowsable(EditorBrowsableState.Advanced)]
5921 public event EventHandler LostFocus {
5922 add { Events.AddHandler (LostFocusEvent, value); }
5923 remove { Events.RemoveHandler (LostFocusEvent, value); }
5927 public event EventHandler MarginChanged {
5928 add { Events.AddHandler (MarginChangedEvent, value); }
5929 remove {Events.RemoveHandler (MarginChangedEvent, value); }
5933 public event EventHandler MouseCaptureChanged {
5935 internal event EventHandler MouseCaptureChanged {
5937 add { Events.AddHandler (MouseCaptureChangedEvent, value); }
5938 remove { Events.RemoveHandler (MouseCaptureChangedEvent, value); }
5941 public event MouseEventHandler MouseClick
5943 add { Events.AddHandler (MouseClickEvent, value); }
5944 remove { Events.RemoveHandler (MouseClickEvent, value); }
5946 public event MouseEventHandler MouseDoubleClick
5948 add { Events.AddHandler (MouseDoubleClickEvent, value); }
5949 remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
5952 public event MouseEventHandler MouseDown {
5953 add { Events.AddHandler (MouseDownEvent, value); }
5954 remove { Events.RemoveHandler (MouseDownEvent, value); }
5957 public event EventHandler MouseEnter {
5958 add { Events.AddHandler (MouseEnterEvent, value); }
5959 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5962 public event EventHandler MouseHover {
5963 add { Events.AddHandler (MouseHoverEvent, value); }
5964 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5967 public event EventHandler MouseLeave {
5968 add { Events.AddHandler (MouseLeaveEvent, value); }
5969 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5972 public event MouseEventHandler MouseMove {
5973 add { Events.AddHandler (MouseMoveEvent, value); }
5974 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5977 public event MouseEventHandler MouseUp {
5978 add { Events.AddHandler (MouseUpEvent, value); }
5979 remove { Events.RemoveHandler (MouseUpEvent, value); }
5982 [EditorBrowsable(EditorBrowsableState.Advanced)]
5984 public event MouseEventHandler MouseWheel {
5985 add { Events.AddHandler (MouseWheelEvent, value); }
5986 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5989 public event EventHandler Move {
5990 add { Events.AddHandler (MoveEvent, value); }
5991 remove { Events.RemoveHandler (MoveEvent, value); }
5994 public event EventHandler PaddingChanged
5996 add { Events.AddHandler (PaddingChangedEvent, value); }
5997 remove { Events.RemoveHandler (PaddingChangedEvent, value); }
6000 public event PaintEventHandler Paint {
6001 add { Events.AddHandler (PaintEvent, value); }
6002 remove { Events.RemoveHandler (PaintEvent, value); }
6005 public event EventHandler ParentChanged {
6006 add { Events.AddHandler (ParentChangedEvent, value); }
6007 remove { Events.RemoveHandler (ParentChangedEvent, value); }
6011 public event PreviewKeyDownEventHandler PreviewKeyDown {
6012 add { Events.AddHandler (PreviewKeyDownEvent, value); }
6013 remove { Events.RemoveHandler (PreviewKeyDownEvent, value); }
6017 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
6018 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
6019 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
6022 public event QueryContinueDragEventHandler QueryContinueDrag {
6023 add { Events.AddHandler (QueryContinueDragEvent, value); }
6024 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
6028 public event EventHandler RegionChanged {
6029 add { Events.AddHandler (RegionChangedEvent, value); }
6030 remove { Events.RemoveHandler (RegionChangedEvent, value); }
6035 [EditorBrowsable (EditorBrowsableState.Advanced)]
6037 public event EventHandler Resize {
6038 add { Events.AddHandler (ResizeEvent, value); }
6039 remove { Events.RemoveHandler (ResizeEvent, value); }
6042 public event EventHandler RightToLeftChanged {
6043 add { Events.AddHandler (RightToLeftChangedEvent, value); }
6044 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
6047 public event EventHandler SizeChanged {
6048 add { Events.AddHandler (SizeChangedEvent, value); }
6049 remove { Events.RemoveHandler (SizeChangedEvent, value); }
6052 public event EventHandler StyleChanged {
6053 add { Events.AddHandler (StyleChangedEvent, value); }
6054 remove { Events.RemoveHandler (StyleChangedEvent, value); }
6057 public event EventHandler SystemColorsChanged {
6058 add { Events.AddHandler (SystemColorsChangedEvent, value); }
6059 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
6062 public event EventHandler TabIndexChanged {
6063 add { Events.AddHandler (TabIndexChangedEvent, value); }
6064 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
6067 public event EventHandler TabStopChanged {
6068 add { Events.AddHandler (TabStopChangedEvent, value); }
6069 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
6072 public event EventHandler TextChanged {
6073 add { Events.AddHandler (TextChangedEvent, value); }
6074 remove { Events.RemoveHandler (TextChangedEvent, value); }
6077 public event EventHandler Validated {
6078 add { Events.AddHandler (ValidatedEvent, value); }
6079 remove { Events.RemoveHandler (ValidatedEvent, value); }
6082 public event CancelEventHandler Validating {
6083 add { Events.AddHandler (ValidatingEvent, value); }
6084 remove { Events.RemoveHandler (ValidatingEvent, value); }
6087 public event EventHandler VisibleChanged {
6088 add { Events.AddHandler (VisibleChangedEvent, value); }
6089 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
6092 #endregion // Events