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);
1644 [EditorBrowsable(EditorBrowsableState.Advanced)]
1646 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1647 public virtual BindingContext BindingContext {
1649 if (binding_context != null)
1650 return binding_context;
1653 binding_context = Parent.BindingContext;
1654 return binding_context;
1657 if (binding_context != value) {
1658 binding_context = value;
1659 OnBindingContextChanged(EventArgs.Empty);
1664 [EditorBrowsable(EditorBrowsableState.Advanced)]
1666 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1669 return bounds.Y+bounds.Height;
1673 [EditorBrowsable(EditorBrowsableState.Advanced)]
1675 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1676 public Rectangle Bounds {
1682 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1686 [EditorBrowsable(EditorBrowsableState.Advanced)]
1688 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1689 public bool CanFocus {
1691 if (IsHandleCreated && Visible && Enabled) {
1698 [EditorBrowsable(EditorBrowsableState.Advanced)]
1700 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1701 public bool CanSelect {
1705 if (!GetStyle(ControlStyles.Selectable)) {
1710 while (parent != null) {
1711 if (!parent.is_visible || !parent.is_enabled) {
1715 parent = parent.parent;
1721 internal virtual bool InternalCapture {
1731 [EditorBrowsable(EditorBrowsableState.Advanced)]
1733 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1734 public bool Capture {
1736 return this.is_captured;
1740 if (this.IsHandleCreated && value != is_captured) {
1743 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1745 XplatUI.UngrabWindow(this.window.Handle);
1746 is_captured = false;
1752 [DefaultValue(true)]
1753 [MWFCategory("Focus")]
1754 public bool CausesValidation {
1756 return this.causes_validation;
1760 if (this.causes_validation != value) {
1761 causes_validation = value;
1762 OnCausesValidationChanged(EventArgs.Empty);
1767 [EditorBrowsable(EditorBrowsableState.Advanced)]
1769 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1770 public Rectangle ClientRectangle {
1772 client_rect.Width = client_size.Width;
1773 client_rect.Height = client_size.Height;
1778 [EditorBrowsable(EditorBrowsableState.Advanced)]
1780 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1781 public Size ClientSize {
1784 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1785 return ((Form)this).form_parent_window.ClientSize;
1793 this.SetClientSizeCore(value.Width, value.Height);
1797 [EditorBrowsable(EditorBrowsableState.Advanced)]
1799 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1800 [DescriptionAttribute("ControlCompanyNameDescr")]
1801 public String CompanyName {
1803 return "Mono Project, Novell, Inc.";
1807 [EditorBrowsable(EditorBrowsableState.Advanced)]
1809 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1810 public bool ContainsFocus {
1812 IntPtr focused_window;
1814 focused_window = XplatUI.GetFocus();
1815 if (IsHandleCreated) {
1816 if (focused_window == Handle) {
1820 for (int i=0; i < child_controls.Count; i++) {
1821 if (child_controls[i].ContainsFocus) {
1830 [DefaultValue(null)]
1831 [MWFCategory("Behavior")]
1832 public virtual ContextMenu ContextMenu {
1834 return context_menu;
1838 if (context_menu != value) {
1839 context_menu = value;
1840 OnContextMenuChanged(EventArgs.Empty);
1846 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1847 public ControlCollection Controls {
1849 return this.child_controls;
1853 [EditorBrowsable(EditorBrowsableState.Advanced)]
1855 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1856 public bool Created {
1858 return (!is_disposed && is_created);
1862 [AmbientValue(null)]
1863 [MWFCategory("Appearance")]
1864 public virtual Cursor Cursor {
1866 if (cursor != null) {
1870 if (parent != null) {
1871 return parent.Cursor;
1874 return Cursors.Default;
1878 if (cursor != value) {
1883 if (IsHandleCreated) {
1884 pt = Cursor.Position;
1886 if (bounds.Contains(pt) || Capture) {
1887 if (GetChildAtPoint(pt) == null) {
1888 if (cursor != null) {
1889 XplatUI.SetCursor(window.Handle, cursor.handle);
1891 if (parent != null) {
1892 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1894 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1901 OnCursorChanged(EventArgs.Empty);
1907 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1908 [ParenthesizePropertyName(true)]
1909 [RefreshProperties(RefreshProperties.All)]
1910 [MWFCategory("Data")]
1911 public ControlBindingsCollection DataBindings {
1913 if (data_bindings == null)
1914 data_bindings = new ControlBindingsCollection (this);
1915 return data_bindings;
1919 [EditorBrowsable(EditorBrowsableState.Advanced)]
1921 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1922 public virtual Rectangle DisplayRectangle {
1924 return ClientRectangle;
1928 [EditorBrowsable(EditorBrowsableState.Advanced)]
1930 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1931 public bool Disposing {
1938 [RefreshProperties(RefreshProperties.Repaint)]
1939 [DefaultValue(DockStyle.None)]
1940 [MWFCategory("Layout")]
1941 public virtual DockStyle Dock {
1947 if (dock_style == value) {
1953 if (dock_style == DockStyle.None) {
1954 if (explicit_bounds == Rectangle.Empty)
1955 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1957 Bounds = explicit_bounds;
1960 if (parent != null) {
1961 parent.PerformLayout(this, "Parent");
1964 OnDockChanged(EventArgs.Empty);
1970 [MWFCategory("Behavior")]
1971 public bool Enabled {
1977 if (parent != null) {
1978 return parent.Enabled;
1986 bool old_value = is_enabled;
1989 if (old_value != value && !value && this.has_focus)
1990 SelectNextControl(this, true, true, true, true);
1992 OnEnabledChanged (EventArgs.Empty);
1996 [EditorBrowsable(EditorBrowsableState.Advanced)]
1998 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1999 public virtual bool Focused {
2001 return this.has_focus;
2006 [AmbientValue(null)]
2008 [MWFCategory("Appearance")]
2009 public virtual Font Font {
2015 if (Parent != null && Parent.Font != null) {
2022 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2024 if (font != null && font.Equals (value)) {
2030 OnFontChanged (EventArgs.Empty);
2035 [MWFCategory("Appearance")]
2036 public virtual Color ForeColor {
2038 if (foreground_color.IsEmpty) {
2040 return parent.ForeColor;
2042 return DefaultForeColor;
2044 return foreground_color;
2048 if (foreground_color != value) {
2049 foreground_color=value;
2051 OnForeColorChanged(EventArgs.Empty);
2058 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2059 public IntPtr Handle { // IWin32Window
2062 if (verify_thread_handle) {
2063 if (this.InvokeRequired) {
2064 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2068 if (!IsHandleCreated) {
2071 return window.Handle;
2075 [EditorBrowsable(EditorBrowsableState.Advanced)]
2077 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2078 public bool HasChildren {
2080 if (this.child_controls.Count>0) {
2087 [EditorBrowsable(EditorBrowsableState.Always)]
2089 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2092 return this.bounds.Height;
2096 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2100 [AmbientValue(ImeMode.Inherit)]
2102 [MWFCategory("Behavior")]
2103 public ImeMode ImeMode {
2105 if (ime_mode == ImeMode.Inherit) {
2107 return parent.ImeMode;
2109 return ImeMode.NoControl; // default value
2115 if (ime_mode != value) {
2118 OnImeModeChanged(EventArgs.Empty);
2123 [EditorBrowsable(EditorBrowsableState.Advanced)]
2125 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2126 public bool InvokeRequired { // ISynchronizeInvoke
2128 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2135 [EditorBrowsable(EditorBrowsableState.Advanced)]
2137 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2138 public bool IsAccessible {
2140 return is_accessible;
2144 is_accessible = value;
2148 [EditorBrowsable(EditorBrowsableState.Advanced)]
2150 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2151 public bool IsDisposed {
2153 return this.is_disposed;
2157 [EditorBrowsable(EditorBrowsableState.Advanced)]
2159 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2160 public bool IsHandleCreated {
2162 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2163 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2164 if (hwnd != null && !hwnd.zombie)
2173 public virtual Layout.LayoutEngine LayoutEngine {
2174 get { return new Layout.DefaultLayout (); }
2178 [EditorBrowsable(EditorBrowsableState.Always)]
2180 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2183 return this.bounds.X;
2187 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2192 [MWFCategory("Layout")]
2193 public Point Location {
2195 return new Point(bounds.X, bounds.Y);
2199 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2204 [Localizable (true)]
2205 public Padding Margin {
2206 get { return this.margin; }
2207 set { this.margin = value; }
2212 public string Name {
2224 public Padding Padding {
2236 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2237 public Control Parent {
2243 if (value == this) {
2244 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2247 if (parent!=value) {
2249 parent.Controls.Remove(this);
2254 value.Controls.Add(this);
2259 [EditorBrowsable(EditorBrowsableState.Advanced)]
2261 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2262 public string ProductName {
2264 Type t = typeof (AssemblyProductAttribute);
2265 Assembly assembly = GetType().Module.Assembly;
2266 object [] attrs = assembly.GetCustomAttributes (t, false);
2267 AssemblyProductAttribute a = null;
2268 // On MS we get a NullRefException if product attribute is not
2270 if (attrs != null && attrs.Length > 0)
2271 a = (AssemblyProductAttribute) attrs [0];
2276 [EditorBrowsable(EditorBrowsableState.Advanced)]
2278 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2279 public string ProductVersion {
2281 Type t = typeof (AssemblyVersionAttribute);
2282 Assembly assembly = GetType().Module.Assembly;
2283 object [] attrs = assembly.GetCustomAttributes (t, false);
2284 if (attrs == null || attrs.Length < 1)
2286 return ((AssemblyVersionAttribute)attrs [0]).Version;
2290 [EditorBrowsable(EditorBrowsableState.Advanced)]
2292 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2293 public bool RecreatingHandle {
2295 return is_recreating;
2299 [EditorBrowsable(EditorBrowsableState.Advanced)]
2301 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2302 public Region Region {
2308 if (IsHandleCreated) {
2309 XplatUI.SetClipRegion(Handle, value);
2311 clip_region = value;
2315 [EditorBrowsable(EditorBrowsableState.Advanced)]
2317 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2320 return this.bounds.X+this.bounds.Width;
2324 [AmbientValue(RightToLeft.Inherit)]
2326 [MWFCategory("Appearance")]
2327 public virtual RightToLeft RightToLeft {
2329 if (right_to_left == RightToLeft.Inherit) {
2331 return parent.RightToLeft;
2333 return RightToLeft.No; // default value
2335 return right_to_left;
2339 if (value != right_to_left) {
2340 right_to_left = value;
2341 OnRightToLeftChanged(EventArgs.Empty);
2346 [EditorBrowsable(EditorBrowsableState.Advanced)]
2347 public override ISite Site {
2355 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2357 BackColor = ap.BackColor;
2358 ForeColor = ap.ForeColor;
2366 [MWFCategory("Layout")]
2369 return new Size(Width, Height);
2373 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2378 [MergableProperty(false)]
2379 [MWFCategory("Behavior")]
2380 public int TabIndex {
2382 if (tab_index != -1) {
2389 if (tab_index != value) {
2391 OnTabIndexChanged(EventArgs.Empty);
2397 [DefaultValue(true)]
2398 [MWFCategory("Behavior")]
2399 public bool TabStop {
2405 if (tab_stop != value) {
2407 OnTabStopChanged(EventArgs.Empty);
2412 [Localizable(false)]
2414 [TypeConverter(typeof(StringConverter))]
2415 [DefaultValue(null)]
2416 [MWFCategory("Data")]
2423 control_tag = value;
2429 [BindableAttribute(true)]
2430 [MWFCategory("Appearance")]
2431 public virtual string Text {
2433 // Our implementation ignores ControlStyles.CacheText - we always cache
2438 if (value == null) {
2439 value = String.Empty;
2444 if (IsHandleCreated) {
2445 /* we need to call .SetWindowStyle here instead of just .Text
2446 because the presence/absence of Text (== "" or not) can cause
2447 other window style things to appear/disappear */
2448 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2449 XplatUI.Text(Handle, text);
2451 OnTextChanged (EventArgs.Empty);
2456 [EditorBrowsable(EditorBrowsableState.Always)]
2458 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2461 return this.bounds.Y;
2465 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2469 [EditorBrowsable(EditorBrowsableState.Advanced)]
2471 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2472 public Control TopLevelControl {
2476 while (p.parent != null) {
2480 return p is Form ? p : null;
2485 [MWFCategory("Behavior")]
2486 public bool Visible {
2490 } else if (parent != null) {
2491 return parent.Visible;
2498 SetVisibleCore(value);
2502 [EditorBrowsable(EditorBrowsableState.Always)]
2504 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2507 return this.bounds.Width;
2511 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2515 [EditorBrowsable(EditorBrowsableState.Never)]
2517 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2518 public IWindowTarget WindowTarget {
2527 #endregion // Public Instance Properties
2529 #region Protected Instance Properties
2530 protected virtual CreateParams CreateParams {
2532 CreateParams create_params = new CreateParams();
2535 create_params.Caption = Text;
2538 create_params.Caption = text;
2542 create_params.X = Left;
2545 create_params.X = this.bounds.X;
2549 create_params.Y = Top;
2552 create_params.Y = this.bounds.Y;
2556 create_params.Width = Width;
2559 create_params.Width = this.bounds.Width;
2563 create_params.Height = Height;
2566 create_params.Height = this.bounds.Height;
2570 create_params.ClassName = XplatUI.DefaultClassName;
2571 create_params.ClassStyle = 0;
2572 create_params.ExStyle = 0;
2573 create_params.Param = 0;
2576 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2579 if ((parent!=null) && (parent.IsHandleCreated)) {
2580 create_params.Parent = parent.Handle;
2583 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2586 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2590 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2593 switch (border_style) {
2594 case BorderStyle.FixedSingle:
2595 create_params.Style |= (int) WindowStyles.WS_BORDER;
2597 case BorderStyle.Fixed3D:
2598 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2602 return create_params;
2606 protected virtual ImeMode DefaultImeMode {
2608 return ImeMode.Inherit;
2613 protected virtual Padding DefaultMargin {
2614 get { return new Padding (3); }
2618 protected virtual Size DefaultSize {
2620 return new Size(0, 0);
2624 protected int FontHeight {
2634 protected bool RenderRightToLeft {
2636 return (this.right_to_left == RightToLeft.Yes);
2640 protected bool ResizeRedraw {
2642 return GetStyle(ControlStyles.ResizeRedraw);
2646 SetStyle(ControlStyles.ResizeRedraw, value);
2650 [EditorBrowsable(EditorBrowsableState.Advanced)]
2652 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2653 protected virtual bool ShowFocusCues {
2659 [EditorBrowsable(EditorBrowsableState.Advanced)]
2661 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2662 protected bool ShowKeyboardCues {
2667 #endregion // Protected Instance Properties
2669 #region Public Static Methods
2670 [EditorBrowsable(EditorBrowsableState.Advanced)]
2671 public static Control FromChildHandle(IntPtr handle) {
2672 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2675 [EditorBrowsable(EditorBrowsableState.Advanced)]
2676 public static Control FromHandle(IntPtr handle) {
2677 return Control.ControlNativeWindow.ControlFromHandle(handle);
2680 public static bool IsMnemonic(char charCode, string text) {
2683 amp = text.IndexOf('&');
2686 if (amp + 1 < text.Length) {
2687 if (text[amp + 1] != '&') {
2688 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2698 #region Protected Static Methods
2699 [EditorBrowsable(EditorBrowsableState.Advanced)]
2700 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2703 c = Control.FromHandle(hWnd);
2713 #region Public Instance Methods
2714 [EditorBrowsable(EditorBrowsableState.Advanced)]
2715 public IAsyncResult BeginInvoke(Delegate method) {
2716 object [] prms = null;
2717 if (method is EventHandler)
2718 prms = new object [] { this, EventArgs.Empty };
2719 return BeginInvokeInternal(method, prms, false);
2722 [EditorBrowsable(EditorBrowsableState.Advanced)]
2723 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2724 return BeginInvokeInternal (method, args, false);
2727 public void BringToFront() {
2728 if (parent != null) {
2729 parent.child_controls.SetChildIndex(this, 0);
2732 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2736 public bool Contains(Control ctl) {
2737 while (ctl != null) {
2746 public void CreateControl() {
2748 throw new ObjectDisposedException(GetType().FullName.ToString());
2754 if (!IsHandleCreated) {
2762 Control [] controls = child_controls.GetAllControls ();
2763 for (int i=0; i<controls.Length; i++) {
2764 controls [i].CreateControl ();
2767 UpdateChildrenZOrder();
2769 if (binding_context == null) { // seem to be sent whenever it's null?
2770 OnBindingContextChanged(EventArgs.Empty);
2776 public Graphics CreateGraphics() {
2777 if (!IsHandleCreated) {
2778 this.CreateHandle();
2780 return Graphics.FromHwnd(this.window.Handle);
2783 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2784 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2787 [EditorBrowsable(EditorBrowsableState.Advanced)]
2788 public object EndInvoke (IAsyncResult async_result) {
2789 AsyncMethodResult result = (AsyncMethodResult) async_result;
2790 return result.EndInvoke ();
2793 public Form FindForm() {
2806 public bool Focus() {
2807 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2810 is_focusing = false;
2815 public Control GetChildAtPoint(Point pt) {
2816 // Microsoft's version of this function doesn't seem to work, so I can't check
2817 // if we only consider children or also grandchildren, etc.
2818 // I'm gonna say 'children only'
2819 for (int i=0; i<child_controls.Count; i++) {
2820 if (child_controls[i].Bounds.Contains(pt)) {
2821 return child_controls[i];
2827 public IContainerControl GetContainerControl() {
2828 Control current = this;
2830 while (current!=null) {
2831 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2832 return (IContainerControl)current;
2834 current = current.parent;
2839 public Control GetNextControl(Control ctl, bool forward) {
2841 if (!this.Contains(ctl)) {
2846 ctl = FindControlForward(this, ctl);
2849 ctl = FindControlBackward(this, ctl);
2859 public virtual Size GetPreferredSize (Size proposedSize) {
2860 return preferred_size;
2864 public void Hide() {
2865 this.Visible = false;
2868 public void Invalidate() {
2869 Invalidate(ClientRectangle, false);
2872 public void Invalidate(bool invalidateChildren) {
2873 Invalidate(ClientRectangle, invalidateChildren);
2876 public void Invalidate(System.Drawing.Rectangle rc) {
2877 Invalidate(rc, false);
2880 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2881 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2885 NotifyInvalidate(rc);
2887 XplatUI.Invalidate(Handle, rc, false);
2889 if (invalidateChildren) {
2890 Control [] controls = child_controls.GetAllControls ();
2891 for (int i=0; i<controls.Length; i++)
2892 controls [i].Invalidate ();
2894 OnInvalidated(new InvalidateEventArgs(rc));
2897 public void Invalidate(System.Drawing.Region region) {
2898 Invalidate(region, false);
2901 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2902 RectangleF bounds = region.GetBounds (CreateGraphics ());
2903 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2904 invalidateChildren);
2907 public object Invoke (Delegate method) {
2908 object [] prms = null;
2909 if (method is EventHandler)
2910 prms = new object [] { this, EventArgs.Empty };
2912 return Invoke(method, prms);
2915 public object Invoke (Delegate method, object[] args) {
2916 if (!this.InvokeRequired) {
2917 return method.DynamicInvoke(args);
2920 IAsyncResult result = BeginInvoke (method, args);
2921 return EndInvoke(result);
2924 internal object InvokeInternal (Delegate method, bool disposing) {
2925 return InvokeInternal(method, null, disposing);
2928 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2929 if (!this.InvokeRequired) {
2930 return method.DynamicInvoke(args);
2933 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2934 return EndInvoke(result);
2937 [EditorBrowsable(EditorBrowsableState.Advanced)]
2938 public void PerformLayout() {
2939 PerformLayout(null, null);
2943 private void SetImplicitBounds (int x, int y, int width, int height)
2945 Rectangle saved_bounds = explicit_bounds;
2946 SetBounds (x, y, width, height);
2947 explicit_bounds = saved_bounds;
2951 [EditorBrowsable(EditorBrowsableState.Advanced)]
2952 public void PerformLayout(Control affectedControl, string affectedProperty) {
2953 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2955 if (layout_suspended > 0) {
2956 layout_pending = true;
2960 layout_pending = false;
2962 // Prevent us from getting messed up
2965 // Perform all Dock and Anchor calculations
2969 this.layout_engine.Layout(this, levent);
2971 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2973 AnchorStyles anchor;
2976 space = DisplayRectangle;
2978 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2979 Control [] controls = child_controls.GetAllControls ();
2980 for (int i = controls.Length - 1; i >= 0; i--) {
2981 child = controls [i];
2983 if (!child.Visible) {
2987 switch (child.Dock) {
2988 case DockStyle.None: {
2993 case DockStyle.Left: {
2994 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
2995 space.X+=child.Width;
2996 space.Width-=child.Width;
3000 case DockStyle.Top: {
3001 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3002 space.Y+=child.Height;
3003 space.Height-=child.Height;
3007 case DockStyle.Right: {
3008 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3009 space.Width-=child.Width;
3013 case DockStyle.Bottom: {
3014 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3015 space.Height-=child.Height;
3021 for (int i = controls.Length - 1; i >= 0; i--) {
3024 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3025 if (child.Dock == DockStyle.Fill) {
3026 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3030 space = DisplayRectangle;
3032 for (int i=0; i < controls.Length; i++) {
3038 child = controls[i];
3040 // If the control is docked we don't need to do anything
3041 if (child.Dock != DockStyle.None) {
3045 anchor = child.Anchor;
3049 width = child.Width;
3050 height = child.Height;
3052 if ((anchor & AnchorStyles.Left) !=0 ) {
3053 if ((anchor & AnchorStyles.Right) != 0) {
3054 width = space.Width - child.dist_right - left;
3056 ; // Left anchored only, nothing to be done
3058 } else if ((anchor & AnchorStyles.Right) != 0) {
3059 left = space.Width - child.dist_right - width;
3061 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3062 // This calculates from scratch every time:
3063 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3066 if ((anchor & AnchorStyles.Top) !=0 ) {
3067 if ((anchor & AnchorStyles.Bottom) != 0) {
3068 height = space.Height - child.dist_bottom - top;
3070 ; // Top anchored only, nothing to be done
3072 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3073 top = space.Height - child.dist_bottom - height;
3075 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3076 // This calculates from scratch every time:
3077 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3089 child.SetImplicitBounds(left, top, width, height);
3093 // Let everyone know
3097 // Need to make sure we decremend layout_suspended
3103 public Point PointToClient (Point p) {
3107 XplatUI.ScreenToClient (Handle, ref x, ref y);
3109 return new Point (x, y);
3112 public Point PointToScreen(Point p) {
3116 XplatUI.ClientToScreen(Handle, ref x, ref y);
3118 return new Point(x, y);
3121 public virtual bool PreProcessMessage(ref Message msg) {
3122 return InternalPreProcessMessage (ref msg);
3125 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3128 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3129 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3131 if (!ProcessCmdKey(ref msg, key_data)) {
3132 if (IsInputKey(key_data)) {
3136 return ProcessDialogKey(key_data);
3140 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3141 if (IsInputChar((char)msg.WParam)) {
3144 return ProcessDialogChar((char)msg.WParam);
3145 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3146 return ProcessDialogChar((char)msg.WParam);
3151 public Rectangle RectangleToClient(Rectangle r) {
3152 return new Rectangle(PointToClient(r.Location), r.Size);
3155 public Rectangle RectangleToScreen(Rectangle r) {
3156 return new Rectangle(PointToScreen(r.Location), r.Size);
3159 public virtual void Refresh() {
3160 if (IsHandleCreated == true) {
3162 XplatUI.UpdateWindow(window.Handle);
3164 Control [] controls = child_controls.GetAllControls ();
3165 for (int i=0; i < controls.Length; i++) {
3166 controls[i].Refresh();
3172 [EditorBrowsable(EditorBrowsableState.Never)]
3173 public virtual void ResetBackColor() {
3174 BackColor = Color.Empty;
3177 [EditorBrowsable(EditorBrowsableState.Never)]
3178 public void ResetBindings() {
3179 data_bindings.Clear();
3182 [EditorBrowsable(EditorBrowsableState.Never)]
3183 public virtual void ResetCursor() {
3187 [EditorBrowsable(EditorBrowsableState.Never)]
3188 public virtual void ResetFont() {
3192 [EditorBrowsable(EditorBrowsableState.Never)]
3193 public virtual void ResetForeColor() {
3194 foreground_color = Color.Empty;
3197 [EditorBrowsable(EditorBrowsableState.Never)]
3198 public void ResetImeMode() {
3199 ime_mode = DefaultImeMode;
3202 [EditorBrowsable(EditorBrowsableState.Never)]
3203 public virtual void ResetRightToLeft() {
3204 right_to_left = RightToLeft.Inherit;
3207 public virtual void ResetText() {
3208 text = String.Empty;
3211 public void ResumeLayout() {
3212 ResumeLayout (true);
3215 public void ResumeLayout(bool performLayout) {
3216 if (layout_suspended > 0) {
3220 if (layout_suspended == 0) {
3221 Control [] controls = child_controls.GetAllControls ();
3222 for (int i=0; i<controls.Length; i++) {
3223 controls [i].UpdateDistances ();
3226 if (performLayout && layout_pending) {
3232 public void Scale(float ratio) {
3233 ScaleCore(ratio, ratio);
3236 public void Scale(float dx, float dy) {
3241 public void Scale(SizeF factor) {
3242 ScaleCore(factor.Width, factor.Height);
3246 public void Select() {
3247 Select(false, false);
3251 private void printTree(Control c, string t) {
3252 foreach(Control i in c.child_controls) {
3253 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3254 printTree(i, t+"\t");
3258 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3262 Console.WriteLine("{0}", this.FindForm());
3263 printTree(this, "\t");
3266 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3271 c = GetNextControl(c, forward);
3280 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3281 c.Select (true, true);
3284 } while (c != ctl); // If we wrap back to ourselves we stop
3289 public void SendToBack() {
3290 if (parent != null) {
3291 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3295 public void SetBounds(int x, int y, int width, int height) {
3296 SetBounds(x, y, width, height, BoundsSpecified.All);
3299 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3300 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3304 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3308 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3312 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3316 SetBoundsCore(x, y, width, height, specified);
3317 if (parent != null) {
3318 parent.PerformLayout(this, "Bounds");
3322 public void Show() {
3324 this.CreateControl();
3330 public void SuspendLayout() {
3334 public void Update() {
3335 if (IsHandleCreated) {
3336 XplatUI.UpdateWindow(window.Handle);
3339 #endregion // Public Instance Methods
3341 #region Protected Instance Methods
3342 [EditorBrowsable(EditorBrowsableState.Advanced)]
3343 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3344 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3345 throw new NotImplementedException();
3348 [EditorBrowsable(EditorBrowsableState.Advanced)]
3349 protected virtual AccessibleObject CreateAccessibilityInstance() {
3350 return new Control.ControlAccessibleObject(this);
3353 [EditorBrowsable(EditorBrowsableState.Advanced)]
3354 protected virtual ControlCollection CreateControlsInstance() {
3355 return new ControlCollection(this);
3358 [EditorBrowsable(EditorBrowsableState.Advanced)]
3359 protected virtual void CreateHandle() {
3361 throw new ObjectDisposedException(GetType().FullName.ToString());
3364 if (IsHandleCreated && !is_recreating) {
3368 window.CreateHandle(CreateParams);
3370 if (window.Handle != IntPtr.Zero) {
3371 creator_thread = Thread.CurrentThread;
3373 XplatUI.EnableWindow(window.Handle, is_enabled);
3374 XplatUI.SetVisible(window.Handle, is_visible, true);
3376 if (clip_region != null) {
3377 XplatUI.SetClipRegion(Handle, clip_region);
3380 // Set our handle with our parent
3381 if ((parent != null) && (parent.IsHandleCreated)) {
3382 XplatUI.SetParent(window.Handle, parent.Handle);
3385 // Set our handle as parent for our children
3386 Control [] children;
3388 children = child_controls.GetAllControls ();
3389 for (int i = 0; i < children.Length; i++ ) {
3390 if (!children[i].RecreatingHandle)
3391 XplatUI.SetParent(children[i].Handle, window.Handle);
3395 XplatUI.SetAllowDrop (Handle, allow_drop);
3397 // Find out where the window manager placed us
3398 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3399 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3403 OnHandleCreated(EventArgs.Empty);
3407 [EditorBrowsable(EditorBrowsableState.Advanced)]
3408 protected virtual void DefWndProc(ref Message m) {
3409 window.DefWndProc(ref m);
3412 [EditorBrowsable(EditorBrowsableState.Advanced)]
3413 protected virtual void DestroyHandle() {
3414 if (IsHandleCreated) {
3415 if (window != null) {
3416 window.DestroyHandle();
3421 protected internal bool GetStyle(ControlStyles flag) {
3422 return (control_style & flag) != 0;
3425 protected bool GetTopLevel() {
3429 [EditorBrowsable(EditorBrowsableState.Advanced)]
3430 protected virtual void InitLayout() {
3434 [EditorBrowsable(EditorBrowsableState.Advanced)]
3435 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3436 toInvoke.OnGotFocus(e);
3439 [EditorBrowsable(EditorBrowsableState.Advanced)]
3440 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3441 toInvoke.OnLostFocus(e);
3444 [EditorBrowsable(EditorBrowsableState.Advanced)]
3445 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3446 toInvoke.OnClick(e);
3449 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3450 toInvoke.OnPaint(e);
3453 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3454 toInvoke.OnPaintBackground(e);
3457 protected virtual bool IsInputChar (char charCode) {
3461 protected virtual bool IsInputKey (Keys keyData) {
3462 // Doc says this one calls IsInputChar; not sure what to do with that
3466 [EditorBrowsable(EditorBrowsableState.Advanced)]
3467 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3471 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3472 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3476 if (parent != null) {
3477 return parent.ProcessCmdKey(ref msg, keyData);
3483 protected virtual bool ProcessDialogChar(char charCode) {
3484 if (parent != null) {
3485 return parent.ProcessDialogChar (charCode);
3491 protected virtual bool ProcessDialogKey (Keys keyData) {
3492 if (parent != null) {
3493 return parent.ProcessDialogKey (keyData);
3499 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3501 KeyEventArgs key_event;
3504 case (int)Msg.WM_SYSKEYDOWN:
3505 case (int)Msg.WM_KEYDOWN: {
3506 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3507 OnKeyDown (key_event);
3508 return key_event.Handled;
3511 case (int)Msg.WM_SYSKEYUP:
3512 case (int)Msg.WM_KEYUP: {
3513 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3514 OnKeyUp (key_event);
3515 return key_event.Handled;
3518 case (int)Msg.WM_SYSCHAR:
3519 case (int)Msg.WM_CHAR: {
3520 KeyPressEventArgs key_press_event;
3522 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3523 OnKeyPress(key_press_event);
3525 msg.WParam = (IntPtr)key_press_event.KeyChar;
3527 return key_press_event.Handled;
3538 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3539 if (parent != null) {
3540 if (parent.ProcessKeyPreview(ref msg)) {
3545 return ProcessKeyEventArgs(ref msg);
3548 protected virtual bool ProcessKeyPreview(ref Message msg) {
3549 if (parent != null) {
3550 return parent.ProcessKeyPreview(ref msg);
3556 protected virtual bool ProcessMnemonic(char charCode) {
3561 [EditorBrowsable(EditorBrowsableState.Advanced)]
3562 protected void RaiseDragEvent(object key, DragEventArgs e) {
3566 [EditorBrowsable(EditorBrowsableState.Advanced)]
3567 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3571 [EditorBrowsable(EditorBrowsableState.Advanced)]
3572 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3576 [EditorBrowsable(EditorBrowsableState.Advanced)]
3577 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3581 private void SetIsRecreating ()
3585 foreach (Control c in Controls.GetAllControls()) {
3586 c.SetIsRecreating ();
3590 [EditorBrowsable(EditorBrowsableState.Advanced)]
3591 protected void RecreateHandle() {
3593 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3598 if (IsHandleCreated) {
3600 Console.WriteLine(" + handle is created, destroying it.");
3603 // WM_DESTROY will CreateHandle for us
3606 Console.WriteLine(" + handle is not created, creating it.");
3614 is_recreating = false;
3616 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3622 [EditorBrowsable(EditorBrowsableState.Advanced)]
3623 protected void ResetMouseEventArgs() {
3627 [EditorBrowsable(EditorBrowsableState.Advanced)]
3628 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3629 if (right_to_left == RightToLeft.No) {
3634 case ContentAlignment.TopLeft: {
3635 return ContentAlignment.TopRight;
3638 case ContentAlignment.TopRight: {
3639 return ContentAlignment.TopLeft;
3642 case ContentAlignment.MiddleLeft: {
3643 return ContentAlignment.MiddleRight;
3646 case ContentAlignment.MiddleRight: {
3647 return ContentAlignment.MiddleLeft;
3650 case ContentAlignment.BottomLeft: {
3651 return ContentAlignment.BottomRight;
3654 case ContentAlignment.BottomRight: {
3655 return ContentAlignment.BottomLeft;
3659 // if it's center it doesn't change
3665 [EditorBrowsable(EditorBrowsableState.Advanced)]
3666 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3667 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3671 if (align == HorizontalAlignment.Left) {
3672 return HorizontalAlignment.Right;
3675 // align must be HorizontalAlignment.Right
3676 return HorizontalAlignment.Left;
3679 [EditorBrowsable(EditorBrowsableState.Advanced)]
3680 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3681 if (right_to_left == RightToLeft.No) {
3685 if (align == LeftRightAlignment.Left) {
3686 return LeftRightAlignment.Right;
3689 // align must be LeftRightAlignment.Right;
3690 return LeftRightAlignment.Left;
3693 [EditorBrowsable(EditorBrowsableState.Advanced)]
3694 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3695 return RtlTranslateAlignment(align);
3698 [EditorBrowsable(EditorBrowsableState.Advanced)]
3699 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3700 return RtlTranslateAlignment(align);
3703 [EditorBrowsable(EditorBrowsableState.Advanced)]
3704 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3705 return RtlTranslateAlignment(align);
3708 [EditorBrowsable(EditorBrowsableState.Advanced)]
3709 protected virtual void ScaleCore(float dx, float dy) {
3715 location = new Point((int)(Left * dx), (int)(Top * dy));
3716 size = this.ClientSize;
3718 if (!GetStyle(ControlStyles.FixedWidth)) {
3719 size.Width = (int)(size.Width * dx);
3722 if (!GetStyle(ControlStyles.FixedHeight)) {
3723 size.Height = (int)(size.Height * dy);
3726 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3728 /* Now scale our children */
3729 Control [] controls = child_controls.GetAllControls ();
3730 for (int i=0; i < controls.Length; i++) {
3731 controls[i].Scale(dx, dy);
3737 protected virtual void Select(bool directed, bool forward) {
3738 IContainerControl container;
3740 container = GetContainerControl();
3741 if (container != null)
3742 container.ActiveControl = this;
3745 [EditorBrowsable(EditorBrowsableState.Advanced)]
3746 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3747 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3748 if (IsHandleCreated) {
3749 XplatUI.SetWindowPos(Handle, x, y, width, height);
3751 // Win32 automatically changes negative width/height to 0.
3752 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3753 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3755 if (width < 0 || height < 0) {
3757 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3761 UpdateBounds(x, y, width, height);
3766 [EditorBrowsable(EditorBrowsableState.Advanced)]
3767 protected virtual void SetClientSizeCore(int x, int y) {
3768 // Calculate the actual window size from the client size (it usually stays the same or grows)
3769 Rectangle ClientRect;
3770 Rectangle WindowRect;
3773 ClientRect = new Rectangle(0, 0, x, y);
3774 cp = this.CreateParams;
3776 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3780 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3783 [EditorBrowsable(EditorBrowsableState.Advanced)]
3784 protected internal void SetStyle(ControlStyles flag, bool value) {
3786 control_style |= flag;
3788 control_style &= ~flag;
3792 protected void SetTopLevel(bool value) {
3793 if ((GetTopLevel() != value) && (parent != null)) {
3794 throw new Exception();
3798 if (value == true) {
3808 is_toplevel = value;
3811 protected virtual void SetVisibleCore(bool value) {
3812 if (value!=is_visible) {
3813 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3819 if (IsHandleCreated) {
3820 XplatUI.SetVisible(Handle, value, true);
3821 // Explicitly move Toplevel windows to where we want them;
3822 // apparently moving unmapped toplevel windows doesn't work
3823 if (is_visible && (this is Form)) {
3824 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3828 OnVisibleChanged(EventArgs.Empty);
3830 if (value == false && parent != null && Focused) {
3833 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3834 container = (Control)parent.GetContainerControl();
3835 if (container != null) {
3836 container.SelectNextControl(this, true, true, true, true);
3840 if (parent != null) {
3841 parent.PerformLayout(this, "visible");
3843 PerformLayout(this, "visible");
3848 [EditorBrowsable(EditorBrowsableState.Advanced)]
3849 protected void UpdateBounds() {
3857 if (!IsHandleCreated) {
3861 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3863 UpdateBounds(x, y, width, height, client_width, client_height);
3866 [EditorBrowsable(EditorBrowsableState.Advanced)]
3867 protected void UpdateBounds(int x, int y, int width, int height) {
3871 // Calculate client rectangle
3872 rect = new Rectangle(0, 0, 0, 0);
3875 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3876 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3879 [EditorBrowsable(EditorBrowsableState.Advanced)]
3880 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3881 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3883 bool resized = false;
3885 // Needed to generate required notifications
3886 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3890 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3897 bounds.Height=height;
3899 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3900 explicit_bounds = bounds;
3902 client_size.Width=clientWidth;
3903 client_size.Height=clientHeight;
3906 OnLocationChanged(EventArgs.Empty);
3910 OnSizeChanged(EventArgs.Empty);
3914 [EditorBrowsable(EditorBrowsableState.Advanced)]
3915 protected void UpdateStyles() {
3916 if (!IsHandleCreated) {
3920 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3921 OnStyleChanged(EventArgs.Empty);
3924 private void UpdateZOrderOfChild(Control child) {
3925 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3928 index = child_controls.IndexOf(child);
3931 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3933 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3938 private void UpdateChildrenZOrder() {
3939 Control [] controls;
3941 if (!IsHandleCreated) {
3945 controls = child_controls.GetAllControls ();
3946 for (int i = 1; i < controls.Length; i++ ) {
3947 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3951 [EditorBrowsable(EditorBrowsableState.Advanced)]
3952 protected void UpdateZOrder() {
3953 if (parent != null) {
3954 parent.UpdateZOrderOfChild(this);
3958 protected virtual void WndProc(ref Message m) {
3960 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3962 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3966 switch((Msg)m.Msg) {
3967 case Msg.WM_DESTROY: {
3968 OnHandleDestroyed(EventArgs.Empty);
3970 IntPtr handle = window.Handle;
3972 window.InvalidateHandle();
3974 if (is_recreating) {
3976 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
3980 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3982 is_recreating = false;
3987 case Msg.WM_WINDOWPOSCHANGED: {
3989 Rectangle save_bounds = explicit_bounds;
3991 explicit_bounds = save_bounds;
3992 if (GetStyle(ControlStyles.ResizeRedraw)) {
3999 // Nice description of what should happen when handling WM_PAINT
4000 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4001 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4002 case Msg.WM_PAINT: {
4003 PaintEventArgs paint_event;
4005 paint_event = XplatUI.PaintEventStart(Handle, true);
4007 if (paint_event == null) {
4011 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4013 // Just blit the previous image
4014 XplatUI.BlitFromOffscreen (Handle, paint_event.Graphics, backbuffer, backbuffer_dc, paint_event.ClipRectangle);
4015 XplatUI.PaintEventEnd (Handle, true);
4020 Graphics back_dc = null;
4022 if (ThemeEngine.Current.DoubleBufferingSupported) {
4023 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4024 CreateBackBuffer ();
4026 back_dc = backbuffer_dc;
4027 dc = paint_event.SetGraphics (back_dc);
4031 if (!GetStyle(ControlStyles.Opaque)) {
4032 OnPaintBackground(paint_event);
4035 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4036 OnPaintBackgroundInternal(paint_event);
4038 OnPaintInternal(paint_event);
4039 if (!paint_event.Handled) {
4040 OnPaint(paint_event);
4043 if (ThemeEngine.Current.DoubleBufferingSupported)
4044 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4045 XplatUI.BlitFromOffscreen (Handle, dc, back, back_dc, paint_event.ClipRectangle);
4046 paint_event.SetGraphics (dc);
4047 invalid_region.Exclude (paint_event.ClipRectangle);
4049 if (back != backbuffer)
4050 XplatUI.DestroyOffscreenDrawable (back, back_dc);
4053 XplatUI.PaintEventEnd(Handle, true);
4058 case Msg.WM_ERASEBKGND: {
4059 // The DefWndProc will never have to handle this, we always paint the background in managed code
4060 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4061 // here but it just makes things more complicated...
4062 m.Result = (IntPtr)1;
4066 case Msg.WM_LBUTTONUP: {
4069 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4071 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4074 HandleClick(mouse_clicks, me);
4077 if (InternalCapture) {
4078 InternalCapture = false;
4081 if (mouse_clicks > 1) {
4087 case Msg.WM_LBUTTONDOWN: {
4089 Select (true, true);
4091 InternalCapture = true;
4092 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4093 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4099 case Msg.WM_LBUTTONDBLCLK: {
4100 InternalCapture = true;
4102 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4103 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4108 case Msg.WM_MBUTTONUP: {
4111 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4113 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4116 HandleClick(mouse_clicks, me);
4118 if (InternalCapture) {
4119 InternalCapture = false;
4121 if (mouse_clicks > 1) {
4127 case Msg.WM_MBUTTONDOWN: {
4128 InternalCapture = true;
4129 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4130 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4135 case Msg.WM_MBUTTONDBLCLK: {
4136 InternalCapture = true;
4138 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4139 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4144 case Msg.WM_RBUTTONUP: {
4148 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4149 pt = PointToScreen(pt);
4151 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4153 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4155 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4158 HandleClick(mouse_clicks, me);
4161 if (InternalCapture) {
4162 InternalCapture = false;
4165 if (mouse_clicks > 1) {
4171 case Msg.WM_RBUTTONDOWN: {
4172 InternalCapture = true;
4173 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4174 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4179 case Msg.WM_RBUTTONDBLCLK: {
4180 InternalCapture = true;
4182 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4183 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4188 case Msg.WM_CONTEXTMENU: {
4189 if (context_menu != null) {
4192 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4193 context_menu.Show(this, PointToClient(pt));
4201 case Msg.WM_MOUSEWHEEL: {
4203 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4204 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4205 HighOrder(m.WParam.ToInt32())));
4210 case Msg.WM_MOUSEMOVE: {
4211 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4213 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4218 case Msg.WM_MOUSE_ENTER: {
4223 OnMouseEnter(EventArgs.Empty);
4227 case Msg.WM_MOUSE_LEAVE: {
4229 OnMouseLeave(EventArgs.Empty);
4233 case Msg.WM_MOUSEHOVER: {
4234 OnMouseHover(EventArgs.Empty);
4238 case Msg.WM_SYSKEYUP: {
4239 if (ProcessKeyMessage(ref m)) {
4240 m.Result = IntPtr.Zero;
4244 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4248 if (form != null && form.ActiveMenu != null) {
4249 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4257 case Msg.WM_SYSKEYDOWN:
4258 case Msg.WM_KEYDOWN:
4260 case Msg.WM_SYSCHAR:
4262 if (ProcessKeyMessage(ref m)) {
4263 m.Result = IntPtr.Zero;
4272 if (m.LParam != IntPtr.Zero) {
4275 hi = new HELPINFO();
4277 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4278 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4280 mouse_pos = Control.MousePosition;
4282 OnHelpRequested(new HelpEventArgs(mouse_pos));
4283 m.Result = (IntPtr)1;
4287 case Msg.WM_KILLFOCUS: {
4288 this.has_focus = false;
4289 OnLostFocusInternal (EventArgs.Empty);
4293 case Msg.WM_SETFOCUS: {
4295 this.has_focus = true;
4296 OnGotFocusInternal (EventArgs.Empty);
4301 case Msg.WM_SYSCOLORCHANGE: {
4302 ThemeEngine.Current.ResetDefaults();
4303 OnSystemColorsChanged(EventArgs.Empty);
4307 case Msg.WM_SETCURSOR: {
4308 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4313 XplatUI.SetCursor(window.Handle, cursor.handle);
4314 m.Result = (IntPtr)1;
4324 #endregion // Public Instance Methods
4326 #region OnXXX methods
4327 [EditorBrowsable(EditorBrowsableState.Advanced)]
4328 protected virtual void OnBackColorChanged(EventArgs e) {
4329 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4332 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4335 [EditorBrowsable(EditorBrowsableState.Advanced)]
4336 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4337 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4340 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4343 [EditorBrowsable(EditorBrowsableState.Advanced)]
4344 protected virtual void OnBindingContextChanged(EventArgs e) {
4345 CheckDataBindings ();
4346 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4349 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4352 [EditorBrowsable(EditorBrowsableState.Advanced)]
4353 protected virtual void OnCausesValidationChanged(EventArgs e) {
4354 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4359 [EditorBrowsable(EditorBrowsableState.Advanced)]
4360 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4361 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4366 [EditorBrowsable(EditorBrowsableState.Advanced)]
4367 protected virtual void OnClick(EventArgs e) {
4368 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4373 [EditorBrowsable(EditorBrowsableState.Advanced)]
4374 protected virtual void OnContextMenuChanged(EventArgs e) {
4375 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4380 [EditorBrowsable(EditorBrowsableState.Advanced)]
4381 protected virtual void OnControlAdded(ControlEventArgs e) {
4382 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4387 [EditorBrowsable(EditorBrowsableState.Advanced)]
4388 protected virtual void OnControlRemoved(ControlEventArgs e) {
4389 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4394 [EditorBrowsable(EditorBrowsableState.Advanced)]
4395 protected virtual void OnCreateControl() {
4399 [EditorBrowsable(EditorBrowsableState.Advanced)]
4400 protected virtual void OnCursorChanged(EventArgs e) {
4401 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4406 [EditorBrowsable(EditorBrowsableState.Advanced)]
4407 protected virtual void OnDockChanged(EventArgs e) {
4408 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4413 [EditorBrowsable(EditorBrowsableState.Advanced)]
4414 protected virtual void OnDoubleClick(EventArgs e) {
4415 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4420 [EditorBrowsable(EditorBrowsableState.Advanced)]
4421 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4422 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4424 eh (this, drgevent);
4427 [EditorBrowsable(EditorBrowsableState.Advanced)]
4428 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4429 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4431 eh (this, drgevent);
4434 [EditorBrowsable(EditorBrowsableState.Advanced)]
4435 protected virtual void OnDragLeave(EventArgs e) {
4436 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4441 [EditorBrowsable(EditorBrowsableState.Advanced)]
4442 protected virtual void OnDragOver(DragEventArgs drgevent) {
4443 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4445 eh (this, drgevent);
4448 [EditorBrowsable(EditorBrowsableState.Advanced)]
4449 protected virtual void OnEnabledChanged(EventArgs e) {
4450 if (IsHandleCreated) {
4452 if (((Form)this).context == null) {
4453 XplatUI.EnableWindow(window.Handle, Enabled);
4456 XplatUI.EnableWindow(window.Handle, Enabled);
4461 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4465 for (int i=0; i<child_controls.Count; i++) {
4466 child_controls[i].OnParentEnabledChanged(e);
4470 [EditorBrowsable(EditorBrowsableState.Advanced)]
4471 protected virtual void OnEnter(EventArgs e) {
4472 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4477 [EditorBrowsable(EditorBrowsableState.Advanced)]
4478 protected virtual void OnFontChanged(EventArgs e) {
4479 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4482 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4485 [EditorBrowsable(EditorBrowsableState.Advanced)]
4486 protected virtual void OnForeColorChanged(EventArgs e) {
4487 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4490 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4493 [EditorBrowsable(EditorBrowsableState.Advanced)]
4494 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4495 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4497 eh (this, gfbevent);
4500 [EditorBrowsable(EditorBrowsableState.Advanced)]
4501 protected virtual void OnGotFocus(EventArgs e) {
4502 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4507 [EditorBrowsable(EditorBrowsableState.Advanced)]
4508 protected virtual void OnHandleCreated(EventArgs e) {
4509 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4514 [EditorBrowsable(EditorBrowsableState.Advanced)]
4515 protected virtual void OnHandleDestroyed(EventArgs e) {
4516 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4521 [EditorBrowsable(EditorBrowsableState.Advanced)]
4522 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4523 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4528 protected virtual void OnImeModeChanged(EventArgs e) {
4529 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4534 [EditorBrowsable(EditorBrowsableState.Advanced)]
4535 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4536 if (ThemeEngine.Current.DoubleBufferingSupported)
4537 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4538 // should this block be here? seems like it
4539 // would be more at home in
4540 // NotifyInvalidated..
4541 if (e.InvalidRect == ClientRectangle) {
4542 InvalidateBackBuffer ();
4545 // we need this Inflate call here so
4546 // that the border of the rectangle is
4547 // considered Visible (the
4548 // invalid_region.IsVisible call) in
4549 // the WM_PAINT handling below.
4550 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4551 if (invalid_region == null)
4552 invalid_region = new Region (r);
4554 invalid_region.Union (r);
4558 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4563 [EditorBrowsable(EditorBrowsableState.Advanced)]
4564 protected virtual void OnKeyDown(KeyEventArgs e) {
4565 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4570 [EditorBrowsable(EditorBrowsableState.Advanced)]
4571 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4572 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4577 [EditorBrowsable(EditorBrowsableState.Advanced)]
4578 protected virtual void OnKeyUp(KeyEventArgs e) {
4579 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4584 [EditorBrowsable(EditorBrowsableState.Advanced)]
4585 protected virtual void OnLayout(LayoutEventArgs levent) {
4586 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4591 [EditorBrowsable(EditorBrowsableState.Advanced)]
4592 protected virtual void OnLeave(EventArgs e) {
4593 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4598 [EditorBrowsable(EditorBrowsableState.Advanced)]
4599 protected virtual void OnLocationChanged(EventArgs e) {
4601 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4606 [EditorBrowsable(EditorBrowsableState.Advanced)]
4607 protected virtual void OnLostFocus(EventArgs e) {
4608 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4613 [EditorBrowsable(EditorBrowsableState.Advanced)]
4614 protected virtual void OnMouseDown(MouseEventArgs e) {
4615 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4620 [EditorBrowsable(EditorBrowsableState.Advanced)]
4621 protected virtual void OnMouseEnter(EventArgs e) {
4622 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4627 [EditorBrowsable(EditorBrowsableState.Advanced)]
4628 protected virtual void OnMouseHover(EventArgs e) {
4629 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4634 [EditorBrowsable(EditorBrowsableState.Advanced)]
4635 protected virtual void OnMouseLeave(EventArgs e) {
4636 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4641 [EditorBrowsable(EditorBrowsableState.Advanced)]
4642 protected virtual void OnMouseMove(MouseEventArgs e) {
4643 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4648 [EditorBrowsable(EditorBrowsableState.Advanced)]
4649 protected virtual void OnMouseUp(MouseEventArgs e) {
4650 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4655 [EditorBrowsable(EditorBrowsableState.Advanced)]
4656 protected virtual void OnMouseWheel(MouseEventArgs e) {
4657 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4662 [EditorBrowsable(EditorBrowsableState.Advanced)]
4663 protected virtual void OnMove(EventArgs e) {
4664 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4669 [EditorBrowsable(EditorBrowsableState.Advanced)]
4670 protected virtual void OnNotifyMessage(Message m) {
4674 [EditorBrowsable(EditorBrowsableState.Advanced)]
4675 protected virtual void OnPaint(PaintEventArgs e) {
4676 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4681 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4685 internal virtual void OnPaintInternal(PaintEventArgs e) {
4689 internal virtual void OnGotFocusInternal (EventArgs e)
4694 internal virtual void OnLostFocusInternal (EventArgs e)
4699 [EditorBrowsable(EditorBrowsableState.Advanced)]
4700 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4701 PaintControlBackground (pevent);
4704 [EditorBrowsable(EditorBrowsableState.Advanced)]
4705 protected virtual void OnParentBackColorChanged(EventArgs e) {
4706 if (background_color.IsEmpty && background_image==null) {
4708 OnBackColorChanged(e);
4712 [EditorBrowsable(EditorBrowsableState.Advanced)]
4713 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4714 if (background_color.IsEmpty && background_image==null) {
4716 OnBackgroundImageChanged(e);
4720 [EditorBrowsable(EditorBrowsableState.Advanced)]
4721 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4722 if (binding_context==null) {
4723 binding_context=Parent.binding_context;
4724 OnBindingContextChanged(e);
4728 [EditorBrowsable(EditorBrowsableState.Advanced)]
4729 protected virtual void OnParentChanged(EventArgs e) {
4730 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4735 [EditorBrowsable(EditorBrowsableState.Advanced)]
4736 protected virtual void OnParentEnabledChanged(EventArgs e) {
4738 OnEnabledChanged(e);
4742 [EditorBrowsable(EditorBrowsableState.Advanced)]
4743 protected virtual void OnParentFontChanged(EventArgs e) {
4750 [EditorBrowsable(EditorBrowsableState.Advanced)]
4751 protected virtual void OnParentForeColorChanged(EventArgs e) {
4752 if (foreground_color.IsEmpty) {
4754 OnForeColorChanged(e);
4758 [EditorBrowsable(EditorBrowsableState.Advanced)]
4759 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4760 if (right_to_left==RightToLeft.Inherit) {
4762 OnRightToLeftChanged(e);
4766 [EditorBrowsable(EditorBrowsableState.Advanced)]
4767 protected virtual void OnParentVisibleChanged(EventArgs e) {
4769 OnVisibleChanged(e);
4773 [EditorBrowsable(EditorBrowsableState.Advanced)]
4774 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4775 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4780 [EditorBrowsable(EditorBrowsableState.Advanced)]
4781 protected virtual void OnResize(EventArgs e) {
4782 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4786 PerformLayout(this, "bounds");
4788 if (parent != null) {
4789 parent.PerformLayout();
4793 [EditorBrowsable(EditorBrowsableState.Advanced)]
4794 protected virtual void OnRightToLeftChanged(EventArgs e) {
4795 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4798 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4801 [EditorBrowsable(EditorBrowsableState.Advanced)]
4802 protected virtual void OnSizeChanged(EventArgs e) {
4803 DisposeBackBuffer ();
4805 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4810 [EditorBrowsable(EditorBrowsableState.Advanced)]
4811 protected virtual void OnStyleChanged(EventArgs e) {
4812 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4817 [EditorBrowsable(EditorBrowsableState.Advanced)]
4818 protected virtual void OnSystemColorsChanged(EventArgs e) {
4819 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4824 [EditorBrowsable(EditorBrowsableState.Advanced)]
4825 protected virtual void OnTabIndexChanged(EventArgs e) {
4826 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4831 [EditorBrowsable(EditorBrowsableState.Advanced)]
4832 protected virtual void OnTabStopChanged(EventArgs e) {
4833 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4838 [EditorBrowsable(EditorBrowsableState.Advanced)]
4839 protected virtual void OnTextChanged(EventArgs e) {
4840 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4845 [EditorBrowsable(EditorBrowsableState.Advanced)]
4846 protected virtual void OnValidated(EventArgs e) {
4847 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4852 [EditorBrowsable(EditorBrowsableState.Advanced)]
4853 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4854 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4859 [EditorBrowsable(EditorBrowsableState.Advanced)]
4860 protected virtual void OnVisibleChanged(EventArgs e) {
4861 if ((parent != null) && !Created && Visible) {
4868 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4872 // We need to tell our kids
4873 for (int i=0; i<child_controls.Count; i++) {
4874 if (child_controls[i].Visible) {
4875 child_controls[i].OnParentVisibleChanged(e);
4879 #endregion // OnXXX methods
4882 static object BackColorChangedEvent = new object ();
4883 static object BackgroundImageChangedEvent = new object ();
4884 static object BindingContextChangedEvent = new object ();
4885 static object CausesValidationChangedEvent = new object ();
4886 static object ChangeUICuesEvent = new object ();
4887 static object ClickEvent = new object ();
4888 static object ContextMenuChangedEvent = new object ();
4889 static object ControlAddedEvent = new object ();
4890 static object ControlRemovedEvent = new object ();
4891 static object CursorChangedEvent = new object ();
4892 static object DockChangedEvent = new object ();
4893 static object DoubleClickEvent = new object ();
4894 static object DragDropEvent = new object ();
4895 static object DragEnterEvent = new object ();
4896 static object DragLeaveEvent = new object ();
4897 static object DragOverEvent = new object ();
4898 static object EnabledChangedEvent = new object ();
4899 static object EnterEvent = new object ();
4900 static object FontChangedEvent = new object ();
4901 static object ForeColorChangedEvent = new object ();
4902 static object GiveFeedbackEvent = new object ();
4903 static object GotFocusEvent = new object ();
4904 static object HandleCreatedEvent = new object ();
4905 static object HandleDestroyedEvent = new object ();
4906 static object HelpRequestedEvent = new object ();
4907 static object ImeModeChangedEvent = new object ();
4908 static object InvalidatedEvent = new object ();
4909 static object KeyDownEvent = new object ();
4910 static object KeyPressEvent = new object ();
4911 static object KeyUpEvent = new object ();
4912 static object LayoutEvent = new object ();
4913 static object LeaveEvent = new object ();
4914 static object LocationChangedEvent = new object ();
4915 static object LostFocusEvent = new object ();
4916 static object MouseDownEvent = new object ();
4917 static object MouseEnterEvent = new object ();
4918 static object MouseHoverEvent = new object ();
4919 static object MouseLeaveEvent = new object ();
4920 static object MouseMoveEvent = new object ();
4921 static object MouseUpEvent = new object ();
4922 static object MouseWheelEvent = new object ();
4923 static object MoveEvent = new object ();
4924 static object PaintEvent = new object ();
4925 static object ParentChangedEvent = new object ();
4926 static object QueryAccessibilityHelpEvent = new object ();
4927 static object QueryContinueDragEvent = new object ();
4928 static object ResizeEvent = new object ();
4929 static object RightToLeftChangedEvent = new object ();
4930 static object SizeChangedEvent = new object ();
4931 static object StyleChangedEvent = new object ();
4932 static object SystemColorsChangedEvent = new object ();
4933 static object TabIndexChangedEvent = new object ();
4934 static object TabStopChangedEvent = new object ();
4935 static object TextChangedEvent = new object ();
4936 static object ValidatedEvent = new object ();
4937 static object ValidatingEvent = new object ();
4938 static object VisibleChangedEvent = new object ();
4940 public event EventHandler BackColorChanged {
4941 add { Events.AddHandler (BackColorChangedEvent, value); }
4942 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4945 public event EventHandler BackgroundImageChanged {
4946 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4947 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4950 public event EventHandler BindingContextChanged {
4951 add { Events.AddHandler (BindingContextChangedEvent, value); }
4952 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4955 public event EventHandler CausesValidationChanged {
4956 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4957 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4960 public event UICuesEventHandler ChangeUICues {
4961 add { Events.AddHandler (ChangeUICuesEvent, value); }
4962 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4965 public event EventHandler Click {
4966 add { Events.AddHandler (ClickEvent, value); }
4967 remove { Events.RemoveHandler (ClickEvent, value); }
4970 public event EventHandler ContextMenuChanged {
4971 add { Events.AddHandler (ContextMenuChangedEvent, value); }
4972 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
4975 [EditorBrowsable(EditorBrowsableState.Advanced)]
4977 public event ControlEventHandler ControlAdded {
4978 add { Events.AddHandler (ControlAddedEvent, value); }
4979 remove { Events.RemoveHandler (ControlAddedEvent, value); }
4982 [EditorBrowsable(EditorBrowsableState.Advanced)]
4984 public event ControlEventHandler ControlRemoved {
4985 add { Events.AddHandler (ControlRemovedEvent, value); }
4986 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
4989 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
4990 public event EventHandler CursorChanged {
4991 add { Events.AddHandler (CursorChangedEvent, value); }
4992 remove { Events.RemoveHandler (CursorChangedEvent, value); }
4994 public event EventHandler DockChanged {
4995 add { Events.AddHandler (DockChangedEvent, value); }
4996 remove { Events.RemoveHandler (DockChangedEvent, value); }
4999 public event EventHandler DoubleClick {
5000 add { Events.AddHandler (DoubleClickEvent, value); }
5001 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5004 public event DragEventHandler DragDrop {
5005 add { Events.AddHandler (DragDropEvent, value); }
5006 remove { Events.RemoveHandler (DragDropEvent, value); }
5009 public event DragEventHandler DragEnter {
5010 add { Events.AddHandler (DragEnterEvent, value); }
5011 remove { Events.RemoveHandler (DragEnterEvent, value); }
5014 public event EventHandler DragLeave {
5015 add { Events.AddHandler (DragLeaveEvent, value); }
5016 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5019 public event DragEventHandler DragOver {
5020 add { Events.AddHandler (DragOverEvent, value); }
5021 remove { Events.RemoveHandler (DragOverEvent, value); }
5024 public event EventHandler EnabledChanged {
5025 add { Events.AddHandler (EnabledChangedEvent, value); }
5026 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5029 public event EventHandler Enter {
5030 add { Events.AddHandler (EnterEvent, value); }
5031 remove { Events.RemoveHandler (EnterEvent, value); }
5034 public event EventHandler FontChanged {
5035 add { Events.AddHandler (FontChangedEvent, value); }
5036 remove { Events.RemoveHandler (FontChangedEvent, value); }
5039 public event EventHandler ForeColorChanged {
5040 add { Events.AddHandler (ForeColorChangedEvent, value); }
5041 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5044 public event GiveFeedbackEventHandler GiveFeedback {
5045 add { Events.AddHandler (GiveFeedbackEvent, value); }
5046 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5049 [EditorBrowsable(EditorBrowsableState.Advanced)]
5051 public event EventHandler GotFocus {
5052 add { Events.AddHandler (GotFocusEvent, value); }
5053 remove { Events.RemoveHandler (GotFocusEvent, value); }
5057 [EditorBrowsable(EditorBrowsableState.Advanced)]
5059 public event EventHandler HandleCreated {
5060 add { Events.AddHandler (HandleCreatedEvent, value); }
5061 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5064 [EditorBrowsable(EditorBrowsableState.Advanced)]
5066 public event EventHandler HandleDestroyed {
5067 add { Events.AddHandler (HandleDestroyedEvent, value); }
5068 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5071 public event HelpEventHandler HelpRequested {
5072 add { Events.AddHandler (HelpRequestedEvent, value); }
5073 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5076 public event EventHandler ImeModeChanged {
5077 add { Events.AddHandler (ImeModeChangedEvent, value); }
5078 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5081 [EditorBrowsable(EditorBrowsableState.Advanced)]
5083 public event InvalidateEventHandler Invalidated {
5084 add { Events.AddHandler (InvalidatedEvent, value); }
5085 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5088 public event KeyEventHandler KeyDown {
5089 add { Events.AddHandler (KeyDownEvent, value); }
5090 remove { Events.RemoveHandler (KeyDownEvent, value); }
5093 public event KeyPressEventHandler KeyPress {
5094 add { Events.AddHandler (KeyPressEvent, value); }
5095 remove { Events.RemoveHandler (KeyPressEvent, value); }
5098 public event KeyEventHandler KeyUp {
5099 add { Events.AddHandler (KeyUpEvent, value); }
5100 remove { Events.RemoveHandler (KeyUpEvent, value); }
5103 public event LayoutEventHandler Layout {
5104 add { Events.AddHandler (LayoutEvent, value); }
5105 remove { Events.RemoveHandler (LayoutEvent, value); }
5108 public event EventHandler Leave {
5109 add { Events.AddHandler (LeaveEvent, value); }
5110 remove { Events.RemoveHandler (LeaveEvent, value); }
5113 public event EventHandler LocationChanged {
5114 add { Events.AddHandler (LocationChangedEvent, value); }
5115 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5118 [EditorBrowsable(EditorBrowsableState.Advanced)]
5120 public event EventHandler LostFocus {
5121 add { Events.AddHandler (LostFocusEvent, value); }
5122 remove { Events.RemoveHandler (LostFocusEvent, value); }
5125 public event MouseEventHandler MouseDown {
5126 add { Events.AddHandler (MouseDownEvent, value); }
5127 remove { Events.RemoveHandler (MouseDownEvent, value); }
5130 public event EventHandler MouseEnter {
5131 add { Events.AddHandler (MouseEnterEvent, value); }
5132 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5135 public event EventHandler MouseHover {
5136 add { Events.AddHandler (MouseHoverEvent, value); }
5137 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5140 public event EventHandler MouseLeave {
5141 add { Events.AddHandler (MouseLeaveEvent, value); }
5142 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5145 public event MouseEventHandler MouseMove {
5146 add { Events.AddHandler (MouseMoveEvent, value); }
5147 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5150 public event MouseEventHandler MouseUp {
5151 add { Events.AddHandler (MouseUpEvent, value); }
5152 remove { Events.RemoveHandler (MouseUpEvent, value); }
5155 [EditorBrowsable(EditorBrowsableState.Advanced)]
5157 public event MouseEventHandler MouseWheel {
5158 add { Events.AddHandler (MouseWheelEvent, value); }
5159 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5162 public event EventHandler Move {
5163 add { Events.AddHandler (MoveEvent, value); }
5164 remove { Events.RemoveHandler (MoveEvent, value); }
5167 public event PaintEventHandler Paint {
5168 add { Events.AddHandler (PaintEvent, value); }
5169 remove { Events.RemoveHandler (PaintEvent, value); }
5172 public event EventHandler ParentChanged {
5173 add { Events.AddHandler (ParentChangedEvent, value); }
5174 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5177 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5178 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5179 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5182 public event QueryContinueDragEventHandler QueryContinueDrag {
5183 add { Events.AddHandler (QueryContinueDragEvent, value); }
5184 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5187 public event EventHandler Resize {
5188 add { Events.AddHandler (ResizeEvent, value); }
5189 remove { Events.RemoveHandler (ResizeEvent, value); }
5192 public event EventHandler RightToLeftChanged {
5193 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5194 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5197 public event EventHandler SizeChanged {
5198 add { Events.AddHandler (SizeChangedEvent, value); }
5199 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5202 public event EventHandler StyleChanged {
5203 add { Events.AddHandler (StyleChangedEvent, value); }
5204 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5207 public event EventHandler SystemColorsChanged {
5208 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5209 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5212 public event EventHandler TabIndexChanged {
5213 add { Events.AddHandler (TabIndexChangedEvent, value); }
5214 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5217 public event EventHandler TabStopChanged {
5218 add { Events.AddHandler (TabStopChangedEvent, value); }
5219 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5222 public event EventHandler TextChanged {
5223 add { Events.AddHandler (TextChangedEvent, value); }
5224 remove { Events.RemoveHandler (TextChangedEvent, value); }
5227 public event EventHandler Validated {
5228 add { Events.AddHandler (ValidatedEvent, value); }
5229 remove { Events.RemoveHandler (ValidatedEvent, value); }
5232 public event CancelEventHandler Validating {
5233 add { Events.AddHandler (ValidatingEvent, value); }
5234 remove { Events.RemoveHandler (ValidatingEvent, value); }
5237 public event EventHandler VisibleChanged {
5238 add { Events.AddHandler (VisibleChangedEvent, value); }
5239 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5242 #endregion // Events