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 IntPtr MakeParam (int low, int high){
987 return new IntPtr (high << 16 | low & 0xffff);
990 internal static int LowOrder (int param) {
991 return ((int)(short)(param & 0xffff));
994 internal static int HighOrder (int param) {
995 return ((int)(short)(param >> 16));
998 // This method exists so controls overriding OnPaintBackground can have default background painting done
999 internal virtual void PaintControlBackground (PaintEventArgs pevent)
1001 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1002 if (parent != null) {
1003 PaintEventArgs parent_pe;
1004 GraphicsState state;
1006 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1008 state = parent_pe.Graphics.Save();
1009 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1010 parent.OnPaintBackground(parent_pe);
1011 parent_pe.Graphics.Restore(state);
1013 state = parent_pe.Graphics.Save();
1014 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1015 parent.OnPaint(parent_pe);
1016 parent_pe.Graphics.Restore(state);
1017 parent_pe.SetGraphics(null);
1021 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1022 if (parent != null) {
1023 PaintEventArgs parent_pe;
1025 GraphicsState state;
1028 hwnd = Hwnd.ObjectFromHandle(Handle);
1031 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1033 region = new Region ();
1035 region.Union(ClientRectangle);
1037 foreach (Rectangle r in hwnd.ClipRectangles) {
1041 state = parent_pe.Graphics.Save();
1042 parent_pe.Graphics.Clip = region;
1044 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1045 parent.OnPaintBackground(parent_pe);
1046 parent_pe.Graphics.Restore(state);
1048 state = parent_pe.Graphics.Save();
1049 parent_pe.Graphics.Clip = region;
1051 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1052 parent.OnPaint(parent_pe);
1053 parent_pe.Graphics.Restore(state);
1054 parent_pe.SetGraphics(null);
1056 region.Intersect(clip_region);
1057 pevent.Graphics.Clip = region;
1062 if (background_image == null) {
1063 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));
1067 DrawBackgroundImage (pevent.Graphics);
1070 void DrawBackgroundImage (Graphics g)
1072 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1073 g.FillRectangle (b, ClientRectangle);
1077 internal virtual void DndEnter (DragEventArgs e)
1084 internal virtual void DndOver (DragEventArgs e)
1091 internal virtual void DndDrop (DragEventArgs e)
1095 } catch (Exception exc) {
1096 Console.Error.WriteLine ("MWF: Exception while dropping:");
1097 Console.Error.WriteLine (exc);
1101 internal virtual void DndLeave (EventArgs e)
1108 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1115 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1118 OnQueryContinueDrag(e);
1122 internal static MouseButtons FromParamToMouseButtons (int param) {
1123 MouseButtons buttons = MouseButtons.None;
1125 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1126 buttons |= MouseButtons.Left;
1128 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1129 buttons |= MouseButtons.Middle;
1131 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1132 buttons |= MouseButtons.Right;
1138 internal void FireEnter ()
1140 OnEnter (EventArgs.Empty);
1143 internal void FireLeave ()
1145 OnLeave (EventArgs.Empty);
1148 internal void FireValidating (CancelEventArgs ce)
1153 internal void FireValidated ()
1155 OnValidated (EventArgs.Empty);
1158 internal virtual bool ProcessControlMnemonic(char charCode) {
1159 return ProcessMnemonic(charCode);
1162 private static Control FindFlatForward(Control container, Control start) {
1168 end = container.child_controls.Count;
1170 if (start != null) {
1171 index = start.tab_index;
1176 for (int i = 0, pos = -1; i < end; i++) {
1177 if (start == container.child_controls[i]) {
1182 if (found == null) {
1183 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1184 found = container.child_controls[i];
1186 } else if (found.tab_index > container.child_controls[i].tab_index) {
1187 if (container.child_controls[i].tab_index > index) {
1188 found = container.child_controls[i];
1195 private static Control FindControlForward(Control container, Control start) {
1200 if (start == null) {
1201 return FindFlatForward(container, start);
1204 if (start.child_controls != null && start.child_controls.Count > 0 &&
1205 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1206 return FindControlForward(start, null);
1209 while (start != container) {
1210 found = FindFlatForward(start.parent, start);
1211 if (found != null) {
1214 start = start.parent;
1220 private static Control FindFlatBackward(Control container, Control start) {
1226 end = container.child_controls.Count;
1228 if (start != null) {
1229 index = start.tab_index;
1231 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1233 for (int i = 0; i < end; i++) {
1234 if (container.child_controls[i].tab_index > index) {
1235 index = container.child_controls[i].tab_index;
1243 for (int i = end - 1; i >= 0; i--) {
1244 if (start == container.child_controls[i]) {
1249 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1250 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1251 found = container.child_controls[i];
1258 private static Control FindControlBackward(Control container, Control start) {
1260 Control found = null;
1262 if (start == null) {
1263 found = FindFlatBackward(container, start);
1265 else if (start != container) {
1266 if (start.parent != null) {
1267 found = FindFlatBackward(start.parent, start);
1269 if (found == null) {
1270 if (start.parent != container)
1271 return start.parent;
1277 if (found == null || start.parent == null)
1280 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1281 found.child_controls != null && found.child_controls.Count > 0)) {
1282 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1283 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1284 found = FindFlatBackward(found, null);
1294 if (start != null) {
1295 found = FindFlatBackward(start.parent, start);
1296 if (found == null) {
1297 if (start.parent != container) {
1298 return start.parent;
1302 if (found == null) {
1303 found = FindFlatBackward(container, start);
1306 if (container != start) {
1307 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1308 found = FindControlBackward(found, null);
1309 if (found != null) {
1318 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1319 if (GetStyle(ControlStyles.StandardClick)) {
1320 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1322 OnDoubleClick(EventArgs.Empty);
1324 OnClick(EventArgs.Empty);
1334 private void CheckDataBindings ()
1336 if (data_bindings == null)
1339 BindingContext binding_context = BindingContext;
1340 foreach (Binding binding in data_bindings) {
1341 binding.Check (binding_context);
1345 private void ChangeParent(Control new_parent) {
1349 Color pre_fore_color;
1350 Color pre_back_color;
1351 RightToLeft pre_rtl;
1353 // These properties are inherited from our parent
1354 // Get them pre parent-change and then send events
1355 // if they are changed after we have our new parent
1356 pre_enabled = Enabled;
1357 pre_visible = Visible;
1359 pre_fore_color = ForeColor;
1360 pre_back_color = BackColor;
1361 pre_rtl = RightToLeft;
1362 // MS doesn't seem to send a CursorChangedEvent
1364 parent = new_parent;
1366 if (IsHandleCreated)
1367 XplatUI.SetParent(Handle,
1368 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1370 OnParentChanged(EventArgs.Empty);
1372 if (pre_enabled != Enabled) {
1373 OnEnabledChanged(EventArgs.Empty);
1376 if (pre_visible != Visible) {
1377 OnVisibleChanged(EventArgs.Empty);
1380 if (pre_font != Font) {
1381 OnFontChanged(EventArgs.Empty);
1384 if (pre_fore_color != ForeColor) {
1385 OnForeColorChanged(EventArgs.Empty);
1388 if (pre_back_color != BackColor) {
1389 OnBackColorChanged(EventArgs.Empty);
1392 if (pre_rtl != RightToLeft) {
1393 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1394 // because when RTL changes they have to recreate the win32 control
1395 // We don't really need that (until someone runs into compatibility issues)
1396 OnRightToLeftChanged(EventArgs.Empty);
1399 if ((new_parent != null) && new_parent.Created && !Created) {
1403 if ((binding_context == null) && Created) {
1404 OnBindingContextChanged(EventArgs.Empty);
1408 private void UpdateDistances() {
1409 if ((parent != null) && (parent.layout_suspended == 0)) {
1410 dist_left = bounds.X;
1411 dist_top = bounds.Y;
1412 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1413 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1416 #endregion // Private & Internal Methods
1418 #region Public Static Properties
1419 public static Color DefaultBackColor {
1421 return ThemeEngine.Current.DefaultControlBackColor;
1425 public static Font DefaultFont {
1427 return ThemeEngine.Current.DefaultFont;
1431 public static Color DefaultForeColor {
1433 return ThemeEngine.Current.DefaultControlForeColor;
1437 public static Keys ModifierKeys {
1439 return XplatUI.State.ModifierKeys;
1443 public static MouseButtons MouseButtons {
1445 return XplatUI.State.MouseButtons;
1449 public static Point MousePosition {
1451 return Cursor.Position;
1457 public static bool CheckForIllegalCrossThreadCalls
1460 return verify_thread_handle;
1464 verify_thread_handle = value;
1468 #endregion // Public Static Properties
1470 #region Public Instance Properties
1471 [EditorBrowsable(EditorBrowsableState.Advanced)]
1473 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1474 public AccessibleObject AccessibilityObject {
1476 if (accessibility_object==null) {
1477 accessibility_object=CreateAccessibilityInstance();
1479 return accessibility_object;
1483 [EditorBrowsable(EditorBrowsableState.Advanced)]
1485 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1486 public string AccessibleDefaultActionDescription {
1488 return AccessibilityObject.default_action;
1492 AccessibilityObject.default_action=value;
1497 [DefaultValue(null)]
1498 [MWFCategory("Accessibility")]
1499 public string AccessibleDescription {
1501 return AccessibilityObject.description;
1505 AccessibilityObject.description=value;
1510 [DefaultValue(null)]
1511 [MWFCategory("Accessibility")]
1512 public string AccessibleName {
1514 return AccessibilityObject.Name;
1518 AccessibilityObject.Name=value;
1522 [DefaultValue(AccessibleRole.Default)]
1523 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1524 public AccessibleRole AccessibleRole {
1526 return AccessibilityObject.role;
1530 AccessibilityObject.role=value;
1534 [DefaultValue(false)]
1535 [MWFCategory("Behavior")]
1536 public virtual bool AllowDrop {
1542 if (allow_drop == value)
1545 if (IsHandleCreated) {
1547 XplatUI.SetAllowDrop (Handle, value);
1553 [RefreshProperties(RefreshProperties.Repaint)]
1554 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1555 [MWFCategory("Layout")]
1556 public virtual AnchorStyles Anchor {
1558 return anchor_style;
1564 if (parent != null) {
1565 parent.PerformLayout(this, "Parent");
1571 // XXX: Implement me!
1574 public virtual bool AutoSize {
1576 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1580 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1585 public virtual Size MaximumSize {
1587 return maximum_size;
1590 maximum_size = value;
1594 public virtual Size MinimumSize {
1596 return minimum_size;
1599 minimum_size = value;
1605 [MWFCategory("Appearance")]
1606 public virtual Color BackColor {
1608 if (background_color.IsEmpty) {
1610 Color pcolor = parent.BackColor;
1611 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1614 return DefaultBackColor;
1616 return background_color;
1620 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1621 throw new ArgumentException("Transparent background colors are not supported on this control");
1624 if (background_color != value) {
1625 background_color=value;
1626 SetChildColor(this);
1627 OnBackColorChanged(EventArgs.Empty);
1634 [DefaultValue(null)]
1635 [MWFCategory("Appearance")]
1636 public virtual Image BackgroundImage {
1638 return background_image;
1642 if (background_image!=value) {
1643 background_image=value;
1644 OnBackgroundImageChanged(EventArgs.Empty);
1650 [EditorBrowsable(EditorBrowsableState.Advanced)]
1652 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1653 public virtual BindingContext BindingContext {
1655 if (binding_context != null)
1656 return binding_context;
1659 binding_context = Parent.BindingContext;
1660 return binding_context;
1663 if (binding_context != value) {
1664 binding_context = value;
1665 OnBindingContextChanged(EventArgs.Empty);
1670 [EditorBrowsable(EditorBrowsableState.Advanced)]
1672 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1675 return bounds.Y+bounds.Height;
1679 [EditorBrowsable(EditorBrowsableState.Advanced)]
1681 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1682 public Rectangle Bounds {
1688 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1692 [EditorBrowsable(EditorBrowsableState.Advanced)]
1694 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1695 public bool CanFocus {
1697 if (IsHandleCreated && Visible && Enabled) {
1704 [EditorBrowsable(EditorBrowsableState.Advanced)]
1706 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1707 public bool CanSelect {
1711 if (!GetStyle(ControlStyles.Selectable)) {
1716 while (parent != null) {
1717 if (!parent.is_visible || !parent.is_enabled) {
1721 parent = parent.parent;
1727 internal virtual bool InternalCapture {
1737 [EditorBrowsable(EditorBrowsableState.Advanced)]
1739 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1740 public bool Capture {
1742 return this.is_captured;
1746 if (this.IsHandleCreated && value != is_captured) {
1749 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1751 XplatUI.UngrabWindow(this.window.Handle);
1752 is_captured = false;
1758 [DefaultValue(true)]
1759 [MWFCategory("Focus")]
1760 public bool CausesValidation {
1762 return this.causes_validation;
1766 if (this.causes_validation != value) {
1767 causes_validation = value;
1768 OnCausesValidationChanged(EventArgs.Empty);
1773 [EditorBrowsable(EditorBrowsableState.Advanced)]
1775 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1776 public Rectangle ClientRectangle {
1778 client_rect.Width = client_size.Width;
1779 client_rect.Height = client_size.Height;
1784 [EditorBrowsable(EditorBrowsableState.Advanced)]
1786 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1787 public Size ClientSize {
1790 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1791 return ((Form)this).form_parent_window.ClientSize;
1799 this.SetClientSizeCore(value.Width, value.Height);
1803 [EditorBrowsable(EditorBrowsableState.Advanced)]
1805 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1806 [DescriptionAttribute("ControlCompanyNameDescr")]
1807 public String CompanyName {
1809 return "Mono Project, Novell, Inc.";
1813 [EditorBrowsable(EditorBrowsableState.Advanced)]
1815 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1816 public bool ContainsFocus {
1818 IntPtr focused_window;
1820 focused_window = XplatUI.GetFocus();
1821 if (IsHandleCreated) {
1822 if (focused_window == Handle) {
1826 for (int i=0; i < child_controls.Count; i++) {
1827 if (child_controls[i].ContainsFocus) {
1836 [DefaultValue(null)]
1837 [MWFCategory("Behavior")]
1838 public virtual ContextMenu ContextMenu {
1840 return GetContextMenuInternal ();
1844 if (context_menu != value) {
1845 context_menu = value;
1846 OnContextMenuChanged(EventArgs.Empty);
1851 internal virtual ContextMenu GetContextMenuInternal ()
1853 return context_menu;
1857 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1858 public ControlCollection Controls {
1860 return this.child_controls;
1864 [EditorBrowsable(EditorBrowsableState.Advanced)]
1866 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1867 public bool Created {
1869 return (!is_disposed && is_created);
1873 [AmbientValue(null)]
1874 [MWFCategory("Appearance")]
1875 public virtual Cursor Cursor {
1877 if (cursor != null) {
1881 if (parent != null) {
1882 return parent.Cursor;
1885 return Cursors.Default;
1889 if (cursor != value) {
1894 if (IsHandleCreated) {
1895 pt = Cursor.Position;
1897 if (bounds.Contains(pt) || Capture) {
1898 if (GetChildAtPoint(pt) == null) {
1899 if (cursor != null) {
1900 XplatUI.SetCursor(window.Handle, cursor.handle);
1902 if (parent != null) {
1903 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1905 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1912 OnCursorChanged(EventArgs.Empty);
1918 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1919 [ParenthesizePropertyName(true)]
1920 [RefreshProperties(RefreshProperties.All)]
1921 [MWFCategory("Data")]
1922 public ControlBindingsCollection DataBindings {
1924 if (data_bindings == null)
1925 data_bindings = new ControlBindingsCollection (this);
1926 return data_bindings;
1930 [EditorBrowsable(EditorBrowsableState.Advanced)]
1932 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1933 public virtual Rectangle DisplayRectangle {
1935 return ClientRectangle;
1939 [EditorBrowsable(EditorBrowsableState.Advanced)]
1941 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1942 public bool Disposing {
1949 [RefreshProperties(RefreshProperties.Repaint)]
1950 [DefaultValue(DockStyle.None)]
1951 [MWFCategory("Layout")]
1952 public virtual DockStyle Dock {
1958 if (dock_style == value) {
1962 if (!Enum.IsDefined (typeof (DockStyle), value)) {
1963 throw new InvalidEnumArgumentException ("value", (int) value,
1964 typeof (DockStyle));
1969 if (dock_style == DockStyle.None) {
1970 if (explicit_bounds == Rectangle.Empty)
1971 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1973 Bounds = explicit_bounds;
1976 if (parent != null) {
1977 parent.PerformLayout(this, "Parent");
1980 OnDockChanged(EventArgs.Empty);
1985 protected virtual bool DoubleBuffered {
1987 return (control_style & ControlStyles.DoubleBuffer) != 0;
1991 SetStyle (ControlStyles.DoubleBuffer, value);
1998 [MWFCategory("Behavior")]
1999 public bool Enabled {
2005 if (parent != null) {
2006 return parent.Enabled;
2014 bool old_value = is_enabled;
2017 if (old_value != value && !value && this.has_focus)
2018 SelectNextControl(this, true, true, true, true);
2020 OnEnabledChanged (EventArgs.Empty);
2024 [EditorBrowsable(EditorBrowsableState.Advanced)]
2026 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2027 public virtual bool Focused {
2029 return this.has_focus;
2034 [AmbientValue(null)]
2036 [MWFCategory("Appearance")]
2037 public virtual Font Font {
2043 if (Parent != null && Parent.Font != null) {
2050 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2052 if (font != null && font.Equals (value)) {
2058 OnFontChanged (EventArgs.Empty);
2063 [MWFCategory("Appearance")]
2064 public virtual Color ForeColor {
2066 if (foreground_color.IsEmpty) {
2068 return parent.ForeColor;
2070 return DefaultForeColor;
2072 return foreground_color;
2076 if (foreground_color != value) {
2077 foreground_color=value;
2079 OnForeColorChanged(EventArgs.Empty);
2086 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2087 public IntPtr Handle { // IWin32Window
2090 if (verify_thread_handle) {
2091 if (this.InvokeRequired) {
2092 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2096 if (!IsHandleCreated) {
2099 return window.Handle;
2103 [EditorBrowsable(EditorBrowsableState.Advanced)]
2105 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2106 public bool HasChildren {
2108 if (this.child_controls.Count>0) {
2115 [EditorBrowsable(EditorBrowsableState.Always)]
2117 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2120 return this.bounds.Height;
2124 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2128 [AmbientValue(ImeMode.Inherit)]
2130 [MWFCategory("Behavior")]
2131 public ImeMode ImeMode {
2133 if (ime_mode == ImeMode.Inherit) {
2135 return parent.ImeMode;
2137 return ImeMode.NoControl; // default value
2143 if (ime_mode != value) {
2146 OnImeModeChanged(EventArgs.Empty);
2151 [EditorBrowsable(EditorBrowsableState.Advanced)]
2153 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2154 public bool InvokeRequired { // ISynchronizeInvoke
2156 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2163 [EditorBrowsable(EditorBrowsableState.Advanced)]
2165 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2166 public bool IsAccessible {
2168 return is_accessible;
2172 is_accessible = value;
2176 [EditorBrowsable(EditorBrowsableState.Advanced)]
2178 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2179 public bool IsDisposed {
2181 return this.is_disposed;
2185 [EditorBrowsable(EditorBrowsableState.Advanced)]
2187 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2188 public bool IsHandleCreated {
2190 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2191 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2192 if (hwnd != null && !hwnd.zombie)
2201 public virtual Layout.LayoutEngine LayoutEngine {
2202 get { return new Layout.DefaultLayout (); }
2206 [EditorBrowsable(EditorBrowsableState.Always)]
2208 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2211 return this.bounds.X;
2215 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2220 [MWFCategory("Layout")]
2221 public Point Location {
2223 return new Point(bounds.X, bounds.Y);
2227 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2232 [Localizable (true)]
2233 public Padding Margin {
2234 get { return this.margin; }
2235 set { this.margin = value; }
2240 public string Name {
2252 public Padding Padding {
2264 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2265 public Control Parent {
2271 if (value == this) {
2272 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2275 if (parent!=value) {
2277 parent.Controls.Remove(this);
2282 value.Controls.Add(this);
2287 [EditorBrowsable(EditorBrowsableState.Advanced)]
2289 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2290 public string ProductName {
2292 Type t = typeof (AssemblyProductAttribute);
2293 Assembly assembly = GetType().Module.Assembly;
2294 object [] attrs = assembly.GetCustomAttributes (t, false);
2295 AssemblyProductAttribute a = null;
2296 // On MS we get a NullRefException if product attribute is not
2298 if (attrs != null && attrs.Length > 0)
2299 a = (AssemblyProductAttribute) attrs [0];
2304 [EditorBrowsable(EditorBrowsableState.Advanced)]
2306 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2307 public string ProductVersion {
2309 Type t = typeof (AssemblyVersionAttribute);
2310 Assembly assembly = GetType().Module.Assembly;
2311 object [] attrs = assembly.GetCustomAttributes (t, false);
2312 if (attrs == null || attrs.Length < 1)
2314 return ((AssemblyVersionAttribute)attrs [0]).Version;
2318 [EditorBrowsable(EditorBrowsableState.Advanced)]
2320 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2321 public bool RecreatingHandle {
2323 return is_recreating;
2327 [EditorBrowsable(EditorBrowsableState.Advanced)]
2329 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2330 public Region Region {
2336 if (value != null) {
2337 if (IsHandleCreated) {
2338 XplatUI.SetClipRegion(Handle, value);
2340 clip_region = value;
2345 [EditorBrowsable(EditorBrowsableState.Advanced)]
2347 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2350 return this.bounds.X+this.bounds.Width;
2354 [AmbientValue(RightToLeft.Inherit)]
2356 [MWFCategory("Appearance")]
2357 public virtual RightToLeft RightToLeft {
2359 if (right_to_left == RightToLeft.Inherit) {
2361 return parent.RightToLeft;
2363 return RightToLeft.No; // default value
2365 return right_to_left;
2369 if (value != right_to_left) {
2370 right_to_left = value;
2371 OnRightToLeftChanged(EventArgs.Empty);
2376 [EditorBrowsable(EditorBrowsableState.Advanced)]
2377 public override ISite Site {
2385 if (value != null) {
2386 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2388 BackColor = ap.BackColor;
2389 ForeColor = ap.ForeColor;
2398 [MWFCategory("Layout")]
2401 return new Size(Width, Height);
2405 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2410 [MergableProperty(false)]
2411 [MWFCategory("Behavior")]
2412 public int TabIndex {
2414 if (tab_index != -1) {
2421 if (tab_index != value) {
2423 OnTabIndexChanged(EventArgs.Empty);
2429 [DefaultValue(true)]
2430 [MWFCategory("Behavior")]
2431 public bool TabStop {
2437 if (tab_stop != value) {
2439 OnTabStopChanged(EventArgs.Empty);
2444 [Localizable(false)]
2446 [TypeConverter(typeof(StringConverter))]
2447 [DefaultValue(null)]
2448 [MWFCategory("Data")]
2455 control_tag = value;
2461 [BindableAttribute(true)]
2462 [MWFCategory("Appearance")]
2463 public virtual string Text {
2465 // Our implementation ignores ControlStyles.CacheText - we always cache
2470 if (value == null) {
2471 value = String.Empty;
2476 if (IsHandleCreated) {
2477 /* we need to call .SetWindowStyle here instead of just .Text
2478 because the presence/absence of Text (== "" or not) can cause
2479 other window style things to appear/disappear */
2480 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2481 XplatUI.Text(Handle, text);
2483 OnTextChanged (EventArgs.Empty);
2488 [EditorBrowsable(EditorBrowsableState.Always)]
2490 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2493 return this.bounds.Y;
2497 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2501 [EditorBrowsable(EditorBrowsableState.Advanced)]
2503 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2504 public Control TopLevelControl {
2508 while (p.parent != null) {
2512 return p is Form ? p : null;
2517 [MWFCategory("Behavior")]
2518 public bool Visible {
2522 } else if (parent != null) {
2523 return parent.Visible;
2530 SetVisibleCore(value);
2534 [EditorBrowsable(EditorBrowsableState.Always)]
2536 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2539 return this.bounds.Width;
2543 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2547 [EditorBrowsable(EditorBrowsableState.Never)]
2549 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2550 public IWindowTarget WindowTarget {
2559 #endregion // Public Instance Properties
2561 #region Protected Instance Properties
2562 protected virtual CreateParams CreateParams {
2564 CreateParams create_params = new CreateParams();
2567 create_params.Caption = Text;
2570 create_params.Caption = text;
2574 create_params.X = Left;
2577 create_params.X = this.bounds.X;
2581 create_params.Y = Top;
2584 create_params.Y = this.bounds.Y;
2588 create_params.Width = Width;
2591 create_params.Width = this.bounds.Width;
2595 create_params.Height = Height;
2598 create_params.Height = this.bounds.Height;
2602 create_params.ClassName = XplatUI.DefaultClassName;
2603 create_params.ClassStyle = 0;
2604 create_params.ExStyle = 0;
2605 create_params.Param = 0;
2608 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2611 if ((parent!=null) && (parent.IsHandleCreated)) {
2612 create_params.Parent = parent.Handle;
2615 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2618 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2622 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2625 switch (border_style) {
2626 case BorderStyle.FixedSingle:
2627 create_params.Style |= (int) WindowStyles.WS_BORDER;
2629 case BorderStyle.Fixed3D:
2630 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2634 return create_params;
2638 protected virtual ImeMode DefaultImeMode {
2640 return ImeMode.Inherit;
2645 protected virtual Padding DefaultMargin {
2646 get { return new Padding (3); }
2650 protected virtual Size DefaultSize {
2652 return new Size(0, 0);
2656 protected int FontHeight {
2666 protected bool RenderRightToLeft {
2668 return (this.right_to_left == RightToLeft.Yes);
2672 protected bool ResizeRedraw {
2674 return GetStyle(ControlStyles.ResizeRedraw);
2678 SetStyle(ControlStyles.ResizeRedraw, value);
2682 [EditorBrowsable(EditorBrowsableState.Advanced)]
2684 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2685 protected virtual bool ShowFocusCues {
2691 [EditorBrowsable(EditorBrowsableState.Advanced)]
2693 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2694 protected bool ShowKeyboardCues {
2699 #endregion // Protected Instance Properties
2701 #region Public Static Methods
2702 [EditorBrowsable(EditorBrowsableState.Advanced)]
2703 public static Control FromChildHandle(IntPtr handle) {
2704 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2707 [EditorBrowsable(EditorBrowsableState.Advanced)]
2708 public static Control FromHandle(IntPtr handle) {
2709 return Control.ControlNativeWindow.ControlFromHandle(handle);
2712 public static bool IsMnemonic(char charCode, string text) {
2715 amp = text.IndexOf('&');
2718 if (amp + 1 < text.Length) {
2719 if (text[amp + 1] != '&') {
2720 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2730 #region Protected Static Methods
2731 [EditorBrowsable(EditorBrowsableState.Advanced)]
2732 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2735 c = Control.FromHandle(hWnd);
2745 #region Public Instance Methods
2746 [EditorBrowsable(EditorBrowsableState.Advanced)]
2747 public IAsyncResult BeginInvoke(Delegate method) {
2748 object [] prms = null;
2749 if (method is EventHandler)
2750 prms = new object [] { this, EventArgs.Empty };
2751 return BeginInvokeInternal(method, prms, false);
2754 [EditorBrowsable(EditorBrowsableState.Advanced)]
2755 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2756 return BeginInvokeInternal (method, args, false);
2759 public void BringToFront() {
2760 if (parent != null) {
2761 parent.child_controls.SetChildIndex(this, 0);
2764 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2768 public bool Contains(Control ctl) {
2769 while (ctl != null) {
2778 public void CreateControl() {
2780 throw new ObjectDisposedException(GetType().FullName.ToString());
2786 if (!IsHandleCreated) {
2794 Control [] controls = child_controls.GetAllControls ();
2795 for (int i=0; i<controls.Length; i++) {
2796 controls [i].CreateControl ();
2799 UpdateChildrenZOrder();
2801 if (binding_context == null) { // seem to be sent whenever it's null?
2802 OnBindingContextChanged(EventArgs.Empty);
2808 public Graphics CreateGraphics() {
2809 if (!IsHandleCreated) {
2810 this.CreateHandle();
2812 return Graphics.FromHwnd(this.window.Handle);
2815 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2816 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2819 [EditorBrowsable(EditorBrowsableState.Advanced)]
2820 public object EndInvoke (IAsyncResult async_result) {
2821 AsyncMethodResult result = (AsyncMethodResult) async_result;
2822 return result.EndInvoke ();
2825 public Form FindForm() {
2838 public bool Focus() {
2839 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2842 is_focusing = false;
2847 public Control GetChildAtPoint(Point pt) {
2848 // Microsoft's version of this function doesn't seem to work, so I can't check
2849 // if we only consider children or also grandchildren, etc.
2850 // I'm gonna say 'children only'
2851 for (int i=0; i<child_controls.Count; i++) {
2852 if (child_controls[i].Bounds.Contains(pt)) {
2853 return child_controls[i];
2859 public IContainerControl GetContainerControl() {
2860 Control current = this;
2862 while (current!=null) {
2863 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2864 return (IContainerControl)current;
2866 current = current.parent;
2871 public Control GetNextControl(Control ctl, bool forward) {
2873 if (!this.Contains(ctl)) {
2878 ctl = FindControlForward(this, ctl);
2881 ctl = FindControlBackward(this, ctl);
2891 public virtual Size GetPreferredSize (Size proposedSize) {
2892 return preferred_size;
2896 public void Hide() {
2897 this.Visible = false;
2900 public void Invalidate() {
2901 Invalidate(ClientRectangle, false);
2904 public void Invalidate(bool invalidateChildren) {
2905 Invalidate(ClientRectangle, invalidateChildren);
2908 public void Invalidate(System.Drawing.Rectangle rc) {
2909 Invalidate(rc, false);
2912 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2913 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2917 NotifyInvalidate(rc);
2919 XplatUI.Invalidate(Handle, rc, false);
2921 if (invalidateChildren) {
2922 Control [] controls = child_controls.GetAllControls ();
2923 for (int i=0; i<controls.Length; i++)
2924 controls [i].Invalidate ();
2926 OnInvalidated(new InvalidateEventArgs(rc));
2929 public void Invalidate(System.Drawing.Region region) {
2930 Invalidate(region, false);
2933 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2934 RectangleF bounds = region.GetBounds (CreateGraphics ());
2935 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2936 invalidateChildren);
2939 public object Invoke (Delegate method) {
2940 object [] prms = null;
2941 if (method is EventHandler)
2942 prms = new object [] { this, EventArgs.Empty };
2944 return Invoke(method, prms);
2947 public object Invoke (Delegate method, object[] args) {
2948 if (!this.InvokeRequired) {
2949 return method.DynamicInvoke(args);
2952 IAsyncResult result = BeginInvoke (method, args);
2953 return EndInvoke(result);
2956 internal object InvokeInternal (Delegate method, bool disposing) {
2957 return InvokeInternal(method, null, disposing);
2960 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2961 if (!this.InvokeRequired) {
2962 return method.DynamicInvoke(args);
2965 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2966 return EndInvoke(result);
2969 [EditorBrowsable(EditorBrowsableState.Advanced)]
2970 public void PerformLayout() {
2971 PerformLayout(null, null);
2975 private void SetImplicitBounds (int x, int y, int width, int height)
2977 Rectangle saved_bounds = explicit_bounds;
2978 SetBounds (x, y, width, height);
2979 explicit_bounds = saved_bounds;
2983 [EditorBrowsable(EditorBrowsableState.Advanced)]
2984 public void PerformLayout(Control affectedControl, string affectedProperty) {
2985 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2987 if (layout_suspended > 0) {
2988 layout_pending = true;
2992 layout_pending = false;
2994 // Prevent us from getting messed up
2997 // Perform all Dock and Anchor calculations
3001 this.layout_engine.Layout(this, levent);
3003 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
3005 AnchorStyles anchor;
3008 space = DisplayRectangle;
3010 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
3011 Control [] controls = child_controls.GetAllControls ();
3012 for (int i = controls.Length - 1; i >= 0; i--) {
3013 child = controls [i];
3015 if (!child.Visible) {
3019 switch (child.Dock) {
3020 case DockStyle.None: {
3025 case DockStyle.Left: {
3026 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3027 space.X+=child.Width;
3028 space.Width-=child.Width;
3032 case DockStyle.Top: {
3033 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3034 space.Y+=child.Height;
3035 space.Height-=child.Height;
3039 case DockStyle.Right: {
3040 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3041 space.Width-=child.Width;
3045 case DockStyle.Bottom: {
3046 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3047 space.Height-=child.Height;
3053 for (int i = controls.Length - 1; i >= 0; i--) {
3056 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3057 if (child.Dock == DockStyle.Fill) {
3058 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3062 space = DisplayRectangle;
3064 for (int i=0; i < controls.Length; i++) {
3070 child = controls[i];
3072 // If the control is docked we don't need to do anything
3073 if (child.Dock != DockStyle.None) {
3077 anchor = child.Anchor;
3081 width = child.Width;
3082 height = child.Height;
3084 if ((anchor & AnchorStyles.Left) !=0 ) {
3085 if ((anchor & AnchorStyles.Right) != 0) {
3086 width = space.Width - child.dist_right - left;
3088 ; // Left anchored only, nothing to be done
3090 } else if ((anchor & AnchorStyles.Right) != 0) {
3091 left = space.Width - child.dist_right - width;
3093 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3094 // This calculates from scratch every time:
3095 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3098 if ((anchor & AnchorStyles.Top) !=0 ) {
3099 if ((anchor & AnchorStyles.Bottom) != 0) {
3100 height = space.Height - child.dist_bottom - top;
3102 ; // Top anchored only, nothing to be done
3104 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3105 top = space.Height - child.dist_bottom - height;
3107 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3108 // This calculates from scratch every time:
3109 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3121 child.SetImplicitBounds(left, top, width, height);
3125 // Let everyone know
3129 // Need to make sure we decremend layout_suspended
3135 public Point PointToClient (Point p) {
3139 XplatUI.ScreenToClient (Handle, ref x, ref y);
3141 return new Point (x, y);
3144 public Point PointToScreen(Point p) {
3148 XplatUI.ClientToScreen(Handle, ref x, ref y);
3150 return new Point(x, y);
3153 public virtual bool PreProcessMessage(ref Message msg) {
3154 return InternalPreProcessMessage (ref msg);
3157 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3160 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3161 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3163 if (!ProcessCmdKey(ref msg, key_data)) {
3164 if (IsInputKey(key_data)) {
3168 return ProcessDialogKey(key_data);
3172 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3173 if (IsInputChar((char)msg.WParam)) {
3176 return ProcessDialogChar((char)msg.WParam);
3177 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3178 return ProcessDialogChar((char)msg.WParam);
3183 public Rectangle RectangleToClient(Rectangle r) {
3184 return new Rectangle(PointToClient(r.Location), r.Size);
3187 public Rectangle RectangleToScreen(Rectangle r) {
3188 return new Rectangle(PointToScreen(r.Location), r.Size);
3191 public virtual void Refresh() {
3192 if (IsHandleCreated == true) {
3194 XplatUI.UpdateWindow(window.Handle);
3196 Control [] controls = child_controls.GetAllControls ();
3197 for (int i=0; i < controls.Length; i++) {
3198 controls[i].Refresh();
3204 [EditorBrowsable(EditorBrowsableState.Never)]
3205 public virtual void ResetBackColor() {
3206 BackColor = Color.Empty;
3209 [EditorBrowsable(EditorBrowsableState.Never)]
3210 public void ResetBindings() {
3211 data_bindings.Clear();
3214 [EditorBrowsable(EditorBrowsableState.Never)]
3215 public virtual void ResetCursor() {
3219 [EditorBrowsable(EditorBrowsableState.Never)]
3220 public virtual void ResetFont() {
3224 [EditorBrowsable(EditorBrowsableState.Never)]
3225 public virtual void ResetForeColor() {
3226 foreground_color = Color.Empty;
3229 [EditorBrowsable(EditorBrowsableState.Never)]
3230 public void ResetImeMode() {
3231 ime_mode = DefaultImeMode;
3234 [EditorBrowsable(EditorBrowsableState.Never)]
3235 public virtual void ResetRightToLeft() {
3236 right_to_left = RightToLeft.Inherit;
3239 public virtual void ResetText() {
3240 text = String.Empty;
3243 public void ResumeLayout() {
3244 ResumeLayout (true);
3247 public void ResumeLayout(bool performLayout) {
3248 if (layout_suspended > 0) {
3252 if (layout_suspended == 0) {
3253 Control [] controls = child_controls.GetAllControls ();
3254 for (int i=0; i<controls.Length; i++) {
3255 controls [i].UpdateDistances ();
3258 if (performLayout && layout_pending) {
3264 public void Scale(float ratio) {
3265 ScaleCore(ratio, ratio);
3268 public void Scale(float dx, float dy) {
3273 public void Scale(SizeF factor) {
3274 ScaleCore(factor.Width, factor.Height);
3278 public void Select() {
3279 Select(false, false);
3283 private void printTree(Control c, string t) {
3284 foreach(Control i in c.child_controls) {
3285 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3286 printTree(i, t+"\t");
3290 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3294 Console.WriteLine("{0}", this.FindForm());
3295 printTree(this, "\t");
3298 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3303 c = GetNextControl(c, forward);
3312 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3313 c.Select (true, true);
3316 } while (c != ctl); // If we wrap back to ourselves we stop
3321 public void SendToBack() {
3322 if (parent != null) {
3323 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3327 public void SetBounds(int x, int y, int width, int height) {
3328 SetBounds(x, y, width, height, BoundsSpecified.All);
3331 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3332 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3336 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3340 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3344 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3348 SetBoundsCore(x, y, width, height, specified);
3349 if (parent != null) {
3350 parent.PerformLayout(this, "Bounds");
3354 public void Show() {
3356 this.CreateControl();
3362 public void SuspendLayout() {
3366 public void Update() {
3367 if (IsHandleCreated) {
3368 XplatUI.UpdateWindow(window.Handle);
3371 #endregion // Public Instance Methods
3373 #region Protected Instance Methods
3374 [EditorBrowsable(EditorBrowsableState.Advanced)]
3375 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3376 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3377 throw new NotImplementedException();
3380 [EditorBrowsable(EditorBrowsableState.Advanced)]
3381 protected virtual AccessibleObject CreateAccessibilityInstance() {
3382 return new Control.ControlAccessibleObject(this);
3385 [EditorBrowsable(EditorBrowsableState.Advanced)]
3386 protected virtual ControlCollection CreateControlsInstance() {
3387 return new ControlCollection(this);
3390 [EditorBrowsable(EditorBrowsableState.Advanced)]
3391 protected virtual void CreateHandle() {
3393 throw new ObjectDisposedException(GetType().FullName.ToString());
3396 if (IsHandleCreated && !is_recreating) {
3400 window.CreateHandle(CreateParams);
3402 if (window.Handle != IntPtr.Zero) {
3403 creator_thread = Thread.CurrentThread;
3405 XplatUI.EnableWindow(window.Handle, is_enabled);
3406 XplatUI.SetVisible(window.Handle, is_visible, true);
3408 if (clip_region != null) {
3409 XplatUI.SetClipRegion(Handle, clip_region);
3412 // Set our handle with our parent
3413 if ((parent != null) && (parent.IsHandleCreated)) {
3414 XplatUI.SetParent(window.Handle, parent.Handle);
3417 // Set our handle as parent for our children
3418 Control [] children;
3420 children = child_controls.GetAllControls ();
3421 for (int i = 0; i < children.Length; i++ ) {
3422 if (!children[i].RecreatingHandle)
3423 XplatUI.SetParent(children[i].Handle, window.Handle);
3427 XplatUI.SetAllowDrop (Handle, allow_drop);
3429 // Find out where the window manager placed us
3430 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3431 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3435 OnHandleCreated(EventArgs.Empty);
3439 [EditorBrowsable(EditorBrowsableState.Advanced)]
3440 protected virtual void DefWndProc(ref Message m) {
3441 window.DefWndProc(ref m);
3444 [EditorBrowsable(EditorBrowsableState.Advanced)]
3445 protected virtual void DestroyHandle() {
3446 if (IsHandleCreated) {
3447 if (window != null) {
3448 window.DestroyHandle();
3453 protected internal bool GetStyle(ControlStyles flag) {
3454 return (control_style & flag) != 0;
3457 protected bool GetTopLevel() {
3461 [EditorBrowsable(EditorBrowsableState.Advanced)]
3462 protected virtual void InitLayout() {
3466 [EditorBrowsable(EditorBrowsableState.Advanced)]
3467 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3468 toInvoke.OnGotFocus(e);
3471 [EditorBrowsable(EditorBrowsableState.Advanced)]
3472 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3473 toInvoke.OnLostFocus(e);
3476 [EditorBrowsable(EditorBrowsableState.Advanced)]
3477 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3478 toInvoke.OnClick(e);
3481 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3482 toInvoke.OnPaint(e);
3485 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3486 toInvoke.OnPaintBackground(e);
3489 protected virtual bool IsInputChar (char charCode) {
3493 protected virtual bool IsInputKey (Keys keyData) {
3494 // Doc says this one calls IsInputChar; not sure what to do with that
3498 [EditorBrowsable(EditorBrowsableState.Advanced)]
3499 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3503 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3504 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3508 if (parent != null) {
3509 return parent.ProcessCmdKey(ref msg, keyData);
3515 protected virtual bool ProcessDialogChar(char charCode) {
3516 if (parent != null) {
3517 return parent.ProcessDialogChar (charCode);
3523 protected virtual bool ProcessDialogKey (Keys keyData) {
3524 if (parent != null) {
3525 return parent.ProcessDialogKey (keyData);
3531 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3533 KeyEventArgs key_event;
3536 case (int)Msg.WM_SYSKEYDOWN:
3537 case (int)Msg.WM_KEYDOWN: {
3538 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3539 OnKeyDown (key_event);
3540 return key_event.Handled;
3543 case (int)Msg.WM_SYSKEYUP:
3544 case (int)Msg.WM_KEYUP: {
3545 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3546 OnKeyUp (key_event);
3547 return key_event.Handled;
3550 case (int)Msg.WM_SYSCHAR:
3551 case (int)Msg.WM_CHAR: {
3552 KeyPressEventArgs key_press_event;
3554 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3555 OnKeyPress(key_press_event);
3557 msg.WParam = (IntPtr)key_press_event.KeyChar;
3559 return key_press_event.Handled;
3570 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3571 if (parent != null) {
3572 if (parent.ProcessKeyPreview(ref msg)) {
3577 return ProcessKeyEventArgs(ref msg);
3580 protected virtual bool ProcessKeyPreview(ref Message msg) {
3581 if (parent != null) {
3582 return parent.ProcessKeyPreview(ref msg);
3588 protected virtual bool ProcessMnemonic(char charCode) {
3593 [EditorBrowsable(EditorBrowsableState.Advanced)]
3594 protected void RaiseDragEvent(object key, DragEventArgs e) {
3598 [EditorBrowsable(EditorBrowsableState.Advanced)]
3599 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3603 [EditorBrowsable(EditorBrowsableState.Advanced)]
3604 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3608 [EditorBrowsable(EditorBrowsableState.Advanced)]
3609 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3613 private void SetIsRecreating ()
3617 foreach (Control c in Controls.GetAllControls()) {
3618 c.SetIsRecreating ();
3622 [EditorBrowsable(EditorBrowsableState.Advanced)]
3623 protected void RecreateHandle() {
3625 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3630 if (IsHandleCreated) {
3632 Console.WriteLine(" + handle is created, destroying it.");
3635 // WM_DESTROY will CreateHandle for us
3638 Console.WriteLine(" + handle is not created, creating it.");
3646 is_recreating = false;
3648 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3654 [EditorBrowsable(EditorBrowsableState.Advanced)]
3655 protected void ResetMouseEventArgs() {
3659 [EditorBrowsable(EditorBrowsableState.Advanced)]
3660 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3661 if (right_to_left == RightToLeft.No) {
3666 case ContentAlignment.TopLeft: {
3667 return ContentAlignment.TopRight;
3670 case ContentAlignment.TopRight: {
3671 return ContentAlignment.TopLeft;
3674 case ContentAlignment.MiddleLeft: {
3675 return ContentAlignment.MiddleRight;
3678 case ContentAlignment.MiddleRight: {
3679 return ContentAlignment.MiddleLeft;
3682 case ContentAlignment.BottomLeft: {
3683 return ContentAlignment.BottomRight;
3686 case ContentAlignment.BottomRight: {
3687 return ContentAlignment.BottomLeft;
3691 // if it's center it doesn't change
3697 [EditorBrowsable(EditorBrowsableState.Advanced)]
3698 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3699 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3703 if (align == HorizontalAlignment.Left) {
3704 return HorizontalAlignment.Right;
3707 // align must be HorizontalAlignment.Right
3708 return HorizontalAlignment.Left;
3711 [EditorBrowsable(EditorBrowsableState.Advanced)]
3712 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3713 if (right_to_left == RightToLeft.No) {
3717 if (align == LeftRightAlignment.Left) {
3718 return LeftRightAlignment.Right;
3721 // align must be LeftRightAlignment.Right;
3722 return LeftRightAlignment.Left;
3725 [EditorBrowsable(EditorBrowsableState.Advanced)]
3726 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3727 return RtlTranslateAlignment(align);
3730 [EditorBrowsable(EditorBrowsableState.Advanced)]
3731 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3732 return RtlTranslateAlignment(align);
3735 [EditorBrowsable(EditorBrowsableState.Advanced)]
3736 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3737 return RtlTranslateAlignment(align);
3740 [EditorBrowsable(EditorBrowsableState.Advanced)]
3741 protected virtual void ScaleCore(float dx, float dy) {
3747 location = new Point((int)(Left * dx), (int)(Top * dy));
3748 size = this.ClientSize;
3750 if (!GetStyle(ControlStyles.FixedWidth)) {
3751 size.Width = (int)(size.Width * dx);
3754 if (!GetStyle(ControlStyles.FixedHeight)) {
3755 size.Height = (int)(size.Height * dy);
3758 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3760 /* Now scale our children */
3761 Control [] controls = child_controls.GetAllControls ();
3762 for (int i=0; i < controls.Length; i++) {
3763 controls[i].Scale(dx, dy);
3769 protected virtual void Select(bool directed, bool forward) {
3770 IContainerControl container;
3772 container = GetContainerControl();
3773 if (container != null)
3774 container.ActiveControl = this;
3777 [EditorBrowsable(EditorBrowsableState.Advanced)]
3778 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3779 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3780 if (IsHandleCreated) {
3781 XplatUI.SetWindowPos(Handle, x, y, width, height);
3783 // Win32 automatically changes negative width/height to 0.
3784 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3785 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3787 if (width < 0 || height < 0) {
3789 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3793 UpdateBounds(x, y, width, height);
3798 [EditorBrowsable(EditorBrowsableState.Advanced)]
3799 protected virtual void SetClientSizeCore(int x, int y) {
3800 // Calculate the actual window size from the client size (it usually stays the same or grows)
3801 Rectangle ClientRect;
3802 Rectangle WindowRect;
3805 ClientRect = new Rectangle(0, 0, x, y);
3806 cp = this.CreateParams;
3808 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3812 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3815 [EditorBrowsable(EditorBrowsableState.Advanced)]
3816 protected internal void SetStyle(ControlStyles flag, bool value) {
3818 control_style |= flag;
3820 control_style &= ~flag;
3824 protected void SetTopLevel(bool value) {
3825 if ((GetTopLevel() != value) && (parent != null)) {
3826 throw new Exception();
3830 if (value == true) {
3840 is_toplevel = value;
3843 protected virtual void SetVisibleCore(bool value) {
3844 if (value!=is_visible) {
3845 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3851 if (IsHandleCreated) {
3852 XplatUI.SetVisible(Handle, value, true);
3853 // Explicitly move Toplevel windows to where we want them;
3854 // apparently moving unmapped toplevel windows doesn't work
3855 if (is_visible && (this is Form)) {
3856 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3860 OnVisibleChanged(EventArgs.Empty);
3862 if (value == false && parent != null && Focused) {
3865 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3866 container = (Control)parent.GetContainerControl();
3867 if (container != null) {
3868 container.SelectNextControl(this, true, true, true, true);
3872 if (parent != null) {
3873 parent.PerformLayout(this, "visible");
3875 PerformLayout(this, "visible");
3880 [EditorBrowsable(EditorBrowsableState.Advanced)]
3881 protected void UpdateBounds() {
3889 if (!IsHandleCreated) {
3893 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3895 UpdateBounds(x, y, width, height, client_width, client_height);
3898 [EditorBrowsable(EditorBrowsableState.Advanced)]
3899 protected void UpdateBounds(int x, int y, int width, int height) {
3903 // Calculate client rectangle
3904 rect = new Rectangle(0, 0, 0, 0);
3907 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3908 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3911 [EditorBrowsable(EditorBrowsableState.Advanced)]
3912 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3913 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3915 bool resized = false;
3917 // Needed to generate required notifications
3918 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3922 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3929 bounds.Height=height;
3931 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3932 explicit_bounds = bounds;
3934 client_size.Width=clientWidth;
3935 client_size.Height=clientHeight;
3938 OnLocationChanged(EventArgs.Empty);
3942 OnSizeChanged(EventArgs.Empty);
3946 [EditorBrowsable(EditorBrowsableState.Advanced)]
3947 protected void UpdateStyles() {
3948 if (!IsHandleCreated) {
3952 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3953 OnStyleChanged(EventArgs.Empty);
3956 private void UpdateZOrderOfChild(Control child) {
3957 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3960 index = child_controls.IndexOf(child);
3963 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3965 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3970 private void UpdateChildrenZOrder() {
3971 Control [] controls;
3973 if (!IsHandleCreated) {
3977 controls = child_controls.GetAllControls ();
3978 for (int i = 1; i < controls.Length; i++ ) {
3979 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3983 [EditorBrowsable(EditorBrowsableState.Advanced)]
3984 protected void UpdateZOrder() {
3985 if (parent != null) {
3986 parent.UpdateZOrderOfChild(this);
3990 protected virtual void WndProc(ref Message m) {
3992 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3994 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3998 switch((Msg)m.Msg) {
3999 case Msg.WM_DESTROY: {
4000 OnHandleDestroyed(EventArgs.Empty);
4002 IntPtr handle = window.Handle;
4004 window.InvalidateHandle();
4006 if (is_recreating) {
4008 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4012 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4014 is_recreating = false;
4019 case Msg.WM_WINDOWPOSCHANGED: {
4021 Rectangle save_bounds = explicit_bounds;
4023 explicit_bounds = save_bounds;
4024 if (GetStyle(ControlStyles.ResizeRedraw)) {
4031 // Nice description of what should happen when handling WM_PAINT
4032 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4033 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4034 case Msg.WM_PAINT: {
4035 PaintEventArgs paint_event;
4037 paint_event = XplatUI.PaintEventStart(Handle, true);
4039 if (paint_event == null) {
4043 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4045 // Just blit the previous image
4046 XplatUI.BlitFromOffscreen (Handle, paint_event.Graphics, backbuffer, backbuffer_dc, paint_event.ClipRectangle);
4047 XplatUI.PaintEventEnd (Handle, true);
4052 Graphics back_dc = null;
4054 if (ThemeEngine.Current.DoubleBufferingSupported) {
4055 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4056 CreateBackBuffer ();
4058 back_dc = backbuffer_dc;
4059 dc = paint_event.SetGraphics (back_dc);
4063 if (!GetStyle(ControlStyles.Opaque)) {
4064 OnPaintBackground(paint_event);
4067 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4068 OnPaintBackgroundInternal(paint_event);
4070 OnPaintInternal(paint_event);
4071 if (!paint_event.Handled) {
4072 OnPaint(paint_event);
4075 if (ThemeEngine.Current.DoubleBufferingSupported)
4076 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4077 XplatUI.BlitFromOffscreen (Handle, dc, back, back_dc, paint_event.ClipRectangle);
4078 paint_event.SetGraphics (dc);
4079 invalid_region.Exclude (paint_event.ClipRectangle);
4081 if (back != backbuffer)
4082 XplatUI.DestroyOffscreenDrawable (back, back_dc);
4085 XplatUI.PaintEventEnd(Handle, true);
4090 case Msg.WM_ERASEBKGND: {
4091 // The DefWndProc will never have to handle this, we always paint the background in managed code
4092 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4093 // here but it just makes things more complicated...
4094 m.Result = (IntPtr)1;
4098 case Msg.WM_LBUTTONUP: {
4101 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4103 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4106 HandleClick(mouse_clicks, me);
4109 if (InternalCapture) {
4110 InternalCapture = false;
4113 if (mouse_clicks > 1) {
4119 case Msg.WM_LBUTTONDOWN: {
4121 Select (true, true);
4123 InternalCapture = true;
4124 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4125 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4131 case Msg.WM_LBUTTONDBLCLK: {
4132 InternalCapture = true;
4134 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4135 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4140 case Msg.WM_MBUTTONUP: {
4143 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4145 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4148 HandleClick(mouse_clicks, me);
4150 if (InternalCapture) {
4151 InternalCapture = false;
4153 if (mouse_clicks > 1) {
4159 case Msg.WM_MBUTTONDOWN: {
4160 InternalCapture = true;
4161 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4162 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4167 case Msg.WM_MBUTTONDBLCLK: {
4168 InternalCapture = true;
4170 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4171 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4176 case Msg.WM_RBUTTONUP: {
4180 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4181 pt = PointToScreen(pt);
4183 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4185 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4187 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4190 HandleClick(mouse_clicks, me);
4193 if (InternalCapture) {
4194 InternalCapture = false;
4197 if (mouse_clicks > 1) {
4203 case Msg.WM_RBUTTONDOWN: {
4204 InternalCapture = true;
4205 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4206 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4211 case Msg.WM_RBUTTONDBLCLK: {
4212 InternalCapture = true;
4214 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4215 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4220 case Msg.WM_CONTEXTMENU: {
4221 if (context_menu != null) {
4224 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4225 context_menu.Show(this, PointToClient(pt));
4233 case Msg.WM_MOUSEWHEEL: {
4235 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4236 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4237 HighOrder(m.WParam.ToInt32())));
4242 case Msg.WM_MOUSEMOVE: {
4243 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4245 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4250 case Msg.WM_MOUSE_ENTER: {
4255 OnMouseEnter(EventArgs.Empty);
4259 case Msg.WM_MOUSE_LEAVE: {
4261 OnMouseLeave(EventArgs.Empty);
4265 case Msg.WM_MOUSEHOVER: {
4266 OnMouseHover(EventArgs.Empty);
4270 case Msg.WM_SYSKEYUP: {
4271 if (ProcessKeyMessage(ref m)) {
4272 m.Result = IntPtr.Zero;
4276 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4280 if (form != null && form.ActiveMenu != null) {
4281 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4289 case Msg.WM_SYSKEYDOWN:
4290 case Msg.WM_KEYDOWN:
4292 case Msg.WM_SYSCHAR:
4294 if (ProcessKeyMessage(ref m)) {
4295 m.Result = IntPtr.Zero;
4304 if (m.LParam != IntPtr.Zero) {
4307 hi = new HELPINFO();
4309 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4310 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4312 mouse_pos = Control.MousePosition;
4314 OnHelpRequested(new HelpEventArgs(mouse_pos));
4315 m.Result = (IntPtr)1;
4319 case Msg.WM_KILLFOCUS: {
4320 this.has_focus = false;
4321 OnLostFocusInternal (EventArgs.Empty);
4325 case Msg.WM_SETFOCUS: {
4327 this.has_focus = true;
4328 OnGotFocusInternal (EventArgs.Empty);
4333 case Msg.WM_SYSCOLORCHANGE: {
4334 ThemeEngine.Current.ResetDefaults();
4335 OnSystemColorsChanged(EventArgs.Empty);
4339 case Msg.WM_SETCURSOR: {
4340 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4345 XplatUI.SetCursor(window.Handle, cursor.handle);
4346 m.Result = (IntPtr)1;
4356 #endregion // Public Instance Methods
4358 #region OnXXX methods
4359 [EditorBrowsable(EditorBrowsableState.Advanced)]
4360 protected virtual void OnBackColorChanged(EventArgs e) {
4361 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4364 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4367 [EditorBrowsable(EditorBrowsableState.Advanced)]
4368 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4369 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4372 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4375 [EditorBrowsable(EditorBrowsableState.Advanced)]
4376 protected virtual void OnBindingContextChanged(EventArgs e) {
4377 CheckDataBindings ();
4378 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4381 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4384 [EditorBrowsable(EditorBrowsableState.Advanced)]
4385 protected virtual void OnCausesValidationChanged(EventArgs e) {
4386 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4391 [EditorBrowsable(EditorBrowsableState.Advanced)]
4392 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4393 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4398 [EditorBrowsable(EditorBrowsableState.Advanced)]
4399 protected virtual void OnClick(EventArgs e) {
4400 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4405 [EditorBrowsable(EditorBrowsableState.Advanced)]
4406 protected virtual void OnContextMenuChanged(EventArgs e) {
4407 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4412 [EditorBrowsable(EditorBrowsableState.Advanced)]
4413 protected virtual void OnControlAdded(ControlEventArgs e) {
4414 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4419 [EditorBrowsable(EditorBrowsableState.Advanced)]
4420 protected virtual void OnControlRemoved(ControlEventArgs e) {
4421 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4426 [EditorBrowsable(EditorBrowsableState.Advanced)]
4427 protected virtual void OnCreateControl() {
4431 [EditorBrowsable(EditorBrowsableState.Advanced)]
4432 protected virtual void OnCursorChanged(EventArgs e) {
4433 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4438 [EditorBrowsable(EditorBrowsableState.Advanced)]
4439 protected virtual void OnDockChanged(EventArgs e) {
4440 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4445 [EditorBrowsable(EditorBrowsableState.Advanced)]
4446 protected virtual void OnDoubleClick(EventArgs e) {
4447 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4452 [EditorBrowsable(EditorBrowsableState.Advanced)]
4453 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4454 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4456 eh (this, drgevent);
4459 [EditorBrowsable(EditorBrowsableState.Advanced)]
4460 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4461 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4463 eh (this, drgevent);
4466 [EditorBrowsable(EditorBrowsableState.Advanced)]
4467 protected virtual void OnDragLeave(EventArgs e) {
4468 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4473 [EditorBrowsable(EditorBrowsableState.Advanced)]
4474 protected virtual void OnDragOver(DragEventArgs drgevent) {
4475 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4477 eh (this, drgevent);
4480 [EditorBrowsable(EditorBrowsableState.Advanced)]
4481 protected virtual void OnEnabledChanged(EventArgs e) {
4482 if (IsHandleCreated) {
4484 if (((Form)this).context == null) {
4485 XplatUI.EnableWindow(window.Handle, Enabled);
4488 XplatUI.EnableWindow(window.Handle, Enabled);
4493 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4497 for (int i=0; i<child_controls.Count; i++) {
4498 child_controls[i].OnParentEnabledChanged(e);
4502 [EditorBrowsable(EditorBrowsableState.Advanced)]
4503 protected virtual void OnEnter(EventArgs e) {
4504 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4509 [EditorBrowsable(EditorBrowsableState.Advanced)]
4510 protected virtual void OnFontChanged(EventArgs e) {
4511 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4514 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4517 [EditorBrowsable(EditorBrowsableState.Advanced)]
4518 protected virtual void OnForeColorChanged(EventArgs e) {
4519 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4522 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4525 [EditorBrowsable(EditorBrowsableState.Advanced)]
4526 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4527 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4529 eh (this, gfbevent);
4532 [EditorBrowsable(EditorBrowsableState.Advanced)]
4533 protected virtual void OnGotFocus(EventArgs e) {
4534 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4539 [EditorBrowsable(EditorBrowsableState.Advanced)]
4540 protected virtual void OnHandleCreated(EventArgs e) {
4541 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4546 [EditorBrowsable(EditorBrowsableState.Advanced)]
4547 protected virtual void OnHandleDestroyed(EventArgs e) {
4548 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4553 [EditorBrowsable(EditorBrowsableState.Advanced)]
4554 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4555 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4560 protected virtual void OnImeModeChanged(EventArgs e) {
4561 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4566 [EditorBrowsable(EditorBrowsableState.Advanced)]
4567 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4568 if (ThemeEngine.Current.DoubleBufferingSupported)
4569 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4570 // should this block be here? seems like it
4571 // would be more at home in
4572 // NotifyInvalidated..
4573 if (e.InvalidRect == ClientRectangle) {
4574 InvalidateBackBuffer ();
4577 // we need this Inflate call here so
4578 // that the border of the rectangle is
4579 // considered Visible (the
4580 // invalid_region.IsVisible call) in
4581 // the WM_PAINT handling below.
4582 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4583 if (invalid_region == null)
4584 invalid_region = new Region (r);
4586 invalid_region.Union (r);
4590 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4595 [EditorBrowsable(EditorBrowsableState.Advanced)]
4596 protected virtual void OnKeyDown(KeyEventArgs e) {
4597 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4602 [EditorBrowsable(EditorBrowsableState.Advanced)]
4603 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4604 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4609 [EditorBrowsable(EditorBrowsableState.Advanced)]
4610 protected virtual void OnKeyUp(KeyEventArgs e) {
4611 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4616 [EditorBrowsable(EditorBrowsableState.Advanced)]
4617 protected virtual void OnLayout(LayoutEventArgs levent) {
4618 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4623 [EditorBrowsable(EditorBrowsableState.Advanced)]
4624 protected virtual void OnLeave(EventArgs e) {
4625 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4630 [EditorBrowsable(EditorBrowsableState.Advanced)]
4631 protected virtual void OnLocationChanged(EventArgs e) {
4633 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4638 [EditorBrowsable(EditorBrowsableState.Advanced)]
4639 protected virtual void OnLostFocus(EventArgs e) {
4640 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4645 [EditorBrowsable(EditorBrowsableState.Advanced)]
4646 protected virtual void OnMouseDown(MouseEventArgs e) {
4647 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4652 [EditorBrowsable(EditorBrowsableState.Advanced)]
4653 protected virtual void OnMouseEnter(EventArgs e) {
4654 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4659 [EditorBrowsable(EditorBrowsableState.Advanced)]
4660 protected virtual void OnMouseHover(EventArgs e) {
4661 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4666 [EditorBrowsable(EditorBrowsableState.Advanced)]
4667 protected virtual void OnMouseLeave(EventArgs e) {
4668 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4673 [EditorBrowsable(EditorBrowsableState.Advanced)]
4674 protected virtual void OnMouseMove(MouseEventArgs e) {
4675 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4680 [EditorBrowsable(EditorBrowsableState.Advanced)]
4681 protected virtual void OnMouseUp(MouseEventArgs e) {
4682 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4687 [EditorBrowsable(EditorBrowsableState.Advanced)]
4688 protected virtual void OnMouseWheel(MouseEventArgs e) {
4689 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4694 [EditorBrowsable(EditorBrowsableState.Advanced)]
4695 protected virtual void OnMove(EventArgs e) {
4696 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4701 [EditorBrowsable(EditorBrowsableState.Advanced)]
4702 protected virtual void OnNotifyMessage(Message m) {
4706 [EditorBrowsable(EditorBrowsableState.Advanced)]
4707 protected virtual void OnPaint(PaintEventArgs e) {
4708 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4713 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4717 internal virtual void OnPaintInternal(PaintEventArgs e) {
4721 internal virtual void OnGotFocusInternal (EventArgs e)
4726 internal virtual void OnLostFocusInternal (EventArgs e)
4731 [EditorBrowsable(EditorBrowsableState.Advanced)]
4732 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4733 PaintControlBackground (pevent);
4736 [EditorBrowsable(EditorBrowsableState.Advanced)]
4737 protected virtual void OnParentBackColorChanged(EventArgs e) {
4738 if (background_color.IsEmpty && background_image==null) {
4740 OnBackColorChanged(e);
4744 [EditorBrowsable(EditorBrowsableState.Advanced)]
4745 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4746 if (background_color.IsEmpty && background_image==null) {
4748 OnBackgroundImageChanged(e);
4752 [EditorBrowsable(EditorBrowsableState.Advanced)]
4753 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4754 if (binding_context==null) {
4755 binding_context=Parent.binding_context;
4756 OnBindingContextChanged(e);
4760 [EditorBrowsable(EditorBrowsableState.Advanced)]
4761 protected virtual void OnParentChanged(EventArgs e) {
4762 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4767 [EditorBrowsable(EditorBrowsableState.Advanced)]
4768 protected virtual void OnParentEnabledChanged(EventArgs e) {
4770 OnEnabledChanged(e);
4774 [EditorBrowsable(EditorBrowsableState.Advanced)]
4775 protected virtual void OnParentFontChanged(EventArgs e) {
4782 [EditorBrowsable(EditorBrowsableState.Advanced)]
4783 protected virtual void OnParentForeColorChanged(EventArgs e) {
4784 if (foreground_color.IsEmpty) {
4786 OnForeColorChanged(e);
4790 [EditorBrowsable(EditorBrowsableState.Advanced)]
4791 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4792 if (right_to_left==RightToLeft.Inherit) {
4794 OnRightToLeftChanged(e);
4798 [EditorBrowsable(EditorBrowsableState.Advanced)]
4799 protected virtual void OnParentVisibleChanged(EventArgs e) {
4801 OnVisibleChanged(e);
4805 [EditorBrowsable(EditorBrowsableState.Advanced)]
4806 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4807 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4812 [EditorBrowsable(EditorBrowsableState.Advanced)]
4813 protected virtual void OnResize(EventArgs e) {
4814 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4818 PerformLayout(this, "bounds");
4820 if (parent != null) {
4821 parent.PerformLayout();
4825 [EditorBrowsable(EditorBrowsableState.Advanced)]
4826 protected virtual void OnRightToLeftChanged(EventArgs e) {
4827 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4830 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4833 [EditorBrowsable(EditorBrowsableState.Advanced)]
4834 protected virtual void OnSizeChanged(EventArgs e) {
4835 DisposeBackBuffer ();
4837 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4842 [EditorBrowsable(EditorBrowsableState.Advanced)]
4843 protected virtual void OnStyleChanged(EventArgs e) {
4844 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4849 [EditorBrowsable(EditorBrowsableState.Advanced)]
4850 protected virtual void OnSystemColorsChanged(EventArgs e) {
4851 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4856 [EditorBrowsable(EditorBrowsableState.Advanced)]
4857 protected virtual void OnTabIndexChanged(EventArgs e) {
4858 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4863 [EditorBrowsable(EditorBrowsableState.Advanced)]
4864 protected virtual void OnTabStopChanged(EventArgs e) {
4865 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4870 [EditorBrowsable(EditorBrowsableState.Advanced)]
4871 protected virtual void OnTextChanged(EventArgs e) {
4872 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4877 [EditorBrowsable(EditorBrowsableState.Advanced)]
4878 protected virtual void OnValidated(EventArgs e) {
4879 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4884 [EditorBrowsable(EditorBrowsableState.Advanced)]
4885 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4886 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4891 [EditorBrowsable(EditorBrowsableState.Advanced)]
4892 protected virtual void OnVisibleChanged(EventArgs e) {
4893 if ((parent != null) && !Created && Visible) {
4900 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4904 // We need to tell our kids
4905 for (int i=0; i<child_controls.Count; i++) {
4906 if (child_controls[i].Visible) {
4907 child_controls[i].OnParentVisibleChanged(e);
4911 #endregion // OnXXX methods
4914 static object BackColorChangedEvent = new object ();
4915 static object BackgroundImageChangedEvent = new object ();
4916 static object BindingContextChangedEvent = new object ();
4917 static object CausesValidationChangedEvent = new object ();
4918 static object ChangeUICuesEvent = new object ();
4919 static object ClickEvent = new object ();
4920 static object ContextMenuChangedEvent = new object ();
4921 static object ControlAddedEvent = new object ();
4922 static object ControlRemovedEvent = new object ();
4923 static object CursorChangedEvent = new object ();
4924 static object DockChangedEvent = new object ();
4925 static object DoubleClickEvent = new object ();
4926 static object DragDropEvent = new object ();
4927 static object DragEnterEvent = new object ();
4928 static object DragLeaveEvent = new object ();
4929 static object DragOverEvent = new object ();
4930 static object EnabledChangedEvent = new object ();
4931 static object EnterEvent = new object ();
4932 static object FontChangedEvent = new object ();
4933 static object ForeColorChangedEvent = new object ();
4934 static object GiveFeedbackEvent = new object ();
4935 static object GotFocusEvent = new object ();
4936 static object HandleCreatedEvent = new object ();
4937 static object HandleDestroyedEvent = new object ();
4938 static object HelpRequestedEvent = new object ();
4939 static object ImeModeChangedEvent = new object ();
4940 static object InvalidatedEvent = new object ();
4941 static object KeyDownEvent = new object ();
4942 static object KeyPressEvent = new object ();
4943 static object KeyUpEvent = new object ();
4944 static object LayoutEvent = new object ();
4945 static object LeaveEvent = new object ();
4946 static object LocationChangedEvent = new object ();
4947 static object LostFocusEvent = new object ();
4948 static object MouseDownEvent = new object ();
4949 static object MouseEnterEvent = new object ();
4950 static object MouseHoverEvent = new object ();
4951 static object MouseLeaveEvent = new object ();
4952 static object MouseMoveEvent = new object ();
4953 static object MouseUpEvent = new object ();
4954 static object MouseWheelEvent = new object ();
4955 static object MoveEvent = new object ();
4956 static object PaintEvent = new object ();
4957 static object ParentChangedEvent = new object ();
4958 static object QueryAccessibilityHelpEvent = new object ();
4959 static object QueryContinueDragEvent = new object ();
4960 static object ResizeEvent = new object ();
4961 static object RightToLeftChangedEvent = new object ();
4962 static object SizeChangedEvent = new object ();
4963 static object StyleChangedEvent = new object ();
4964 static object SystemColorsChangedEvent = new object ();
4965 static object TabIndexChangedEvent = new object ();
4966 static object TabStopChangedEvent = new object ();
4967 static object TextChangedEvent = new object ();
4968 static object ValidatedEvent = new object ();
4969 static object ValidatingEvent = new object ();
4970 static object VisibleChangedEvent = new object ();
4972 public event EventHandler BackColorChanged {
4973 add { Events.AddHandler (BackColorChangedEvent, value); }
4974 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4977 public event EventHandler BackgroundImageChanged {
4978 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4979 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4982 public event EventHandler BindingContextChanged {
4983 add { Events.AddHandler (BindingContextChangedEvent, value); }
4984 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4987 public event EventHandler CausesValidationChanged {
4988 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4989 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4992 public event UICuesEventHandler ChangeUICues {
4993 add { Events.AddHandler (ChangeUICuesEvent, value); }
4994 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4997 public event EventHandler Click {
4998 add { Events.AddHandler (ClickEvent, value); }
4999 remove { Events.RemoveHandler (ClickEvent, value); }
5002 public event EventHandler ContextMenuChanged {
5003 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5004 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5007 [EditorBrowsable(EditorBrowsableState.Advanced)]
5009 public event ControlEventHandler ControlAdded {
5010 add { Events.AddHandler (ControlAddedEvent, value); }
5011 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5014 [EditorBrowsable(EditorBrowsableState.Advanced)]
5016 public event ControlEventHandler ControlRemoved {
5017 add { Events.AddHandler (ControlRemovedEvent, value); }
5018 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5021 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5022 public event EventHandler CursorChanged {
5023 add { Events.AddHandler (CursorChangedEvent, value); }
5024 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5026 public event EventHandler DockChanged {
5027 add { Events.AddHandler (DockChangedEvent, value); }
5028 remove { Events.RemoveHandler (DockChangedEvent, value); }
5031 public event EventHandler DoubleClick {
5032 add { Events.AddHandler (DoubleClickEvent, value); }
5033 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5036 public event DragEventHandler DragDrop {
5037 add { Events.AddHandler (DragDropEvent, value); }
5038 remove { Events.RemoveHandler (DragDropEvent, value); }
5041 public event DragEventHandler DragEnter {
5042 add { Events.AddHandler (DragEnterEvent, value); }
5043 remove { Events.RemoveHandler (DragEnterEvent, value); }
5046 public event EventHandler DragLeave {
5047 add { Events.AddHandler (DragLeaveEvent, value); }
5048 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5051 public event DragEventHandler DragOver {
5052 add { Events.AddHandler (DragOverEvent, value); }
5053 remove { Events.RemoveHandler (DragOverEvent, value); }
5056 public event EventHandler EnabledChanged {
5057 add { Events.AddHandler (EnabledChangedEvent, value); }
5058 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5061 public event EventHandler Enter {
5062 add { Events.AddHandler (EnterEvent, value); }
5063 remove { Events.RemoveHandler (EnterEvent, value); }
5066 public event EventHandler FontChanged {
5067 add { Events.AddHandler (FontChangedEvent, value); }
5068 remove { Events.RemoveHandler (FontChangedEvent, value); }
5071 public event EventHandler ForeColorChanged {
5072 add { Events.AddHandler (ForeColorChangedEvent, value); }
5073 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5076 public event GiveFeedbackEventHandler GiveFeedback {
5077 add { Events.AddHandler (GiveFeedbackEvent, value); }
5078 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5081 [EditorBrowsable(EditorBrowsableState.Advanced)]
5083 public event EventHandler GotFocus {
5084 add { Events.AddHandler (GotFocusEvent, value); }
5085 remove { Events.RemoveHandler (GotFocusEvent, value); }
5089 [EditorBrowsable(EditorBrowsableState.Advanced)]
5091 public event EventHandler HandleCreated {
5092 add { Events.AddHandler (HandleCreatedEvent, value); }
5093 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5096 [EditorBrowsable(EditorBrowsableState.Advanced)]
5098 public event EventHandler HandleDestroyed {
5099 add { Events.AddHandler (HandleDestroyedEvent, value); }
5100 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5103 public event HelpEventHandler HelpRequested {
5104 add { Events.AddHandler (HelpRequestedEvent, value); }
5105 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5108 public event EventHandler ImeModeChanged {
5109 add { Events.AddHandler (ImeModeChangedEvent, value); }
5110 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5113 [EditorBrowsable(EditorBrowsableState.Advanced)]
5115 public event InvalidateEventHandler Invalidated {
5116 add { Events.AddHandler (InvalidatedEvent, value); }
5117 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5120 public event KeyEventHandler KeyDown {
5121 add { Events.AddHandler (KeyDownEvent, value); }
5122 remove { Events.RemoveHandler (KeyDownEvent, value); }
5125 public event KeyPressEventHandler KeyPress {
5126 add { Events.AddHandler (KeyPressEvent, value); }
5127 remove { Events.RemoveHandler (KeyPressEvent, value); }
5130 public event KeyEventHandler KeyUp {
5131 add { Events.AddHandler (KeyUpEvent, value); }
5132 remove { Events.RemoveHandler (KeyUpEvent, value); }
5135 public event LayoutEventHandler Layout {
5136 add { Events.AddHandler (LayoutEvent, value); }
5137 remove { Events.RemoveHandler (LayoutEvent, value); }
5140 public event EventHandler Leave {
5141 add { Events.AddHandler (LeaveEvent, value); }
5142 remove { Events.RemoveHandler (LeaveEvent, value); }
5145 public event EventHandler LocationChanged {
5146 add { Events.AddHandler (LocationChangedEvent, value); }
5147 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5150 [EditorBrowsable(EditorBrowsableState.Advanced)]
5152 public event EventHandler LostFocus {
5153 add { Events.AddHandler (LostFocusEvent, value); }
5154 remove { Events.RemoveHandler (LostFocusEvent, value); }
5157 public event MouseEventHandler MouseDown {
5158 add { Events.AddHandler (MouseDownEvent, value); }
5159 remove { Events.RemoveHandler (MouseDownEvent, value); }
5162 public event EventHandler MouseEnter {
5163 add { Events.AddHandler (MouseEnterEvent, value); }
5164 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5167 public event EventHandler MouseHover {
5168 add { Events.AddHandler (MouseHoverEvent, value); }
5169 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5172 public event EventHandler MouseLeave {
5173 add { Events.AddHandler (MouseLeaveEvent, value); }
5174 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5177 public event MouseEventHandler MouseMove {
5178 add { Events.AddHandler (MouseMoveEvent, value); }
5179 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5182 public event MouseEventHandler MouseUp {
5183 add { Events.AddHandler (MouseUpEvent, value); }
5184 remove { Events.RemoveHandler (MouseUpEvent, value); }
5187 [EditorBrowsable(EditorBrowsableState.Advanced)]
5189 public event MouseEventHandler MouseWheel {
5190 add { Events.AddHandler (MouseWheelEvent, value); }
5191 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5194 public event EventHandler Move {
5195 add { Events.AddHandler (MoveEvent, value); }
5196 remove { Events.RemoveHandler (MoveEvent, value); }
5199 public event PaintEventHandler Paint {
5200 add { Events.AddHandler (PaintEvent, value); }
5201 remove { Events.RemoveHandler (PaintEvent, value); }
5204 public event EventHandler ParentChanged {
5205 add { Events.AddHandler (ParentChangedEvent, value); }
5206 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5209 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5210 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5211 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5214 public event QueryContinueDragEventHandler QueryContinueDrag {
5215 add { Events.AddHandler (QueryContinueDragEvent, value); }
5216 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5219 public event EventHandler Resize {
5220 add { Events.AddHandler (ResizeEvent, value); }
5221 remove { Events.RemoveHandler (ResizeEvent, value); }
5224 public event EventHandler RightToLeftChanged {
5225 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5226 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5229 public event EventHandler SizeChanged {
5230 add { Events.AddHandler (SizeChangedEvent, value); }
5231 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5234 public event EventHandler StyleChanged {
5235 add { Events.AddHandler (StyleChangedEvent, value); }
5236 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5239 public event EventHandler SystemColorsChanged {
5240 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5241 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5244 public event EventHandler TabIndexChanged {
5245 add { Events.AddHandler (TabIndexChangedEvent, value); }
5246 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5249 public event EventHandler TabStopChanged {
5250 add { Events.AddHandler (TabStopChangedEvent, value); }
5251 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5254 public event EventHandler TextChanged {
5255 add { Events.AddHandler (TextChangedEvent, value); }
5256 remove { Events.RemoveHandler (TextChangedEvent, value); }
5259 public event EventHandler Validated {
5260 add { Events.AddHandler (ValidatedEvent, value); }
5261 remove { Events.RemoveHandler (ValidatedEvent, value); }
5264 public event CancelEventHandler Validating {
5265 add { Events.AddHandler (ValidatingEvent, value); }
5266 remove { Events.RemoveHandler (ValidatingEvent, value); }
5269 public event EventHandler VisibleChanged {
5270 add { Events.AddHandler (VisibleChangedEvent, value); }
5271 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5274 #endregion // Events