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 && IsHandleCreated) {
2337 XplatUI.SetClipRegion(Handle, value);
2339 clip_region = value;
2343 [EditorBrowsable(EditorBrowsableState.Advanced)]
2345 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2348 return this.bounds.X+this.bounds.Width;
2352 [AmbientValue(RightToLeft.Inherit)]
2354 [MWFCategory("Appearance")]
2355 public virtual RightToLeft RightToLeft {
2357 if (right_to_left == RightToLeft.Inherit) {
2359 return parent.RightToLeft;
2361 return RightToLeft.No; // default value
2363 return right_to_left;
2367 if (value != right_to_left) {
2368 right_to_left = value;
2369 OnRightToLeftChanged(EventArgs.Empty);
2374 [EditorBrowsable(EditorBrowsableState.Advanced)]
2375 public override ISite Site {
2383 if (value != null) {
2384 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2386 BackColor = ap.BackColor;
2387 ForeColor = ap.ForeColor;
2396 [MWFCategory("Layout")]
2399 return new Size(Width, Height);
2403 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2408 [MergableProperty(false)]
2409 [MWFCategory("Behavior")]
2410 public int TabIndex {
2412 if (tab_index != -1) {
2419 if (tab_index != value) {
2421 OnTabIndexChanged(EventArgs.Empty);
2427 [DefaultValue(true)]
2428 [MWFCategory("Behavior")]
2429 public bool TabStop {
2435 if (tab_stop != value) {
2437 OnTabStopChanged(EventArgs.Empty);
2442 [Localizable(false)]
2444 [TypeConverter(typeof(StringConverter))]
2445 [DefaultValue(null)]
2446 [MWFCategory("Data")]
2453 control_tag = value;
2459 [BindableAttribute(true)]
2460 [MWFCategory("Appearance")]
2461 public virtual string Text {
2463 // Our implementation ignores ControlStyles.CacheText - we always cache
2468 if (value == null) {
2469 value = String.Empty;
2474 if (IsHandleCreated) {
2475 /* we need to call .SetWindowStyle here instead of just .Text
2476 because the presence/absence of Text (== "" or not) can cause
2477 other window style things to appear/disappear */
2478 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2479 XplatUI.Text(Handle, text);
2481 OnTextChanged (EventArgs.Empty);
2486 [EditorBrowsable(EditorBrowsableState.Always)]
2488 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2491 return this.bounds.Y;
2495 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2499 [EditorBrowsable(EditorBrowsableState.Advanced)]
2501 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2502 public Control TopLevelControl {
2506 while (p.parent != null) {
2510 return p is Form ? p : null;
2515 [MWFCategory("Behavior")]
2516 public bool Visible {
2520 } else if (parent != null) {
2521 return parent.Visible;
2528 SetVisibleCore(value);
2532 [EditorBrowsable(EditorBrowsableState.Always)]
2534 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2537 return this.bounds.Width;
2541 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2545 [EditorBrowsable(EditorBrowsableState.Never)]
2547 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2548 public IWindowTarget WindowTarget {
2557 #endregion // Public Instance Properties
2559 #region Protected Instance Properties
2560 protected virtual CreateParams CreateParams {
2562 CreateParams create_params = new CreateParams();
2565 create_params.Caption = Text;
2568 create_params.Caption = text;
2572 create_params.X = Left;
2575 create_params.X = this.bounds.X;
2579 create_params.Y = Top;
2582 create_params.Y = this.bounds.Y;
2586 create_params.Width = Width;
2589 create_params.Width = this.bounds.Width;
2593 create_params.Height = Height;
2596 create_params.Height = this.bounds.Height;
2600 create_params.ClassName = XplatUI.DefaultClassName;
2601 create_params.ClassStyle = 0;
2602 create_params.ExStyle = 0;
2603 create_params.Param = 0;
2606 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2609 if ((parent!=null) && (parent.IsHandleCreated)) {
2610 create_params.Parent = parent.Handle;
2613 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2616 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2620 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2623 switch (border_style) {
2624 case BorderStyle.FixedSingle:
2625 create_params.Style |= (int) WindowStyles.WS_BORDER;
2627 case BorderStyle.Fixed3D:
2628 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2632 return create_params;
2636 protected virtual ImeMode DefaultImeMode {
2638 return ImeMode.Inherit;
2643 protected virtual Padding DefaultMargin {
2644 get { return new Padding (3); }
2648 protected virtual Size DefaultSize {
2650 return new Size(0, 0);
2654 protected int FontHeight {
2664 protected bool RenderRightToLeft {
2666 return (this.right_to_left == RightToLeft.Yes);
2670 protected bool ResizeRedraw {
2672 return GetStyle(ControlStyles.ResizeRedraw);
2676 SetStyle(ControlStyles.ResizeRedraw, value);
2680 [EditorBrowsable(EditorBrowsableState.Advanced)]
2682 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2683 protected virtual bool ShowFocusCues {
2689 [EditorBrowsable(EditorBrowsableState.Advanced)]
2691 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2692 protected bool ShowKeyboardCues {
2697 #endregion // Protected Instance Properties
2699 #region Public Static Methods
2700 [EditorBrowsable(EditorBrowsableState.Advanced)]
2701 public static Control FromChildHandle(IntPtr handle) {
2702 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2705 [EditorBrowsable(EditorBrowsableState.Advanced)]
2706 public static Control FromHandle(IntPtr handle) {
2707 return Control.ControlNativeWindow.ControlFromHandle(handle);
2710 public static bool IsMnemonic(char charCode, string text) {
2713 amp = text.IndexOf('&');
2716 if (amp + 1 < text.Length) {
2717 if (text[amp + 1] != '&') {
2718 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2728 #region Protected Static Methods
2729 [EditorBrowsable(EditorBrowsableState.Advanced)]
2730 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2733 c = Control.FromHandle(hWnd);
2743 #region Public Instance Methods
2744 [EditorBrowsable(EditorBrowsableState.Advanced)]
2745 public IAsyncResult BeginInvoke(Delegate method) {
2746 object [] prms = null;
2747 if (method is EventHandler)
2748 prms = new object [] { this, EventArgs.Empty };
2749 return BeginInvokeInternal(method, prms, false);
2752 [EditorBrowsable(EditorBrowsableState.Advanced)]
2753 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2754 return BeginInvokeInternal (method, args, false);
2757 public void BringToFront() {
2758 if (parent != null) {
2759 parent.child_controls.SetChildIndex(this, 0);
2762 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2766 public bool Contains(Control ctl) {
2767 while (ctl != null) {
2776 public void CreateControl() {
2778 throw new ObjectDisposedException(GetType().FullName.ToString());
2784 if (!IsHandleCreated) {
2792 Control [] controls = child_controls.GetAllControls ();
2793 for (int i=0; i<controls.Length; i++) {
2794 controls [i].CreateControl ();
2797 UpdateChildrenZOrder();
2799 if (binding_context == null) { // seem to be sent whenever it's null?
2800 OnBindingContextChanged(EventArgs.Empty);
2806 public Graphics CreateGraphics() {
2807 if (!IsHandleCreated) {
2808 this.CreateHandle();
2810 return Graphics.FromHwnd(this.window.Handle);
2813 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2814 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2817 [EditorBrowsable(EditorBrowsableState.Advanced)]
2818 public object EndInvoke (IAsyncResult async_result) {
2819 AsyncMethodResult result = (AsyncMethodResult) async_result;
2820 return result.EndInvoke ();
2823 public Form FindForm() {
2836 public bool Focus() {
2837 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2840 is_focusing = false;
2845 public Control GetChildAtPoint(Point pt) {
2846 // Microsoft's version of this function doesn't seem to work, so I can't check
2847 // if we only consider children or also grandchildren, etc.
2848 // I'm gonna say 'children only'
2849 for (int i=0; i<child_controls.Count; i++) {
2850 if (child_controls[i].Bounds.Contains(pt)) {
2851 return child_controls[i];
2857 public IContainerControl GetContainerControl() {
2858 Control current = this;
2860 while (current!=null) {
2861 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2862 return (IContainerControl)current;
2864 current = current.parent;
2869 public Control GetNextControl(Control ctl, bool forward) {
2871 if (!this.Contains(ctl)) {
2876 ctl = FindControlForward(this, ctl);
2879 ctl = FindControlBackward(this, ctl);
2889 public virtual Size GetPreferredSize (Size proposedSize) {
2890 return preferred_size;
2894 public void Hide() {
2895 this.Visible = false;
2898 public void Invalidate() {
2899 Invalidate(ClientRectangle, false);
2902 public void Invalidate(bool invalidateChildren) {
2903 Invalidate(ClientRectangle, invalidateChildren);
2906 public void Invalidate(System.Drawing.Rectangle rc) {
2907 Invalidate(rc, false);
2910 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2911 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2915 NotifyInvalidate(rc);
2917 XplatUI.Invalidate(Handle, rc, false);
2919 if (invalidateChildren) {
2920 Control [] controls = child_controls.GetAllControls ();
2921 for (int i=0; i<controls.Length; i++)
2922 controls [i].Invalidate ();
2924 OnInvalidated(new InvalidateEventArgs(rc));
2927 public void Invalidate(System.Drawing.Region region) {
2928 Invalidate(region, false);
2931 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2932 RectangleF bounds = region.GetBounds (CreateGraphics ());
2933 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2934 invalidateChildren);
2937 public object Invoke (Delegate method) {
2938 object [] prms = null;
2939 if (method is EventHandler)
2940 prms = new object [] { this, EventArgs.Empty };
2942 return Invoke(method, prms);
2945 public object Invoke (Delegate method, object[] args) {
2946 if (!this.InvokeRequired) {
2947 return method.DynamicInvoke(args);
2950 IAsyncResult result = BeginInvoke (method, args);
2951 return EndInvoke(result);
2954 internal object InvokeInternal (Delegate method, bool disposing) {
2955 return InvokeInternal(method, null, disposing);
2958 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2959 if (!this.InvokeRequired) {
2960 return method.DynamicInvoke(args);
2963 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2964 return EndInvoke(result);
2967 [EditorBrowsable(EditorBrowsableState.Advanced)]
2968 public void PerformLayout() {
2969 PerformLayout(null, null);
2973 private void SetImplicitBounds (int x, int y, int width, int height)
2975 Rectangle saved_bounds = explicit_bounds;
2976 SetBounds (x, y, width, height);
2977 explicit_bounds = saved_bounds;
2981 [EditorBrowsable(EditorBrowsableState.Advanced)]
2982 public void PerformLayout(Control affectedControl, string affectedProperty) {
2983 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2985 if (layout_suspended > 0) {
2986 layout_pending = true;
2990 layout_pending = false;
2992 // Prevent us from getting messed up
2995 // Perform all Dock and Anchor calculations
2999 this.layout_engine.Layout(this, levent);
3001 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
3003 AnchorStyles anchor;
3006 space = DisplayRectangle;
3008 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
3009 Control [] controls = child_controls.GetAllControls ();
3010 for (int i = controls.Length - 1; i >= 0; i--) {
3011 child = controls [i];
3013 if (!child.Visible) {
3017 switch (child.Dock) {
3018 case DockStyle.None: {
3023 case DockStyle.Left: {
3024 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3025 space.X+=child.Width;
3026 space.Width-=child.Width;
3030 case DockStyle.Top: {
3031 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3032 space.Y+=child.Height;
3033 space.Height-=child.Height;
3037 case DockStyle.Right: {
3038 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3039 space.Width-=child.Width;
3043 case DockStyle.Bottom: {
3044 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3045 space.Height-=child.Height;
3051 for (int i = controls.Length - 1; i >= 0; i--) {
3054 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3055 if (child.Dock == DockStyle.Fill) {
3056 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3060 space = DisplayRectangle;
3062 for (int i=0; i < controls.Length; i++) {
3068 child = controls[i];
3070 // If the control is docked we don't need to do anything
3071 if (child.Dock != DockStyle.None) {
3075 anchor = child.Anchor;
3079 width = child.Width;
3080 height = child.Height;
3082 if ((anchor & AnchorStyles.Left) !=0 ) {
3083 if ((anchor & AnchorStyles.Right) != 0) {
3084 width = space.Width - child.dist_right - left;
3086 ; // Left anchored only, nothing to be done
3088 } else if ((anchor & AnchorStyles.Right) != 0) {
3089 left = space.Width - child.dist_right - width;
3091 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3092 // This calculates from scratch every time:
3093 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3096 if ((anchor & AnchorStyles.Top) !=0 ) {
3097 if ((anchor & AnchorStyles.Bottom) != 0) {
3098 height = space.Height - child.dist_bottom - top;
3100 ; // Top anchored only, nothing to be done
3102 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3103 top = space.Height - child.dist_bottom - height;
3105 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3106 // This calculates from scratch every time:
3107 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3119 child.SetImplicitBounds(left, top, width, height);
3123 // Let everyone know
3127 // Need to make sure we decremend layout_suspended
3133 public Point PointToClient (Point p) {
3137 XplatUI.ScreenToClient (Handle, ref x, ref y);
3139 return new Point (x, y);
3142 public Point PointToScreen(Point p) {
3146 XplatUI.ClientToScreen(Handle, ref x, ref y);
3148 return new Point(x, y);
3151 public virtual bool PreProcessMessage(ref Message msg) {
3152 return InternalPreProcessMessage (ref msg);
3155 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3158 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3159 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3161 if (!ProcessCmdKey(ref msg, key_data)) {
3162 if (IsInputKey(key_data)) {
3166 return ProcessDialogKey(key_data);
3170 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3171 if (IsInputChar((char)msg.WParam)) {
3174 return ProcessDialogChar((char)msg.WParam);
3175 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3176 return ProcessDialogChar((char)msg.WParam);
3181 public Rectangle RectangleToClient(Rectangle r) {
3182 return new Rectangle(PointToClient(r.Location), r.Size);
3185 public Rectangle RectangleToScreen(Rectangle r) {
3186 return new Rectangle(PointToScreen(r.Location), r.Size);
3189 public virtual void Refresh() {
3190 if (IsHandleCreated == true) {
3192 XplatUI.UpdateWindow(window.Handle);
3194 Control [] controls = child_controls.GetAllControls ();
3195 for (int i=0; i < controls.Length; i++) {
3196 controls[i].Refresh();
3202 [EditorBrowsable(EditorBrowsableState.Never)]
3203 public virtual void ResetBackColor() {
3204 BackColor = Color.Empty;
3207 [EditorBrowsable(EditorBrowsableState.Never)]
3208 public void ResetBindings() {
3209 data_bindings.Clear();
3212 [EditorBrowsable(EditorBrowsableState.Never)]
3213 public virtual void ResetCursor() {
3217 [EditorBrowsable(EditorBrowsableState.Never)]
3218 public virtual void ResetFont() {
3222 [EditorBrowsable(EditorBrowsableState.Never)]
3223 public virtual void ResetForeColor() {
3224 foreground_color = Color.Empty;
3227 [EditorBrowsable(EditorBrowsableState.Never)]
3228 public void ResetImeMode() {
3229 ime_mode = DefaultImeMode;
3232 [EditorBrowsable(EditorBrowsableState.Never)]
3233 public virtual void ResetRightToLeft() {
3234 right_to_left = RightToLeft.Inherit;
3237 public virtual void ResetText() {
3238 text = String.Empty;
3241 public void ResumeLayout() {
3242 ResumeLayout (true);
3245 public void ResumeLayout(bool performLayout) {
3246 if (layout_suspended > 0) {
3250 if (layout_suspended == 0) {
3251 Control [] controls = child_controls.GetAllControls ();
3252 for (int i=0; i<controls.Length; i++) {
3253 controls [i].UpdateDistances ();
3256 if (performLayout && layout_pending) {
3262 public void Scale(float ratio) {
3263 ScaleCore(ratio, ratio);
3266 public void Scale(float dx, float dy) {
3271 public void Scale(SizeF factor) {
3272 ScaleCore(factor.Width, factor.Height);
3276 public void Select() {
3277 Select(false, false);
3281 private void printTree(Control c, string t) {
3282 foreach(Control i in c.child_controls) {
3283 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3284 printTree(i, t+"\t");
3288 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3292 Console.WriteLine("{0}", this.FindForm());
3293 printTree(this, "\t");
3296 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3301 c = GetNextControl(c, forward);
3310 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3311 c.Select (true, true);
3314 } while (c != ctl); // If we wrap back to ourselves we stop
3319 public void SendToBack() {
3320 if (parent != null) {
3321 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3325 public void SetBounds(int x, int y, int width, int height) {
3326 SetBounds(x, y, width, height, BoundsSpecified.All);
3329 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3330 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3334 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3338 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3342 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3346 SetBoundsCore(x, y, width, height, specified);
3347 if (parent != null) {
3348 parent.PerformLayout(this, "Bounds");
3352 public void Show() {
3354 this.CreateControl();
3360 public void SuspendLayout() {
3364 public void Update() {
3365 if (IsHandleCreated) {
3366 XplatUI.UpdateWindow(window.Handle);
3369 #endregion // Public Instance Methods
3371 #region Protected Instance Methods
3372 [EditorBrowsable(EditorBrowsableState.Advanced)]
3373 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3374 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3375 throw new NotImplementedException();
3378 [EditorBrowsable(EditorBrowsableState.Advanced)]
3379 protected virtual AccessibleObject CreateAccessibilityInstance() {
3380 return new Control.ControlAccessibleObject(this);
3383 [EditorBrowsable(EditorBrowsableState.Advanced)]
3384 protected virtual ControlCollection CreateControlsInstance() {
3385 return new ControlCollection(this);
3388 [EditorBrowsable(EditorBrowsableState.Advanced)]
3389 protected virtual void CreateHandle() {
3391 throw new ObjectDisposedException(GetType().FullName.ToString());
3394 if (IsHandleCreated && !is_recreating) {
3398 window.CreateHandle(CreateParams);
3400 if (window.Handle != IntPtr.Zero) {
3401 creator_thread = Thread.CurrentThread;
3403 XplatUI.EnableWindow(window.Handle, is_enabled);
3404 XplatUI.SetVisible(window.Handle, is_visible, true);
3406 if (clip_region != null) {
3407 XplatUI.SetClipRegion(Handle, clip_region);
3410 // Set our handle with our parent
3411 if ((parent != null) && (parent.IsHandleCreated)) {
3412 XplatUI.SetParent(window.Handle, parent.Handle);
3415 // Set our handle as parent for our children
3416 Control [] children;
3418 children = child_controls.GetAllControls ();
3419 for (int i = 0; i < children.Length; i++ ) {
3420 if (!children[i].RecreatingHandle)
3421 XplatUI.SetParent(children[i].Handle, window.Handle);
3425 XplatUI.SetAllowDrop (Handle, allow_drop);
3427 // Find out where the window manager placed us
3428 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3429 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3433 OnHandleCreated(EventArgs.Empty);
3437 [EditorBrowsable(EditorBrowsableState.Advanced)]
3438 protected virtual void DefWndProc(ref Message m) {
3439 window.DefWndProc(ref m);
3442 [EditorBrowsable(EditorBrowsableState.Advanced)]
3443 protected virtual void DestroyHandle() {
3444 if (IsHandleCreated) {
3445 if (window != null) {
3446 window.DestroyHandle();
3451 protected internal bool GetStyle(ControlStyles flag) {
3452 return (control_style & flag) != 0;
3455 protected bool GetTopLevel() {
3459 [EditorBrowsable(EditorBrowsableState.Advanced)]
3460 protected virtual void InitLayout() {
3464 [EditorBrowsable(EditorBrowsableState.Advanced)]
3465 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3466 toInvoke.OnGotFocus(e);
3469 [EditorBrowsable(EditorBrowsableState.Advanced)]
3470 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3471 toInvoke.OnLostFocus(e);
3474 [EditorBrowsable(EditorBrowsableState.Advanced)]
3475 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3476 toInvoke.OnClick(e);
3479 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3480 toInvoke.OnPaint(e);
3483 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3484 toInvoke.OnPaintBackground(e);
3487 protected virtual bool IsInputChar (char charCode) {
3491 protected virtual bool IsInputKey (Keys keyData) {
3492 // Doc says this one calls IsInputChar; not sure what to do with that
3496 [EditorBrowsable(EditorBrowsableState.Advanced)]
3497 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3501 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3502 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3506 if (parent != null) {
3507 return parent.ProcessCmdKey(ref msg, keyData);
3513 protected virtual bool ProcessDialogChar(char charCode) {
3514 if (parent != null) {
3515 return parent.ProcessDialogChar (charCode);
3521 protected virtual bool ProcessDialogKey (Keys keyData) {
3522 if (parent != null) {
3523 return parent.ProcessDialogKey (keyData);
3529 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3531 KeyEventArgs key_event;
3534 case (int)Msg.WM_SYSKEYDOWN:
3535 case (int)Msg.WM_KEYDOWN: {
3536 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3537 OnKeyDown (key_event);
3538 return key_event.Handled;
3541 case (int)Msg.WM_SYSKEYUP:
3542 case (int)Msg.WM_KEYUP: {
3543 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3544 OnKeyUp (key_event);
3545 return key_event.Handled;
3548 case (int)Msg.WM_SYSCHAR:
3549 case (int)Msg.WM_CHAR: {
3550 KeyPressEventArgs key_press_event;
3552 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3553 OnKeyPress(key_press_event);
3555 msg.WParam = (IntPtr)key_press_event.KeyChar;
3557 return key_press_event.Handled;
3568 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3569 if (parent != null) {
3570 if (parent.ProcessKeyPreview(ref msg)) {
3575 return ProcessKeyEventArgs(ref msg);
3578 protected virtual bool ProcessKeyPreview(ref Message msg) {
3579 if (parent != null) {
3580 return parent.ProcessKeyPreview(ref msg);
3586 protected virtual bool ProcessMnemonic(char charCode) {
3591 [EditorBrowsable(EditorBrowsableState.Advanced)]
3592 protected void RaiseDragEvent(object key, DragEventArgs e) {
3596 [EditorBrowsable(EditorBrowsableState.Advanced)]
3597 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3601 [EditorBrowsable(EditorBrowsableState.Advanced)]
3602 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3606 [EditorBrowsable(EditorBrowsableState.Advanced)]
3607 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3611 private void SetIsRecreating ()
3615 foreach (Control c in Controls.GetAllControls()) {
3616 c.SetIsRecreating ();
3620 [EditorBrowsable(EditorBrowsableState.Advanced)]
3621 protected void RecreateHandle() {
3623 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3628 if (IsHandleCreated) {
3630 Console.WriteLine(" + handle is created, destroying it.");
3633 // WM_DESTROY will CreateHandle for us
3636 Console.WriteLine(" + handle is not created, creating it.");
3644 is_recreating = false;
3646 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3652 [EditorBrowsable(EditorBrowsableState.Advanced)]
3653 protected void ResetMouseEventArgs() {
3657 [EditorBrowsable(EditorBrowsableState.Advanced)]
3658 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3659 if (right_to_left == RightToLeft.No) {
3664 case ContentAlignment.TopLeft: {
3665 return ContentAlignment.TopRight;
3668 case ContentAlignment.TopRight: {
3669 return ContentAlignment.TopLeft;
3672 case ContentAlignment.MiddleLeft: {
3673 return ContentAlignment.MiddleRight;
3676 case ContentAlignment.MiddleRight: {
3677 return ContentAlignment.MiddleLeft;
3680 case ContentAlignment.BottomLeft: {
3681 return ContentAlignment.BottomRight;
3684 case ContentAlignment.BottomRight: {
3685 return ContentAlignment.BottomLeft;
3689 // if it's center it doesn't change
3695 [EditorBrowsable(EditorBrowsableState.Advanced)]
3696 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3697 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3701 if (align == HorizontalAlignment.Left) {
3702 return HorizontalAlignment.Right;
3705 // align must be HorizontalAlignment.Right
3706 return HorizontalAlignment.Left;
3709 [EditorBrowsable(EditorBrowsableState.Advanced)]
3710 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3711 if (right_to_left == RightToLeft.No) {
3715 if (align == LeftRightAlignment.Left) {
3716 return LeftRightAlignment.Right;
3719 // align must be LeftRightAlignment.Right;
3720 return LeftRightAlignment.Left;
3723 [EditorBrowsable(EditorBrowsableState.Advanced)]
3724 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3725 return RtlTranslateAlignment(align);
3728 [EditorBrowsable(EditorBrowsableState.Advanced)]
3729 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3730 return RtlTranslateAlignment(align);
3733 [EditorBrowsable(EditorBrowsableState.Advanced)]
3734 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3735 return RtlTranslateAlignment(align);
3738 [EditorBrowsable(EditorBrowsableState.Advanced)]
3739 protected virtual void ScaleCore(float dx, float dy) {
3745 location = new Point((int)(Left * dx), (int)(Top * dy));
3746 size = this.ClientSize;
3748 if (!GetStyle(ControlStyles.FixedWidth)) {
3749 size.Width = (int)(size.Width * dx);
3752 if (!GetStyle(ControlStyles.FixedHeight)) {
3753 size.Height = (int)(size.Height * dy);
3756 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3758 /* Now scale our children */
3759 Control [] controls = child_controls.GetAllControls ();
3760 for (int i=0; i < controls.Length; i++) {
3761 controls[i].Scale(dx, dy);
3767 protected virtual void Select(bool directed, bool forward) {
3768 IContainerControl container;
3770 container = GetContainerControl();
3771 if (container != null)
3772 container.ActiveControl = this;
3775 [EditorBrowsable(EditorBrowsableState.Advanced)]
3776 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3777 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3778 if (IsHandleCreated) {
3779 XplatUI.SetWindowPos(Handle, x, y, width, height);
3781 // Win32 automatically changes negative width/height to 0.
3782 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3783 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3785 if (width < 0 || height < 0) {
3787 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3791 UpdateBounds(x, y, width, height);
3796 [EditorBrowsable(EditorBrowsableState.Advanced)]
3797 protected virtual void SetClientSizeCore(int x, int y) {
3798 // Calculate the actual window size from the client size (it usually stays the same or grows)
3799 Rectangle ClientRect;
3800 Rectangle WindowRect;
3803 ClientRect = new Rectangle(0, 0, x, y);
3804 cp = this.CreateParams;
3806 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3810 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3813 [EditorBrowsable(EditorBrowsableState.Advanced)]
3814 protected internal void SetStyle(ControlStyles flag, bool value) {
3816 control_style |= flag;
3818 control_style &= ~flag;
3822 protected void SetTopLevel(bool value) {
3823 if ((GetTopLevel() != value) && (parent != null)) {
3824 throw new Exception();
3828 if (value == true) {
3838 is_toplevel = value;
3841 protected virtual void SetVisibleCore(bool value) {
3842 if (value!=is_visible) {
3843 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3849 if (IsHandleCreated) {
3850 XplatUI.SetVisible(Handle, value, true);
3851 // Explicitly move Toplevel windows to where we want them;
3852 // apparently moving unmapped toplevel windows doesn't work
3853 if (is_visible && (this is Form)) {
3854 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3858 OnVisibleChanged(EventArgs.Empty);
3860 if (value == false && parent != null && Focused) {
3863 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3864 container = (Control)parent.GetContainerControl();
3865 if (container != null) {
3866 container.SelectNextControl(this, true, true, true, true);
3870 if (parent != null) {
3871 parent.PerformLayout(this, "visible");
3873 PerformLayout(this, "visible");
3878 [EditorBrowsable(EditorBrowsableState.Advanced)]
3879 protected void UpdateBounds() {
3887 if (!IsHandleCreated) {
3891 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3893 UpdateBounds(x, y, width, height, client_width, client_height);
3896 [EditorBrowsable(EditorBrowsableState.Advanced)]
3897 protected void UpdateBounds(int x, int y, int width, int height) {
3901 // Calculate client rectangle
3902 rect = new Rectangle(0, 0, 0, 0);
3905 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3906 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3909 [EditorBrowsable(EditorBrowsableState.Advanced)]
3910 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3911 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3913 bool resized = false;
3915 // Needed to generate required notifications
3916 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3920 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3927 bounds.Height=height;
3929 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3930 explicit_bounds = bounds;
3932 client_size.Width=clientWidth;
3933 client_size.Height=clientHeight;
3936 OnLocationChanged(EventArgs.Empty);
3940 OnSizeChanged(EventArgs.Empty);
3944 [EditorBrowsable(EditorBrowsableState.Advanced)]
3945 protected void UpdateStyles() {
3946 if (!IsHandleCreated) {
3950 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3951 OnStyleChanged(EventArgs.Empty);
3954 private void UpdateZOrderOfChild(Control child) {
3955 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3958 index = child_controls.IndexOf(child);
3961 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3963 IntPtr after = AfterTopMostControl ();
3964 if (after != IntPtr.Zero)
3965 XplatUI.SetZOrder (child.Handle, after, false, false);
3967 XplatUI.SetZOrder (child.Handle, IntPtr.Zero, true, false);
3972 // Override this if there is a control that shall always remain on
3973 // top of other controls (such as scrollbars). If there are several
3974 // of these controls, the bottom-most should be returned.
3975 internal virtual IntPtr AfterTopMostControl ()
3980 private void UpdateChildrenZOrder() {
3981 Control [] controls;
3983 if (!IsHandleCreated) {
3987 controls = child_controls.GetAllControls ();
3988 for (int i = 1; i < controls.Length; i++ ) {
3989 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3993 [EditorBrowsable(EditorBrowsableState.Advanced)]
3994 protected void UpdateZOrder() {
3995 if (parent != null) {
3996 parent.UpdateZOrderOfChild(this);
4000 protected virtual void WndProc(ref Message m) {
4002 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
4004 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
4008 switch((Msg)m.Msg) {
4009 case Msg.WM_DESTROY: {
4010 OnHandleDestroyed(EventArgs.Empty);
4012 IntPtr handle = window.Handle;
4014 window.InvalidateHandle();
4016 if (is_recreating) {
4018 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4022 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4024 is_recreating = false;
4029 case Msg.WM_WINDOWPOSCHANGED: {
4031 Rectangle save_bounds = explicit_bounds;
4033 explicit_bounds = save_bounds;
4034 if (GetStyle(ControlStyles.ResizeRedraw)) {
4041 // Nice description of what should happen when handling WM_PAINT
4042 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4043 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4044 case Msg.WM_PAINT: {
4045 PaintEventArgs paint_event;
4047 paint_event = XplatUI.PaintEventStart(Handle, true);
4049 if (paint_event == null) {
4053 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4055 // Just blit the previous image
4056 XplatUI.BlitFromOffscreen (Handle, paint_event.Graphics, backbuffer, backbuffer_dc, paint_event.ClipRectangle);
4057 XplatUI.PaintEventEnd (Handle, true);
4062 Graphics back_dc = null;
4064 if (ThemeEngine.Current.DoubleBufferingSupported) {
4065 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4066 CreateBackBuffer ();
4068 back_dc = backbuffer_dc;
4069 dc = paint_event.SetGraphics (back_dc);
4073 if (!GetStyle(ControlStyles.Opaque)) {
4074 OnPaintBackground(paint_event);
4077 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4078 OnPaintBackgroundInternal(paint_event);
4080 OnPaintInternal(paint_event);
4081 if (!paint_event.Handled) {
4082 OnPaint(paint_event);
4085 if (ThemeEngine.Current.DoubleBufferingSupported)
4086 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4087 XplatUI.BlitFromOffscreen (Handle, dc, back, back_dc, paint_event.ClipRectangle);
4088 paint_event.SetGraphics (dc);
4089 invalid_region.Exclude (paint_event.ClipRectangle);
4091 if (back != backbuffer)
4092 XplatUI.DestroyOffscreenDrawable (back, back_dc);
4095 XplatUI.PaintEventEnd(Handle, true);
4100 case Msg.WM_ERASEBKGND: {
4101 // The DefWndProc will never have to handle this, we always paint the background in managed code
4102 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4103 // here but it just makes things more complicated...
4104 m.Result = (IntPtr)1;
4108 case Msg.WM_LBUTTONUP: {
4111 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4113 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4116 HandleClick(mouse_clicks, me);
4119 if (InternalCapture) {
4120 InternalCapture = false;
4123 if (mouse_clicks > 1) {
4129 case Msg.WM_LBUTTONDOWN: {
4131 Select (true, true);
4133 InternalCapture = true;
4134 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4135 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4141 case Msg.WM_LBUTTONDBLCLK: {
4142 InternalCapture = true;
4144 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4145 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4150 case Msg.WM_MBUTTONUP: {
4153 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4155 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4158 HandleClick(mouse_clicks, me);
4160 if (InternalCapture) {
4161 InternalCapture = false;
4163 if (mouse_clicks > 1) {
4169 case Msg.WM_MBUTTONDOWN: {
4170 InternalCapture = true;
4171 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4172 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4177 case Msg.WM_MBUTTONDBLCLK: {
4178 InternalCapture = true;
4180 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4181 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4186 case Msg.WM_RBUTTONUP: {
4190 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4191 pt = PointToScreen(pt);
4193 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4195 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4197 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4200 HandleClick(mouse_clicks, me);
4203 if (InternalCapture) {
4204 InternalCapture = false;
4207 if (mouse_clicks > 1) {
4213 case Msg.WM_RBUTTONDOWN: {
4214 InternalCapture = true;
4215 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4216 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4221 case Msg.WM_RBUTTONDBLCLK: {
4222 InternalCapture = true;
4224 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4225 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4230 case Msg.WM_CONTEXTMENU: {
4231 if (context_menu != null) {
4234 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4235 context_menu.Show(this, PointToClient(pt));
4243 case Msg.WM_MOUSEWHEEL: {
4245 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4246 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4247 HighOrder(m.WParam.ToInt32())));
4252 case Msg.WM_MOUSEMOVE: {
4253 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4255 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4260 case Msg.WM_MOUSE_ENTER: {
4265 OnMouseEnter(EventArgs.Empty);
4269 case Msg.WM_MOUSE_LEAVE: {
4271 OnMouseLeave(EventArgs.Empty);
4275 case Msg.WM_MOUSEHOVER: {
4276 OnMouseHover(EventArgs.Empty);
4280 case Msg.WM_SYSKEYUP: {
4281 if (ProcessKeyMessage(ref m)) {
4282 m.Result = IntPtr.Zero;
4286 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4290 if (form != null && form.ActiveMenu != null) {
4291 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4299 case Msg.WM_SYSKEYDOWN:
4300 case Msg.WM_KEYDOWN:
4302 case Msg.WM_SYSCHAR:
4304 if (ProcessKeyMessage(ref m)) {
4305 m.Result = IntPtr.Zero;
4314 if (m.LParam != IntPtr.Zero) {
4317 hi = new HELPINFO();
4319 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4320 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4322 mouse_pos = Control.MousePosition;
4324 OnHelpRequested(new HelpEventArgs(mouse_pos));
4325 m.Result = (IntPtr)1;
4329 case Msg.WM_KILLFOCUS: {
4330 this.has_focus = false;
4331 OnLostFocusInternal (EventArgs.Empty);
4335 case Msg.WM_SETFOCUS: {
4337 this.has_focus = true;
4338 OnGotFocusInternal (EventArgs.Empty);
4343 case Msg.WM_SYSCOLORCHANGE: {
4344 ThemeEngine.Current.ResetDefaults();
4345 OnSystemColorsChanged(EventArgs.Empty);
4349 case Msg.WM_SETCURSOR: {
4350 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4355 XplatUI.SetCursor(window.Handle, cursor.handle);
4356 m.Result = (IntPtr)1;
4366 #endregion // Public Instance Methods
4368 #region OnXXX methods
4369 [EditorBrowsable(EditorBrowsableState.Advanced)]
4370 protected virtual void OnBackColorChanged(EventArgs e) {
4371 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4374 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4377 [EditorBrowsable(EditorBrowsableState.Advanced)]
4378 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4379 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4382 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4385 [EditorBrowsable(EditorBrowsableState.Advanced)]
4386 protected virtual void OnBindingContextChanged(EventArgs e) {
4387 CheckDataBindings ();
4388 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4391 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4394 [EditorBrowsable(EditorBrowsableState.Advanced)]
4395 protected virtual void OnCausesValidationChanged(EventArgs e) {
4396 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4401 [EditorBrowsable(EditorBrowsableState.Advanced)]
4402 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4403 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4408 [EditorBrowsable(EditorBrowsableState.Advanced)]
4409 protected virtual void OnClick(EventArgs e) {
4410 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4415 [EditorBrowsable(EditorBrowsableState.Advanced)]
4416 protected virtual void OnContextMenuChanged(EventArgs e) {
4417 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4422 [EditorBrowsable(EditorBrowsableState.Advanced)]
4423 protected virtual void OnControlAdded(ControlEventArgs e) {
4424 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4429 [EditorBrowsable(EditorBrowsableState.Advanced)]
4430 protected virtual void OnControlRemoved(ControlEventArgs e) {
4431 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4436 [EditorBrowsable(EditorBrowsableState.Advanced)]
4437 protected virtual void OnCreateControl() {
4441 [EditorBrowsable(EditorBrowsableState.Advanced)]
4442 protected virtual void OnCursorChanged(EventArgs e) {
4443 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4448 [EditorBrowsable(EditorBrowsableState.Advanced)]
4449 protected virtual void OnDockChanged(EventArgs e) {
4450 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4455 [EditorBrowsable(EditorBrowsableState.Advanced)]
4456 protected virtual void OnDoubleClick(EventArgs e) {
4457 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4462 [EditorBrowsable(EditorBrowsableState.Advanced)]
4463 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4464 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4466 eh (this, drgevent);
4469 [EditorBrowsable(EditorBrowsableState.Advanced)]
4470 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4471 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4473 eh (this, drgevent);
4476 [EditorBrowsable(EditorBrowsableState.Advanced)]
4477 protected virtual void OnDragLeave(EventArgs e) {
4478 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4483 [EditorBrowsable(EditorBrowsableState.Advanced)]
4484 protected virtual void OnDragOver(DragEventArgs drgevent) {
4485 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4487 eh (this, drgevent);
4490 [EditorBrowsable(EditorBrowsableState.Advanced)]
4491 protected virtual void OnEnabledChanged(EventArgs e) {
4492 if (IsHandleCreated) {
4494 if (((Form)this).context == null) {
4495 XplatUI.EnableWindow(window.Handle, Enabled);
4498 XplatUI.EnableWindow(window.Handle, Enabled);
4503 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4507 for (int i=0; i<child_controls.Count; i++) {
4508 child_controls[i].OnParentEnabledChanged(e);
4512 [EditorBrowsable(EditorBrowsableState.Advanced)]
4513 protected virtual void OnEnter(EventArgs e) {
4514 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4519 [EditorBrowsable(EditorBrowsableState.Advanced)]
4520 protected virtual void OnFontChanged(EventArgs e) {
4521 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4524 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4527 [EditorBrowsable(EditorBrowsableState.Advanced)]
4528 protected virtual void OnForeColorChanged(EventArgs e) {
4529 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4532 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4535 [EditorBrowsable(EditorBrowsableState.Advanced)]
4536 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4537 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4539 eh (this, gfbevent);
4542 [EditorBrowsable(EditorBrowsableState.Advanced)]
4543 protected virtual void OnGotFocus(EventArgs e) {
4544 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4549 [EditorBrowsable(EditorBrowsableState.Advanced)]
4550 protected virtual void OnHandleCreated(EventArgs e) {
4551 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4556 [EditorBrowsable(EditorBrowsableState.Advanced)]
4557 protected virtual void OnHandleDestroyed(EventArgs e) {
4558 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4563 [EditorBrowsable(EditorBrowsableState.Advanced)]
4564 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4565 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4570 protected virtual void OnImeModeChanged(EventArgs e) {
4571 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4576 [EditorBrowsable(EditorBrowsableState.Advanced)]
4577 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4578 if (ThemeEngine.Current.DoubleBufferingSupported)
4579 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4580 // should this block be here? seems like it
4581 // would be more at home in
4582 // NotifyInvalidated..
4583 if (e.InvalidRect == ClientRectangle) {
4584 InvalidateBackBuffer ();
4587 // we need this Inflate call here so
4588 // that the border of the rectangle is
4589 // considered Visible (the
4590 // invalid_region.IsVisible call) in
4591 // the WM_PAINT handling below.
4592 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4593 if (invalid_region == null)
4594 invalid_region = new Region (r);
4596 invalid_region.Union (r);
4600 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4605 [EditorBrowsable(EditorBrowsableState.Advanced)]
4606 protected virtual void OnKeyDown(KeyEventArgs e) {
4607 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4612 [EditorBrowsable(EditorBrowsableState.Advanced)]
4613 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4614 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4619 [EditorBrowsable(EditorBrowsableState.Advanced)]
4620 protected virtual void OnKeyUp(KeyEventArgs e) {
4621 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4626 [EditorBrowsable(EditorBrowsableState.Advanced)]
4627 protected virtual void OnLayout(LayoutEventArgs levent) {
4628 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4633 [EditorBrowsable(EditorBrowsableState.Advanced)]
4634 protected virtual void OnLeave(EventArgs e) {
4635 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4640 [EditorBrowsable(EditorBrowsableState.Advanced)]
4641 protected virtual void OnLocationChanged(EventArgs e) {
4643 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4648 [EditorBrowsable(EditorBrowsableState.Advanced)]
4649 protected virtual void OnLostFocus(EventArgs e) {
4650 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4655 [EditorBrowsable(EditorBrowsableState.Advanced)]
4656 protected virtual void OnMouseDown(MouseEventArgs e) {
4657 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4662 [EditorBrowsable(EditorBrowsableState.Advanced)]
4663 protected virtual void OnMouseEnter(EventArgs e) {
4664 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4669 [EditorBrowsable(EditorBrowsableState.Advanced)]
4670 protected virtual void OnMouseHover(EventArgs e) {
4671 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4676 [EditorBrowsable(EditorBrowsableState.Advanced)]
4677 protected virtual void OnMouseLeave(EventArgs e) {
4678 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4683 [EditorBrowsable(EditorBrowsableState.Advanced)]
4684 protected virtual void OnMouseMove(MouseEventArgs e) {
4685 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4690 [EditorBrowsable(EditorBrowsableState.Advanced)]
4691 protected virtual void OnMouseUp(MouseEventArgs e) {
4692 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4697 [EditorBrowsable(EditorBrowsableState.Advanced)]
4698 protected virtual void OnMouseWheel(MouseEventArgs e) {
4699 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4704 [EditorBrowsable(EditorBrowsableState.Advanced)]
4705 protected virtual void OnMove(EventArgs e) {
4706 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4711 [EditorBrowsable(EditorBrowsableState.Advanced)]
4712 protected virtual void OnNotifyMessage(Message m) {
4716 [EditorBrowsable(EditorBrowsableState.Advanced)]
4717 protected virtual void OnPaint(PaintEventArgs e) {
4718 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4723 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4727 internal virtual void OnPaintInternal(PaintEventArgs e) {
4731 internal virtual void OnGotFocusInternal (EventArgs e)
4736 internal virtual void OnLostFocusInternal (EventArgs e)
4741 [EditorBrowsable(EditorBrowsableState.Advanced)]
4742 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4743 PaintControlBackground (pevent);
4746 [EditorBrowsable(EditorBrowsableState.Advanced)]
4747 protected virtual void OnParentBackColorChanged(EventArgs e) {
4748 if (background_color.IsEmpty && background_image==null) {
4750 OnBackColorChanged(e);
4754 [EditorBrowsable(EditorBrowsableState.Advanced)]
4755 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4756 if (background_color.IsEmpty && background_image==null) {
4758 OnBackgroundImageChanged(e);
4762 [EditorBrowsable(EditorBrowsableState.Advanced)]
4763 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4764 if (binding_context==null) {
4765 binding_context=Parent.binding_context;
4766 OnBindingContextChanged(e);
4770 [EditorBrowsable(EditorBrowsableState.Advanced)]
4771 protected virtual void OnParentChanged(EventArgs e) {
4772 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4777 [EditorBrowsable(EditorBrowsableState.Advanced)]
4778 protected virtual void OnParentEnabledChanged(EventArgs e) {
4780 OnEnabledChanged(e);
4784 [EditorBrowsable(EditorBrowsableState.Advanced)]
4785 protected virtual void OnParentFontChanged(EventArgs e) {
4792 [EditorBrowsable(EditorBrowsableState.Advanced)]
4793 protected virtual void OnParentForeColorChanged(EventArgs e) {
4794 if (foreground_color.IsEmpty) {
4796 OnForeColorChanged(e);
4800 [EditorBrowsable(EditorBrowsableState.Advanced)]
4801 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4802 if (right_to_left==RightToLeft.Inherit) {
4804 OnRightToLeftChanged(e);
4808 [EditorBrowsable(EditorBrowsableState.Advanced)]
4809 protected virtual void OnParentVisibleChanged(EventArgs e) {
4811 OnVisibleChanged(e);
4815 [EditorBrowsable(EditorBrowsableState.Advanced)]
4816 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4817 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4822 [EditorBrowsable(EditorBrowsableState.Advanced)]
4823 protected virtual void OnResize(EventArgs e) {
4824 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4828 PerformLayout(this, "bounds");
4830 if (parent != null) {
4831 parent.PerformLayout();
4835 [EditorBrowsable(EditorBrowsableState.Advanced)]
4836 protected virtual void OnRightToLeftChanged(EventArgs e) {
4837 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4840 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4843 [EditorBrowsable(EditorBrowsableState.Advanced)]
4844 protected virtual void OnSizeChanged(EventArgs e) {
4845 DisposeBackBuffer ();
4847 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4852 [EditorBrowsable(EditorBrowsableState.Advanced)]
4853 protected virtual void OnStyleChanged(EventArgs e) {
4854 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4859 [EditorBrowsable(EditorBrowsableState.Advanced)]
4860 protected virtual void OnSystemColorsChanged(EventArgs e) {
4861 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4866 [EditorBrowsable(EditorBrowsableState.Advanced)]
4867 protected virtual void OnTabIndexChanged(EventArgs e) {
4868 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4873 [EditorBrowsable(EditorBrowsableState.Advanced)]
4874 protected virtual void OnTabStopChanged(EventArgs e) {
4875 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4880 [EditorBrowsable(EditorBrowsableState.Advanced)]
4881 protected virtual void OnTextChanged(EventArgs e) {
4882 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4887 [EditorBrowsable(EditorBrowsableState.Advanced)]
4888 protected virtual void OnValidated(EventArgs e) {
4889 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4894 [EditorBrowsable(EditorBrowsableState.Advanced)]
4895 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4896 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4901 [EditorBrowsable(EditorBrowsableState.Advanced)]
4902 protected virtual void OnVisibleChanged(EventArgs e) {
4903 if ((parent != null) && !Created && Visible) {
4910 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4914 // We need to tell our kids
4915 for (int i=0; i<child_controls.Count; i++) {
4916 if (child_controls[i].Visible) {
4917 child_controls[i].OnParentVisibleChanged(e);
4921 #endregion // OnXXX methods
4924 static object BackColorChangedEvent = new object ();
4925 static object BackgroundImageChangedEvent = new object ();
4926 static object BindingContextChangedEvent = new object ();
4927 static object CausesValidationChangedEvent = new object ();
4928 static object ChangeUICuesEvent = new object ();
4929 static object ClickEvent = new object ();
4930 static object ContextMenuChangedEvent = new object ();
4931 static object ControlAddedEvent = new object ();
4932 static object ControlRemovedEvent = new object ();
4933 static object CursorChangedEvent = new object ();
4934 static object DockChangedEvent = new object ();
4935 static object DoubleClickEvent = new object ();
4936 static object DragDropEvent = new object ();
4937 static object DragEnterEvent = new object ();
4938 static object DragLeaveEvent = new object ();
4939 static object DragOverEvent = new object ();
4940 static object EnabledChangedEvent = new object ();
4941 static object EnterEvent = new object ();
4942 static object FontChangedEvent = new object ();
4943 static object ForeColorChangedEvent = new object ();
4944 static object GiveFeedbackEvent = new object ();
4945 static object GotFocusEvent = new object ();
4946 static object HandleCreatedEvent = new object ();
4947 static object HandleDestroyedEvent = new object ();
4948 static object HelpRequestedEvent = new object ();
4949 static object ImeModeChangedEvent = new object ();
4950 static object InvalidatedEvent = new object ();
4951 static object KeyDownEvent = new object ();
4952 static object KeyPressEvent = new object ();
4953 static object KeyUpEvent = new object ();
4954 static object LayoutEvent = new object ();
4955 static object LeaveEvent = new object ();
4956 static object LocationChangedEvent = new object ();
4957 static object LostFocusEvent = new object ();
4958 static object MouseDownEvent = new object ();
4959 static object MouseEnterEvent = new object ();
4960 static object MouseHoverEvent = new object ();
4961 static object MouseLeaveEvent = new object ();
4962 static object MouseMoveEvent = new object ();
4963 static object MouseUpEvent = new object ();
4964 static object MouseWheelEvent = new object ();
4965 static object MoveEvent = new object ();
4966 static object PaintEvent = new object ();
4967 static object ParentChangedEvent = new object ();
4968 static object QueryAccessibilityHelpEvent = new object ();
4969 static object QueryContinueDragEvent = new object ();
4970 static object ResizeEvent = new object ();
4971 static object RightToLeftChangedEvent = new object ();
4972 static object SizeChangedEvent = new object ();
4973 static object StyleChangedEvent = new object ();
4974 static object SystemColorsChangedEvent = new object ();
4975 static object TabIndexChangedEvent = new object ();
4976 static object TabStopChangedEvent = new object ();
4977 static object TextChangedEvent = new object ();
4978 static object ValidatedEvent = new object ();
4979 static object ValidatingEvent = new object ();
4980 static object VisibleChangedEvent = new object ();
4982 public event EventHandler BackColorChanged {
4983 add { Events.AddHandler (BackColorChangedEvent, value); }
4984 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4987 public event EventHandler BackgroundImageChanged {
4988 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4989 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4992 public event EventHandler BindingContextChanged {
4993 add { Events.AddHandler (BindingContextChangedEvent, value); }
4994 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4997 public event EventHandler CausesValidationChanged {
4998 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4999 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
5002 public event UICuesEventHandler ChangeUICues {
5003 add { Events.AddHandler (ChangeUICuesEvent, value); }
5004 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
5007 public event EventHandler Click {
5008 add { Events.AddHandler (ClickEvent, value); }
5009 remove { Events.RemoveHandler (ClickEvent, value); }
5012 public event EventHandler ContextMenuChanged {
5013 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5014 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5017 [EditorBrowsable(EditorBrowsableState.Advanced)]
5019 public event ControlEventHandler ControlAdded {
5020 add { Events.AddHandler (ControlAddedEvent, value); }
5021 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5024 [EditorBrowsable(EditorBrowsableState.Advanced)]
5026 public event ControlEventHandler ControlRemoved {
5027 add { Events.AddHandler (ControlRemovedEvent, value); }
5028 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5031 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5032 public event EventHandler CursorChanged {
5033 add { Events.AddHandler (CursorChangedEvent, value); }
5034 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5036 public event EventHandler DockChanged {
5037 add { Events.AddHandler (DockChangedEvent, value); }
5038 remove { Events.RemoveHandler (DockChangedEvent, value); }
5041 public event EventHandler DoubleClick {
5042 add { Events.AddHandler (DoubleClickEvent, value); }
5043 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5046 public event DragEventHandler DragDrop {
5047 add { Events.AddHandler (DragDropEvent, value); }
5048 remove { Events.RemoveHandler (DragDropEvent, value); }
5051 public event DragEventHandler DragEnter {
5052 add { Events.AddHandler (DragEnterEvent, value); }
5053 remove { Events.RemoveHandler (DragEnterEvent, value); }
5056 public event EventHandler DragLeave {
5057 add { Events.AddHandler (DragLeaveEvent, value); }
5058 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5061 public event DragEventHandler DragOver {
5062 add { Events.AddHandler (DragOverEvent, value); }
5063 remove { Events.RemoveHandler (DragOverEvent, value); }
5066 public event EventHandler EnabledChanged {
5067 add { Events.AddHandler (EnabledChangedEvent, value); }
5068 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5071 public event EventHandler Enter {
5072 add { Events.AddHandler (EnterEvent, value); }
5073 remove { Events.RemoveHandler (EnterEvent, value); }
5076 public event EventHandler FontChanged {
5077 add { Events.AddHandler (FontChangedEvent, value); }
5078 remove { Events.RemoveHandler (FontChangedEvent, value); }
5081 public event EventHandler ForeColorChanged {
5082 add { Events.AddHandler (ForeColorChangedEvent, value); }
5083 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5086 public event GiveFeedbackEventHandler GiveFeedback {
5087 add { Events.AddHandler (GiveFeedbackEvent, value); }
5088 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5091 [EditorBrowsable(EditorBrowsableState.Advanced)]
5093 public event EventHandler GotFocus {
5094 add { Events.AddHandler (GotFocusEvent, value); }
5095 remove { Events.RemoveHandler (GotFocusEvent, value); }
5099 [EditorBrowsable(EditorBrowsableState.Advanced)]
5101 public event EventHandler HandleCreated {
5102 add { Events.AddHandler (HandleCreatedEvent, value); }
5103 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5106 [EditorBrowsable(EditorBrowsableState.Advanced)]
5108 public event EventHandler HandleDestroyed {
5109 add { Events.AddHandler (HandleDestroyedEvent, value); }
5110 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5113 public event HelpEventHandler HelpRequested {
5114 add { Events.AddHandler (HelpRequestedEvent, value); }
5115 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5118 public event EventHandler ImeModeChanged {
5119 add { Events.AddHandler (ImeModeChangedEvent, value); }
5120 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5123 [EditorBrowsable(EditorBrowsableState.Advanced)]
5125 public event InvalidateEventHandler Invalidated {
5126 add { Events.AddHandler (InvalidatedEvent, value); }
5127 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5130 public event KeyEventHandler KeyDown {
5131 add { Events.AddHandler (KeyDownEvent, value); }
5132 remove { Events.RemoveHandler (KeyDownEvent, value); }
5135 public event KeyPressEventHandler KeyPress {
5136 add { Events.AddHandler (KeyPressEvent, value); }
5137 remove { Events.RemoveHandler (KeyPressEvent, value); }
5140 public event KeyEventHandler KeyUp {
5141 add { Events.AddHandler (KeyUpEvent, value); }
5142 remove { Events.RemoveHandler (KeyUpEvent, value); }
5145 public event LayoutEventHandler Layout {
5146 add { Events.AddHandler (LayoutEvent, value); }
5147 remove { Events.RemoveHandler (LayoutEvent, value); }
5150 public event EventHandler Leave {
5151 add { Events.AddHandler (LeaveEvent, value); }
5152 remove { Events.RemoveHandler (LeaveEvent, value); }
5155 public event EventHandler LocationChanged {
5156 add { Events.AddHandler (LocationChangedEvent, value); }
5157 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5160 [EditorBrowsable(EditorBrowsableState.Advanced)]
5162 public event EventHandler LostFocus {
5163 add { Events.AddHandler (LostFocusEvent, value); }
5164 remove { Events.RemoveHandler (LostFocusEvent, value); }
5167 public event MouseEventHandler MouseDown {
5168 add { Events.AddHandler (MouseDownEvent, value); }
5169 remove { Events.RemoveHandler (MouseDownEvent, value); }
5172 public event EventHandler MouseEnter {
5173 add { Events.AddHandler (MouseEnterEvent, value); }
5174 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5177 public event EventHandler MouseHover {
5178 add { Events.AddHandler (MouseHoverEvent, value); }
5179 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5182 public event EventHandler MouseLeave {
5183 add { Events.AddHandler (MouseLeaveEvent, value); }
5184 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5187 public event MouseEventHandler MouseMove {
5188 add { Events.AddHandler (MouseMoveEvent, value); }
5189 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5192 public event MouseEventHandler MouseUp {
5193 add { Events.AddHandler (MouseUpEvent, value); }
5194 remove { Events.RemoveHandler (MouseUpEvent, value); }
5197 [EditorBrowsable(EditorBrowsableState.Advanced)]
5199 public event MouseEventHandler MouseWheel {
5200 add { Events.AddHandler (MouseWheelEvent, value); }
5201 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5204 public event EventHandler Move {
5205 add { Events.AddHandler (MoveEvent, value); }
5206 remove { Events.RemoveHandler (MoveEvent, value); }
5209 public event PaintEventHandler Paint {
5210 add { Events.AddHandler (PaintEvent, value); }
5211 remove { Events.RemoveHandler (PaintEvent, value); }
5214 public event EventHandler ParentChanged {
5215 add { Events.AddHandler (ParentChangedEvent, value); }
5216 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5219 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5220 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5221 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5224 public event QueryContinueDragEventHandler QueryContinueDrag {
5225 add { Events.AddHandler (QueryContinueDragEvent, value); }
5226 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5229 public event EventHandler Resize {
5230 add { Events.AddHandler (ResizeEvent, value); }
5231 remove { Events.RemoveHandler (ResizeEvent, value); }
5234 public event EventHandler RightToLeftChanged {
5235 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5236 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5239 public event EventHandler SizeChanged {
5240 add { Events.AddHandler (SizeChangedEvent, value); }
5241 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5244 public event EventHandler StyleChanged {
5245 add { Events.AddHandler (StyleChangedEvent, value); }
5246 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5249 public event EventHandler SystemColorsChanged {
5250 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5251 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5254 public event EventHandler TabIndexChanged {
5255 add { Events.AddHandler (TabIndexChangedEvent, value); }
5256 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5259 public event EventHandler TabStopChanged {
5260 add { Events.AddHandler (TabStopChangedEvent, value); }
5261 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5264 public event EventHandler TextChanged {
5265 add { Events.AddHandler (TextChangedEvent, value); }
5266 remove { Events.RemoveHandler (TextChangedEvent, value); }
5269 public event EventHandler Validated {
5270 add { Events.AddHandler (ValidatedEvent, value); }
5271 remove { Events.RemoveHandler (ValidatedEvent, value); }
5274 public event CancelEventHandler Validating {
5275 add { Events.AddHandler (ValidatingEvent, value); }
5276 remove { Events.RemoveHandler (ValidatingEvent, value); }
5279 public event EventHandler VisibleChanged {
5280 add { Events.AddHandler (VisibleChangedEvent, value); }
5281 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5284 #endregion // Events