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 bool owner_permits_toplevels = (owner is MdiClient) || (owner is Form && ((Form)owner).IsMdiContainer);
489 bool child_is_toplevel = ((Control)value).GetTopLevel();
490 bool child_is_mdichild = (value is Form && ((Form)value).IsMdiChild);
492 if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
493 throw new ArgumentException("Cannot add a top level control to a control.", "value");
495 if (Contains (value)) {
496 owner.PerformLayout();
500 if (value.tab_index == -1) {
506 end = owner.child_controls.Count;
507 for (int i = 0; i < end; i++) {
508 index = owner.child_controls[i].tab_index;
513 value.tab_index = use;
516 if (value.parent != null) {
517 value.parent.Controls.Remove(value);
523 value.ChangeParent(owner);
528 owner.UpdateChildrenZOrder();
529 owner.PerformLayout(value, "Parent");
530 owner.OnControlAdded(new ControlEventArgs(value));
533 internal void AddToList (Control c) {
538 internal virtual void AddImplicit (Control control) {
539 if (impl_list == null)
540 impl_list = new ArrayList ();
542 if (AllContains (control)) {
543 owner.PerformLayout ();
547 if (control.parent != null) {
548 control.parent.Controls.Remove(control);
552 impl_list.Add (control);
554 control.ChangeParent (owner);
555 control.InitLayout ();
557 owner.UpdateChildrenZOrder ();
558 owner.PerformLayout (control, "Parent");
559 owner.OnControlAdded (new ControlEventArgs (control));
562 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
564 public virtual void AddRange (Control[] controls) {
565 if (controls == null)
566 throw new ArgumentNullException ("controls");
568 owner.SuspendLayout ();
571 for (int i = 0; i < controls.Length; i++)
574 owner.ResumeLayout ();
578 internal virtual void AddRangeImplicit (Control [] controls) {
579 if (controls == null)
580 throw new ArgumentNullException ("controls");
582 owner.SuspendLayout ();
585 for (int i = 0; i < controls.Length; i++)
586 AddImplicit (controls [i]);
588 owner.ResumeLayout ();
595 public virtual void Clear () {
598 // MS sends remove events in reverse order
599 while (list.Count > 0) {
600 Remove((Control)list[list.Count - 1]);
604 internal virtual void ClearImplicit () {
605 if (impl_list == null)
611 public bool Contains (Control value) {
612 for (int i = list.Count; i > 0; ) {
615 if (list [i] == value) {
616 // Do we need to do anything here?
623 internal bool ImplicitContains (Control value) {
624 if (impl_list == null)
627 for (int i = impl_list.Count; i > 0; ) {
630 if (impl_list [i] == value) {
631 // Do we need to do anything here?
638 internal bool AllContains (Control value) {
639 return Contains (value) || ImplicitContains (value);
643 public virtual bool ContainsKey (string key)
645 return IndexOfKey (key) >= 0;
649 void ICollection.CopyTo (Array array, int index) {
650 CopyTo (array, index);
654 public void CopyTo (Array array, int index) {
655 list.CopyTo(array, index);
658 public override bool Equals (object other) {
659 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
668 // LAMESPEC: MSDN says AE, MS implementation throws ANE
669 public Control[] Find (string key, bool searchAllChildren)
671 if (string.IsNullOrEmpty (key))
672 throw new ArgumentNullException ("key");
674 ArrayList al = new ArrayList ();
676 foreach (Control c in list) {
677 if (c.Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
680 if (searchAllChildren)
681 al.AddRange (c.Controls.Find (key, true));
684 return (Control[])al.ToArray (typeof (Control));
688 public int GetChildIndex(Control child) {
689 return GetChildIndex(child, false);
697 GetChildIndex(Control child, bool throwException) {
700 index=list.IndexOf(child);
702 if (index==-1 && throwException) {
703 throw new ArgumentException("Not a child control", "child");
709 public override IEnumerator
714 return list.GetEnumerator();
717 internal IEnumerator GetAllEnumerator () {
718 Control [] res = GetAllControls ();
719 return res.GetEnumerator ();
722 internal Control [] GetAllControls () {
723 if (all_controls != null)
726 if (impl_list == null) {
727 all_controls = (Control []) list.ToArray (typeof (Control));
731 all_controls = new Control [list.Count + impl_list.Count];
732 impl_list.CopyTo (all_controls);
733 list.CopyTo (all_controls, impl_list.Count);
739 public override int GetHashCode() {
740 return base.GetHashCode();
744 public int IndexOf(Control control) {
745 return list.IndexOf(control);
749 public virtual int IndexOfKey (string key)
751 if (string.IsNullOrEmpty (key))
754 for (int i = 0; i < list.Count; i++)
755 if (((Control)list[i]).Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
762 public virtual void Remove(Control value) {
766 owner.PerformLayout(value, "Parent");
767 owner.OnControlRemoved(new ControlEventArgs(value));
772 value.ChangeParent(null);
774 owner.UpdateChildrenZOrder();
777 internal virtual void RemoveImplicit (Control control) {
778 if (impl_list != null) {
780 owner.PerformLayout (control, "Parent");
781 owner.OnControlRemoved (new ControlEventArgs (control));
782 impl_list.Remove (control);
784 control.ChangeParent (null);
785 owner.UpdateChildrenZOrder ();
791 public void RemoveAt(int index) {
792 if (index < 0 || index >= list.Count) {
793 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
795 Remove ((Control)list[index]);
799 public virtual void RemoveByKey (string key)
801 int index = IndexOfKey (key);
813 SetChildIndex(Control child, int newIndex) {
815 throw new ArgumentNullException ("child");
819 old_index=list.IndexOf(child);
821 throw new ArgumentException("Not a child control", "child");
824 if (old_index==newIndex) {
829 list.RemoveAt(old_index);
831 if (newIndex>list.Count) {
834 list.Insert(newIndex, child);
836 child.UpdateZOrder();
837 owner.PerformLayout();
839 #endregion // ControlCollection Private Instance Methods
841 #region ControlCollection Interface Properties
842 object IList.this[int index] {
844 if (index<0 || index>=list.Count) {
845 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
851 if (!(value is Control)) {
852 throw new ArgumentException("Object of type Control required", "value");
856 Control ctrl = (Control) value;
859 ctrl.ChangeParent(owner);
863 owner.UpdateChildrenZOrder();
864 owner.PerformLayout(ctrl, "Parent");
868 bool IList.IsFixedSize {
874 bool ICollection.IsSynchronized {
876 return list.IsSynchronized;
880 object ICollection.SyncRoot {
882 return list.SyncRoot;
885 #endregion // ControlCollection Interface Properties
887 #region ControlCollection Interface Methods
888 int IList.Add(object value) {
889 if (!(value is Control)) {
890 throw new ArgumentException("Object of type Control required", "value");
894 throw new ArgumentException("value", "Cannot add null controls");
897 bool owner_permits_toplevels = (owner is MdiClient) || (owner is Form && ((Form)owner).IsMdiContainer);
898 bool child_is_toplevel = ((Control)value).GetTopLevel();
899 bool child_is_mdichild = (value is Form && ((Form)value).IsMdiChild);
901 if (child_is_toplevel && !(owner_permits_toplevels && child_is_mdichild))
902 throw new ArgumentException("Cannot add a top level control to a control.", "value");
904 return list.Add(value);
907 bool IList.Contains(object value) {
908 if (!(value is Control)) {
909 throw new ArgumentException("Object of type Control required", "value");
912 return this.Contains((Control) value);
915 int IList.IndexOf(object value) {
916 if (!(value is Control)) {
917 throw new ArgumentException("Object of type Control required", "value");
920 return this.IndexOf((Control) value);
923 void IList.Insert(int index, object value) {
924 if (!(value is Control)) {
925 throw new ArgumentException("Object of type Control required", "value");
928 list.Insert(index, value);
931 void IList.Remove(object value) {
932 if (!(value is Control)) {
933 throw new ArgumentException("Object of type Control required", "value");
939 Object ICloneable.Clone() {
940 ControlCollection clone = new ControlCollection(this.owner);
941 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
944 #endregion // ControlCollection Interface Methods
946 #endregion // ControlCollection Class
948 #region Public Constructors
951 layout_type = LayoutType.Anchor;
952 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
960 layout_pending = false;
962 causes_validation = true;
964 layout_suspended = 0;
968 right_to_left = RightToLeft.Inherit;
969 border_style = BorderStyle.None;
970 background_color = Color.Empty;
974 ime_mode = ImeMode.Inherit;
975 use_compatible_text_rendering = true;
978 backgroundimage_layout = ImageLayout.Tile;
979 use_compatible_text_rendering = Application.use_compatible_text_rendering;
980 padding = new Padding(0);
981 maximum_size = new Size();
982 minimum_size = new Size();
983 margin = this.DefaultMargin;
986 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
987 ControlStyles.Selectable | ControlStyles.StandardClick |
988 ControlStyles.StandardDoubleClick;
990 control_style |= ControlStyles.UseTextForAccessibility;
994 background_image = null;
998 window_target = new ControlWindowTarget(this);
999 window = new ControlNativeWindow(this);
1000 child_controls = CreateControlsInstance();
1001 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
1002 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
1003 bounds.Size = InternalSizeFromClientSize (client_size);
1004 explicit_bounds = bounds;
1007 public Control (Control parent, string text) : this()
1013 public Control (Control parent, string text, int left, int top, int width, int height) : this()
1019 bounds.Height=height;
1020 SetBounds(left, top, width, height, BoundsSpecified.All);
1024 public Control (string text) : this()
1029 public Control (string text, int left, int top, int width, int height) : this()
1034 bounds.Height=height;
1035 SetBounds(left, top, width, height, BoundsSpecified.All);
1039 private delegate void RemoveDelegate(object c);
1041 protected override void Dispose (bool disposing)
1043 if (!is_disposed && disposing) {
1046 DisposeBackBuffer ();
1052 if (bmp_g != null) {
1057 if (this.InvokeRequired) {
1058 if (Application.MessageLoop && IsHandleCreated) {
1059 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null);
1065 if (parent != null) {
1066 parent.Controls.Remove(this);
1069 Control [] children = child_controls.GetAllControls ();
1070 for (int i=0; i<children.Length; i++) {
1071 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
1072 children[i].Dispose();
1077 base.Dispose(disposing);
1079 #endregion // Public Constructors
1081 #region Internal Properties
1082 // Control is currently selected, like Focused, except maintains state
1083 // when Form loses focus
1084 internal bool InternalSelected {
1086 IContainerControl container;
1088 container = GetContainerControl();
1090 if (container != null && container.ActiveControl == this)
1097 // Mouse is currently within the control's bounds
1098 internal bool Entered {
1099 get { return this.is_entered; }
1102 internal bool VisibleInternal {
1103 get { return is_visible; }
1106 internal LayoutType ControlLayoutType {
1107 get { return layout_type; }
1110 internal BorderStyle InternalBorderStyle {
1112 return border_style;
1116 if (!Enum.IsDefined (typeof (BorderStyle), value))
1117 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
1119 if (border_style != value) {
1120 border_style = value;
1122 if (IsHandleCreated) {
1123 XplatUI.SetBorderStyle (window.Handle, (FormBorderStyle)border_style);
1131 internal Size InternalClientSize { set { this.client_size = value; } }
1132 internal virtual bool ActivateOnShow { get { return true; } }
1133 #endregion // Internal Properties
1135 #region Private & Internal Methods
1138 void IDropTarget.OnDragDrop (DragEventArgs e)
1143 void IDropTarget.OnDragEnter (DragEventArgs e)
1148 void IDropTarget.OnDragLeave (EventArgs e)
1153 void IDropTarget.OnDragOver (DragEventArgs e)
1159 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
1160 return BeginInvokeInternal (method, args, FindControlToInvokeOn ());
1163 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, Control control) {
1164 AsyncMethodResult result;
1165 AsyncMethodData data;
1167 result = new AsyncMethodResult ();
1168 data = new AsyncMethodData ();
1170 data.Handle = control.Handle;
1171 data.Method = method;
1173 data.Result = result;
1176 if (!ExecutionContext.IsFlowSuppressed ()) {
1177 data.Context = ExecutionContext.Capture ();
1180 #if !MWF_ON_MSRUNTIME
1181 if (SecurityManager.SecurityEnabled) {
1182 data.Stack = CompressedStack.GetCompressedStack ();
1187 XplatUI.SendAsyncMethod (data);
1192 internal void PointToClient (ref int x, ref int y) {
1193 XplatUI.ScreenToClient (Handle, ref x, ref y);
1196 internal void PointToScreen (ref int x, ref int y) {
1197 XplatUI.ClientToScreen (Handle, ref x, ref y);
1200 internal bool IsRecreating {
1202 return is_recreating;
1206 internal Graphics DeviceContext {
1208 if (bmp_g == null) {
1209 bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
1210 bmp_g = Graphics.FromImage (bmp);
1216 private Control FindControlToInvokeOn ()
1220 if (p.IsHandleCreated)
1223 } while (p != null);
1225 if (p == null || !p.IsHandleCreated)
1226 throw new InvalidOperationException ("Cannot call Invoke or BeginInvoke on a control until the window handle is created");
1231 private void InvalidateBackBuffer () {
1232 if (backbuffer != null)
1233 backbuffer.Invalidate ();
1236 private DoubleBuffer GetBackBuffer () {
1237 if (backbuffer == null)
1238 backbuffer = new DoubleBuffer (this);
1242 private void DisposeBackBuffer () {
1243 if (backbuffer != null) {
1244 backbuffer.Dispose ();
1249 internal static void SetChildColor(Control parent) {
1252 for (int i=0; i < parent.child_controls.Count; i++) {
1253 child=parent.child_controls[i];
1254 if (child.child_controls.Count>0) {
1255 SetChildColor(child);
1260 internal bool Select(Control control) {
1261 IContainerControl container;
1263 if (control == null) {
1267 container = GetContainerControl();
1268 if (container != null && (Control)container != control) {
1269 container.ActiveControl = control;
1271 else if (control.IsHandleCreated) {
1272 XplatUI.SetFocus(control.window.Handle);
1277 internal virtual void DoDefaultAction() {
1278 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1281 internal static IntPtr MakeParam (int low, int high){
1282 return new IntPtr (high << 16 | low & 0xffff);
1285 internal static int LowOrder (int param) {
1286 return ((int)(short)(param & 0xffff));
1289 internal static int HighOrder (int param) {
1290 return ((int)(short)(param >> 16));
1293 // This method exists so controls overriding OnPaintBackground can have default background painting done
1294 internal virtual void PaintControlBackground (PaintEventArgs pevent) {
1295 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1296 if (parent != null) {
1297 PaintEventArgs parent_pe;
1298 GraphicsState state;
1300 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1302 state = parent_pe.Graphics.Save();
1303 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1304 parent.OnPaintBackground(parent_pe);
1305 parent_pe.Graphics.Restore(state);
1307 state = parent_pe.Graphics.Save();
1308 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1309 parent.OnPaint(parent_pe);
1310 parent_pe.Graphics.Restore(state);
1311 parent_pe.SetGraphics(null);
1315 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1316 if (parent != null) {
1317 PaintEventArgs parent_pe;
1319 GraphicsState state;
1322 hwnd = Hwnd.ObjectFromHandle(Handle);
1325 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1327 region = new Region ();
1329 region.Union(ClientRectangle);
1331 foreach (Rectangle r in hwnd.ClipRectangles) {
1335 state = parent_pe.Graphics.Save();
1336 parent_pe.Graphics.Clip = region;
1338 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1339 parent.OnPaintBackground(parent_pe);
1340 parent_pe.Graphics.Restore(state);
1342 state = parent_pe.Graphics.Save();
1343 parent_pe.Graphics.Clip = region;
1345 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1346 parent.OnPaint(parent_pe);
1347 parent_pe.Graphics.Restore(state);
1348 parent_pe.SetGraphics(null);
1350 region.Intersect(clip_region);
1351 pevent.Graphics.Clip = region;
1356 if (background_image == null) {
1357 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));
1361 DrawBackgroundImage (pevent.Graphics);
1364 void DrawBackgroundImage (Graphics g) {
1366 Rectangle drawing_rectangle = new Rectangle ();
1367 g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
1369 switch (backgroundimage_layout)
1371 case ImageLayout.Tile:
1372 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1373 g.FillRectangle (b, ClientRectangle);
1376 case ImageLayout.Center:
1377 drawing_rectangle.Location = new Point (ClientSize.Width / 2 - background_image.Width / 2, ClientSize.Height / 2 - background_image.Height / 2);
1378 drawing_rectangle.Size = background_image.Size;
1380 case ImageLayout.None:
1381 drawing_rectangle.Location = Point.Empty;
1382 drawing_rectangle.Size = background_image.Size;
1384 case ImageLayout.Stretch:
1385 drawing_rectangle = ClientRectangle;
1387 case ImageLayout.Zoom:
1388 drawing_rectangle = ClientRectangle;
1389 if ((float)background_image.Width / (float)background_image.Height < (float)drawing_rectangle.Width / (float) drawing_rectangle.Height) {
1390 drawing_rectangle.Width = (int) (background_image.Width * ((float)drawing_rectangle.Height / (float)background_image.Height));
1391 drawing_rectangle.X = (ClientRectangle.Width - drawing_rectangle.Width) / 2;
1393 drawing_rectangle.Height = (int) (background_image.Height * ((float)drawing_rectangle.Width / (float)background_image.Width));
1394 drawing_rectangle.Y = (ClientRectangle.Height - drawing_rectangle.Height) / 2;
1401 g.DrawImage (background_image, drawing_rectangle);
1404 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1405 g.FillRectangle (b, ClientRectangle);
1410 internal virtual void DndEnter (DragEventArgs e) {
1416 internal virtual void DndOver (DragEventArgs e) {
1422 internal virtual void DndDrop (DragEventArgs e) {
1425 } catch (Exception exc) {
1426 Console.Error.WriteLine ("MWF: Exception while dropping:");
1427 Console.Error.WriteLine (exc);
1431 internal virtual void DndLeave (EventArgs e) {
1437 internal virtual void DndFeedback(GiveFeedbackEventArgs e) {
1443 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e) {
1445 OnQueryContinueDrag(e);
1449 internal static MouseButtons FromParamToMouseButtons (int param) {
1450 MouseButtons buttons = MouseButtons.None;
1452 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1453 buttons |= MouseButtons.Left;
1455 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1456 buttons |= MouseButtons.Middle;
1458 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1459 buttons |= MouseButtons.Right;
1465 internal virtual void FireEnter () {
1466 OnEnter (EventArgs.Empty);
1469 internal virtual void FireLeave () {
1470 OnLeave (EventArgs.Empty);
1473 internal virtual void FireValidating (CancelEventArgs ce) {
1477 internal virtual void FireValidated () {
1478 OnValidated (EventArgs.Empty);
1481 internal virtual bool ProcessControlMnemonic(char charCode) {
1482 return ProcessMnemonic(charCode);
1485 private static Control FindFlatForward(Control container, Control start) {
1491 end = container.child_controls.Count;
1493 if (start != null) {
1494 index = start.tab_index;
1499 for (int i = 0, pos = -1; i < end; i++) {
1500 if (start == container.child_controls[i]) {
1505 if (found == null) {
1506 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1507 found = container.child_controls[i];
1509 } else if (found.tab_index > container.child_controls[i].tab_index) {
1510 if (container.child_controls[i].tab_index > index) {
1511 found = container.child_controls[i];
1518 private static Control FindControlForward(Control container, Control start) {
1523 if (start == null) {
1524 return FindFlatForward(container, start);
1527 if (start.child_controls != null && start.child_controls.Count > 0 &&
1528 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1529 return FindControlForward(start, null);
1532 while (start != container) {
1533 found = FindFlatForward(start.parent, start);
1534 if (found != null) {
1537 start = start.parent;
1543 private static Control FindFlatBackward(Control container, Control start) {
1549 end = container.child_controls.Count;
1551 if (start != null) {
1552 index = start.tab_index;
1554 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1556 for (int i = 0; i < end; i++) {
1557 if (container.child_controls[i].tab_index > index) {
1558 index = container.child_controls[i].tab_index;
1566 for (int i = end - 1; i >= 0; i--) {
1567 if (start == container.child_controls[i]) {
1572 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1573 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1574 found = container.child_controls[i];
1581 private static Control FindControlBackward(Control container, Control start) {
1583 Control found = null;
1585 if (start == null) {
1586 found = FindFlatBackward(container, start);
1588 else if (start != container) {
1589 if (start.parent != null) {
1590 found = FindFlatBackward(start.parent, start);
1592 if (found == null) {
1593 if (start.parent != container)
1594 return start.parent;
1600 if (found == null || start.parent == null)
1603 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1604 found.child_controls != null && found.child_controls.Count > 0)) {
1605 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1606 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1607 found = FindFlatBackward(found, null);
1617 if (start != null) {
1618 found = FindFlatBackward(start.parent, start);
1619 if (found == null) {
1620 if (start.parent != container) {
1621 return start.parent;
1625 if (found == null) {
1626 found = FindFlatBackward(container, start);
1629 if (container != start) {
1630 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1631 found = FindControlBackward(found, null);
1632 if (found != null) {
1641 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1642 if (GetStyle(ControlStyles.StandardClick)) {
1643 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1645 OnDoubleClick(EventArgs.Empty);
1647 OnClick(EventArgs.Empty);
1650 OnMouseDoubleClick (me);
1659 internal void CaptureWithConfine (Control ConfineWindow) {
1660 if (this.IsHandleCreated && !is_captured) {
1662 XplatUI.GrabWindow (this.window.Handle, ConfineWindow.Handle);
1666 private void CheckDataBindings () {
1667 if (data_bindings == null)
1670 BindingContext binding_context = BindingContext;
1671 foreach (Binding binding in data_bindings) {
1672 binding.Check (binding_context);
1676 private void ChangeParent(Control new_parent) {
1680 Color pre_fore_color;
1681 Color pre_back_color;
1682 RightToLeft pre_rtl;
1684 // These properties are inherited from our parent
1685 // Get them pre parent-change and then send events
1686 // if they are changed after we have our new parent
1687 pre_enabled = Enabled;
1688 pre_visible = Visible;
1690 pre_fore_color = ForeColor;
1691 pre_back_color = BackColor;
1692 pre_rtl = RightToLeft;
1693 // MS doesn't seem to send a CursorChangedEvent
1695 parent = new_parent;
1697 if (IsHandleCreated) {
1698 XplatUI.SetParent(Handle,
1699 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1700 if (this is Form ) {
1701 ((Form) this).ChangingParent (new_parent);
1705 OnParentChanged(EventArgs.Empty);
1707 if (pre_enabled != Enabled) {
1708 OnEnabledChanged(EventArgs.Empty);
1711 if (pre_visible != Visible) {
1712 OnVisibleChanged(EventArgs.Empty);
1715 if (pre_font != Font) {
1716 OnFontChanged(EventArgs.Empty);
1719 if (pre_fore_color != ForeColor) {
1720 OnForeColorChanged(EventArgs.Empty);
1723 if (pre_back_color != BackColor) {
1724 OnBackColorChanged(EventArgs.Empty);
1727 if (pre_rtl != RightToLeft) {
1728 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1729 // because when RTL changes they have to recreate the win32 control
1730 // We don't really need that (until someone runs into compatibility issues)
1731 OnRightToLeftChanged(EventArgs.Empty);
1734 if ((new_parent != null) && new_parent.Created && is_visible && !Created) {
1738 if ((binding_context == null) && Created) {
1739 OnBindingContextChanged(EventArgs.Empty);
1743 // Sometimes we need to do this calculation without it being virtual (constructor)
1744 internal Size InternalSizeFromClientSize (Size clientSize)
1746 Rectangle ClientRect;
1747 Rectangle WindowRect;
1750 ClientRect = new Rectangle (0, 0, clientSize.Width, clientSize.Height);
1751 cp = this.CreateParams;
1753 if (XplatUI.CalculateWindowRect (ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect))
1754 return new Size (WindowRect.Width, WindowRect.Height);
1759 private void UpdateDistances() {
1760 if (parent != null) {
1761 if (bounds.Width >= 0)
1762 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1763 if (bounds.Height >= 0)
1764 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1768 private bool UseDoubleBuffering {
1770 if (!ThemeEngine.Current.DoubleBufferingSupported)
1777 return (control_style & ControlStyles.DoubleBuffer) != 0;
1780 #endregion // Private & Internal Methods
1782 #region Public Static Properties
1783 public static Color DefaultBackColor {
1785 return ThemeEngine.Current.DefaultControlBackColor;
1789 public static Font DefaultFont {
1791 return ThemeEngine.Current.DefaultFont;
1795 public static Color DefaultForeColor {
1797 return ThemeEngine.Current.DefaultControlForeColor;
1801 public static Keys ModifierKeys {
1803 return XplatUI.State.ModifierKeys;
1807 public static MouseButtons MouseButtons {
1809 return XplatUI.State.MouseButtons;
1813 public static Point MousePosition {
1815 return Cursor.Position;
1820 [EditorBrowsable (EditorBrowsableState.Advanced)]
1821 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1824 public static bool CheckForIllegalCrossThreadCalls
1827 return verify_thread_handle;
1831 verify_thread_handle = value;
1835 #endregion // Public Static Properties
1837 #region Public Instance Properties
1838 [EditorBrowsable(EditorBrowsableState.Advanced)]
1840 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1841 public AccessibleObject AccessibilityObject {
1843 if (accessibility_object==null) {
1844 accessibility_object=CreateAccessibilityInstance();
1846 return accessibility_object;
1850 [EditorBrowsable(EditorBrowsableState.Advanced)]
1852 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1853 public string AccessibleDefaultActionDescription {
1855 if (accessibility_object != null)
1856 return accessibility_object.default_action;
1862 if (accessibility_object != null)
1863 accessibility_object.default_action = value;
1868 [DefaultValue(null)]
1869 [MWFCategory("Accessibility")]
1870 public string AccessibleDescription {
1872 if (accessibility_object != null)
1873 return accessibility_object.description;
1879 if (accessibility_object != null)
1880 accessibility_object.description = value;
1885 [DefaultValue(null)]
1886 [MWFCategory("Accessibility")]
1887 public string AccessibleName {
1889 if (accessibility_object != null)
1890 return accessibility_object.Name;
1896 if (accessibility_object != null)
1897 accessibility_object.Name = value;
1901 [DefaultValue(AccessibleRole.Default)]
1902 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1903 public AccessibleRole AccessibleRole {
1905 if (accessibility_object != null)
1906 return accessibility_object.role;
1908 return AccessibleRole.Default;
1912 if (accessibility_object != null)
1913 accessibility_object.role = value;
1917 [DefaultValue(false)]
1918 [MWFCategory("Behavior")]
1919 public virtual bool AllowDrop {
1925 if (allow_drop == value)
1928 if (IsHandleCreated) {
1930 XplatUI.SetAllowDrop (Handle, value);
1936 [RefreshProperties(RefreshProperties.Repaint)]
1937 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1938 [MWFCategory("Layout")]
1939 public virtual AnchorStyles Anchor {
1941 return anchor_style;
1945 layout_type = LayoutType.Anchor;
1947 if (anchor_style == value)
1951 dock_style = DockStyle.None;
1956 parent.PerformLayout(this, "Anchor");
1961 // XXX: Implement me!
1964 [RefreshProperties (RefreshProperties.All)]
1965 [Localizable (true)]
1966 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1968 [EditorBrowsable (EditorBrowsableState.Never)]
1969 [DefaultValue (false)]
1970 [MonoTODO("This method currently does nothing")]
1971 public virtual bool AutoSize {
1972 get { return auto_size; }
1974 if (this.auto_size != value) {
1976 OnAutoSizeChanged (EventArgs.Empty);
1982 [AmbientValue ("{Width=0, Height=0}")]
1984 [AmbientValue (typeof(Size), "0, 0")]
1986 public virtual Size MaximumSize {
1988 return maximum_size;
1991 if (maximum_size != value) {
1992 maximum_size = value;
1993 Size = PreferredSize;
1998 public virtual Size MinimumSize {
2000 return minimum_size;
2003 if (minimum_size != value) {
2004 minimum_size = value;
2005 Size = PreferredSize;
2012 [MWFCategory("Appearance")]
2013 public virtual Color BackColor {
2015 if (background_color.IsEmpty) {
2017 Color pcolor = parent.BackColor;
2018 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
2021 return DefaultBackColor;
2023 return background_color;
2027 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
2028 throw new ArgumentException("Transparent background colors are not supported on this control");
2031 if (background_color != value) {
2032 background_color=value;
2033 SetChildColor(this);
2034 OnBackColorChanged(EventArgs.Empty);
2041 [DefaultValue(null)]
2042 [MWFCategory("Appearance")]
2043 public virtual Image BackgroundImage {
2045 return background_image;
2049 if (background_image!=value) {
2050 background_image=value;
2051 OnBackgroundImageChanged(EventArgs.Empty);
2058 [DefaultValue (ImageLayout.Tile)]
2059 [Localizable (true)]
2060 public virtual ImageLayout BackgroundImageLayout {
2062 return backgroundimage_layout;
2065 if (Array.IndexOf (Enum.GetValues (typeof (ImageLayout)), value) == -1)
2066 throw new InvalidEnumArgumentException ("value", (int) value, typeof(ImageLayout));
2068 if (value != backgroundimage_layout) {
2069 backgroundimage_layout = value;
2071 OnBackgroundImageLayoutChanged (EventArgs.Empty);
2077 [EditorBrowsable(EditorBrowsableState.Advanced)]
2079 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2080 public virtual BindingContext BindingContext {
2082 if (binding_context != null)
2083 return binding_context;
2086 binding_context = Parent.BindingContext;
2087 return binding_context;
2090 if (binding_context != value) {
2091 binding_context = value;
2092 OnBindingContextChanged(EventArgs.Empty);
2097 [EditorBrowsable(EditorBrowsableState.Advanced)]
2099 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2102 return bounds.Y+bounds.Height;
2106 [EditorBrowsable(EditorBrowsableState.Advanced)]
2108 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2109 public Rectangle Bounds {
2115 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
2119 [EditorBrowsable(EditorBrowsableState.Advanced)]
2121 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2122 public bool CanFocus {
2124 if (IsHandleCreated && Visible && Enabled) {
2131 [EditorBrowsable(EditorBrowsableState.Advanced)]
2133 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2134 public bool CanSelect {
2138 if (!GetStyle(ControlStyles.Selectable)) {
2143 while (parent != null) {
2144 if (!parent.is_visible || !parent.is_enabled) {
2148 parent = parent.parent;
2154 internal virtual bool InternalCapture {
2164 [EditorBrowsable(EditorBrowsableState.Advanced)]
2166 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2167 public bool Capture {
2169 return this.is_captured;
2173 // Call OnMouseCaptureChanged when we get WM_CAPTURECHANGED.
2174 if (value != is_captured) {
2177 XplatUI.GrabWindow(Handle, IntPtr.Zero);
2179 if (IsHandleCreated)
2180 XplatUI.UngrabWindow(Handle);
2181 is_captured = false;
2187 [DefaultValue(true)]
2188 [MWFCategory("Focus")]
2189 public bool CausesValidation {
2191 return this.causes_validation;
2195 if (this.causes_validation != value) {
2196 causes_validation = value;
2197 OnCausesValidationChanged(EventArgs.Empty);
2202 [EditorBrowsable(EditorBrowsableState.Advanced)]
2204 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2205 public Rectangle ClientRectangle {
2207 client_rect.Width = client_size.Width;
2208 client_rect.Height = client_size.Height;
2213 [EditorBrowsable(EditorBrowsableState.Advanced)]
2215 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2216 public Size ClientSize {
2219 if ((this is Form) && (((Form)this).form_parent_window != null)) {
2220 return ((Form)this).form_parent_window.ClientSize;
2228 this.SetClientSizeCore(value.Width, value.Height);
2230 this.OnClientSizeChanged (EventArgs.Empty);
2235 [EditorBrowsable(EditorBrowsableState.Advanced)]
2237 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2238 [DescriptionAttribute("ControlCompanyNameDescr")]
2239 public String CompanyName {
2241 return "Mono Project, Novell, Inc.";
2245 [EditorBrowsable(EditorBrowsableState.Advanced)]
2247 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2248 public bool ContainsFocus {
2250 IntPtr focused_window;
2252 focused_window = XplatUI.GetFocus();
2253 if (IsHandleCreated) {
2254 if (focused_window == Handle) {
2258 for (int i=0; i < child_controls.Count; i++) {
2259 if (child_controls[i].ContainsFocus) {
2270 [DefaultValue(null)]
2271 [MWFCategory("Behavior")]
2272 public virtual ContextMenu ContextMenu {
2274 return GetContextMenuInternal ();
2278 if (context_menu != value) {
2279 context_menu = value;
2280 OnContextMenuChanged(EventArgs.Empty);
2285 internal virtual ContextMenu GetContextMenuInternal () {
2286 return context_menu;
2290 [DefaultValue (null)]
2291 public virtual ContextMenuStrip ContextMenuStrip {
2292 get { return this.context_menu_strip; }
2294 if (this.context_menu_strip != value) {
2295 this.context_menu_strip = value;
2296 OnContextMenuStripChanged (EventArgs.Empty);
2303 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2304 public ControlCollection Controls {
2306 return this.child_controls;
2310 [EditorBrowsable(EditorBrowsableState.Advanced)]
2312 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2313 public bool Created {
2315 return (!is_disposed && is_created);
2319 [AmbientValue(null)]
2320 [MWFCategory("Appearance")]
2321 public virtual Cursor Cursor {
2323 if (cursor != null) {
2327 if (parent != null) {
2328 return parent.Cursor;
2331 return Cursors.Default;
2335 if (cursor != value) {
2340 if (IsHandleCreated) {
2341 pt = Cursor.Position;
2343 if (bounds.Contains(pt) || Capture) {
2344 if (GetChildAtPoint(pt) == null) {
2345 if (cursor != null) {
2346 XplatUI.SetCursor(window.Handle, cursor.handle);
2348 if (parent != null) {
2349 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
2351 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
2358 OnCursorChanged(EventArgs.Empty);
2364 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2365 [ParenthesizePropertyName(true)]
2366 [RefreshProperties(RefreshProperties.All)]
2367 [MWFCategory("Data")]
2368 public ControlBindingsCollection DataBindings {
2370 if (data_bindings == null)
2371 data_bindings = new ControlBindingsCollection (this);
2372 return data_bindings;
2376 [EditorBrowsable(EditorBrowsableState.Advanced)]
2378 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2379 public virtual Rectangle DisplayRectangle {
2381 return ClientRectangle;
2385 [EditorBrowsable(EditorBrowsableState.Advanced)]
2387 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2388 public bool Disposing {
2395 [RefreshProperties(RefreshProperties.Repaint)]
2396 [DefaultValue(DockStyle.None)]
2397 [MWFCategory("Layout")]
2398 public virtual DockStyle Dock {
2404 layout_type = LayoutType.Dock;
2406 if (dock_style == value) {
2410 if (!Enum.IsDefined (typeof (DockStyle), value)) {
2411 throw new InvalidEnumArgumentException ("value", (int) value,
2412 typeof (DockStyle));
2416 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
2418 if (dock_style == DockStyle.None) {
2419 if (explicit_bounds == Rectangle.Empty)
2420 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
2422 Bounds = explicit_bounds;
2425 if (parent != null) {
2426 parent.PerformLayout(this, "Dock");
2429 OnDockChanged(EventArgs.Empty);
2434 protected virtual bool DoubleBuffered {
2436 return (control_style & ControlStyles.OptimizedDoubleBuffer) != 0;
2440 if (value == DoubleBuffered)
2443 SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
2445 SetStyle (ControlStyles.OptimizedDoubleBuffer, false);
2454 [MWFCategory("Behavior")]
2455 public bool Enabled {
2461 if (parent != null) {
2462 return parent.Enabled;
2469 if (this.is_enabled != value) {
2470 bool old_value = is_enabled;
2473 if (old_value != value && !value && this.has_focus)
2474 SelectNextControl(this, true, true, true, true);
2476 OnEnabledChanged (EventArgs.Empty);
2481 [EditorBrowsable(EditorBrowsableState.Advanced)]
2483 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2484 public virtual bool Focused {
2486 return this.has_focus;
2491 [AmbientValue(null)]
2493 [MWFCategory("Appearance")]
2494 public virtual Font Font {
2500 if (Parent != null && Parent.Font != null) {
2507 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2509 if (font != null && font.Equals (value)) {
2515 OnFontChanged (EventArgs.Empty);
2521 [MWFCategory("Appearance")]
2522 public virtual Color ForeColor {
2524 if (foreground_color.IsEmpty) {
2526 return parent.ForeColor;
2528 return DefaultForeColor;
2530 return foreground_color;
2534 if (foreground_color != value) {
2535 foreground_color=value;
2537 OnForeColorChanged(EventArgs.Empty);
2544 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2545 public IntPtr Handle { // IWin32Window
2548 if (verify_thread_handle) {
2549 if (this.InvokeRequired) {
2550 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2554 if (!IsHandleCreated) {
2557 return window.Handle;
2561 [EditorBrowsable(EditorBrowsableState.Advanced)]
2563 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2564 public bool HasChildren {
2566 if (this.child_controls.Count>0) {
2573 [EditorBrowsable(EditorBrowsableState.Always)]
2575 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2578 return this.bounds.Height;
2582 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2586 [AmbientValue(ImeMode.Inherit)]
2588 [MWFCategory("Behavior")]
2589 public ImeMode ImeMode {
2591 if (ime_mode == ImeMode.Inherit) {
2593 return parent.ImeMode;
2595 return ImeMode.NoControl; // default value
2601 if (ime_mode != value) {
2604 OnImeModeChanged(EventArgs.Empty);
2609 [EditorBrowsable(EditorBrowsableState.Advanced)]
2611 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2612 public bool InvokeRequired { // ISynchronizeInvoke
2614 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2621 [EditorBrowsable(EditorBrowsableState.Advanced)]
2623 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2624 public bool IsAccessible {
2626 return is_accessible;
2630 is_accessible = value;
2634 [EditorBrowsable(EditorBrowsableState.Advanced)]
2636 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2637 public bool IsDisposed {
2639 return this.is_disposed;
2643 [EditorBrowsable(EditorBrowsableState.Advanced)]
2645 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2646 public bool IsHandleCreated {
2648 if (window == null || window.Handle == IntPtr.Zero)
2651 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2652 if (hwnd != null && hwnd.zombie)
2660 [EditorBrowsable (EditorBrowsableState.Advanced)]
2664 Layout.LayoutEngine LayoutEngine {
2666 if (layout_engine == null)
2667 layout_engine = new Layout.DefaultLayout ();
2668 return layout_engine;
2672 [EditorBrowsable(EditorBrowsableState.Always)]
2674 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2677 return this.bounds.X;
2681 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2686 [MWFCategory("Layout")]
2687 public Point Location {
2689 return new Point(bounds.X, bounds.Y);
2693 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2698 [Localizable (true)]
2699 public Padding Margin {
2700 get { return this.margin; }
2702 if (this.margin != value) {
2703 this.margin = value;
2704 OnMarginChanged (EventArgs.Empty);
2711 public string Name {
2723 public Padding Padding {
2729 if (padding != value) {
2731 OnPaddingChanged (EventArgs.Empty);
2739 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2740 public Control Parent {
2746 if (value == this) {
2747 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2750 if (parent!=value) {
2752 parent.Controls.Remove(this);
2757 value.Controls.Add(this);
2764 public Size PreferredSize {
2765 get { return this.GetPreferredSize (Size.Empty); }
2769 [EditorBrowsable(EditorBrowsableState.Advanced)]
2771 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2772 public string ProductName {
2774 Type t = typeof (AssemblyProductAttribute);
2775 Assembly assembly = GetType().Module.Assembly;
2776 object [] attrs = assembly.GetCustomAttributes (t, false);
2777 AssemblyProductAttribute a = null;
2778 // On MS we get a NullRefException if product attribute is not
2780 if (attrs != null && attrs.Length > 0)
2781 a = (AssemblyProductAttribute) attrs [0];
2786 [EditorBrowsable(EditorBrowsableState.Advanced)]
2788 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2789 public string ProductVersion {
2791 Type t = typeof (AssemblyVersionAttribute);
2792 Assembly assembly = GetType().Module.Assembly;
2793 object [] attrs = assembly.GetCustomAttributes (t, false);
2794 if (attrs == null || attrs.Length < 1)
2796 return ((AssemblyVersionAttribute)attrs [0]).Version;
2800 [EditorBrowsable(EditorBrowsableState.Advanced)]
2802 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2803 public bool RecreatingHandle {
2805 return is_recreating;
2809 [EditorBrowsable(EditorBrowsableState.Advanced)]
2811 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2812 public Region Region {
2818 if (clip_region != value) {
2819 if (value != null && IsHandleCreated)
2820 XplatUI.SetClipRegion(Handle, value);
2822 clip_region = value;
2824 OnRegionChanged (EventArgs.Empty);
2830 [EditorBrowsable(EditorBrowsableState.Advanced)]
2832 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2835 return this.bounds.X+this.bounds.Width;
2839 [AmbientValue(RightToLeft.Inherit)]
2841 [MWFCategory("Appearance")]
2842 public virtual RightToLeft RightToLeft {
2844 if (right_to_left == RightToLeft.Inherit) {
2846 return parent.RightToLeft;
2848 return RightToLeft.No; // default value
2850 return right_to_left;
2854 if (value != right_to_left) {
2855 right_to_left = value;
2856 OnRightToLeftChanged(EventArgs.Empty);
2862 [EditorBrowsable(EditorBrowsableState.Advanced)]
2863 public override ISite Site {
2871 if (value != null) {
2872 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2874 BackColor = ap.BackColor;
2875 ForeColor = ap.ForeColor;
2884 [MWFCategory("Layout")]
2887 return new Size(Width, Height);
2891 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2896 [MergableProperty(false)]
2897 [MWFCategory("Behavior")]
2898 public int TabIndex {
2900 if (tab_index != -1) {
2907 if (tab_index != value) {
2909 OnTabIndexChanged(EventArgs.Empty);
2915 [DefaultValue(true)]
2916 [MWFCategory("Behavior")]
2917 public bool TabStop {
2923 if (tab_stop != value) {
2925 OnTabStopChanged(EventArgs.Empty);
2930 [Localizable(false)]
2932 [TypeConverter(typeof(StringConverter))]
2933 [DefaultValue(null)]
2934 [MWFCategory("Data")]
2941 control_tag = value;
2947 [BindableAttribute(true)]
2948 [MWFCategory("Appearance")]
2949 public virtual string Text {
2951 // Our implementation ignores ControlStyles.CacheText - we always cache
2956 if (value == null) {
2957 value = String.Empty;
2962 if (IsHandleCreated) {
2963 /* we need to call .SetWindowStyle here instead of just .Text
2964 because the presence/absence of Text (== "" or not) can cause
2965 other window style things to appear/disappear */
2966 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2967 XplatUI.Text(Handle, text);
2969 OnTextChanged (EventArgs.Empty);
2974 [EditorBrowsable(EditorBrowsableState.Always)]
2976 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2979 return this.bounds.Y;
2983 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2987 [EditorBrowsable(EditorBrowsableState.Advanced)]
2989 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2990 public Control TopLevelControl {
2994 while (p.parent != null) {
2998 return p is Form ? p : null;
3003 [MWFCategory("Behavior")]
3004 public bool Visible {
3008 } else if (parent != null) {
3009 return parent.Visible;
3016 SetVisibleCore(value);
3020 [EditorBrowsable(EditorBrowsableState.Always)]
3022 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3025 return this.bounds.Width;
3029 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
3033 [EditorBrowsable(EditorBrowsableState.Never)]
3035 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3036 public IWindowTarget WindowTarget {
3037 get { return window_target; }
3038 set { window_target = value; }
3040 #endregion // Public Instance Properties
3042 #region Protected Instance Properties
3043 protected virtual CreateParams CreateParams {
3045 CreateParams create_params = new CreateParams();
3048 create_params.Caption = Text;
3051 create_params.Caption = text;
3055 create_params.X = Left;
3058 create_params.X = this.bounds.X;
3062 create_params.Y = Top;
3065 create_params.Y = this.bounds.Y;
3069 create_params.Width = Width;
3072 create_params.Width = this.bounds.Width;
3076 create_params.Height = Height;
3079 create_params.Height = this.bounds.Height;
3083 create_params.ClassName = XplatUI.DefaultClassName;
3084 create_params.ClassStyle = (int)(XplatUIWin32.ClassStyle.CS_OWNDC | XplatUIWin32.ClassStyle.CS_DBLCLKS);
3085 create_params.ExStyle = 0;
3086 create_params.Param = 0;
3089 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
3092 if ((parent!=null) && (parent.IsHandleCreated)) {
3093 create_params.Parent = parent.Handle;
3096 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
3099 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
3103 create_params.Style |= (int)WindowStyles.WS_DISABLED;
3106 switch (border_style) {
3107 case BorderStyle.FixedSingle:
3108 create_params.Style |= (int) WindowStyles.WS_BORDER;
3110 case BorderStyle.Fixed3D:
3111 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
3115 return create_params;
3120 protected virtual Cursor DefaultCursor { get { return Cursors.Default; } }
3123 protected virtual ImeMode DefaultImeMode {
3125 return ImeMode.Inherit;
3130 protected virtual Padding DefaultMargin {
3131 get { return new Padding (3); }
3134 protected virtual Size DefaultMaximumSize { get { return new Size (); } }
3135 protected virtual Size DefaultMinimumSize { get { return new Size (); } }
3136 protected virtual Padding DefaultPadding { get { return new Padding (); } }
3139 protected virtual Size DefaultSize {
3141 return new Size(0, 0);
3145 protected int FontHeight {
3157 protected bool RenderRightToLeft {
3159 return (this.right_to_left == RightToLeft.Yes);
3163 protected bool ResizeRedraw {
3165 return GetStyle(ControlStyles.ResizeRedraw);
3169 SetStyle(ControlStyles.ResizeRedraw, value);
3173 [EditorBrowsable(EditorBrowsableState.Advanced)]
3175 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3176 protected virtual bool ShowFocusCues {
3182 [EditorBrowsable(EditorBrowsableState.Advanced)]
3184 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
3188 protected bool ShowKeyboardCues {
3193 #endregion // Protected Instance Properties
3195 #region Public Static Methods
3196 [EditorBrowsable(EditorBrowsableState.Advanced)]
3197 public static Control FromChildHandle(IntPtr handle) {
3198 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
3201 [EditorBrowsable(EditorBrowsableState.Advanced)]
3202 public static Control FromHandle(IntPtr handle) {
3203 return Control.ControlNativeWindow.ControlFromHandle(handle);
3206 public static bool IsMnemonic(char charCode, string text) {
3209 amp = text.IndexOf('&');
3212 if (amp + 1 < text.Length) {
3213 if (text[amp + 1] != '&') {
3214 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
3224 #region Protected Static Methods
3225 [EditorBrowsable(EditorBrowsableState.Advanced)]
3226 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
3229 c = Control.FromHandle(hWnd);
3239 #region Public Instance Methods
3240 [EditorBrowsable(EditorBrowsableState.Advanced)]
3241 public IAsyncResult BeginInvoke(Delegate method) {
3242 object [] prms = null;
3243 if (method is EventHandler)
3244 prms = new object [] { this, EventArgs.Empty };
3245 return BeginInvokeInternal(method, prms);
3248 [EditorBrowsable(EditorBrowsableState.Advanced)]
3250 public IAsyncResult BeginInvoke (Delegate method, params object[] args)
3252 public IAsyncResult BeginInvoke (Delegate method, object[] args)
3255 return BeginInvokeInternal (method, args);
3258 public void BringToFront() {
3259 if (parent != null) {
3260 parent.child_controls.SetChildIndex(this, 0);
3262 else if (IsHandleCreated) {
3263 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
3267 public bool Contains(Control ctl) {
3268 while (ctl != null) {
3277 public void CreateControl () {
3279 throw new ObjectDisposedException(GetType().FullName.ToString());
3285 if (!IsHandleCreated) {
3293 if (binding_context == null) { // seem to be sent whenever it's null?
3294 OnBindingContextChanged(EventArgs.Empty);
3300 public Graphics CreateGraphics() {
3301 if (!IsHandleCreated) {
3302 this.CreateHandle();
3304 return Graphics.FromHwnd(this.window.Handle);
3307 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
3308 if (IsHandleCreated)
3309 return XplatUI.StartDrag(Handle, data, allowedEffects);
3311 return DragDropEffects.None;
3314 [EditorBrowsable(EditorBrowsableState.Advanced)]
3315 public object EndInvoke (IAsyncResult async_result) {
3316 AsyncMethodResult result = (AsyncMethodResult) async_result;
3317 return result.EndInvoke ();
3320 public Form FindForm() {
3333 [EditorBrowsable (EditorBrowsableState.Advanced)]
3335 public bool Focus() {
3336 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
3339 is_focusing = false;
3344 internal void FocusInternal () {
3347 is_focusing = false;
3350 public Control GetChildAtPoint(Point pt) {
3351 // MS's version causes the handle to be created. The stack trace shows that get_Handle is called here, but
3352 // we'll just call CreateHandle instead.
3355 // Microsoft's version of this function doesn't seem to work, so I can't check
3356 // if we only consider children or also grandchildren, etc.
3357 // I'm gonna say 'children only'
3358 for (int i=0; i<child_controls.Count; i++) {
3359 if (child_controls[i].Bounds.Contains(pt)) {
3360 return child_controls[i];
3366 public IContainerControl GetContainerControl() {
3367 Control current = this;
3369 while (current!=null) {
3370 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
3371 return (IContainerControl)current;
3373 current = current.parent;
3378 public Control GetNextControl(Control ctl, bool forward) {
3380 if (!this.Contains(ctl)) {
3385 ctl = FindControlForward(this, ctl);
3388 ctl = FindControlBackward(this, ctl);
3398 [EditorBrowsable (EditorBrowsableState.Advanced)]
3399 public virtual Size GetPreferredSize (Size proposedSize) {
3400 Size retsize = this.explicit_bounds.Size;
3402 // If we're bigger than the MaximumSize, fix that
3403 if (this.maximum_size.Width != 0 && retsize.Width > this.maximum_size.Width)
3404 retsize.Width = this.maximum_size.Width;
3405 if (this.maximum_size.Height != 0 && retsize.Height > this.maximum_size.Height)
3406 retsize.Height = this.maximum_size.Height;
3408 // If we're smaller than the MinimumSize, fix that
3409 if (this.minimum_size.Width != 0 && retsize.Width < this.minimum_size.Width)
3410 retsize.Width = this.minimum_size.Width;
3411 if (this.minimum_size.Height != 0 && retsize.Height < this.minimum_size.Height)
3412 retsize.Height = this.minimum_size.Height;
3418 public void Hide() {
3419 this.Visible = false;
3422 public void Invalidate() {
3423 Invalidate(ClientRectangle, false);
3426 public void Invalidate(bool invalidateChildren) {
3427 Invalidate(ClientRectangle, invalidateChildren);
3430 public void Invalidate(System.Drawing.Rectangle rc) {
3431 Invalidate(rc, false);
3434 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
3435 // Win32 invalidates control including when Width and Height is equal 0
3436 // or is not visible, only Paint event must be care about this.
3437 if (!IsHandleCreated)
3440 if (rc.Width > 0 && rc.Height > 0) {
3442 NotifyInvalidate(rc);
3444 XplatUI.Invalidate(Handle, rc, false);
3446 if (invalidateChildren) {
3447 Control [] controls = child_controls.GetAllControls ();
3448 for (int i=0; i<controls.Length; i++)
3449 controls [i].Invalidate ();
3452 OnInvalidated(new InvalidateEventArgs(rc));
3455 public void Invalidate(System.Drawing.Region region) {
3456 Invalidate(region, false);
3459 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
3460 RectangleF bounds = region.GetBounds (CreateGraphics ());
3461 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
3462 invalidateChildren);
3465 public object Invoke (Delegate method) {
3466 object [] prms = null;
3467 if (method is EventHandler)
3468 prms = new object [] { this, EventArgs.Empty };
3470 return Invoke(method, prms);
3473 public object Invoke (Delegate method, params object [] args) {
3475 public object Invoke (Delegate method, object[] args) {
3477 Control control = FindControlToInvokeOn ();
3479 if (!this.InvokeRequired) {
3480 return method.DynamicInvoke(args);
3483 IAsyncResult result = BeginInvokeInternal (method, args, control);
3484 return EndInvoke(result);
3487 [EditorBrowsable(EditorBrowsableState.Advanced)]
3488 public void PerformLayout() {
3489 PerformLayout(null, null);
3492 internal void SetImplicitBounds (int x, int y, int width, int height) {
3493 Rectangle saved_bounds = explicit_bounds;
3494 SetBounds (x, y, width, height);
3495 explicit_bounds = saved_bounds;
3498 [EditorBrowsable(EditorBrowsableState.Advanced)]
3499 public void PerformLayout(Control affectedControl, string affectedProperty) {
3500 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
3502 if (layout_suspended > 0) {
3503 layout_pending = true;
3507 layout_pending = false;
3509 // Prevent us from getting messed up
3512 // Perform all Dock and Anchor calculations
3517 // Need to make sure we decremend layout_suspended
3523 public Point PointToClient (Point p) {
3527 XplatUI.ScreenToClient (Handle, ref x, ref y);
3529 return new Point (x, y);
3532 public Point PointToScreen(Point p) {
3536 XplatUI.ClientToScreen(Handle, ref x, ref y);
3538 return new Point(x, y);
3541 public virtual bool PreProcessMessage(ref Message msg) {
3542 return InternalPreProcessMessage (ref msg);
3545 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3548 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3549 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3551 if (!ProcessCmdKey(ref msg, key_data)) {
3552 if (IsInputKey(key_data)) {
3556 return ProcessDialogKey(key_data);
3560 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3561 if (IsInputChar((char)msg.WParam)) {
3564 return ProcessDialogChar((char)msg.WParam);
3565 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3566 return ProcessDialogChar((char)msg.WParam);
3571 public Rectangle RectangleToClient(Rectangle r) {
3572 return new Rectangle(PointToClient(r.Location), r.Size);
3575 public Rectangle RectangleToScreen(Rectangle r) {
3576 return new Rectangle(PointToScreen(r.Location), r.Size);
3579 public virtual void Refresh() {
3580 if (IsHandleCreated && Visible) {
3582 XplatUI.UpdateWindow(window.Handle);
3584 Control [] controls = child_controls.GetAllControls ();
3585 for (int i=0; i < controls.Length; i++) {
3586 controls[i].Refresh();
3592 [EditorBrowsable(EditorBrowsableState.Never)]
3593 public virtual void ResetBackColor() {
3594 BackColor = Color.Empty;
3597 [EditorBrowsable(EditorBrowsableState.Never)]
3598 public void ResetBindings() {
3599 if (data_bindings != null)
3600 data_bindings.Clear();
3603 [EditorBrowsable(EditorBrowsableState.Never)]
3604 public virtual void ResetCursor() {
3608 [EditorBrowsable(EditorBrowsableState.Never)]
3609 public virtual void ResetFont() {
3613 [EditorBrowsable(EditorBrowsableState.Never)]
3614 public virtual void ResetForeColor() {
3615 foreground_color = Color.Empty;
3618 [EditorBrowsable(EditorBrowsableState.Never)]
3619 public void ResetImeMode() {
3620 ime_mode = DefaultImeMode;
3623 [EditorBrowsable(EditorBrowsableState.Never)]
3624 public virtual void ResetRightToLeft() {
3625 right_to_left = RightToLeft.Inherit;
3628 public virtual void ResetText() {
3629 text = String.Empty;
3632 public void ResumeLayout() {
3633 ResumeLayout (true);
3636 public void ResumeLayout(bool performLayout) {
3637 if (layout_suspended > 0) {
3641 if (layout_suspended == 0) {
3642 if (performLayout && layout_pending) {
3648 [EditorBrowsable (EditorBrowsableState.Never)]
3651 public void Scale(float ratio) {
3652 ScaleCore(ratio, ratio);
3656 [EditorBrowsable (EditorBrowsableState.Never)]
3659 public void Scale(float dx, float dy) {
3664 [EditorBrowsable (EditorBrowsableState.Advanced)]
3665 public void Scale(SizeF factor) {
3666 ScaleCore(factor.Width, factor.Height);
3670 public void Select() {
3671 Select(false, false);
3675 private void printTree(Control c, string t) {
3676 foreach(Control i in c.child_controls) {
3677 Console.WriteLine ("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3678 printTree (i, t+"\t");
3682 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3686 Console.WriteLine("{0}", this.FindForm());
3687 printTree(this, "\t");
3690 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3695 c = GetNextControl(c, forward);
3704 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3705 c.Select (true, true);
3708 } while (c != ctl); // If we wrap back to ourselves we stop
3713 public void SendToBack() {
3714 if (parent != null) {
3715 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3719 public void SetBounds(int x, int y, int width, int height) {
3720 SetBounds(x, y, width, height, BoundsSpecified.All);
3723 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3724 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3728 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3732 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3736 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3740 SetBoundsCore(x, y, width, height, specified);
3742 parent.PerformLayout(this, "Bounds");
3745 public void Show () {
3746 this.Visible = true;
3749 public void SuspendLayout() {
3753 public void Update() {
3754 if (IsHandleCreated) {
3755 XplatUI.UpdateWindow(window.Handle);
3758 #endregion // Public Instance Methods
3760 #region Protected Instance Methods
3761 [EditorBrowsable(EditorBrowsableState.Advanced)]
3762 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3763 // turns out this method causes handle
3764 // creation in 1.1. at first I thought this
3765 // would be accomplished just by using
3766 // get_AccessibilityObject, which would route
3767 // through CreateAccessibilityInstance, which
3768 // calls CreateControl. This isn't the case,
3769 // though (as overriding
3770 // CreateAccessibilityInstance and adding a
3771 // CWL shows nothing. So we fudge it and put
3772 // a CreateHandle here.
3778 if (accessibility_object != null && accessibility_object is ControlAccessibleObject)
3779 ((ControlAccessibleObject)accessibility_object).NotifyClients (accEvent, childID);
3782 [EditorBrowsable(EditorBrowsableState.Advanced)]
3783 protected virtual AccessibleObject CreateAccessibilityInstance() {
3785 return new Control.ControlAccessibleObject(this);
3788 [EditorBrowsable(EditorBrowsableState.Advanced)]
3789 protected virtual ControlCollection CreateControlsInstance() {
3790 return new ControlCollection(this);
3793 [EditorBrowsable(EditorBrowsableState.Advanced)]
3794 protected virtual void CreateHandle() {
3796 throw new ObjectDisposedException(GetType().FullName.ToString());
3799 if (IsHandleCreated && !is_recreating) {
3803 window.CreateHandle(CreateParams);
3805 if (window.Handle != IntPtr.Zero) {
3806 creator_thread = Thread.CurrentThread;
3808 XplatUI.EnableWindow(window.Handle, is_enabled);
3810 if (clip_region != null) {
3811 XplatUI.SetClipRegion(window.Handle, clip_region);
3814 // Set our handle with our parent
3815 if ((parent != null) && (parent.IsHandleCreated)) {
3816 XplatUI.SetParent(window.Handle, parent.Handle);
3820 XplatUI.SetAllowDrop (window.Handle, allow_drop);
3822 // Find out where the window manager placed us
3823 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3824 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3830 [EditorBrowsable(EditorBrowsableState.Advanced)]
3831 protected virtual void DefWndProc(ref Message m) {
3832 window.DefWndProc(ref m);
3835 [EditorBrowsable(EditorBrowsableState.Advanced)]
3836 protected virtual void DestroyHandle() {
3837 if (IsHandleCreated) {
3838 if (window != null) {
3839 window.DestroyHandle();
3845 protected virtual AccessibleObject GetAccessibilityObjectById (int objectId)
3847 // XXX need to implement this.
3852 protected internal bool GetStyle(ControlStyles flag) {
3853 return (control_style & flag) != 0;
3856 protected bool GetTopLevel() {
3860 [EditorBrowsable(EditorBrowsableState.Advanced)]
3861 protected virtual void InitLayout() {
3865 [EditorBrowsable(EditorBrowsableState.Advanced)]
3866 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3867 toInvoke.OnGotFocus(e);
3870 [EditorBrowsable(EditorBrowsableState.Advanced)]
3871 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3872 toInvoke.OnLostFocus(e);
3875 [EditorBrowsable(EditorBrowsableState.Advanced)]
3876 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3877 toInvoke.OnClick(e);
3880 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3881 toInvoke.OnPaint(e);
3884 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3885 toInvoke.OnPaintBackground(e);
3888 protected virtual bool IsInputChar (char charCode) {
3889 // XXX on MS.NET this method causes the handle to be created..
3895 protected virtual bool IsInputKey (Keys keyData) {
3896 // Doc says this one calls IsInputChar; not sure what to do with that
3900 [EditorBrowsable(EditorBrowsableState.Advanced)]
3901 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3905 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3906 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3910 if (parent != null) {
3911 return parent.ProcessCmdKey(ref msg, keyData);
3917 protected virtual bool ProcessDialogChar(char charCode) {
3918 if (parent != null) {
3919 return parent.ProcessDialogChar (charCode);
3925 protected virtual bool ProcessDialogKey (Keys keyData) {
3926 if (parent != null) {
3927 return parent.ProcessDialogKey (keyData);
3933 protected virtual bool ProcessKeyEventArgs (ref Message msg) {
3934 KeyEventArgs key_event;
3937 case (int)Msg.WM_SYSKEYDOWN:
3938 case (int)Msg.WM_KEYDOWN: {
3939 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3940 OnKeyDown (key_event);
3941 return key_event.Handled;
3944 case (int)Msg.WM_SYSKEYUP:
3945 case (int)Msg.WM_KEYUP: {
3946 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3947 OnKeyUp (key_event);
3948 return key_event.Handled;
3951 case (int)Msg.WM_SYSCHAR:
3952 case (int)Msg.WM_CHAR: {
3953 KeyPressEventArgs key_press_event;
3955 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3956 OnKeyPress(key_press_event);
3958 msg.WParam = (IntPtr)key_press_event.KeyChar;
3960 return key_press_event.Handled;
3971 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3972 if (parent != null) {
3973 if (parent.ProcessKeyPreview(ref msg)) {
3978 return ProcessKeyEventArgs(ref msg);
3981 protected virtual bool ProcessKeyPreview(ref Message msg) {
3982 if (parent != null) {
3983 return parent.ProcessKeyPreview(ref msg);
3989 protected virtual bool ProcessMnemonic(char charCode) {
3994 [EditorBrowsable(EditorBrowsableState.Advanced)]
3995 protected void RaiseDragEvent(object key, DragEventArgs e) {
3999 [EditorBrowsable(EditorBrowsableState.Advanced)]
4000 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
4004 [EditorBrowsable(EditorBrowsableState.Advanced)]
4005 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
4009 [EditorBrowsable(EditorBrowsableState.Advanced)]
4010 protected void RaisePaintEvent(object key, PaintEventArgs e) {
4014 private void SetIsRecreating () {
4017 foreach (Control c in Controls.GetAllControls()) {
4018 c.SetIsRecreating ();
4022 [EditorBrowsable(EditorBrowsableState.Advanced)]
4023 protected void RecreateHandle() {
4024 if (!IsHandleCreated)
4028 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
4033 if (IsHandleCreated) {
4035 Console.WriteLine(" + handle is created, destroying it.");
4038 // WM_DESTROY will CreateHandle for us
4041 Console.WriteLine(" + handle is not created, creating it.");
4049 is_recreating = false;
4051 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4057 [EditorBrowsable(EditorBrowsableState.Advanced)]
4058 protected void ResetMouseEventArgs() {
4062 [EditorBrowsable(EditorBrowsableState.Advanced)]
4063 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
4064 if (right_to_left == RightToLeft.No) {
4069 case ContentAlignment.TopLeft: {
4070 return ContentAlignment.TopRight;
4073 case ContentAlignment.TopRight: {
4074 return ContentAlignment.TopLeft;
4077 case ContentAlignment.MiddleLeft: {
4078 return ContentAlignment.MiddleRight;
4081 case ContentAlignment.MiddleRight: {
4082 return ContentAlignment.MiddleLeft;
4085 case ContentAlignment.BottomLeft: {
4086 return ContentAlignment.BottomRight;
4089 case ContentAlignment.BottomRight: {
4090 return ContentAlignment.BottomLeft;
4094 // if it's center it doesn't change
4100 [EditorBrowsable(EditorBrowsableState.Advanced)]
4101 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
4102 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
4106 if (align == HorizontalAlignment.Left) {
4107 return HorizontalAlignment.Right;
4110 // align must be HorizontalAlignment.Right
4111 return HorizontalAlignment.Left;
4114 [EditorBrowsable(EditorBrowsableState.Advanced)]
4115 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
4116 if (right_to_left == RightToLeft.No) {
4120 if (align == LeftRightAlignment.Left) {
4121 return LeftRightAlignment.Right;
4124 // align must be LeftRightAlignment.Right;
4125 return LeftRightAlignment.Left;
4128 [EditorBrowsable(EditorBrowsableState.Advanced)]
4129 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
4130 return RtlTranslateAlignment(align);
4133 [EditorBrowsable(EditorBrowsableState.Advanced)]
4134 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
4135 return RtlTranslateAlignment(align);
4138 [EditorBrowsable(EditorBrowsableState.Advanced)]
4139 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
4140 return RtlTranslateAlignment(align);
4144 [EditorBrowsable (EditorBrowsableState.Never)]
4146 [EditorBrowsable(EditorBrowsableState.Advanced)]
4148 protected virtual void ScaleCore(float dx, float dy) {
4154 location = new Point((int)(Left * dx), (int)(Top * dy));
4155 size = this.ClientSize;
4157 if (!GetStyle(ControlStyles.FixedWidth)) {
4158 size.Width = (int)(size.Width * dx);
4161 if (!GetStyle(ControlStyles.FixedHeight)) {
4162 size.Height = (int)(size.Height * dy);
4165 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
4167 /* Now scale our children */
4168 Control [] controls = child_controls.GetAllControls ();
4169 for (int i=0; i < controls.Length; i++) {
4170 controls[i].Scale(dx, dy);
4176 protected virtual void Select(bool directed, bool forward) {
4177 IContainerControl container;
4179 container = GetContainerControl();
4180 if (container != null && (Control)container != this)
4181 container.ActiveControl = this;
4184 [EditorBrowsable(EditorBrowsableState.Advanced)]
4185 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
4186 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
4187 if (IsHandleCreated) {
4188 XplatUI.SetWindowPos(Handle, x, y, width, height);
4190 // Win32 automatically changes negative width/height to 0.
4191 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
4192 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
4194 if (width < 0 || height < 0) {
4196 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
4200 UpdateBounds(x, y, width, height);
4205 [EditorBrowsable(EditorBrowsableState.Advanced)]
4206 protected virtual void SetClientSizeCore(int x, int y) {
4207 Size NewSize = InternalSizeFromClientSize (new Size (x, y));
4209 if (NewSize != Size.Empty)
4210 SetBounds (bounds.X, bounds.Y, NewSize.Width, NewSize.Height, BoundsSpecified.Size);
4213 [EditorBrowsable(EditorBrowsableState.Advanced)]
4214 protected internal void SetStyle(ControlStyles flag, bool value) {
4216 control_style |= flag;
4218 control_style &= ~flag;
4222 protected void SetTopLevel(bool value) {
4223 if ((GetTopLevel() != value) && (parent != null)) {
4224 throw new ArgumentException ("Cannot change toplevel style of a parented control.");
4227 // XXX MS.NET causes handle to be created here
4231 if (value == true) {
4241 is_toplevel = value;
4244 protected virtual void SetVisibleCore(bool value) {
4245 if (value != is_visible) {
4248 if (is_visible && ((window.Handle == IntPtr.Zero) || !is_created)) {
4252 if (IsHandleCreated) {
4253 XplatUI.SetVisible(Handle, is_visible, true);
4254 // Explicitly move Toplevel windows to where we want them;
4255 // apparently moving unmapped toplevel windows doesn't work
4256 if (is_visible && (this is Form)) {
4257 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
4261 OnVisibleChanged(EventArgs.Empty);
4266 [EditorBrowsable (EditorBrowsableState.Advanced)]
4272 virtual Size SizeFromClientSize (Size clientSize) {
4273 return InternalSizeFromClientSize (clientSize);
4276 [EditorBrowsable(EditorBrowsableState.Advanced)]
4277 protected void UpdateBounds() {
4278 if (!IsHandleCreated)
4288 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
4290 UpdateBounds(x, y, width, height, client_width, client_height);
4293 [EditorBrowsable(EditorBrowsableState.Advanced)]
4294 protected void UpdateBounds(int x, int y, int width, int height) {
4298 // Calculate client rectangle
4299 rect = new Rectangle(0, 0, 0, 0);
4302 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
4303 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
4306 [EditorBrowsable(EditorBrowsableState.Advanced)]
4307 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
4308 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
4310 bool resized = false;
4312 // Needed to generate required notifications
4313 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
4317 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
4324 bounds.Height=height;
4326 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
4327 explicit_bounds = bounds;
4329 client_size.Width=clientWidth;
4330 client_size.Height=clientHeight;
4333 OnLocationChanged(EventArgs.Empty);
4335 if (!background_color.IsEmpty && background_color.A < byte.MaxValue)
4340 OnSizeChanged(EventArgs.Empty);
4342 OnClientSizeChanged (EventArgs.Empty);
4347 [EditorBrowsable(EditorBrowsableState.Advanced)]
4348 protected void UpdateStyles() {
4349 if (!IsHandleCreated) {
4353 XplatUI.SetWindowStyle(window.Handle, CreateParams);
4354 OnStyleChanged(EventArgs.Empty);
4357 private void UpdateZOrderOfChild(Control child) {
4358 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
4361 index = child_controls.IndexOf(child);
4364 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
4366 IntPtr after = AfterTopMostControl ();
4367 if (after != IntPtr.Zero)
4368 XplatUI.SetZOrder (child.Handle, after, false, false);
4370 XplatUI.SetZOrder (child.Handle, IntPtr.Zero, true, false);
4375 // Override this if there is a control that shall always remain on
4376 // top of other controls (such as scrollbars). If there are several
4377 // of these controls, the bottom-most should be returned.
4378 internal virtual IntPtr AfterTopMostControl () {
4382 // internal because we need to call it from ScrollableControl.OnVisibleChanged
4383 internal void UpdateChildrenZOrder() {
4384 Control [] controls;
4386 if (!IsHandleCreated) {
4390 // XXX This code is severely broken. It leaks
4391 // the "zero_sized" abstraction out of the X11
4392 // backend and into Control.cs. It'll work on
4393 // windows simply by virtue of windows never
4394 // setting that field to true.
4396 // basically what we need to guard against is
4397 // calling XplatUI.SetZOrder on an hwnd that
4398 // corresponds to an unmapped X window.
4399 controls = child_controls.GetAllControls ();
4401 ArrayList children_to_order = new ArrayList ();
4403 for (int i = 0; i < controls.Length; i ++) {
4404 if (!controls[i].IsHandleCreated || !controls[i].VisibleInternal)
4407 Hwnd hwnd = Hwnd.ObjectFromHandle (controls[i].Handle);
4408 if (hwnd.zero_sized)
4411 children_to_order.Add (controls[i]);
4414 for (int i = 1; i < children_to_order.Count; i ++) {
4415 Control upper = (Control)children_to_order[i-1];
4416 Control lower = (Control)children_to_order[i];
4418 XplatUI.SetZOrder(lower.Handle, upper.Handle, false, false);
4422 [EditorBrowsable(EditorBrowsableState.Advanced)]
4423 protected void UpdateZOrder() {
4424 if (parent != null) {
4425 parent.UpdateZOrderOfChild(this);
4429 protected virtual void WndProc(ref Message m) {
4431 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
4433 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
4437 switch((Msg)m.Msg) {
4438 case Msg.WM_DESTROY: {
4443 case Msg.WM_WINDOWPOSCHANGED: {
4444 WmWindowPosChanged(ref m);
4448 // Nice description of what should happen when handling WM_PAINT
4449 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4450 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4451 case Msg.WM_PAINT: {
4456 // The DefWndProc will never have to handle this, we always paint the background in managed code
4457 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4458 // here but it just makes things more complicated...
4459 case Msg.WM_ERASEBKGND: {
4460 WmEraseBackground (ref m);
4464 case Msg.WM_LBUTTONUP: {
4465 WmLButtonUp (ref m);
4469 case Msg.WM_LBUTTONDOWN: {
4470 WmLButtonDown (ref m);
4474 case Msg.WM_LBUTTONDBLCLK: {
4475 WmLButtonDblClick (ref m);
4479 case Msg.WM_MBUTTONUP: {
4480 WmMButtonUp (ref m);
4484 case Msg.WM_MBUTTONDOWN: {
4485 WmMButtonDown (ref m);
4489 case Msg.WM_MBUTTONDBLCLK: {
4490 WmMButtonDblClick (ref m);
4494 case Msg.WM_RBUTTONUP: {
4495 WmRButtonUp (ref m);
4499 case Msg.WM_RBUTTONDOWN: {
4500 WmRButtonDown (ref m);
4504 case Msg.WM_RBUTTONDBLCLK: {
4505 WmRButtonDblClick (ref m);
4509 case Msg.WM_CONTEXTMENU: {
4510 WmContextMenu (ref m);
4514 case Msg.WM_MOUSEWHEEL: {
4515 WmMouseWheel (ref m);
4520 case Msg.WM_MOUSEMOVE: {
4521 WmMouseMove (ref m);
4525 case Msg.WM_SHOWWINDOW: {
4526 WmShowWindow (ref m);
4530 case Msg.WM_CREATE: {
4535 case Msg.WM_MOUSE_ENTER: {
4536 WmMouseEnter (ref m);
4540 case Msg.WM_MOUSELEAVE: {
4541 WmMouseLeave (ref m);
4545 case Msg.WM_MOUSEHOVER: {
4546 WmMouseHover (ref m);
4550 case Msg.WM_SYSKEYUP: {
4555 case Msg.WM_SYSKEYDOWN:
4556 case Msg.WM_KEYDOWN:
4558 case Msg.WM_SYSCHAR:
4569 case Msg.WM_KILLFOCUS: {
4570 WmKillFocus (ref m);
4574 case Msg.WM_SETFOCUS: {
4579 case Msg.WM_SYSCOLORCHANGE: {
4580 WmSysColorChange (ref m);
4584 case Msg.WM_SETCURSOR: {
4585 WmSetCursor (ref m);
4589 case Msg.WM_CAPTURECHANGED: {
4590 WmCaptureChanged (ref m);
4599 #endregion // Public Instance Methods
4603 private void WmDestroy (ref Message m) {
4604 OnHandleDestroyed(EventArgs.Empty);
4606 IntPtr handle = window.Handle;
4608 window.InvalidateHandle();
4610 if (is_recreating) {
4612 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4616 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4618 is_recreating = false;
4622 private void WmWindowPosChanged (ref Message m) {
4624 Rectangle save_bounds = explicit_bounds;
4626 explicit_bounds = save_bounds;
4627 if (GetStyle(ControlStyles.ResizeRedraw)) {
4634 // Nice description of what should happen when handling WM_PAINT
4635 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4636 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4637 private void WmPaint (ref Message m) {
4638 PaintEventArgs paint_event;
4640 paint_event = XplatUI.PaintEventStart(Handle, true);
4642 if (paint_event == null) {
4645 DoubleBuffer current_buffer = null;
4646 if (UseDoubleBuffering) {
4647 current_buffer = GetBackBuffer ();
4648 if (!current_buffer.InvalidRegion.IsVisible (paint_event.ClipRectangle)) {
4649 // Just blit the previous image
4650 current_buffer.Blit (paint_event);
4651 XplatUI.PaintEventEnd (Handle, true);
4654 current_buffer.Start (paint_event);
4657 if (!GetStyle(ControlStyles.Opaque)) {
4658 OnPaintBackground(paint_event);
4661 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4662 OnPaintBackgroundInternal(paint_event);
4664 OnPaintInternal(paint_event);
4665 if (!paint_event.Handled) {
4666 OnPaint(paint_event);
4669 if (current_buffer != null) {
4670 current_buffer.End (paint_event);
4674 XplatUI.PaintEventEnd(Handle, true);
4678 private void WmEraseBackground (ref Message m) {
4679 // The DefWndProc will never have to handle this, we always paint the background in managed code
4680 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4681 // here but it just makes things more complicated...
4682 m.Result = (IntPtr)1;
4685 private void WmLButtonUp (ref Message m) {
4688 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4690 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4693 HandleClick(mouse_clicks, me);
4696 if (InternalCapture) {
4697 InternalCapture = false;
4700 if (mouse_clicks > 1) {
4705 private void WmLButtonDown (ref Message m) {
4707 Select (true, true);
4709 InternalCapture = true;
4710 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4711 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4715 private void WmLButtonDblClick (ref Message m) {
4716 InternalCapture = true;
4718 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4719 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4723 private void WmMButtonUp (ref Message m) {
4726 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4728 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4731 HandleClick(mouse_clicks, me);
4733 if (InternalCapture) {
4734 InternalCapture = false;
4736 if (mouse_clicks > 1) {
4741 private void WmMButtonDown (ref Message m) {
4742 InternalCapture = true;
4743 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4744 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4748 private void WmMButtonDblClick (ref Message m) {
4749 InternalCapture = true;
4751 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4752 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4756 private void WmRButtonUp (ref Message m) {
4760 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4761 pt = PointToScreen(pt);
4763 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4765 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4767 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4770 HandleClick(mouse_clicks, me);
4773 if (InternalCapture) {
4774 InternalCapture = false;
4777 if (mouse_clicks > 1) {
4782 private void WmRButtonDown (ref Message m) {
4783 InternalCapture = true;
4784 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4785 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4789 private void WmRButtonDblClick (ref Message m) {
4790 InternalCapture = true;
4792 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4793 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4797 private void WmContextMenu (ref Message m) {
4798 if (context_menu != null) {
4801 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4803 if (pt.X == -1 || pt.Y == -1) {
4804 pt.X = (this.Width / 2) + this.Left;
4805 pt.Y = (this.Height / 2) + this.Top;
4806 pt = this.PointToScreen (pt);
4809 context_menu.Show (this, PointToClient (pt));
4814 // If there isn't a regular context menu, show the Strip version
4815 if (context_menu == null && context_menu_strip != null) {
4818 pt = new Point (LowOrder ((int)m.LParam.ToInt32 ()), HighOrder ((int)m.LParam.ToInt32 ()));
4820 if (pt.X == -1 || pt.Y == -1) {
4821 pt.X = (this.Width / 2) + this.Left;
4822 pt.Y = (this.Height /2) + this.Top;
4823 pt = this.PointToScreen (pt);
4826 context_menu_strip.Show (this, PointToClient (pt));
4833 private void WmCreate (ref Message m) {
4834 OnHandleCreated(EventArgs.Empty);
4837 private void WmMouseWheel (ref Message m) {
4839 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4840 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4841 HighOrder(m.WParam.ToInt32())));
4845 private void WmMouseMove (ref Message m) {
4846 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4848 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4852 private void WmMouseEnter (ref Message m) {
4857 OnMouseEnter(EventArgs.Empty);
4860 private void WmMouseLeave (ref Message m) {
4862 OnMouseLeave(EventArgs.Empty);
4865 private void WmMouseHover (ref Message m) {
4866 OnMouseHover(EventArgs.Empty);
4869 private void WmShowWindow (ref Message m) {
4870 if (m.WParam.ToInt32() != 0) {
4871 /* if we're being shown, make sure our child controls all have their handles created */
4872 Control [] controls = child_controls.GetAllControls ();
4873 for (int i=0; i<controls.Length; i++) {
4874 if (controls [i].is_visible) {
4875 controls [i].CreateControl ();
4876 XplatUI.SetParent(controls[i].Handle, window.Handle);
4881 if (parent != null && Focused) {
4884 // Need to start at parent, GetContainerControl might return ourselves if we're a container
4885 container = (Control)parent.GetContainerControl();
4886 if (container != null) {
4887 container.SelectNextControl(this, true, true, true, true);
4892 if (is_toplevel) /* XXX make sure this works for mdi forms */
4893 OnVisibleChanged(EventArgs.Empty);
4896 private void WmSysKeyUp (ref Message m) {
4897 if (ProcessKeyMessage(ref m)) {
4898 m.Result = IntPtr.Zero;
4902 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4906 if (form != null && form.ActiveMenu != null) {
4907 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4914 private void WmKeys (ref Message m) {
4915 if (ProcessKeyMessage(ref m)) {
4916 m.Result = IntPtr.Zero;
4922 private void WmHelp (ref Message m) {
4924 if (m.LParam != IntPtr.Zero) {
4927 hi = new HELPINFO();
4929 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4930 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4932 mouse_pos = Control.MousePosition;
4934 OnHelpRequested(new HelpEventArgs(mouse_pos));
4935 m.Result = (IntPtr)1;
4938 private void WmKillFocus (ref Message m) {
4939 this.has_focus = false;
4940 OnLostFocus (EventArgs.Empty);
4943 private void WmSetFocus (ref Message m) {
4945 this.has_focus = true;
4946 OnGotFocus (EventArgs.Empty);
4950 private void WmSysColorChange (ref Message m) {
4951 ThemeEngine.Current.ResetDefaults();
4952 OnSystemColorsChanged(EventArgs.Empty);
4955 private void WmSetCursor (ref Message m) {
4956 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4961 XplatUI.SetCursor(window.Handle, cursor.handle);
4962 m.Result = (IntPtr)1;
4965 private void WmCaptureChanged (ref Message m) {
4966 is_captured = false;
4967 OnMouseCaptureChanged (EventArgs.Empty);
4968 m.Result = (IntPtr) 0;
4974 #region OnXXX methods
4976 protected virtual void OnAutoSizeChanged (EventArgs e)
4978 EventHandler eh = (EventHandler)(Events[AutoSizeChangedEvent]);
4984 [EditorBrowsable (EditorBrowsableState.Advanced)]
4985 protected virtual void OnBackColorChanged(EventArgs e) {
4986 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4989 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4992 [EditorBrowsable(EditorBrowsableState.Advanced)]
4993 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4994 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4997 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
5001 [EditorBrowsable (EditorBrowsableState.Advanced)]
5002 protected virtual void OnBackgroundImageLayoutChanged (EventArgs e)
5004 EventHandler eh = (EventHandler)(Events[BackgroundImageLayoutChangedEvent]);
5010 [EditorBrowsable(EditorBrowsableState.Advanced)]
5011 protected virtual void OnBindingContextChanged(EventArgs e) {
5012 CheckDataBindings ();
5013 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
5016 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
5019 [EditorBrowsable(EditorBrowsableState.Advanced)]
5020 protected virtual void OnCausesValidationChanged(EventArgs e) {
5021 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
5026 [EditorBrowsable(EditorBrowsableState.Advanced)]
5027 protected virtual void OnChangeUICues(UICuesEventArgs e) {
5028 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
5033 [EditorBrowsable(EditorBrowsableState.Advanced)]
5034 protected virtual void OnClick(EventArgs e) {
5035 EventHandler eh = (EventHandler)(Events [ClickEvent]);
5041 [EditorBrowsable (EditorBrowsableState.Advanced)]
5042 protected virtual void OnClientSizeChanged (EventArgs e)
5044 EventHandler eh = (EventHandler)(Events[ClientSizeChangedEvent]);
5050 [EditorBrowsable(EditorBrowsableState.Advanced)]
5051 protected virtual void OnContextMenuChanged(EventArgs e) {
5052 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
5058 [EditorBrowsable (EditorBrowsableState.Advanced)]
5059 protected virtual void OnContextMenuStripChanged (EventArgs e) {
5060 EventHandler eh = (EventHandler)(Events [ContextMenuStripChangedEvent]);
5066 [EditorBrowsable(EditorBrowsableState.Advanced)]
5067 protected virtual void OnControlAdded(ControlEventArgs e) {
5068 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
5073 [EditorBrowsable(EditorBrowsableState.Advanced)]
5074 protected virtual void OnControlRemoved(ControlEventArgs e) {
5075 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
5080 [EditorBrowsable(EditorBrowsableState.Advanced)]
5081 protected virtual void OnCreateControl() {
5085 [EditorBrowsable(EditorBrowsableState.Advanced)]
5086 protected virtual void OnCursorChanged(EventArgs e) {
5087 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
5092 [EditorBrowsable(EditorBrowsableState.Advanced)]
5093 protected virtual void OnDockChanged(EventArgs e) {
5094 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
5099 [EditorBrowsable(EditorBrowsableState.Advanced)]
5100 protected virtual void OnDoubleClick(EventArgs e) {
5101 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
5106 [EditorBrowsable(EditorBrowsableState.Advanced)]
5107 protected virtual void OnDragDrop(DragEventArgs drgevent) {
5108 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
5110 eh (this, drgevent);
5113 [EditorBrowsable(EditorBrowsableState.Advanced)]
5114 protected virtual void OnDragEnter(DragEventArgs drgevent) {
5115 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
5117 eh (this, drgevent);
5120 [EditorBrowsable(EditorBrowsableState.Advanced)]
5121 protected virtual void OnDragLeave(EventArgs e) {
5122 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
5127 [EditorBrowsable(EditorBrowsableState.Advanced)]
5128 protected virtual void OnDragOver(DragEventArgs drgevent) {
5129 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
5131 eh (this, drgevent);
5134 [EditorBrowsable(EditorBrowsableState.Advanced)]
5135 protected virtual void OnEnabledChanged(EventArgs e) {
5136 if (IsHandleCreated) {
5138 if (((Form)this).context == null) {
5139 XplatUI.EnableWindow(window.Handle, Enabled);
5142 XplatUI.EnableWindow(window.Handle, Enabled);
5147 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
5151 for (int i=0; i<child_controls.Count; i++) {
5152 child_controls[i].OnParentEnabledChanged(e);
5156 [EditorBrowsable(EditorBrowsableState.Advanced)]
5157 protected virtual void OnEnter(EventArgs e) {
5158 EventHandler eh = (EventHandler)(Events [EnterEvent]);
5163 [EditorBrowsable(EditorBrowsableState.Advanced)]
5164 protected virtual void OnFontChanged(EventArgs e) {
5165 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
5168 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
5171 [EditorBrowsable(EditorBrowsableState.Advanced)]
5172 protected virtual void OnForeColorChanged(EventArgs e) {
5173 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
5176 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
5179 [EditorBrowsable(EditorBrowsableState.Advanced)]
5180 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
5181 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
5183 eh (this, gfbevent);
5186 [EditorBrowsable(EditorBrowsableState.Advanced)]
5187 protected virtual void OnGotFocus(EventArgs e) {
5188 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
5193 [EditorBrowsable(EditorBrowsableState.Advanced)]
5194 protected virtual void OnHandleCreated(EventArgs e) {
5195 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
5200 [EditorBrowsable(EditorBrowsableState.Advanced)]
5201 protected virtual void OnHandleDestroyed(EventArgs e) {
5202 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
5207 internal void RaiseHelpRequested (HelpEventArgs hevent) {
5208 OnHelpRequested (hevent);
5211 [EditorBrowsable(EditorBrowsableState.Advanced)]
5212 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
5213 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
5218 protected virtual void OnImeModeChanged(EventArgs e) {
5219 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
5224 [EditorBrowsable(EditorBrowsableState.Advanced)]
5225 protected virtual void OnInvalidated(InvalidateEventArgs e) {
5226 if (UseDoubleBuffering) {
5227 // should this block be here? seems like it
5228 // would be more at home in
5229 // NotifyInvalidated..
5230 if (e.InvalidRect == ClientRectangle) {
5231 InvalidateBackBuffer ();
5232 } else if (backbuffer != null){
5233 // we need this Inflate call here so
5234 // that the border of the rectangle is
5235 // considered Visible (the
5236 // invalid_region.IsVisible call) in
5237 // the WM_PAINT handling below.
5238 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
5239 backbuffer.InvalidRegion.Union (r);
5243 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
5248 [EditorBrowsable(EditorBrowsableState.Advanced)]
5249 protected virtual void OnKeyDown(KeyEventArgs e) {
5250 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
5255 [EditorBrowsable(EditorBrowsableState.Advanced)]
5256 protected virtual void OnKeyPress(KeyPressEventArgs e) {
5257 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
5262 [EditorBrowsable(EditorBrowsableState.Advanced)]
5263 protected virtual void OnKeyUp(KeyEventArgs e) {
5264 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
5269 [EditorBrowsable(EditorBrowsableState.Advanced)]
5270 protected virtual void OnLayout(LayoutEventArgs levent) {
5271 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
5275 LayoutEngine.Layout (this, levent);
5278 [EditorBrowsable(EditorBrowsableState.Advanced)]
5279 protected virtual void OnLeave(EventArgs e) {
5280 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
5285 [EditorBrowsable(EditorBrowsableState.Advanced)]
5286 protected virtual void OnLocationChanged(EventArgs e) {
5288 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
5293 [EditorBrowsable(EditorBrowsableState.Advanced)]
5294 protected virtual void OnLostFocus(EventArgs e) {
5295 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
5301 protected virtual void OnMarginChanged (EventArgs e)
5303 EventHandler eh = (EventHandler)(Events[MarginChangedEvent]);
5308 [EditorBrowsable (EditorBrowsableState.Advanced)]
5310 protected virtual void OnMouseCaptureChanged (EventArgs e)
5312 internal virtual void OnMouseCaptureChanged (EventArgs e)
5315 EventHandler eh = (EventHandler)(Events [MouseCaptureChangedEvent]);
5321 [EditorBrowsable (EditorBrowsableState.Advanced)]
5322 protected virtual void OnMouseClick (MouseEventArgs e)
5324 MouseEventHandler eh = (MouseEventHandler)(Events [MouseClickEvent]);
5329 [EditorBrowsable (EditorBrowsableState.Advanced)]
5330 protected virtual void OnMouseDoubleClick (MouseEventArgs e)
5332 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDoubleClickEvent]);
5338 [EditorBrowsable(EditorBrowsableState.Advanced)]
5339 protected virtual void OnMouseDown(MouseEventArgs e) {
5340 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
5345 [EditorBrowsable(EditorBrowsableState.Advanced)]
5346 protected virtual void OnMouseEnter(EventArgs e) {
5347 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
5352 [EditorBrowsable(EditorBrowsableState.Advanced)]
5353 protected virtual void OnMouseHover(EventArgs e) {
5354 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
5359 [EditorBrowsable(EditorBrowsableState.Advanced)]
5360 protected virtual void OnMouseLeave(EventArgs e) {
5361 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
5366 [EditorBrowsable(EditorBrowsableState.Advanced)]
5367 protected virtual void OnMouseMove(MouseEventArgs e) {
5368 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
5373 [EditorBrowsable(EditorBrowsableState.Advanced)]
5374 protected virtual void OnMouseUp(MouseEventArgs e) {
5375 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
5380 [EditorBrowsable(EditorBrowsableState.Advanced)]
5381 protected virtual void OnMouseWheel(MouseEventArgs e) {
5382 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
5387 [EditorBrowsable(EditorBrowsableState.Advanced)]
5388 protected virtual void OnMove(EventArgs e) {
5389 EventHandler eh = (EventHandler)(Events [MoveEvent]);
5394 [EditorBrowsable(EditorBrowsableState.Advanced)]
5395 protected virtual void OnNotifyMessage(Message m) {
5400 protected virtual void OnPaddingChanged (EventArgs e) {
5401 EventHandler eh = (EventHandler) (Events [PaddingChangedEvent]);
5407 [EditorBrowsable(EditorBrowsableState.Advanced)]
5408 protected virtual void OnPaint(PaintEventArgs e) {
5409 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
5414 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
5418 internal virtual void OnPaintInternal(PaintEventArgs e) {
5422 [EditorBrowsable(EditorBrowsableState.Advanced)]
5423 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
5424 PaintControlBackground (pevent);
5427 [EditorBrowsable(EditorBrowsableState.Advanced)]
5428 protected virtual void OnParentBackColorChanged(EventArgs e) {
5429 if (background_color.IsEmpty && background_image==null) {
5431 OnBackColorChanged(e);
5435 [EditorBrowsable(EditorBrowsableState.Advanced)]
5436 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
5438 OnBackgroundImageChanged(e);
5441 [EditorBrowsable(EditorBrowsableState.Advanced)]
5442 protected virtual void OnParentBindingContextChanged(EventArgs e) {
5443 if (binding_context==null) {
5444 binding_context=Parent.binding_context;
5445 OnBindingContextChanged(e);
5449 [EditorBrowsable(EditorBrowsableState.Advanced)]
5450 protected virtual void OnParentChanged(EventArgs e) {
5451 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
5456 [EditorBrowsable(EditorBrowsableState.Advanced)]
5457 protected virtual void OnParentEnabledChanged(EventArgs e) {
5459 OnEnabledChanged(e);
5463 [EditorBrowsable(EditorBrowsableState.Advanced)]
5464 protected virtual void OnParentFontChanged(EventArgs e) {
5471 [EditorBrowsable(EditorBrowsableState.Advanced)]
5472 protected virtual void OnParentForeColorChanged(EventArgs e) {
5473 if (foreground_color.IsEmpty) {
5475 OnForeColorChanged(e);
5479 [EditorBrowsable(EditorBrowsableState.Advanced)]
5480 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
5481 if (right_to_left==RightToLeft.Inherit) {
5483 OnRightToLeftChanged(e);
5487 [EditorBrowsable(EditorBrowsableState.Advanced)]
5488 protected virtual void OnParentVisibleChanged(EventArgs e) {
5490 OnVisibleChanged(e);
5494 [EditorBrowsable(EditorBrowsableState.Advanced)]
5495 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
5496 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
5502 [EditorBrowsable (EditorBrowsableState.Advanced)]
5503 protected virtual void OnRegionChanged (EventArgs e)
5505 EventHandler eh = (EventHandler)(Events[RegionChangedEvent]);
5511 [EditorBrowsable(EditorBrowsableState.Advanced)]
5512 protected virtual void OnResize(EventArgs e) {
5513 PerformLayout(this, "Bounds");
5515 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
5520 [EditorBrowsable(EditorBrowsableState.Advanced)]
5521 protected virtual void OnRightToLeftChanged(EventArgs e) {
5522 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
5525 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
5528 [EditorBrowsable(EditorBrowsableState.Advanced)]
5529 protected virtual void OnSizeChanged(EventArgs e) {
5530 DisposeBackBuffer ();
5532 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
5537 [EditorBrowsable(EditorBrowsableState.Advanced)]
5538 protected virtual void OnStyleChanged(EventArgs e) {
5539 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
5544 [EditorBrowsable(EditorBrowsableState.Advanced)]
5545 protected virtual void OnSystemColorsChanged(EventArgs e) {
5546 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
5551 [EditorBrowsable(EditorBrowsableState.Advanced)]
5552 protected virtual void OnTabIndexChanged(EventArgs e) {
5553 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
5558 [EditorBrowsable(EditorBrowsableState.Advanced)]
5559 protected virtual void OnTabStopChanged(EventArgs e) {
5560 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
5565 [EditorBrowsable(EditorBrowsableState.Advanced)]
5566 protected virtual void OnTextChanged(EventArgs e) {
5567 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
5572 [EditorBrowsable(EditorBrowsableState.Advanced)]
5573 protected virtual void OnValidated(EventArgs e) {
5574 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
5579 [EditorBrowsable(EditorBrowsableState.Advanced)]
5580 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
5581 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
5586 [EditorBrowsable(EditorBrowsableState.Advanced)]
5587 protected virtual void OnVisibleChanged(EventArgs e) {
5588 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
5592 // We need to tell our kids
5593 for (int i=0; i<child_controls.Count; i++) {
5594 if (child_controls[i].Visible) {
5595 child_controls[i].OnParentVisibleChanged(e);
5599 #endregion // OnXXX methods
5603 static object AutoSizeChangedEvent = new object ();
5605 static object BackColorChangedEvent = new object ();
5606 static object BackgroundImageChangedEvent = new object ();
5608 static object BackgroundImageLayoutChangedEvent = new object ();
5610 static object BindingContextChangedEvent = new object ();
5611 static object CausesValidationChangedEvent = new object ();
5612 static object ChangeUICuesEvent = new object ();
5613 static object ClickEvent = new object ();
5615 static object ClientSizeChangedEvent = new object ();
5617 static object ContextMenuChangedEvent = new object ();
5619 static object ContextMenuStripChangedEvent = new object ();
5621 static object ControlAddedEvent = new object ();
5622 static object ControlRemovedEvent = new object ();
5623 static object CursorChangedEvent = new object ();
5624 static object DockChangedEvent = new object ();
5625 static object DoubleClickEvent = new object ();
5626 static object DragDropEvent = new object ();
5627 static object DragEnterEvent = new object ();
5628 static object DragLeaveEvent = new object ();
5629 static object DragOverEvent = new object ();
5630 static object EnabledChangedEvent = new object ();
5631 static object EnterEvent = new object ();
5632 static object FontChangedEvent = new object ();
5633 static object ForeColorChangedEvent = new object ();
5634 static object GiveFeedbackEvent = new object ();
5635 static object GotFocusEvent = new object ();
5636 static object HandleCreatedEvent = new object ();
5637 static object HandleDestroyedEvent = new object ();
5638 static object HelpRequestedEvent = new object ();
5639 static object ImeModeChangedEvent = new object ();
5640 static object InvalidatedEvent = new object ();
5641 static object KeyDownEvent = new object ();
5642 static object KeyPressEvent = new object ();
5643 static object KeyUpEvent = new object ();
5644 static object LayoutEvent = new object ();
5645 static object LeaveEvent = new object ();
5646 static object LocationChangedEvent = new object ();
5647 static object LostFocusEvent = new object ();
5649 static object MarginChangedEvent = new object ();
5651 static object MouseCaptureChangedEvent = new object ();
5653 static object MouseClickEvent = new object ();
5654 static object MouseDoubleClickEvent = new object ();
5656 static object MouseDownEvent = new object ();
5657 static object MouseEnterEvent = new object ();
5658 static object MouseHoverEvent = new object ();
5659 static object MouseLeaveEvent = new object ();
5660 static object MouseMoveEvent = new object ();
5661 static object MouseUpEvent = new object ();
5662 static object MouseWheelEvent = new object ();
5663 static object MoveEvent = new object ();
5665 static object PaddingChangedEvent = new object ();
5667 static object PaintEvent = new object ();
5668 static object ParentChangedEvent = new object ();
5670 static object PreviewKeyDownEvent = new object ();
5672 static object QueryAccessibilityHelpEvent = new object ();
5673 static object QueryContinueDragEvent = new object ();
5675 static object RegionChangedEvent = new object ();
5677 static object ResizeEvent = new object ();
5678 static object RightToLeftChangedEvent = new object ();
5679 static object SizeChangedEvent = new object ();
5680 static object StyleChangedEvent = new object ();
5681 static object SystemColorsChangedEvent = new object ();
5682 static object TabIndexChangedEvent = new object ();
5683 static object TabStopChangedEvent = new object ();
5684 static object TextChangedEvent = new object ();
5685 static object ValidatedEvent = new object ();
5686 static object ValidatingEvent = new object ();
5687 static object VisibleChangedEvent = new object ();
5691 [EditorBrowsable (EditorBrowsableState.Never)]
5692 public event EventHandler AutoSizeChanged {
5693 add { Events.AddHandler (AutoSizeChangedEvent, value);}
5694 remove {Events.RemoveHandler (AutoSizeChangedEvent, value);}
5697 public event EventHandler BackColorChanged {
5698 add { Events.AddHandler (BackColorChangedEvent, value); }
5699 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
5702 public event EventHandler BackgroundImageChanged {
5703 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
5704 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
5708 public event EventHandler BackgroundImageLayoutChanged {
5709 add {Events.AddHandler (BackgroundImageLayoutChangedEvent, value);}
5710 remove {Events.RemoveHandler (BackgroundImageLayoutChangedEvent, value);}
5714 public event EventHandler BindingContextChanged {
5715 add { Events.AddHandler (BindingContextChangedEvent, value); }
5716 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
5719 public event EventHandler CausesValidationChanged {
5720 add { Events.AddHandler (CausesValidationChangedEvent, value); }
5721 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
5724 public event UICuesEventHandler ChangeUICues {
5725 add { Events.AddHandler (ChangeUICuesEvent, value); }
5726 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
5729 public event EventHandler Click {
5730 add { Events.AddHandler (ClickEvent, value); }
5731 remove { Events.RemoveHandler (ClickEvent, value); }
5735 public event EventHandler ClientSizeChanged {
5736 add {Events.AddHandler (ClientSizeChangedEvent, value);}
5737 remove {Events.RemoveHandler (ClientSizeChangedEvent, value);}
5744 public event EventHandler ContextMenuChanged {
5745 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5746 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5750 public event EventHandler ContextMenuStripChanged {
5751 add { Events.AddHandler (ContextMenuStripChangedEvent, value); }
5752 remove { Events.RemoveHandler (ContextMenuStripChangedEvent, value);}
5757 [EditorBrowsable(EditorBrowsableState.Advanced)]
5763 public event ControlEventHandler ControlAdded {
5764 add { Events.AddHandler (ControlAddedEvent, value); }
5765 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5768 [EditorBrowsable(EditorBrowsableState.Advanced)]
5774 public event ControlEventHandler ControlRemoved {
5775 add { Events.AddHandler (ControlRemovedEvent, value); }
5776 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5779 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5780 public event EventHandler CursorChanged {
5781 add { Events.AddHandler (CursorChangedEvent, value); }
5782 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5784 public event EventHandler DockChanged {
5785 add { Events.AddHandler (DockChangedEvent, value); }
5786 remove { Events.RemoveHandler (DockChangedEvent, value); }
5789 public event EventHandler DoubleClick {
5790 add { Events.AddHandler (DoubleClickEvent, value); }
5791 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5794 public event DragEventHandler DragDrop {
5795 add { Events.AddHandler (DragDropEvent, value); }
5796 remove { Events.RemoveHandler (DragDropEvent, value); }
5799 public event DragEventHandler DragEnter {
5800 add { Events.AddHandler (DragEnterEvent, value); }
5801 remove { Events.RemoveHandler (DragEnterEvent, value); }
5804 public event EventHandler DragLeave {
5805 add { Events.AddHandler (DragLeaveEvent, value); }
5806 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5809 public event DragEventHandler DragOver {
5810 add { Events.AddHandler (DragOverEvent, value); }
5811 remove { Events.RemoveHandler (DragOverEvent, value); }
5814 public event EventHandler EnabledChanged {
5815 add { Events.AddHandler (EnabledChangedEvent, value); }
5816 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5819 public event EventHandler Enter {
5820 add { Events.AddHandler (EnterEvent, value); }
5821 remove { Events.RemoveHandler (EnterEvent, value); }
5824 public event EventHandler FontChanged {
5825 add { Events.AddHandler (FontChangedEvent, value); }
5826 remove { Events.RemoveHandler (FontChangedEvent, value); }
5829 public event EventHandler ForeColorChanged {
5830 add { Events.AddHandler (ForeColorChangedEvent, value); }
5831 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5834 public event GiveFeedbackEventHandler GiveFeedback {
5835 add { Events.AddHandler (GiveFeedbackEvent, value); }
5836 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5839 [EditorBrowsable(EditorBrowsableState.Advanced)]
5841 public event EventHandler GotFocus {
5842 add { Events.AddHandler (GotFocusEvent, value); }
5843 remove { Events.RemoveHandler (GotFocusEvent, value); }
5847 [EditorBrowsable(EditorBrowsableState.Advanced)]
5849 public event EventHandler HandleCreated {
5850 add { Events.AddHandler (HandleCreatedEvent, value); }
5851 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5854 [EditorBrowsable(EditorBrowsableState.Advanced)]
5856 public event EventHandler HandleDestroyed {
5857 add { Events.AddHandler (HandleDestroyedEvent, value); }
5858 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5861 public event HelpEventHandler HelpRequested {
5862 add { Events.AddHandler (HelpRequestedEvent, value); }
5863 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5866 public event EventHandler ImeModeChanged {
5867 add { Events.AddHandler (ImeModeChangedEvent, value); }
5868 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5871 [EditorBrowsable(EditorBrowsableState.Advanced)]
5873 public event InvalidateEventHandler Invalidated {
5874 add { Events.AddHandler (InvalidatedEvent, value); }
5875 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5878 public event KeyEventHandler KeyDown {
5879 add { Events.AddHandler (KeyDownEvent, value); }
5880 remove { Events.RemoveHandler (KeyDownEvent, value); }
5883 public event KeyPressEventHandler KeyPress {
5884 add { Events.AddHandler (KeyPressEvent, value); }
5885 remove { Events.RemoveHandler (KeyPressEvent, value); }
5888 public event KeyEventHandler KeyUp {
5889 add { Events.AddHandler (KeyUpEvent, value); }
5890 remove { Events.RemoveHandler (KeyUpEvent, value); }
5893 public event LayoutEventHandler Layout {
5894 add { Events.AddHandler (LayoutEvent, value); }
5895 remove { Events.RemoveHandler (LayoutEvent, value); }
5898 public event EventHandler Leave {
5899 add { Events.AddHandler (LeaveEvent, value); }
5900 remove { Events.RemoveHandler (LeaveEvent, value); }
5903 public event EventHandler LocationChanged {
5904 add { Events.AddHandler (LocationChangedEvent, value); }
5905 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5908 [EditorBrowsable(EditorBrowsableState.Advanced)]
5910 public event EventHandler LostFocus {
5911 add { Events.AddHandler (LostFocusEvent, value); }
5912 remove { Events.RemoveHandler (LostFocusEvent, value); }
5916 public event EventHandler MarginChanged {
5917 add { Events.AddHandler (MarginChangedEvent, value); }
5918 remove {Events.RemoveHandler (MarginChangedEvent, value); }
5922 public event EventHandler MouseCaptureChanged {
5924 internal event EventHandler MouseCaptureChanged {
5926 add { Events.AddHandler (MouseCaptureChangedEvent, value); }
5927 remove { Events.RemoveHandler (MouseCaptureChangedEvent, value); }
5930 public event MouseEventHandler MouseClick
5932 add { Events.AddHandler (MouseClickEvent, value); }
5933 remove { Events.RemoveHandler (MouseClickEvent, value); }
5935 public event MouseEventHandler MouseDoubleClick
5937 add { Events.AddHandler (MouseDoubleClickEvent, value); }
5938 remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
5941 public event MouseEventHandler MouseDown {
5942 add { Events.AddHandler (MouseDownEvent, value); }
5943 remove { Events.RemoveHandler (MouseDownEvent, value); }
5946 public event EventHandler MouseEnter {
5947 add { Events.AddHandler (MouseEnterEvent, value); }
5948 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5951 public event EventHandler MouseHover {
5952 add { Events.AddHandler (MouseHoverEvent, value); }
5953 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5956 public event EventHandler MouseLeave {
5957 add { Events.AddHandler (MouseLeaveEvent, value); }
5958 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5961 public event MouseEventHandler MouseMove {
5962 add { Events.AddHandler (MouseMoveEvent, value); }
5963 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5966 public event MouseEventHandler MouseUp {
5967 add { Events.AddHandler (MouseUpEvent, value); }
5968 remove { Events.RemoveHandler (MouseUpEvent, value); }
5971 [EditorBrowsable(EditorBrowsableState.Advanced)]
5973 public event MouseEventHandler MouseWheel {
5974 add { Events.AddHandler (MouseWheelEvent, value); }
5975 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5978 public event EventHandler Move {
5979 add { Events.AddHandler (MoveEvent, value); }
5980 remove { Events.RemoveHandler (MoveEvent, value); }
5983 public event EventHandler PaddingChanged
5985 add { Events.AddHandler (PaddingChangedEvent, value); }
5986 remove { Events.RemoveHandler (PaddingChangedEvent, value); }
5989 public event PaintEventHandler Paint {
5990 add { Events.AddHandler (PaintEvent, value); }
5991 remove { Events.RemoveHandler (PaintEvent, value); }
5994 public event EventHandler ParentChanged {
5995 add { Events.AddHandler (ParentChangedEvent, value); }
5996 remove { Events.RemoveHandler (ParentChangedEvent, value); }
6000 public event PreviewKeyDownEventHandler PreviewKeyDown {
6001 add { Events.AddHandler (PreviewKeyDownEvent, value); }
6002 remove { Events.RemoveHandler (PreviewKeyDownEvent, value); }
6006 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
6007 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
6008 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
6011 public event QueryContinueDragEventHandler QueryContinueDrag {
6012 add { Events.AddHandler (QueryContinueDragEvent, value); }
6013 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
6017 public event EventHandler RegionChanged {
6018 add { Events.AddHandler (RegionChangedEvent, value); }
6019 remove { Events.RemoveHandler (RegionChangedEvent, value); }
6024 [EditorBrowsable (EditorBrowsableState.Advanced)]
6026 public event EventHandler Resize {
6027 add { Events.AddHandler (ResizeEvent, value); }
6028 remove { Events.RemoveHandler (ResizeEvent, value); }
6031 public event EventHandler RightToLeftChanged {
6032 add { Events.AddHandler (RightToLeftChangedEvent, value); }
6033 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
6036 public event EventHandler SizeChanged {
6037 add { Events.AddHandler (SizeChangedEvent, value); }
6038 remove { Events.RemoveHandler (SizeChangedEvent, value); }
6041 public event EventHandler StyleChanged {
6042 add { Events.AddHandler (StyleChangedEvent, value); }
6043 remove { Events.RemoveHandler (StyleChangedEvent, value); }
6046 public event EventHandler SystemColorsChanged {
6047 add { Events.AddHandler (SystemColorsChangedEvent, value); }
6048 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
6051 public event EventHandler TabIndexChanged {
6052 add { Events.AddHandler (TabIndexChangedEvent, value); }
6053 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
6056 public event EventHandler TabStopChanged {
6057 add { Events.AddHandler (TabStopChangedEvent, value); }
6058 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
6061 public event EventHandler TextChanged {
6062 add { Events.AddHandler (TextChangedEvent, value); }
6063 remove { Events.RemoveHandler (TextChangedEvent, value); }
6066 public event EventHandler Validated {
6067 add { Events.AddHandler (ValidatedEvent, value); }
6068 remove { Events.RemoveHandler (ValidatedEvent, value); }
6071 public event CancelEventHandler Validating {
6072 add { Events.AddHandler (ValidatingEvent, value); }
6073 remove { Events.RemoveHandler (ValidatingEvent, value); }
6076 public event EventHandler VisibleChanged {
6077 add { Events.AddHandler (VisibleChangedEvent, value); }
6078 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
6081 #endregion // Events