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 internal 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 internal 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 internal bool tab_stop = true; // is the control a tab stop?
83 bool is_disposed; // has the window already been disposed?
84 internal Size client_size; // size of the client area (window excluding decorations)
85 internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
86 internal ControlStyles control_style; // rather win32-specific, style bits for control
87 internal ImeMode ime_mode = ImeMode.Inherit;
88 bool layout_pending; // true if our parent needs to re-layout us
89 internal object control_tag; // object that contains data about our control
90 internal int mouse_clicks; // Counter for mouse clicks
91 internal 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 internal 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 internal ControlCollection child_controls; // our children
116 internal Control parent; // our parent control
117 AccessibleObject accessibility_object; // object that contains accessibility information about our control
118 BindingContext binding_context;
119 internal RightToLeft right_to_left; // drawing direction for control
120 internal ContextMenu context_menu; // Context menu associated with the control
123 Graphics dc_mem; // Graphics context for double buffering
124 Bitmap bmp_mem; // Bitmap for double buffering control
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;
726 use_compatible_text_rendering = Application.use_compatible_text_rendering;
727 padding = new Padding(0);
728 maximum_size = new Size();
729 minimum_size = new Size();
730 preferred_size = new Size();
731 margin = this.DefaultMargin;
732 layout_engine = this.LayoutEngine;
735 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
736 ControlStyles.Selectable | ControlStyles.StandardClick |
737 ControlStyles.StandardDoubleClick;
739 control_style |= ControlStyles.UseTextForAccessibility;
743 background_image = null;
747 window = new ControlNativeWindow(this);
748 child_controls = CreateControlsInstance();
749 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
750 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
751 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
752 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
758 public Control(Control parent, string text) : this() {
763 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
768 bounds.Height=height;
769 SetBounds(left, top, width, height, BoundsSpecified.All);
773 public Control(string text) : this() {
777 public Control(string text, int left, int top, int width, int height) : this() {
781 bounds.Height=height;
782 SetBounds(left, top, width, height, BoundsSpecified.All);
786 private delegate void RemoveDelegate(object c);
788 protected override void Dispose(bool disposing) {
789 if (!is_disposed && disposing) {
802 if (invalid_region!=null) {
803 invalid_region.Dispose();
806 if (this.InvokeRequired) {
807 if (Application.MessageLoop) {
808 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
809 this.BeginInvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
813 lock (Control.controls) {
814 Control.controls.Remove(this);
819 if (parent != null) {
820 parent.Controls.Remove(this);
823 Control [] children = child_controls.GetAllControls ();
824 for (int i=0; i<children.Length; i++) {
825 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
826 children[i].Dispose();
831 base.Dispose(disposing);
833 #endregion // Public Constructors
835 #region Internal Properties
836 internal BorderStyle InternalBorderStyle {
842 if (!Enum.IsDefined (typeof (BorderStyle), value))
843 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
845 if (border_style != value) {
846 border_style = value;
848 if (IsHandleCreated) {
849 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
855 #endregion // Internal Properties
857 #region Private & Internal Methods
858 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
859 AsyncMethodResult result;
860 AsyncMethodData data;
867 if (!p.IsHandleCreated) {
868 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
874 result = new AsyncMethodResult ();
875 data = new AsyncMethodData ();
877 data.Handle = window.Handle;
878 data.Method = method;
880 data.Result = result;
883 if (!ExecutionContext.IsFlowSuppressed ()) {
884 data.Context = ExecutionContext.Capture ();
887 #if !MWF_ON_MSRUNTIME
888 if (SecurityManager.SecurityEnabled) {
889 data.Stack = CompressedStack.GetCompressedStack ();
894 XplatUI.SendAsyncMethod (data);
899 internal void PointToClient (ref int x, ref int y)
901 XplatUI.ScreenToClient (Handle, ref x, ref y);
904 internal void PointToScreen (ref int x, ref int y)
906 XplatUI.ClientToScreen (Handle, ref x, ref y);
909 internal bool IsRecreating {
911 return is_recreating;
915 internal Graphics DeviceContext {
917 if (dc_mem == null) {
918 CreateBuffers(this.Width, this.Height);
924 private void ImageBufferNeedsRedraw () {
925 if (invalid_region != null)
926 invalid_region.Dispose();
927 invalid_region = new Region (ClientRectangle);
930 private Bitmap ImageBuffer {
933 CreateBuffers(this.Width, this.Height);
939 internal void CreateBuffers (int width, int height) {
948 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
949 dc_mem = Graphics.FromImage (bmp_mem);
950 ImageBufferNeedsRedraw ();
953 internal void InvalidateBuffers ()
955 if (dc_mem != null) {
961 ImageBufferNeedsRedraw ();
964 internal static void SetChildColor(Control parent) {
967 for (int i=0; i < parent.child_controls.Count; i++) {
968 child=parent.child_controls[i];
969 if (child.child_controls.Count>0) {
970 SetChildColor(child);
976 internal bool Select(Control control) {
977 IContainerControl container;
979 if (control == null) {
983 container = GetContainerControl();
984 if (container != null) {
985 container.ActiveControl = control;
987 if (control.IsHandleCreated) {
988 XplatUI.SetFocus(control.window.Handle);
993 internal void SelectChild (Control control)
995 if (control.IsHandleCreated)
996 XplatUI.SetFocus (control.window.Handle);
999 internal virtual void DoDefaultAction() {
1000 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1003 internal static int LowOrder (int param) {
1004 return ((int)(short)(param & 0xffff));
1007 internal static int HighOrder (int param) {
1008 return ((int)(short)(param >> 16));
1011 // This method exists so controls overriding OnPaintBackground can have default background painting done
1012 internal virtual void PaintControlBackground (PaintEventArgs pevent)
1014 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1015 if (parent != null) {
1016 PaintEventArgs parent_pe;
1017 GraphicsState state;
1019 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1021 state = parent_pe.Graphics.Save();
1022 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1023 parent.OnPaintBackground(parent_pe);
1024 parent_pe.Graphics.Restore(state);
1026 state = parent_pe.Graphics.Save();
1027 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1028 parent.OnPaint(parent_pe);
1029 parent_pe.Graphics.Restore(state);
1030 parent_pe.SetGraphics(null);
1034 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1035 if (parent != null) {
1036 PaintEventArgs parent_pe;
1038 GraphicsState state;
1041 hwnd = Hwnd.ObjectFromHandle(Handle);
1044 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1046 region = new Region ();
1048 region.Union(ClientRectangle);
1050 foreach (Rectangle r in hwnd.ClipRectangles) {
1054 state = parent_pe.Graphics.Save();
1055 parent_pe.Graphics.Clip = region;
1057 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1058 parent.OnPaintBackground(parent_pe);
1059 parent_pe.Graphics.Restore(state);
1061 state = parent_pe.Graphics.Save();
1062 parent_pe.Graphics.Clip = region;
1064 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1065 parent.OnPaint(parent_pe);
1066 parent_pe.Graphics.Restore(state);
1067 parent_pe.SetGraphics(null);
1069 region.Intersect(clip_region);
1070 pevent.Graphics.Clip = region;
1075 if (background_image == null) {
1076 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));
1080 DrawBackgroundImage (pevent.Graphics);
1083 void DrawBackgroundImage (Graphics g)
1085 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1086 g.FillRectangle (b, ClientRectangle);
1090 internal virtual void DndEnter (DragEventArgs e)
1097 internal virtual void DndOver (DragEventArgs e)
1104 internal virtual void DndDrop (DragEventArgs e)
1108 } catch (Exception exc) {
1109 Console.Error.WriteLine ("MWF: Exception while dropping:");
1110 Console.Error.WriteLine (exc);
1114 internal virtual void DndLeave (EventArgs e)
1121 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1128 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1131 OnQueryContinueDrag(e);
1135 internal static MouseButtons FromParamToMouseButtons (int param) {
1136 MouseButtons buttons = MouseButtons.None;
1138 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1139 buttons |= MouseButtons.Left;
1141 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1142 buttons |= MouseButtons.Middle;
1144 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1145 buttons |= MouseButtons.Right;
1151 internal void FireEnter ()
1153 OnEnter (EventArgs.Empty);
1156 internal void FireLeave ()
1158 OnLeave (EventArgs.Empty);
1161 internal void FireValidating (CancelEventArgs ce)
1166 internal void FireValidated ()
1168 OnValidated (EventArgs.Empty);
1171 internal virtual bool ProcessControlMnemonic(char charCode) {
1172 return ProcessMnemonic(charCode);
1175 private static Control FindFlatForward(Control container, Control start) {
1181 end = container.child_controls.Count;
1183 if (start != null) {
1184 index = start.tab_index;
1190 for (int i = 0, pos = -1; i < end; i++) {
1191 if (start == container.child_controls[i]) {
1196 if (found == null) {
1197 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1198 found = container.child_controls[i];
1200 } else if (found.tab_index > container.child_controls[i].tab_index) {
1201 if (container.child_controls[i].tab_index > index) {
1202 found = container.child_controls[i];
1209 private static Control FindControlForward(Control container, Control start) {
1214 if (start == null) {
1215 return FindFlatForward(container, start);
1218 if (start.child_controls != null && start.child_controls.Count > 0 &&
1219 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1220 return FindControlForward(start, null);
1223 while (start != container) {
1224 found = FindFlatForward(start.parent, start);
1225 if (found != null) {
1228 start = start.parent;
1234 private static Control FindFlatBackward(Control container, Control start) {
1240 end = container.child_controls.Count;
1242 if (start != null) {
1243 index = start.tab_index;
1245 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1247 for (int i = 0; i < end; i++) {
1248 if (container.child_controls[i].tab_index > index) {
1249 index = container.child_controls[i].tab_index;
1257 for (int i = end - 1; i >= 0; i--) {
1258 if (start == container.child_controls[i]) {
1263 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1264 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1265 found = container.child_controls[i];
1272 private static Control FindControlBackward(Control container, Control start) {
1274 Control found = null;
1276 if (start == null) {
1277 found = FindFlatBackward(container, start);
1279 else if (start != container) {
1280 if (start.parent != null) {
1281 found = FindFlatBackward(start.parent, start);
1283 if (found == null) {
1284 if (start.parent != container)
1285 return start.parent;
1291 if (found == null || start.parent == null)
1294 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1295 found.child_controls != null && found.child_controls.Count > 0)) {
1296 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1297 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1298 found = FindFlatBackward(found, null);
1308 if (start != null) {
1309 found = FindFlatBackward(start.parent, start);
1310 if (found == null) {
1311 if (start.parent != container) {
1312 return start.parent;
1316 if (found == null) {
1317 found = FindFlatBackward(container, start);
1320 if (container != start) {
1321 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1322 found = FindControlBackward(found, null);
1323 if (found != null) {
1332 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1333 if (GetStyle(ControlStyles.StandardClick)) {
1334 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1336 OnDoubleClick(EventArgs.Empty);
1338 OnClick(EventArgs.Empty);
1348 private void CheckDataBindings ()
1350 if (data_bindings == null)
1353 BindingContext binding_context = BindingContext;
1354 foreach (Binding binding in data_bindings) {
1355 binding.Check (binding_context);
1360 private void ChangeParent(Control new_parent) {
1364 Color pre_fore_color;
1365 Color pre_back_color;
1366 RightToLeft pre_rtl;
1368 // These properties are inherited from our parent
1369 // Get them pre parent-change and then send events
1370 // if they are changed after we have our new parent
1371 pre_enabled = Enabled;
1372 pre_visible = Visible;
1374 pre_fore_color = ForeColor;
1375 pre_back_color = BackColor;
1376 pre_rtl = RightToLeft;
1377 // MS doesn't seem to send a CursorChangedEvent
1379 parent = new_parent;
1381 if (IsHandleCreated)
1382 XplatUI.SetParent(Handle,
1383 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1385 OnParentChanged(EventArgs.Empty);
1387 if (pre_enabled != Enabled) {
1388 OnEnabledChanged(EventArgs.Empty);
1391 if (pre_visible != Visible) {
1392 OnVisibleChanged(EventArgs.Empty);
1395 if (pre_font != Font) {
1396 OnFontChanged(EventArgs.Empty);
1399 if (pre_fore_color != ForeColor) {
1400 OnForeColorChanged(EventArgs.Empty);
1403 if (pre_back_color != BackColor) {
1404 OnBackColorChanged(EventArgs.Empty);
1407 if (pre_rtl != RightToLeft) {
1408 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1409 // because when RTL changes they have to recreate the win32 control
1410 // We don't really need that (until someone runs into compatibility issues)
1411 OnRightToLeftChanged(EventArgs.Empty);
1414 if ((new_parent != null) && new_parent.Created && !Created) {
1418 if ((binding_context == null) && Created) {
1419 OnBindingContextChanged(EventArgs.Empty);
1423 private void UpdateDistances() {
1424 if ((parent != null) && (parent.layout_suspended == 0)) {
1425 dist_left = bounds.X;
1426 dist_top = bounds.Y;
1427 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1428 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1431 #endregion // Private & Internal Methods
1433 #region Public Static Properties
1434 public static Color DefaultBackColor {
1436 return ThemeEngine.Current.DefaultControlBackColor;
1440 public static Font DefaultFont {
1442 return ThemeEngine.Current.DefaultFont;
1446 public static Color DefaultForeColor {
1448 return ThemeEngine.Current.DefaultControlForeColor;
1452 public static Keys ModifierKeys {
1454 return XplatUI.State.ModifierKeys;
1458 public static MouseButtons MouseButtons {
1460 return XplatUI.State.MouseButtons;
1464 public static Point MousePosition {
1466 return Cursor.Position;
1472 public static bool CheckForIllegalCrossThreadCalls
1475 return verify_thread_handle;
1479 verify_thread_handle = value;
1483 #endregion // Public Static Properties
1485 #region Public Instance Properties
1486 [EditorBrowsable(EditorBrowsableState.Advanced)]
1488 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1489 public AccessibleObject AccessibilityObject {
1491 if (accessibility_object==null) {
1492 accessibility_object=CreateAccessibilityInstance();
1494 return accessibility_object;
1498 [EditorBrowsable(EditorBrowsableState.Advanced)]
1500 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1501 public string AccessibleDefaultActionDescription {
1503 return AccessibilityObject.default_action;
1507 AccessibilityObject.default_action=value;
1512 [DefaultValue(null)]
1513 [MWFCategory("Accessibility")]
1514 public string AccessibleDescription {
1516 return AccessibilityObject.description;
1520 AccessibilityObject.description=value;
1525 [DefaultValue(null)]
1526 [MWFCategory("Accessibility")]
1527 public string AccessibleName {
1529 return AccessibilityObject.Name;
1533 AccessibilityObject.Name=value;
1537 [DefaultValue(AccessibleRole.Default)]
1538 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1539 public AccessibleRole AccessibleRole {
1541 return AccessibilityObject.role;
1545 AccessibilityObject.role=value;
1549 [DefaultValue(false)]
1550 [MWFCategory("Behavior")]
1551 public virtual bool AllowDrop {
1557 if (allow_drop == value)
1560 if (IsHandleCreated) {
1562 XplatUI.SetAllowDrop (Handle, value);
1568 [RefreshProperties(RefreshProperties.Repaint)]
1569 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1570 [MWFCategory("Layout")]
1571 public virtual AnchorStyles Anchor {
1573 return anchor_style;
1579 if (parent != null) {
1580 parent.PerformLayout(this, "Parent");
1586 // XXX: Implement me!
1589 public virtual bool AutoSize {
1591 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1595 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1600 public virtual Size MaximumSize {
1602 return maximum_size;
1605 maximum_size = value;
1609 public virtual Size MinimumSize {
1611 return minimum_size;
1614 minimum_size = value;
1620 [MWFCategory("Appearance")]
1621 public virtual Color BackColor {
1623 if (background_color.IsEmpty) {
1625 Color pcolor = parent.BackColor;
1626 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1629 return DefaultBackColor;
1631 return background_color;
1635 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1636 throw new ArgumentException("Transparent background colors are not supported on this control");
1639 if (background_color != value) {
1640 background_color=value;
1641 SetChildColor(this);
1642 OnBackColorChanged(EventArgs.Empty);
1649 [DefaultValue(null)]
1650 [MWFCategory("Appearance")]
1651 public virtual Image BackgroundImage {
1653 return background_image;
1657 if (background_image!=value) {
1658 background_image=value;
1659 OnBackgroundImageChanged(EventArgs.Empty);
1664 [EditorBrowsable(EditorBrowsableState.Advanced)]
1666 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1667 public virtual BindingContext BindingContext {
1669 if (binding_context != null)
1670 return binding_context;
1673 binding_context = Parent.BindingContext;
1674 return binding_context;
1677 if (binding_context != value) {
1678 binding_context = value;
1679 OnBindingContextChanged(EventArgs.Empty);
1684 [EditorBrowsable(EditorBrowsableState.Advanced)]
1686 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1689 return bounds.Y+bounds.Height;
1693 [EditorBrowsable(EditorBrowsableState.Advanced)]
1695 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1696 public Rectangle Bounds {
1702 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1706 [EditorBrowsable(EditorBrowsableState.Advanced)]
1708 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1709 public bool CanFocus {
1711 if (IsHandleCreated && Visible && Enabled) {
1718 [EditorBrowsable(EditorBrowsableState.Advanced)]
1720 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1721 public bool CanSelect {
1725 if (!GetStyle(ControlStyles.Selectable)) {
1730 while (parent != null) {
1731 if (!parent.is_visible || !parent.is_enabled) {
1735 parent = parent.parent;
1741 internal virtual bool InternalCapture {
1751 [EditorBrowsable(EditorBrowsableState.Advanced)]
1753 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1754 public bool Capture {
1756 return this.is_captured;
1760 if (this.IsHandleCreated && value != is_captured) {
1763 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1765 XplatUI.UngrabWindow(this.window.Handle);
1766 is_captured = false;
1772 [DefaultValue(true)]
1773 [MWFCategory("Focus")]
1774 public bool CausesValidation {
1776 return this.causes_validation;
1780 if (this.causes_validation != value) {
1781 causes_validation = value;
1782 OnCausesValidationChanged(EventArgs.Empty);
1787 [EditorBrowsable(EditorBrowsableState.Advanced)]
1789 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1790 public Rectangle ClientRectangle {
1792 client_rect.Width = client_size.Width;
1793 client_rect.Height = client_size.Height;
1798 [EditorBrowsable(EditorBrowsableState.Advanced)]
1800 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1801 public Size ClientSize {
1804 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1805 return ((Form)this).form_parent_window.ClientSize;
1813 this.SetClientSizeCore(value.Width, value.Height);
1817 [EditorBrowsable(EditorBrowsableState.Advanced)]
1819 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1820 [DescriptionAttribute("ControlCompanyNameDescr")]
1821 public String CompanyName {
1823 return "Mono Project, Novell, Inc.";
1827 [EditorBrowsable(EditorBrowsableState.Advanced)]
1829 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1830 public bool ContainsFocus {
1832 IntPtr focused_window;
1834 focused_window = XplatUI.GetFocus();
1835 if (IsHandleCreated) {
1836 if (focused_window == Handle) {
1840 for (int i=0; i < child_controls.Count; i++) {
1841 if (child_controls[i].ContainsFocus) {
1850 [DefaultValue(null)]
1851 [MWFCategory("Behavior")]
1852 public virtual ContextMenu ContextMenu {
1854 return context_menu;
1858 if (context_menu != value) {
1859 context_menu = value;
1860 OnContextMenuChanged(EventArgs.Empty);
1866 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1867 public ControlCollection Controls {
1869 return this.child_controls;
1873 [EditorBrowsable(EditorBrowsableState.Advanced)]
1875 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1876 public bool Created {
1878 return (!is_disposed && is_created);
1882 [AmbientValue(null)]
1883 [MWFCategory("Appearance")]
1884 public virtual Cursor Cursor {
1886 if (cursor != null) {
1890 if (parent != null) {
1891 return parent.Cursor;
1894 return Cursors.Default;
1898 if (cursor != value) {
1903 if (IsHandleCreated) {
1904 pt = Cursor.Position;
1906 if (bounds.Contains(pt) || Capture) {
1907 if (GetChildAtPoint(pt) == null) {
1908 if (cursor != null) {
1909 XplatUI.SetCursor(window.Handle, cursor.handle);
1911 if (parent != null) {
1912 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1914 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1921 OnCursorChanged(EventArgs.Empty);
1927 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1928 [ParenthesizePropertyName(true)]
1929 [RefreshProperties(RefreshProperties.All)]
1930 [MWFCategory("Data")]
1931 public ControlBindingsCollection DataBindings {
1933 if (data_bindings == null)
1934 data_bindings = new ControlBindingsCollection (this);
1935 return data_bindings;
1939 [EditorBrowsable(EditorBrowsableState.Advanced)]
1941 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1942 public virtual Rectangle DisplayRectangle {
1944 return ClientRectangle;
1948 [EditorBrowsable(EditorBrowsableState.Advanced)]
1950 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1951 public bool Disposing {
1958 [RefreshProperties(RefreshProperties.Repaint)]
1959 [DefaultValue(DockStyle.None)]
1960 [MWFCategory("Layout")]
1961 public virtual DockStyle Dock {
1967 if (dock_style == value) {
1973 if (dock_style == DockStyle.None) {
1974 if (explicit_bounds == Rectangle.Empty)
1975 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1977 Bounds = explicit_bounds;
1980 if (parent != null) {
1981 parent.PerformLayout(this, "Parent");
1984 OnDockChanged(EventArgs.Empty);
1990 [MWFCategory("Behavior")]
1991 public bool Enabled {
1997 if (parent != null) {
1998 return parent.Enabled;
2006 bool old_value = is_enabled;
2009 if (old_value != value && !value && this.has_focus)
2010 SelectNextControl(this, true, true, true, true);
2012 OnEnabledChanged (EventArgs.Empty);
2016 [EditorBrowsable(EditorBrowsableState.Advanced)]
2018 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2019 public virtual bool Focused {
2021 return this.has_focus;
2026 [AmbientValue(null)]
2028 [MWFCategory("Appearance")]
2029 public virtual Font Font {
2035 if (Parent != null && Parent.Font != null) {
2042 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2044 if (font != null && font.Equals (value)) {
2050 OnFontChanged (EventArgs.Empty);
2055 [MWFCategory("Appearance")]
2056 public virtual Color ForeColor {
2058 if (foreground_color.IsEmpty) {
2060 return parent.ForeColor;
2062 return DefaultForeColor;
2064 return foreground_color;
2068 if (foreground_color != value) {
2069 foreground_color=value;
2071 OnForeColorChanged(EventArgs.Empty);
2078 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2079 public IntPtr Handle { // IWin32Window
2082 if (verify_thread_handle) {
2083 if (this.InvokeRequired) {
2084 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2088 if (!IsHandleCreated) {
2091 return window.Handle;
2095 [EditorBrowsable(EditorBrowsableState.Advanced)]
2097 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2098 public bool HasChildren {
2100 if (this.child_controls.Count>0) {
2107 [EditorBrowsable(EditorBrowsableState.Always)]
2109 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2112 return this.bounds.Height;
2116 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2120 [AmbientValue(ImeMode.Inherit)]
2122 [MWFCategory("Behavior")]
2123 public ImeMode ImeMode {
2125 if (ime_mode == DefaultImeMode) {
2127 return parent.ImeMode;
2129 return ImeMode.NoControl; // default value
2135 if (ime_mode != value) {
2138 OnImeModeChanged(EventArgs.Empty);
2143 [EditorBrowsable(EditorBrowsableState.Advanced)]
2145 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2146 public bool InvokeRequired { // ISynchronizeInvoke
2148 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2155 [EditorBrowsable(EditorBrowsableState.Advanced)]
2157 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2158 public bool IsAccessible {
2160 return is_accessible;
2164 is_accessible = value;
2168 [EditorBrowsable(EditorBrowsableState.Advanced)]
2170 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2171 public bool IsDisposed {
2173 return this.is_disposed;
2177 [EditorBrowsable(EditorBrowsableState.Advanced)]
2179 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2180 public bool IsHandleCreated {
2182 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2183 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2184 if (hwnd != null && !hwnd.zombie)
2193 public virtual Layout.LayoutEngine LayoutEngine {
2194 get { return new Layout.DefaultLayout (); }
2198 [EditorBrowsable(EditorBrowsableState.Always)]
2200 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2203 return this.bounds.X;
2207 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2212 [MWFCategory("Layout")]
2213 public Point Location {
2215 return new Point(bounds.X, bounds.Y);
2219 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2224 [Localizable (true)]
2225 public Padding Margin {
2226 get { return this.margin; }
2227 set { this.margin = value; }
2232 public string Name {
2244 public Padding Padding {
2256 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2257 public Control Parent {
2263 if (value == this) {
2264 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2267 if (parent!=value) {
2269 parent.Controls.Remove(this);
2274 value.Controls.Add(this);
2279 [EditorBrowsable(EditorBrowsableState.Advanced)]
2281 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2282 public string ProductName {
2284 Type t = typeof (AssemblyProductAttribute);
2285 Assembly assembly = GetType().Module.Assembly;
2286 object [] attrs = assembly.GetCustomAttributes (t, false);
2287 AssemblyProductAttribute a = null;
2288 // On MS we get a NullRefException if product attribute is not
2290 if (attrs != null && attrs.Length > 0)
2291 a = (AssemblyProductAttribute) attrs [0];
2296 [EditorBrowsable(EditorBrowsableState.Advanced)]
2298 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2299 public string ProductVersion {
2301 Type t = typeof (AssemblyVersionAttribute);
2302 Assembly assembly = GetType().Module.Assembly;
2303 object [] attrs = assembly.GetCustomAttributes (t, false);
2304 if (attrs == null || attrs.Length < 1)
2306 return ((AssemblyVersionAttribute)attrs [0]).Version;
2310 [EditorBrowsable(EditorBrowsableState.Advanced)]
2312 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2313 public bool RecreatingHandle {
2315 return is_recreating;
2319 [EditorBrowsable(EditorBrowsableState.Advanced)]
2321 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2322 public Region Region {
2328 if (IsHandleCreated) {
2329 XplatUI.SetClipRegion(Handle, value);
2331 clip_region = value;
2335 [EditorBrowsable(EditorBrowsableState.Advanced)]
2337 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2340 return this.bounds.X+this.bounds.Width;
2344 [AmbientValue(RightToLeft.Inherit)]
2346 [MWFCategory("Appearance")]
2347 public virtual RightToLeft RightToLeft {
2349 if (right_to_left == RightToLeft.Inherit) {
2351 return parent.RightToLeft;
2353 return RightToLeft.No; // default value
2355 return right_to_left;
2359 if (value != right_to_left) {
2360 right_to_left = value;
2361 OnRightToLeftChanged(EventArgs.Empty);
2366 [EditorBrowsable(EditorBrowsableState.Advanced)]
2367 public override ISite Site {
2375 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2377 BackColor = ap.BackColor;
2378 ForeColor = ap.ForeColor;
2386 [MWFCategory("Layout")]
2389 return new Size(Width, Height);
2393 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2398 [MergableProperty(false)]
2399 [MWFCategory("Behavior")]
2400 public int TabIndex {
2402 if (tab_index != -1) {
2409 if (tab_index != value) {
2411 OnTabIndexChanged(EventArgs.Empty);
2417 [DefaultValue(true)]
2418 [MWFCategory("Behavior")]
2419 public bool TabStop {
2425 if (tab_stop != value) {
2427 OnTabStopChanged(EventArgs.Empty);
2432 [Localizable(false)]
2434 [TypeConverter(typeof(StringConverter))]
2435 [DefaultValue(null)]
2436 [MWFCategory("Data")]
2443 control_tag = value;
2449 [BindableAttribute(true)]
2450 [MWFCategory("Appearance")]
2451 public virtual string Text {
2453 // Our implementation ignores ControlStyles.CacheText - we always cache
2458 if (value == null) {
2459 value = String.Empty;
2464 if (IsHandleCreated) {
2465 /* we need to call .SetWindowStyle here instead of just .Text
2466 because the presence/absence of Text (== "" or not) can cause
2467 other window style things to appear/disappear */
2468 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2469 XplatUI.Text(Handle, text);
2471 OnTextChanged (EventArgs.Empty);
2476 [EditorBrowsable(EditorBrowsableState.Always)]
2478 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2481 return this.bounds.Y;
2485 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2489 [EditorBrowsable(EditorBrowsableState.Advanced)]
2491 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2492 public Control TopLevelControl {
2496 while (p.parent != null) {
2500 return p is Form ? p : null;
2505 [MWFCategory("Behavior")]
2506 public bool Visible {
2510 } else if (parent != null) {
2511 return parent.Visible;
2518 SetVisibleCore(value);
2522 [EditorBrowsable(EditorBrowsableState.Always)]
2524 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2527 return this.bounds.Width;
2531 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2535 [EditorBrowsable(EditorBrowsableState.Never)]
2537 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2538 public IWindowTarget WindowTarget {
2547 #endregion // Public Instance Properties
2549 #region Protected Instance Properties
2550 protected virtual CreateParams CreateParams {
2552 CreateParams create_params = new CreateParams();
2555 create_params.Caption = Text;
2558 create_params.Caption = text;
2562 create_params.X = Left;
2565 create_params.X = this.bounds.X;
2569 create_params.Y = Top;
2572 create_params.Y = this.bounds.Y;
2576 create_params.Width = Width;
2579 create_params.Width = this.bounds.Width;
2583 create_params.Height = Height;
2586 create_params.Height = this.bounds.Height;
2590 create_params.ClassName = XplatUI.DefaultClassName;
2591 create_params.ClassStyle = 0;
2592 create_params.ExStyle = 0;
2593 create_params.Param = 0;
2596 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2599 if ((parent!=null) && (parent.IsHandleCreated)) {
2600 create_params.Parent = parent.Handle;
2603 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2606 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2610 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2613 switch (border_style) {
2614 case BorderStyle.FixedSingle:
2615 create_params.Style |= (int) WindowStyles.WS_BORDER;
2617 case BorderStyle.Fixed3D:
2618 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2622 return create_params;
2626 protected virtual ImeMode DefaultImeMode {
2628 return ImeMode.Inherit;
2633 protected virtual Padding DefaultMargin {
2634 get { return new Padding (3); }
2638 protected virtual Size DefaultSize {
2640 return new Size(0, 0);
2644 protected int FontHeight {
2654 protected bool RenderRightToLeft {
2656 return (this.right_to_left == RightToLeft.Yes);
2660 protected bool ResizeRedraw {
2662 return GetStyle(ControlStyles.ResizeRedraw);
2666 SetStyle(ControlStyles.ResizeRedraw, value);
2670 [EditorBrowsable(EditorBrowsableState.Advanced)]
2672 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2673 protected virtual bool ShowFocusCues {
2679 [EditorBrowsable(EditorBrowsableState.Advanced)]
2681 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2682 protected bool ShowKeyboardCues {
2687 #endregion // Protected Instance Properties
2689 #region Public Static Methods
2690 [EditorBrowsable(EditorBrowsableState.Advanced)]
2691 public static Control FromChildHandle(IntPtr handle) {
2692 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2695 [EditorBrowsable(EditorBrowsableState.Advanced)]
2696 public static Control FromHandle(IntPtr handle) {
2697 return Control.ControlNativeWindow.ControlFromHandle(handle);
2700 public static bool IsMnemonic(char charCode, string text) {
2703 amp = text.IndexOf('&');
2706 if (amp + 1 < text.Length) {
2707 if (text[amp + 1] != '&') {
2708 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2718 #region Protected Static Methods
2719 [EditorBrowsable(EditorBrowsableState.Advanced)]
2720 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2723 c = Control.FromHandle(hWnd);
2733 #region Public Instance Methods
2734 [EditorBrowsable(EditorBrowsableState.Advanced)]
2735 public IAsyncResult BeginInvoke(Delegate method) {
2736 object [] prms = null;
2737 if (method is EventHandler)
2738 prms = new object [] { this, EventArgs.Empty };
2739 return BeginInvokeInternal(method, prms, false);
2742 [EditorBrowsable(EditorBrowsableState.Advanced)]
2743 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2744 return BeginInvokeInternal (method, args, false);
2747 public void BringToFront() {
2748 if (parent != null) {
2749 parent.child_controls.SetChildIndex(this, 0);
2752 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2756 public bool Contains(Control ctl) {
2757 while (ctl != null) {
2766 public void CreateControl() {
2768 throw new ObjectDisposedException(GetType().FullName.ToString());
2774 if (!IsHandleCreated) {
2782 Control [] controls = child_controls.GetAllControls ();
2783 for (int i=0; i<controls.Length; i++) {
2784 controls [i].CreateControl ();
2787 UpdateChildrenZOrder();
2789 if (binding_context == null) { // seem to be sent whenever it's null?
2790 OnBindingContextChanged(EventArgs.Empty);
2796 public Graphics CreateGraphics() {
2797 if (!IsHandleCreated) {
2798 this.CreateHandle();
2800 return Graphics.FromHwnd(this.window.Handle);
2803 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2804 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2807 [EditorBrowsable(EditorBrowsableState.Advanced)]
2808 public object EndInvoke (IAsyncResult async_result) {
2809 AsyncMethodResult result = (AsyncMethodResult) async_result;
2810 return result.EndInvoke ();
2813 public Form FindForm() {
2826 public bool Focus() {
2827 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2830 is_focusing = false;
2835 public Control GetChildAtPoint(Point pt) {
2836 // Microsoft's version of this function doesn't seem to work, so I can't check
2837 // if we only consider children or also grandchildren, etc.
2838 // I'm gonna say 'children only'
2839 for (int i=0; i<child_controls.Count; i++) {
2840 if (child_controls[i].Bounds.Contains(pt)) {
2841 return child_controls[i];
2847 public IContainerControl GetContainerControl() {
2848 Control current = this;
2850 while (current!=null) {
2851 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2852 return (IContainerControl)current;
2854 current = current.parent;
2859 public Control GetNextControl(Control ctl, bool forward) {
2861 if (!this.Contains(ctl)) {
2866 ctl = FindControlForward(this, ctl);
2869 ctl = FindControlBackward(this, ctl);
2879 public virtual Size GetPreferredSize (Size proposedSize) {
2880 return preferred_size;
2884 public void Hide() {
2885 this.Visible = false;
2888 public void Invalidate() {
2889 Invalidate(ClientRectangle, false);
2892 public void Invalidate(bool invalidateChildren) {
2893 Invalidate(ClientRectangle, invalidateChildren);
2896 public void Invalidate(System.Drawing.Rectangle rc) {
2897 Invalidate(rc, false);
2900 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2901 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2905 NotifyInvalidate(rc);
2907 XplatUI.Invalidate(Handle, rc, false);
2909 if (invalidateChildren) {
2910 Control [] controls = child_controls.GetAllControls ();
2911 for (int i=0; i<controls.Length; i++)
2912 controls [i].Invalidate ();
2914 OnInvalidated(new InvalidateEventArgs(rc));
2917 public void Invalidate(System.Drawing.Region region) {
2918 Invalidate(region, false);
2921 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2922 RectangleF bounds = region.GetBounds (CreateGraphics ());
2923 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2924 invalidateChildren);
2927 public object Invoke (Delegate method) {
2928 object [] prms = null;
2929 if (method is EventHandler)
2930 prms = new object [] { this, EventArgs.Empty };
2932 return Invoke(method, prms);
2935 public object Invoke (Delegate method, object[] args) {
2936 if (!this.InvokeRequired) {
2937 return method.DynamicInvoke(args);
2940 IAsyncResult result = BeginInvoke (method, args);
2941 return EndInvoke(result);
2944 internal object InvokeInternal (Delegate method, bool disposing) {
2945 return InvokeInternal(method, null, disposing);
2948 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2949 if (!this.InvokeRequired) {
2950 return method.DynamicInvoke(args);
2953 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2954 return EndInvoke(result);
2957 [EditorBrowsable(EditorBrowsableState.Advanced)]
2958 public void PerformLayout() {
2959 PerformLayout(null, null);
2963 private void SetImplicitBounds (int x, int y, int width, int height)
2965 Rectangle saved_bounds = explicit_bounds;
2966 SetBounds (x, y, width, height);
2967 explicit_bounds = saved_bounds;
2971 [EditorBrowsable(EditorBrowsableState.Advanced)]
2972 public void PerformLayout(Control affectedControl, string affectedProperty) {
2973 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2975 if (layout_suspended > 0) {
2976 layout_pending = true;
2980 layout_pending = false;
2982 // Prevent us from getting messed up
2985 // Perform all Dock and Anchor calculations
2989 this.layout_engine.Layout(this, levent);
2991 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2993 AnchorStyles anchor;
2996 space = DisplayRectangle;
2998 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2999 Control [] controls = child_controls.GetAllControls ();
3000 for (int i = controls.Length - 1; i >= 0; i--) {
3001 child = controls [i];
3003 if (!child.Visible) {
3007 switch (child.Dock) {
3008 case DockStyle.None: {
3013 case DockStyle.Left: {
3014 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3015 space.X+=child.Width;
3016 space.Width-=child.Width;
3020 case DockStyle.Top: {
3021 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3022 space.Y+=child.Height;
3023 space.Height-=child.Height;
3027 case DockStyle.Right: {
3028 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3029 space.Width-=child.Width;
3033 case DockStyle.Bottom: {
3034 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3035 space.Height-=child.Height;
3041 for (int i = controls.Length - 1; i >= 0; i--) {
3044 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3045 if (child.Dock == DockStyle.Fill) {
3046 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3050 space = DisplayRectangle;
3052 for (int i=0; i < controls.Length; i++) {
3058 child = controls[i];
3060 // If the control is docked we don't need to do anything
3061 if (child.Dock != DockStyle.None) {
3065 anchor = child.Anchor;
3069 width = child.Width;
3070 height = child.Height;
3072 if ((anchor & AnchorStyles.Left) !=0 ) {
3073 if ((anchor & AnchorStyles.Right) != 0) {
3074 width = space.Width - child.dist_right - left;
3076 ; // Left anchored only, nothing to be done
3078 } else if ((anchor & AnchorStyles.Right) != 0) {
3079 left = space.Width - child.dist_right - width;
3081 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3082 // This calculates from scratch every time:
3083 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3086 if ((anchor & AnchorStyles.Top) !=0 ) {
3087 if ((anchor & AnchorStyles.Bottom) != 0) {
3088 height = space.Height - child.dist_bottom - top;
3090 ; // Top anchored only, nothing to be done
3092 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3093 top = space.Height - child.dist_bottom - height;
3095 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3096 // This calculates from scratch every time:
3097 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3109 child.SetImplicitBounds(left, top, width, height);
3113 // Let everyone know
3117 // Need to make sure we decremend layout_suspended
3123 public Point PointToClient (Point p) {
3127 XplatUI.ScreenToClient (Handle, ref x, ref y);
3129 return new Point (x, y);
3132 public Point PointToScreen(Point p) {
3136 XplatUI.ClientToScreen(Handle, ref x, ref y);
3138 return new Point(x, y);
3141 public virtual bool PreProcessMessage(ref Message msg) {
3142 return InternalPreProcessMessage (ref msg);
3145 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3148 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3149 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3151 if (!ProcessCmdKey(ref msg, key_data)) {
3152 if (IsInputKey(key_data)) {
3156 return ProcessDialogKey(key_data);
3160 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3161 if (IsInputChar((char)msg.WParam)) {
3164 return ProcessDialogChar((char)msg.WParam);
3165 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3166 return ProcessDialogChar((char)msg.WParam);
3171 public Rectangle RectangleToClient(Rectangle r) {
3172 return new Rectangle(PointToClient(r.Location), r.Size);
3175 public Rectangle RectangleToScreen(Rectangle r) {
3176 return new Rectangle(PointToScreen(r.Location), r.Size);
3179 public virtual void Refresh() {
3180 if (IsHandleCreated == true) {
3182 XplatUI.UpdateWindow(window.Handle);
3184 Control [] controls = child_controls.GetAllControls ();
3185 for (int i=0; i < controls.Length; i++) {
3186 controls[i].Refresh();
3192 [EditorBrowsable(EditorBrowsableState.Never)]
3193 public virtual void ResetBackColor() {
3194 BackColor = Color.Empty;
3197 [EditorBrowsable(EditorBrowsableState.Never)]
3198 public void ResetBindings() {
3199 data_bindings.Clear();
3202 [EditorBrowsable(EditorBrowsableState.Never)]
3203 public virtual void ResetCursor() {
3207 [EditorBrowsable(EditorBrowsableState.Never)]
3208 public virtual void ResetFont() {
3212 [EditorBrowsable(EditorBrowsableState.Never)]
3213 public virtual void ResetForeColor() {
3214 foreground_color = Color.Empty;
3217 [EditorBrowsable(EditorBrowsableState.Never)]
3218 public void ResetImeMode() {
3219 ime_mode = DefaultImeMode;
3222 [EditorBrowsable(EditorBrowsableState.Never)]
3223 public virtual void ResetRightToLeft() {
3224 right_to_left = RightToLeft.Inherit;
3227 public virtual void ResetText() {
3228 text = String.Empty;
3231 public void ResumeLayout() {
3232 ResumeLayout (true);
3235 public void ResumeLayout(bool performLayout) {
3236 if (layout_suspended > 0) {
3240 if (layout_suspended == 0) {
3241 Control [] controls = child_controls.GetAllControls ();
3242 for (int i=0; i<controls.Length; i++) {
3243 controls [i].UpdateDistances ();
3246 if (performLayout && layout_pending) {
3252 public void Scale(float ratio) {
3253 ScaleCore(ratio, ratio);
3256 public void Scale(float dx, float dy) {
3261 public void Scale(SizeF factor) {
3262 ScaleCore(factor.Width, factor.Height);
3266 public void Select() {
3267 Select(false, false);
3271 private void printTree(Control c, string t) {
3272 foreach(Control i in c.child_controls) {
3273 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3274 printTree(i, t+"\t");
3278 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3282 Console.WriteLine("{0}", this.FindForm());
3283 printTree(this, "\t");
3286 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3291 c = GetNextControl(c, forward);
3300 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3301 c.Select (true, true);
3304 } while (c != ctl); // If we wrap back to ourselves we stop
3309 public void SendToBack() {
3310 if (parent != null) {
3311 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3315 public void SetBounds(int x, int y, int width, int height) {
3316 SetBounds(x, y, width, height, BoundsSpecified.All);
3319 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3320 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3324 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3328 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3332 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3336 SetBoundsCore(x, y, width, height, specified);
3337 if (parent != null) {
3338 parent.PerformLayout(this, "Bounds");
3342 public void Show() {
3344 this.CreateControl();
3350 public void SuspendLayout() {
3354 public void Update() {
3355 if (IsHandleCreated) {
3356 XplatUI.UpdateWindow(window.Handle);
3359 #endregion // Public Instance Methods
3361 #region Protected Instance Methods
3362 [EditorBrowsable(EditorBrowsableState.Advanced)]
3363 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3364 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3365 throw new NotImplementedException();
3368 [EditorBrowsable(EditorBrowsableState.Advanced)]
3369 protected virtual AccessibleObject CreateAccessibilityInstance() {
3370 return new Control.ControlAccessibleObject(this);
3373 [EditorBrowsable(EditorBrowsableState.Advanced)]
3374 protected virtual ControlCollection CreateControlsInstance() {
3375 return new ControlCollection(this);
3378 [EditorBrowsable(EditorBrowsableState.Advanced)]
3379 protected virtual void CreateHandle() {
3381 throw new ObjectDisposedException(GetType().FullName.ToString());
3384 if (IsHandleCreated && !is_recreating) {
3388 window.CreateHandle(CreateParams);
3390 if (window.Handle != IntPtr.Zero) {
3391 lock (Control.controls) {
3392 if (!Control.controls.Contains(window.Handle)) {
3393 Control.controls.Add(this);
3397 creator_thread = Thread.CurrentThread;
3399 XplatUI.EnableWindow(window.Handle, is_enabled);
3400 XplatUI.SetVisible(window.Handle, is_visible, true);
3402 if (clip_region != null) {
3403 XplatUI.SetClipRegion(Handle, clip_region);
3406 // Set our handle with our parent
3407 if ((parent != null) && (parent.IsHandleCreated)) {
3408 XplatUI.SetParent(window.Handle, parent.Handle);
3411 // Set our handle as parent for our children
3412 Control [] children;
3414 children = child_controls.GetAllControls ();
3415 for (int i = 0; i < children.Length; i++ ) {
3416 if (!children[i].RecreatingHandle)
3417 XplatUI.SetParent(children[i].Handle, window.Handle);
3421 XplatUI.SetAllowDrop (Handle, allow_drop);
3423 // Find out where the window manager placed us
3424 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3425 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3429 OnHandleCreated(EventArgs.Empty);
3433 [EditorBrowsable(EditorBrowsableState.Advanced)]
3434 protected virtual void DefWndProc(ref Message m) {
3435 window.DefWndProc(ref m);
3438 [EditorBrowsable(EditorBrowsableState.Advanced)]
3439 protected virtual void DestroyHandle() {
3440 if (IsHandleCreated) {
3441 if (window != null) {
3442 window.DestroyHandle();
3447 protected bool GetStyle(ControlStyles flag) {
3448 return (control_style & flag) != 0;
3451 protected bool GetTopLevel() {
3455 [EditorBrowsable(EditorBrowsableState.Advanced)]
3456 protected virtual void InitLayout() {
3460 [EditorBrowsable(EditorBrowsableState.Advanced)]
3461 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3462 toInvoke.OnGotFocus(e);
3465 [EditorBrowsable(EditorBrowsableState.Advanced)]
3466 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3467 toInvoke.OnLostFocus(e);
3470 [EditorBrowsable(EditorBrowsableState.Advanced)]
3471 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3472 toInvoke.OnClick(e);
3475 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3476 toInvoke.OnPaint(e);
3479 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3480 toInvoke.OnPaintBackground(e);
3483 protected virtual bool IsInputChar (char charCode) {
3487 protected virtual bool IsInputKey (Keys keyData) {
3488 // Doc says this one calls IsInputChar; not sure what to do with that
3492 [EditorBrowsable(EditorBrowsableState.Advanced)]
3493 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3497 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3498 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3502 if (parent != null) {
3503 return parent.ProcessCmdKey(ref msg, keyData);
3509 protected virtual bool ProcessDialogChar(char charCode) {
3510 if (parent != null) {
3511 return parent.ProcessDialogChar (charCode);
3517 protected virtual bool ProcessDialogKey (Keys keyData) {
3518 if (parent != null) {
3519 return parent.ProcessDialogKey (keyData);
3525 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3527 KeyEventArgs key_event;
3530 case (int)Msg.WM_SYSKEYDOWN:
3531 case (int)Msg.WM_KEYDOWN: {
3532 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3533 OnKeyDown (key_event);
3534 return key_event.Handled;
3537 case (int)Msg.WM_SYSKEYUP:
3538 case (int)Msg.WM_KEYUP: {
3539 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3540 OnKeyUp (key_event);
3541 return key_event.Handled;
3544 case (int)Msg.WM_SYSCHAR:
3545 case (int)Msg.WM_CHAR: {
3546 KeyPressEventArgs key_press_event;
3548 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3549 OnKeyPress(key_press_event);
3551 msg.WParam = (IntPtr)key_press_event.KeyChar;
3553 return key_press_event.Handled;
3564 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3565 if (parent != null) {
3566 if (parent.ProcessKeyPreview(ref msg)) {
3571 return ProcessKeyEventArgs(ref msg);
3574 protected virtual bool ProcessKeyPreview(ref Message msg) {
3575 if (parent != null) {
3576 return parent.ProcessKeyPreview(ref msg);
3582 protected virtual bool ProcessMnemonic(char charCode) {
3587 [EditorBrowsable(EditorBrowsableState.Advanced)]
3588 protected void RaiseDragEvent(object key, DragEventArgs e) {
3592 [EditorBrowsable(EditorBrowsableState.Advanced)]
3593 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3597 [EditorBrowsable(EditorBrowsableState.Advanced)]
3598 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3602 [EditorBrowsable(EditorBrowsableState.Advanced)]
3603 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3607 private void SetIsRecreating ()
3611 foreach (Control c in Controls.GetAllControls()) {
3612 c.SetIsRecreating ();
3616 [EditorBrowsable(EditorBrowsableState.Advanced)]
3617 protected void RecreateHandle() {
3619 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3624 if (IsHandleCreated) {
3626 Console.WriteLine(" + handle is created, destroying it.");
3629 // WM_DESTROY will CreateHandle for us
3632 Console.WriteLine(" + handle is not created, creating it.");
3640 is_recreating = false;
3642 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3648 [EditorBrowsable(EditorBrowsableState.Advanced)]
3649 protected void ResetMouseEventArgs() {
3653 [EditorBrowsable(EditorBrowsableState.Advanced)]
3654 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3655 if (right_to_left == RightToLeft.No) {
3660 case ContentAlignment.TopLeft: {
3661 return ContentAlignment.TopRight;
3664 case ContentAlignment.TopRight: {
3665 return ContentAlignment.TopLeft;
3668 case ContentAlignment.MiddleLeft: {
3669 return ContentAlignment.MiddleRight;
3672 case ContentAlignment.MiddleRight: {
3673 return ContentAlignment.MiddleLeft;
3676 case ContentAlignment.BottomLeft: {
3677 return ContentAlignment.BottomRight;
3680 case ContentAlignment.BottomRight: {
3681 return ContentAlignment.BottomLeft;
3685 // if it's center it doesn't change
3691 [EditorBrowsable(EditorBrowsableState.Advanced)]
3692 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3693 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3697 if (align == HorizontalAlignment.Left) {
3698 return HorizontalAlignment.Right;
3701 // align must be HorizontalAlignment.Right
3702 return HorizontalAlignment.Left;
3705 [EditorBrowsable(EditorBrowsableState.Advanced)]
3706 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3707 if (right_to_left == RightToLeft.No) {
3711 if (align == LeftRightAlignment.Left) {
3712 return LeftRightAlignment.Right;
3715 // align must be LeftRightAlignment.Right;
3716 return LeftRightAlignment.Left;
3719 [EditorBrowsable(EditorBrowsableState.Advanced)]
3720 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3721 return RtlTranslateAlignment(align);
3724 [EditorBrowsable(EditorBrowsableState.Advanced)]
3725 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3726 return RtlTranslateAlignment(align);
3729 [EditorBrowsable(EditorBrowsableState.Advanced)]
3730 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3731 return RtlTranslateAlignment(align);
3734 [EditorBrowsable(EditorBrowsableState.Advanced)]
3735 protected virtual void ScaleCore(float dx, float dy) {
3741 location = new Point((int)(Left * dx), (int)(Top * dy));
3742 size = this.ClientSize;
3744 if (!GetStyle(ControlStyles.FixedWidth)) {
3745 size.Width = (int)(size.Width * dx);
3748 if (!GetStyle(ControlStyles.FixedHeight)) {
3749 size.Height = (int)(size.Height * dy);
3752 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3754 /* Now scale our children */
3755 Control [] controls = child_controls.GetAllControls ();
3756 for (int i=0; i < controls.Length; i++) {
3757 controls[i].Scale(dx, dy);
3763 protected virtual void Select(bool directed, bool forward) {
3764 IContainerControl container;
3766 container = GetContainerControl();
3767 if (container != null)
3768 container.ActiveControl = this;
3771 [EditorBrowsable(EditorBrowsableState.Advanced)]
3772 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3773 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3774 if (IsHandleCreated) {
3775 XplatUI.SetWindowPos(Handle, x, y, width, height);
3777 // Win32 automatically changes negative width/height to 0.
3778 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3779 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3781 if (width < 0 || height < 0) {
3783 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3787 UpdateBounds(x, y, width, height);
3792 [EditorBrowsable(EditorBrowsableState.Advanced)]
3793 protected virtual void SetClientSizeCore(int x, int y) {
3794 // Calculate the actual window size from the client size (it usually stays the same or grows)
3795 Rectangle ClientRect;
3796 Rectangle WindowRect;
3799 ClientRect = new Rectangle(0, 0, x, y);
3800 cp = this.CreateParams;
3802 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3806 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3809 [EditorBrowsable(EditorBrowsableState.Advanced)]
3810 protected void SetStyle(ControlStyles flag, bool value) {
3812 control_style |= flag;
3814 control_style &= ~flag;
3818 protected void SetTopLevel(bool value) {
3819 if ((GetTopLevel() != value) && (parent != null)) {
3820 throw new Exception();
3824 if (value == true) {
3834 is_toplevel = value;
3837 protected virtual void SetVisibleCore(bool value) {
3838 if (value!=is_visible) {
3839 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3845 if (IsHandleCreated) {
3846 XplatUI.SetVisible(Handle, value, true);
3847 // Explicitly move Toplevel windows to where we want them;
3848 // apparently moving unmapped toplevel windows doesn't work
3849 if (is_visible && (this is Form)) {
3850 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3854 OnVisibleChanged(EventArgs.Empty);
3856 if (value == false && parent != null && Focused) {
3859 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3860 container = (Control)parent.GetContainerControl();
3861 if (container != null) {
3862 container.SelectNextControl(this, true, true, true, true);
3866 if (parent != null) {
3867 parent.PerformLayout(this, "visible");
3869 PerformLayout(this, "visible");
3874 [EditorBrowsable(EditorBrowsableState.Advanced)]
3875 protected void UpdateBounds() {
3883 if (!IsHandleCreated) {
3887 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3889 UpdateBounds(x, y, width, height, client_width, client_height);
3892 [EditorBrowsable(EditorBrowsableState.Advanced)]
3893 protected void UpdateBounds(int x, int y, int width, int height) {
3897 // Calculate client rectangle
3898 rect = new Rectangle(0, 0, 0, 0);
3901 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3902 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3905 [EditorBrowsable(EditorBrowsableState.Advanced)]
3906 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3907 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3909 bool resized = false;
3911 // Needed to generate required notifications
3912 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3916 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3923 bounds.Height=height;
3925 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3926 explicit_bounds = bounds;
3928 client_size.Width=clientWidth;
3929 client_size.Height=clientHeight;
3932 OnLocationChanged(EventArgs.Empty);
3936 OnSizeChanged(EventArgs.Empty);
3940 [EditorBrowsable(EditorBrowsableState.Advanced)]
3941 protected void UpdateStyles() {
3942 if (!IsHandleCreated) {
3946 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3947 OnStyleChanged(EventArgs.Empty);
3950 private void UpdateZOrderOfChild(Control child) {
3951 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3954 index = child_controls.IndexOf(child);
3957 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3959 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3964 private void UpdateChildrenZOrder() {
3965 Control [] controls;
3967 if (!IsHandleCreated) {
3971 controls = child_controls.GetAllControls ();
3972 for (int i = 1; i < controls.Length; i++ ) {
3973 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3977 [EditorBrowsable(EditorBrowsableState.Advanced)]
3978 protected void UpdateZOrder() {
3979 if (parent != null) {
3980 parent.UpdateZOrderOfChild(this);
3984 protected virtual void WndProc(ref Message m) {
3986 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3988 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3992 switch((Msg)m.Msg) {
3993 case Msg.WM_DESTROY: {
3994 OnHandleDestroyed(EventArgs.Empty);
3996 IntPtr handle = window.Handle;
3998 window.InvalidateHandle();
4000 if (is_recreating) {
4002 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4006 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4008 is_recreating = false;
4013 case Msg.WM_WINDOWPOSCHANGED: {
4015 Rectangle save_bounds = explicit_bounds;
4017 explicit_bounds = save_bounds;
4018 if (GetStyle(ControlStyles.ResizeRedraw)) {
4025 // Nice description of what should happen when handling WM_PAINT
4026 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4027 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4028 case Msg.WM_PAINT: {
4029 PaintEventArgs paint_event;
4031 paint_event = XplatUI.PaintEventStart(Handle, true);
4033 if (paint_event == null) {
4037 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4038 // Just blit the previous image
4039 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4040 XplatUI.PaintEventEnd(Handle, true);
4045 Graphics back_dc = null;
4046 Bitmap backbuffer = null;
4047 if (ThemeEngine.Current.DoubleBufferingSupported) {
4048 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4049 backbuffer = ImageBuffer;
4050 back_dc = Graphics.FromImage (backbuffer);
4051 dc = paint_event.SetGraphics (back_dc);
4055 if (!GetStyle(ControlStyles.Opaque)) {
4056 OnPaintBackground(paint_event);
4059 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4060 OnPaintBackgroundInternal(paint_event);
4062 OnPaintInternal(paint_event);
4063 if (!paint_event.Handled) {
4064 OnPaint(paint_event);
4067 if (ThemeEngine.Current.DoubleBufferingSupported)
4068 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4069 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4070 paint_event.SetGraphics (dc);
4071 invalid_region.Exclude (paint_event.ClipRectangle);
4073 if (backbuffer != bmp_mem)
4074 backbuffer.Dispose();
4077 XplatUI.PaintEventEnd(Handle, true);
4082 case Msg.WM_ERASEBKGND: {
4083 // The DefWndProc will never have to handle this, we always paint the background in managed code
4084 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4085 // here but it just makes things more complicated...
4086 m.Result = (IntPtr)1;
4090 case Msg.WM_LBUTTONUP: {
4093 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4095 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4098 HandleClick(mouse_clicks, me);
4101 if (InternalCapture) {
4102 InternalCapture = false;
4105 if (mouse_clicks > 1) {
4111 case Msg.WM_LBUTTONDOWN: {
4113 Select (true, true);
4115 InternalCapture = true;
4116 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4117 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4123 case Msg.WM_LBUTTONDBLCLK: {
4124 InternalCapture = true;
4126 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4127 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4133 case Msg.WM_MBUTTONUP: {
4136 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4138 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4141 HandleClick(mouse_clicks, me);
4143 if (InternalCapture) {
4144 InternalCapture = false;
4146 if (mouse_clicks > 1) {
4152 case Msg.WM_MBUTTONDOWN: {
4153 InternalCapture = true;
4154 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4155 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4161 case Msg.WM_MBUTTONDBLCLK: {
4162 InternalCapture = true;
4164 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4165 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4170 case Msg.WM_RBUTTONUP: {
4174 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4175 pt = PointToScreen(pt);
4177 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4179 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4181 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4184 HandleClick(mouse_clicks, me);
4187 if (InternalCapture) {
4188 InternalCapture = false;
4191 if (mouse_clicks > 1) {
4197 case Msg.WM_RBUTTONDOWN: {
4198 InternalCapture = true;
4199 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4200 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4205 case Msg.WM_RBUTTONDBLCLK: {
4206 InternalCapture = true;
4208 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4209 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4214 case Msg.WM_CONTEXTMENU: {
4215 if (context_menu != null) {
4218 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4219 context_menu.Show(this, PointToClient(pt));
4227 case Msg.WM_MOUSEWHEEL: {
4229 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4230 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4231 HighOrder(m.WParam.ToInt32())));
4236 case Msg.WM_MOUSEMOVE: {
4237 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4239 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4244 case Msg.WM_MOUSE_ENTER: {
4249 OnMouseEnter(EventArgs.Empty);
4253 case Msg.WM_MOUSE_LEAVE: {
4255 OnMouseLeave(EventArgs.Empty);
4259 case Msg.WM_MOUSEHOVER: {
4260 OnMouseHover(EventArgs.Empty);
4264 case Msg.WM_SYSKEYUP: {
4265 if (ProcessKeyMessage(ref m)) {
4266 m.Result = IntPtr.Zero;
4270 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4274 if (form != null && form.ActiveMenu != null) {
4275 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4283 case Msg.WM_SYSKEYDOWN:
4284 case Msg.WM_KEYDOWN:
4286 case Msg.WM_SYSCHAR:
4288 if (ProcessKeyMessage(ref m)) {
4289 m.Result = IntPtr.Zero;
4298 if (m.LParam != IntPtr.Zero) {
4301 hi = new HELPINFO();
4303 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4304 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4306 mouse_pos = Control.MousePosition;
4308 OnHelpRequested(new HelpEventArgs(mouse_pos));
4309 m.Result = (IntPtr)1;
4313 case Msg.WM_KILLFOCUS: {
4314 this.has_focus = false;
4315 OnLostFocusInternal (EventArgs.Empty);
4319 case Msg.WM_SETFOCUS: {
4321 this.has_focus = true;
4322 OnGotFocusInternal (EventArgs.Empty);
4328 case Msg.WM_SYSCOLORCHANGE: {
4329 ThemeEngine.Current.ResetDefaults();
4330 OnSystemColorsChanged(EventArgs.Empty);
4335 case Msg.WM_SETCURSOR: {
4336 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4341 XplatUI.SetCursor(window.Handle, cursor.handle);
4342 m.Result = (IntPtr)1;
4353 #endregion // Public Instance Methods
4355 #region OnXXX methods
4356 [EditorBrowsable(EditorBrowsableState.Advanced)]
4357 protected virtual void OnBackColorChanged(EventArgs e) {
4358 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4361 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4364 [EditorBrowsable(EditorBrowsableState.Advanced)]
4365 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4366 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4369 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4372 [EditorBrowsable(EditorBrowsableState.Advanced)]
4373 protected virtual void OnBindingContextChanged(EventArgs e) {
4374 CheckDataBindings ();
4375 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4378 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4381 [EditorBrowsable(EditorBrowsableState.Advanced)]
4382 protected virtual void OnCausesValidationChanged(EventArgs e) {
4383 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4388 [EditorBrowsable(EditorBrowsableState.Advanced)]
4389 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4390 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4395 [EditorBrowsable(EditorBrowsableState.Advanced)]
4396 protected virtual void OnClick(EventArgs e) {
4397 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4402 [EditorBrowsable(EditorBrowsableState.Advanced)]
4403 protected virtual void OnContextMenuChanged(EventArgs e) {
4404 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4409 [EditorBrowsable(EditorBrowsableState.Advanced)]
4410 protected virtual void OnControlAdded(ControlEventArgs e) {
4411 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4416 [EditorBrowsable(EditorBrowsableState.Advanced)]
4417 protected virtual void OnControlRemoved(ControlEventArgs e) {
4418 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4423 [EditorBrowsable(EditorBrowsableState.Advanced)]
4424 protected virtual void OnCreateControl() {
4428 [EditorBrowsable(EditorBrowsableState.Advanced)]
4429 protected virtual void OnCursorChanged(EventArgs e) {
4430 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4435 [EditorBrowsable(EditorBrowsableState.Advanced)]
4436 protected virtual void OnDockChanged(EventArgs e) {
4437 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4442 [EditorBrowsable(EditorBrowsableState.Advanced)]
4443 protected virtual void OnDoubleClick(EventArgs e) {
4444 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4449 [EditorBrowsable(EditorBrowsableState.Advanced)]
4450 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4451 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4453 eh (this, drgevent);
4456 [EditorBrowsable(EditorBrowsableState.Advanced)]
4457 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4458 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4460 eh (this, drgevent);
4463 [EditorBrowsable(EditorBrowsableState.Advanced)]
4464 protected virtual void OnDragLeave(EventArgs e) {
4465 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4470 [EditorBrowsable(EditorBrowsableState.Advanced)]
4471 protected virtual void OnDragOver(DragEventArgs drgevent) {
4472 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4474 eh (this, drgevent);
4477 [EditorBrowsable(EditorBrowsableState.Advanced)]
4478 protected virtual void OnEnabledChanged(EventArgs e) {
4479 if (IsHandleCreated) {
4481 if (((Form)this).context == null) {
4482 XplatUI.EnableWindow(window.Handle, Enabled);
4485 XplatUI.EnableWindow(window.Handle, Enabled);
4490 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4494 for (int i=0; i<child_controls.Count; i++) {
4495 child_controls[i].OnParentEnabledChanged(e);
4499 [EditorBrowsable(EditorBrowsableState.Advanced)]
4500 protected virtual void OnEnter(EventArgs e) {
4501 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4506 [EditorBrowsable(EditorBrowsableState.Advanced)]
4507 protected virtual void OnFontChanged(EventArgs e) {
4508 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4511 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4514 [EditorBrowsable(EditorBrowsableState.Advanced)]
4515 protected virtual void OnForeColorChanged(EventArgs e) {
4516 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4519 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4522 [EditorBrowsable(EditorBrowsableState.Advanced)]
4523 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4524 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4526 eh (this, gfbevent);
4529 [EditorBrowsable(EditorBrowsableState.Advanced)]
4530 protected virtual void OnGotFocus(EventArgs e) {
4531 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4536 [EditorBrowsable(EditorBrowsableState.Advanced)]
4537 protected virtual void OnHandleCreated(EventArgs e) {
4538 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4543 [EditorBrowsable(EditorBrowsableState.Advanced)]
4544 protected virtual void OnHandleDestroyed(EventArgs e) {
4545 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4550 [EditorBrowsable(EditorBrowsableState.Advanced)]
4551 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4552 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4557 protected virtual void OnImeModeChanged(EventArgs e) {
4558 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4563 [EditorBrowsable(EditorBrowsableState.Advanced)]
4564 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4565 if (ThemeEngine.Current.DoubleBufferingSupported)
4566 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4567 // should this block be here? seems like it
4568 // would be more at home in
4569 // NotifyInvalidated..
4570 if (e.InvalidRect == ClientRectangle) {
4571 ImageBufferNeedsRedraw ();
4574 // we need this Inflate call here so
4575 // that the border of the rectangle is
4576 // considered Visible (the
4577 // invalid_region.IsVisible call) in
4578 // the WM_PAINT handling below.
4579 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4580 if (invalid_region == null)
4581 invalid_region = new Region (r);
4583 invalid_region.Union (r);
4587 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4592 [EditorBrowsable(EditorBrowsableState.Advanced)]
4593 protected virtual void OnKeyDown(KeyEventArgs e) {
4594 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4599 [EditorBrowsable(EditorBrowsableState.Advanced)]
4600 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4601 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4606 [EditorBrowsable(EditorBrowsableState.Advanced)]
4607 protected virtual void OnKeyUp(KeyEventArgs e) {
4608 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4613 [EditorBrowsable(EditorBrowsableState.Advanced)]
4614 protected virtual void OnLayout(LayoutEventArgs levent) {
4615 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4620 [EditorBrowsable(EditorBrowsableState.Advanced)]
4621 protected virtual void OnLeave(EventArgs e) {
4622 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4627 [EditorBrowsable(EditorBrowsableState.Advanced)]
4628 protected virtual void OnLocationChanged(EventArgs e) {
4630 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4635 [EditorBrowsable(EditorBrowsableState.Advanced)]
4636 protected virtual void OnLostFocus(EventArgs e) {
4637 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4642 [EditorBrowsable(EditorBrowsableState.Advanced)]
4643 protected virtual void OnMouseDown(MouseEventArgs e) {
4644 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4649 [EditorBrowsable(EditorBrowsableState.Advanced)]
4650 protected virtual void OnMouseEnter(EventArgs e) {
4651 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4656 [EditorBrowsable(EditorBrowsableState.Advanced)]
4657 protected virtual void OnMouseHover(EventArgs e) {
4658 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4663 [EditorBrowsable(EditorBrowsableState.Advanced)]
4664 protected virtual void OnMouseLeave(EventArgs e) {
4665 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4670 [EditorBrowsable(EditorBrowsableState.Advanced)]
4671 protected virtual void OnMouseMove(MouseEventArgs e) {
4672 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4677 [EditorBrowsable(EditorBrowsableState.Advanced)]
4678 protected virtual void OnMouseUp(MouseEventArgs e) {
4679 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4684 [EditorBrowsable(EditorBrowsableState.Advanced)]
4685 protected virtual void OnMouseWheel(MouseEventArgs e) {
4686 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4691 [EditorBrowsable(EditorBrowsableState.Advanced)]
4692 protected virtual void OnMove(EventArgs e) {
4693 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4698 [EditorBrowsable(EditorBrowsableState.Advanced)]
4699 protected virtual void OnNotifyMessage(Message m) {
4703 [EditorBrowsable(EditorBrowsableState.Advanced)]
4704 protected virtual void OnPaint(PaintEventArgs e) {
4705 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4710 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4714 internal virtual void OnPaintInternal(PaintEventArgs e) {
4718 internal virtual void OnGotFocusInternal (EventArgs e)
4723 internal virtual void OnLostFocusInternal (EventArgs e)
4728 [EditorBrowsable(EditorBrowsableState.Advanced)]
4729 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4730 PaintControlBackground (pevent);
4733 [EditorBrowsable(EditorBrowsableState.Advanced)]
4734 protected virtual void OnParentBackColorChanged(EventArgs e) {
4735 if (background_color.IsEmpty && background_image==null) {
4737 OnBackColorChanged(e);
4741 [EditorBrowsable(EditorBrowsableState.Advanced)]
4742 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4743 if (background_color.IsEmpty && background_image==null) {
4745 OnBackgroundImageChanged(e);
4749 [EditorBrowsable(EditorBrowsableState.Advanced)]
4750 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4751 if (binding_context==null) {
4752 binding_context=Parent.binding_context;
4753 OnBindingContextChanged(e);
4757 [EditorBrowsable(EditorBrowsableState.Advanced)]
4758 protected virtual void OnParentChanged(EventArgs e) {
4759 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4764 [EditorBrowsable(EditorBrowsableState.Advanced)]
4765 protected virtual void OnParentEnabledChanged(EventArgs e) {
4767 OnEnabledChanged(e);
4771 [EditorBrowsable(EditorBrowsableState.Advanced)]
4772 protected virtual void OnParentFontChanged(EventArgs e) {
4779 [EditorBrowsable(EditorBrowsableState.Advanced)]
4780 protected virtual void OnParentForeColorChanged(EventArgs e) {
4781 if (foreground_color.IsEmpty) {
4783 OnForeColorChanged(e);
4787 [EditorBrowsable(EditorBrowsableState.Advanced)]
4788 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4789 if (right_to_left==RightToLeft.Inherit) {
4791 OnRightToLeftChanged(e);
4795 [EditorBrowsable(EditorBrowsableState.Advanced)]
4796 protected virtual void OnParentVisibleChanged(EventArgs e) {
4798 OnVisibleChanged(e);
4802 [EditorBrowsable(EditorBrowsableState.Advanced)]
4803 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4804 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4809 [EditorBrowsable(EditorBrowsableState.Advanced)]
4810 protected virtual void OnResize(EventArgs e) {
4811 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4815 PerformLayout(this, "bounds");
4817 if (parent != null) {
4818 parent.PerformLayout();
4822 [EditorBrowsable(EditorBrowsableState.Advanced)]
4823 protected virtual void OnRightToLeftChanged(EventArgs e) {
4824 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4827 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4830 [EditorBrowsable(EditorBrowsableState.Advanced)]
4831 protected virtual void OnSizeChanged(EventArgs e) {
4832 InvalidateBuffers ();
4834 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4839 [EditorBrowsable(EditorBrowsableState.Advanced)]
4840 protected virtual void OnStyleChanged(EventArgs e) {
4841 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4846 [EditorBrowsable(EditorBrowsableState.Advanced)]
4847 protected virtual void OnSystemColorsChanged(EventArgs e) {
4848 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4853 [EditorBrowsable(EditorBrowsableState.Advanced)]
4854 protected virtual void OnTabIndexChanged(EventArgs e) {
4855 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4860 [EditorBrowsable(EditorBrowsableState.Advanced)]
4861 protected virtual void OnTabStopChanged(EventArgs e) {
4862 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4867 [EditorBrowsable(EditorBrowsableState.Advanced)]
4868 protected virtual void OnTextChanged(EventArgs e) {
4869 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4874 [EditorBrowsable(EditorBrowsableState.Advanced)]
4875 protected virtual void OnValidated(EventArgs e) {
4876 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4881 [EditorBrowsable(EditorBrowsableState.Advanced)]
4882 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4883 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4888 [EditorBrowsable(EditorBrowsableState.Advanced)]
4889 protected virtual void OnVisibleChanged(EventArgs e) {
4890 if ((parent != null) && !Created && Visible) {
4897 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4901 // We need to tell our kids
4902 for (int i=0; i<child_controls.Count; i++) {
4903 if (child_controls[i].Visible) {
4904 child_controls[i].OnParentVisibleChanged(e);
4908 #endregion // OnXXX methods
4911 static object BackColorChangedEvent = new object ();
4912 static object BackgroundImageChangedEvent = new object ();
4913 static object BindingContextChangedEvent = new object ();
4914 static object CausesValidationChangedEvent = new object ();
4915 static object ChangeUICuesEvent = new object ();
4916 static object ClickEvent = new object ();
4917 static object ContextMenuChangedEvent = new object ();
4918 static object ControlAddedEvent = new object ();
4919 static object ControlRemovedEvent = new object ();
4920 static object CursorChangedEvent = new object ();
4921 static object DockChangedEvent = new object ();
4922 static object DoubleClickEvent = new object ();
4923 static object DragDropEvent = new object ();
4924 static object DragEnterEvent = new object ();
4925 static object DragLeaveEvent = new object ();
4926 static object DragOverEvent = new object ();
4927 static object EnabledChangedEvent = new object ();
4928 static object EnterEvent = new object ();
4929 static object FontChangedEvent = new object ();
4930 static object ForeColorChangedEvent = new object ();
4931 static object GiveFeedbackEvent = new object ();
4932 static object GotFocusEvent = new object ();
4933 static object HandleCreatedEvent = new object ();
4934 static object HandleDestroyedEvent = new object ();
4935 static object HelpRequestedEvent = new object ();
4936 static object ImeModeChangedEvent = new object ();
4937 static object InvalidatedEvent = new object ();
4938 static object KeyDownEvent = new object ();
4939 static object KeyPressEvent = new object ();
4940 static object KeyUpEvent = new object ();
4941 static object LayoutEvent = new object ();
4942 static object LeaveEvent = new object ();
4943 static object LocationChangedEvent = new object ();
4944 static object LostFocusEvent = new object ();
4945 static object MouseDownEvent = new object ();
4946 static object MouseEnterEvent = new object ();
4947 static object MouseHoverEvent = new object ();
4948 static object MouseLeaveEvent = new object ();
4949 static object MouseMoveEvent = new object ();
4950 static object MouseUpEvent = new object ();
4951 static object MouseWheelEvent = new object ();
4952 static object MoveEvent = new object ();
4953 static object PaintEvent = new object ();
4954 static object ParentChangedEvent = new object ();
4955 static object QueryAccessibilityHelpEvent = new object ();
4956 static object QueryContinueDragEvent = new object ();
4957 static object ResizeEvent = new object ();
4958 static object RightToLeftChangedEvent = new object ();
4959 static object SizeChangedEvent = new object ();
4960 static object StyleChangedEvent = new object ();
4961 static object SystemColorsChangedEvent = new object ();
4962 static object TabIndexChangedEvent = new object ();
4963 static object TabStopChangedEvent = new object ();
4964 static object TextChangedEvent = new object ();
4965 static object ValidatedEvent = new object ();
4966 static object ValidatingEvent = new object ();
4967 static object VisibleChangedEvent = new object ();
4969 public event EventHandler BackColorChanged {
4970 add { Events.AddHandler (BackColorChangedEvent, value); }
4971 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4974 public event EventHandler BackgroundImageChanged {
4975 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4976 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4979 public event EventHandler BindingContextChanged {
4980 add { Events.AddHandler (BindingContextChangedEvent, value); }
4981 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4984 public event EventHandler CausesValidationChanged {
4985 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4986 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4989 public event UICuesEventHandler ChangeUICues {
4990 add { Events.AddHandler (ChangeUICuesEvent, value); }
4991 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4994 public event EventHandler Click {
4995 add { Events.AddHandler (ClickEvent, value); }
4996 remove { Events.RemoveHandler (ClickEvent, value); }
4999 public event EventHandler ContextMenuChanged {
5000 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5001 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5004 [EditorBrowsable(EditorBrowsableState.Advanced)]
5006 public event ControlEventHandler ControlAdded {
5007 add { Events.AddHandler (ControlAddedEvent, value); }
5008 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5011 [EditorBrowsable(EditorBrowsableState.Advanced)]
5013 public event ControlEventHandler ControlRemoved {
5014 add { Events.AddHandler (ControlRemovedEvent, value); }
5015 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5018 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5019 public event EventHandler CursorChanged {
5020 add { Events.AddHandler (CursorChangedEvent, value); }
5021 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5023 public event EventHandler DockChanged {
5024 add { Events.AddHandler (DockChangedEvent, value); }
5025 remove { Events.RemoveHandler (DockChangedEvent, value); }
5028 public event EventHandler DoubleClick {
5029 add { Events.AddHandler (DoubleClickEvent, value); }
5030 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5033 public event DragEventHandler DragDrop {
5034 add { Events.AddHandler (DragDropEvent, value); }
5035 remove { Events.RemoveHandler (DragDropEvent, value); }
5038 public event DragEventHandler DragEnter {
5039 add { Events.AddHandler (DragEnterEvent, value); }
5040 remove { Events.RemoveHandler (DragEnterEvent, value); }
5043 public event EventHandler DragLeave {
5044 add { Events.AddHandler (DragLeaveEvent, value); }
5045 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5048 public event DragEventHandler DragOver {
5049 add { Events.AddHandler (DragOverEvent, value); }
5050 remove { Events.RemoveHandler (DragOverEvent, value); }
5053 public event EventHandler EnabledChanged {
5054 add { Events.AddHandler (EnabledChangedEvent, value); }
5055 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5058 public event EventHandler Enter {
5059 add { Events.AddHandler (EnterEvent, value); }
5060 remove { Events.RemoveHandler (EnterEvent, value); }
5063 public event EventHandler FontChanged {
5064 add { Events.AddHandler (FontChangedEvent, value); }
5065 remove { Events.RemoveHandler (FontChangedEvent, value); }
5068 public event EventHandler ForeColorChanged {
5069 add { Events.AddHandler (ForeColorChangedEvent, value); }
5070 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5073 public event GiveFeedbackEventHandler GiveFeedback {
5074 add { Events.AddHandler (GiveFeedbackEvent, value); }
5075 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5078 [EditorBrowsable(EditorBrowsableState.Advanced)]
5080 public event EventHandler GotFocus {
5081 add { Events.AddHandler (GotFocusEvent, value); }
5082 remove { Events.RemoveHandler (GotFocusEvent, value); }
5086 [EditorBrowsable(EditorBrowsableState.Advanced)]
5088 public event EventHandler HandleCreated {
5089 add { Events.AddHandler (HandleCreatedEvent, value); }
5090 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5093 [EditorBrowsable(EditorBrowsableState.Advanced)]
5095 public event EventHandler HandleDestroyed {
5096 add { Events.AddHandler (HandleDestroyedEvent, value); }
5097 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5100 public event HelpEventHandler HelpRequested {
5101 add { Events.AddHandler (HelpRequestedEvent, value); }
5102 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5105 public event EventHandler ImeModeChanged {
5106 add { Events.AddHandler (ImeModeChangedEvent, value); }
5107 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5110 [EditorBrowsable(EditorBrowsableState.Advanced)]
5112 public event InvalidateEventHandler Invalidated {
5113 add { Events.AddHandler (InvalidatedEvent, value); }
5114 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5117 public event KeyEventHandler KeyDown {
5118 add { Events.AddHandler (KeyDownEvent, value); }
5119 remove { Events.RemoveHandler (KeyDownEvent, value); }
5122 public event KeyPressEventHandler KeyPress {
5123 add { Events.AddHandler (KeyPressEvent, value); }
5124 remove { Events.RemoveHandler (KeyPressEvent, value); }
5127 public event KeyEventHandler KeyUp {
5128 add { Events.AddHandler (KeyUpEvent, value); }
5129 remove { Events.RemoveHandler (KeyUpEvent, value); }
5132 public event LayoutEventHandler Layout {
5133 add { Events.AddHandler (LayoutEvent, value); }
5134 remove { Events.RemoveHandler (LayoutEvent, value); }
5137 public event EventHandler Leave {
5138 add { Events.AddHandler (LeaveEvent, value); }
5139 remove { Events.RemoveHandler (LeaveEvent, value); }
5142 public event EventHandler LocationChanged {
5143 add { Events.AddHandler (LocationChangedEvent, value); }
5144 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5147 [EditorBrowsable(EditorBrowsableState.Advanced)]
5149 public event EventHandler LostFocus {
5150 add { Events.AddHandler (LostFocusEvent, value); }
5151 remove { Events.RemoveHandler (LostFocusEvent, value); }
5154 public event MouseEventHandler MouseDown {
5155 add { Events.AddHandler (MouseDownEvent, value); }
5156 remove { Events.RemoveHandler (MouseDownEvent, value); }
5159 public event EventHandler MouseEnter {
5160 add { Events.AddHandler (MouseEnterEvent, value); }
5161 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5164 public event EventHandler MouseHover {
5165 add { Events.AddHandler (MouseHoverEvent, value); }
5166 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5169 public event EventHandler MouseLeave {
5170 add { Events.AddHandler (MouseLeaveEvent, value); }
5171 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5174 public event MouseEventHandler MouseMove {
5175 add { Events.AddHandler (MouseMoveEvent, value); }
5176 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5179 public event MouseEventHandler MouseUp {
5180 add { Events.AddHandler (MouseUpEvent, value); }
5181 remove { Events.RemoveHandler (MouseUpEvent, value); }
5184 [EditorBrowsable(EditorBrowsableState.Advanced)]
5186 public event MouseEventHandler MouseWheel {
5187 add { Events.AddHandler (MouseWheelEvent, value); }
5188 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5191 public event EventHandler Move {
5192 add { Events.AddHandler (MoveEvent, value); }
5193 remove { Events.RemoveHandler (MoveEvent, value); }
5196 public event PaintEventHandler Paint {
5197 add { Events.AddHandler (PaintEvent, value); }
5198 remove { Events.RemoveHandler (PaintEvent, value); }
5201 public event EventHandler ParentChanged {
5202 add { Events.AddHandler (ParentChangedEvent, value); }
5203 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5206 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5207 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5208 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5211 public event QueryContinueDragEventHandler QueryContinueDrag {
5212 add { Events.AddHandler (QueryContinueDragEvent, value); }
5213 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5216 public event EventHandler Resize {
5217 add { Events.AddHandler (ResizeEvent, value); }
5218 remove { Events.RemoveHandler (ResizeEvent, value); }
5221 public event EventHandler RightToLeftChanged {
5222 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5223 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5226 public event EventHandler SizeChanged {
5227 add { Events.AddHandler (SizeChangedEvent, value); }
5228 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5231 public event EventHandler StyleChanged {
5232 add { Events.AddHandler (StyleChangedEvent, value); }
5233 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5236 public event EventHandler SystemColorsChanged {
5237 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5238 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5241 public event EventHandler TabIndexChanged {
5242 add { Events.AddHandler (TabIndexChangedEvent, value); }
5243 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5246 public event EventHandler TabStopChanged {
5247 add { Events.AddHandler (TabStopChangedEvent, value); }
5248 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5251 public event EventHandler TextChanged {
5252 add { Events.AddHandler (TextChangedEvent, value); }
5253 remove { Events.RemoveHandler (TextChangedEvent, value); }
5256 public event EventHandler Validated {
5257 add { Events.AddHandler (ValidatedEvent, value); }
5258 remove { Events.RemoveHandler (ValidatedEvent, value); }
5261 public event CancelEventHandler Validating {
5262 add { Events.AddHandler (ValidatingEvent, value); }
5263 remove { Events.RemoveHandler (ValidatingEvent, value); }
5266 public event EventHandler VisibleChanged {
5267 add { Events.AddHandler (VisibleChangedEvent, value); }
5268 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5271 #endregion // Events