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) {
542 owner.PerformLayout(value, "Parent");
543 owner.OnControlRemoved(new ControlEventArgs(value));
548 value.ChangeParent(null);
550 owner.UpdateChildrenZOrder();
553 internal virtual void RemoveImplicit (Control control)
555 if (impl_list != null) {
557 owner.PerformLayout (control, "Parent");
558 owner.OnControlRemoved (new ControlEventArgs (control));
559 impl_list.Remove (control);
561 control.ChangeParent (null);
562 owner.UpdateChildrenZOrder ();
565 public void RemoveAt(int index) {
566 if (index < 0 || index >= list.Count) {
567 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
569 Remove ((Control)list[index]);
572 public void SetChildIndex(Control child, int newIndex) {
575 old_index=list.IndexOf(child);
577 throw new ArgumentException("Not a child control", "child");
580 if (old_index==newIndex) {
585 list.RemoveAt(old_index);
587 if (newIndex>list.Count) {
590 list.Insert(newIndex, child);
592 child.UpdateZOrder();
593 owner.PerformLayout();
595 #endregion // ControlCollection Private Instance Methods
597 #region ControlCollection Interface Properties
598 object IList.this[int index] {
600 if (index<0 || index>=list.Count) {
601 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
607 if (!(value is Control)) {
608 throw new ArgumentException("Object of type Control required", "value");
612 Control ctrl = (Control) value;
615 ctrl.ChangeParent(owner);
619 owner.UpdateChildrenZOrder();
620 owner.PerformLayout(ctrl, "Parent");
624 bool IList.IsFixedSize {
630 bool ICollection.IsSynchronized {
632 return list.IsSynchronized;
636 object ICollection.SyncRoot {
638 return list.SyncRoot;
641 #endregion // ControlCollection Interface Properties
643 #region ControlCollection Interface Methods
644 int IList.Add(object value) {
646 throw new ArgumentNullException("value", "Cannot add null controls");
649 if (!(value is Control)) {
650 throw new ArgumentException("Object of type Control required", "value");
653 return list.Add(value);
656 bool IList.Contains(object value) {
657 if (!(value is Control)) {
658 throw new ArgumentException("Object of type Control required", "value");
661 return this.Contains((Control) value);
664 int IList.IndexOf(object value) {
665 if (!(value is Control)) {
666 throw new ArgumentException("Object of type Control required", "value");
669 return this.IndexOf((Control) value);
672 void IList.Insert(int index, object value) {
673 if (!(value is Control)) {
674 throw new ArgumentException("Object of type Control required", "value");
677 list.Insert(index, value);
680 void IList.Remove(object value) {
681 if (!(value is Control)) {
682 throw new ArgumentException("Object of type Control required", "value");
688 Object ICloneable.Clone() {
689 ControlCollection clone = new ControlCollection(this.owner);
690 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
693 #endregion // ControlCollection Interface Methods
695 #endregion // ControlCollection Class
697 #region Public Constructors
700 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
708 layout_pending = false;
710 causes_validation = true;
712 layout_suspended = 0;
716 right_to_left = RightToLeft.Inherit;
717 border_style = BorderStyle.None;
718 background_color = Color.Empty;
724 ime_mode = ImeMode.Inherit;
727 use_compatible_text_rendering = Application.use_compatible_text_rendering;
728 padding = new Padding(0);
729 maximum_size = new Size();
730 minimum_size = new Size();
731 preferred_size = new Size();
732 margin = this.DefaultMargin;
733 layout_engine = this.LayoutEngine;
736 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
737 ControlStyles.Selectable | ControlStyles.StandardClick |
738 ControlStyles.StandardDoubleClick;
740 control_style |= ControlStyles.UseTextForAccessibility;
744 background_image = null;
748 window = new ControlNativeWindow(this);
749 child_controls = CreateControlsInstance();
750 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
751 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
752 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
753 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
759 public Control(Control parent, string text) : this() {
764 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
769 bounds.Height=height;
770 SetBounds(left, top, width, height, BoundsSpecified.All);
774 public Control(string text) : this() {
778 public Control(string text, int left, int top, int width, int height) : this() {
782 bounds.Height=height;
783 SetBounds(left, top, width, height, BoundsSpecified.All);
787 private delegate void RemoveDelegate(object c);
789 protected override void Dispose(bool disposing) {
790 if (!is_disposed && disposing) {
793 DisposeBackBuffer ();
795 if (invalid_region!=null) {
796 invalid_region.Dispose();
799 if (this.InvokeRequired) {
800 if (Application.MessageLoop) {
801 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
808 if (parent != null) {
809 parent.Controls.Remove(this);
812 Control [] children = child_controls.GetAllControls ();
813 for (int i=0; i<children.Length; i++) {
814 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
815 children[i].Dispose();
820 base.Dispose(disposing);
822 #endregion // Public Constructors
824 #region Internal Properties
825 internal BorderStyle InternalBorderStyle {
831 if (!Enum.IsDefined (typeof (BorderStyle), value))
832 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
834 if (border_style != value) {
835 border_style = value;
837 if (IsHandleCreated) {
838 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
844 #endregion // Internal Properties
846 #region Private & Internal Methods
847 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
848 AsyncMethodResult result;
849 AsyncMethodData data;
856 if (!p.IsHandleCreated) {
857 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
863 result = new AsyncMethodResult ();
864 data = new AsyncMethodData ();
866 data.Handle = window.Handle;
867 data.Method = method;
869 data.Result = result;
872 if (!ExecutionContext.IsFlowSuppressed ()) {
873 data.Context = ExecutionContext.Capture ();
876 #if !MWF_ON_MSRUNTIME
877 if (SecurityManager.SecurityEnabled) {
878 data.Stack = CompressedStack.GetCompressedStack ();
883 XplatUI.SendAsyncMethod (data);
888 internal void PointToClient (ref int x, ref int y)
890 XplatUI.ScreenToClient (Handle, ref x, ref y);
893 internal void PointToScreen (ref int x, ref int y)
895 XplatUI.ClientToScreen (Handle, ref x, ref y);
898 internal bool IsRecreating {
900 return is_recreating;
904 internal Graphics DeviceContext {
905 get { return Hwnd.bmp_g; }
908 private void InvalidateBackBuffer ()
910 if (invalid_region != null)
911 invalid_region.Dispose();
912 invalid_region = new Region (ClientRectangle);
915 private void CreateBackBuffer ()
917 if (backbuffer != null)
923 if (width < 1) width = 1;
924 if (height < 1) height = 1;
926 XplatUI.CreateOffscreenDrawable (Handle, width, height, out backbuffer, out backbuffer_dc);
927 InvalidateBackBuffer ();
930 private void DisposeBackBuffer ()
932 if (backbuffer == null)
935 XplatUI.DestroyOffscreenDrawable (backbuffer, backbuffer_dc);
937 backbuffer_dc = null;
940 if (invalid_region != null)
941 invalid_region.Dispose ();
942 invalid_region = null;
945 internal static void SetChildColor(Control parent) {
948 for (int i=0; i < parent.child_controls.Count; i++) {
949 child=parent.child_controls[i];
950 if (child.child_controls.Count>0) {
951 SetChildColor(child);
956 internal bool Select(Control control) {
957 IContainerControl container;
959 if (control == null) {
963 container = GetContainerControl();
964 if (container != null) {
965 container.ActiveControl = control;
967 if (control.IsHandleCreated) {
968 XplatUI.SetFocus(control.window.Handle);
973 internal void SelectChild (Control control)
975 if (control.IsHandleCreated)
976 XplatUI.SetFocus (control.window.Handle);
979 internal virtual void DoDefaultAction() {
980 // Only here to be overriden by our actual controls; this is needed by the accessibility class
983 internal static int LowOrder (int param) {
984 return ((int)(short)(param & 0xffff));
987 internal static int HighOrder (int param) {
988 return ((int)(short)(param >> 16));
991 // This method exists so controls overriding OnPaintBackground can have default background painting done
992 internal virtual void PaintControlBackground (PaintEventArgs pevent)
994 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
995 if (parent != null) {
996 PaintEventArgs parent_pe;
999 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1001 state = parent_pe.Graphics.Save();
1002 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1003 parent.OnPaintBackground(parent_pe);
1004 parent_pe.Graphics.Restore(state);
1006 state = parent_pe.Graphics.Save();
1007 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1008 parent.OnPaint(parent_pe);
1009 parent_pe.Graphics.Restore(state);
1010 parent_pe.SetGraphics(null);
1014 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1015 if (parent != null) {
1016 PaintEventArgs parent_pe;
1018 GraphicsState state;
1021 hwnd = Hwnd.ObjectFromHandle(Handle);
1024 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1026 region = new Region ();
1028 region.Union(ClientRectangle);
1030 foreach (Rectangle r in hwnd.ClipRectangles) {
1034 state = parent_pe.Graphics.Save();
1035 parent_pe.Graphics.Clip = region;
1037 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1038 parent.OnPaintBackground(parent_pe);
1039 parent_pe.Graphics.Restore(state);
1041 state = parent_pe.Graphics.Save();
1042 parent_pe.Graphics.Clip = region;
1044 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1045 parent.OnPaint(parent_pe);
1046 parent_pe.Graphics.Restore(state);
1047 parent_pe.SetGraphics(null);
1049 region.Intersect(clip_region);
1050 pevent.Graphics.Clip = region;
1055 if (background_image == null) {
1056 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));
1060 DrawBackgroundImage (pevent.Graphics);
1063 void DrawBackgroundImage (Graphics g)
1065 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1066 g.FillRectangle (b, ClientRectangle);
1070 internal virtual void DndEnter (DragEventArgs e)
1077 internal virtual void DndOver (DragEventArgs e)
1084 internal virtual void DndDrop (DragEventArgs e)
1088 } catch (Exception exc) {
1089 Console.Error.WriteLine ("MWF: Exception while dropping:");
1090 Console.Error.WriteLine (exc);
1094 internal virtual void DndLeave (EventArgs e)
1101 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1108 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1111 OnQueryContinueDrag(e);
1115 internal static MouseButtons FromParamToMouseButtons (int param) {
1116 MouseButtons buttons = MouseButtons.None;
1118 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1119 buttons |= MouseButtons.Left;
1121 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1122 buttons |= MouseButtons.Middle;
1124 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1125 buttons |= MouseButtons.Right;
1131 internal void FireEnter ()
1133 OnEnter (EventArgs.Empty);
1136 internal void FireLeave ()
1138 OnLeave (EventArgs.Empty);
1141 internal void FireValidating (CancelEventArgs ce)
1146 internal void FireValidated ()
1148 OnValidated (EventArgs.Empty);
1151 internal virtual bool ProcessControlMnemonic(char charCode) {
1152 return ProcessMnemonic(charCode);
1155 private static Control FindFlatForward(Control container, Control start) {
1161 end = container.child_controls.Count;
1163 if (start != null) {
1164 index = start.tab_index;
1170 for (int i = 0, pos = -1; i < end; i++) {
1171 if (start == container.child_controls[i]) {
1176 if (found == null) {
1177 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1178 found = container.child_controls[i];
1180 } else if (found.tab_index > container.child_controls[i].tab_index) {
1181 if (container.child_controls[i].tab_index > index) {
1182 found = container.child_controls[i];
1189 private static Control FindControlForward(Control container, Control start) {
1194 if (start == null) {
1195 return FindFlatForward(container, start);
1198 if (start.child_controls != null && start.child_controls.Count > 0 &&
1199 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1200 return FindControlForward(start, null);
1203 while (start != container) {
1204 found = FindFlatForward(start.parent, start);
1205 if (found != null) {
1208 start = start.parent;
1214 private static Control FindFlatBackward(Control container, Control start) {
1220 end = container.child_controls.Count;
1222 if (start != null) {
1223 index = start.tab_index;
1225 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1227 for (int i = 0; i < end; i++) {
1228 if (container.child_controls[i].tab_index > index) {
1229 index = container.child_controls[i].tab_index;
1237 for (int i = end - 1; i >= 0; i--) {
1238 if (start == container.child_controls[i]) {
1243 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1244 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1245 found = container.child_controls[i];
1252 private static Control FindControlBackward(Control container, Control start) {
1254 Control found = null;
1256 if (start == null) {
1257 found = FindFlatBackward(container, start);
1259 else if (start != container) {
1260 if (start.parent != null) {
1261 found = FindFlatBackward(start.parent, start);
1263 if (found == null) {
1264 if (start.parent != container)
1265 return start.parent;
1271 if (found == null || start.parent == null)
1274 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1275 found.child_controls != null && found.child_controls.Count > 0)) {
1276 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1277 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1278 found = FindFlatBackward(found, null);
1288 if (start != null) {
1289 found = FindFlatBackward(start.parent, start);
1290 if (found == null) {
1291 if (start.parent != container) {
1292 return start.parent;
1296 if (found == null) {
1297 found = FindFlatBackward(container, start);
1300 if (container != start) {
1301 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1302 found = FindControlBackward(found, null);
1303 if (found != null) {
1312 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1313 if (GetStyle(ControlStyles.StandardClick)) {
1314 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1316 OnDoubleClick(EventArgs.Empty);
1318 OnClick(EventArgs.Empty);
1328 private void CheckDataBindings ()
1330 if (data_bindings == null)
1333 BindingContext binding_context = BindingContext;
1334 foreach (Binding binding in data_bindings) {
1335 binding.Check (binding_context);
1340 private void ChangeParent(Control new_parent) {
1344 Color pre_fore_color;
1345 Color pre_back_color;
1346 RightToLeft pre_rtl;
1348 // These properties are inherited from our parent
1349 // Get them pre parent-change and then send events
1350 // if they are changed after we have our new parent
1351 pre_enabled = Enabled;
1352 pre_visible = Visible;
1354 pre_fore_color = ForeColor;
1355 pre_back_color = BackColor;
1356 pre_rtl = RightToLeft;
1357 // MS doesn't seem to send a CursorChangedEvent
1359 parent = new_parent;
1361 if (IsHandleCreated)
1362 XplatUI.SetParent(Handle,
1363 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1365 OnParentChanged(EventArgs.Empty);
1367 if (pre_enabled != Enabled) {
1368 OnEnabledChanged(EventArgs.Empty);
1371 if (pre_visible != Visible) {
1372 OnVisibleChanged(EventArgs.Empty);
1375 if (pre_font != Font) {
1376 OnFontChanged(EventArgs.Empty);
1379 if (pre_fore_color != ForeColor) {
1380 OnForeColorChanged(EventArgs.Empty);
1383 if (pre_back_color != BackColor) {
1384 OnBackColorChanged(EventArgs.Empty);
1387 if (pre_rtl != RightToLeft) {
1388 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1389 // because when RTL changes they have to recreate the win32 control
1390 // We don't really need that (until someone runs into compatibility issues)
1391 OnRightToLeftChanged(EventArgs.Empty);
1394 if ((new_parent != null) && new_parent.Created && !Created) {
1398 if ((binding_context == null) && Created) {
1399 OnBindingContextChanged(EventArgs.Empty);
1403 private void UpdateDistances() {
1404 if ((parent != null) && (parent.layout_suspended == 0)) {
1405 dist_left = bounds.X;
1406 dist_top = bounds.Y;
1407 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1408 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1411 #endregion // Private & Internal Methods
1413 #region Public Static Properties
1414 public static Color DefaultBackColor {
1416 return ThemeEngine.Current.DefaultControlBackColor;
1420 public static Font DefaultFont {
1422 return ThemeEngine.Current.DefaultFont;
1426 public static Color DefaultForeColor {
1428 return ThemeEngine.Current.DefaultControlForeColor;
1432 public static Keys ModifierKeys {
1434 return XplatUI.State.ModifierKeys;
1438 public static MouseButtons MouseButtons {
1440 return XplatUI.State.MouseButtons;
1444 public static Point MousePosition {
1446 return Cursor.Position;
1452 public static bool CheckForIllegalCrossThreadCalls
1455 return verify_thread_handle;
1459 verify_thread_handle = value;
1463 #endregion // Public Static Properties
1465 #region Public Instance Properties
1466 [EditorBrowsable(EditorBrowsableState.Advanced)]
1468 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1469 public AccessibleObject AccessibilityObject {
1471 if (accessibility_object==null) {
1472 accessibility_object=CreateAccessibilityInstance();
1474 return accessibility_object;
1478 [EditorBrowsable(EditorBrowsableState.Advanced)]
1480 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1481 public string AccessibleDefaultActionDescription {
1483 return AccessibilityObject.default_action;
1487 AccessibilityObject.default_action=value;
1492 [DefaultValue(null)]
1493 [MWFCategory("Accessibility")]
1494 public string AccessibleDescription {
1496 return AccessibilityObject.description;
1500 AccessibilityObject.description=value;
1505 [DefaultValue(null)]
1506 [MWFCategory("Accessibility")]
1507 public string AccessibleName {
1509 return AccessibilityObject.Name;
1513 AccessibilityObject.Name=value;
1517 [DefaultValue(AccessibleRole.Default)]
1518 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1519 public AccessibleRole AccessibleRole {
1521 return AccessibilityObject.role;
1525 AccessibilityObject.role=value;
1529 [DefaultValue(false)]
1530 [MWFCategory("Behavior")]
1531 public virtual bool AllowDrop {
1537 if (allow_drop == value)
1540 if (IsHandleCreated) {
1542 XplatUI.SetAllowDrop (Handle, value);
1548 [RefreshProperties(RefreshProperties.Repaint)]
1549 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1550 [MWFCategory("Layout")]
1551 public virtual AnchorStyles Anchor {
1553 return anchor_style;
1559 if (parent != null) {
1560 parent.PerformLayout(this, "Parent");
1566 // XXX: Implement me!
1569 public virtual bool AutoSize {
1571 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1575 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1580 public virtual Size MaximumSize {
1582 return maximum_size;
1585 maximum_size = value;
1589 public virtual Size MinimumSize {
1591 return minimum_size;
1594 minimum_size = value;
1600 [MWFCategory("Appearance")]
1601 public virtual Color BackColor {
1603 if (background_color.IsEmpty) {
1605 Color pcolor = parent.BackColor;
1606 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1609 return DefaultBackColor;
1611 return background_color;
1615 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1616 throw new ArgumentException("Transparent background colors are not supported on this control");
1619 if (background_color != value) {
1620 background_color=value;
1621 SetChildColor(this);
1622 OnBackColorChanged(EventArgs.Empty);
1629 [DefaultValue(null)]
1630 [MWFCategory("Appearance")]
1631 public virtual Image BackgroundImage {
1633 return background_image;
1637 if (background_image!=value) {
1638 background_image=value;
1639 OnBackgroundImageChanged(EventArgs.Empty);
1645 [EditorBrowsable(EditorBrowsableState.Advanced)]
1647 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1648 public virtual BindingContext BindingContext {
1650 if (binding_context != null)
1651 return binding_context;
1654 binding_context = Parent.BindingContext;
1655 return binding_context;
1658 if (binding_context != value) {
1659 binding_context = value;
1660 OnBindingContextChanged(EventArgs.Empty);
1665 [EditorBrowsable(EditorBrowsableState.Advanced)]
1667 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1670 return bounds.Y+bounds.Height;
1674 [EditorBrowsable(EditorBrowsableState.Advanced)]
1676 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1677 public Rectangle Bounds {
1683 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1687 [EditorBrowsable(EditorBrowsableState.Advanced)]
1689 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1690 public bool CanFocus {
1692 if (IsHandleCreated && Visible && Enabled) {
1699 [EditorBrowsable(EditorBrowsableState.Advanced)]
1701 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1702 public bool CanSelect {
1706 if (!GetStyle(ControlStyles.Selectable)) {
1711 while (parent != null) {
1712 if (!parent.is_visible || !parent.is_enabled) {
1716 parent = parent.parent;
1722 internal virtual bool InternalCapture {
1732 [EditorBrowsable(EditorBrowsableState.Advanced)]
1734 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1735 public bool Capture {
1737 return this.is_captured;
1741 if (this.IsHandleCreated && value != is_captured) {
1744 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1746 XplatUI.UngrabWindow(this.window.Handle);
1747 is_captured = false;
1753 [DefaultValue(true)]
1754 [MWFCategory("Focus")]
1755 public bool CausesValidation {
1757 return this.causes_validation;
1761 if (this.causes_validation != value) {
1762 causes_validation = value;
1763 OnCausesValidationChanged(EventArgs.Empty);
1768 [EditorBrowsable(EditorBrowsableState.Advanced)]
1770 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1771 public Rectangle ClientRectangle {
1773 client_rect.Width = client_size.Width;
1774 client_rect.Height = client_size.Height;
1779 [EditorBrowsable(EditorBrowsableState.Advanced)]
1781 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1782 public Size ClientSize {
1785 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1786 return ((Form)this).form_parent_window.ClientSize;
1794 this.SetClientSizeCore(value.Width, value.Height);
1798 [EditorBrowsable(EditorBrowsableState.Advanced)]
1800 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1801 [DescriptionAttribute("ControlCompanyNameDescr")]
1802 public String CompanyName {
1804 return "Mono Project, Novell, Inc.";
1808 [EditorBrowsable(EditorBrowsableState.Advanced)]
1810 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1811 public bool ContainsFocus {
1813 IntPtr focused_window;
1815 focused_window = XplatUI.GetFocus();
1816 if (IsHandleCreated) {
1817 if (focused_window == Handle) {
1821 for (int i=0; i < child_controls.Count; i++) {
1822 if (child_controls[i].ContainsFocus) {
1831 [DefaultValue(null)]
1832 [MWFCategory("Behavior")]
1833 public virtual ContextMenu ContextMenu {
1835 return context_menu;
1839 if (context_menu != value) {
1840 context_menu = value;
1841 OnContextMenuChanged(EventArgs.Empty);
1847 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1848 public ControlCollection Controls {
1850 return this.child_controls;
1854 [EditorBrowsable(EditorBrowsableState.Advanced)]
1856 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1857 public bool Created {
1859 return (!is_disposed && is_created);
1863 [AmbientValue(null)]
1864 [MWFCategory("Appearance")]
1865 public virtual Cursor Cursor {
1867 if (cursor != null) {
1871 if (parent != null) {
1872 return parent.Cursor;
1875 return Cursors.Default;
1879 if (cursor != value) {
1884 if (IsHandleCreated) {
1885 pt = Cursor.Position;
1887 if (bounds.Contains(pt) || Capture) {
1888 if (GetChildAtPoint(pt) == null) {
1889 if (cursor != null) {
1890 XplatUI.SetCursor(window.Handle, cursor.handle);
1892 if (parent != null) {
1893 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1895 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1902 OnCursorChanged(EventArgs.Empty);
1908 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1909 [ParenthesizePropertyName(true)]
1910 [RefreshProperties(RefreshProperties.All)]
1911 [MWFCategory("Data")]
1912 public ControlBindingsCollection DataBindings {
1914 if (data_bindings == null)
1915 data_bindings = new ControlBindingsCollection (this);
1916 return data_bindings;
1920 [EditorBrowsable(EditorBrowsableState.Advanced)]
1922 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1923 public virtual Rectangle DisplayRectangle {
1925 return ClientRectangle;
1929 [EditorBrowsable(EditorBrowsableState.Advanced)]
1931 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1932 public bool Disposing {
1939 [RefreshProperties(RefreshProperties.Repaint)]
1940 [DefaultValue(DockStyle.None)]
1941 [MWFCategory("Layout")]
1942 public virtual DockStyle Dock {
1948 if (dock_style == value) {
1954 if (dock_style == DockStyle.None) {
1955 if (explicit_bounds == Rectangle.Empty)
1956 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1958 Bounds = explicit_bounds;
1961 if (parent != null) {
1962 parent.PerformLayout(this, "Parent");
1965 OnDockChanged(EventArgs.Empty);
1971 [MWFCategory("Behavior")]
1972 public bool Enabled {
1978 if (parent != null) {
1979 return parent.Enabled;
1987 bool old_value = is_enabled;
1990 if (old_value != value && !value && this.has_focus)
1991 SelectNextControl(this, true, true, true, true);
1993 OnEnabledChanged (EventArgs.Empty);
1997 [EditorBrowsable(EditorBrowsableState.Advanced)]
1999 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2000 public virtual bool Focused {
2002 return this.has_focus;
2007 [AmbientValue(null)]
2009 [MWFCategory("Appearance")]
2010 public virtual Font Font {
2016 if (Parent != null && Parent.Font != null) {
2023 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2025 if (font != null && font.Equals (value)) {
2031 OnFontChanged (EventArgs.Empty);
2036 [MWFCategory("Appearance")]
2037 public virtual Color ForeColor {
2039 if (foreground_color.IsEmpty) {
2041 return parent.ForeColor;
2043 return DefaultForeColor;
2045 return foreground_color;
2049 if (foreground_color != value) {
2050 foreground_color=value;
2052 OnForeColorChanged(EventArgs.Empty);
2059 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2060 public IntPtr Handle { // IWin32Window
2063 if (verify_thread_handle) {
2064 if (this.InvokeRequired) {
2065 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2069 if (!IsHandleCreated) {
2072 return window.Handle;
2076 [EditorBrowsable(EditorBrowsableState.Advanced)]
2078 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2079 public bool HasChildren {
2081 if (this.child_controls.Count>0) {
2088 [EditorBrowsable(EditorBrowsableState.Always)]
2090 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2093 return this.bounds.Height;
2097 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2101 [AmbientValue(ImeMode.Inherit)]
2103 [MWFCategory("Behavior")]
2104 public ImeMode ImeMode {
2106 if (ime_mode == ImeMode.Inherit) {
2108 return parent.ImeMode;
2110 return ImeMode.NoControl; // default value
2116 if (ime_mode != value) {
2119 OnImeModeChanged(EventArgs.Empty);
2124 [EditorBrowsable(EditorBrowsableState.Advanced)]
2126 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2127 public bool InvokeRequired { // ISynchronizeInvoke
2129 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2136 [EditorBrowsable(EditorBrowsableState.Advanced)]
2138 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2139 public bool IsAccessible {
2141 return is_accessible;
2145 is_accessible = value;
2149 [EditorBrowsable(EditorBrowsableState.Advanced)]
2151 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2152 public bool IsDisposed {
2154 return this.is_disposed;
2158 [EditorBrowsable(EditorBrowsableState.Advanced)]
2160 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2161 public bool IsHandleCreated {
2163 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2164 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2165 if (hwnd != null && !hwnd.zombie)
2174 public virtual Layout.LayoutEngine LayoutEngine {
2175 get { return new Layout.DefaultLayout (); }
2179 [EditorBrowsable(EditorBrowsableState.Always)]
2181 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2184 return this.bounds.X;
2188 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2193 [MWFCategory("Layout")]
2194 public Point Location {
2196 return new Point(bounds.X, bounds.Y);
2200 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2205 [Localizable (true)]
2206 public Padding Margin {
2207 get { return this.margin; }
2208 set { this.margin = value; }
2213 public string Name {
2225 public Padding Padding {
2237 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2238 public Control Parent {
2244 if (value == this) {
2245 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2248 if (parent!=value) {
2250 parent.Controls.Remove(this);
2255 value.Controls.Add(this);
2260 [EditorBrowsable(EditorBrowsableState.Advanced)]
2262 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2263 public string ProductName {
2265 Type t = typeof (AssemblyProductAttribute);
2266 Assembly assembly = GetType().Module.Assembly;
2267 object [] attrs = assembly.GetCustomAttributes (t, false);
2268 AssemblyProductAttribute a = null;
2269 // On MS we get a NullRefException if product attribute is not
2271 if (attrs != null && attrs.Length > 0)
2272 a = (AssemblyProductAttribute) attrs [0];
2277 [EditorBrowsable(EditorBrowsableState.Advanced)]
2279 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2280 public string ProductVersion {
2282 Type t = typeof (AssemblyVersionAttribute);
2283 Assembly assembly = GetType().Module.Assembly;
2284 object [] attrs = assembly.GetCustomAttributes (t, false);
2285 if (attrs == null || attrs.Length < 1)
2287 return ((AssemblyVersionAttribute)attrs [0]).Version;
2291 [EditorBrowsable(EditorBrowsableState.Advanced)]
2293 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2294 public bool RecreatingHandle {
2296 return is_recreating;
2300 [EditorBrowsable(EditorBrowsableState.Advanced)]
2302 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2303 public Region Region {
2309 if (IsHandleCreated) {
2310 XplatUI.SetClipRegion(Handle, value);
2312 clip_region = value;
2316 [EditorBrowsable(EditorBrowsableState.Advanced)]
2318 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2321 return this.bounds.X+this.bounds.Width;
2325 [AmbientValue(RightToLeft.Inherit)]
2327 [MWFCategory("Appearance")]
2328 public virtual RightToLeft RightToLeft {
2330 if (right_to_left == RightToLeft.Inherit) {
2332 return parent.RightToLeft;
2334 return RightToLeft.No; // default value
2336 return right_to_left;
2340 if (value != right_to_left) {
2341 right_to_left = value;
2342 OnRightToLeftChanged(EventArgs.Empty);
2347 [EditorBrowsable(EditorBrowsableState.Advanced)]
2348 public override ISite Site {
2356 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2358 BackColor = ap.BackColor;
2359 ForeColor = ap.ForeColor;
2367 [MWFCategory("Layout")]
2370 return new Size(Width, Height);
2374 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2379 [MergableProperty(false)]
2380 [MWFCategory("Behavior")]
2381 public int TabIndex {
2383 if (tab_index != -1) {
2390 if (tab_index != value) {
2392 OnTabIndexChanged(EventArgs.Empty);
2398 [DefaultValue(true)]
2399 [MWFCategory("Behavior")]
2400 public bool TabStop {
2406 if (tab_stop != value) {
2408 OnTabStopChanged(EventArgs.Empty);
2413 [Localizable(false)]
2415 [TypeConverter(typeof(StringConverter))]
2416 [DefaultValue(null)]
2417 [MWFCategory("Data")]
2424 control_tag = value;
2430 [BindableAttribute(true)]
2431 [MWFCategory("Appearance")]
2432 public virtual string Text {
2434 // Our implementation ignores ControlStyles.CacheText - we always cache
2439 if (value == null) {
2440 value = String.Empty;
2445 if (IsHandleCreated) {
2446 /* we need to call .SetWindowStyle here instead of just .Text
2447 because the presence/absence of Text (== "" or not) can cause
2448 other window style things to appear/disappear */
2449 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2450 XplatUI.Text(Handle, text);
2452 OnTextChanged (EventArgs.Empty);
2457 [EditorBrowsable(EditorBrowsableState.Always)]
2459 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2462 return this.bounds.Y;
2466 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2470 [EditorBrowsable(EditorBrowsableState.Advanced)]
2472 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2473 public Control TopLevelControl {
2477 while (p.parent != null) {
2481 return p is Form ? p : null;
2486 [MWFCategory("Behavior")]
2487 public bool Visible {
2491 } else if (parent != null) {
2492 return parent.Visible;
2499 SetVisibleCore(value);
2503 [EditorBrowsable(EditorBrowsableState.Always)]
2505 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2508 return this.bounds.Width;
2512 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2516 [EditorBrowsable(EditorBrowsableState.Never)]
2518 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2519 public IWindowTarget WindowTarget {
2528 #endregion // Public Instance Properties
2530 #region Protected Instance Properties
2531 protected virtual CreateParams CreateParams {
2533 CreateParams create_params = new CreateParams();
2536 create_params.Caption = Text;
2539 create_params.Caption = text;
2543 create_params.X = Left;
2546 create_params.X = this.bounds.X;
2550 create_params.Y = Top;
2553 create_params.Y = this.bounds.Y;
2557 create_params.Width = Width;
2560 create_params.Width = this.bounds.Width;
2564 create_params.Height = Height;
2567 create_params.Height = this.bounds.Height;
2571 create_params.ClassName = XplatUI.DefaultClassName;
2572 create_params.ClassStyle = 0;
2573 create_params.ExStyle = 0;
2574 create_params.Param = 0;
2577 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2580 if ((parent!=null) && (parent.IsHandleCreated)) {
2581 create_params.Parent = parent.Handle;
2584 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2587 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2591 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2594 switch (border_style) {
2595 case BorderStyle.FixedSingle:
2596 create_params.Style |= (int) WindowStyles.WS_BORDER;
2598 case BorderStyle.Fixed3D:
2599 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2603 return create_params;
2607 protected virtual ImeMode DefaultImeMode {
2609 return ImeMode.Inherit;
2614 protected virtual Padding DefaultMargin {
2615 get { return new Padding (3); }
2619 protected virtual Size DefaultSize {
2621 return new Size(0, 0);
2625 protected int FontHeight {
2635 protected bool RenderRightToLeft {
2637 return (this.right_to_left == RightToLeft.Yes);
2641 protected bool ResizeRedraw {
2643 return GetStyle(ControlStyles.ResizeRedraw);
2647 SetStyle(ControlStyles.ResizeRedraw, value);
2651 [EditorBrowsable(EditorBrowsableState.Advanced)]
2653 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2654 protected virtual bool ShowFocusCues {
2660 [EditorBrowsable(EditorBrowsableState.Advanced)]
2662 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2663 protected bool ShowKeyboardCues {
2668 #endregion // Protected Instance Properties
2670 #region Public Static Methods
2671 [EditorBrowsable(EditorBrowsableState.Advanced)]
2672 public static Control FromChildHandle(IntPtr handle) {
2673 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2676 [EditorBrowsable(EditorBrowsableState.Advanced)]
2677 public static Control FromHandle(IntPtr handle) {
2678 return Control.ControlNativeWindow.ControlFromHandle(handle);
2681 public static bool IsMnemonic(char charCode, string text) {
2684 amp = text.IndexOf('&');
2687 if (amp + 1 < text.Length) {
2688 if (text[amp + 1] != '&') {
2689 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2699 #region Protected Static Methods
2700 [EditorBrowsable(EditorBrowsableState.Advanced)]
2701 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2704 c = Control.FromHandle(hWnd);
2714 #region Public Instance Methods
2715 [EditorBrowsable(EditorBrowsableState.Advanced)]
2716 public IAsyncResult BeginInvoke(Delegate method) {
2717 object [] prms = null;
2718 if (method is EventHandler)
2719 prms = new object [] { this, EventArgs.Empty };
2720 return BeginInvokeInternal(method, prms, false);
2723 [EditorBrowsable(EditorBrowsableState.Advanced)]
2724 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2725 return BeginInvokeInternal (method, args, false);
2728 public void BringToFront() {
2729 if (parent != null) {
2730 parent.child_controls.SetChildIndex(this, 0);
2733 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2737 public bool Contains(Control ctl) {
2738 while (ctl != null) {
2747 public void CreateControl() {
2749 throw new ObjectDisposedException(GetType().FullName.ToString());
2755 if (!IsHandleCreated) {
2763 Control [] controls = child_controls.GetAllControls ();
2764 for (int i=0; i<controls.Length; i++) {
2765 controls [i].CreateControl ();
2768 UpdateChildrenZOrder();
2770 if (binding_context == null) { // seem to be sent whenever it's null?
2771 OnBindingContextChanged(EventArgs.Empty);
2777 public Graphics CreateGraphics() {
2778 if (!IsHandleCreated) {
2779 this.CreateHandle();
2781 return Graphics.FromHwnd(this.window.Handle);
2784 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2785 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2788 [EditorBrowsable(EditorBrowsableState.Advanced)]
2789 public object EndInvoke (IAsyncResult async_result) {
2790 AsyncMethodResult result = (AsyncMethodResult) async_result;
2791 return result.EndInvoke ();
2794 public Form FindForm() {
2807 public bool Focus() {
2808 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2811 is_focusing = false;
2816 public Control GetChildAtPoint(Point pt) {
2817 // Microsoft's version of this function doesn't seem to work, so I can't check
2818 // if we only consider children or also grandchildren, etc.
2819 // I'm gonna say 'children only'
2820 for (int i=0; i<child_controls.Count; i++) {
2821 if (child_controls[i].Bounds.Contains(pt)) {
2822 return child_controls[i];
2828 public IContainerControl GetContainerControl() {
2829 Control current = this;
2831 while (current!=null) {
2832 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2833 return (IContainerControl)current;
2835 current = current.parent;
2840 public Control GetNextControl(Control ctl, bool forward) {
2842 if (!this.Contains(ctl)) {
2847 ctl = FindControlForward(this, ctl);
2850 ctl = FindControlBackward(this, ctl);
2860 public virtual Size GetPreferredSize (Size proposedSize) {
2861 return preferred_size;
2865 public void Hide() {
2866 this.Visible = false;
2869 public void Invalidate() {
2870 Invalidate(ClientRectangle, false);
2873 public void Invalidate(bool invalidateChildren) {
2874 Invalidate(ClientRectangle, invalidateChildren);
2877 public void Invalidate(System.Drawing.Rectangle rc) {
2878 Invalidate(rc, false);
2881 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2882 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2886 NotifyInvalidate(rc);
2888 XplatUI.Invalidate(Handle, rc, false);
2890 if (invalidateChildren) {
2891 Control [] controls = child_controls.GetAllControls ();
2892 for (int i=0; i<controls.Length; i++)
2893 controls [i].Invalidate ();
2895 OnInvalidated(new InvalidateEventArgs(rc));
2898 public void Invalidate(System.Drawing.Region region) {
2899 Invalidate(region, false);
2902 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2903 RectangleF bounds = region.GetBounds (CreateGraphics ());
2904 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2905 invalidateChildren);
2908 public object Invoke (Delegate method) {
2909 object [] prms = null;
2910 if (method is EventHandler)
2911 prms = new object [] { this, EventArgs.Empty };
2913 return Invoke(method, prms);
2916 public object Invoke (Delegate method, object[] args) {
2917 if (!this.InvokeRequired) {
2918 return method.DynamicInvoke(args);
2921 IAsyncResult result = BeginInvoke (method, args);
2922 return EndInvoke(result);
2925 internal object InvokeInternal (Delegate method, bool disposing) {
2926 return InvokeInternal(method, null, disposing);
2929 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2930 if (!this.InvokeRequired) {
2931 return method.DynamicInvoke(args);
2934 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2935 return EndInvoke(result);
2938 [EditorBrowsable(EditorBrowsableState.Advanced)]
2939 public void PerformLayout() {
2940 PerformLayout(null, null);
2944 private void SetImplicitBounds (int x, int y, int width, int height)
2946 Rectangle saved_bounds = explicit_bounds;
2947 SetBounds (x, y, width, height);
2948 explicit_bounds = saved_bounds;
2952 [EditorBrowsable(EditorBrowsableState.Advanced)]
2953 public void PerformLayout(Control affectedControl, string affectedProperty) {
2954 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2956 if (layout_suspended > 0) {
2957 layout_pending = true;
2961 layout_pending = false;
2963 // Prevent us from getting messed up
2966 // Perform all Dock and Anchor calculations
2970 this.layout_engine.Layout(this, levent);
2972 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2974 AnchorStyles anchor;
2977 space = DisplayRectangle;
2979 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2980 Control [] controls = child_controls.GetAllControls ();
2981 for (int i = controls.Length - 1; i >= 0; i--) {
2982 child = controls [i];
2984 if (!child.Visible) {
2988 switch (child.Dock) {
2989 case DockStyle.None: {
2994 case DockStyle.Left: {
2995 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
2996 space.X+=child.Width;
2997 space.Width-=child.Width;
3001 case DockStyle.Top: {
3002 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3003 space.Y+=child.Height;
3004 space.Height-=child.Height;
3008 case DockStyle.Right: {
3009 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3010 space.Width-=child.Width;
3014 case DockStyle.Bottom: {
3015 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3016 space.Height-=child.Height;
3022 for (int i = controls.Length - 1; i >= 0; i--) {
3025 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3026 if (child.Dock == DockStyle.Fill) {
3027 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3031 space = DisplayRectangle;
3033 for (int i=0; i < controls.Length; i++) {
3039 child = controls[i];
3041 // If the control is docked we don't need to do anything
3042 if (child.Dock != DockStyle.None) {
3046 anchor = child.Anchor;
3050 width = child.Width;
3051 height = child.Height;
3053 if ((anchor & AnchorStyles.Left) !=0 ) {
3054 if ((anchor & AnchorStyles.Right) != 0) {
3055 width = space.Width - child.dist_right - left;
3057 ; // Left anchored only, nothing to be done
3059 } else if ((anchor & AnchorStyles.Right) != 0) {
3060 left = space.Width - child.dist_right - width;
3062 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3063 // This calculates from scratch every time:
3064 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3067 if ((anchor & AnchorStyles.Top) !=0 ) {
3068 if ((anchor & AnchorStyles.Bottom) != 0) {
3069 height = space.Height - child.dist_bottom - top;
3071 ; // Top anchored only, nothing to be done
3073 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3074 top = space.Height - child.dist_bottom - height;
3076 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3077 // This calculates from scratch every time:
3078 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3090 child.SetImplicitBounds(left, top, width, height);
3094 // Let everyone know
3098 // Need to make sure we decremend layout_suspended
3104 public Point PointToClient (Point p) {
3108 XplatUI.ScreenToClient (Handle, ref x, ref y);
3110 return new Point (x, y);
3113 public Point PointToScreen(Point p) {
3117 XplatUI.ClientToScreen(Handle, ref x, ref y);
3119 return new Point(x, y);
3122 public virtual bool PreProcessMessage(ref Message msg) {
3123 return InternalPreProcessMessage (ref msg);
3126 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3129 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3130 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3132 if (!ProcessCmdKey(ref msg, key_data)) {
3133 if (IsInputKey(key_data)) {
3137 return ProcessDialogKey(key_data);
3141 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3142 if (IsInputChar((char)msg.WParam)) {
3145 return ProcessDialogChar((char)msg.WParam);
3146 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3147 return ProcessDialogChar((char)msg.WParam);
3152 public Rectangle RectangleToClient(Rectangle r) {
3153 return new Rectangle(PointToClient(r.Location), r.Size);
3156 public Rectangle RectangleToScreen(Rectangle r) {
3157 return new Rectangle(PointToScreen(r.Location), r.Size);
3160 public virtual void Refresh() {
3161 if (IsHandleCreated == true) {
3163 XplatUI.UpdateWindow(window.Handle);
3165 Control [] controls = child_controls.GetAllControls ();
3166 for (int i=0; i < controls.Length; i++) {
3167 controls[i].Refresh();
3173 [EditorBrowsable(EditorBrowsableState.Never)]
3174 public virtual void ResetBackColor() {
3175 BackColor = Color.Empty;
3178 [EditorBrowsable(EditorBrowsableState.Never)]
3179 public void ResetBindings() {
3180 data_bindings.Clear();
3183 [EditorBrowsable(EditorBrowsableState.Never)]
3184 public virtual void ResetCursor() {
3188 [EditorBrowsable(EditorBrowsableState.Never)]
3189 public virtual void ResetFont() {
3193 [EditorBrowsable(EditorBrowsableState.Never)]
3194 public virtual void ResetForeColor() {
3195 foreground_color = Color.Empty;
3198 [EditorBrowsable(EditorBrowsableState.Never)]
3199 public void ResetImeMode() {
3200 ime_mode = DefaultImeMode;
3203 [EditorBrowsable(EditorBrowsableState.Never)]
3204 public virtual void ResetRightToLeft() {
3205 right_to_left = RightToLeft.Inherit;
3208 public virtual void ResetText() {
3209 text = String.Empty;
3212 public void ResumeLayout() {
3213 ResumeLayout (true);
3216 public void ResumeLayout(bool performLayout) {
3217 if (layout_suspended > 0) {
3221 if (layout_suspended == 0) {
3222 Control [] controls = child_controls.GetAllControls ();
3223 for (int i=0; i<controls.Length; i++) {
3224 controls [i].UpdateDistances ();
3227 if (performLayout && layout_pending) {
3233 public void Scale(float ratio) {
3234 ScaleCore(ratio, ratio);
3237 public void Scale(float dx, float dy) {
3242 public void Scale(SizeF factor) {
3243 ScaleCore(factor.Width, factor.Height);
3247 public void Select() {
3248 Select(false, false);
3252 private void printTree(Control c, string t) {
3253 foreach(Control i in c.child_controls) {
3254 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3255 printTree(i, t+"\t");
3259 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3263 Console.WriteLine("{0}", this.FindForm());
3264 printTree(this, "\t");
3267 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3272 c = GetNextControl(c, forward);
3281 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3282 c.Select (true, true);
3285 } while (c != ctl); // If we wrap back to ourselves we stop
3290 public void SendToBack() {
3291 if (parent != null) {
3292 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3296 public void SetBounds(int x, int y, int width, int height) {
3297 SetBounds(x, y, width, height, BoundsSpecified.All);
3300 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3301 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3305 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3309 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3313 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3317 SetBoundsCore(x, y, width, height, specified);
3318 if (parent != null) {
3319 parent.PerformLayout(this, "Bounds");
3323 public void Show() {
3325 this.CreateControl();
3331 public void SuspendLayout() {
3335 public void Update() {
3336 if (IsHandleCreated) {
3337 XplatUI.UpdateWindow(window.Handle);
3340 #endregion // Public Instance Methods
3342 #region Protected Instance Methods
3343 [EditorBrowsable(EditorBrowsableState.Advanced)]
3344 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3345 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3346 throw new NotImplementedException();
3349 [EditorBrowsable(EditorBrowsableState.Advanced)]
3350 protected virtual AccessibleObject CreateAccessibilityInstance() {
3351 return new Control.ControlAccessibleObject(this);
3354 [EditorBrowsable(EditorBrowsableState.Advanced)]
3355 protected virtual ControlCollection CreateControlsInstance() {
3356 return new ControlCollection(this);
3359 [EditorBrowsable(EditorBrowsableState.Advanced)]
3360 protected virtual void CreateHandle() {
3362 throw new ObjectDisposedException(GetType().FullName.ToString());
3365 if (IsHandleCreated && !is_recreating) {
3369 window.CreateHandle(CreateParams);
3371 if (window.Handle != IntPtr.Zero) {
3372 creator_thread = Thread.CurrentThread;
3374 XplatUI.EnableWindow(window.Handle, is_enabled);
3375 XplatUI.SetVisible(window.Handle, is_visible, true);
3377 if (clip_region != null) {
3378 XplatUI.SetClipRegion(Handle, clip_region);
3381 // Set our handle with our parent
3382 if ((parent != null) && (parent.IsHandleCreated)) {
3383 XplatUI.SetParent(window.Handle, parent.Handle);
3386 // Set our handle as parent for our children
3387 Control [] children;
3389 children = child_controls.GetAllControls ();
3390 for (int i = 0; i < children.Length; i++ ) {
3391 if (!children[i].RecreatingHandle)
3392 XplatUI.SetParent(children[i].Handle, window.Handle);
3396 XplatUI.SetAllowDrop (Handle, allow_drop);
3398 // Find out where the window manager placed us
3399 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3400 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3404 OnHandleCreated(EventArgs.Empty);
3408 [EditorBrowsable(EditorBrowsableState.Advanced)]
3409 protected virtual void DefWndProc(ref Message m) {
3410 window.DefWndProc(ref m);
3413 [EditorBrowsable(EditorBrowsableState.Advanced)]
3414 protected virtual void DestroyHandle() {
3415 if (IsHandleCreated) {
3416 if (window != null) {
3417 window.DestroyHandle();
3422 protected internal bool GetStyle(ControlStyles flag) {
3423 return (control_style & flag) != 0;
3426 protected bool GetTopLevel() {
3430 [EditorBrowsable(EditorBrowsableState.Advanced)]
3431 protected virtual void InitLayout() {
3435 [EditorBrowsable(EditorBrowsableState.Advanced)]
3436 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3437 toInvoke.OnGotFocus(e);
3440 [EditorBrowsable(EditorBrowsableState.Advanced)]
3441 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3442 toInvoke.OnLostFocus(e);
3445 [EditorBrowsable(EditorBrowsableState.Advanced)]
3446 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3447 toInvoke.OnClick(e);
3450 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3451 toInvoke.OnPaint(e);
3454 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3455 toInvoke.OnPaintBackground(e);
3458 protected virtual bool IsInputChar (char charCode) {
3462 protected virtual bool IsInputKey (Keys keyData) {
3463 // Doc says this one calls IsInputChar; not sure what to do with that
3467 [EditorBrowsable(EditorBrowsableState.Advanced)]
3468 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3472 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3473 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3477 if (parent != null) {
3478 return parent.ProcessCmdKey(ref msg, keyData);
3484 protected virtual bool ProcessDialogChar(char charCode) {
3485 if (parent != null) {
3486 return parent.ProcessDialogChar (charCode);
3492 protected virtual bool ProcessDialogKey (Keys keyData) {
3493 if (parent != null) {
3494 return parent.ProcessDialogKey (keyData);
3500 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3502 KeyEventArgs key_event;
3505 case (int)Msg.WM_SYSKEYDOWN:
3506 case (int)Msg.WM_KEYDOWN: {
3507 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3508 OnKeyDown (key_event);
3509 return key_event.Handled;
3512 case (int)Msg.WM_SYSKEYUP:
3513 case (int)Msg.WM_KEYUP: {
3514 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3515 OnKeyUp (key_event);
3516 return key_event.Handled;
3519 case (int)Msg.WM_SYSCHAR:
3520 case (int)Msg.WM_CHAR: {
3521 KeyPressEventArgs key_press_event;
3523 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3524 OnKeyPress(key_press_event);
3526 msg.WParam = (IntPtr)key_press_event.KeyChar;
3528 return key_press_event.Handled;
3539 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3540 if (parent != null) {
3541 if (parent.ProcessKeyPreview(ref msg)) {
3546 return ProcessKeyEventArgs(ref msg);
3549 protected virtual bool ProcessKeyPreview(ref Message msg) {
3550 if (parent != null) {
3551 return parent.ProcessKeyPreview(ref msg);
3557 protected virtual bool ProcessMnemonic(char charCode) {
3562 [EditorBrowsable(EditorBrowsableState.Advanced)]
3563 protected void RaiseDragEvent(object key, DragEventArgs e) {
3567 [EditorBrowsable(EditorBrowsableState.Advanced)]
3568 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3572 [EditorBrowsable(EditorBrowsableState.Advanced)]
3573 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3577 [EditorBrowsable(EditorBrowsableState.Advanced)]
3578 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3582 private void SetIsRecreating ()
3586 foreach (Control c in Controls.GetAllControls()) {
3587 c.SetIsRecreating ();
3591 [EditorBrowsable(EditorBrowsableState.Advanced)]
3592 protected void RecreateHandle() {
3594 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3599 if (IsHandleCreated) {
3601 Console.WriteLine(" + handle is created, destroying it.");
3604 // WM_DESTROY will CreateHandle for us
3607 Console.WriteLine(" + handle is not created, creating it.");
3615 is_recreating = false;
3617 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3623 [EditorBrowsable(EditorBrowsableState.Advanced)]
3624 protected void ResetMouseEventArgs() {
3628 [EditorBrowsable(EditorBrowsableState.Advanced)]
3629 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3630 if (right_to_left == RightToLeft.No) {
3635 case ContentAlignment.TopLeft: {
3636 return ContentAlignment.TopRight;
3639 case ContentAlignment.TopRight: {
3640 return ContentAlignment.TopLeft;
3643 case ContentAlignment.MiddleLeft: {
3644 return ContentAlignment.MiddleRight;
3647 case ContentAlignment.MiddleRight: {
3648 return ContentAlignment.MiddleLeft;
3651 case ContentAlignment.BottomLeft: {
3652 return ContentAlignment.BottomRight;
3655 case ContentAlignment.BottomRight: {
3656 return ContentAlignment.BottomLeft;
3660 // if it's center it doesn't change
3666 [EditorBrowsable(EditorBrowsableState.Advanced)]
3667 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3668 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3672 if (align == HorizontalAlignment.Left) {
3673 return HorizontalAlignment.Right;
3676 // align must be HorizontalAlignment.Right
3677 return HorizontalAlignment.Left;
3680 [EditorBrowsable(EditorBrowsableState.Advanced)]
3681 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3682 if (right_to_left == RightToLeft.No) {
3686 if (align == LeftRightAlignment.Left) {
3687 return LeftRightAlignment.Right;
3690 // align must be LeftRightAlignment.Right;
3691 return LeftRightAlignment.Left;
3694 [EditorBrowsable(EditorBrowsableState.Advanced)]
3695 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3696 return RtlTranslateAlignment(align);
3699 [EditorBrowsable(EditorBrowsableState.Advanced)]
3700 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3701 return RtlTranslateAlignment(align);
3704 [EditorBrowsable(EditorBrowsableState.Advanced)]
3705 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3706 return RtlTranslateAlignment(align);
3709 [EditorBrowsable(EditorBrowsableState.Advanced)]
3710 protected virtual void ScaleCore(float dx, float dy) {
3716 location = new Point((int)(Left * dx), (int)(Top * dy));
3717 size = this.ClientSize;
3719 if (!GetStyle(ControlStyles.FixedWidth)) {
3720 size.Width = (int)(size.Width * dx);
3723 if (!GetStyle(ControlStyles.FixedHeight)) {
3724 size.Height = (int)(size.Height * dy);
3727 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3729 /* Now scale our children */
3730 Control [] controls = child_controls.GetAllControls ();
3731 for (int i=0; i < controls.Length; i++) {
3732 controls[i].Scale(dx, dy);
3738 protected virtual void Select(bool directed, bool forward) {
3739 IContainerControl container;
3741 container = GetContainerControl();
3742 if (container != null)
3743 container.ActiveControl = this;
3746 [EditorBrowsable(EditorBrowsableState.Advanced)]
3747 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3748 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3749 if (IsHandleCreated) {
3750 XplatUI.SetWindowPos(Handle, x, y, width, height);
3752 // Win32 automatically changes negative width/height to 0.
3753 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3754 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3756 if (width < 0 || height < 0) {
3758 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3762 UpdateBounds(x, y, width, height);
3767 [EditorBrowsable(EditorBrowsableState.Advanced)]
3768 protected virtual void SetClientSizeCore(int x, int y) {
3769 // Calculate the actual window size from the client size (it usually stays the same or grows)
3770 Rectangle ClientRect;
3771 Rectangle WindowRect;
3774 ClientRect = new Rectangle(0, 0, x, y);
3775 cp = this.CreateParams;
3777 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3781 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3784 [EditorBrowsable(EditorBrowsableState.Advanced)]
3785 protected internal void SetStyle(ControlStyles flag, bool value) {
3787 control_style |= flag;
3789 control_style &= ~flag;
3793 protected void SetTopLevel(bool value) {
3794 if ((GetTopLevel() != value) && (parent != null)) {
3795 throw new Exception();
3799 if (value == true) {
3809 is_toplevel = value;
3812 protected virtual void SetVisibleCore(bool value) {
3813 if (value!=is_visible) {
3814 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3820 if (IsHandleCreated) {
3821 XplatUI.SetVisible(Handle, value, true);
3822 // Explicitly move Toplevel windows to where we want them;
3823 // apparently moving unmapped toplevel windows doesn't work
3824 if (is_visible && (this is Form)) {
3825 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3829 OnVisibleChanged(EventArgs.Empty);
3831 if (value == false && parent != null && Focused) {
3834 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3835 container = (Control)parent.GetContainerControl();
3836 if (container != null) {
3837 container.SelectNextControl(this, true, true, true, true);
3841 if (parent != null) {
3842 parent.PerformLayout(this, "visible");
3844 PerformLayout(this, "visible");
3849 [EditorBrowsable(EditorBrowsableState.Advanced)]
3850 protected void UpdateBounds() {
3858 if (!IsHandleCreated) {
3862 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3864 UpdateBounds(x, y, width, height, client_width, client_height);
3867 [EditorBrowsable(EditorBrowsableState.Advanced)]
3868 protected void UpdateBounds(int x, int y, int width, int height) {
3872 // Calculate client rectangle
3873 rect = new Rectangle(0, 0, 0, 0);
3876 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3877 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3880 [EditorBrowsable(EditorBrowsableState.Advanced)]
3881 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3882 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3884 bool resized = false;
3886 // Needed to generate required notifications
3887 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3891 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3898 bounds.Height=height;
3900 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3901 explicit_bounds = bounds;
3903 client_size.Width=clientWidth;
3904 client_size.Height=clientHeight;
3907 OnLocationChanged(EventArgs.Empty);
3911 OnSizeChanged(EventArgs.Empty);
3915 [EditorBrowsable(EditorBrowsableState.Advanced)]
3916 protected void UpdateStyles() {
3917 if (!IsHandleCreated) {
3921 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3922 OnStyleChanged(EventArgs.Empty);
3925 private void UpdateZOrderOfChild(Control child) {
3926 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3929 index = child_controls.IndexOf(child);
3932 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3934 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3939 private void UpdateChildrenZOrder() {
3940 Control [] controls;
3942 if (!IsHandleCreated) {
3946 controls = child_controls.GetAllControls ();
3947 for (int i = 1; i < controls.Length; i++ ) {
3948 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3952 [EditorBrowsable(EditorBrowsableState.Advanced)]
3953 protected void UpdateZOrder() {
3954 if (parent != null) {
3955 parent.UpdateZOrderOfChild(this);
3959 protected virtual void WndProc(ref Message m) {
3961 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3963 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3967 switch((Msg)m.Msg) {
3968 case Msg.WM_DESTROY: {
3969 OnHandleDestroyed(EventArgs.Empty);
3971 IntPtr handle = window.Handle;
3973 window.InvalidateHandle();
3975 if (is_recreating) {
3977 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
3981 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3983 is_recreating = false;
3988 case Msg.WM_WINDOWPOSCHANGED: {
3990 Rectangle save_bounds = explicit_bounds;
3992 explicit_bounds = save_bounds;
3993 if (GetStyle(ControlStyles.ResizeRedraw)) {
4000 // Nice description of what should happen when handling WM_PAINT
4001 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4002 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4003 case Msg.WM_PAINT: {
4004 PaintEventArgs paint_event;
4006 paint_event = XplatUI.PaintEventStart(Handle, true);
4008 if (paint_event == null) {
4012 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4014 // Just blit the previous image
4015 XplatUI.BlitFromOffscreen (Handle, paint_event.Graphics, backbuffer, backbuffer_dc, paint_event.ClipRectangle);
4016 XplatUI.PaintEventEnd (Handle, true);
4021 Graphics back_dc = null;
4023 if (ThemeEngine.Current.DoubleBufferingSupported) {
4024 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4025 CreateBackBuffer ();
4027 back_dc = backbuffer_dc;
4028 dc = paint_event.SetGraphics (back_dc);
4032 if (!GetStyle(ControlStyles.Opaque)) {
4033 OnPaintBackground(paint_event);
4036 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4037 OnPaintBackgroundInternal(paint_event);
4039 OnPaintInternal(paint_event);
4040 if (!paint_event.Handled) {
4041 OnPaint(paint_event);
4044 if (ThemeEngine.Current.DoubleBufferingSupported)
4045 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4046 XplatUI.BlitFromOffscreen (Handle, dc, back, back_dc, paint_event.ClipRectangle);
4047 paint_event.SetGraphics (dc);
4048 invalid_region.Exclude (paint_event.ClipRectangle);
4050 if (back != backbuffer)
4051 XplatUI.DestroyOffscreenDrawable (back, back_dc);
4054 XplatUI.PaintEventEnd(Handle, true);
4059 case Msg.WM_ERASEBKGND: {
4060 // The DefWndProc will never have to handle this, we always paint the background in managed code
4061 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4062 // here but it just makes things more complicated...
4063 m.Result = (IntPtr)1;
4067 case Msg.WM_LBUTTONUP: {
4070 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4072 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4075 HandleClick(mouse_clicks, me);
4078 if (InternalCapture) {
4079 InternalCapture = false;
4082 if (mouse_clicks > 1) {
4088 case Msg.WM_LBUTTONDOWN: {
4090 Select (true, true);
4092 InternalCapture = true;
4093 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4094 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4100 case Msg.WM_LBUTTONDBLCLK: {
4101 InternalCapture = true;
4103 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4104 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4109 case Msg.WM_MBUTTONUP: {
4112 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4114 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4117 HandleClick(mouse_clicks, me);
4119 if (InternalCapture) {
4120 InternalCapture = false;
4122 if (mouse_clicks > 1) {
4128 case Msg.WM_MBUTTONDOWN: {
4129 InternalCapture = true;
4130 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4131 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4136 case Msg.WM_MBUTTONDBLCLK: {
4137 InternalCapture = true;
4139 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4140 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4145 case Msg.WM_RBUTTONUP: {
4149 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4150 pt = PointToScreen(pt);
4152 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4154 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4156 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4159 HandleClick(mouse_clicks, me);
4162 if (InternalCapture) {
4163 InternalCapture = false;
4166 if (mouse_clicks > 1) {
4172 case Msg.WM_RBUTTONDOWN: {
4173 InternalCapture = true;
4174 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4175 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4180 case Msg.WM_RBUTTONDBLCLK: {
4181 InternalCapture = true;
4183 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4184 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4189 case Msg.WM_CONTEXTMENU: {
4190 if (context_menu != null) {
4193 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4194 context_menu.Show(this, PointToClient(pt));
4202 case Msg.WM_MOUSEWHEEL: {
4204 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4205 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4206 HighOrder(m.WParam.ToInt32())));
4211 case Msg.WM_MOUSEMOVE: {
4212 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4214 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4219 case Msg.WM_MOUSE_ENTER: {
4224 OnMouseEnter(EventArgs.Empty);
4228 case Msg.WM_MOUSE_LEAVE: {
4230 OnMouseLeave(EventArgs.Empty);
4234 case Msg.WM_MOUSEHOVER: {
4235 OnMouseHover(EventArgs.Empty);
4239 case Msg.WM_SYSKEYUP: {
4240 if (ProcessKeyMessage(ref m)) {
4241 m.Result = IntPtr.Zero;
4245 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4249 if (form != null && form.ActiveMenu != null) {
4250 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4258 case Msg.WM_SYSKEYDOWN:
4259 case Msg.WM_KEYDOWN:
4261 case Msg.WM_SYSCHAR:
4263 if (ProcessKeyMessage(ref m)) {
4264 m.Result = IntPtr.Zero;
4273 if (m.LParam != IntPtr.Zero) {
4276 hi = new HELPINFO();
4278 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4279 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4281 mouse_pos = Control.MousePosition;
4283 OnHelpRequested(new HelpEventArgs(mouse_pos));
4284 m.Result = (IntPtr)1;
4288 case Msg.WM_KILLFOCUS: {
4289 this.has_focus = false;
4290 OnLostFocusInternal (EventArgs.Empty);
4294 case Msg.WM_SETFOCUS: {
4296 this.has_focus = true;
4297 OnGotFocusInternal (EventArgs.Empty);
4302 case Msg.WM_SYSCOLORCHANGE: {
4303 ThemeEngine.Current.ResetDefaults();
4304 OnSystemColorsChanged(EventArgs.Empty);
4308 case Msg.WM_SETCURSOR: {
4309 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4314 XplatUI.SetCursor(window.Handle, cursor.handle);
4315 m.Result = (IntPtr)1;
4325 #endregion // Public Instance Methods
4327 #region OnXXX methods
4328 [EditorBrowsable(EditorBrowsableState.Advanced)]
4329 protected virtual void OnBackColorChanged(EventArgs e) {
4330 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4333 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4336 [EditorBrowsable(EditorBrowsableState.Advanced)]
4337 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4338 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4341 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4344 [EditorBrowsable(EditorBrowsableState.Advanced)]
4345 protected virtual void OnBindingContextChanged(EventArgs e) {
4346 CheckDataBindings ();
4347 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4350 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4353 [EditorBrowsable(EditorBrowsableState.Advanced)]
4354 protected virtual void OnCausesValidationChanged(EventArgs e) {
4355 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4360 [EditorBrowsable(EditorBrowsableState.Advanced)]
4361 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4362 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4367 [EditorBrowsable(EditorBrowsableState.Advanced)]
4368 protected virtual void OnClick(EventArgs e) {
4369 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4374 [EditorBrowsable(EditorBrowsableState.Advanced)]
4375 protected virtual void OnContextMenuChanged(EventArgs e) {
4376 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4381 [EditorBrowsable(EditorBrowsableState.Advanced)]
4382 protected virtual void OnControlAdded(ControlEventArgs e) {
4383 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4388 [EditorBrowsable(EditorBrowsableState.Advanced)]
4389 protected virtual void OnControlRemoved(ControlEventArgs e) {
4390 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4395 [EditorBrowsable(EditorBrowsableState.Advanced)]
4396 protected virtual void OnCreateControl() {
4400 [EditorBrowsable(EditorBrowsableState.Advanced)]
4401 protected virtual void OnCursorChanged(EventArgs e) {
4402 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4407 [EditorBrowsable(EditorBrowsableState.Advanced)]
4408 protected virtual void OnDockChanged(EventArgs e) {
4409 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4414 [EditorBrowsable(EditorBrowsableState.Advanced)]
4415 protected virtual void OnDoubleClick(EventArgs e) {
4416 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4421 [EditorBrowsable(EditorBrowsableState.Advanced)]
4422 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4423 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4425 eh (this, drgevent);
4428 [EditorBrowsable(EditorBrowsableState.Advanced)]
4429 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4430 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4432 eh (this, drgevent);
4435 [EditorBrowsable(EditorBrowsableState.Advanced)]
4436 protected virtual void OnDragLeave(EventArgs e) {
4437 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4442 [EditorBrowsable(EditorBrowsableState.Advanced)]
4443 protected virtual void OnDragOver(DragEventArgs drgevent) {
4444 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4446 eh (this, drgevent);
4449 [EditorBrowsable(EditorBrowsableState.Advanced)]
4450 protected virtual void OnEnabledChanged(EventArgs e) {
4451 if (IsHandleCreated) {
4453 if (((Form)this).context == null) {
4454 XplatUI.EnableWindow(window.Handle, Enabled);
4457 XplatUI.EnableWindow(window.Handle, Enabled);
4462 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4466 for (int i=0; i<child_controls.Count; i++) {
4467 child_controls[i].OnParentEnabledChanged(e);
4471 [EditorBrowsable(EditorBrowsableState.Advanced)]
4472 protected virtual void OnEnter(EventArgs e) {
4473 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4478 [EditorBrowsable(EditorBrowsableState.Advanced)]
4479 protected virtual void OnFontChanged(EventArgs e) {
4480 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4483 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4486 [EditorBrowsable(EditorBrowsableState.Advanced)]
4487 protected virtual void OnForeColorChanged(EventArgs e) {
4488 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4491 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4494 [EditorBrowsable(EditorBrowsableState.Advanced)]
4495 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4496 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4498 eh (this, gfbevent);
4501 [EditorBrowsable(EditorBrowsableState.Advanced)]
4502 protected virtual void OnGotFocus(EventArgs e) {
4503 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4508 [EditorBrowsable(EditorBrowsableState.Advanced)]
4509 protected virtual void OnHandleCreated(EventArgs e) {
4510 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4515 [EditorBrowsable(EditorBrowsableState.Advanced)]
4516 protected virtual void OnHandleDestroyed(EventArgs e) {
4517 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4522 [EditorBrowsable(EditorBrowsableState.Advanced)]
4523 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4524 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4529 protected virtual void OnImeModeChanged(EventArgs e) {
4530 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4535 [EditorBrowsable(EditorBrowsableState.Advanced)]
4536 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4537 if (ThemeEngine.Current.DoubleBufferingSupported)
4538 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4539 // should this block be here? seems like it
4540 // would be more at home in
4541 // NotifyInvalidated..
4542 if (e.InvalidRect == ClientRectangle) {
4543 InvalidateBackBuffer ();
4546 // we need this Inflate call here so
4547 // that the border of the rectangle is
4548 // considered Visible (the
4549 // invalid_region.IsVisible call) in
4550 // the WM_PAINT handling below.
4551 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4552 if (invalid_region == null)
4553 invalid_region = new Region (r);
4555 invalid_region.Union (r);
4559 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4564 [EditorBrowsable(EditorBrowsableState.Advanced)]
4565 protected virtual void OnKeyDown(KeyEventArgs e) {
4566 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4571 [EditorBrowsable(EditorBrowsableState.Advanced)]
4572 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4573 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4578 [EditorBrowsable(EditorBrowsableState.Advanced)]
4579 protected virtual void OnKeyUp(KeyEventArgs e) {
4580 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4585 [EditorBrowsable(EditorBrowsableState.Advanced)]
4586 protected virtual void OnLayout(LayoutEventArgs levent) {
4587 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4592 [EditorBrowsable(EditorBrowsableState.Advanced)]
4593 protected virtual void OnLeave(EventArgs e) {
4594 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4599 [EditorBrowsable(EditorBrowsableState.Advanced)]
4600 protected virtual void OnLocationChanged(EventArgs e) {
4602 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4607 [EditorBrowsable(EditorBrowsableState.Advanced)]
4608 protected virtual void OnLostFocus(EventArgs e) {
4609 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4614 [EditorBrowsable(EditorBrowsableState.Advanced)]
4615 protected virtual void OnMouseDown(MouseEventArgs e) {
4616 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4621 [EditorBrowsable(EditorBrowsableState.Advanced)]
4622 protected virtual void OnMouseEnter(EventArgs e) {
4623 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4628 [EditorBrowsable(EditorBrowsableState.Advanced)]
4629 protected virtual void OnMouseHover(EventArgs e) {
4630 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4635 [EditorBrowsable(EditorBrowsableState.Advanced)]
4636 protected virtual void OnMouseLeave(EventArgs e) {
4637 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4642 [EditorBrowsable(EditorBrowsableState.Advanced)]
4643 protected virtual void OnMouseMove(MouseEventArgs e) {
4644 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4649 [EditorBrowsable(EditorBrowsableState.Advanced)]
4650 protected virtual void OnMouseUp(MouseEventArgs e) {
4651 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4656 [EditorBrowsable(EditorBrowsableState.Advanced)]
4657 protected virtual void OnMouseWheel(MouseEventArgs e) {
4658 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4663 [EditorBrowsable(EditorBrowsableState.Advanced)]
4664 protected virtual void OnMove(EventArgs e) {
4665 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4670 [EditorBrowsable(EditorBrowsableState.Advanced)]
4671 protected virtual void OnNotifyMessage(Message m) {
4675 [EditorBrowsable(EditorBrowsableState.Advanced)]
4676 protected virtual void OnPaint(PaintEventArgs e) {
4677 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4682 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4686 internal virtual void OnPaintInternal(PaintEventArgs e) {
4690 internal virtual void OnGotFocusInternal (EventArgs e)
4695 internal virtual void OnLostFocusInternal (EventArgs e)
4700 [EditorBrowsable(EditorBrowsableState.Advanced)]
4701 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4702 PaintControlBackground (pevent);
4705 [EditorBrowsable(EditorBrowsableState.Advanced)]
4706 protected virtual void OnParentBackColorChanged(EventArgs e) {
4707 if (background_color.IsEmpty && background_image==null) {
4709 OnBackColorChanged(e);
4713 [EditorBrowsable(EditorBrowsableState.Advanced)]
4714 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4715 if (background_color.IsEmpty && background_image==null) {
4717 OnBackgroundImageChanged(e);
4721 [EditorBrowsable(EditorBrowsableState.Advanced)]
4722 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4723 if (binding_context==null) {
4724 binding_context=Parent.binding_context;
4725 OnBindingContextChanged(e);
4729 [EditorBrowsable(EditorBrowsableState.Advanced)]
4730 protected virtual void OnParentChanged(EventArgs e) {
4731 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4736 [EditorBrowsable(EditorBrowsableState.Advanced)]
4737 protected virtual void OnParentEnabledChanged(EventArgs e) {
4739 OnEnabledChanged(e);
4743 [EditorBrowsable(EditorBrowsableState.Advanced)]
4744 protected virtual void OnParentFontChanged(EventArgs e) {
4751 [EditorBrowsable(EditorBrowsableState.Advanced)]
4752 protected virtual void OnParentForeColorChanged(EventArgs e) {
4753 if (foreground_color.IsEmpty) {
4755 OnForeColorChanged(e);
4759 [EditorBrowsable(EditorBrowsableState.Advanced)]
4760 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4761 if (right_to_left==RightToLeft.Inherit) {
4763 OnRightToLeftChanged(e);
4767 [EditorBrowsable(EditorBrowsableState.Advanced)]
4768 protected virtual void OnParentVisibleChanged(EventArgs e) {
4770 OnVisibleChanged(e);
4774 [EditorBrowsable(EditorBrowsableState.Advanced)]
4775 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4776 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4781 [EditorBrowsable(EditorBrowsableState.Advanced)]
4782 protected virtual void OnResize(EventArgs e) {
4783 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4787 PerformLayout(this, "bounds");
4789 if (parent != null) {
4790 parent.PerformLayout();
4794 [EditorBrowsable(EditorBrowsableState.Advanced)]
4795 protected virtual void OnRightToLeftChanged(EventArgs e) {
4796 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4799 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4802 [EditorBrowsable(EditorBrowsableState.Advanced)]
4803 protected virtual void OnSizeChanged(EventArgs e) {
4804 DisposeBackBuffer ();
4806 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4811 [EditorBrowsable(EditorBrowsableState.Advanced)]
4812 protected virtual void OnStyleChanged(EventArgs e) {
4813 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4818 [EditorBrowsable(EditorBrowsableState.Advanced)]
4819 protected virtual void OnSystemColorsChanged(EventArgs e) {
4820 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4825 [EditorBrowsable(EditorBrowsableState.Advanced)]
4826 protected virtual void OnTabIndexChanged(EventArgs e) {
4827 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4832 [EditorBrowsable(EditorBrowsableState.Advanced)]
4833 protected virtual void OnTabStopChanged(EventArgs e) {
4834 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4839 [EditorBrowsable(EditorBrowsableState.Advanced)]
4840 protected virtual void OnTextChanged(EventArgs e) {
4841 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4846 [EditorBrowsable(EditorBrowsableState.Advanced)]
4847 protected virtual void OnValidated(EventArgs e) {
4848 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4853 [EditorBrowsable(EditorBrowsableState.Advanced)]
4854 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4855 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4860 [EditorBrowsable(EditorBrowsableState.Advanced)]
4861 protected virtual void OnVisibleChanged(EventArgs e) {
4862 if ((parent != null) && !Created && Visible) {
4869 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4873 // We need to tell our kids
4874 for (int i=0; i<child_controls.Count; i++) {
4875 if (child_controls[i].Visible) {
4876 child_controls[i].OnParentVisibleChanged(e);
4880 #endregion // OnXXX methods
4883 static object BackColorChangedEvent = new object ();
4884 static object BackgroundImageChangedEvent = new object ();
4885 static object BindingContextChangedEvent = new object ();
4886 static object CausesValidationChangedEvent = new object ();
4887 static object ChangeUICuesEvent = new object ();
4888 static object ClickEvent = new object ();
4889 static object ContextMenuChangedEvent = new object ();
4890 static object ControlAddedEvent = new object ();
4891 static object ControlRemovedEvent = new object ();
4892 static object CursorChangedEvent = new object ();
4893 static object DockChangedEvent = new object ();
4894 static object DoubleClickEvent = new object ();
4895 static object DragDropEvent = new object ();
4896 static object DragEnterEvent = new object ();
4897 static object DragLeaveEvent = new object ();
4898 static object DragOverEvent = new object ();
4899 static object EnabledChangedEvent = new object ();
4900 static object EnterEvent = new object ();
4901 static object FontChangedEvent = new object ();
4902 static object ForeColorChangedEvent = new object ();
4903 static object GiveFeedbackEvent = new object ();
4904 static object GotFocusEvent = new object ();
4905 static object HandleCreatedEvent = new object ();
4906 static object HandleDestroyedEvent = new object ();
4907 static object HelpRequestedEvent = new object ();
4908 static object ImeModeChangedEvent = new object ();
4909 static object InvalidatedEvent = new object ();
4910 static object KeyDownEvent = new object ();
4911 static object KeyPressEvent = new object ();
4912 static object KeyUpEvent = new object ();
4913 static object LayoutEvent = new object ();
4914 static object LeaveEvent = new object ();
4915 static object LocationChangedEvent = new object ();
4916 static object LostFocusEvent = new object ();
4917 static object MouseDownEvent = new object ();
4918 static object MouseEnterEvent = new object ();
4919 static object MouseHoverEvent = new object ();
4920 static object MouseLeaveEvent = new object ();
4921 static object MouseMoveEvent = new object ();
4922 static object MouseUpEvent = new object ();
4923 static object MouseWheelEvent = new object ();
4924 static object MoveEvent = new object ();
4925 static object PaintEvent = new object ();
4926 static object ParentChangedEvent = new object ();
4927 static object QueryAccessibilityHelpEvent = new object ();
4928 static object QueryContinueDragEvent = new object ();
4929 static object ResizeEvent = new object ();
4930 static object RightToLeftChangedEvent = new object ();
4931 static object SizeChangedEvent = new object ();
4932 static object StyleChangedEvent = new object ();
4933 static object SystemColorsChangedEvent = new object ();
4934 static object TabIndexChangedEvent = new object ();
4935 static object TabStopChangedEvent = new object ();
4936 static object TextChangedEvent = new object ();
4937 static object ValidatedEvent = new object ();
4938 static object ValidatingEvent = new object ();
4939 static object VisibleChangedEvent = new object ();
4941 public event EventHandler BackColorChanged {
4942 add { Events.AddHandler (BackColorChangedEvent, value); }
4943 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4946 public event EventHandler BackgroundImageChanged {
4947 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4948 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4951 public event EventHandler BindingContextChanged {
4952 add { Events.AddHandler (BindingContextChangedEvent, value); }
4953 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4956 public event EventHandler CausesValidationChanged {
4957 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4958 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4961 public event UICuesEventHandler ChangeUICues {
4962 add { Events.AddHandler (ChangeUICuesEvent, value); }
4963 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4966 public event EventHandler Click {
4967 add { Events.AddHandler (ClickEvent, value); }
4968 remove { Events.RemoveHandler (ClickEvent, value); }
4971 public event EventHandler ContextMenuChanged {
4972 add { Events.AddHandler (ContextMenuChangedEvent, value); }
4973 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
4976 [EditorBrowsable(EditorBrowsableState.Advanced)]
4978 public event ControlEventHandler ControlAdded {
4979 add { Events.AddHandler (ControlAddedEvent, value); }
4980 remove { Events.RemoveHandler (ControlAddedEvent, value); }
4983 [EditorBrowsable(EditorBrowsableState.Advanced)]
4985 public event ControlEventHandler ControlRemoved {
4986 add { Events.AddHandler (ControlRemovedEvent, value); }
4987 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
4990 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4991 public event EventHandler CursorChanged {
4992 add { Events.AddHandler (CursorChangedEvent, value); }
4993 remove { Events.RemoveHandler (CursorChangedEvent, value); }
4995 public event EventHandler DockChanged {
4996 add { Events.AddHandler (DockChangedEvent, value); }
4997 remove { Events.RemoveHandler (DockChangedEvent, value); }
5000 public event EventHandler DoubleClick {
5001 add { Events.AddHandler (DoubleClickEvent, value); }
5002 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5005 public event DragEventHandler DragDrop {
5006 add { Events.AddHandler (DragDropEvent, value); }
5007 remove { Events.RemoveHandler (DragDropEvent, value); }
5010 public event DragEventHandler DragEnter {
5011 add { Events.AddHandler (DragEnterEvent, value); }
5012 remove { Events.RemoveHandler (DragEnterEvent, value); }
5015 public event EventHandler DragLeave {
5016 add { Events.AddHandler (DragLeaveEvent, value); }
5017 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5020 public event DragEventHandler DragOver {
5021 add { Events.AddHandler (DragOverEvent, value); }
5022 remove { Events.RemoveHandler (DragOverEvent, value); }
5025 public event EventHandler EnabledChanged {
5026 add { Events.AddHandler (EnabledChangedEvent, value); }
5027 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5030 public event EventHandler Enter {
5031 add { Events.AddHandler (EnterEvent, value); }
5032 remove { Events.RemoveHandler (EnterEvent, value); }
5035 public event EventHandler FontChanged {
5036 add { Events.AddHandler (FontChangedEvent, value); }
5037 remove { Events.RemoveHandler (FontChangedEvent, value); }
5040 public event EventHandler ForeColorChanged {
5041 add { Events.AddHandler (ForeColorChangedEvent, value); }
5042 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5045 public event GiveFeedbackEventHandler GiveFeedback {
5046 add { Events.AddHandler (GiveFeedbackEvent, value); }
5047 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5050 [EditorBrowsable(EditorBrowsableState.Advanced)]
5052 public event EventHandler GotFocus {
5053 add { Events.AddHandler (GotFocusEvent, value); }
5054 remove { Events.RemoveHandler (GotFocusEvent, value); }
5058 [EditorBrowsable(EditorBrowsableState.Advanced)]
5060 public event EventHandler HandleCreated {
5061 add { Events.AddHandler (HandleCreatedEvent, value); }
5062 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5065 [EditorBrowsable(EditorBrowsableState.Advanced)]
5067 public event EventHandler HandleDestroyed {
5068 add { Events.AddHandler (HandleDestroyedEvent, value); }
5069 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5072 public event HelpEventHandler HelpRequested {
5073 add { Events.AddHandler (HelpRequestedEvent, value); }
5074 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5077 public event EventHandler ImeModeChanged {
5078 add { Events.AddHandler (ImeModeChangedEvent, value); }
5079 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5082 [EditorBrowsable(EditorBrowsableState.Advanced)]
5084 public event InvalidateEventHandler Invalidated {
5085 add { Events.AddHandler (InvalidatedEvent, value); }
5086 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5089 public event KeyEventHandler KeyDown {
5090 add { Events.AddHandler (KeyDownEvent, value); }
5091 remove { Events.RemoveHandler (KeyDownEvent, value); }
5094 public event KeyPressEventHandler KeyPress {
5095 add { Events.AddHandler (KeyPressEvent, value); }
5096 remove { Events.RemoveHandler (KeyPressEvent, value); }
5099 public event KeyEventHandler KeyUp {
5100 add { Events.AddHandler (KeyUpEvent, value); }
5101 remove { Events.RemoveHandler (KeyUpEvent, value); }
5104 public event LayoutEventHandler Layout {
5105 add { Events.AddHandler (LayoutEvent, value); }
5106 remove { Events.RemoveHandler (LayoutEvent, value); }
5109 public event EventHandler Leave {
5110 add { Events.AddHandler (LeaveEvent, value); }
5111 remove { Events.RemoveHandler (LeaveEvent, value); }
5114 public event EventHandler LocationChanged {
5115 add { Events.AddHandler (LocationChangedEvent, value); }
5116 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5119 [EditorBrowsable(EditorBrowsableState.Advanced)]
5121 public event EventHandler LostFocus {
5122 add { Events.AddHandler (LostFocusEvent, value); }
5123 remove { Events.RemoveHandler (LostFocusEvent, value); }
5126 public event MouseEventHandler MouseDown {
5127 add { Events.AddHandler (MouseDownEvent, value); }
5128 remove { Events.RemoveHandler (MouseDownEvent, value); }
5131 public event EventHandler MouseEnter {
5132 add { Events.AddHandler (MouseEnterEvent, value); }
5133 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5136 public event EventHandler MouseHover {
5137 add { Events.AddHandler (MouseHoverEvent, value); }
5138 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5141 public event EventHandler MouseLeave {
5142 add { Events.AddHandler (MouseLeaveEvent, value); }
5143 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5146 public event MouseEventHandler MouseMove {
5147 add { Events.AddHandler (MouseMoveEvent, value); }
5148 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5151 public event MouseEventHandler MouseUp {
5152 add { Events.AddHandler (MouseUpEvent, value); }
5153 remove { Events.RemoveHandler (MouseUpEvent, value); }
5156 [EditorBrowsable(EditorBrowsableState.Advanced)]
5158 public event MouseEventHandler MouseWheel {
5159 add { Events.AddHandler (MouseWheelEvent, value); }
5160 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5163 public event EventHandler Move {
5164 add { Events.AddHandler (MoveEvent, value); }
5165 remove { Events.RemoveHandler (MoveEvent, value); }
5168 public event PaintEventHandler Paint {
5169 add { Events.AddHandler (PaintEvent, value); }
5170 remove { Events.RemoveHandler (PaintEvent, value); }
5173 public event EventHandler ParentChanged {
5174 add { Events.AddHandler (ParentChangedEvent, value); }
5175 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5178 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5179 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5180 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5183 public event QueryContinueDragEventHandler QueryContinueDrag {
5184 add { Events.AddHandler (QueryContinueDragEvent, value); }
5185 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5188 public event EventHandler Resize {
5189 add { Events.AddHandler (ResizeEvent, value); }
5190 remove { Events.RemoveHandler (ResizeEvent, value); }
5193 public event EventHandler RightToLeftChanged {
5194 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5195 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5198 public event EventHandler SizeChanged {
5199 add { Events.AddHandler (SizeChangedEvent, value); }
5200 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5203 public event EventHandler StyleChanged {
5204 add { Events.AddHandler (StyleChangedEvent, value); }
5205 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5208 public event EventHandler SystemColorsChanged {
5209 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5210 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5213 public event EventHandler TabIndexChanged {
5214 add { Events.AddHandler (TabIndexChangedEvent, value); }
5215 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5218 public event EventHandler TabStopChanged {
5219 add { Events.AddHandler (TabStopChangedEvent, value); }
5220 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5223 public event EventHandler TextChanged {
5224 add { Events.AddHandler (TextChangedEvent, value); }
5225 remove { Events.RemoveHandler (TextChangedEvent, value); }
5228 public event EventHandler Validated {
5229 add { Events.AddHandler (ValidatedEvent, value); }
5230 remove { Events.RemoveHandler (ValidatedEvent, value); }
5233 public event CancelEventHandler Validating {
5234 add { Events.AddHandler (ValidatingEvent, value); }
5235 remove { Events.RemoveHandler (ValidatingEvent, value); }
5238 public event EventHandler VisibleChanged {
5239 add { Events.AddHandler (VisibleChangedEvent, value); }
5240 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5243 #endregion // Events