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 static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
115 ControlCollection child_controls; // our children
116 Control parent; // our parent control
117 AccessibleObject accessibility_object; // object that contains accessibility information about our control
118 BindingContext binding_context;
119 RightToLeft right_to_left; // drawing direction for control
120 ContextMenu context_menu; // Context menu associated with the control
123 Graphics backbuffer_dc;
125 Region invalid_region;
127 ControlBindingsCollection data_bindings;
130 internal bool use_compatible_text_rendering;
131 static bool verify_thread_handle;
137 Layout.LayoutEngine layout_engine;
140 #endregion // Local Variables
142 #region Private Classes
143 // This helper class allows us to dispatch messages to Control.WndProc
144 internal class ControlNativeWindow : NativeWindow {
145 private Control owner;
147 public ControlNativeWindow(Control control) : base() {
152 public Control Owner {
158 static internal Control ControlFromHandle(IntPtr hWnd) {
159 ControlNativeWindow window;
161 window = (ControlNativeWindow)window_collection[hWnd];
162 if (window != null) {
169 static internal Control ControlFromChildHandle (IntPtr handle) {
170 ControlNativeWindow window;
172 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
173 while (hwnd != null) {
174 window = (ControlNativeWindow)window_collection[hwnd.Handle];
175 if (window != null) {
184 protected override void WndProc(ref Message m) {
185 owner.WndProc(ref m);
190 #region Public Classes
192 public class ControlAccessibleObject : AccessibleObject {
195 #region ControlAccessibleObject Constructors
196 public ControlAccessibleObject(Control ownerControl)
197 : base (ownerControl)
199 this.owner = ownerControl;
201 #endregion // ControlAccessibleObject Constructors
203 #region ControlAccessibleObject Public Instance Properties
204 public override string DefaultAction {
206 return base.DefaultAction;
210 public override string Description {
212 return base.Description;
216 public IntPtr Handle {
222 // We don't want to let them set it
226 public override string Help {
232 public override string KeyboardShortcut {
234 return base.KeyboardShortcut;
238 public override string Name {
248 public Control Owner {
254 public override AccessibleObject Parent {
261 public override AccessibleRole Role {
266 #endregion // ControlAccessibleObject Public Instance Properties
268 #region ControlAccessibleObject Public Instance Methods
269 public override int GetHelpTopic(out string FileName) {
270 return base.GetHelpTopic (out FileName);
273 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
274 public void NotifyClients(AccessibleEvents accEvent) {
275 throw new NotImplementedException();
278 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
279 public void NotifyClients(AccessibleEvents accEvent, int childID) {
280 throw new NotImplementedException();
283 public override string ToString() {
284 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
287 #endregion // ControlAccessibleObject Public Instance Methods
290 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
291 [ListBindable(false)]
292 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
293 #region ControlCollection Local Variables
296 Control[] all_controls;
298 #endregion // ControlCollection Local Variables
300 #region ControlCollection Public Constructor
301 public ControlCollection(Control owner) {
303 this.list=new ArrayList();
307 #region ControlCollection Public Instance Properties
314 public bool IsReadOnly {
316 return list.IsReadOnly;
320 public virtual Control this[int index] {
322 if (index < 0 || index >= list.Count) {
323 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
325 return (Control)list[index];
328 #endregion // ControlCollection Public Instance Properties
330 #region ControlCollection Private Instance Methods
331 public virtual void Add (Control value)
336 if (Contains (value)) {
337 owner.PerformLayout();
341 if (value.tab_index == -1) {
347 end = owner.child_controls.Count;
348 for (int i = 0; i < end; i++) {
349 index = owner.child_controls[i].tab_index;
354 value.tab_index = use;
357 if (value.parent != null) {
358 value.parent.Controls.Remove(value);
364 value.ChangeParent(owner);
368 owner.UpdateChildrenZOrder();
369 owner.PerformLayout(value, "Parent");
370 owner.OnControlAdded(new ControlEventArgs(value));
373 internal void AddToList (Control c)
379 internal virtual void AddImplicit (Control control)
381 if (impl_list == null)
382 impl_list = new ArrayList ();
384 if (AllContains (control))
388 impl_list.Add (control);
390 control.ChangeParent (owner);
391 control.InitLayout ();
392 owner.UpdateChildrenZOrder ();
393 owner.PerformLayout (control, "Parent");
394 owner.OnControlAdded (new ControlEventArgs (control));
397 public virtual void AddRange (Control[] controls)
399 if (controls == null)
400 throw new ArgumentNullException ("controls");
402 owner.SuspendLayout ();
405 for (int i = 0; i < controls.Length; i++)
408 owner.ResumeLayout ();
412 internal virtual void AddRangeImplicit (Control [] controls)
414 if (controls == null)
415 throw new ArgumentNullException ("controls");
417 owner.SuspendLayout ();
420 for (int i = 0; i < controls.Length; i++)
421 AddImplicit (controls [i]);
423 owner.ResumeLayout ();
427 public virtual void Clear ()
431 // MS sends remove events in reverse order
432 while (list.Count > 0) {
433 Remove((Control)list[list.Count - 1]);
437 internal virtual void ClearImplicit ()
439 if (impl_list == null)
445 public bool Contains (Control value)
447 for (int i = list.Count; i > 0; ) {
450 if (list [i] == value) {
451 // Do we need to do anything here?
458 internal bool ImplicitContains (Control value)
460 if (impl_list == null)
463 for (int i = impl_list.Count; i > 0; ) {
466 if (impl_list [i] == value) {
467 // Do we need to do anything here?
474 internal bool AllContains (Control value)
476 return Contains (value) || ImplicitContains (value);
479 public void CopyTo (Array array, int index)
481 list.CopyTo(array, index);
484 public override bool Equals(object other) {
485 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
492 public int GetChildIndex(Control child) {
493 return GetChildIndex(child, false);
496 public int GetChildIndex(Control child, bool throwException) {
499 index=list.IndexOf(child);
501 if (index==-1 && throwException) {
502 throw new ArgumentException("Not a child control", "child");
507 public IEnumerator GetEnumerator() {
508 return list.GetEnumerator();
511 internal IEnumerator GetAllEnumerator ()
513 Control [] res = GetAllControls ();
514 return res.GetEnumerator ();
517 internal Control [] GetAllControls ()
519 if (all_controls != null)
522 if (impl_list == null) {
523 all_controls = (Control []) list.ToArray (typeof (Control));
527 all_controls = new Control [list.Count + impl_list.Count];
528 impl_list.CopyTo (all_controls);
529 list.CopyTo (all_controls, impl_list.Count);
534 public override int GetHashCode() {
535 return base.GetHashCode();
538 public int IndexOf(Control control) {
539 return list.IndexOf(control);
542 public virtual void Remove(Control value) {
543 owner.PerformLayout(value, "Parent");
544 owner.OnControlRemoved(new ControlEventArgs(value));
549 value.ChangeParent(null);
551 owner.UpdateChildrenZOrder();
554 internal virtual void RemoveImplicit (Control control)
556 if (impl_list != null) {
558 owner.PerformLayout (control, "Parent");
559 owner.OnControlRemoved (new ControlEventArgs (control));
560 impl_list.Remove (control);
562 control.ChangeParent (null);
563 owner.UpdateChildrenZOrder ();
566 public void RemoveAt(int index) {
567 if (index < 0 || index >= list.Count) {
568 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
570 Remove ((Control)list[index]);
573 public void SetChildIndex(Control child, int newIndex) {
576 old_index=list.IndexOf(child);
578 throw new ArgumentException("Not a child control", "child");
581 if (old_index==newIndex) {
586 list.RemoveAt(old_index);
588 if (newIndex>list.Count) {
591 list.Insert(newIndex, child);
593 child.UpdateZOrder();
594 owner.PerformLayout();
596 #endregion // ControlCollection Private Instance Methods
598 #region ControlCollection Interface Properties
599 object IList.this[int index] {
601 if (index<0 || index>=list.Count) {
602 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
608 if (!(value is Control)) {
609 throw new ArgumentException("Object of type Control required", "value");
613 Control ctrl = (Control) value;
616 ctrl.ChangeParent(owner);
620 owner.UpdateChildrenZOrder();
621 owner.PerformLayout(ctrl, "Parent");
625 bool IList.IsFixedSize {
631 bool ICollection.IsSynchronized {
633 return list.IsSynchronized;
637 object ICollection.SyncRoot {
639 return list.SyncRoot;
642 #endregion // ControlCollection Interface Properties
644 #region ControlCollection Interface Methods
645 int IList.Add(object value) {
647 throw new ArgumentNullException("value", "Cannot add null controls");
650 if (!(value is Control)) {
651 throw new ArgumentException("Object of type Control required", "value");
654 return list.Add(value);
657 bool IList.Contains(object value) {
658 if (!(value is Control)) {
659 throw new ArgumentException("Object of type Control required", "value");
662 return this.Contains((Control) value);
665 int IList.IndexOf(object value) {
666 if (!(value is Control)) {
667 throw new ArgumentException("Object of type Control required", "value");
670 return this.IndexOf((Control) value);
673 void IList.Insert(int index, object value) {
674 if (!(value is Control)) {
675 throw new ArgumentException("Object of type Control required", "value");
678 list.Insert(index, value);
681 void IList.Remove(object value) {
682 if (!(value is Control)) {
683 throw new ArgumentException("Object of type Control required", "value");
689 Object ICloneable.Clone() {
690 ControlCollection clone = new ControlCollection(this.owner);
691 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
694 #endregion // ControlCollection Interface Methods
696 #endregion // ControlCollection Class
698 #region Public Constructors
701 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
709 layout_pending = false;
711 causes_validation = true;
713 layout_suspended = 0;
717 right_to_left = RightToLeft.Inherit;
718 border_style = BorderStyle.None;
719 background_color = Color.Empty;
725 ime_mode = ImeMode.Inherit;
728 use_compatible_text_rendering = Application.use_compatible_text_rendering;
729 padding = new Padding(0);
730 maximum_size = new Size();
731 minimum_size = new Size();
732 preferred_size = new Size();
733 margin = this.DefaultMargin;
734 layout_engine = this.LayoutEngine;
737 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
738 ControlStyles.Selectable | ControlStyles.StandardClick |
739 ControlStyles.StandardDoubleClick;
741 control_style |= ControlStyles.UseTextForAccessibility;
745 background_image = null;
749 window = new ControlNativeWindow(this);
750 child_controls = CreateControlsInstance();
751 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
752 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
753 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
754 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
760 public Control(Control parent, string text) : this() {
765 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
770 bounds.Height=height;
771 SetBounds(left, top, width, height, BoundsSpecified.All);
775 public Control(string text) : this() {
779 public Control(string text, int left, int top, int width, int height) : this() {
783 bounds.Height=height;
784 SetBounds(left, top, width, height, BoundsSpecified.All);
788 private delegate void RemoveDelegate(object c);
790 protected override void Dispose(bool disposing) {
791 if (!is_disposed && disposing) {
794 DisposeBackBuffer ();
796 if (invalid_region!=null) {
797 invalid_region.Dispose();
800 if (this.InvokeRequired) {
801 if (Application.MessageLoop) {
802 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
803 this.BeginInvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
807 lock (Control.controls) {
808 Control.controls.Remove(this);
813 if (parent != null) {
814 parent.Controls.Remove(this);
817 Control [] children = child_controls.GetAllControls ();
818 for (int i=0; i<children.Length; i++) {
819 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
820 children[i].Dispose();
825 base.Dispose(disposing);
827 #endregion // Public Constructors
829 #region Internal Properties
830 internal BorderStyle InternalBorderStyle {
836 if (!Enum.IsDefined (typeof (BorderStyle), value))
837 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
839 if (border_style != value) {
840 border_style = value;
842 if (IsHandleCreated) {
843 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
849 #endregion // Internal Properties
851 #region Private & Internal Methods
852 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
853 AsyncMethodResult result;
854 AsyncMethodData data;
861 if (!p.IsHandleCreated) {
862 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
868 result = new AsyncMethodResult ();
869 data = new AsyncMethodData ();
871 data.Handle = window.Handle;
872 data.Method = method;
874 data.Result = result;
877 if (!ExecutionContext.IsFlowSuppressed ()) {
878 data.Context = ExecutionContext.Capture ();
881 #if !MWF_ON_MSRUNTIME
882 if (SecurityManager.SecurityEnabled) {
883 data.Stack = CompressedStack.GetCompressedStack ();
888 XplatUI.SendAsyncMethod (data);
893 internal void PointToClient (ref int x, ref int y)
895 XplatUI.ScreenToClient (Handle, ref x, ref y);
898 internal void PointToScreen (ref int x, ref int y)
900 XplatUI.ClientToScreen (Handle, ref x, ref y);
903 internal bool IsRecreating {
905 return is_recreating;
909 internal Graphics DeviceContext {
910 get { return Hwnd.bmp_g; }
913 private void InvalidateBackBuffer ()
915 if (invalid_region != null)
916 invalid_region.Dispose();
917 invalid_region = new Region (ClientRectangle);
920 private void CreateBackBuffer ()
922 if (backbuffer != null)
928 if (width < 1) width = 1;
929 if (height < 1) height = 1;
931 XplatUI.CreateOffscreenDrawable (Handle, width, height, out backbuffer, out backbuffer_dc);
932 InvalidateBackBuffer ();
935 private void DisposeBackBuffer ()
937 if (backbuffer == null)
940 XplatUI.DestroyOffscreenDrawable (backbuffer, backbuffer_dc);
942 backbuffer_dc = null;
945 if (invalid_region != null)
946 invalid_region.Dispose ();
947 invalid_region = null;
950 internal static void SetChildColor(Control parent) {
953 for (int i=0; i < parent.child_controls.Count; i++) {
954 child=parent.child_controls[i];
955 if (child.child_controls.Count>0) {
956 SetChildColor(child);
961 internal bool Select(Control control) {
962 IContainerControl container;
964 if (control == null) {
968 container = GetContainerControl();
969 if (container != null) {
970 container.ActiveControl = control;
972 if (control.IsHandleCreated) {
973 XplatUI.SetFocus(control.window.Handle);
978 internal void SelectChild (Control control)
980 if (control.IsHandleCreated)
981 XplatUI.SetFocus (control.window.Handle);
984 internal virtual void DoDefaultAction() {
985 // Only here to be overriden by our actual controls; this is needed by the accessibility class
988 internal static int LowOrder (int param) {
989 return ((int)(short)(param & 0xffff));
992 internal static int HighOrder (int param) {
993 return ((int)(short)(param >> 16));
996 // This method exists so controls overriding OnPaintBackground can have default background painting done
997 internal virtual void PaintControlBackground (PaintEventArgs pevent)
999 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1000 if (parent != null) {
1001 PaintEventArgs parent_pe;
1002 GraphicsState state;
1004 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1006 state = parent_pe.Graphics.Save();
1007 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1008 parent.OnPaintBackground(parent_pe);
1009 parent_pe.Graphics.Restore(state);
1011 state = parent_pe.Graphics.Save();
1012 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1013 parent.OnPaint(parent_pe);
1014 parent_pe.Graphics.Restore(state);
1015 parent_pe.SetGraphics(null);
1019 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1020 if (parent != null) {
1021 PaintEventArgs parent_pe;
1023 GraphicsState state;
1026 hwnd = Hwnd.ObjectFromHandle(Handle);
1029 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1031 region = new Region ();
1033 region.Union(ClientRectangle);
1035 foreach (Rectangle r in hwnd.ClipRectangles) {
1039 state = parent_pe.Graphics.Save();
1040 parent_pe.Graphics.Clip = region;
1042 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1043 parent.OnPaintBackground(parent_pe);
1044 parent_pe.Graphics.Restore(state);
1046 state = parent_pe.Graphics.Save();
1047 parent_pe.Graphics.Clip = region;
1049 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1050 parent.OnPaint(parent_pe);
1051 parent_pe.Graphics.Restore(state);
1052 parent_pe.SetGraphics(null);
1054 region.Intersect(clip_region);
1055 pevent.Graphics.Clip = region;
1060 if (background_image == null) {
1061 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));
1065 DrawBackgroundImage (pevent.Graphics);
1068 void DrawBackgroundImage (Graphics g)
1070 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1071 g.FillRectangle (b, ClientRectangle);
1075 internal virtual void DndEnter (DragEventArgs e)
1082 internal virtual void DndOver (DragEventArgs e)
1089 internal virtual void DndDrop (DragEventArgs e)
1093 } catch (Exception exc) {
1094 Console.Error.WriteLine ("MWF: Exception while dropping:");
1095 Console.Error.WriteLine (exc);
1099 internal virtual void DndLeave (EventArgs e)
1106 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1113 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1116 OnQueryContinueDrag(e);
1120 internal static MouseButtons FromParamToMouseButtons (int param) {
1121 MouseButtons buttons = MouseButtons.None;
1123 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1124 buttons |= MouseButtons.Left;
1126 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1127 buttons |= MouseButtons.Middle;
1129 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1130 buttons |= MouseButtons.Right;
1136 internal void FireEnter ()
1138 OnEnter (EventArgs.Empty);
1141 internal void FireLeave ()
1143 OnLeave (EventArgs.Empty);
1146 internal void FireValidating (CancelEventArgs ce)
1151 internal void FireValidated ()
1153 OnValidated (EventArgs.Empty);
1156 internal virtual bool ProcessControlMnemonic(char charCode) {
1157 return ProcessMnemonic(charCode);
1160 private static Control FindFlatForward(Control container, Control start) {
1166 end = container.child_controls.Count;
1168 if (start != null) {
1169 index = start.tab_index;
1175 for (int i = 0, pos = -1; i < end; i++) {
1176 if (start == container.child_controls[i]) {
1181 if (found == null) {
1182 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1183 found = container.child_controls[i];
1185 } else if (found.tab_index > container.child_controls[i].tab_index) {
1186 if (container.child_controls[i].tab_index > index) {
1187 found = container.child_controls[i];
1194 private static Control FindControlForward(Control container, Control start) {
1199 if (start == null) {
1200 return FindFlatForward(container, start);
1203 if (start.child_controls != null && start.child_controls.Count > 0 &&
1204 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1205 return FindControlForward(start, null);
1208 while (start != container) {
1209 found = FindFlatForward(start.parent, start);
1210 if (found != null) {
1213 start = start.parent;
1219 private static Control FindFlatBackward(Control container, Control start) {
1225 end = container.child_controls.Count;
1227 if (start != null) {
1228 index = start.tab_index;
1230 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1232 for (int i = 0; i < end; i++) {
1233 if (container.child_controls[i].tab_index > index) {
1234 index = container.child_controls[i].tab_index;
1242 for (int i = end - 1; i >= 0; i--) {
1243 if (start == container.child_controls[i]) {
1248 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1249 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1250 found = container.child_controls[i];
1257 private static Control FindControlBackward(Control container, Control start) {
1259 Control found = null;
1261 if (start == null) {
1262 found = FindFlatBackward(container, start);
1264 else if (start != container) {
1265 if (start.parent != null) {
1266 found = FindFlatBackward(start.parent, start);
1268 if (found == null) {
1269 if (start.parent != container)
1270 return start.parent;
1276 if (found == null || start.parent == null)
1279 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1280 found.child_controls != null && found.child_controls.Count > 0)) {
1281 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1282 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1283 found = FindFlatBackward(found, null);
1293 if (start != null) {
1294 found = FindFlatBackward(start.parent, start);
1295 if (found == null) {
1296 if (start.parent != container) {
1297 return start.parent;
1301 if (found == null) {
1302 found = FindFlatBackward(container, start);
1305 if (container != start) {
1306 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1307 found = FindControlBackward(found, null);
1308 if (found != null) {
1317 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1318 if (GetStyle(ControlStyles.StandardClick)) {
1319 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1321 OnDoubleClick(EventArgs.Empty);
1323 OnClick(EventArgs.Empty);
1333 private void CheckDataBindings ()
1335 if (data_bindings == null)
1338 BindingContext binding_context = BindingContext;
1339 foreach (Binding binding in data_bindings) {
1340 binding.Check (binding_context);
1345 private void ChangeParent(Control new_parent) {
1349 Color pre_fore_color;
1350 Color pre_back_color;
1351 RightToLeft pre_rtl;
1353 // These properties are inherited from our parent
1354 // Get them pre parent-change and then send events
1355 // if they are changed after we have our new parent
1356 pre_enabled = Enabled;
1357 pre_visible = Visible;
1359 pre_fore_color = ForeColor;
1360 pre_back_color = BackColor;
1361 pre_rtl = RightToLeft;
1362 // MS doesn't seem to send a CursorChangedEvent
1364 parent = new_parent;
1366 if (IsHandleCreated)
1367 XplatUI.SetParent(Handle,
1368 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1370 OnParentChanged(EventArgs.Empty);
1372 if (pre_enabled != Enabled) {
1373 OnEnabledChanged(EventArgs.Empty);
1376 if (pre_visible != Visible) {
1377 OnVisibleChanged(EventArgs.Empty);
1380 if (pre_font != Font) {
1381 OnFontChanged(EventArgs.Empty);
1384 if (pre_fore_color != ForeColor) {
1385 OnForeColorChanged(EventArgs.Empty);
1388 if (pre_back_color != BackColor) {
1389 OnBackColorChanged(EventArgs.Empty);
1392 if (pre_rtl != RightToLeft) {
1393 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1394 // because when RTL changes they have to recreate the win32 control
1395 // We don't really need that (until someone runs into compatibility issues)
1396 OnRightToLeftChanged(EventArgs.Empty);
1399 if ((new_parent != null) && new_parent.Created && !Created) {
1403 if ((binding_context == null) && Created) {
1404 OnBindingContextChanged(EventArgs.Empty);
1408 private void UpdateDistances() {
1409 if ((parent != null) && (parent.layout_suspended == 0)) {
1410 dist_left = bounds.X;
1411 dist_top = bounds.Y;
1412 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1413 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1416 #endregion // Private & Internal Methods
1418 #region Public Static Properties
1419 public static Color DefaultBackColor {
1421 return ThemeEngine.Current.DefaultControlBackColor;
1425 public static Font DefaultFont {
1427 return ThemeEngine.Current.DefaultFont;
1431 public static Color DefaultForeColor {
1433 return ThemeEngine.Current.DefaultControlForeColor;
1437 public static Keys ModifierKeys {
1439 return XplatUI.State.ModifierKeys;
1443 public static MouseButtons MouseButtons {
1445 return XplatUI.State.MouseButtons;
1449 public static Point MousePosition {
1451 return Cursor.Position;
1457 public static bool CheckForIllegalCrossThreadCalls
1460 return verify_thread_handle;
1464 verify_thread_handle = value;
1468 #endregion // Public Static Properties
1470 #region Public Instance Properties
1471 [EditorBrowsable(EditorBrowsableState.Advanced)]
1473 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1474 public AccessibleObject AccessibilityObject {
1476 if (accessibility_object==null) {
1477 accessibility_object=CreateAccessibilityInstance();
1479 return accessibility_object;
1483 [EditorBrowsable(EditorBrowsableState.Advanced)]
1485 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1486 public string AccessibleDefaultActionDescription {
1488 return AccessibilityObject.default_action;
1492 AccessibilityObject.default_action=value;
1497 [DefaultValue(null)]
1498 [MWFCategory("Accessibility")]
1499 public string AccessibleDescription {
1501 return AccessibilityObject.description;
1505 AccessibilityObject.description=value;
1510 [DefaultValue(null)]
1511 [MWFCategory("Accessibility")]
1512 public string AccessibleName {
1514 return AccessibilityObject.Name;
1518 AccessibilityObject.Name=value;
1522 [DefaultValue(AccessibleRole.Default)]
1523 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1524 public AccessibleRole AccessibleRole {
1526 return AccessibilityObject.role;
1530 AccessibilityObject.role=value;
1534 [DefaultValue(false)]
1535 [MWFCategory("Behavior")]
1536 public virtual bool AllowDrop {
1542 if (allow_drop == value)
1545 if (IsHandleCreated) {
1547 XplatUI.SetAllowDrop (Handle, value);
1553 [RefreshProperties(RefreshProperties.Repaint)]
1554 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1555 [MWFCategory("Layout")]
1556 public virtual AnchorStyles Anchor {
1558 return anchor_style;
1564 if (parent != null) {
1565 parent.PerformLayout(this, "Parent");
1571 // XXX: Implement me!
1574 public virtual bool AutoSize {
1576 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1580 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1585 public virtual Size MaximumSize {
1587 return maximum_size;
1590 maximum_size = value;
1594 public virtual Size MinimumSize {
1596 return minimum_size;
1599 minimum_size = value;
1605 [MWFCategory("Appearance")]
1606 public virtual Color BackColor {
1608 if (background_color.IsEmpty) {
1610 Color pcolor = parent.BackColor;
1611 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1614 return DefaultBackColor;
1616 return background_color;
1620 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1621 throw new ArgumentException("Transparent background colors are not supported on this control");
1624 if (background_color != value) {
1625 background_color=value;
1626 SetChildColor(this);
1627 OnBackColorChanged(EventArgs.Empty);
1634 [DefaultValue(null)]
1635 [MWFCategory("Appearance")]
1636 public virtual Image BackgroundImage {
1638 return background_image;
1642 if (background_image!=value) {
1643 background_image=value;
1644 OnBackgroundImageChanged(EventArgs.Empty);
1649 [EditorBrowsable(EditorBrowsableState.Advanced)]
1651 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1652 public virtual BindingContext BindingContext {
1654 if (binding_context != null)
1655 return binding_context;
1658 binding_context = Parent.BindingContext;
1659 return binding_context;
1662 if (binding_context != value) {
1663 binding_context = value;
1664 OnBindingContextChanged(EventArgs.Empty);
1669 [EditorBrowsable(EditorBrowsableState.Advanced)]
1671 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1674 return bounds.Y+bounds.Height;
1678 [EditorBrowsable(EditorBrowsableState.Advanced)]
1680 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1681 public Rectangle Bounds {
1687 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1691 [EditorBrowsable(EditorBrowsableState.Advanced)]
1693 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1694 public bool CanFocus {
1696 if (IsHandleCreated && Visible && Enabled) {
1703 [EditorBrowsable(EditorBrowsableState.Advanced)]
1705 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1706 public bool CanSelect {
1710 if (!GetStyle(ControlStyles.Selectable)) {
1715 while (parent != null) {
1716 if (!parent.is_visible || !parent.is_enabled) {
1720 parent = parent.parent;
1726 internal virtual bool InternalCapture {
1736 [EditorBrowsable(EditorBrowsableState.Advanced)]
1738 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1739 public bool Capture {
1741 return this.is_captured;
1745 if (this.IsHandleCreated && value != is_captured) {
1748 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1750 XplatUI.UngrabWindow(this.window.Handle);
1751 is_captured = false;
1757 [DefaultValue(true)]
1758 [MWFCategory("Focus")]
1759 public bool CausesValidation {
1761 return this.causes_validation;
1765 if (this.causes_validation != value) {
1766 causes_validation = value;
1767 OnCausesValidationChanged(EventArgs.Empty);
1772 [EditorBrowsable(EditorBrowsableState.Advanced)]
1774 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1775 public Rectangle ClientRectangle {
1777 client_rect.Width = client_size.Width;
1778 client_rect.Height = client_size.Height;
1783 [EditorBrowsable(EditorBrowsableState.Advanced)]
1785 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1786 public Size ClientSize {
1789 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1790 return ((Form)this).form_parent_window.ClientSize;
1798 this.SetClientSizeCore(value.Width, value.Height);
1802 [EditorBrowsable(EditorBrowsableState.Advanced)]
1804 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1805 [DescriptionAttribute("ControlCompanyNameDescr")]
1806 public String CompanyName {
1808 return "Mono Project, Novell, Inc.";
1812 [EditorBrowsable(EditorBrowsableState.Advanced)]
1814 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1815 public bool ContainsFocus {
1817 IntPtr focused_window;
1819 focused_window = XplatUI.GetFocus();
1820 if (IsHandleCreated) {
1821 if (focused_window == Handle) {
1825 for (int i=0; i < child_controls.Count; i++) {
1826 if (child_controls[i].ContainsFocus) {
1835 [DefaultValue(null)]
1836 [MWFCategory("Behavior")]
1837 public virtual ContextMenu ContextMenu {
1839 return context_menu;
1843 if (context_menu != value) {
1844 context_menu = value;
1845 OnContextMenuChanged(EventArgs.Empty);
1851 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1852 public ControlCollection Controls {
1854 return this.child_controls;
1858 [EditorBrowsable(EditorBrowsableState.Advanced)]
1860 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1861 public bool Created {
1863 return (!is_disposed && is_created);
1867 [AmbientValue(null)]
1868 [MWFCategory("Appearance")]
1869 public virtual Cursor Cursor {
1871 if (cursor != null) {
1875 if (parent != null) {
1876 return parent.Cursor;
1879 return Cursors.Default;
1883 if (cursor != value) {
1888 if (IsHandleCreated) {
1889 pt = Cursor.Position;
1891 if (bounds.Contains(pt) || Capture) {
1892 if (GetChildAtPoint(pt) == null) {
1893 if (cursor != null) {
1894 XplatUI.SetCursor(window.Handle, cursor.handle);
1896 if (parent != null) {
1897 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1899 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1906 OnCursorChanged(EventArgs.Empty);
1912 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1913 [ParenthesizePropertyName(true)]
1914 [RefreshProperties(RefreshProperties.All)]
1915 [MWFCategory("Data")]
1916 public ControlBindingsCollection DataBindings {
1918 if (data_bindings == null)
1919 data_bindings = new ControlBindingsCollection (this);
1920 return data_bindings;
1924 [EditorBrowsable(EditorBrowsableState.Advanced)]
1926 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1927 public virtual Rectangle DisplayRectangle {
1929 return ClientRectangle;
1933 [EditorBrowsable(EditorBrowsableState.Advanced)]
1935 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1936 public bool Disposing {
1943 [RefreshProperties(RefreshProperties.Repaint)]
1944 [DefaultValue(DockStyle.None)]
1945 [MWFCategory("Layout")]
1946 public virtual DockStyle Dock {
1952 if (dock_style == value) {
1958 if (dock_style == DockStyle.None) {
1959 if (explicit_bounds == Rectangle.Empty)
1960 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1962 Bounds = explicit_bounds;
1965 if (parent != null) {
1966 parent.PerformLayout(this, "Parent");
1969 OnDockChanged(EventArgs.Empty);
1975 [MWFCategory("Behavior")]
1976 public bool Enabled {
1982 if (parent != null) {
1983 return parent.Enabled;
1991 bool old_value = is_enabled;
1994 if (old_value != value && !value && this.has_focus)
1995 SelectNextControl(this, true, true, true, true);
1997 OnEnabledChanged (EventArgs.Empty);
2001 [EditorBrowsable(EditorBrowsableState.Advanced)]
2003 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2004 public virtual bool Focused {
2006 return this.has_focus;
2011 [AmbientValue(null)]
2013 [MWFCategory("Appearance")]
2014 public virtual Font Font {
2020 if (Parent != null && Parent.Font != null) {
2027 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2029 if (font != null && font.Equals (value)) {
2035 OnFontChanged (EventArgs.Empty);
2040 [MWFCategory("Appearance")]
2041 public virtual Color ForeColor {
2043 if (foreground_color.IsEmpty) {
2045 return parent.ForeColor;
2047 return DefaultForeColor;
2049 return foreground_color;
2053 if (foreground_color != value) {
2054 foreground_color=value;
2056 OnForeColorChanged(EventArgs.Empty);
2063 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2064 public IntPtr Handle { // IWin32Window
2067 if (verify_thread_handle) {
2068 if (this.InvokeRequired) {
2069 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2073 if (!IsHandleCreated) {
2076 return window.Handle;
2080 [EditorBrowsable(EditorBrowsableState.Advanced)]
2082 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2083 public bool HasChildren {
2085 if (this.child_controls.Count>0) {
2092 [EditorBrowsable(EditorBrowsableState.Always)]
2094 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2097 return this.bounds.Height;
2101 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2105 [AmbientValue(ImeMode.Inherit)]
2107 [MWFCategory("Behavior")]
2108 public ImeMode ImeMode {
2110 if (ime_mode == ImeMode.Inherit) {
2112 return parent.ImeMode;
2114 return ImeMode.NoControl; // default value
2120 if (ime_mode != value) {
2123 OnImeModeChanged(EventArgs.Empty);
2128 [EditorBrowsable(EditorBrowsableState.Advanced)]
2130 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2131 public bool InvokeRequired { // ISynchronizeInvoke
2133 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2140 [EditorBrowsable(EditorBrowsableState.Advanced)]
2142 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2143 public bool IsAccessible {
2145 return is_accessible;
2149 is_accessible = value;
2153 [EditorBrowsable(EditorBrowsableState.Advanced)]
2155 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2156 public bool IsDisposed {
2158 return this.is_disposed;
2162 [EditorBrowsable(EditorBrowsableState.Advanced)]
2164 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2165 public bool IsHandleCreated {
2167 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2168 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2169 if (hwnd != null && !hwnd.zombie)
2178 public virtual Layout.LayoutEngine LayoutEngine {
2179 get { return new Layout.DefaultLayout (); }
2183 [EditorBrowsable(EditorBrowsableState.Always)]
2185 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2188 return this.bounds.X;
2192 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2197 [MWFCategory("Layout")]
2198 public Point Location {
2200 return new Point(bounds.X, bounds.Y);
2204 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2209 [Localizable (true)]
2210 public Padding Margin {
2211 get { return this.margin; }
2212 set { this.margin = value; }
2217 public string Name {
2229 public Padding Padding {
2241 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2242 public Control Parent {
2248 if (value == this) {
2249 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2252 if (parent!=value) {
2254 parent.Controls.Remove(this);
2259 value.Controls.Add(this);
2264 [EditorBrowsable(EditorBrowsableState.Advanced)]
2266 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2267 public string ProductName {
2269 Type t = typeof (AssemblyProductAttribute);
2270 Assembly assembly = GetType().Module.Assembly;
2271 object [] attrs = assembly.GetCustomAttributes (t, false);
2272 AssemblyProductAttribute a = null;
2273 // On MS we get a NullRefException if product attribute is not
2275 if (attrs != null && attrs.Length > 0)
2276 a = (AssemblyProductAttribute) attrs [0];
2281 [EditorBrowsable(EditorBrowsableState.Advanced)]
2283 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2284 public string ProductVersion {
2286 Type t = typeof (AssemblyVersionAttribute);
2287 Assembly assembly = GetType().Module.Assembly;
2288 object [] attrs = assembly.GetCustomAttributes (t, false);
2289 if (attrs == null || attrs.Length < 1)
2291 return ((AssemblyVersionAttribute)attrs [0]).Version;
2295 [EditorBrowsable(EditorBrowsableState.Advanced)]
2297 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2298 public bool RecreatingHandle {
2300 return is_recreating;
2304 [EditorBrowsable(EditorBrowsableState.Advanced)]
2306 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2307 public Region Region {
2313 if (IsHandleCreated) {
2314 XplatUI.SetClipRegion(Handle, value);
2316 clip_region = value;
2320 [EditorBrowsable(EditorBrowsableState.Advanced)]
2322 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2325 return this.bounds.X+this.bounds.Width;
2329 [AmbientValue(RightToLeft.Inherit)]
2331 [MWFCategory("Appearance")]
2332 public virtual RightToLeft RightToLeft {
2334 if (right_to_left == RightToLeft.Inherit) {
2336 return parent.RightToLeft;
2338 return RightToLeft.No; // default value
2340 return right_to_left;
2344 if (value != right_to_left) {
2345 right_to_left = value;
2346 OnRightToLeftChanged(EventArgs.Empty);
2351 [EditorBrowsable(EditorBrowsableState.Advanced)]
2352 public override ISite Site {
2360 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2362 BackColor = ap.BackColor;
2363 ForeColor = ap.ForeColor;
2371 [MWFCategory("Layout")]
2374 return new Size(Width, Height);
2378 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2383 [MergableProperty(false)]
2384 [MWFCategory("Behavior")]
2385 public int TabIndex {
2387 if (tab_index != -1) {
2394 if (tab_index != value) {
2396 OnTabIndexChanged(EventArgs.Empty);
2402 [DefaultValue(true)]
2403 [MWFCategory("Behavior")]
2404 public bool TabStop {
2410 if (tab_stop != value) {
2412 OnTabStopChanged(EventArgs.Empty);
2417 [Localizable(false)]
2419 [TypeConverter(typeof(StringConverter))]
2420 [DefaultValue(null)]
2421 [MWFCategory("Data")]
2428 control_tag = value;
2434 [BindableAttribute(true)]
2435 [MWFCategory("Appearance")]
2436 public virtual string Text {
2438 // Our implementation ignores ControlStyles.CacheText - we always cache
2443 if (value == null) {
2444 value = String.Empty;
2449 if (IsHandleCreated) {
2450 /* we need to call .SetWindowStyle here instead of just .Text
2451 because the presence/absence of Text (== "" or not) can cause
2452 other window style things to appear/disappear */
2453 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2454 XplatUI.Text(Handle, text);
2456 OnTextChanged (EventArgs.Empty);
2461 [EditorBrowsable(EditorBrowsableState.Always)]
2463 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2466 return this.bounds.Y;
2470 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2474 [EditorBrowsable(EditorBrowsableState.Advanced)]
2476 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2477 public Control TopLevelControl {
2481 while (p.parent != null) {
2485 return p is Form ? p : null;
2490 [MWFCategory("Behavior")]
2491 public bool Visible {
2495 } else if (parent != null) {
2496 return parent.Visible;
2503 SetVisibleCore(value);
2507 [EditorBrowsable(EditorBrowsableState.Always)]
2509 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2512 return this.bounds.Width;
2516 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2520 [EditorBrowsable(EditorBrowsableState.Never)]
2522 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2523 public IWindowTarget WindowTarget {
2532 #endregion // Public Instance Properties
2534 #region Protected Instance Properties
2535 protected virtual CreateParams CreateParams {
2537 CreateParams create_params = new CreateParams();
2540 create_params.Caption = Text;
2543 create_params.Caption = text;
2547 create_params.X = Left;
2550 create_params.X = this.bounds.X;
2554 create_params.Y = Top;
2557 create_params.Y = this.bounds.Y;
2561 create_params.Width = Width;
2564 create_params.Width = this.bounds.Width;
2568 create_params.Height = Height;
2571 create_params.Height = this.bounds.Height;
2575 create_params.ClassName = XplatUI.DefaultClassName;
2576 create_params.ClassStyle = 0;
2577 create_params.ExStyle = 0;
2578 create_params.Param = 0;
2581 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2584 if ((parent!=null) && (parent.IsHandleCreated)) {
2585 create_params.Parent = parent.Handle;
2588 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2591 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2595 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2598 switch (border_style) {
2599 case BorderStyle.FixedSingle:
2600 create_params.Style |= (int) WindowStyles.WS_BORDER;
2602 case BorderStyle.Fixed3D:
2603 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2607 return create_params;
2611 protected virtual ImeMode DefaultImeMode {
2613 return ImeMode.Inherit;
2618 protected virtual Padding DefaultMargin {
2619 get { return new Padding (3); }
2623 protected virtual Size DefaultSize {
2625 return new Size(0, 0);
2629 protected int FontHeight {
2639 protected bool RenderRightToLeft {
2641 return (this.right_to_left == RightToLeft.Yes);
2645 protected bool ResizeRedraw {
2647 return GetStyle(ControlStyles.ResizeRedraw);
2651 SetStyle(ControlStyles.ResizeRedraw, value);
2655 [EditorBrowsable(EditorBrowsableState.Advanced)]
2657 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2658 protected virtual bool ShowFocusCues {
2664 [EditorBrowsable(EditorBrowsableState.Advanced)]
2666 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2667 protected bool ShowKeyboardCues {
2672 #endregion // Protected Instance Properties
2674 #region Public Static Methods
2675 [EditorBrowsable(EditorBrowsableState.Advanced)]
2676 public static Control FromChildHandle(IntPtr handle) {
2677 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2680 [EditorBrowsable(EditorBrowsableState.Advanced)]
2681 public static Control FromHandle(IntPtr handle) {
2682 return Control.ControlNativeWindow.ControlFromHandle(handle);
2685 public static bool IsMnemonic(char charCode, string text) {
2688 amp = text.IndexOf('&');
2691 if (amp + 1 < text.Length) {
2692 if (text[amp + 1] != '&') {
2693 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2703 #region Protected Static Methods
2704 [EditorBrowsable(EditorBrowsableState.Advanced)]
2705 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2708 c = Control.FromHandle(hWnd);
2718 #region Public Instance Methods
2719 [EditorBrowsable(EditorBrowsableState.Advanced)]
2720 public IAsyncResult BeginInvoke(Delegate method) {
2721 object [] prms = null;
2722 if (method is EventHandler)
2723 prms = new object [] { this, EventArgs.Empty };
2724 return BeginInvokeInternal(method, prms, false);
2727 [EditorBrowsable(EditorBrowsableState.Advanced)]
2728 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2729 return BeginInvokeInternal (method, args, false);
2732 public void BringToFront() {
2733 if (parent != null) {
2734 parent.child_controls.SetChildIndex(this, 0);
2737 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2741 public bool Contains(Control ctl) {
2742 while (ctl != null) {
2751 public void CreateControl() {
2753 throw new ObjectDisposedException(GetType().FullName.ToString());
2759 if (!IsHandleCreated) {
2767 Control [] controls = child_controls.GetAllControls ();
2768 for (int i=0; i<controls.Length; i++) {
2769 controls [i].CreateControl ();
2772 UpdateChildrenZOrder();
2774 if (binding_context == null) { // seem to be sent whenever it's null?
2775 OnBindingContextChanged(EventArgs.Empty);
2781 public Graphics CreateGraphics() {
2782 if (!IsHandleCreated) {
2783 this.CreateHandle();
2785 return Graphics.FromHwnd(this.window.Handle);
2788 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2789 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2792 [EditorBrowsable(EditorBrowsableState.Advanced)]
2793 public object EndInvoke (IAsyncResult async_result) {
2794 AsyncMethodResult result = (AsyncMethodResult) async_result;
2795 return result.EndInvoke ();
2798 public Form FindForm() {
2811 public bool Focus() {
2812 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2815 is_focusing = false;
2820 public Control GetChildAtPoint(Point pt) {
2821 // Microsoft's version of this function doesn't seem to work, so I can't check
2822 // if we only consider children or also grandchildren, etc.
2823 // I'm gonna say 'children only'
2824 for (int i=0; i<child_controls.Count; i++) {
2825 if (child_controls[i].Bounds.Contains(pt)) {
2826 return child_controls[i];
2832 public IContainerControl GetContainerControl() {
2833 Control current = this;
2835 while (current!=null) {
2836 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2837 return (IContainerControl)current;
2839 current = current.parent;
2844 public Control GetNextControl(Control ctl, bool forward) {
2846 if (!this.Contains(ctl)) {
2851 ctl = FindControlForward(this, ctl);
2854 ctl = FindControlBackward(this, ctl);
2864 public virtual Size GetPreferredSize (Size proposedSize) {
2865 return preferred_size;
2869 public void Hide() {
2870 this.Visible = false;
2873 public void Invalidate() {
2874 Invalidate(ClientRectangle, false);
2877 public void Invalidate(bool invalidateChildren) {
2878 Invalidate(ClientRectangle, invalidateChildren);
2881 public void Invalidate(System.Drawing.Rectangle rc) {
2882 Invalidate(rc, false);
2885 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2886 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2890 NotifyInvalidate(rc);
2892 XplatUI.Invalidate(Handle, rc, false);
2894 if (invalidateChildren) {
2895 Control [] controls = child_controls.GetAllControls ();
2896 for (int i=0; i<controls.Length; i++)
2897 controls [i].Invalidate ();
2899 OnInvalidated(new InvalidateEventArgs(rc));
2902 public void Invalidate(System.Drawing.Region region) {
2903 Invalidate(region, false);
2906 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2907 RectangleF bounds = region.GetBounds (CreateGraphics ());
2908 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2909 invalidateChildren);
2912 public object Invoke (Delegate method) {
2913 object [] prms = null;
2914 if (method is EventHandler)
2915 prms = new object [] { this, EventArgs.Empty };
2917 return Invoke(method, prms);
2920 public object Invoke (Delegate method, object[] args) {
2921 if (!this.InvokeRequired) {
2922 return method.DynamicInvoke(args);
2925 IAsyncResult result = BeginInvoke (method, args);
2926 return EndInvoke(result);
2929 internal object InvokeInternal (Delegate method, bool disposing) {
2930 return InvokeInternal(method, null, disposing);
2933 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2934 if (!this.InvokeRequired) {
2935 return method.DynamicInvoke(args);
2938 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2939 return EndInvoke(result);
2942 [EditorBrowsable(EditorBrowsableState.Advanced)]
2943 public void PerformLayout() {
2944 PerformLayout(null, null);
2948 private void SetImplicitBounds (int x, int y, int width, int height)
2950 Rectangle saved_bounds = explicit_bounds;
2951 SetBounds (x, y, width, height);
2952 explicit_bounds = saved_bounds;
2956 [EditorBrowsable(EditorBrowsableState.Advanced)]
2957 public void PerformLayout(Control affectedControl, string affectedProperty) {
2958 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2960 if (layout_suspended > 0) {
2961 layout_pending = true;
2965 layout_pending = false;
2967 // Prevent us from getting messed up
2970 // Perform all Dock and Anchor calculations
2974 this.layout_engine.Layout(this, levent);
2976 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2978 AnchorStyles anchor;
2981 space = DisplayRectangle;
2983 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2984 Control [] controls = child_controls.GetAllControls ();
2985 for (int i = controls.Length - 1; i >= 0; i--) {
2986 child = controls [i];
2988 if (!child.Visible) {
2992 switch (child.Dock) {
2993 case DockStyle.None: {
2998 case DockStyle.Left: {
2999 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3000 space.X+=child.Width;
3001 space.Width-=child.Width;
3005 case DockStyle.Top: {
3006 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3007 space.Y+=child.Height;
3008 space.Height-=child.Height;
3012 case DockStyle.Right: {
3013 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3014 space.Width-=child.Width;
3018 case DockStyle.Bottom: {
3019 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3020 space.Height-=child.Height;
3026 for (int i = controls.Length - 1; i >= 0; i--) {
3029 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3030 if (child.Dock == DockStyle.Fill) {
3031 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3035 space = DisplayRectangle;
3037 for (int i=0; i < controls.Length; i++) {
3043 child = controls[i];
3045 // If the control is docked we don't need to do anything
3046 if (child.Dock != DockStyle.None) {
3050 anchor = child.Anchor;
3054 width = child.Width;
3055 height = child.Height;
3057 if ((anchor & AnchorStyles.Left) !=0 ) {
3058 if ((anchor & AnchorStyles.Right) != 0) {
3059 width = space.Width - child.dist_right - left;
3061 ; // Left anchored only, nothing to be done
3063 } else if ((anchor & AnchorStyles.Right) != 0) {
3064 left = space.Width - child.dist_right - width;
3066 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3067 // This calculates from scratch every time:
3068 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3071 if ((anchor & AnchorStyles.Top) !=0 ) {
3072 if ((anchor & AnchorStyles.Bottom) != 0) {
3073 height = space.Height - child.dist_bottom - top;
3075 ; // Top anchored only, nothing to be done
3077 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3078 top = space.Height - child.dist_bottom - height;
3080 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3081 // This calculates from scratch every time:
3082 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3094 child.SetImplicitBounds(left, top, width, height);
3098 // Let everyone know
3102 // Need to make sure we decremend layout_suspended
3108 public Point PointToClient (Point p) {
3112 XplatUI.ScreenToClient (Handle, ref x, ref y);
3114 return new Point (x, y);
3117 public Point PointToScreen(Point p) {
3121 XplatUI.ClientToScreen(Handle, ref x, ref y);
3123 return new Point(x, y);
3126 public virtual bool PreProcessMessage(ref Message msg) {
3127 return InternalPreProcessMessage (ref msg);
3130 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3133 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3134 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3136 if (!ProcessCmdKey(ref msg, key_data)) {
3137 if (IsInputKey(key_data)) {
3141 return ProcessDialogKey(key_data);
3145 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3146 if (IsInputChar((char)msg.WParam)) {
3149 return ProcessDialogChar((char)msg.WParam);
3150 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3151 return ProcessDialogChar((char)msg.WParam);
3156 public Rectangle RectangleToClient(Rectangle r) {
3157 return new Rectangle(PointToClient(r.Location), r.Size);
3160 public Rectangle RectangleToScreen(Rectangle r) {
3161 return new Rectangle(PointToScreen(r.Location), r.Size);
3164 public virtual void Refresh() {
3165 if (IsHandleCreated == true) {
3167 XplatUI.UpdateWindow(window.Handle);
3169 Control [] controls = child_controls.GetAllControls ();
3170 for (int i=0; i < controls.Length; i++) {
3171 controls[i].Refresh();
3177 [EditorBrowsable(EditorBrowsableState.Never)]
3178 public virtual void ResetBackColor() {
3179 BackColor = Color.Empty;
3182 [EditorBrowsable(EditorBrowsableState.Never)]
3183 public void ResetBindings() {
3184 data_bindings.Clear();
3187 [EditorBrowsable(EditorBrowsableState.Never)]
3188 public virtual void ResetCursor() {
3192 [EditorBrowsable(EditorBrowsableState.Never)]
3193 public virtual void ResetFont() {
3197 [EditorBrowsable(EditorBrowsableState.Never)]
3198 public virtual void ResetForeColor() {
3199 foreground_color = Color.Empty;
3202 [EditorBrowsable(EditorBrowsableState.Never)]
3203 public void ResetImeMode() {
3204 ime_mode = DefaultImeMode;
3207 [EditorBrowsable(EditorBrowsableState.Never)]
3208 public virtual void ResetRightToLeft() {
3209 right_to_left = RightToLeft.Inherit;
3212 public virtual void ResetText() {
3213 text = String.Empty;
3216 public void ResumeLayout() {
3217 ResumeLayout (true);
3220 public void ResumeLayout(bool performLayout) {
3221 if (layout_suspended > 0) {
3225 if (layout_suspended == 0) {
3226 Control [] controls = child_controls.GetAllControls ();
3227 for (int i=0; i<controls.Length; i++) {
3228 controls [i].UpdateDistances ();
3231 if (performLayout && layout_pending) {
3237 public void Scale(float ratio) {
3238 ScaleCore(ratio, ratio);
3241 public void Scale(float dx, float dy) {
3246 public void Scale(SizeF factor) {
3247 ScaleCore(factor.Width, factor.Height);
3251 public void Select() {
3252 Select(false, false);
3256 private void printTree(Control c, string t) {
3257 foreach(Control i in c.child_controls) {
3258 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3259 printTree(i, t+"\t");
3263 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3267 Console.WriteLine("{0}", this.FindForm());
3268 printTree(this, "\t");
3271 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3276 c = GetNextControl(c, forward);
3285 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3286 c.Select (true, true);
3289 } while (c != ctl); // If we wrap back to ourselves we stop
3294 public void SendToBack() {
3295 if (parent != null) {
3296 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3300 public void SetBounds(int x, int y, int width, int height) {
3301 SetBounds(x, y, width, height, BoundsSpecified.All);
3304 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3305 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3309 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3313 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3317 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3321 SetBoundsCore(x, y, width, height, specified);
3322 if (parent != null) {
3323 parent.PerformLayout(this, "Bounds");
3327 public void Show() {
3329 this.CreateControl();
3335 public void SuspendLayout() {
3339 public void Update() {
3340 if (IsHandleCreated) {
3341 XplatUI.UpdateWindow(window.Handle);
3344 #endregion // Public Instance Methods
3346 #region Protected Instance Methods
3347 [EditorBrowsable(EditorBrowsableState.Advanced)]
3348 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3349 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3350 throw new NotImplementedException();
3353 [EditorBrowsable(EditorBrowsableState.Advanced)]
3354 protected virtual AccessibleObject CreateAccessibilityInstance() {
3355 return new Control.ControlAccessibleObject(this);
3358 [EditorBrowsable(EditorBrowsableState.Advanced)]
3359 protected virtual ControlCollection CreateControlsInstance() {
3360 return new ControlCollection(this);
3363 [EditorBrowsable(EditorBrowsableState.Advanced)]
3364 protected virtual void CreateHandle() {
3366 throw new ObjectDisposedException(GetType().FullName.ToString());
3369 if (IsHandleCreated && !is_recreating) {
3373 window.CreateHandle(CreateParams);
3375 if (window.Handle != IntPtr.Zero) {
3376 lock (Control.controls) {
3377 if (!Control.controls.Contains(window.Handle)) {
3378 Control.controls.Add(this);
3382 creator_thread = Thread.CurrentThread;
3384 XplatUI.EnableWindow(window.Handle, is_enabled);
3385 XplatUI.SetVisible(window.Handle, is_visible, true);
3387 if (clip_region != null) {
3388 XplatUI.SetClipRegion(Handle, clip_region);
3391 // Set our handle with our parent
3392 if ((parent != null) && (parent.IsHandleCreated)) {
3393 XplatUI.SetParent(window.Handle, parent.Handle);
3396 // Set our handle as parent for our children
3397 Control [] children;
3399 children = child_controls.GetAllControls ();
3400 for (int i = 0; i < children.Length; i++ ) {
3401 if (!children[i].RecreatingHandle)
3402 XplatUI.SetParent(children[i].Handle, window.Handle);
3406 XplatUI.SetAllowDrop (Handle, allow_drop);
3408 // Find out where the window manager placed us
3409 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3410 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3414 OnHandleCreated(EventArgs.Empty);
3418 [EditorBrowsable(EditorBrowsableState.Advanced)]
3419 protected virtual void DefWndProc(ref Message m) {
3420 window.DefWndProc(ref m);
3423 [EditorBrowsable(EditorBrowsableState.Advanced)]
3424 protected virtual void DestroyHandle() {
3425 if (IsHandleCreated) {
3426 if (window != null) {
3427 window.DestroyHandle();
3432 protected internal bool GetStyle(ControlStyles flag) {
3433 return (control_style & flag) != 0;
3436 protected bool GetTopLevel() {
3440 [EditorBrowsable(EditorBrowsableState.Advanced)]
3441 protected virtual void InitLayout() {
3445 [EditorBrowsable(EditorBrowsableState.Advanced)]
3446 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3447 toInvoke.OnGotFocus(e);
3450 [EditorBrowsable(EditorBrowsableState.Advanced)]
3451 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3452 toInvoke.OnLostFocus(e);
3455 [EditorBrowsable(EditorBrowsableState.Advanced)]
3456 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3457 toInvoke.OnClick(e);
3460 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3461 toInvoke.OnPaint(e);
3464 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3465 toInvoke.OnPaintBackground(e);
3468 protected virtual bool IsInputChar (char charCode) {
3472 protected virtual bool IsInputKey (Keys keyData) {
3473 // Doc says this one calls IsInputChar; not sure what to do with that
3477 [EditorBrowsable(EditorBrowsableState.Advanced)]
3478 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3482 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3483 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3487 if (parent != null) {
3488 return parent.ProcessCmdKey(ref msg, keyData);
3494 protected virtual bool ProcessDialogChar(char charCode) {
3495 if (parent != null) {
3496 return parent.ProcessDialogChar (charCode);
3502 protected virtual bool ProcessDialogKey (Keys keyData) {
3503 if (parent != null) {
3504 return parent.ProcessDialogKey (keyData);
3510 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3512 KeyEventArgs key_event;
3515 case (int)Msg.WM_SYSKEYDOWN:
3516 case (int)Msg.WM_KEYDOWN: {
3517 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3518 OnKeyDown (key_event);
3519 return key_event.Handled;
3522 case (int)Msg.WM_SYSKEYUP:
3523 case (int)Msg.WM_KEYUP: {
3524 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3525 OnKeyUp (key_event);
3526 return key_event.Handled;
3529 case (int)Msg.WM_SYSCHAR:
3530 case (int)Msg.WM_CHAR: {
3531 KeyPressEventArgs key_press_event;
3533 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3534 OnKeyPress(key_press_event);
3536 msg.WParam = (IntPtr)key_press_event.KeyChar;
3538 return key_press_event.Handled;
3549 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3550 if (parent != null) {
3551 if (parent.ProcessKeyPreview(ref msg)) {
3556 return ProcessKeyEventArgs(ref msg);
3559 protected virtual bool ProcessKeyPreview(ref Message msg) {
3560 if (parent != null) {
3561 return parent.ProcessKeyPreview(ref msg);
3567 protected virtual bool ProcessMnemonic(char charCode) {
3572 [EditorBrowsable(EditorBrowsableState.Advanced)]
3573 protected void RaiseDragEvent(object key, DragEventArgs e) {
3577 [EditorBrowsable(EditorBrowsableState.Advanced)]
3578 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3582 [EditorBrowsable(EditorBrowsableState.Advanced)]
3583 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3587 [EditorBrowsable(EditorBrowsableState.Advanced)]
3588 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3592 private void SetIsRecreating ()
3596 foreach (Control c in Controls.GetAllControls()) {
3597 c.SetIsRecreating ();
3601 [EditorBrowsable(EditorBrowsableState.Advanced)]
3602 protected void RecreateHandle() {
3604 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3609 if (IsHandleCreated) {
3611 Console.WriteLine(" + handle is created, destroying it.");
3614 // WM_DESTROY will CreateHandle for us
3617 Console.WriteLine(" + handle is not created, creating it.");
3625 is_recreating = false;
3627 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3633 [EditorBrowsable(EditorBrowsableState.Advanced)]
3634 protected void ResetMouseEventArgs() {
3638 [EditorBrowsable(EditorBrowsableState.Advanced)]
3639 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3640 if (right_to_left == RightToLeft.No) {
3645 case ContentAlignment.TopLeft: {
3646 return ContentAlignment.TopRight;
3649 case ContentAlignment.TopRight: {
3650 return ContentAlignment.TopLeft;
3653 case ContentAlignment.MiddleLeft: {
3654 return ContentAlignment.MiddleRight;
3657 case ContentAlignment.MiddleRight: {
3658 return ContentAlignment.MiddleLeft;
3661 case ContentAlignment.BottomLeft: {
3662 return ContentAlignment.BottomRight;
3665 case ContentAlignment.BottomRight: {
3666 return ContentAlignment.BottomLeft;
3670 // if it's center it doesn't change
3676 [EditorBrowsable(EditorBrowsableState.Advanced)]
3677 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3678 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3682 if (align == HorizontalAlignment.Left) {
3683 return HorizontalAlignment.Right;
3686 // align must be HorizontalAlignment.Right
3687 return HorizontalAlignment.Left;
3690 [EditorBrowsable(EditorBrowsableState.Advanced)]
3691 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3692 if (right_to_left == RightToLeft.No) {
3696 if (align == LeftRightAlignment.Left) {
3697 return LeftRightAlignment.Right;
3700 // align must be LeftRightAlignment.Right;
3701 return LeftRightAlignment.Left;
3704 [EditorBrowsable(EditorBrowsableState.Advanced)]
3705 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3706 return RtlTranslateAlignment(align);
3709 [EditorBrowsable(EditorBrowsableState.Advanced)]
3710 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3711 return RtlTranslateAlignment(align);
3714 [EditorBrowsable(EditorBrowsableState.Advanced)]
3715 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3716 return RtlTranslateAlignment(align);
3719 [EditorBrowsable(EditorBrowsableState.Advanced)]
3720 protected virtual void ScaleCore(float dx, float dy) {
3726 location = new Point((int)(Left * dx), (int)(Top * dy));
3727 size = this.ClientSize;
3729 if (!GetStyle(ControlStyles.FixedWidth)) {
3730 size.Width = (int)(size.Width * dx);
3733 if (!GetStyle(ControlStyles.FixedHeight)) {
3734 size.Height = (int)(size.Height * dy);
3737 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3739 /* Now scale our children */
3740 Control [] controls = child_controls.GetAllControls ();
3741 for (int i=0; i < controls.Length; i++) {
3742 controls[i].Scale(dx, dy);
3748 protected virtual void Select(bool directed, bool forward) {
3749 IContainerControl container;
3751 container = GetContainerControl();
3752 if (container != null)
3753 container.ActiveControl = this;
3756 [EditorBrowsable(EditorBrowsableState.Advanced)]
3757 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3758 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3759 if (IsHandleCreated) {
3760 XplatUI.SetWindowPos(Handle, x, y, width, height);
3762 // Win32 automatically changes negative width/height to 0.
3763 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3764 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3766 if (width < 0 || height < 0) {
3768 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3772 UpdateBounds(x, y, width, height);
3777 [EditorBrowsable(EditorBrowsableState.Advanced)]
3778 protected virtual void SetClientSizeCore(int x, int y) {
3779 // Calculate the actual window size from the client size (it usually stays the same or grows)
3780 Rectangle ClientRect;
3781 Rectangle WindowRect;
3784 ClientRect = new Rectangle(0, 0, x, y);
3785 cp = this.CreateParams;
3787 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3791 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3794 [EditorBrowsable(EditorBrowsableState.Advanced)]
3795 protected internal void SetStyle(ControlStyles flag, bool value) {
3797 control_style |= flag;
3799 control_style &= ~flag;
3803 protected void SetTopLevel(bool value) {
3804 if ((GetTopLevel() != value) && (parent != null)) {
3805 throw new Exception();
3809 if (value == true) {
3819 is_toplevel = value;
3822 protected virtual void SetVisibleCore(bool value) {
3823 if (value!=is_visible) {
3824 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3830 if (IsHandleCreated) {
3831 XplatUI.SetVisible(Handle, value, true);
3832 // Explicitly move Toplevel windows to where we want them;
3833 // apparently moving unmapped toplevel windows doesn't work
3834 if (is_visible && (this is Form)) {
3835 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3839 OnVisibleChanged(EventArgs.Empty);
3841 if (value == false && parent != null && Focused) {
3844 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3845 container = (Control)parent.GetContainerControl();
3846 if (container != null) {
3847 container.SelectNextControl(this, true, true, true, true);
3851 if (parent != null) {
3852 parent.PerformLayout(this, "visible");
3854 PerformLayout(this, "visible");
3859 [EditorBrowsable(EditorBrowsableState.Advanced)]
3860 protected void UpdateBounds() {
3868 if (!IsHandleCreated) {
3872 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3874 UpdateBounds(x, y, width, height, client_width, client_height);
3877 [EditorBrowsable(EditorBrowsableState.Advanced)]
3878 protected void UpdateBounds(int x, int y, int width, int height) {
3882 // Calculate client rectangle
3883 rect = new Rectangle(0, 0, 0, 0);
3886 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3887 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3890 [EditorBrowsable(EditorBrowsableState.Advanced)]
3891 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3892 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3894 bool resized = false;
3896 // Needed to generate required notifications
3897 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3901 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3908 bounds.Height=height;
3910 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3911 explicit_bounds = bounds;
3913 client_size.Width=clientWidth;
3914 client_size.Height=clientHeight;
3917 OnLocationChanged(EventArgs.Empty);
3921 OnSizeChanged(EventArgs.Empty);
3925 [EditorBrowsable(EditorBrowsableState.Advanced)]
3926 protected void UpdateStyles() {
3927 if (!IsHandleCreated) {
3931 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3932 OnStyleChanged(EventArgs.Empty);
3935 private void UpdateZOrderOfChild(Control child) {
3936 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3939 index = child_controls.IndexOf(child);
3942 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3944 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3949 private void UpdateChildrenZOrder() {
3950 Control [] controls;
3952 if (!IsHandleCreated) {
3956 controls = child_controls.GetAllControls ();
3957 for (int i = 1; i < controls.Length; i++ ) {
3958 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3962 [EditorBrowsable(EditorBrowsableState.Advanced)]
3963 protected void UpdateZOrder() {
3964 if (parent != null) {
3965 parent.UpdateZOrderOfChild(this);
3969 protected virtual void WndProc(ref Message m) {
3971 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3973 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3977 switch((Msg)m.Msg) {
3978 case Msg.WM_DESTROY: {
3979 OnHandleDestroyed(EventArgs.Empty);
3981 IntPtr handle = window.Handle;
3983 window.InvalidateHandle();
3985 if (is_recreating) {
3987 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
3991 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3993 is_recreating = false;
3998 case Msg.WM_WINDOWPOSCHANGED: {
4000 Rectangle save_bounds = explicit_bounds;
4002 explicit_bounds = save_bounds;
4003 if (GetStyle(ControlStyles.ResizeRedraw)) {
4010 // Nice description of what should happen when handling WM_PAINT
4011 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4012 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4013 case Msg.WM_PAINT: {
4014 PaintEventArgs paint_event;
4016 paint_event = XplatUI.PaintEventStart(Handle, true);
4018 if (paint_event == null) {
4022 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4024 // Just blit the previous image
4025 XplatUI.BlitFromOffscreen (Handle, paint_event.Graphics, backbuffer, backbuffer_dc, paint_event.ClipRectangle);
4026 XplatUI.PaintEventEnd (Handle, true);
4031 Graphics back_dc = null;
4033 if (ThemeEngine.Current.DoubleBufferingSupported) {
4034 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4035 CreateBackBuffer ();
4037 back_dc = backbuffer_dc;
4038 dc = paint_event.SetGraphics (back_dc);
4042 if (!GetStyle(ControlStyles.Opaque)) {
4043 OnPaintBackground(paint_event);
4046 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4047 OnPaintBackgroundInternal(paint_event);
4049 OnPaintInternal(paint_event);
4050 if (!paint_event.Handled) {
4051 OnPaint(paint_event);
4054 if (ThemeEngine.Current.DoubleBufferingSupported)
4055 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4056 XplatUI.BlitFromOffscreen (Handle, dc, back, back_dc, paint_event.ClipRectangle);
4057 paint_event.SetGraphics (dc);
4058 invalid_region.Exclude (paint_event.ClipRectangle);
4060 if (back != backbuffer)
4061 XplatUI.DestroyOffscreenDrawable (back, back_dc);
4064 XplatUI.PaintEventEnd(Handle, true);
4069 case Msg.WM_ERASEBKGND: {
4070 // The DefWndProc will never have to handle this, we always paint the background in managed code
4071 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4072 // here but it just makes things more complicated...
4073 m.Result = (IntPtr)1;
4077 case Msg.WM_LBUTTONUP: {
4080 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4082 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4085 HandleClick(mouse_clicks, me);
4088 if (InternalCapture) {
4089 InternalCapture = false;
4092 if (mouse_clicks > 1) {
4098 case Msg.WM_LBUTTONDOWN: {
4100 Select (true, true);
4102 InternalCapture = true;
4103 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4104 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4110 case Msg.WM_LBUTTONDBLCLK: {
4111 InternalCapture = true;
4113 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4114 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4119 case Msg.WM_MBUTTONUP: {
4122 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4124 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4127 HandleClick(mouse_clicks, me);
4129 if (InternalCapture) {
4130 InternalCapture = false;
4132 if (mouse_clicks > 1) {
4138 case Msg.WM_MBUTTONDOWN: {
4139 InternalCapture = true;
4140 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4141 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4146 case Msg.WM_MBUTTONDBLCLK: {
4147 InternalCapture = true;
4149 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4150 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4155 case Msg.WM_RBUTTONUP: {
4159 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4160 pt = PointToScreen(pt);
4162 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4164 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4166 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4169 HandleClick(mouse_clicks, me);
4172 if (InternalCapture) {
4173 InternalCapture = false;
4176 if (mouse_clicks > 1) {
4182 case Msg.WM_RBUTTONDOWN: {
4183 InternalCapture = true;
4184 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4185 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4190 case Msg.WM_RBUTTONDBLCLK: {
4191 InternalCapture = true;
4193 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4194 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4199 case Msg.WM_CONTEXTMENU: {
4200 if (context_menu != null) {
4203 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4204 context_menu.Show(this, PointToClient(pt));
4212 case Msg.WM_MOUSEWHEEL: {
4214 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4215 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4216 HighOrder(m.WParam.ToInt32())));
4221 case Msg.WM_MOUSEMOVE: {
4222 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4224 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4229 case Msg.WM_MOUSE_ENTER: {
4234 OnMouseEnter(EventArgs.Empty);
4238 case Msg.WM_MOUSE_LEAVE: {
4240 OnMouseLeave(EventArgs.Empty);
4244 case Msg.WM_MOUSEHOVER: {
4245 OnMouseHover(EventArgs.Empty);
4249 case Msg.WM_SYSKEYUP: {
4250 if (ProcessKeyMessage(ref m)) {
4251 m.Result = IntPtr.Zero;
4255 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4259 if (form != null && form.ActiveMenu != null) {
4260 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4268 case Msg.WM_SYSKEYDOWN:
4269 case Msg.WM_KEYDOWN:
4271 case Msg.WM_SYSCHAR:
4273 if (ProcessKeyMessage(ref m)) {
4274 m.Result = IntPtr.Zero;
4283 if (m.LParam != IntPtr.Zero) {
4286 hi = new HELPINFO();
4288 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4289 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4291 mouse_pos = Control.MousePosition;
4293 OnHelpRequested(new HelpEventArgs(mouse_pos));
4294 m.Result = (IntPtr)1;
4298 case Msg.WM_KILLFOCUS: {
4299 this.has_focus = false;
4300 OnLostFocusInternal (EventArgs.Empty);
4304 case Msg.WM_SETFOCUS: {
4306 this.has_focus = true;
4307 OnGotFocusInternal (EventArgs.Empty);
4312 case Msg.WM_SYSCOLORCHANGE: {
4313 ThemeEngine.Current.ResetDefaults();
4314 OnSystemColorsChanged(EventArgs.Empty);
4318 case Msg.WM_SETCURSOR: {
4319 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4324 XplatUI.SetCursor(window.Handle, cursor.handle);
4325 m.Result = (IntPtr)1;
4335 #endregion // Public Instance Methods
4337 #region OnXXX methods
4338 [EditorBrowsable(EditorBrowsableState.Advanced)]
4339 protected virtual void OnBackColorChanged(EventArgs e) {
4340 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4343 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4346 [EditorBrowsable(EditorBrowsableState.Advanced)]
4347 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4348 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4351 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4354 [EditorBrowsable(EditorBrowsableState.Advanced)]
4355 protected virtual void OnBindingContextChanged(EventArgs e) {
4356 CheckDataBindings ();
4357 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4360 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4363 [EditorBrowsable(EditorBrowsableState.Advanced)]
4364 protected virtual void OnCausesValidationChanged(EventArgs e) {
4365 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4370 [EditorBrowsable(EditorBrowsableState.Advanced)]
4371 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4372 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4377 [EditorBrowsable(EditorBrowsableState.Advanced)]
4378 protected virtual void OnClick(EventArgs e) {
4379 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4384 [EditorBrowsable(EditorBrowsableState.Advanced)]
4385 protected virtual void OnContextMenuChanged(EventArgs e) {
4386 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4391 [EditorBrowsable(EditorBrowsableState.Advanced)]
4392 protected virtual void OnControlAdded(ControlEventArgs e) {
4393 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4398 [EditorBrowsable(EditorBrowsableState.Advanced)]
4399 protected virtual void OnControlRemoved(ControlEventArgs e) {
4400 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4405 [EditorBrowsable(EditorBrowsableState.Advanced)]
4406 protected virtual void OnCreateControl() {
4410 [EditorBrowsable(EditorBrowsableState.Advanced)]
4411 protected virtual void OnCursorChanged(EventArgs e) {
4412 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4417 [EditorBrowsable(EditorBrowsableState.Advanced)]
4418 protected virtual void OnDockChanged(EventArgs e) {
4419 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4424 [EditorBrowsable(EditorBrowsableState.Advanced)]
4425 protected virtual void OnDoubleClick(EventArgs e) {
4426 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4431 [EditorBrowsable(EditorBrowsableState.Advanced)]
4432 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4433 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4435 eh (this, drgevent);
4438 [EditorBrowsable(EditorBrowsableState.Advanced)]
4439 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4440 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4442 eh (this, drgevent);
4445 [EditorBrowsable(EditorBrowsableState.Advanced)]
4446 protected virtual void OnDragLeave(EventArgs e) {
4447 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4452 [EditorBrowsable(EditorBrowsableState.Advanced)]
4453 protected virtual void OnDragOver(DragEventArgs drgevent) {
4454 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4456 eh (this, drgevent);
4459 [EditorBrowsable(EditorBrowsableState.Advanced)]
4460 protected virtual void OnEnabledChanged(EventArgs e) {
4461 if (IsHandleCreated) {
4463 if (((Form)this).context == null) {
4464 XplatUI.EnableWindow(window.Handle, Enabled);
4467 XplatUI.EnableWindow(window.Handle, Enabled);
4472 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4476 for (int i=0; i<child_controls.Count; i++) {
4477 child_controls[i].OnParentEnabledChanged(e);
4481 [EditorBrowsable(EditorBrowsableState.Advanced)]
4482 protected virtual void OnEnter(EventArgs e) {
4483 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4488 [EditorBrowsable(EditorBrowsableState.Advanced)]
4489 protected virtual void OnFontChanged(EventArgs e) {
4490 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4493 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4496 [EditorBrowsable(EditorBrowsableState.Advanced)]
4497 protected virtual void OnForeColorChanged(EventArgs e) {
4498 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4501 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4504 [EditorBrowsable(EditorBrowsableState.Advanced)]
4505 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4506 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4508 eh (this, gfbevent);
4511 [EditorBrowsable(EditorBrowsableState.Advanced)]
4512 protected virtual void OnGotFocus(EventArgs e) {
4513 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4518 [EditorBrowsable(EditorBrowsableState.Advanced)]
4519 protected virtual void OnHandleCreated(EventArgs e) {
4520 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4525 [EditorBrowsable(EditorBrowsableState.Advanced)]
4526 protected virtual void OnHandleDestroyed(EventArgs e) {
4527 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4532 [EditorBrowsable(EditorBrowsableState.Advanced)]
4533 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4534 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4539 protected virtual void OnImeModeChanged(EventArgs e) {
4540 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4545 [EditorBrowsable(EditorBrowsableState.Advanced)]
4546 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4547 if (ThemeEngine.Current.DoubleBufferingSupported)
4548 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4549 // should this block be here? seems like it
4550 // would be more at home in
4551 // NotifyInvalidated..
4552 if (e.InvalidRect == ClientRectangle) {
4553 InvalidateBackBuffer ();
4556 // we need this Inflate call here so
4557 // that the border of the rectangle is
4558 // considered Visible (the
4559 // invalid_region.IsVisible call) in
4560 // the WM_PAINT handling below.
4561 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4562 if (invalid_region == null)
4563 invalid_region = new Region (r);
4565 invalid_region.Union (r);
4569 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4574 [EditorBrowsable(EditorBrowsableState.Advanced)]
4575 protected virtual void OnKeyDown(KeyEventArgs e) {
4576 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4581 [EditorBrowsable(EditorBrowsableState.Advanced)]
4582 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4583 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4588 [EditorBrowsable(EditorBrowsableState.Advanced)]
4589 protected virtual void OnKeyUp(KeyEventArgs e) {
4590 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4595 [EditorBrowsable(EditorBrowsableState.Advanced)]
4596 protected virtual void OnLayout(LayoutEventArgs levent) {
4597 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4602 [EditorBrowsable(EditorBrowsableState.Advanced)]
4603 protected virtual void OnLeave(EventArgs e) {
4604 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4609 [EditorBrowsable(EditorBrowsableState.Advanced)]
4610 protected virtual void OnLocationChanged(EventArgs e) {
4612 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4617 [EditorBrowsable(EditorBrowsableState.Advanced)]
4618 protected virtual void OnLostFocus(EventArgs e) {
4619 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4624 [EditorBrowsable(EditorBrowsableState.Advanced)]
4625 protected virtual void OnMouseDown(MouseEventArgs e) {
4626 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4631 [EditorBrowsable(EditorBrowsableState.Advanced)]
4632 protected virtual void OnMouseEnter(EventArgs e) {
4633 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4638 [EditorBrowsable(EditorBrowsableState.Advanced)]
4639 protected virtual void OnMouseHover(EventArgs e) {
4640 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4645 [EditorBrowsable(EditorBrowsableState.Advanced)]
4646 protected virtual void OnMouseLeave(EventArgs e) {
4647 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4652 [EditorBrowsable(EditorBrowsableState.Advanced)]
4653 protected virtual void OnMouseMove(MouseEventArgs e) {
4654 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4659 [EditorBrowsable(EditorBrowsableState.Advanced)]
4660 protected virtual void OnMouseUp(MouseEventArgs e) {
4661 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4666 [EditorBrowsable(EditorBrowsableState.Advanced)]
4667 protected virtual void OnMouseWheel(MouseEventArgs e) {
4668 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4673 [EditorBrowsable(EditorBrowsableState.Advanced)]
4674 protected virtual void OnMove(EventArgs e) {
4675 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4680 [EditorBrowsable(EditorBrowsableState.Advanced)]
4681 protected virtual void OnNotifyMessage(Message m) {
4685 [EditorBrowsable(EditorBrowsableState.Advanced)]
4686 protected virtual void OnPaint(PaintEventArgs e) {
4687 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4692 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4696 internal virtual void OnPaintInternal(PaintEventArgs e) {
4700 internal virtual void OnGotFocusInternal (EventArgs e)
4705 internal virtual void OnLostFocusInternal (EventArgs e)
4710 [EditorBrowsable(EditorBrowsableState.Advanced)]
4711 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4712 PaintControlBackground (pevent);
4715 [EditorBrowsable(EditorBrowsableState.Advanced)]
4716 protected virtual void OnParentBackColorChanged(EventArgs e) {
4717 if (background_color.IsEmpty && background_image==null) {
4719 OnBackColorChanged(e);
4723 [EditorBrowsable(EditorBrowsableState.Advanced)]
4724 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4725 if (background_color.IsEmpty && background_image==null) {
4727 OnBackgroundImageChanged(e);
4731 [EditorBrowsable(EditorBrowsableState.Advanced)]
4732 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4733 if (binding_context==null) {
4734 binding_context=Parent.binding_context;
4735 OnBindingContextChanged(e);
4739 [EditorBrowsable(EditorBrowsableState.Advanced)]
4740 protected virtual void OnParentChanged(EventArgs e) {
4741 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4746 [EditorBrowsable(EditorBrowsableState.Advanced)]
4747 protected virtual void OnParentEnabledChanged(EventArgs e) {
4749 OnEnabledChanged(e);
4753 [EditorBrowsable(EditorBrowsableState.Advanced)]
4754 protected virtual void OnParentFontChanged(EventArgs e) {
4761 [EditorBrowsable(EditorBrowsableState.Advanced)]
4762 protected virtual void OnParentForeColorChanged(EventArgs e) {
4763 if (foreground_color.IsEmpty) {
4765 OnForeColorChanged(e);
4769 [EditorBrowsable(EditorBrowsableState.Advanced)]
4770 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4771 if (right_to_left==RightToLeft.Inherit) {
4773 OnRightToLeftChanged(e);
4777 [EditorBrowsable(EditorBrowsableState.Advanced)]
4778 protected virtual void OnParentVisibleChanged(EventArgs e) {
4780 OnVisibleChanged(e);
4784 [EditorBrowsable(EditorBrowsableState.Advanced)]
4785 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4786 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4791 [EditorBrowsable(EditorBrowsableState.Advanced)]
4792 protected virtual void OnResize(EventArgs e) {
4793 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4797 PerformLayout(this, "bounds");
4799 if (parent != null) {
4800 parent.PerformLayout();
4804 [EditorBrowsable(EditorBrowsableState.Advanced)]
4805 protected virtual void OnRightToLeftChanged(EventArgs e) {
4806 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4809 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4812 [EditorBrowsable(EditorBrowsableState.Advanced)]
4813 protected virtual void OnSizeChanged(EventArgs e) {
4814 DisposeBackBuffer ();
4816 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4821 [EditorBrowsable(EditorBrowsableState.Advanced)]
4822 protected virtual void OnStyleChanged(EventArgs e) {
4823 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4828 [EditorBrowsable(EditorBrowsableState.Advanced)]
4829 protected virtual void OnSystemColorsChanged(EventArgs e) {
4830 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4835 [EditorBrowsable(EditorBrowsableState.Advanced)]
4836 protected virtual void OnTabIndexChanged(EventArgs e) {
4837 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4842 [EditorBrowsable(EditorBrowsableState.Advanced)]
4843 protected virtual void OnTabStopChanged(EventArgs e) {
4844 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4849 [EditorBrowsable(EditorBrowsableState.Advanced)]
4850 protected virtual void OnTextChanged(EventArgs e) {
4851 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4856 [EditorBrowsable(EditorBrowsableState.Advanced)]
4857 protected virtual void OnValidated(EventArgs e) {
4858 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4863 [EditorBrowsable(EditorBrowsableState.Advanced)]
4864 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4865 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4870 [EditorBrowsable(EditorBrowsableState.Advanced)]
4871 protected virtual void OnVisibleChanged(EventArgs e) {
4872 if ((parent != null) && !Created && Visible) {
4879 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4883 // We need to tell our kids
4884 for (int i=0; i<child_controls.Count; i++) {
4885 if (child_controls[i].Visible) {
4886 child_controls[i].OnParentVisibleChanged(e);
4890 #endregion // OnXXX methods
4893 static object BackColorChangedEvent = new object ();
4894 static object BackgroundImageChangedEvent = new object ();
4895 static object BindingContextChangedEvent = new object ();
4896 static object CausesValidationChangedEvent = new object ();
4897 static object ChangeUICuesEvent = new object ();
4898 static object ClickEvent = new object ();
4899 static object ContextMenuChangedEvent = new object ();
4900 static object ControlAddedEvent = new object ();
4901 static object ControlRemovedEvent = new object ();
4902 static object CursorChangedEvent = new object ();
4903 static object DockChangedEvent = new object ();
4904 static object DoubleClickEvent = new object ();
4905 static object DragDropEvent = new object ();
4906 static object DragEnterEvent = new object ();
4907 static object DragLeaveEvent = new object ();
4908 static object DragOverEvent = new object ();
4909 static object EnabledChangedEvent = new object ();
4910 static object EnterEvent = new object ();
4911 static object FontChangedEvent = new object ();
4912 static object ForeColorChangedEvent = new object ();
4913 static object GiveFeedbackEvent = new object ();
4914 static object GotFocusEvent = new object ();
4915 static object HandleCreatedEvent = new object ();
4916 static object HandleDestroyedEvent = new object ();
4917 static object HelpRequestedEvent = new object ();
4918 static object ImeModeChangedEvent = new object ();
4919 static object InvalidatedEvent = new object ();
4920 static object KeyDownEvent = new object ();
4921 static object KeyPressEvent = new object ();
4922 static object KeyUpEvent = new object ();
4923 static object LayoutEvent = new object ();
4924 static object LeaveEvent = new object ();
4925 static object LocationChangedEvent = new object ();
4926 static object LostFocusEvent = new object ();
4927 static object MouseDownEvent = new object ();
4928 static object MouseEnterEvent = new object ();
4929 static object MouseHoverEvent = new object ();
4930 static object MouseLeaveEvent = new object ();
4931 static object MouseMoveEvent = new object ();
4932 static object MouseUpEvent = new object ();
4933 static object MouseWheelEvent = new object ();
4934 static object MoveEvent = new object ();
4935 static object PaintEvent = new object ();
4936 static object ParentChangedEvent = new object ();
4937 static object QueryAccessibilityHelpEvent = new object ();
4938 static object QueryContinueDragEvent = new object ();
4939 static object ResizeEvent = new object ();
4940 static object RightToLeftChangedEvent = new object ();
4941 static object SizeChangedEvent = new object ();
4942 static object StyleChangedEvent = new object ();
4943 static object SystemColorsChangedEvent = new object ();
4944 static object TabIndexChangedEvent = new object ();
4945 static object TabStopChangedEvent = new object ();
4946 static object TextChangedEvent = new object ();
4947 static object ValidatedEvent = new object ();
4948 static object ValidatingEvent = new object ();
4949 static object VisibleChangedEvent = new object ();
4951 public event EventHandler BackColorChanged {
4952 add { Events.AddHandler (BackColorChangedEvent, value); }
4953 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4956 public event EventHandler BackgroundImageChanged {
4957 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4958 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4961 public event EventHandler BindingContextChanged {
4962 add { Events.AddHandler (BindingContextChangedEvent, value); }
4963 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4966 public event EventHandler CausesValidationChanged {
4967 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4968 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4971 public event UICuesEventHandler ChangeUICues {
4972 add { Events.AddHandler (ChangeUICuesEvent, value); }
4973 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4976 public event EventHandler Click {
4977 add { Events.AddHandler (ClickEvent, value); }
4978 remove { Events.RemoveHandler (ClickEvent, value); }
4981 public event EventHandler ContextMenuChanged {
4982 add { Events.AddHandler (ContextMenuChangedEvent, value); }
4983 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
4986 [EditorBrowsable(EditorBrowsableState.Advanced)]
4988 public event ControlEventHandler ControlAdded {
4989 add { Events.AddHandler (ControlAddedEvent, value); }
4990 remove { Events.RemoveHandler (ControlAddedEvent, value); }
4993 [EditorBrowsable(EditorBrowsableState.Advanced)]
4995 public event ControlEventHandler ControlRemoved {
4996 add { Events.AddHandler (ControlRemovedEvent, value); }
4997 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5000 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5001 public event EventHandler CursorChanged {
5002 add { Events.AddHandler (CursorChangedEvent, value); }
5003 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5005 public event EventHandler DockChanged {
5006 add { Events.AddHandler (DockChangedEvent, value); }
5007 remove { Events.RemoveHandler (DockChangedEvent, value); }
5010 public event EventHandler DoubleClick {
5011 add { Events.AddHandler (DoubleClickEvent, value); }
5012 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5015 public event DragEventHandler DragDrop {
5016 add { Events.AddHandler (DragDropEvent, value); }
5017 remove { Events.RemoveHandler (DragDropEvent, value); }
5020 public event DragEventHandler DragEnter {
5021 add { Events.AddHandler (DragEnterEvent, value); }
5022 remove { Events.RemoveHandler (DragEnterEvent, value); }
5025 public event EventHandler DragLeave {
5026 add { Events.AddHandler (DragLeaveEvent, value); }
5027 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5030 public event DragEventHandler DragOver {
5031 add { Events.AddHandler (DragOverEvent, value); }
5032 remove { Events.RemoveHandler (DragOverEvent, value); }
5035 public event EventHandler EnabledChanged {
5036 add { Events.AddHandler (EnabledChangedEvent, value); }
5037 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5040 public event EventHandler Enter {
5041 add { Events.AddHandler (EnterEvent, value); }
5042 remove { Events.RemoveHandler (EnterEvent, value); }
5045 public event EventHandler FontChanged {
5046 add { Events.AddHandler (FontChangedEvent, value); }
5047 remove { Events.RemoveHandler (FontChangedEvent, value); }
5050 public event EventHandler ForeColorChanged {
5051 add { Events.AddHandler (ForeColorChangedEvent, value); }
5052 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5055 public event GiveFeedbackEventHandler GiveFeedback {
5056 add { Events.AddHandler (GiveFeedbackEvent, value); }
5057 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5060 [EditorBrowsable(EditorBrowsableState.Advanced)]
5062 public event EventHandler GotFocus {
5063 add { Events.AddHandler (GotFocusEvent, value); }
5064 remove { Events.RemoveHandler (GotFocusEvent, value); }
5068 [EditorBrowsable(EditorBrowsableState.Advanced)]
5070 public event EventHandler HandleCreated {
5071 add { Events.AddHandler (HandleCreatedEvent, value); }
5072 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5075 [EditorBrowsable(EditorBrowsableState.Advanced)]
5077 public event EventHandler HandleDestroyed {
5078 add { Events.AddHandler (HandleDestroyedEvent, value); }
5079 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5082 public event HelpEventHandler HelpRequested {
5083 add { Events.AddHandler (HelpRequestedEvent, value); }
5084 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5087 public event EventHandler ImeModeChanged {
5088 add { Events.AddHandler (ImeModeChangedEvent, value); }
5089 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5092 [EditorBrowsable(EditorBrowsableState.Advanced)]
5094 public event InvalidateEventHandler Invalidated {
5095 add { Events.AddHandler (InvalidatedEvent, value); }
5096 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5099 public event KeyEventHandler KeyDown {
5100 add { Events.AddHandler (KeyDownEvent, value); }
5101 remove { Events.RemoveHandler (KeyDownEvent, value); }
5104 public event KeyPressEventHandler KeyPress {
5105 add { Events.AddHandler (KeyPressEvent, value); }
5106 remove { Events.RemoveHandler (KeyPressEvent, value); }
5109 public event KeyEventHandler KeyUp {
5110 add { Events.AddHandler (KeyUpEvent, value); }
5111 remove { Events.RemoveHandler (KeyUpEvent, value); }
5114 public event LayoutEventHandler Layout {
5115 add { Events.AddHandler (LayoutEvent, value); }
5116 remove { Events.RemoveHandler (LayoutEvent, value); }
5119 public event EventHandler Leave {
5120 add { Events.AddHandler (LeaveEvent, value); }
5121 remove { Events.RemoveHandler (LeaveEvent, value); }
5124 public event EventHandler LocationChanged {
5125 add { Events.AddHandler (LocationChangedEvent, value); }
5126 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5129 [EditorBrowsable(EditorBrowsableState.Advanced)]
5131 public event EventHandler LostFocus {
5132 add { Events.AddHandler (LostFocusEvent, value); }
5133 remove { Events.RemoveHandler (LostFocusEvent, value); }
5136 public event MouseEventHandler MouseDown {
5137 add { Events.AddHandler (MouseDownEvent, value); }
5138 remove { Events.RemoveHandler (MouseDownEvent, value); }
5141 public event EventHandler MouseEnter {
5142 add { Events.AddHandler (MouseEnterEvent, value); }
5143 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5146 public event EventHandler MouseHover {
5147 add { Events.AddHandler (MouseHoverEvent, value); }
5148 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5151 public event EventHandler MouseLeave {
5152 add { Events.AddHandler (MouseLeaveEvent, value); }
5153 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5156 public event MouseEventHandler MouseMove {
5157 add { Events.AddHandler (MouseMoveEvent, value); }
5158 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5161 public event MouseEventHandler MouseUp {
5162 add { Events.AddHandler (MouseUpEvent, value); }
5163 remove { Events.RemoveHandler (MouseUpEvent, value); }
5166 [EditorBrowsable(EditorBrowsableState.Advanced)]
5168 public event MouseEventHandler MouseWheel {
5169 add { Events.AddHandler (MouseWheelEvent, value); }
5170 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5173 public event EventHandler Move {
5174 add { Events.AddHandler (MoveEvent, value); }
5175 remove { Events.RemoveHandler (MoveEvent, value); }
5178 public event PaintEventHandler Paint {
5179 add { Events.AddHandler (PaintEvent, value); }
5180 remove { Events.RemoveHandler (PaintEvent, value); }
5183 public event EventHandler ParentChanged {
5184 add { Events.AddHandler (ParentChangedEvent, value); }
5185 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5188 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5189 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5190 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5193 public event QueryContinueDragEventHandler QueryContinueDrag {
5194 add { Events.AddHandler (QueryContinueDragEvent, value); }
5195 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5198 public event EventHandler Resize {
5199 add { Events.AddHandler (ResizeEvent, value); }
5200 remove { Events.RemoveHandler (ResizeEvent, value); }
5203 public event EventHandler RightToLeftChanged {
5204 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5205 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5208 public event EventHandler SizeChanged {
5209 add { Events.AddHandler (SizeChangedEvent, value); }
5210 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5213 public event EventHandler StyleChanged {
5214 add { Events.AddHandler (StyleChangedEvent, value); }
5215 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5218 public event EventHandler SystemColorsChanged {
5219 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5220 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5223 public event EventHandler TabIndexChanged {
5224 add { Events.AddHandler (TabIndexChangedEvent, value); }
5225 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5228 public event EventHandler TabStopChanged {
5229 add { Events.AddHandler (TabStopChangedEvent, value); }
5230 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5233 public event EventHandler TextChanged {
5234 add { Events.AddHandler (TextChangedEvent, value); }
5235 remove { Events.RemoveHandler (TextChangedEvent, value); }
5238 public event EventHandler Validated {
5239 add { Events.AddHandler (ValidatedEvent, value); }
5240 remove { Events.RemoveHandler (ValidatedEvent, value); }
5243 public event CancelEventHandler Validating {
5244 add { Events.AddHandler (ValidatingEvent, value); }
5245 remove { Events.RemoveHandler (ValidatingEvent, value); }
5248 public event EventHandler VisibleChanged {
5249 add { Events.AddHandler (VisibleChangedEvent, value); }
5250 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5253 #endregion // Events