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
39 using System.ComponentModel;
40 using System.ComponentModel.Design;
41 using System.ComponentModel.Design.Serialization;
42 using System.Collections;
43 using System.Diagnostics;
45 using System.Drawing.Drawing2D;
46 using System.Reflection;
47 using System.Runtime.InteropServices;
48 using System.Security;
49 using System.Threading;
51 namespace System.Windows.Forms
53 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
54 [DefaultProperty("Text")]
55 [DefaultEvent("Click")]
56 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
57 [ToolboxItemFilter("System.Windows.Forms")]
58 public class Control : Component, ISynchronizeInvoke, IWin32Window
60 #region Local Variables
63 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
64 Rectangle explicit_bounds; // explicitly set bounds
65 internal object creator_thread; // thread that created the control
66 internal ControlNativeWindow window; // object for native window handle
67 string name; // for object naming
70 bool is_created; // true if OnCreateControl has been sent
71 internal bool has_focus; // true if control has focus
72 internal bool is_visible; // true if control is visible
73 internal bool is_entered; // is the mouse inside the control?
74 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
75 bool is_accessible; // true if the control is visible to accessibility applications
76 bool is_captured; // tracks if the control has captured the mouse
77 internal bool is_toplevel; // tracks if the control is a toplevel window
78 bool is_recreating; // tracks if the handle for the control is being recreated
79 bool causes_validation; // tracks if validation is executed on changes
80 bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
81 int tab_index; // position in tab order of siblings
82 bool tab_stop; // is the control a tab stop?
83 bool is_disposed; // has the window already been disposed?
84 Size client_size; // size of the client area (window excluding decorations)
85 Rectangle client_rect; // rectangle with the client area (window excluding decorations)
86 ControlStyles control_style; // rather win32-specific, style bits for control
88 bool layout_pending; // true if our parent needs to re-layout us
89 object control_tag; // object that contains data about our control
90 internal int mouse_clicks; // Counter for mouse clicks
91 Cursor cursor; // Cursor for the window
92 internal bool allow_drop; // true if the control accepts droping objects on it
93 Region clip_region; // User-specified clip region for the window
96 internal Color foreground_color; // foreground color for control
97 internal Color background_color; // background color for control
98 Image background_image; // background image for control
99 internal Font font; // font for control
100 string text; // window/title text for control
101 internal BorderStyle border_style; // Border style of control
104 int layout_suspended;
105 internal AnchorStyles anchor_style; // anchoring requirements for our control
106 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
107 // Please leave the next 4 as internal until DefaultLayout (2.0) is rewritten
108 internal int dist_left; // distance to the left border of the parent
109 internal int dist_top; // distance to the top border of the parent
110 internal int dist_right; // distance to the right border of the parent
111 internal int dist_bottom; // distance to the bottom border of the parent
113 // to be categorized...
114 ControlCollection child_controls; // our children
115 Control parent; // our parent control
116 AccessibleObject accessibility_object; // object that contains accessibility information about our control
117 BindingContext binding_context;
118 RightToLeft right_to_left; // drawing direction for control
119 ContextMenu context_menu; // Context menu associated with the control
122 Graphics backbuffer_dc;
124 Region invalid_region;
126 ControlBindingsCollection data_bindings;
129 internal bool use_compatible_text_rendering;
130 static bool verify_thread_handle;
136 Layout.LayoutEngine layout_engine;
139 #endregion // Local Variables
141 #region Private Classes
142 // This helper class allows us to dispatch messages to Control.WndProc
143 internal class ControlNativeWindow : NativeWindow {
144 private Control owner;
146 public ControlNativeWindow(Control control) : base() {
151 public Control Owner {
157 static internal Control ControlFromHandle(IntPtr hWnd) {
158 ControlNativeWindow window;
160 window = (ControlNativeWindow)window_collection[hWnd];
161 if (window != null) {
168 static internal Control ControlFromChildHandle (IntPtr handle) {
169 ControlNativeWindow window;
171 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
172 while (hwnd != null) {
173 window = (ControlNativeWindow)window_collection[hwnd.Handle];
174 if (window != null) {
183 protected override void WndProc(ref Message m) {
184 owner.WndProc(ref m);
189 #region Public Classes
191 public class ControlAccessibleObject : AccessibleObject {
194 #region ControlAccessibleObject Constructors
195 public ControlAccessibleObject(Control ownerControl)
196 : base (ownerControl)
198 this.owner = ownerControl;
200 #endregion // ControlAccessibleObject Constructors
202 #region ControlAccessibleObject Public Instance Properties
203 public override string DefaultAction {
205 return base.DefaultAction;
209 public override string Description {
211 return base.Description;
215 public IntPtr Handle {
221 // We don't want to let them set it
225 public override string Help {
231 public override string KeyboardShortcut {
233 return base.KeyboardShortcut;
237 public override string Name {
247 public Control Owner {
253 public override AccessibleObject Parent {
260 public override AccessibleRole Role {
265 #endregion // ControlAccessibleObject Public Instance Properties
267 #region ControlAccessibleObject Public Instance Methods
268 public override int GetHelpTopic(out string FileName) {
269 return base.GetHelpTopic (out FileName);
272 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
273 public void NotifyClients(AccessibleEvents accEvent) {
274 throw new NotImplementedException();
277 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
278 public void NotifyClients(AccessibleEvents accEvent, int childID) {
279 throw new NotImplementedException();
282 public override string ToString() {
283 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
286 #endregion // ControlAccessibleObject Public Instance Methods
289 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
290 [ListBindable(false)]
291 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
292 #region ControlCollection Local Variables
295 Control[] all_controls;
297 #endregion // ControlCollection Local Variables
299 #region ControlCollection Public Constructor
300 public ControlCollection(Control owner) {
302 this.list=new ArrayList();
306 #region ControlCollection Public Instance Properties
313 public bool IsReadOnly {
315 return list.IsReadOnly;
319 public virtual Control this[int index] {
321 if (index < 0 || index >= list.Count) {
322 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
324 return (Control)list[index];
327 #endregion // ControlCollection Public Instance Properties
329 #region ControlCollection Private Instance Methods
330 public virtual void Add (Control value)
335 if (Contains (value)) {
336 owner.PerformLayout();
340 if (value.tab_index == -1) {
346 end = owner.child_controls.Count;
347 for (int i = 0; i < end; i++) {
348 index = owner.child_controls[i].tab_index;
353 value.tab_index = use;
356 if (value.parent != null) {
357 value.parent.Controls.Remove(value);
363 value.ChangeParent(owner);
367 owner.UpdateChildrenZOrder();
368 owner.PerformLayout(value, "Parent");
369 owner.OnControlAdded(new ControlEventArgs(value));
372 internal void AddToList (Control c)
378 internal virtual void AddImplicit (Control control)
380 if (impl_list == null)
381 impl_list = new ArrayList ();
383 if (AllContains (control))
387 impl_list.Add (control);
389 control.ChangeParent (owner);
390 control.InitLayout ();
391 owner.UpdateChildrenZOrder ();
392 owner.PerformLayout (control, "Parent");
393 owner.OnControlAdded (new ControlEventArgs (control));
396 public virtual void AddRange (Control[] controls)
398 if (controls == null)
399 throw new ArgumentNullException ("controls");
401 owner.SuspendLayout ();
404 for (int i = 0; i < controls.Length; i++)
407 owner.ResumeLayout ();
411 internal virtual void AddRangeImplicit (Control [] controls)
413 if (controls == null)
414 throw new ArgumentNullException ("controls");
416 owner.SuspendLayout ();
419 for (int i = 0; i < controls.Length; i++)
420 AddImplicit (controls [i]);
422 owner.ResumeLayout ();
426 public virtual void Clear ()
430 // MS sends remove events in reverse order
431 while (list.Count > 0) {
432 Remove((Control)list[list.Count - 1]);
436 internal virtual void ClearImplicit ()
438 if (impl_list == null)
444 public bool Contains (Control value)
446 for (int i = list.Count; i > 0; ) {
449 if (list [i] == value) {
450 // Do we need to do anything here?
457 internal bool ImplicitContains (Control value)
459 if (impl_list == null)
462 for (int i = impl_list.Count; i > 0; ) {
465 if (impl_list [i] == value) {
466 // Do we need to do anything here?
473 internal bool AllContains (Control value)
475 return Contains (value) || ImplicitContains (value);
478 public void CopyTo (Array array, int index)
480 list.CopyTo(array, index);
483 public override bool Equals(object other) {
484 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
491 public int GetChildIndex(Control child) {
492 return GetChildIndex(child, false);
495 public int GetChildIndex(Control child, bool throwException) {
498 index=list.IndexOf(child);
500 if (index==-1 && throwException) {
501 throw new ArgumentException("Not a child control", "child");
506 public IEnumerator GetEnumerator() {
507 return list.GetEnumerator();
510 internal IEnumerator GetAllEnumerator ()
512 Control [] res = GetAllControls ();
513 return res.GetEnumerator ();
516 internal Control [] GetAllControls ()
518 if (all_controls != null)
521 if (impl_list == null) {
522 all_controls = (Control []) list.ToArray (typeof (Control));
526 all_controls = new Control [list.Count + impl_list.Count];
527 impl_list.CopyTo (all_controls);
528 list.CopyTo (all_controls, impl_list.Count);
533 public override int GetHashCode() {
534 return base.GetHashCode();
537 public int IndexOf(Control control) {
538 return list.IndexOf(control);
541 public virtual void Remove(Control value) {
545 owner.PerformLayout(value, "Parent");
546 owner.OnControlRemoved(new ControlEventArgs(value));
551 value.ChangeParent(null);
553 owner.UpdateChildrenZOrder();
556 internal virtual void RemoveImplicit (Control control)
558 if (impl_list != null) {
560 owner.PerformLayout (control, "Parent");
561 owner.OnControlRemoved (new ControlEventArgs (control));
562 impl_list.Remove (control);
564 control.ChangeParent (null);
565 owner.UpdateChildrenZOrder ();
568 public void RemoveAt(int index) {
569 if (index < 0 || index >= list.Count) {
570 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
572 Remove ((Control)list[index]);
575 public void SetChildIndex(Control child, int newIndex) {
577 throw new ArgumentNullException ("child");
581 old_index=list.IndexOf(child);
583 throw new ArgumentException("Not a child control", "child");
586 if (old_index==newIndex) {
591 list.RemoveAt(old_index);
593 if (newIndex>list.Count) {
596 list.Insert(newIndex, child);
598 child.UpdateZOrder();
599 owner.PerformLayout();
601 #endregion // ControlCollection Private Instance Methods
603 #region ControlCollection Interface Properties
604 object IList.this[int index] {
606 if (index<0 || index>=list.Count) {
607 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
613 if (!(value is Control)) {
614 throw new ArgumentException("Object of type Control required", "value");
618 Control ctrl = (Control) value;
621 ctrl.ChangeParent(owner);
625 owner.UpdateChildrenZOrder();
626 owner.PerformLayout(ctrl, "Parent");
630 bool IList.IsFixedSize {
636 bool ICollection.IsSynchronized {
638 return list.IsSynchronized;
642 object ICollection.SyncRoot {
644 return list.SyncRoot;
647 #endregion // ControlCollection Interface Properties
649 #region ControlCollection Interface Methods
650 int IList.Add(object value) {
652 throw new ArgumentNullException("value", "Cannot add null controls");
655 if (!(value is Control)) {
656 throw new ArgumentException("Object of type Control required", "value");
659 return list.Add(value);
662 bool IList.Contains(object value) {
663 if (!(value is Control)) {
664 throw new ArgumentException("Object of type Control required", "value");
667 return this.Contains((Control) value);
670 int IList.IndexOf(object value) {
671 if (!(value is Control)) {
672 throw new ArgumentException("Object of type Control required", "value");
675 return this.IndexOf((Control) value);
678 void IList.Insert(int index, object value) {
679 if (!(value is Control)) {
680 throw new ArgumentException("Object of type Control required", "value");
683 list.Insert(index, value);
686 void IList.Remove(object value) {
687 if (!(value is Control)) {
688 throw new ArgumentException("Object of type Control required", "value");
694 Object ICloneable.Clone() {
695 ControlCollection clone = new ControlCollection(this.owner);
696 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
699 #endregion // ControlCollection Interface Methods
701 #endregion // ControlCollection Class
703 #region Public Constructors
706 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
714 layout_pending = false;
716 causes_validation = true;
718 layout_suspended = 0;
722 right_to_left = RightToLeft.Inherit;
723 border_style = BorderStyle.None;
724 background_color = Color.Empty;
730 ime_mode = ImeMode.Inherit;
733 use_compatible_text_rendering = Application.use_compatible_text_rendering;
734 padding = new Padding(0);
735 maximum_size = new Size();
736 minimum_size = new Size();
737 preferred_size = new Size();
738 margin = this.DefaultMargin;
739 layout_engine = this.LayoutEngine;
742 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
743 ControlStyles.Selectable | ControlStyles.StandardClick |
744 ControlStyles.StandardDoubleClick;
746 control_style |= ControlStyles.UseTextForAccessibility;
750 background_image = null;
754 window = new ControlNativeWindow(this);
755 child_controls = CreateControlsInstance();
756 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
757 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
758 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
759 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
765 public Control(Control parent, string text) : this() {
770 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
775 bounds.Height=height;
776 SetBounds(left, top, width, height, BoundsSpecified.All);
780 public Control(string text) : this() {
784 public Control(string text, int left, int top, int width, int height) : this() {
788 bounds.Height=height;
789 SetBounds(left, top, width, height, BoundsSpecified.All);
793 private delegate void RemoveDelegate(object c);
795 protected override void Dispose(bool disposing) {
796 if (!is_disposed && disposing) {
799 DisposeBackBuffer ();
801 if (invalid_region!=null) {
802 invalid_region.Dispose();
805 if (this.InvokeRequired) {
806 if (Application.MessageLoop) {
807 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
813 if (parent != null) {
814 parent.Controls.Remove(this);
817 Control [] children = child_controls.GetAllControls ();
818 for (int i=0; i<children.Length; i++) {
819 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
820 children[i].Dispose();
825 base.Dispose(disposing);
827 #endregion // Public Constructors
829 #region Internal Properties
830 internal BorderStyle InternalBorderStyle {
836 if (!Enum.IsDefined (typeof (BorderStyle), value))
837 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
839 if (border_style != value) {
840 border_style = value;
842 if (IsHandleCreated) {
843 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
849 #endregion // Internal Properties
851 #region Private & Internal Methods
852 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
853 AsyncMethodResult result;
854 AsyncMethodData data;
859 if (!p.IsHandleCreated) {
860 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
866 result = new AsyncMethodResult ();
867 data = new AsyncMethodData ();
869 data.Handle = window.Handle;
870 data.Method = method;
872 data.Result = result;
875 if (!ExecutionContext.IsFlowSuppressed ()) {
876 data.Context = ExecutionContext.Capture ();
879 #if !MWF_ON_MSRUNTIME
880 if (SecurityManager.SecurityEnabled) {
881 data.Stack = CompressedStack.GetCompressedStack ();
886 XplatUI.SendAsyncMethod (data);
891 internal void PointToClient (ref int x, ref int y)
893 XplatUI.ScreenToClient (Handle, ref x, ref y);
896 internal void PointToScreen (ref int x, ref int y)
898 XplatUI.ClientToScreen (Handle, ref x, ref y);
901 internal bool IsRecreating {
903 return is_recreating;
907 internal Graphics DeviceContext {
908 get { return Hwnd.bmp_g; }
911 private void InvalidateBackBuffer ()
913 if (invalid_region != null)
914 invalid_region.Dispose();
915 invalid_region = new Region (ClientRectangle);
918 private void CreateBackBuffer ()
920 if (backbuffer != null)
926 if (width < 1) width = 1;
927 if (height < 1) height = 1;
929 XplatUI.CreateOffscreenDrawable (Handle, width, height, out backbuffer, out backbuffer_dc);
930 InvalidateBackBuffer ();
933 private void DisposeBackBuffer ()
935 if (backbuffer == null)
938 XplatUI.DestroyOffscreenDrawable (backbuffer, backbuffer_dc);
940 backbuffer_dc = null;
943 if (invalid_region != null)
944 invalid_region.Dispose ();
945 invalid_region = null;
948 internal static void SetChildColor(Control parent) {
951 for (int i=0; i < parent.child_controls.Count; i++) {
952 child=parent.child_controls[i];
953 if (child.child_controls.Count>0) {
954 SetChildColor(child);
959 internal bool Select(Control control) {
960 IContainerControl container;
962 if (control == null) {
966 container = GetContainerControl();
967 if (container != null) {
968 container.ActiveControl = control;
970 if (control.IsHandleCreated) {
971 XplatUI.SetFocus(control.window.Handle);
976 internal void SelectChild (Control control)
978 if (control.IsHandleCreated)
979 XplatUI.SetFocus (control.window.Handle);
982 internal virtual void DoDefaultAction() {
983 // Only here to be overriden by our actual controls; this is needed by the accessibility class
986 internal static int LowOrder (int param) {
987 return ((int)(short)(param & 0xffff));
990 internal static int HighOrder (int param) {
991 return ((int)(short)(param >> 16));
994 // This method exists so controls overriding OnPaintBackground can have default background painting done
995 internal virtual void PaintControlBackground (PaintEventArgs pevent)
997 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
998 if (parent != null) {
999 PaintEventArgs parent_pe;
1000 GraphicsState state;
1002 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1004 state = parent_pe.Graphics.Save();
1005 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1006 parent.OnPaintBackground(parent_pe);
1007 parent_pe.Graphics.Restore(state);
1009 state = parent_pe.Graphics.Save();
1010 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1011 parent.OnPaint(parent_pe);
1012 parent_pe.Graphics.Restore(state);
1013 parent_pe.SetGraphics(null);
1017 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1018 if (parent != null) {
1019 PaintEventArgs parent_pe;
1021 GraphicsState state;
1024 hwnd = Hwnd.ObjectFromHandle(Handle);
1027 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1029 region = new Region ();
1031 region.Union(ClientRectangle);
1033 foreach (Rectangle r in hwnd.ClipRectangles) {
1037 state = parent_pe.Graphics.Save();
1038 parent_pe.Graphics.Clip = region;
1040 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1041 parent.OnPaintBackground(parent_pe);
1042 parent_pe.Graphics.Restore(state);
1044 state = parent_pe.Graphics.Save();
1045 parent_pe.Graphics.Clip = region;
1047 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1048 parent.OnPaint(parent_pe);
1049 parent_pe.Graphics.Restore(state);
1050 parent_pe.SetGraphics(null);
1052 region.Intersect(clip_region);
1053 pevent.Graphics.Clip = region;
1058 if (background_image == null) {
1059 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));
1063 DrawBackgroundImage (pevent.Graphics);
1066 void DrawBackgroundImage (Graphics g)
1068 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1069 g.FillRectangle (b, ClientRectangle);
1073 internal virtual void DndEnter (DragEventArgs e)
1080 internal virtual void DndOver (DragEventArgs e)
1087 internal virtual void DndDrop (DragEventArgs e)
1091 } catch (Exception exc) {
1092 Console.Error.WriteLine ("MWF: Exception while dropping:");
1093 Console.Error.WriteLine (exc);
1097 internal virtual void DndLeave (EventArgs e)
1104 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1111 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1114 OnQueryContinueDrag(e);
1118 internal static MouseButtons FromParamToMouseButtons (int param) {
1119 MouseButtons buttons = MouseButtons.None;
1121 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1122 buttons |= MouseButtons.Left;
1124 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1125 buttons |= MouseButtons.Middle;
1127 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1128 buttons |= MouseButtons.Right;
1134 internal void FireEnter ()
1136 OnEnter (EventArgs.Empty);
1139 internal void FireLeave ()
1141 OnLeave (EventArgs.Empty);
1144 internal void FireValidating (CancelEventArgs ce)
1149 internal void FireValidated ()
1151 OnValidated (EventArgs.Empty);
1154 internal virtual bool ProcessControlMnemonic(char charCode) {
1155 return ProcessMnemonic(charCode);
1158 private static Control FindFlatForward(Control container, Control start) {
1164 end = container.child_controls.Count;
1166 if (start != null) {
1167 index = start.tab_index;
1172 for (int i = 0, pos = -1; i < end; i++) {
1173 if (start == container.child_controls[i]) {
1178 if (found == null) {
1179 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1180 found = container.child_controls[i];
1182 } else if (found.tab_index > container.child_controls[i].tab_index) {
1183 if (container.child_controls[i].tab_index > index) {
1184 found = container.child_controls[i];
1191 private static Control FindControlForward(Control container, Control start) {
1196 if (start == null) {
1197 return FindFlatForward(container, start);
1200 if (start.child_controls != null && start.child_controls.Count > 0 &&
1201 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1202 return FindControlForward(start, null);
1205 while (start != container) {
1206 found = FindFlatForward(start.parent, start);
1207 if (found != null) {
1210 start = start.parent;
1216 private static Control FindFlatBackward(Control container, Control start) {
1222 end = container.child_controls.Count;
1224 if (start != null) {
1225 index = start.tab_index;
1227 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1229 for (int i = 0; i < end; i++) {
1230 if (container.child_controls[i].tab_index > index) {
1231 index = container.child_controls[i].tab_index;
1239 for (int i = end - 1; i >= 0; i--) {
1240 if (start == container.child_controls[i]) {
1245 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1246 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1247 found = container.child_controls[i];
1254 private static Control FindControlBackward(Control container, Control start) {
1256 Control found = null;
1258 if (start == null) {
1259 found = FindFlatBackward(container, start);
1261 else if (start != container) {
1262 if (start.parent != null) {
1263 found = FindFlatBackward(start.parent, start);
1265 if (found == null) {
1266 if (start.parent != container)
1267 return start.parent;
1273 if (found == null || start.parent == null)
1276 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1277 found.child_controls != null && found.child_controls.Count > 0)) {
1278 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1279 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1280 found = FindFlatBackward(found, null);
1290 if (start != null) {
1291 found = FindFlatBackward(start.parent, start);
1292 if (found == null) {
1293 if (start.parent != container) {
1294 return start.parent;
1298 if (found == null) {
1299 found = FindFlatBackward(container, start);
1302 if (container != start) {
1303 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1304 found = FindControlBackward(found, null);
1305 if (found != null) {
1314 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1315 if (GetStyle(ControlStyles.StandardClick)) {
1316 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1318 OnDoubleClick(EventArgs.Empty);
1320 OnClick(EventArgs.Empty);
1330 private void CheckDataBindings ()
1332 if (data_bindings == null)
1335 BindingContext binding_context = BindingContext;
1336 foreach (Binding binding in data_bindings) {
1337 binding.Check (binding_context);
1341 private void ChangeParent(Control new_parent) {
1345 Color pre_fore_color;
1346 Color pre_back_color;
1347 RightToLeft pre_rtl;
1349 // These properties are inherited from our parent
1350 // Get them pre parent-change and then send events
1351 // if they are changed after we have our new parent
1352 pre_enabled = Enabled;
1353 pre_visible = Visible;
1355 pre_fore_color = ForeColor;
1356 pre_back_color = BackColor;
1357 pre_rtl = RightToLeft;
1358 // MS doesn't seem to send a CursorChangedEvent
1360 parent = new_parent;
1362 if (IsHandleCreated)
1363 XplatUI.SetParent(Handle,
1364 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1366 OnParentChanged(EventArgs.Empty);
1368 if (pre_enabled != Enabled) {
1369 OnEnabledChanged(EventArgs.Empty);
1372 if (pre_visible != Visible) {
1373 OnVisibleChanged(EventArgs.Empty);
1376 if (pre_font != Font) {
1377 OnFontChanged(EventArgs.Empty);
1380 if (pre_fore_color != ForeColor) {
1381 OnForeColorChanged(EventArgs.Empty);
1384 if (pre_back_color != BackColor) {
1385 OnBackColorChanged(EventArgs.Empty);
1388 if (pre_rtl != RightToLeft) {
1389 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1390 // because when RTL changes they have to recreate the win32 control
1391 // We don't really need that (until someone runs into compatibility issues)
1392 OnRightToLeftChanged(EventArgs.Empty);
1395 if ((new_parent != null) && new_parent.Created && !Created) {
1399 if ((binding_context == null) && Created) {
1400 OnBindingContextChanged(EventArgs.Empty);
1404 private void UpdateDistances() {
1405 if ((parent != null) && (parent.layout_suspended == 0)) {
1406 dist_left = bounds.X;
1407 dist_top = bounds.Y;
1408 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1409 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1412 #endregion // Private & Internal Methods
1414 #region Public Static Properties
1415 public static Color DefaultBackColor {
1417 return ThemeEngine.Current.DefaultControlBackColor;
1421 public static Font DefaultFont {
1423 return ThemeEngine.Current.DefaultFont;
1427 public static Color DefaultForeColor {
1429 return ThemeEngine.Current.DefaultControlForeColor;
1433 public static Keys ModifierKeys {
1435 return XplatUI.State.ModifierKeys;
1439 public static MouseButtons MouseButtons {
1441 return XplatUI.State.MouseButtons;
1445 public static Point MousePosition {
1447 return Cursor.Position;
1453 public static bool CheckForIllegalCrossThreadCalls
1456 return verify_thread_handle;
1460 verify_thread_handle = value;
1464 #endregion // Public Static Properties
1466 #region Public Instance Properties
1467 [EditorBrowsable(EditorBrowsableState.Advanced)]
1469 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1470 public AccessibleObject AccessibilityObject {
1472 if (accessibility_object==null) {
1473 accessibility_object=CreateAccessibilityInstance();
1475 return accessibility_object;
1479 [EditorBrowsable(EditorBrowsableState.Advanced)]
1481 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1482 public string AccessibleDefaultActionDescription {
1484 return AccessibilityObject.default_action;
1488 AccessibilityObject.default_action=value;
1493 [DefaultValue(null)]
1494 [MWFCategory("Accessibility")]
1495 public string AccessibleDescription {
1497 return AccessibilityObject.description;
1501 AccessibilityObject.description=value;
1506 [DefaultValue(null)]
1507 [MWFCategory("Accessibility")]
1508 public string AccessibleName {
1510 return AccessibilityObject.Name;
1514 AccessibilityObject.Name=value;
1518 [DefaultValue(AccessibleRole.Default)]
1519 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1520 public AccessibleRole AccessibleRole {
1522 return AccessibilityObject.role;
1526 AccessibilityObject.role=value;
1530 [DefaultValue(false)]
1531 [MWFCategory("Behavior")]
1532 public virtual bool AllowDrop {
1538 if (allow_drop == value)
1541 if (IsHandleCreated) {
1543 XplatUI.SetAllowDrop (Handle, value);
1549 [RefreshProperties(RefreshProperties.Repaint)]
1550 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1551 [MWFCategory("Layout")]
1552 public virtual AnchorStyles Anchor {
1554 return anchor_style;
1560 if (parent != null) {
1561 parent.PerformLayout(this, "Parent");
1567 // XXX: Implement me!
1570 public virtual bool AutoSize {
1572 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1576 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1581 public virtual Size MaximumSize {
1583 return maximum_size;
1586 maximum_size = value;
1590 public virtual Size MinimumSize {
1592 return minimum_size;
1595 minimum_size = value;
1601 [MWFCategory("Appearance")]
1602 public virtual Color BackColor {
1604 if (background_color.IsEmpty) {
1606 Color pcolor = parent.BackColor;
1607 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1610 return DefaultBackColor;
1612 return background_color;
1616 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1617 throw new ArgumentException("Transparent background colors are not supported on this control");
1620 if (background_color != value) {
1621 background_color=value;
1622 SetChildColor(this);
1623 OnBackColorChanged(EventArgs.Empty);
1630 [DefaultValue(null)]
1631 [MWFCategory("Appearance")]
1632 public virtual Image BackgroundImage {
1634 return background_image;
1638 if (background_image!=value) {
1639 background_image=value;
1640 OnBackgroundImageChanged(EventArgs.Empty);
1646 [EditorBrowsable(EditorBrowsableState.Advanced)]
1648 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1649 public virtual BindingContext BindingContext {
1651 if (binding_context != null)
1652 return binding_context;
1655 binding_context = Parent.BindingContext;
1656 return binding_context;
1659 if (binding_context != value) {
1660 binding_context = value;
1661 OnBindingContextChanged(EventArgs.Empty);
1666 [EditorBrowsable(EditorBrowsableState.Advanced)]
1668 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1671 return bounds.Y+bounds.Height;
1675 [EditorBrowsable(EditorBrowsableState.Advanced)]
1677 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1678 public Rectangle Bounds {
1684 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1688 [EditorBrowsable(EditorBrowsableState.Advanced)]
1690 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1691 public bool CanFocus {
1693 if (IsHandleCreated && Visible && Enabled) {
1700 [EditorBrowsable(EditorBrowsableState.Advanced)]
1702 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1703 public bool CanSelect {
1707 if (!GetStyle(ControlStyles.Selectable)) {
1712 while (parent != null) {
1713 if (!parent.is_visible || !parent.is_enabled) {
1717 parent = parent.parent;
1723 internal virtual bool InternalCapture {
1733 [EditorBrowsable(EditorBrowsableState.Advanced)]
1735 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1736 public bool Capture {
1738 return this.is_captured;
1742 if (this.IsHandleCreated && value != is_captured) {
1745 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1747 XplatUI.UngrabWindow(this.window.Handle);
1748 is_captured = false;
1754 [DefaultValue(true)]
1755 [MWFCategory("Focus")]
1756 public bool CausesValidation {
1758 return this.causes_validation;
1762 if (this.causes_validation != value) {
1763 causes_validation = value;
1764 OnCausesValidationChanged(EventArgs.Empty);
1769 [EditorBrowsable(EditorBrowsableState.Advanced)]
1771 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1772 public Rectangle ClientRectangle {
1774 client_rect.Width = client_size.Width;
1775 client_rect.Height = client_size.Height;
1780 [EditorBrowsable(EditorBrowsableState.Advanced)]
1782 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1783 public Size ClientSize {
1786 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1787 return ((Form)this).form_parent_window.ClientSize;
1795 this.SetClientSizeCore(value.Width, value.Height);
1799 [EditorBrowsable(EditorBrowsableState.Advanced)]
1801 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1802 [DescriptionAttribute("ControlCompanyNameDescr")]
1803 public String CompanyName {
1805 return "Mono Project, Novell, Inc.";
1809 [EditorBrowsable(EditorBrowsableState.Advanced)]
1811 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1812 public bool ContainsFocus {
1814 IntPtr focused_window;
1816 focused_window = XplatUI.GetFocus();
1817 if (IsHandleCreated) {
1818 if (focused_window == Handle) {
1822 for (int i=0; i < child_controls.Count; i++) {
1823 if (child_controls[i].ContainsFocus) {
1832 [DefaultValue(null)]
1833 [MWFCategory("Behavior")]
1834 public virtual ContextMenu ContextMenu {
1836 return GetContextMenuInternal ();
1840 if (context_menu != value) {
1841 context_menu = value;
1842 OnContextMenuChanged(EventArgs.Empty);
1847 internal virtual ContextMenu GetContextMenuInternal ()
1849 return context_menu;
1853 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1854 public ControlCollection Controls {
1856 return this.child_controls;
1860 [EditorBrowsable(EditorBrowsableState.Advanced)]
1862 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1863 public bool Created {
1865 return (!is_disposed && is_created);
1869 [AmbientValue(null)]
1870 [MWFCategory("Appearance")]
1871 public virtual Cursor Cursor {
1873 if (cursor != null) {
1877 if (parent != null) {
1878 return parent.Cursor;
1881 return Cursors.Default;
1885 if (cursor != value) {
1890 if (IsHandleCreated) {
1891 pt = Cursor.Position;
1893 if (bounds.Contains(pt) || Capture) {
1894 if (GetChildAtPoint(pt) == null) {
1895 if (cursor != null) {
1896 XplatUI.SetCursor(window.Handle, cursor.handle);
1898 if (parent != null) {
1899 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1901 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1908 OnCursorChanged(EventArgs.Empty);
1914 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1915 [ParenthesizePropertyName(true)]
1916 [RefreshProperties(RefreshProperties.All)]
1917 [MWFCategory("Data")]
1918 public ControlBindingsCollection DataBindings {
1920 if (data_bindings == null)
1921 data_bindings = new ControlBindingsCollection (this);
1922 return data_bindings;
1926 [EditorBrowsable(EditorBrowsableState.Advanced)]
1928 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1929 public virtual Rectangle DisplayRectangle {
1931 return ClientRectangle;
1935 [EditorBrowsable(EditorBrowsableState.Advanced)]
1937 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1938 public bool Disposing {
1945 [RefreshProperties(RefreshProperties.Repaint)]
1946 [DefaultValue(DockStyle.None)]
1947 [MWFCategory("Layout")]
1948 public virtual DockStyle Dock {
1954 if (dock_style == value) {
1958 if (!Enum.IsDefined (typeof (DockStyle), value)) {
1959 throw new InvalidEnumArgumentException ("value", (int) value,
1960 typeof (DockStyle));
1965 if (dock_style == DockStyle.None) {
1966 if (explicit_bounds == Rectangle.Empty)
1967 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1969 Bounds = explicit_bounds;
1972 if (parent != null) {
1973 parent.PerformLayout(this, "Parent");
1976 OnDockChanged(EventArgs.Empty);
1981 protected virtual bool DoubleBuffered {
1983 return (control_style & ControlStyles.DoubleBuffer) != 0;
1987 SetStyle (ControlStyles.DoubleBuffer, value);
1994 [MWFCategory("Behavior")]
1995 public bool Enabled {
2001 if (parent != null) {
2002 return parent.Enabled;
2010 bool old_value = is_enabled;
2013 if (old_value != value && !value && this.has_focus)
2014 SelectNextControl(this, true, true, true, true);
2016 OnEnabledChanged (EventArgs.Empty);
2020 [EditorBrowsable(EditorBrowsableState.Advanced)]
2022 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2023 public virtual bool Focused {
2025 return this.has_focus;
2030 [AmbientValue(null)]
2032 [MWFCategory("Appearance")]
2033 public virtual Font Font {
2039 if (Parent != null && Parent.Font != null) {
2046 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2048 if (font != null && font.Equals (value)) {
2054 OnFontChanged (EventArgs.Empty);
2059 [MWFCategory("Appearance")]
2060 public virtual Color ForeColor {
2062 if (foreground_color.IsEmpty) {
2064 return parent.ForeColor;
2066 return DefaultForeColor;
2068 return foreground_color;
2072 if (foreground_color != value) {
2073 foreground_color=value;
2075 OnForeColorChanged(EventArgs.Empty);
2082 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2083 public IntPtr Handle { // IWin32Window
2086 if (verify_thread_handle) {
2087 if (this.InvokeRequired) {
2088 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2092 if (!IsHandleCreated) {
2095 return window.Handle;
2099 [EditorBrowsable(EditorBrowsableState.Advanced)]
2101 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2102 public bool HasChildren {
2104 if (this.child_controls.Count>0) {
2111 [EditorBrowsable(EditorBrowsableState.Always)]
2113 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2116 return this.bounds.Height;
2120 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2124 [AmbientValue(ImeMode.Inherit)]
2126 [MWFCategory("Behavior")]
2127 public ImeMode ImeMode {
2129 if (ime_mode == ImeMode.Inherit) {
2131 return parent.ImeMode;
2133 return ImeMode.NoControl; // default value
2139 if (ime_mode != value) {
2142 OnImeModeChanged(EventArgs.Empty);
2147 [EditorBrowsable(EditorBrowsableState.Advanced)]
2149 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2150 public bool InvokeRequired { // ISynchronizeInvoke
2152 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2159 [EditorBrowsable(EditorBrowsableState.Advanced)]
2161 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2162 public bool IsAccessible {
2164 return is_accessible;
2168 is_accessible = value;
2172 [EditorBrowsable(EditorBrowsableState.Advanced)]
2174 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2175 public bool IsDisposed {
2177 return this.is_disposed;
2181 [EditorBrowsable(EditorBrowsableState.Advanced)]
2183 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2184 public bool IsHandleCreated {
2186 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2187 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2188 if (hwnd != null && !hwnd.zombie)
2197 public virtual Layout.LayoutEngine LayoutEngine {
2198 get { return new Layout.DefaultLayout (); }
2202 [EditorBrowsable(EditorBrowsableState.Always)]
2204 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2207 return this.bounds.X;
2211 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2216 [MWFCategory("Layout")]
2217 public Point Location {
2219 return new Point(bounds.X, bounds.Y);
2223 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2228 [Localizable (true)]
2229 public Padding Margin {
2230 get { return this.margin; }
2231 set { this.margin = value; }
2236 public string Name {
2248 public Padding Padding {
2260 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2261 public Control Parent {
2267 if (value == this) {
2268 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2271 if (parent!=value) {
2273 parent.Controls.Remove(this);
2278 value.Controls.Add(this);
2283 [EditorBrowsable(EditorBrowsableState.Advanced)]
2285 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2286 public string ProductName {
2288 Type t = typeof (AssemblyProductAttribute);
2289 Assembly assembly = GetType().Module.Assembly;
2290 object [] attrs = assembly.GetCustomAttributes (t, false);
2291 AssemblyProductAttribute a = null;
2292 // On MS we get a NullRefException if product attribute is not
2294 if (attrs != null && attrs.Length > 0)
2295 a = (AssemblyProductAttribute) attrs [0];
2300 [EditorBrowsable(EditorBrowsableState.Advanced)]
2302 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2303 public string ProductVersion {
2305 Type t = typeof (AssemblyVersionAttribute);
2306 Assembly assembly = GetType().Module.Assembly;
2307 object [] attrs = assembly.GetCustomAttributes (t, false);
2308 if (attrs == null || attrs.Length < 1)
2310 return ((AssemblyVersionAttribute)attrs [0]).Version;
2314 [EditorBrowsable(EditorBrowsableState.Advanced)]
2316 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2317 public bool RecreatingHandle {
2319 return is_recreating;
2323 [EditorBrowsable(EditorBrowsableState.Advanced)]
2325 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2326 public Region Region {
2332 if (IsHandleCreated) {
2333 XplatUI.SetClipRegion(Handle, value);
2335 clip_region = value;
2339 [EditorBrowsable(EditorBrowsableState.Advanced)]
2341 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2344 return this.bounds.X+this.bounds.Width;
2348 [AmbientValue(RightToLeft.Inherit)]
2350 [MWFCategory("Appearance")]
2351 public virtual RightToLeft RightToLeft {
2353 if (right_to_left == RightToLeft.Inherit) {
2355 return parent.RightToLeft;
2357 return RightToLeft.No; // default value
2359 return right_to_left;
2363 if (value != right_to_left) {
2364 right_to_left = value;
2365 OnRightToLeftChanged(EventArgs.Empty);
2370 [EditorBrowsable(EditorBrowsableState.Advanced)]
2371 public override ISite Site {
2379 if (value != null) {
2380 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2382 BackColor = ap.BackColor;
2383 ForeColor = ap.ForeColor;
2392 [MWFCategory("Layout")]
2395 return new Size(Width, Height);
2399 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2404 [MergableProperty(false)]
2405 [MWFCategory("Behavior")]
2406 public int TabIndex {
2408 if (tab_index != -1) {
2415 if (tab_index != value) {
2417 OnTabIndexChanged(EventArgs.Empty);
2423 [DefaultValue(true)]
2424 [MWFCategory("Behavior")]
2425 public bool TabStop {
2431 if (tab_stop != value) {
2433 OnTabStopChanged(EventArgs.Empty);
2438 [Localizable(false)]
2440 [TypeConverter(typeof(StringConverter))]
2441 [DefaultValue(null)]
2442 [MWFCategory("Data")]
2449 control_tag = value;
2455 [BindableAttribute(true)]
2456 [MWFCategory("Appearance")]
2457 public virtual string Text {
2459 // Our implementation ignores ControlStyles.CacheText - we always cache
2464 if (value == null) {
2465 value = String.Empty;
2470 if (IsHandleCreated) {
2471 /* we need to call .SetWindowStyle here instead of just .Text
2472 because the presence/absence of Text (== "" or not) can cause
2473 other window style things to appear/disappear */
2474 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2475 XplatUI.Text(Handle, text);
2477 OnTextChanged (EventArgs.Empty);
2482 [EditorBrowsable(EditorBrowsableState.Always)]
2484 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2487 return this.bounds.Y;
2491 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2495 [EditorBrowsable(EditorBrowsableState.Advanced)]
2497 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2498 public Control TopLevelControl {
2502 while (p.parent != null) {
2506 return p is Form ? p : null;
2511 [MWFCategory("Behavior")]
2512 public bool Visible {
2516 } else if (parent != null) {
2517 return parent.Visible;
2524 SetVisibleCore(value);
2528 [EditorBrowsable(EditorBrowsableState.Always)]
2530 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2533 return this.bounds.Width;
2537 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2541 [EditorBrowsable(EditorBrowsableState.Never)]
2543 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2544 public IWindowTarget WindowTarget {
2553 #endregion // Public Instance Properties
2555 #region Protected Instance Properties
2556 protected virtual CreateParams CreateParams {
2558 CreateParams create_params = new CreateParams();
2561 create_params.Caption = Text;
2564 create_params.Caption = text;
2568 create_params.X = Left;
2571 create_params.X = this.bounds.X;
2575 create_params.Y = Top;
2578 create_params.Y = this.bounds.Y;
2582 create_params.Width = Width;
2585 create_params.Width = this.bounds.Width;
2589 create_params.Height = Height;
2592 create_params.Height = this.bounds.Height;
2596 create_params.ClassName = XplatUI.DefaultClassName;
2597 create_params.ClassStyle = 0;
2598 create_params.ExStyle = 0;
2599 create_params.Param = 0;
2602 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2605 if ((parent!=null) && (parent.IsHandleCreated)) {
2606 create_params.Parent = parent.Handle;
2609 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2612 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2616 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2619 switch (border_style) {
2620 case BorderStyle.FixedSingle:
2621 create_params.Style |= (int) WindowStyles.WS_BORDER;
2623 case BorderStyle.Fixed3D:
2624 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2628 return create_params;
2632 protected virtual ImeMode DefaultImeMode {
2634 return ImeMode.Inherit;
2639 protected virtual Padding DefaultMargin {
2640 get { return new Padding (3); }
2644 protected virtual Size DefaultSize {
2646 return new Size(0, 0);
2650 protected int FontHeight {
2660 protected bool RenderRightToLeft {
2662 return (this.right_to_left == RightToLeft.Yes);
2666 protected bool ResizeRedraw {
2668 return GetStyle(ControlStyles.ResizeRedraw);
2672 SetStyle(ControlStyles.ResizeRedraw, value);
2676 [EditorBrowsable(EditorBrowsableState.Advanced)]
2678 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2679 protected virtual bool ShowFocusCues {
2685 [EditorBrowsable(EditorBrowsableState.Advanced)]
2687 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2688 protected bool ShowKeyboardCues {
2693 #endregion // Protected Instance Properties
2695 #region Public Static Methods
2696 [EditorBrowsable(EditorBrowsableState.Advanced)]
2697 public static Control FromChildHandle(IntPtr handle) {
2698 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2701 [EditorBrowsable(EditorBrowsableState.Advanced)]
2702 public static Control FromHandle(IntPtr handle) {
2703 return Control.ControlNativeWindow.ControlFromHandle(handle);
2706 public static bool IsMnemonic(char charCode, string text) {
2709 amp = text.IndexOf('&');
2712 if (amp + 1 < text.Length) {
2713 if (text[amp + 1] != '&') {
2714 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2724 #region Protected Static Methods
2725 [EditorBrowsable(EditorBrowsableState.Advanced)]
2726 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2729 c = Control.FromHandle(hWnd);
2739 #region Public Instance Methods
2740 [EditorBrowsable(EditorBrowsableState.Advanced)]
2741 public IAsyncResult BeginInvoke(Delegate method) {
2742 object [] prms = null;
2743 if (method is EventHandler)
2744 prms = new object [] { this, EventArgs.Empty };
2745 return BeginInvokeInternal(method, prms, false);
2748 [EditorBrowsable(EditorBrowsableState.Advanced)]
2749 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2750 return BeginInvokeInternal (method, args, false);
2753 public void BringToFront() {
2754 if (parent != null) {
2755 parent.child_controls.SetChildIndex(this, 0);
2758 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2762 public bool Contains(Control ctl) {
2763 while (ctl != null) {
2772 public void CreateControl() {
2774 throw new ObjectDisposedException(GetType().FullName.ToString());
2780 if (!IsHandleCreated) {
2788 Control [] controls = child_controls.GetAllControls ();
2789 for (int i=0; i<controls.Length; i++) {
2790 controls [i].CreateControl ();
2793 UpdateChildrenZOrder();
2795 if (binding_context == null) { // seem to be sent whenever it's null?
2796 OnBindingContextChanged(EventArgs.Empty);
2802 public Graphics CreateGraphics() {
2803 if (!IsHandleCreated) {
2804 this.CreateHandle();
2806 return Graphics.FromHwnd(this.window.Handle);
2809 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2810 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2813 [EditorBrowsable(EditorBrowsableState.Advanced)]
2814 public object EndInvoke (IAsyncResult async_result) {
2815 AsyncMethodResult result = (AsyncMethodResult) async_result;
2816 return result.EndInvoke ();
2819 public Form FindForm() {
2832 public bool Focus() {
2833 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2836 is_focusing = false;
2841 public Control GetChildAtPoint(Point pt) {
2842 // Microsoft's version of this function doesn't seem to work, so I can't check
2843 // if we only consider children or also grandchildren, etc.
2844 // I'm gonna say 'children only'
2845 for (int i=0; i<child_controls.Count; i++) {
2846 if (child_controls[i].Bounds.Contains(pt)) {
2847 return child_controls[i];
2853 public IContainerControl GetContainerControl() {
2854 Control current = this;
2856 while (current!=null) {
2857 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2858 return (IContainerControl)current;
2860 current = current.parent;
2865 public Control GetNextControl(Control ctl, bool forward) {
2867 if (!this.Contains(ctl)) {
2872 ctl = FindControlForward(this, ctl);
2875 ctl = FindControlBackward(this, ctl);
2885 public virtual Size GetPreferredSize (Size proposedSize) {
2886 return preferred_size;
2890 public void Hide() {
2891 this.Visible = false;
2894 public void Invalidate() {
2895 Invalidate(ClientRectangle, false);
2898 public void Invalidate(bool invalidateChildren) {
2899 Invalidate(ClientRectangle, invalidateChildren);
2902 public void Invalidate(System.Drawing.Rectangle rc) {
2903 Invalidate(rc, false);
2906 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2907 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2911 NotifyInvalidate(rc);
2913 XplatUI.Invalidate(Handle, rc, false);
2915 if (invalidateChildren) {
2916 Control [] controls = child_controls.GetAllControls ();
2917 for (int i=0; i<controls.Length; i++)
2918 controls [i].Invalidate ();
2920 OnInvalidated(new InvalidateEventArgs(rc));
2923 public void Invalidate(System.Drawing.Region region) {
2924 Invalidate(region, false);
2927 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2928 RectangleF bounds = region.GetBounds (CreateGraphics ());
2929 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2930 invalidateChildren);
2933 public object Invoke (Delegate method) {
2934 object [] prms = null;
2935 if (method is EventHandler)
2936 prms = new object [] { this, EventArgs.Empty };
2938 return Invoke(method, prms);
2941 public object Invoke (Delegate method, object[] args) {
2942 if (!this.InvokeRequired) {
2943 return method.DynamicInvoke(args);
2946 IAsyncResult result = BeginInvoke (method, args);
2947 return EndInvoke(result);
2950 internal object InvokeInternal (Delegate method, bool disposing) {
2951 return InvokeInternal(method, null, disposing);
2954 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2955 if (!this.InvokeRequired) {
2956 return method.DynamicInvoke(args);
2959 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2960 return EndInvoke(result);
2963 [EditorBrowsable(EditorBrowsableState.Advanced)]
2964 public void PerformLayout() {
2965 PerformLayout(null, null);
2969 private void SetImplicitBounds (int x, int y, int width, int height)
2971 Rectangle saved_bounds = explicit_bounds;
2972 SetBounds (x, y, width, height);
2973 explicit_bounds = saved_bounds;
2977 [EditorBrowsable(EditorBrowsableState.Advanced)]
2978 public void PerformLayout(Control affectedControl, string affectedProperty) {
2979 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2981 if (layout_suspended > 0) {
2982 layout_pending = true;
2986 layout_pending = false;
2988 // Prevent us from getting messed up
2991 // Perform all Dock and Anchor calculations
2995 this.layout_engine.Layout(this, levent);
2997 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2999 AnchorStyles anchor;
3002 space = DisplayRectangle;
3004 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
3005 Control [] controls = child_controls.GetAllControls ();
3006 for (int i = controls.Length - 1; i >= 0; i--) {
3007 child = controls [i];
3009 if (!child.Visible) {
3013 switch (child.Dock) {
3014 case DockStyle.None: {
3019 case DockStyle.Left: {
3020 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3021 space.X+=child.Width;
3022 space.Width-=child.Width;
3026 case DockStyle.Top: {
3027 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3028 space.Y+=child.Height;
3029 space.Height-=child.Height;
3033 case DockStyle.Right: {
3034 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3035 space.Width-=child.Width;
3039 case DockStyle.Bottom: {
3040 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3041 space.Height-=child.Height;
3047 for (int i = controls.Length - 1; i >= 0; i--) {
3050 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3051 if (child.Dock == DockStyle.Fill) {
3052 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3056 space = DisplayRectangle;
3058 for (int i=0; i < controls.Length; i++) {
3064 child = controls[i];
3066 // If the control is docked we don't need to do anything
3067 if (child.Dock != DockStyle.None) {
3071 anchor = child.Anchor;
3075 width = child.Width;
3076 height = child.Height;
3078 if ((anchor & AnchorStyles.Left) !=0 ) {
3079 if ((anchor & AnchorStyles.Right) != 0) {
3080 width = space.Width - child.dist_right - left;
3082 ; // Left anchored only, nothing to be done
3084 } else if ((anchor & AnchorStyles.Right) != 0) {
3085 left = space.Width - child.dist_right - width;
3087 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3088 // This calculates from scratch every time:
3089 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3092 if ((anchor & AnchorStyles.Top) !=0 ) {
3093 if ((anchor & AnchorStyles.Bottom) != 0) {
3094 height = space.Height - child.dist_bottom - top;
3096 ; // Top anchored only, nothing to be done
3098 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3099 top = space.Height - child.dist_bottom - height;
3101 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3102 // This calculates from scratch every time:
3103 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3115 child.SetImplicitBounds(left, top, width, height);
3119 // Let everyone know
3123 // Need to make sure we decremend layout_suspended
3129 public Point PointToClient (Point p) {
3133 XplatUI.ScreenToClient (Handle, ref x, ref y);
3135 return new Point (x, y);
3138 public Point PointToScreen(Point p) {
3142 XplatUI.ClientToScreen(Handle, ref x, ref y);
3144 return new Point(x, y);
3147 public virtual bool PreProcessMessage(ref Message msg) {
3148 return InternalPreProcessMessage (ref msg);
3151 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3154 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3155 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3157 if (!ProcessCmdKey(ref msg, key_data)) {
3158 if (IsInputKey(key_data)) {
3162 return ProcessDialogKey(key_data);
3166 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3167 if (IsInputChar((char)msg.WParam)) {
3170 return ProcessDialogChar((char)msg.WParam);
3171 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3172 return ProcessDialogChar((char)msg.WParam);
3177 public Rectangle RectangleToClient(Rectangle r) {
3178 return new Rectangle(PointToClient(r.Location), r.Size);
3181 public Rectangle RectangleToScreen(Rectangle r) {
3182 return new Rectangle(PointToScreen(r.Location), r.Size);
3185 public virtual void Refresh() {
3186 if (IsHandleCreated == true) {
3188 XplatUI.UpdateWindow(window.Handle);
3190 Control [] controls = child_controls.GetAllControls ();
3191 for (int i=0; i < controls.Length; i++) {
3192 controls[i].Refresh();
3198 [EditorBrowsable(EditorBrowsableState.Never)]
3199 public virtual void ResetBackColor() {
3200 BackColor = Color.Empty;
3203 [EditorBrowsable(EditorBrowsableState.Never)]
3204 public void ResetBindings() {
3205 data_bindings.Clear();
3208 [EditorBrowsable(EditorBrowsableState.Never)]
3209 public virtual void ResetCursor() {
3213 [EditorBrowsable(EditorBrowsableState.Never)]
3214 public virtual void ResetFont() {
3218 [EditorBrowsable(EditorBrowsableState.Never)]
3219 public virtual void ResetForeColor() {
3220 foreground_color = Color.Empty;
3223 [EditorBrowsable(EditorBrowsableState.Never)]
3224 public void ResetImeMode() {
3225 ime_mode = DefaultImeMode;
3228 [EditorBrowsable(EditorBrowsableState.Never)]
3229 public virtual void ResetRightToLeft() {
3230 right_to_left = RightToLeft.Inherit;
3233 public virtual void ResetText() {
3234 text = String.Empty;
3237 public void ResumeLayout() {
3238 ResumeLayout (true);
3241 public void ResumeLayout(bool performLayout) {
3242 if (layout_suspended > 0) {
3246 if (layout_suspended == 0) {
3247 Control [] controls = child_controls.GetAllControls ();
3248 for (int i=0; i<controls.Length; i++) {
3249 controls [i].UpdateDistances ();
3252 if (performLayout && layout_pending) {
3258 public void Scale(float ratio) {
3259 ScaleCore(ratio, ratio);
3262 public void Scale(float dx, float dy) {
3267 public void Scale(SizeF factor) {
3268 ScaleCore(factor.Width, factor.Height);
3272 public void Select() {
3273 Select(false, false);
3277 private void printTree(Control c, string t) {
3278 foreach(Control i in c.child_controls) {
3279 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3280 printTree(i, t+"\t");
3284 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3288 Console.WriteLine("{0}", this.FindForm());
3289 printTree(this, "\t");
3292 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3297 c = GetNextControl(c, forward);
3306 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3307 c.Select (true, true);
3310 } while (c != ctl); // If we wrap back to ourselves we stop
3315 public void SendToBack() {
3316 if (parent != null) {
3317 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3321 public void SetBounds(int x, int y, int width, int height) {
3322 SetBounds(x, y, width, height, BoundsSpecified.All);
3325 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3326 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3330 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3334 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3338 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3342 SetBoundsCore(x, y, width, height, specified);
3343 if (parent != null) {
3344 parent.PerformLayout(this, "Bounds");
3348 public void Show() {
3350 this.CreateControl();
3356 public void SuspendLayout() {
3360 public void Update() {
3361 if (IsHandleCreated) {
3362 XplatUI.UpdateWindow(window.Handle);
3365 #endregion // Public Instance Methods
3367 #region Protected Instance Methods
3368 [EditorBrowsable(EditorBrowsableState.Advanced)]
3369 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3370 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3371 throw new NotImplementedException();
3374 [EditorBrowsable(EditorBrowsableState.Advanced)]
3375 protected virtual AccessibleObject CreateAccessibilityInstance() {
3376 return new Control.ControlAccessibleObject(this);
3379 [EditorBrowsable(EditorBrowsableState.Advanced)]
3380 protected virtual ControlCollection CreateControlsInstance() {
3381 return new ControlCollection(this);
3384 [EditorBrowsable(EditorBrowsableState.Advanced)]
3385 protected virtual void CreateHandle() {
3387 throw new ObjectDisposedException(GetType().FullName.ToString());
3390 if (IsHandleCreated && !is_recreating) {
3394 window.CreateHandle(CreateParams);
3396 if (window.Handle != IntPtr.Zero) {
3397 creator_thread = Thread.CurrentThread;
3399 XplatUI.EnableWindow(window.Handle, is_enabled);
3400 XplatUI.SetVisible(window.Handle, is_visible, true);
3402 if (clip_region != null) {
3403 XplatUI.SetClipRegion(Handle, clip_region);
3406 // Set our handle with our parent
3407 if ((parent != null) && (parent.IsHandleCreated)) {
3408 XplatUI.SetParent(window.Handle, parent.Handle);
3411 // Set our handle as parent for our children
3412 Control [] children;
3414 children = child_controls.GetAllControls ();
3415 for (int i = 0; i < children.Length; i++ ) {
3416 if (!children[i].RecreatingHandle)
3417 XplatUI.SetParent(children[i].Handle, window.Handle);
3421 XplatUI.SetAllowDrop (Handle, allow_drop);
3423 // Find out where the window manager placed us
3424 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3425 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3429 OnHandleCreated(EventArgs.Empty);
3433 [EditorBrowsable(EditorBrowsableState.Advanced)]
3434 protected virtual void DefWndProc(ref Message m) {
3435 window.DefWndProc(ref m);
3438 [EditorBrowsable(EditorBrowsableState.Advanced)]
3439 protected virtual void DestroyHandle() {
3440 if (IsHandleCreated) {
3441 if (window != null) {
3442 window.DestroyHandle();
3447 protected internal bool GetStyle(ControlStyles flag) {
3448 return (control_style & flag) != 0;
3451 protected bool GetTopLevel() {
3455 [EditorBrowsable(EditorBrowsableState.Advanced)]
3456 protected virtual void InitLayout() {
3460 [EditorBrowsable(EditorBrowsableState.Advanced)]
3461 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3462 toInvoke.OnGotFocus(e);
3465 [EditorBrowsable(EditorBrowsableState.Advanced)]
3466 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3467 toInvoke.OnLostFocus(e);
3470 [EditorBrowsable(EditorBrowsableState.Advanced)]
3471 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3472 toInvoke.OnClick(e);
3475 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3476 toInvoke.OnPaint(e);
3479 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3480 toInvoke.OnPaintBackground(e);
3483 protected virtual bool IsInputChar (char charCode) {
3487 protected virtual bool IsInputKey (Keys keyData) {
3488 // Doc says this one calls IsInputChar; not sure what to do with that
3492 [EditorBrowsable(EditorBrowsableState.Advanced)]
3493 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3497 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3498 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3502 if (parent != null) {
3503 return parent.ProcessCmdKey(ref msg, keyData);
3509 protected virtual bool ProcessDialogChar(char charCode) {
3510 if (parent != null) {
3511 return parent.ProcessDialogChar (charCode);
3517 protected virtual bool ProcessDialogKey (Keys keyData) {
3518 if (parent != null) {
3519 return parent.ProcessDialogKey (keyData);
3525 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3527 KeyEventArgs key_event;
3530 case (int)Msg.WM_SYSKEYDOWN:
3531 case (int)Msg.WM_KEYDOWN: {
3532 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3533 OnKeyDown (key_event);
3534 return key_event.Handled;
3537 case (int)Msg.WM_SYSKEYUP:
3538 case (int)Msg.WM_KEYUP: {
3539 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3540 OnKeyUp (key_event);
3541 return key_event.Handled;
3544 case (int)Msg.WM_SYSCHAR:
3545 case (int)Msg.WM_CHAR: {
3546 KeyPressEventArgs key_press_event;
3548 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3549 OnKeyPress(key_press_event);
3551 msg.WParam = (IntPtr)key_press_event.KeyChar;
3553 return key_press_event.Handled;
3564 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3565 if (parent != null) {
3566 if (parent.ProcessKeyPreview(ref msg)) {
3571 return ProcessKeyEventArgs(ref msg);
3574 protected virtual bool ProcessKeyPreview(ref Message msg) {
3575 if (parent != null) {
3576 return parent.ProcessKeyPreview(ref msg);
3582 protected virtual bool ProcessMnemonic(char charCode) {
3587 [EditorBrowsable(EditorBrowsableState.Advanced)]
3588 protected void RaiseDragEvent(object key, DragEventArgs e) {
3592 [EditorBrowsable(EditorBrowsableState.Advanced)]
3593 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3597 [EditorBrowsable(EditorBrowsableState.Advanced)]
3598 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3602 [EditorBrowsable(EditorBrowsableState.Advanced)]
3603 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3607 private void SetIsRecreating ()
3611 foreach (Control c in Controls.GetAllControls()) {
3612 c.SetIsRecreating ();
3616 [EditorBrowsable(EditorBrowsableState.Advanced)]
3617 protected void RecreateHandle() {
3619 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3624 if (IsHandleCreated) {
3626 Console.WriteLine(" + handle is created, destroying it.");
3629 // WM_DESTROY will CreateHandle for us
3632 Console.WriteLine(" + handle is not created, creating it.");
3640 is_recreating = false;
3642 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3648 [EditorBrowsable(EditorBrowsableState.Advanced)]
3649 protected void ResetMouseEventArgs() {
3653 [EditorBrowsable(EditorBrowsableState.Advanced)]
3654 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3655 if (right_to_left == RightToLeft.No) {
3660 case ContentAlignment.TopLeft: {
3661 return ContentAlignment.TopRight;
3664 case ContentAlignment.TopRight: {
3665 return ContentAlignment.TopLeft;
3668 case ContentAlignment.MiddleLeft: {
3669 return ContentAlignment.MiddleRight;
3672 case ContentAlignment.MiddleRight: {
3673 return ContentAlignment.MiddleLeft;
3676 case ContentAlignment.BottomLeft: {
3677 return ContentAlignment.BottomRight;
3680 case ContentAlignment.BottomRight: {
3681 return ContentAlignment.BottomLeft;
3685 // if it's center it doesn't change
3691 [EditorBrowsable(EditorBrowsableState.Advanced)]
3692 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3693 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3697 if (align == HorizontalAlignment.Left) {
3698 return HorizontalAlignment.Right;
3701 // align must be HorizontalAlignment.Right
3702 return HorizontalAlignment.Left;
3705 [EditorBrowsable(EditorBrowsableState.Advanced)]
3706 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3707 if (right_to_left == RightToLeft.No) {
3711 if (align == LeftRightAlignment.Left) {
3712 return LeftRightAlignment.Right;
3715 // align must be LeftRightAlignment.Right;
3716 return LeftRightAlignment.Left;
3719 [EditorBrowsable(EditorBrowsableState.Advanced)]
3720 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3721 return RtlTranslateAlignment(align);
3724 [EditorBrowsable(EditorBrowsableState.Advanced)]
3725 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3726 return RtlTranslateAlignment(align);
3729 [EditorBrowsable(EditorBrowsableState.Advanced)]
3730 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3731 return RtlTranslateAlignment(align);
3734 [EditorBrowsable(EditorBrowsableState.Advanced)]
3735 protected virtual void ScaleCore(float dx, float dy) {
3741 location = new Point((int)(Left * dx), (int)(Top * dy));
3742 size = this.ClientSize;
3744 if (!GetStyle(ControlStyles.FixedWidth)) {
3745 size.Width = (int)(size.Width * dx);
3748 if (!GetStyle(ControlStyles.FixedHeight)) {
3749 size.Height = (int)(size.Height * dy);
3752 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3754 /* Now scale our children */
3755 Control [] controls = child_controls.GetAllControls ();
3756 for (int i=0; i < controls.Length; i++) {
3757 controls[i].Scale(dx, dy);
3763 protected virtual void Select(bool directed, bool forward) {
3764 IContainerControl container;
3766 container = GetContainerControl();
3767 if (container != null)
3768 container.ActiveControl = this;
3771 [EditorBrowsable(EditorBrowsableState.Advanced)]
3772 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3773 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3774 if (IsHandleCreated) {
3775 XplatUI.SetWindowPos(Handle, x, y, width, height);
3777 // Win32 automatically changes negative width/height to 0.
3778 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3779 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3781 if (width < 0 || height < 0) {
3783 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3787 UpdateBounds(x, y, width, height);
3792 [EditorBrowsable(EditorBrowsableState.Advanced)]
3793 protected virtual void SetClientSizeCore(int x, int y) {
3794 // Calculate the actual window size from the client size (it usually stays the same or grows)
3795 Rectangle ClientRect;
3796 Rectangle WindowRect;
3799 ClientRect = new Rectangle(0, 0, x, y);
3800 cp = this.CreateParams;
3802 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3806 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3809 [EditorBrowsable(EditorBrowsableState.Advanced)]
3810 protected internal void SetStyle(ControlStyles flag, bool value) {
3812 control_style |= flag;
3814 control_style &= ~flag;
3818 protected void SetTopLevel(bool value) {
3819 if ((GetTopLevel() != value) && (parent != null)) {
3820 throw new Exception();
3824 if (value == true) {
3834 is_toplevel = value;
3837 protected virtual void SetVisibleCore(bool value) {
3838 if (value!=is_visible) {
3839 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3845 if (IsHandleCreated) {
3846 XplatUI.SetVisible(Handle, value, true);
3847 // Explicitly move Toplevel windows to where we want them;
3848 // apparently moving unmapped toplevel windows doesn't work
3849 if (is_visible && (this is Form)) {
3850 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3854 OnVisibleChanged(EventArgs.Empty);
3856 if (value == false && parent != null && Focused) {
3859 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3860 container = (Control)parent.GetContainerControl();
3861 if (container != null) {
3862 container.SelectNextControl(this, true, true, true, true);
3866 if (parent != null) {
3867 parent.PerformLayout(this, "visible");
3869 PerformLayout(this, "visible");
3874 [EditorBrowsable(EditorBrowsableState.Advanced)]
3875 protected void UpdateBounds() {
3883 if (!IsHandleCreated) {
3887 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3889 UpdateBounds(x, y, width, height, client_width, client_height);
3892 [EditorBrowsable(EditorBrowsableState.Advanced)]
3893 protected void UpdateBounds(int x, int y, int width, int height) {
3897 // Calculate client rectangle
3898 rect = new Rectangle(0, 0, 0, 0);
3901 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3902 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3905 [EditorBrowsable(EditorBrowsableState.Advanced)]
3906 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3907 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3909 bool resized = false;
3911 // Needed to generate required notifications
3912 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3916 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3923 bounds.Height=height;
3925 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3926 explicit_bounds = bounds;
3928 client_size.Width=clientWidth;
3929 client_size.Height=clientHeight;
3932 OnLocationChanged(EventArgs.Empty);
3936 OnSizeChanged(EventArgs.Empty);
3940 [EditorBrowsable(EditorBrowsableState.Advanced)]
3941 protected void UpdateStyles() {
3942 if (!IsHandleCreated) {
3946 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3947 OnStyleChanged(EventArgs.Empty);
3950 private void UpdateZOrderOfChild(Control child) {
3951 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3954 index = child_controls.IndexOf(child);
3957 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3959 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3964 private void UpdateChildrenZOrder() {
3965 Control [] controls;
3967 if (!IsHandleCreated) {
3971 controls = child_controls.GetAllControls ();
3972 for (int i = 1; i < controls.Length; i++ ) {
3973 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3977 [EditorBrowsable(EditorBrowsableState.Advanced)]
3978 protected void UpdateZOrder() {
3979 if (parent != null) {
3980 parent.UpdateZOrderOfChild(this);
3984 protected virtual void WndProc(ref Message m) {
3986 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3988 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3992 switch((Msg)m.Msg) {
3993 case Msg.WM_DESTROY: {
3994 OnHandleDestroyed(EventArgs.Empty);
3996 IntPtr handle = window.Handle;
3998 window.InvalidateHandle();
4000 if (is_recreating) {
4002 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4006 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4008 is_recreating = false;
4013 case Msg.WM_WINDOWPOSCHANGED: {
4015 Rectangle save_bounds = explicit_bounds;
4017 explicit_bounds = save_bounds;
4018 if (GetStyle(ControlStyles.ResizeRedraw)) {
4025 // Nice description of what should happen when handling WM_PAINT
4026 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4027 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4028 case Msg.WM_PAINT: {
4029 PaintEventArgs paint_event;
4031 paint_event = XplatUI.PaintEventStart(Handle, true);
4033 if (paint_event == null) {
4037 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4039 // Just blit the previous image
4040 XplatUI.BlitFromOffscreen (Handle, paint_event.Graphics, backbuffer, backbuffer_dc, paint_event.ClipRectangle);
4041 XplatUI.PaintEventEnd (Handle, true);
4046 Graphics back_dc = null;
4048 if (ThemeEngine.Current.DoubleBufferingSupported) {
4049 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4050 CreateBackBuffer ();
4052 back_dc = backbuffer_dc;
4053 dc = paint_event.SetGraphics (back_dc);
4057 if (!GetStyle(ControlStyles.Opaque)) {
4058 OnPaintBackground(paint_event);
4061 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4062 OnPaintBackgroundInternal(paint_event);
4064 OnPaintInternal(paint_event);
4065 if (!paint_event.Handled) {
4066 OnPaint(paint_event);
4069 if (ThemeEngine.Current.DoubleBufferingSupported)
4070 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4071 XplatUI.BlitFromOffscreen (Handle, dc, back, back_dc, paint_event.ClipRectangle);
4072 paint_event.SetGraphics (dc);
4073 invalid_region.Exclude (paint_event.ClipRectangle);
4075 if (back != backbuffer)
4076 XplatUI.DestroyOffscreenDrawable (back, back_dc);
4079 XplatUI.PaintEventEnd(Handle, true);
4084 case Msg.WM_ERASEBKGND: {
4085 // The DefWndProc will never have to handle this, we always paint the background in managed code
4086 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4087 // here but it just makes things more complicated...
4088 m.Result = (IntPtr)1;
4092 case Msg.WM_LBUTTONUP: {
4095 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4097 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4100 HandleClick(mouse_clicks, me);
4103 if (InternalCapture) {
4104 InternalCapture = false;
4107 if (mouse_clicks > 1) {
4113 case Msg.WM_LBUTTONDOWN: {
4115 Select (true, true);
4117 InternalCapture = true;
4118 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4119 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4125 case Msg.WM_LBUTTONDBLCLK: {
4126 InternalCapture = true;
4128 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4129 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4134 case Msg.WM_MBUTTONUP: {
4137 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4139 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4142 HandleClick(mouse_clicks, me);
4144 if (InternalCapture) {
4145 InternalCapture = false;
4147 if (mouse_clicks > 1) {
4153 case Msg.WM_MBUTTONDOWN: {
4154 InternalCapture = true;
4155 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4156 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4161 case Msg.WM_MBUTTONDBLCLK: {
4162 InternalCapture = true;
4164 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4165 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4170 case Msg.WM_RBUTTONUP: {
4174 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4175 pt = PointToScreen(pt);
4177 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4179 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4181 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4184 HandleClick(mouse_clicks, me);
4187 if (InternalCapture) {
4188 InternalCapture = false;
4191 if (mouse_clicks > 1) {
4197 case Msg.WM_RBUTTONDOWN: {
4198 InternalCapture = true;
4199 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4200 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4205 case Msg.WM_RBUTTONDBLCLK: {
4206 InternalCapture = true;
4208 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4209 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4214 case Msg.WM_CONTEXTMENU: {
4215 if (context_menu != null) {
4218 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4219 context_menu.Show(this, PointToClient(pt));
4227 case Msg.WM_MOUSEWHEEL: {
4229 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4230 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4231 HighOrder(m.WParam.ToInt32())));
4236 case Msg.WM_MOUSEMOVE: {
4237 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4239 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4244 case Msg.WM_MOUSE_ENTER: {
4249 OnMouseEnter(EventArgs.Empty);
4253 case Msg.WM_MOUSE_LEAVE: {
4255 OnMouseLeave(EventArgs.Empty);
4259 case Msg.WM_MOUSEHOVER: {
4260 OnMouseHover(EventArgs.Empty);
4264 case Msg.WM_SYSKEYUP: {
4265 if (ProcessKeyMessage(ref m)) {
4266 m.Result = IntPtr.Zero;
4270 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4274 if (form != null && form.ActiveMenu != null) {
4275 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4283 case Msg.WM_SYSKEYDOWN:
4284 case Msg.WM_KEYDOWN:
4286 case Msg.WM_SYSCHAR:
4288 if (ProcessKeyMessage(ref m)) {
4289 m.Result = IntPtr.Zero;
4298 if (m.LParam != IntPtr.Zero) {
4301 hi = new HELPINFO();
4303 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4304 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4306 mouse_pos = Control.MousePosition;
4308 OnHelpRequested(new HelpEventArgs(mouse_pos));
4309 m.Result = (IntPtr)1;
4313 case Msg.WM_KILLFOCUS: {
4314 this.has_focus = false;
4315 OnLostFocusInternal (EventArgs.Empty);
4319 case Msg.WM_SETFOCUS: {
4321 this.has_focus = true;
4322 OnGotFocusInternal (EventArgs.Empty);
4327 case Msg.WM_SYSCOLORCHANGE: {
4328 ThemeEngine.Current.ResetDefaults();
4329 OnSystemColorsChanged(EventArgs.Empty);
4333 case Msg.WM_SETCURSOR: {
4334 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4339 XplatUI.SetCursor(window.Handle, cursor.handle);
4340 m.Result = (IntPtr)1;
4350 #endregion // Public Instance Methods
4352 #region OnXXX methods
4353 [EditorBrowsable(EditorBrowsableState.Advanced)]
4354 protected virtual void OnBackColorChanged(EventArgs e) {
4355 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4358 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4361 [EditorBrowsable(EditorBrowsableState.Advanced)]
4362 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4363 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4366 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4369 [EditorBrowsable(EditorBrowsableState.Advanced)]
4370 protected virtual void OnBindingContextChanged(EventArgs e) {
4371 CheckDataBindings ();
4372 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4375 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4378 [EditorBrowsable(EditorBrowsableState.Advanced)]
4379 protected virtual void OnCausesValidationChanged(EventArgs e) {
4380 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4385 [EditorBrowsable(EditorBrowsableState.Advanced)]
4386 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4387 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4392 [EditorBrowsable(EditorBrowsableState.Advanced)]
4393 protected virtual void OnClick(EventArgs e) {
4394 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4399 [EditorBrowsable(EditorBrowsableState.Advanced)]
4400 protected virtual void OnContextMenuChanged(EventArgs e) {
4401 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4406 [EditorBrowsable(EditorBrowsableState.Advanced)]
4407 protected virtual void OnControlAdded(ControlEventArgs e) {
4408 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4413 [EditorBrowsable(EditorBrowsableState.Advanced)]
4414 protected virtual void OnControlRemoved(ControlEventArgs e) {
4415 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4420 [EditorBrowsable(EditorBrowsableState.Advanced)]
4421 protected virtual void OnCreateControl() {
4425 [EditorBrowsable(EditorBrowsableState.Advanced)]
4426 protected virtual void OnCursorChanged(EventArgs e) {
4427 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4432 [EditorBrowsable(EditorBrowsableState.Advanced)]
4433 protected virtual void OnDockChanged(EventArgs e) {
4434 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4439 [EditorBrowsable(EditorBrowsableState.Advanced)]
4440 protected virtual void OnDoubleClick(EventArgs e) {
4441 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4446 [EditorBrowsable(EditorBrowsableState.Advanced)]
4447 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4448 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4450 eh (this, drgevent);
4453 [EditorBrowsable(EditorBrowsableState.Advanced)]
4454 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4455 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4457 eh (this, drgevent);
4460 [EditorBrowsable(EditorBrowsableState.Advanced)]
4461 protected virtual void OnDragLeave(EventArgs e) {
4462 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4467 [EditorBrowsable(EditorBrowsableState.Advanced)]
4468 protected virtual void OnDragOver(DragEventArgs drgevent) {
4469 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4471 eh (this, drgevent);
4474 [EditorBrowsable(EditorBrowsableState.Advanced)]
4475 protected virtual void OnEnabledChanged(EventArgs e) {
4476 if (IsHandleCreated) {
4478 if (((Form)this).context == null) {
4479 XplatUI.EnableWindow(window.Handle, Enabled);
4482 XplatUI.EnableWindow(window.Handle, Enabled);
4487 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4491 for (int i=0; i<child_controls.Count; i++) {
4492 child_controls[i].OnParentEnabledChanged(e);
4496 [EditorBrowsable(EditorBrowsableState.Advanced)]
4497 protected virtual void OnEnter(EventArgs e) {
4498 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4503 [EditorBrowsable(EditorBrowsableState.Advanced)]
4504 protected virtual void OnFontChanged(EventArgs e) {
4505 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4508 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4511 [EditorBrowsable(EditorBrowsableState.Advanced)]
4512 protected virtual void OnForeColorChanged(EventArgs e) {
4513 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4516 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4519 [EditorBrowsable(EditorBrowsableState.Advanced)]
4520 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4521 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4523 eh (this, gfbevent);
4526 [EditorBrowsable(EditorBrowsableState.Advanced)]
4527 protected virtual void OnGotFocus(EventArgs e) {
4528 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4533 [EditorBrowsable(EditorBrowsableState.Advanced)]
4534 protected virtual void OnHandleCreated(EventArgs e) {
4535 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4540 [EditorBrowsable(EditorBrowsableState.Advanced)]
4541 protected virtual void OnHandleDestroyed(EventArgs e) {
4542 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4547 [EditorBrowsable(EditorBrowsableState.Advanced)]
4548 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4549 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4554 protected virtual void OnImeModeChanged(EventArgs e) {
4555 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4560 [EditorBrowsable(EditorBrowsableState.Advanced)]
4561 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4562 if (ThemeEngine.Current.DoubleBufferingSupported)
4563 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4564 // should this block be here? seems like it
4565 // would be more at home in
4566 // NotifyInvalidated..
4567 if (e.InvalidRect == ClientRectangle) {
4568 InvalidateBackBuffer ();
4571 // we need this Inflate call here so
4572 // that the border of the rectangle is
4573 // considered Visible (the
4574 // invalid_region.IsVisible call) in
4575 // the WM_PAINT handling below.
4576 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4577 if (invalid_region == null)
4578 invalid_region = new Region (r);
4580 invalid_region.Union (r);
4584 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4589 [EditorBrowsable(EditorBrowsableState.Advanced)]
4590 protected virtual void OnKeyDown(KeyEventArgs e) {
4591 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4596 [EditorBrowsable(EditorBrowsableState.Advanced)]
4597 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4598 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4603 [EditorBrowsable(EditorBrowsableState.Advanced)]
4604 protected virtual void OnKeyUp(KeyEventArgs e) {
4605 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4610 [EditorBrowsable(EditorBrowsableState.Advanced)]
4611 protected virtual void OnLayout(LayoutEventArgs levent) {
4612 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4617 [EditorBrowsable(EditorBrowsableState.Advanced)]
4618 protected virtual void OnLeave(EventArgs e) {
4619 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4624 [EditorBrowsable(EditorBrowsableState.Advanced)]
4625 protected virtual void OnLocationChanged(EventArgs e) {
4627 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4632 [EditorBrowsable(EditorBrowsableState.Advanced)]
4633 protected virtual void OnLostFocus(EventArgs e) {
4634 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4639 [EditorBrowsable(EditorBrowsableState.Advanced)]
4640 protected virtual void OnMouseDown(MouseEventArgs e) {
4641 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4646 [EditorBrowsable(EditorBrowsableState.Advanced)]
4647 protected virtual void OnMouseEnter(EventArgs e) {
4648 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4653 [EditorBrowsable(EditorBrowsableState.Advanced)]
4654 protected virtual void OnMouseHover(EventArgs e) {
4655 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4660 [EditorBrowsable(EditorBrowsableState.Advanced)]
4661 protected virtual void OnMouseLeave(EventArgs e) {
4662 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4667 [EditorBrowsable(EditorBrowsableState.Advanced)]
4668 protected virtual void OnMouseMove(MouseEventArgs e) {
4669 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4674 [EditorBrowsable(EditorBrowsableState.Advanced)]
4675 protected virtual void OnMouseUp(MouseEventArgs e) {
4676 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4681 [EditorBrowsable(EditorBrowsableState.Advanced)]
4682 protected virtual void OnMouseWheel(MouseEventArgs e) {
4683 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4688 [EditorBrowsable(EditorBrowsableState.Advanced)]
4689 protected virtual void OnMove(EventArgs e) {
4690 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4695 [EditorBrowsable(EditorBrowsableState.Advanced)]
4696 protected virtual void OnNotifyMessage(Message m) {
4700 [EditorBrowsable(EditorBrowsableState.Advanced)]
4701 protected virtual void OnPaint(PaintEventArgs e) {
4702 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4707 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4711 internal virtual void OnPaintInternal(PaintEventArgs e) {
4715 internal virtual void OnGotFocusInternal (EventArgs e)
4720 internal virtual void OnLostFocusInternal (EventArgs e)
4725 [EditorBrowsable(EditorBrowsableState.Advanced)]
4726 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4727 PaintControlBackground (pevent);
4730 [EditorBrowsable(EditorBrowsableState.Advanced)]
4731 protected virtual void OnParentBackColorChanged(EventArgs e) {
4732 if (background_color.IsEmpty && background_image==null) {
4734 OnBackColorChanged(e);
4738 [EditorBrowsable(EditorBrowsableState.Advanced)]
4739 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4740 if (background_color.IsEmpty && background_image==null) {
4742 OnBackgroundImageChanged(e);
4746 [EditorBrowsable(EditorBrowsableState.Advanced)]
4747 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4748 if (binding_context==null) {
4749 binding_context=Parent.binding_context;
4750 OnBindingContextChanged(e);
4754 [EditorBrowsable(EditorBrowsableState.Advanced)]
4755 protected virtual void OnParentChanged(EventArgs e) {
4756 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4761 [EditorBrowsable(EditorBrowsableState.Advanced)]
4762 protected virtual void OnParentEnabledChanged(EventArgs e) {
4764 OnEnabledChanged(e);
4768 [EditorBrowsable(EditorBrowsableState.Advanced)]
4769 protected virtual void OnParentFontChanged(EventArgs e) {
4776 [EditorBrowsable(EditorBrowsableState.Advanced)]
4777 protected virtual void OnParentForeColorChanged(EventArgs e) {
4778 if (foreground_color.IsEmpty) {
4780 OnForeColorChanged(e);
4784 [EditorBrowsable(EditorBrowsableState.Advanced)]
4785 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4786 if (right_to_left==RightToLeft.Inherit) {
4788 OnRightToLeftChanged(e);
4792 [EditorBrowsable(EditorBrowsableState.Advanced)]
4793 protected virtual void OnParentVisibleChanged(EventArgs e) {
4795 OnVisibleChanged(e);
4799 [EditorBrowsable(EditorBrowsableState.Advanced)]
4800 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4801 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4806 [EditorBrowsable(EditorBrowsableState.Advanced)]
4807 protected virtual void OnResize(EventArgs e) {
4808 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4812 PerformLayout(this, "bounds");
4814 if (parent != null) {
4815 parent.PerformLayout();
4819 [EditorBrowsable(EditorBrowsableState.Advanced)]
4820 protected virtual void OnRightToLeftChanged(EventArgs e) {
4821 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4824 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4827 [EditorBrowsable(EditorBrowsableState.Advanced)]
4828 protected virtual void OnSizeChanged(EventArgs e) {
4829 DisposeBackBuffer ();
4831 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4836 [EditorBrowsable(EditorBrowsableState.Advanced)]
4837 protected virtual void OnStyleChanged(EventArgs e) {
4838 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4843 [EditorBrowsable(EditorBrowsableState.Advanced)]
4844 protected virtual void OnSystemColorsChanged(EventArgs e) {
4845 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4850 [EditorBrowsable(EditorBrowsableState.Advanced)]
4851 protected virtual void OnTabIndexChanged(EventArgs e) {
4852 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4857 [EditorBrowsable(EditorBrowsableState.Advanced)]
4858 protected virtual void OnTabStopChanged(EventArgs e) {
4859 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4864 [EditorBrowsable(EditorBrowsableState.Advanced)]
4865 protected virtual void OnTextChanged(EventArgs e) {
4866 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4871 [EditorBrowsable(EditorBrowsableState.Advanced)]
4872 protected virtual void OnValidated(EventArgs e) {
4873 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4878 [EditorBrowsable(EditorBrowsableState.Advanced)]
4879 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4880 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4885 [EditorBrowsable(EditorBrowsableState.Advanced)]
4886 protected virtual void OnVisibleChanged(EventArgs e) {
4887 if ((parent != null) && !Created && Visible) {
4894 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4898 // We need to tell our kids
4899 for (int i=0; i<child_controls.Count; i++) {
4900 if (child_controls[i].Visible) {
4901 child_controls[i].OnParentVisibleChanged(e);
4905 #endregion // OnXXX methods
4908 static object BackColorChangedEvent = new object ();
4909 static object BackgroundImageChangedEvent = new object ();
4910 static object BindingContextChangedEvent = new object ();
4911 static object CausesValidationChangedEvent = new object ();
4912 static object ChangeUICuesEvent = new object ();
4913 static object ClickEvent = new object ();
4914 static object ContextMenuChangedEvent = new object ();
4915 static object ControlAddedEvent = new object ();
4916 static object ControlRemovedEvent = new object ();
4917 static object CursorChangedEvent = new object ();
4918 static object DockChangedEvent = new object ();
4919 static object DoubleClickEvent = new object ();
4920 static object DragDropEvent = new object ();
4921 static object DragEnterEvent = new object ();
4922 static object DragLeaveEvent = new object ();
4923 static object DragOverEvent = new object ();
4924 static object EnabledChangedEvent = new object ();
4925 static object EnterEvent = new object ();
4926 static object FontChangedEvent = new object ();
4927 static object ForeColorChangedEvent = new object ();
4928 static object GiveFeedbackEvent = new object ();
4929 static object GotFocusEvent = new object ();
4930 static object HandleCreatedEvent = new object ();
4931 static object HandleDestroyedEvent = new object ();
4932 static object HelpRequestedEvent = new object ();
4933 static object ImeModeChangedEvent = new object ();
4934 static object InvalidatedEvent = new object ();
4935 static object KeyDownEvent = new object ();
4936 static object KeyPressEvent = new object ();
4937 static object KeyUpEvent = new object ();
4938 static object LayoutEvent = new object ();
4939 static object LeaveEvent = new object ();
4940 static object LocationChangedEvent = new object ();
4941 static object LostFocusEvent = new object ();
4942 static object MouseDownEvent = new object ();
4943 static object MouseEnterEvent = new object ();
4944 static object MouseHoverEvent = new object ();
4945 static object MouseLeaveEvent = new object ();
4946 static object MouseMoveEvent = new object ();
4947 static object MouseUpEvent = new object ();
4948 static object MouseWheelEvent = new object ();
4949 static object MoveEvent = new object ();
4950 static object PaintEvent = new object ();
4951 static object ParentChangedEvent = new object ();
4952 static object QueryAccessibilityHelpEvent = new object ();
4953 static object QueryContinueDragEvent = new object ();
4954 static object ResizeEvent = new object ();
4955 static object RightToLeftChangedEvent = new object ();
4956 static object SizeChangedEvent = new object ();
4957 static object StyleChangedEvent = new object ();
4958 static object SystemColorsChangedEvent = new object ();
4959 static object TabIndexChangedEvent = new object ();
4960 static object TabStopChangedEvent = new object ();
4961 static object TextChangedEvent = new object ();
4962 static object ValidatedEvent = new object ();
4963 static object ValidatingEvent = new object ();
4964 static object VisibleChangedEvent = new object ();
4966 public event EventHandler BackColorChanged {
4967 add { Events.AddHandler (BackColorChangedEvent, value); }
4968 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4971 public event EventHandler BackgroundImageChanged {
4972 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4973 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4976 public event EventHandler BindingContextChanged {
4977 add { Events.AddHandler (BindingContextChangedEvent, value); }
4978 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4981 public event EventHandler CausesValidationChanged {
4982 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4983 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4986 public event UICuesEventHandler ChangeUICues {
4987 add { Events.AddHandler (ChangeUICuesEvent, value); }
4988 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4991 public event EventHandler Click {
4992 add { Events.AddHandler (ClickEvent, value); }
4993 remove { Events.RemoveHandler (ClickEvent, value); }
4996 public event EventHandler ContextMenuChanged {
4997 add { Events.AddHandler (ContextMenuChangedEvent, value); }
4998 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5001 [EditorBrowsable(EditorBrowsableState.Advanced)]
5003 public event ControlEventHandler ControlAdded {
5004 add { Events.AddHandler (ControlAddedEvent, value); }
5005 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5008 [EditorBrowsable(EditorBrowsableState.Advanced)]
5010 public event ControlEventHandler ControlRemoved {
5011 add { Events.AddHandler (ControlRemovedEvent, value); }
5012 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5015 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5016 public event EventHandler CursorChanged {
5017 add { Events.AddHandler (CursorChangedEvent, value); }
5018 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5020 public event EventHandler DockChanged {
5021 add { Events.AddHandler (DockChangedEvent, value); }
5022 remove { Events.RemoveHandler (DockChangedEvent, value); }
5025 public event EventHandler DoubleClick {
5026 add { Events.AddHandler (DoubleClickEvent, value); }
5027 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5030 public event DragEventHandler DragDrop {
5031 add { Events.AddHandler (DragDropEvent, value); }
5032 remove { Events.RemoveHandler (DragDropEvent, value); }
5035 public event DragEventHandler DragEnter {
5036 add { Events.AddHandler (DragEnterEvent, value); }
5037 remove { Events.RemoveHandler (DragEnterEvent, value); }
5040 public event EventHandler DragLeave {
5041 add { Events.AddHandler (DragLeaveEvent, value); }
5042 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5045 public event DragEventHandler DragOver {
5046 add { Events.AddHandler (DragOverEvent, value); }
5047 remove { Events.RemoveHandler (DragOverEvent, value); }
5050 public event EventHandler EnabledChanged {
5051 add { Events.AddHandler (EnabledChangedEvent, value); }
5052 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5055 public event EventHandler Enter {
5056 add { Events.AddHandler (EnterEvent, value); }
5057 remove { Events.RemoveHandler (EnterEvent, value); }
5060 public event EventHandler FontChanged {
5061 add { Events.AddHandler (FontChangedEvent, value); }
5062 remove { Events.RemoveHandler (FontChangedEvent, value); }
5065 public event EventHandler ForeColorChanged {
5066 add { Events.AddHandler (ForeColorChangedEvent, value); }
5067 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5070 public event GiveFeedbackEventHandler GiveFeedback {
5071 add { Events.AddHandler (GiveFeedbackEvent, value); }
5072 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5075 [EditorBrowsable(EditorBrowsableState.Advanced)]
5077 public event EventHandler GotFocus {
5078 add { Events.AddHandler (GotFocusEvent, value); }
5079 remove { Events.RemoveHandler (GotFocusEvent, value); }
5083 [EditorBrowsable(EditorBrowsableState.Advanced)]
5085 public event EventHandler HandleCreated {
5086 add { Events.AddHandler (HandleCreatedEvent, value); }
5087 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5090 [EditorBrowsable(EditorBrowsableState.Advanced)]
5092 public event EventHandler HandleDestroyed {
5093 add { Events.AddHandler (HandleDestroyedEvent, value); }
5094 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5097 public event HelpEventHandler HelpRequested {
5098 add { Events.AddHandler (HelpRequestedEvent, value); }
5099 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5102 public event EventHandler ImeModeChanged {
5103 add { Events.AddHandler (ImeModeChangedEvent, value); }
5104 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5107 [EditorBrowsable(EditorBrowsableState.Advanced)]
5109 public event InvalidateEventHandler Invalidated {
5110 add { Events.AddHandler (InvalidatedEvent, value); }
5111 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5114 public event KeyEventHandler KeyDown {
5115 add { Events.AddHandler (KeyDownEvent, value); }
5116 remove { Events.RemoveHandler (KeyDownEvent, value); }
5119 public event KeyPressEventHandler KeyPress {
5120 add { Events.AddHandler (KeyPressEvent, value); }
5121 remove { Events.RemoveHandler (KeyPressEvent, value); }
5124 public event KeyEventHandler KeyUp {
5125 add { Events.AddHandler (KeyUpEvent, value); }
5126 remove { Events.RemoveHandler (KeyUpEvent, value); }
5129 public event LayoutEventHandler Layout {
5130 add { Events.AddHandler (LayoutEvent, value); }
5131 remove { Events.RemoveHandler (LayoutEvent, value); }
5134 public event EventHandler Leave {
5135 add { Events.AddHandler (LeaveEvent, value); }
5136 remove { Events.RemoveHandler (LeaveEvent, value); }
5139 public event EventHandler LocationChanged {
5140 add { Events.AddHandler (LocationChangedEvent, value); }
5141 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5144 [EditorBrowsable(EditorBrowsableState.Advanced)]
5146 public event EventHandler LostFocus {
5147 add { Events.AddHandler (LostFocusEvent, value); }
5148 remove { Events.RemoveHandler (LostFocusEvent, value); }
5151 public event MouseEventHandler MouseDown {
5152 add { Events.AddHandler (MouseDownEvent, value); }
5153 remove { Events.RemoveHandler (MouseDownEvent, value); }
5156 public event EventHandler MouseEnter {
5157 add { Events.AddHandler (MouseEnterEvent, value); }
5158 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5161 public event EventHandler MouseHover {
5162 add { Events.AddHandler (MouseHoverEvent, value); }
5163 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5166 public event EventHandler MouseLeave {
5167 add { Events.AddHandler (MouseLeaveEvent, value); }
5168 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5171 public event MouseEventHandler MouseMove {
5172 add { Events.AddHandler (MouseMoveEvent, value); }
5173 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5176 public event MouseEventHandler MouseUp {
5177 add { Events.AddHandler (MouseUpEvent, value); }
5178 remove { Events.RemoveHandler (MouseUpEvent, value); }
5181 [EditorBrowsable(EditorBrowsableState.Advanced)]
5183 public event MouseEventHandler MouseWheel {
5184 add { Events.AddHandler (MouseWheelEvent, value); }
5185 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5188 public event EventHandler Move {
5189 add { Events.AddHandler (MoveEvent, value); }
5190 remove { Events.RemoveHandler (MoveEvent, value); }
5193 public event PaintEventHandler Paint {
5194 add { Events.AddHandler (PaintEvent, value); }
5195 remove { Events.RemoveHandler (PaintEvent, value); }
5198 public event EventHandler ParentChanged {
5199 add { Events.AddHandler (ParentChangedEvent, value); }
5200 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5203 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5204 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5205 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5208 public event QueryContinueDragEventHandler QueryContinueDrag {
5209 add { Events.AddHandler (QueryContinueDragEvent, value); }
5210 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5213 public event EventHandler Resize {
5214 add { Events.AddHandler (ResizeEvent, value); }
5215 remove { Events.RemoveHandler (ResizeEvent, value); }
5218 public event EventHandler RightToLeftChanged {
5219 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5220 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5223 public event EventHandler SizeChanged {
5224 add { Events.AddHandler (SizeChangedEvent, value); }
5225 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5228 public event EventHandler StyleChanged {
5229 add { Events.AddHandler (StyleChangedEvent, value); }
5230 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5233 public event EventHandler SystemColorsChanged {
5234 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5235 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5238 public event EventHandler TabIndexChanged {
5239 add { Events.AddHandler (TabIndexChangedEvent, value); }
5240 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5243 public event EventHandler TabStopChanged {
5244 add { Events.AddHandler (TabStopChangedEvent, value); }
5245 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5248 public event EventHandler TextChanged {
5249 add { Events.AddHandler (TextChangedEvent, value); }
5250 remove { Events.RemoveHandler (TextChangedEvent, value); }
5253 public event EventHandler Validated {
5254 add { Events.AddHandler (ValidatedEvent, value); }
5255 remove { Events.RemoveHandler (ValidatedEvent, value); }
5258 public event CancelEventHandler Validating {
5259 add { Events.AddHandler (ValidatingEvent, value); }
5260 remove { Events.RemoveHandler (ValidatingEvent, value); }
5263 public event EventHandler VisibleChanged {
5264 add { Events.AddHandler (VisibleChangedEvent, value); }
5265 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5268 #endregion // Events