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 private 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 internal string name; // for object naming
70 internal 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 internal 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 internal bool is_recreating; // tracks if the handle for the control is being recreated
79 internal 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 internal int tab_index; // position in tab order of siblings
82 internal bool tab_stop = true; // is the control a tab stop?
83 internal 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 internal 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 internal 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 internal string text; // window/title text for control
101 internal BorderStyle border_style; // Border style of control
104 internal AnchorStyles anchor_style; // anchoring requirements for our control
105 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
106 internal int dist_left; // distance to the left border of the parent
107 internal int dist_top; // distance to the top border of the parent
108 internal int dist_right; // distance to the right border of the parent
109 internal int dist_bottom; // distance to the bottom border of the parent
111 // to be categorized...
112 static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
113 internal ControlCollection child_controls; // our children
114 internal Control parent; // our parent control
115 internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
116 internal BindingContext binding_context; // TODO
117 internal RightToLeft right_to_left; // drawing direction for control
118 internal int layout_suspended;
119 internal ContextMenu context_menu; // Context menu associated with the control
121 private Graphics dc_mem; // Graphics context for double buffering
122 private Bitmap bmp_mem; // Bitmap for double buffering control
123 private Region invalid_region;
125 private ControlBindingsCollection data_bindings;
128 internal bool use_compatible_text_rendering;
129 static bool verify_thread_handle;
135 Layout.LayoutEngine layout_engine;
138 #endregion // Local Variables
140 #region Private Classes
141 // This helper class allows us to dispatch messages to Control.WndProc
142 internal class ControlNativeWindow : NativeWindow {
143 private Control owner;
145 public ControlNativeWindow(Control control) : base() {
150 public Control Owner {
156 static internal Control ControlFromHandle(IntPtr hWnd) {
157 ControlNativeWindow window;
159 window = (ControlNativeWindow)window_collection[hWnd];
160 if (window != null) {
167 static internal Control ControlFromChildHandle (IntPtr handle) {
168 ControlNativeWindow window;
170 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
171 while (hwnd != null) {
172 window = (ControlNativeWindow)window_collection[hwnd.Handle];
173 if (window != null) {
182 protected override void WndProc(ref Message m) {
183 owner.WndProc(ref m);
188 #region Public Classes
190 public class ControlAccessibleObject : AccessibleObject {
193 #region ControlAccessibleObject Constructors
194 public ControlAccessibleObject(Control ownerControl)
195 : base (ownerControl)
197 this.owner = ownerControl;
199 #endregion // ControlAccessibleObject Constructors
201 #region ControlAccessibleObject Public Instance Properties
202 public override string DefaultAction {
204 return base.DefaultAction;
208 public override string Description {
210 return base.Description;
214 public IntPtr Handle {
220 // We don't want to let them set it
224 public override string Help {
230 public override string KeyboardShortcut {
232 return base.KeyboardShortcut;
236 public override string Name {
246 public Control Owner {
252 public override AccessibleObject Parent {
259 public override AccessibleRole Role {
264 #endregion // ControlAccessibleObject Public Instance Properties
266 #region ControlAccessibleObject Public Instance Methods
267 public override int GetHelpTopic(out string FileName) {
268 return base.GetHelpTopic (out FileName);
271 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
272 public void NotifyClients(AccessibleEvents accEvent) {
273 throw new NotImplementedException();
276 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
277 public void NotifyClients(AccessibleEvents accEvent, int childID) {
278 throw new NotImplementedException();
281 public override string ToString() {
282 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
285 #endregion // ControlAccessibleObject Public Instance Methods
288 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
289 [ListBindable(false)]
290 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
291 #region ControlCollection Local Variables
294 Control[] all_controls;
296 #endregion // ControlCollection Local Variables
298 #region ControlCollection Public Constructor
299 public ControlCollection(Control owner) {
301 this.list=new ArrayList();
305 #region ControlCollection Public Instance Properties
312 public bool IsReadOnly {
314 return list.IsReadOnly;
318 public virtual Control this[int index] {
320 if (index < 0 || index >= list.Count) {
321 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
323 return (Control)list[index];
326 #endregion // ControlCollection Public Instance Properties
328 #region ControlCollection Private Instance Methods
329 public virtual void Add (Control value)
334 if (Contains (value)) {
335 owner.PerformLayout();
339 if (value.tab_index == -1) {
345 end = owner.child_controls.Count;
346 for (int i = 0; i < end; i++) {
347 index = owner.child_controls[i].tab_index;
352 value.tab_index = use;
355 if (value.parent != null) {
356 value.parent.Controls.Remove(value);
362 value.ChangeParent(owner);
366 owner.UpdateChildrenZOrder();
367 owner.PerformLayout(value, "Parent");
368 owner.OnControlAdded(new ControlEventArgs(value));
371 internal void AddToList (Control c)
377 internal virtual void AddImplicit (Control control)
379 if (impl_list == null)
380 impl_list = new ArrayList ();
382 if (AllContains (control))
386 impl_list.Add (control);
388 control.ChangeParent (owner);
389 control.InitLayout ();
390 owner.UpdateChildrenZOrder ();
391 owner.PerformLayout (control, "Parent");
392 owner.OnControlAdded (new ControlEventArgs (control));
395 public virtual void AddRange (Control[] controls)
397 if (controls == null)
398 throw new ArgumentNullException ("controls");
400 owner.SuspendLayout ();
403 for (int i = 0; i < controls.Length; i++)
406 owner.ResumeLayout ();
410 internal virtual void AddRangeImplicit (Control [] controls)
412 if (controls == null)
413 throw new ArgumentNullException ("controls");
415 owner.SuspendLayout ();
418 for (int i = 0; i < controls.Length; i++)
419 AddImplicit (controls [i]);
421 owner.ResumeLayout ();
425 public virtual void Clear ()
429 // MS sends remove events in reverse order
430 while (list.Count > 0) {
431 Remove((Control)list[list.Count - 1]);
435 internal virtual void ClearImplicit ()
437 if (impl_list == null)
443 public bool Contains (Control value)
445 for (int i = list.Count; i > 0; ) {
448 if (list [i] == value) {
449 // Do we need to do anything here?
456 internal bool ImplicitContains (Control value)
458 if (impl_list == null)
461 for (int i = impl_list.Count; i > 0; ) {
464 if (impl_list [i] == value) {
465 // Do we need to do anything here?
472 internal bool AllContains (Control value)
474 return Contains (value) || ImplicitContains (value);
477 public void CopyTo (Array array, int index)
479 list.CopyTo(array, index);
482 public override bool Equals(object other) {
483 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
490 public int GetChildIndex(Control child) {
491 return GetChildIndex(child, false);
494 public int GetChildIndex(Control child, bool throwException) {
497 index=list.IndexOf(child);
499 if (index==-1 && throwException) {
500 throw new ArgumentException("Not a child control", "child");
505 public IEnumerator GetEnumerator() {
506 return list.GetEnumerator();
509 internal IEnumerator GetAllEnumerator ()
511 Control [] res = GetAllControls ();
512 return res.GetEnumerator ();
515 internal Control [] GetAllControls ()
517 if (all_controls != null)
520 if (impl_list == null) {
521 all_controls = (Control []) list.ToArray (typeof (Control));
525 all_controls = new Control [list.Count + impl_list.Count];
526 impl_list.CopyTo (all_controls);
527 list.CopyTo (all_controls, impl_list.Count);
532 public override int GetHashCode() {
533 return base.GetHashCode();
536 public int IndexOf(Control control) {
537 return list.IndexOf(control);
540 public virtual void Remove(Control value) {
541 owner.PerformLayout(value, "Parent");
542 owner.OnControlRemoved(new ControlEventArgs(value));
547 value.ChangeParent(null);
549 owner.UpdateChildrenZOrder();
552 internal virtual void RemoveImplicit (Control control)
554 if (impl_list != null) {
556 owner.PerformLayout (control, "Parent");
557 owner.OnControlRemoved (new ControlEventArgs (control));
558 impl_list.Remove (control);
560 control.ChangeParent (null);
561 owner.UpdateChildrenZOrder ();
564 public void RemoveAt(int index) {
565 if (index < 0 || index >= list.Count) {
566 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
568 Remove ((Control)list[index]);
571 public void SetChildIndex(Control child, int newIndex) {
574 old_index=list.IndexOf(child);
576 throw new ArgumentException("Not a child control", "child");
579 if (old_index==newIndex) {
584 list.RemoveAt(old_index);
586 if (newIndex>list.Count) {
589 list.Insert(newIndex, child);
591 child.UpdateZOrder();
592 owner.PerformLayout();
594 #endregion // ControlCollection Private Instance Methods
596 #region ControlCollection Interface Properties
597 object IList.this[int index] {
599 if (index<0 || index>=list.Count) {
600 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
606 if (!(value is Control)) {
607 throw new ArgumentException("Object of type Control required", "value");
611 Control ctrl = (Control) value;
614 ctrl.ChangeParent(owner);
618 owner.UpdateChildrenZOrder();
619 owner.PerformLayout(ctrl, "Parent");
623 bool IList.IsFixedSize {
629 bool ICollection.IsSynchronized {
631 return list.IsSynchronized;
635 object ICollection.SyncRoot {
637 return list.SyncRoot;
640 #endregion // ControlCollection Interface Properties
642 #region ControlCollection Interface Methods
643 int IList.Add(object value) {
645 throw new ArgumentNullException("value", "Cannot add null controls");
648 if (!(value is Control)) {
649 throw new ArgumentException("Object of type Control required", "value");
652 return list.Add(value);
655 bool IList.Contains(object value) {
656 if (!(value is Control)) {
657 throw new ArgumentException("Object of type Control required", "value");
660 return this.Contains((Control) value);
663 int IList.IndexOf(object value) {
664 if (!(value is Control)) {
665 throw new ArgumentException("Object of type Control required", "value");
668 return this.IndexOf((Control) value);
671 void IList.Insert(int index, object value) {
672 if (!(value is Control)) {
673 throw new ArgumentException("Object of type Control required", "value");
676 list.Insert(index, value);
679 void IList.Remove(object value) {
680 if (!(value is Control)) {
681 throw new ArgumentException("Object of type Control required", "value");
687 Object ICloneable.Clone() {
688 ControlCollection clone = new ControlCollection(this.owner);
689 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
692 #endregion // ControlCollection Interface Methods
694 #endregion // ControlCollection Class
696 #region Public Constructors
699 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
707 layout_pending = false;
709 causes_validation = true;
711 layout_suspended = 0;
715 right_to_left = RightToLeft.Inherit;
716 border_style = BorderStyle.None;
717 background_color = Color.Empty;
724 use_compatible_text_rendering = Application.use_compatible_text_rendering;
725 padding = new Padding(0);
726 maximum_size = new Size();
727 minimum_size = new Size();
728 preferred_size = new Size();
729 margin = this.DefaultMargin;
730 layout_engine = this.LayoutEngine;
733 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
734 ControlStyles.Selectable | ControlStyles.StandardClick |
735 ControlStyles.StandardDoubleClick;
737 control_style |= ControlStyles.UseTextForAccessibility;
741 background_image = null;
745 window = new ControlNativeWindow(this);
746 child_controls = CreateControlsInstance();
747 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
748 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
749 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
750 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
756 public Control(Control parent, string text) : this() {
761 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
766 bounds.Height=height;
767 SetBounds(left, top, width, height, BoundsSpecified.All);
771 public Control(string text) : this() {
775 public Control(string text, int left, int top, int width, int height) : this() {
779 bounds.Height=height;
780 SetBounds(left, top, width, height, BoundsSpecified.All);
784 private delegate void RemoveDelegate(object c);
786 protected override void Dispose(bool disposing) {
787 if (!is_disposed && disposing) {
800 if (invalid_region!=null) {
801 invalid_region.Dispose();
804 if (this.InvokeRequired) {
805 if (Application.MessageLoop) {
806 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
807 this.BeginInvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
811 lock (Control.controls) {
812 Control.controls.Remove(this);
817 if (parent != null) {
818 parent.Controls.Remove(this);
821 Control [] children = child_controls.GetAllControls ();
822 for (int i=0; i<children.Length; i++) {
823 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
824 children[i].Dispose();
829 base.Dispose(disposing);
831 #endregion // Public Constructors
833 #region Internal Properties
834 internal BorderStyle InternalBorderStyle {
840 if (!Enum.IsDefined (typeof (BorderStyle), value))
841 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
843 if (border_style != value) {
844 border_style = value;
846 if (IsHandleCreated) {
847 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
853 #endregion // Internal Properties
855 #region Private & Internal Methods
856 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
857 AsyncMethodResult result;
858 AsyncMethodData data;
865 if (!p.IsHandleCreated) {
866 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
872 result = new AsyncMethodResult ();
873 data = new AsyncMethodData ();
875 data.Handle = window.Handle;
876 data.Method = method;
878 data.Result = result;
881 if (!ExecutionContext.IsFlowSuppressed ()) {
882 data.Context = ExecutionContext.Capture ();
885 #if !MWF_ON_MSRUNTIME
886 if (SecurityManager.SecurityEnabled) {
887 data.Stack = CompressedStack.GetCompressedStack ();
892 XplatUI.SendAsyncMethod (data);
897 internal void PointToClient (ref int x, ref int y)
899 XplatUI.ScreenToClient (Handle, ref x, ref y);
902 internal void PointToScreen (ref int x, ref int y)
904 XplatUI.ClientToScreen (Handle, ref x, ref y);
907 internal bool IsRecreating {
909 return is_recreating;
913 internal Graphics DeviceContext {
915 if (dc_mem == null) {
916 CreateBuffers(this.Width, this.Height);
922 private void ImageBufferNeedsRedraw () {
923 if (invalid_region != null)
924 invalid_region.Dispose();
925 invalid_region = new Region (ClientRectangle);
928 private Bitmap ImageBuffer {
931 CreateBuffers(this.Width, this.Height);
937 internal void CreateBuffers (int width, int height) {
946 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
947 dc_mem = Graphics.FromImage (bmp_mem);
948 ImageBufferNeedsRedraw ();
951 internal void InvalidateBuffers ()
953 if (dc_mem != null) {
959 ImageBufferNeedsRedraw ();
962 internal static void SetChildColor(Control parent) {
965 for (int i=0; i < parent.child_controls.Count; i++) {
966 child=parent.child_controls[i];
967 if (child.child_controls.Count>0) {
968 SetChildColor(child);
974 internal bool Select(Control control) {
975 IContainerControl container;
977 if (control == null) {
981 container = GetContainerControl();
982 if (container != null) {
983 container.ActiveControl = control;
985 if (control.IsHandleCreated) {
986 XplatUI.SetFocus(control.window.Handle);
991 internal void SelectChild (Control control)
993 if (control.IsHandleCreated)
994 XplatUI.SetFocus (control.window.Handle);
997 internal virtual void DoDefaultAction() {
998 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1001 internal static int LowOrder (int param) {
1002 return ((int)(short)(param & 0xffff));
1005 internal static int HighOrder (int param) {
1006 return ((int)(short)(param >> 16));
1009 // This method exists so controls overriding OnPaintBackground can have default background painting done
1010 internal virtual void PaintControlBackground (PaintEventArgs pevent)
1012 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1013 if (parent != null) {
1014 PaintEventArgs parent_pe;
1015 GraphicsState state;
1017 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1019 state = parent_pe.Graphics.Save();
1020 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1021 parent.OnPaintBackground(parent_pe);
1022 parent_pe.Graphics.Restore(state);
1024 state = parent_pe.Graphics.Save();
1025 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1026 parent.OnPaint(parent_pe);
1027 parent_pe.Graphics.Restore(state);
1028 parent_pe.SetGraphics(null);
1032 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1033 if (parent != null) {
1034 PaintEventArgs parent_pe;
1036 GraphicsState state;
1039 hwnd = Hwnd.ObjectFromHandle(Handle);
1042 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1044 region = new Region ();
1046 region.Union(ClientRectangle);
1048 foreach (Rectangle r in hwnd.ClipRectangles) {
1052 state = parent_pe.Graphics.Save();
1053 parent_pe.Graphics.Clip = region;
1055 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1056 parent.OnPaintBackground(parent_pe);
1057 parent_pe.Graphics.Restore(state);
1059 state = parent_pe.Graphics.Save();
1060 parent_pe.Graphics.Clip = region;
1062 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1063 parent.OnPaint(parent_pe);
1064 parent_pe.Graphics.Restore(state);
1065 parent_pe.SetGraphics(null);
1067 region.Intersect(clip_region);
1068 pevent.Graphics.Clip = region;
1073 if (background_image == null) {
1074 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));
1078 DrawBackgroundImage (pevent.Graphics);
1081 void DrawBackgroundImage (Graphics g)
1083 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1084 g.FillRectangle (b, ClientRectangle);
1088 internal virtual void DndEnter (DragEventArgs e)
1095 internal virtual void DndOver (DragEventArgs e)
1102 internal virtual void DndDrop (DragEventArgs e)
1106 } catch (Exception exc) {
1107 Console.Error.WriteLine ("MWF: Exception while dropping:");
1108 Console.Error.WriteLine (exc);
1112 internal virtual void DndLeave (EventArgs e)
1119 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1126 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1129 OnQueryContinueDrag(e);
1133 internal static MouseButtons FromParamToMouseButtons (int param) {
1134 MouseButtons buttons = MouseButtons.None;
1136 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1137 buttons |= MouseButtons.Left;
1139 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1140 buttons |= MouseButtons.Middle;
1142 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1143 buttons |= MouseButtons.Right;
1149 internal void FireEnter ()
1151 OnEnter (EventArgs.Empty);
1154 internal void FireLeave ()
1156 OnLeave (EventArgs.Empty);
1159 internal void FireValidating (CancelEventArgs ce)
1164 internal void FireValidated ()
1166 OnValidated (EventArgs.Empty);
1169 internal virtual bool ProcessControlMnemonic(char charCode) {
1170 return ProcessMnemonic(charCode);
1173 private static Control FindFlatForward(Control container, Control start) {
1179 end = container.child_controls.Count;
1181 if (start != null) {
1182 index = start.tab_index;
1188 for (int i = 0, pos = -1; i < end; i++) {
1189 if (start == container.child_controls[i]) {
1194 if (found == null) {
1195 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1196 found = container.child_controls[i];
1198 } else if (found.tab_index > container.child_controls[i].tab_index) {
1199 if (container.child_controls[i].tab_index > index) {
1200 found = container.child_controls[i];
1207 private static Control FindControlForward(Control container, Control start) {
1212 if (start == null) {
1213 return FindFlatForward(container, start);
1216 if (start.child_controls != null && start.child_controls.Count > 0 &&
1217 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1218 return FindControlForward(start, null);
1221 while (start != container) {
1222 found = FindFlatForward(start.parent, start);
1223 if (found != null) {
1226 start = start.parent;
1232 private static Control FindFlatBackward(Control container, Control start) {
1238 end = container.child_controls.Count;
1240 if (start != null) {
1241 index = start.tab_index;
1243 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1245 for (int i = 0; i < end; i++) {
1246 if (container.child_controls[i].tab_index > index) {
1247 index = container.child_controls[i].tab_index;
1255 for (int i = end - 1; i >= 0; i--) {
1256 if (start == container.child_controls[i]) {
1261 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1262 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1263 found = container.child_controls[i];
1270 private static Control FindControlBackward(Control container, Control start) {
1272 Control found = null;
1274 if (start == null) {
1275 found = FindFlatBackward(container, start);
1277 else if (start != container) {
1278 if (start.parent != null) {
1279 found = FindFlatBackward(start.parent, start);
1281 if (found == null) {
1282 if (start.parent != container)
1283 return start.parent;
1289 if (found == null || start.parent == null)
1292 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1293 found.child_controls != null && found.child_controls.Count > 0)) {
1294 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1295 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1296 found = FindFlatBackward(found, null);
1306 if (start != null) {
1307 found = FindFlatBackward(start.parent, start);
1308 if (found == null) {
1309 if (start.parent != container) {
1310 return start.parent;
1314 if (found == null) {
1315 found = FindFlatBackward(container, start);
1318 if (container != start) {
1319 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1320 found = FindControlBackward(found, null);
1321 if (found != null) {
1330 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1331 if (GetStyle(ControlStyles.StandardClick)) {
1332 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1334 OnDoubleClick(EventArgs.Empty);
1336 OnClick(EventArgs.Empty);
1346 private void CheckDataBindings ()
1348 if (data_bindings == null)
1351 BindingContext binding_context = BindingContext;
1352 foreach (Binding binding in data_bindings) {
1353 binding.Check (binding_context);
1358 private void ChangeParent(Control new_parent) {
1362 Color pre_fore_color;
1363 Color pre_back_color;
1364 RightToLeft pre_rtl;
1366 // These properties are inherited from our parent
1367 // Get them pre parent-change and then send events
1368 // if they are changed after we have our new parent
1369 pre_enabled = Enabled;
1370 pre_visible = Visible;
1372 pre_fore_color = ForeColor;
1373 pre_back_color = BackColor;
1374 pre_rtl = RightToLeft;
1375 // MS doesn't seem to send a CursorChangedEvent
1377 parent = new_parent;
1379 if (IsHandleCreated)
1380 XplatUI.SetParent(Handle,
1381 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1383 OnParentChanged(EventArgs.Empty);
1385 if (pre_enabled != Enabled) {
1386 OnEnabledChanged(EventArgs.Empty);
1389 if (pre_visible != Visible) {
1390 OnVisibleChanged(EventArgs.Empty);
1393 if (pre_font != Font) {
1394 OnFontChanged(EventArgs.Empty);
1397 if (pre_fore_color != ForeColor) {
1398 OnForeColorChanged(EventArgs.Empty);
1401 if (pre_back_color != BackColor) {
1402 OnBackColorChanged(EventArgs.Empty);
1405 if (pre_rtl != RightToLeft) {
1406 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1407 // because when RTL changes they have to recreate the win32 control
1408 // We don't really need that (until someone runs into compatibility issues)
1409 OnRightToLeftChanged(EventArgs.Empty);
1412 if ((new_parent != null) && new_parent.Created && !Created) {
1416 if ((binding_context == null) && Created) {
1417 OnBindingContextChanged(EventArgs.Empty);
1421 private void UpdateDistances() {
1422 if ((parent != null) && (parent.layout_suspended == 0)) {
1423 dist_left = bounds.X;
1424 dist_top = bounds.Y;
1425 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1426 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1429 #endregion // Private & Internal Methods
1431 #region Public Static Properties
1432 public static Color DefaultBackColor {
1434 return ThemeEngine.Current.DefaultControlBackColor;
1438 public static Font DefaultFont {
1440 return ThemeEngine.Current.DefaultFont;
1444 public static Color DefaultForeColor {
1446 return ThemeEngine.Current.DefaultControlForeColor;
1450 public static Keys ModifierKeys {
1452 return XplatUI.State.ModifierKeys;
1456 public static MouseButtons MouseButtons {
1458 return XplatUI.State.MouseButtons;
1462 public static Point MousePosition {
1464 return Cursor.Position;
1470 public static bool CheckForIllegalCrossThreadCalls
1473 return verify_thread_handle;
1477 verify_thread_handle = value;
1481 #endregion // Public Static Properties
1483 #region Public Instance Properties
1484 [EditorBrowsable(EditorBrowsableState.Advanced)]
1486 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1487 public AccessibleObject AccessibilityObject {
1489 if (accessibility_object==null) {
1490 accessibility_object=CreateAccessibilityInstance();
1492 return accessibility_object;
1496 [EditorBrowsable(EditorBrowsableState.Advanced)]
1498 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1499 public string AccessibleDefaultActionDescription {
1501 return AccessibilityObject.default_action;
1505 AccessibilityObject.default_action=value;
1510 [DefaultValue(null)]
1511 [MWFCategory("Accessibility")]
1512 public string AccessibleDescription {
1514 return AccessibilityObject.description;
1518 AccessibilityObject.description=value;
1523 [DefaultValue(null)]
1524 [MWFCategory("Accessibility")]
1525 public string AccessibleName {
1527 return AccessibilityObject.Name;
1531 AccessibilityObject.Name=value;
1535 [DefaultValue(AccessibleRole.Default)]
1536 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1537 public AccessibleRole AccessibleRole {
1539 return AccessibilityObject.role;
1543 AccessibilityObject.role=value;
1547 [DefaultValue(false)]
1548 [MWFCategory("Behavior")]
1549 public virtual bool AllowDrop {
1555 if (allow_drop == value)
1558 if (IsHandleCreated) {
1560 XplatUI.SetAllowDrop (Handle, value);
1566 [RefreshProperties(RefreshProperties.Repaint)]
1567 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1568 [MWFCategory("Layout")]
1569 public virtual AnchorStyles Anchor {
1571 return anchor_style;
1577 if (parent != null) {
1578 parent.PerformLayout(this, "Parent");
1584 // XXX: Implement me!
1587 public virtual bool AutoSize {
1589 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1593 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1598 public virtual Size MaximumSize {
1600 return maximum_size;
1603 maximum_size = value;
1607 public virtual Size MinimumSize {
1609 return minimum_size;
1612 minimum_size = value;
1618 [MWFCategory("Appearance")]
1619 public virtual Color BackColor {
1621 if (background_color.IsEmpty) {
1623 Color pcolor = parent.BackColor;
1624 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1627 return DefaultBackColor;
1629 return background_color;
1633 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1634 throw new ArgumentException("Transparent background colors are not supported on this control");
1637 if (background_color != value) {
1638 background_color=value;
1639 SetChildColor(this);
1640 OnBackColorChanged(EventArgs.Empty);
1647 [DefaultValue(null)]
1648 [MWFCategory("Appearance")]
1649 public virtual Image BackgroundImage {
1651 return background_image;
1655 if (background_image!=value) {
1656 background_image=value;
1657 OnBackgroundImageChanged(EventArgs.Empty);
1662 [EditorBrowsable(EditorBrowsableState.Advanced)]
1664 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1665 public virtual BindingContext BindingContext {
1667 if (binding_context != null)
1668 return binding_context;
1671 binding_context = Parent.BindingContext;
1672 return binding_context;
1675 if (binding_context != value) {
1676 binding_context = value;
1677 OnBindingContextChanged(EventArgs.Empty);
1682 [EditorBrowsable(EditorBrowsableState.Advanced)]
1684 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1687 return bounds.Y+bounds.Height;
1691 [EditorBrowsable(EditorBrowsableState.Advanced)]
1693 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1694 public Rectangle Bounds {
1700 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1704 [EditorBrowsable(EditorBrowsableState.Advanced)]
1706 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1707 public bool CanFocus {
1709 if (IsHandleCreated && Visible && Enabled) {
1716 [EditorBrowsable(EditorBrowsableState.Advanced)]
1718 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1719 public bool CanSelect {
1723 if (!GetStyle(ControlStyles.Selectable)) {
1728 while (parent != null) {
1729 if (!parent.is_visible || !parent.is_enabled) {
1733 parent = parent.parent;
1739 internal virtual bool InternalCapture {
1749 [EditorBrowsable(EditorBrowsableState.Advanced)]
1751 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1752 public bool Capture {
1754 return this.is_captured;
1758 if (this.IsHandleCreated && value != is_captured) {
1761 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1763 XplatUI.UngrabWindow(this.window.Handle);
1764 is_captured = false;
1770 [DefaultValue(true)]
1771 [MWFCategory("Focus")]
1772 public bool CausesValidation {
1774 return this.causes_validation;
1778 if (this.causes_validation != value) {
1779 causes_validation = value;
1780 OnCausesValidationChanged(EventArgs.Empty);
1785 [EditorBrowsable(EditorBrowsableState.Advanced)]
1787 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1788 public Rectangle ClientRectangle {
1790 client_rect.Width = client_size.Width;
1791 client_rect.Height = client_size.Height;
1796 [EditorBrowsable(EditorBrowsableState.Advanced)]
1798 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1799 public Size ClientSize {
1802 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1803 return ((Form)this).form_parent_window.ClientSize;
1811 this.SetClientSizeCore(value.Width, value.Height);
1815 [EditorBrowsable(EditorBrowsableState.Advanced)]
1817 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1818 [DescriptionAttribute("ControlCompanyNameDescr")]
1819 public String CompanyName {
1821 return "Mono Project, Novell, Inc.";
1825 [EditorBrowsable(EditorBrowsableState.Advanced)]
1827 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1828 public bool ContainsFocus {
1830 IntPtr focused_window;
1832 focused_window = XplatUI.GetFocus();
1833 if (IsHandleCreated) {
1834 if (focused_window == Handle) {
1838 for (int i=0; i < child_controls.Count; i++) {
1839 if (child_controls[i].ContainsFocus) {
1848 [DefaultValue(null)]
1849 [MWFCategory("Behavior")]
1850 public virtual ContextMenu ContextMenu {
1852 return context_menu;
1856 if (context_menu != value) {
1857 context_menu = value;
1858 OnContextMenuChanged(EventArgs.Empty);
1864 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1865 public ControlCollection Controls {
1867 return this.child_controls;
1871 [EditorBrowsable(EditorBrowsableState.Advanced)]
1873 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1874 public bool Created {
1876 return (!is_disposed && is_created);
1880 [AmbientValue(null)]
1881 [MWFCategory("Appearance")]
1882 public virtual Cursor Cursor {
1884 if (cursor != null) {
1888 if (parent != null) {
1889 return parent.Cursor;
1892 return Cursors.Default;
1896 if (cursor != value) {
1901 if (IsHandleCreated) {
1902 pt = Cursor.Position;
1904 if (bounds.Contains(pt) || Capture) {
1905 if (GetChildAtPoint(pt) == null) {
1906 if (cursor != null) {
1907 XplatUI.SetCursor(window.Handle, cursor.handle);
1909 if (parent != null) {
1910 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1912 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1919 OnCursorChanged(EventArgs.Empty);
1925 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1926 [ParenthesizePropertyName(true)]
1927 [RefreshProperties(RefreshProperties.All)]
1928 [MWFCategory("Data")]
1929 public ControlBindingsCollection DataBindings {
1931 if (data_bindings == null)
1932 data_bindings = new ControlBindingsCollection (this);
1933 return data_bindings;
1937 [EditorBrowsable(EditorBrowsableState.Advanced)]
1939 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1940 public virtual Rectangle DisplayRectangle {
1942 return ClientRectangle;
1946 [EditorBrowsable(EditorBrowsableState.Advanced)]
1948 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1949 public bool Disposing {
1956 [RefreshProperties(RefreshProperties.Repaint)]
1957 [DefaultValue(DockStyle.None)]
1958 [MWFCategory("Layout")]
1959 public virtual DockStyle Dock {
1965 if (dock_style == value) {
1971 if (dock_style == DockStyle.None) {
1972 if (explicit_bounds == Rectangle.Empty)
1973 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1975 Bounds = explicit_bounds;
1978 if (parent != null) {
1979 parent.PerformLayout(this, "Parent");
1982 OnDockChanged(EventArgs.Empty);
1988 [MWFCategory("Behavior")]
1989 public bool Enabled {
1995 if (parent != null) {
1996 return parent.Enabled;
2004 bool old_value = is_enabled;
2007 if (old_value != value && !value && this.has_focus)
2008 SelectNextControl(this, true, true, true, true);
2010 OnEnabledChanged (EventArgs.Empty);
2014 [EditorBrowsable(EditorBrowsableState.Advanced)]
2016 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2017 public virtual bool Focused {
2019 return this.has_focus;
2024 [AmbientValue(null)]
2026 [MWFCategory("Appearance")]
2027 public virtual Font Font {
2033 if (Parent != null && Parent.Font != null) {
2040 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2042 if (font != null && font.Equals (value)) {
2048 OnFontChanged (EventArgs.Empty);
2053 [MWFCategory("Appearance")]
2054 public virtual Color ForeColor {
2056 if (foreground_color.IsEmpty) {
2058 return parent.ForeColor;
2060 return DefaultForeColor;
2062 return foreground_color;
2066 if (foreground_color != value) {
2067 foreground_color=value;
2069 OnForeColorChanged(EventArgs.Empty);
2076 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2077 public IntPtr Handle { // IWin32Window
2080 if (verify_thread_handle) {
2081 if (this.InvokeRequired) {
2082 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2086 if (!IsHandleCreated) {
2089 return window.Handle;
2093 [EditorBrowsable(EditorBrowsableState.Advanced)]
2095 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2096 public bool HasChildren {
2098 if (this.child_controls.Count>0) {
2105 [EditorBrowsable(EditorBrowsableState.Always)]
2107 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2110 return this.bounds.Height;
2114 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2118 [AmbientValue(ImeMode.Inherit)]
2120 [MWFCategory("Behavior")]
2121 public ImeMode ImeMode {
2123 if (ime_mode == DefaultImeMode) {
2125 return parent.ImeMode;
2127 return ImeMode.NoControl; // default value
2133 if (ime_mode != value) {
2136 OnImeModeChanged(EventArgs.Empty);
2141 [EditorBrowsable(EditorBrowsableState.Advanced)]
2143 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2144 public bool InvokeRequired { // ISynchronizeInvoke
2146 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2153 [EditorBrowsable(EditorBrowsableState.Advanced)]
2155 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2156 public bool IsAccessible {
2158 return is_accessible;
2162 is_accessible = value;
2166 [EditorBrowsable(EditorBrowsableState.Advanced)]
2168 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2169 public bool IsDisposed {
2171 return this.is_disposed;
2175 [EditorBrowsable(EditorBrowsableState.Advanced)]
2177 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2178 public bool IsHandleCreated {
2180 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2181 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2182 if (hwnd != null && !hwnd.zombie)
2191 public virtual Layout.LayoutEngine LayoutEngine {
2192 get { return new Layout.DefaultLayout (); }
2196 [EditorBrowsable(EditorBrowsableState.Always)]
2198 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2201 return this.bounds.X;
2205 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2210 [MWFCategory("Layout")]
2211 public Point Location {
2213 return new Point(bounds.X, bounds.Y);
2217 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2222 [Localizable (true)]
2223 public Padding Margin {
2224 get { return this.margin; }
2225 set { this.margin = value; }
2230 public string Name {
2242 public Padding Padding {
2254 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2255 public Control Parent {
2261 if (value == this) {
2262 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2265 if (parent!=value) {
2267 parent.Controls.Remove(this);
2272 value.Controls.Add(this);
2277 [EditorBrowsable(EditorBrowsableState.Advanced)]
2279 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2280 public string ProductName {
2282 Type t = typeof (AssemblyProductAttribute);
2283 Assembly assembly = GetType().Module.Assembly;
2284 object [] attrs = assembly.GetCustomAttributes (t, false);
2285 AssemblyProductAttribute a = null;
2286 // On MS we get a NullRefException if product attribute is not
2288 if (attrs != null && attrs.Length > 0)
2289 a = (AssemblyProductAttribute) attrs [0];
2294 [EditorBrowsable(EditorBrowsableState.Advanced)]
2296 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2297 public string ProductVersion {
2299 Type t = typeof (AssemblyVersionAttribute);
2300 Assembly assembly = GetType().Module.Assembly;
2301 object [] attrs = assembly.GetCustomAttributes (t, false);
2302 if (attrs == null || attrs.Length < 1)
2304 return ((AssemblyVersionAttribute)attrs [0]).Version;
2308 [EditorBrowsable(EditorBrowsableState.Advanced)]
2310 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2311 public bool RecreatingHandle {
2313 return is_recreating;
2317 [EditorBrowsable(EditorBrowsableState.Advanced)]
2319 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2320 public Region Region {
2326 if (IsHandleCreated) {
2327 XplatUI.SetClipRegion(Handle, value);
2329 clip_region = value;
2333 [EditorBrowsable(EditorBrowsableState.Advanced)]
2335 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2338 return this.bounds.X+this.bounds.Width;
2342 [AmbientValue(RightToLeft.Inherit)]
2344 [MWFCategory("Appearance")]
2345 public virtual RightToLeft RightToLeft {
2347 if (right_to_left == RightToLeft.Inherit) {
2349 return parent.RightToLeft;
2351 return RightToLeft.No; // default value
2353 return right_to_left;
2357 if (value != right_to_left) {
2358 right_to_left = value;
2359 OnRightToLeftChanged(EventArgs.Empty);
2364 [EditorBrowsable(EditorBrowsableState.Advanced)]
2365 public override ISite Site {
2373 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2375 BackColor = ap.BackColor;
2376 ForeColor = ap.ForeColor;
2384 [MWFCategory("Layout")]
2387 return new Size(Width, Height);
2391 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2396 [MergableProperty(false)]
2397 [MWFCategory("Behavior")]
2398 public int TabIndex {
2400 if (tab_index != -1) {
2407 if (tab_index != value) {
2409 OnTabIndexChanged(EventArgs.Empty);
2415 [DefaultValue(true)]
2416 [MWFCategory("Behavior")]
2417 public bool TabStop {
2423 if (tab_stop != value) {
2425 OnTabStopChanged(EventArgs.Empty);
2430 [Localizable(false)]
2432 [TypeConverter(typeof(StringConverter))]
2433 [DefaultValue(null)]
2434 [MWFCategory("Data")]
2441 control_tag = value;
2447 [BindableAttribute(true)]
2448 [MWFCategory("Appearance")]
2449 public virtual string Text {
2451 // Our implementation ignores ControlStyles.CacheText - we always cache
2456 if (value == null) {
2457 value = String.Empty;
2462 if (IsHandleCreated) {
2463 /* we need to call .SetWindowStyle here instead of just .Text
2464 because the presence/absence of Text (== "" or not) can cause
2465 other window style things to appear/disappear */
2466 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2467 XplatUI.Text(Handle, text);
2469 OnTextChanged (EventArgs.Empty);
2474 [EditorBrowsable(EditorBrowsableState.Always)]
2476 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2479 return this.bounds.Y;
2483 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2487 [EditorBrowsable(EditorBrowsableState.Advanced)]
2489 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2490 public Control TopLevelControl {
2494 while (p.parent != null) {
2498 return p is Form ? p : null;
2503 [MWFCategory("Behavior")]
2504 public bool Visible {
2508 } else if (parent != null) {
2509 return parent.Visible;
2516 SetVisibleCore(value);
2520 [EditorBrowsable(EditorBrowsableState.Always)]
2522 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2525 return this.bounds.Width;
2529 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2533 [EditorBrowsable(EditorBrowsableState.Never)]
2535 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2536 public IWindowTarget WindowTarget {
2545 #endregion // Public Instance Properties
2547 #region Protected Instance Properties
2548 protected virtual CreateParams CreateParams {
2550 CreateParams create_params = new CreateParams();
2553 create_params.Caption = Text;
2556 create_params.Caption = text;
2560 create_params.X = Left;
2563 create_params.X = this.bounds.X;
2567 create_params.Y = Top;
2570 create_params.Y = this.bounds.Y;
2574 create_params.Width = Width;
2577 create_params.Width = this.bounds.Width;
2581 create_params.Height = Height;
2584 create_params.Height = this.bounds.Height;
2588 create_params.ClassName = XplatUI.DefaultClassName;
2589 create_params.ClassStyle = 0;
2590 create_params.ExStyle = 0;
2591 create_params.Param = 0;
2594 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2597 if ((parent!=null) && (parent.IsHandleCreated)) {
2598 create_params.Parent = parent.Handle;
2601 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2604 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2608 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2611 switch (border_style) {
2612 case BorderStyle.FixedSingle:
2613 create_params.Style |= (int) WindowStyles.WS_BORDER;
2615 case BorderStyle.Fixed3D:
2616 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2620 return create_params;
2624 protected virtual ImeMode DefaultImeMode {
2626 return ImeMode.Inherit;
2631 protected virtual Padding DefaultMargin {
2632 get { return new Padding (3); }
2636 protected virtual Size DefaultSize {
2638 return new Size(0, 0);
2642 protected int FontHeight {
2652 protected bool RenderRightToLeft {
2654 return (this.right_to_left == RightToLeft.Yes);
2658 protected bool ResizeRedraw {
2660 return GetStyle(ControlStyles.ResizeRedraw);
2664 SetStyle(ControlStyles.ResizeRedraw, value);
2668 [EditorBrowsable(EditorBrowsableState.Advanced)]
2670 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2671 protected virtual bool ShowFocusCues {
2677 [EditorBrowsable(EditorBrowsableState.Advanced)]
2679 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2680 protected bool ShowKeyboardCues {
2685 #endregion // Protected Instance Properties
2687 #region Public Static Methods
2688 [EditorBrowsable(EditorBrowsableState.Advanced)]
2689 public static Control FromChildHandle(IntPtr handle) {
2690 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2693 [EditorBrowsable(EditorBrowsableState.Advanced)]
2694 public static Control FromHandle(IntPtr handle) {
2695 return Control.ControlNativeWindow.ControlFromHandle(handle);
2698 public static bool IsMnemonic(char charCode, string text) {
2701 amp = text.IndexOf('&');
2704 if (amp + 1 < text.Length) {
2705 if (text[amp + 1] != '&') {
2706 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2716 #region Protected Static Methods
2717 [EditorBrowsable(EditorBrowsableState.Advanced)]
2718 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2721 c = Control.FromHandle(hWnd);
2731 #region Public Instance Methods
2732 [EditorBrowsable(EditorBrowsableState.Advanced)]
2733 public IAsyncResult BeginInvoke(Delegate method) {
2734 object [] prms = null;
2735 if (method is EventHandler)
2736 prms = new object [] { this, EventArgs.Empty };
2737 return BeginInvokeInternal(method, prms, false);
2740 [EditorBrowsable(EditorBrowsableState.Advanced)]
2741 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2742 return BeginInvokeInternal (method, args, false);
2745 public void BringToFront() {
2746 if (parent != null) {
2747 parent.child_controls.SetChildIndex(this, 0);
2750 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2754 public bool Contains(Control ctl) {
2755 while (ctl != null) {
2764 public void CreateControl() {
2766 throw new ObjectDisposedException(GetType().FullName.ToString());
2772 if (!IsHandleCreated) {
2780 Control [] controls = child_controls.GetAllControls ();
2781 for (int i=0; i<controls.Length; i++) {
2782 controls [i].CreateControl ();
2785 UpdateChildrenZOrder();
2787 if (binding_context == null) { // seem to be sent whenever it's null?
2788 OnBindingContextChanged(EventArgs.Empty);
2794 public Graphics CreateGraphics() {
2795 if (!IsHandleCreated) {
2796 this.CreateHandle();
2798 return Graphics.FromHwnd(this.window.Handle);
2801 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2802 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2805 [EditorBrowsable(EditorBrowsableState.Advanced)]
2806 public object EndInvoke (IAsyncResult async_result) {
2807 AsyncMethodResult result = (AsyncMethodResult) async_result;
2808 return result.EndInvoke ();
2811 public Form FindForm() {
2824 public bool Focus() {
2825 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2828 is_focusing = false;
2833 public Control GetChildAtPoint(Point pt) {
2834 // Microsoft's version of this function doesn't seem to work, so I can't check
2835 // if we only consider children or also grandchildren, etc.
2836 // I'm gonna say 'children only'
2837 for (int i=0; i<child_controls.Count; i++) {
2838 if (child_controls[i].Bounds.Contains(pt)) {
2839 return child_controls[i];
2845 public IContainerControl GetContainerControl() {
2846 Control current = this;
2848 while (current!=null) {
2849 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2850 return (IContainerControl)current;
2852 current = current.parent;
2857 public Control GetNextControl(Control ctl, bool forward) {
2859 if (!this.Contains(ctl)) {
2864 ctl = FindControlForward(this, ctl);
2867 ctl = FindControlBackward(this, ctl);
2877 public virtual Size GetPreferredSize (Size proposedSize) {
2878 return preferred_size;
2882 public void Hide() {
2883 this.Visible = false;
2886 public void Invalidate() {
2887 Invalidate(ClientRectangle, false);
2890 public void Invalidate(bool invalidateChildren) {
2891 Invalidate(ClientRectangle, invalidateChildren);
2894 public void Invalidate(System.Drawing.Rectangle rc) {
2895 Invalidate(rc, false);
2898 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2899 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2903 NotifyInvalidate(rc);
2905 XplatUI.Invalidate(Handle, rc, false);
2907 if (invalidateChildren) {
2908 Control [] controls = child_controls.GetAllControls ();
2909 for (int i=0; i<controls.Length; i++)
2910 controls [i].Invalidate ();
2912 OnInvalidated(new InvalidateEventArgs(rc));
2915 public void Invalidate(System.Drawing.Region region) {
2916 Invalidate(region, false);
2919 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2920 RectangleF bounds = region.GetBounds (CreateGraphics ());
2921 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2922 invalidateChildren);
2925 public object Invoke (Delegate method) {
2926 object [] prms = null;
2927 if (method is EventHandler)
2928 prms = new object [] { this, EventArgs.Empty };
2930 return Invoke(method, prms);
2933 public object Invoke (Delegate method, object[] args) {
2934 if (!this.InvokeRequired) {
2935 return method.DynamicInvoke(args);
2938 IAsyncResult result = BeginInvoke (method, args);
2939 return EndInvoke(result);
2942 internal object InvokeInternal (Delegate method, bool disposing) {
2943 return InvokeInternal(method, null, disposing);
2946 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2947 if (!this.InvokeRequired) {
2948 return method.DynamicInvoke(args);
2951 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2952 return EndInvoke(result);
2955 [EditorBrowsable(EditorBrowsableState.Advanced)]
2956 public void PerformLayout() {
2957 PerformLayout(null, null);
2961 private void SetImplicitBounds (int x, int y, int width, int height)
2963 Rectangle saved_bounds = explicit_bounds;
2964 SetBounds (x, y, width, height);
2965 explicit_bounds = saved_bounds;
2969 [EditorBrowsable(EditorBrowsableState.Advanced)]
2970 public void PerformLayout(Control affectedControl, string affectedProperty) {
2971 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2973 if (layout_suspended > 0) {
2974 layout_pending = true;
2978 layout_pending = false;
2980 // Prevent us from getting messed up
2983 // Perform all Dock and Anchor calculations
2987 this.layout_engine.Layout(this, levent);
2989 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2991 AnchorStyles anchor;
2994 space = DisplayRectangle;
2996 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2997 Control [] controls = child_controls.GetAllControls ();
2998 for (int i = controls.Length - 1; i >= 0; i--) {
2999 child = controls [i];
3001 if (!child.Visible) {
3005 switch (child.Dock) {
3006 case DockStyle.None: {
3011 case DockStyle.Left: {
3012 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3013 space.X+=child.Width;
3014 space.Width-=child.Width;
3018 case DockStyle.Top: {
3019 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3020 space.Y+=child.Height;
3021 space.Height-=child.Height;
3025 case DockStyle.Right: {
3026 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3027 space.Width-=child.Width;
3031 case DockStyle.Bottom: {
3032 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3033 space.Height-=child.Height;
3039 for (int i = controls.Length - 1; i >= 0; i--) {
3042 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3043 if (child.Dock == DockStyle.Fill) {
3044 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3048 space = DisplayRectangle;
3050 for (int i=0; i < controls.Length; i++) {
3056 child = controls[i];
3058 // If the control is docked we don't need to do anything
3059 if (child.Dock != DockStyle.None) {
3063 anchor = child.Anchor;
3067 width = child.Width;
3068 height = child.Height;
3070 if ((anchor & AnchorStyles.Left) !=0 ) {
3071 if ((anchor & AnchorStyles.Right) != 0) {
3072 width = space.Width - child.dist_right - left;
3074 ; // Left anchored only, nothing to be done
3076 } else if ((anchor & AnchorStyles.Right) != 0) {
3077 left = space.Width - child.dist_right - width;
3079 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3080 // This calculates from scratch every time:
3081 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3084 if ((anchor & AnchorStyles.Top) !=0 ) {
3085 if ((anchor & AnchorStyles.Bottom) != 0) {
3086 height = space.Height - child.dist_bottom - top;
3088 ; // Top anchored only, nothing to be done
3090 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3091 top = space.Height - child.dist_bottom - height;
3093 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3094 // This calculates from scratch every time:
3095 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3107 child.SetImplicitBounds(left, top, width, height);
3111 // Let everyone know
3115 // Need to make sure we decremend layout_suspended
3121 public Point PointToClient (Point p) {
3125 XplatUI.ScreenToClient (Handle, ref x, ref y);
3127 return new Point (x, y);
3130 public Point PointToScreen(Point p) {
3134 XplatUI.ClientToScreen(Handle, ref x, ref y);
3136 return new Point(x, y);
3139 public virtual bool PreProcessMessage(ref Message msg) {
3140 return InternalPreProcessMessage (ref msg);
3143 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3146 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3147 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3149 if (!ProcessCmdKey(ref msg, key_data)) {
3150 if (IsInputKey(key_data)) {
3154 return ProcessDialogKey(key_data);
3158 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3159 if (IsInputChar((char)msg.WParam)) {
3162 return ProcessDialogChar((char)msg.WParam);
3163 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3164 return ProcessDialogChar((char)msg.WParam);
3169 public Rectangle RectangleToClient(Rectangle r) {
3170 return new Rectangle(PointToClient(r.Location), r.Size);
3173 public Rectangle RectangleToScreen(Rectangle r) {
3174 return new Rectangle(PointToScreen(r.Location), r.Size);
3177 public virtual void Refresh() {
3178 if (IsHandleCreated == true) {
3180 XplatUI.UpdateWindow(window.Handle);
3182 Control [] controls = child_controls.GetAllControls ();
3183 for (int i=0; i < controls.Length; i++) {
3184 controls[i].Refresh();
3190 [EditorBrowsable(EditorBrowsableState.Never)]
3191 public virtual void ResetBackColor() {
3192 BackColor = Color.Empty;
3195 [EditorBrowsable(EditorBrowsableState.Never)]
3196 public void ResetBindings() {
3197 data_bindings.Clear();
3200 [EditorBrowsable(EditorBrowsableState.Never)]
3201 public virtual void ResetCursor() {
3205 [EditorBrowsable(EditorBrowsableState.Never)]
3206 public virtual void ResetFont() {
3210 [EditorBrowsable(EditorBrowsableState.Never)]
3211 public virtual void ResetForeColor() {
3212 foreground_color = Color.Empty;
3215 [EditorBrowsable(EditorBrowsableState.Never)]
3216 public void ResetImeMode() {
3217 ime_mode = DefaultImeMode;
3220 [EditorBrowsable(EditorBrowsableState.Never)]
3221 public virtual void ResetRightToLeft() {
3222 right_to_left = RightToLeft.Inherit;
3225 public virtual void ResetText() {
3226 text = String.Empty;
3229 public void ResumeLayout() {
3230 ResumeLayout (true);
3233 public void ResumeLayout(bool performLayout) {
3234 if (layout_suspended > 0) {
3238 if (layout_suspended == 0) {
3239 Control [] controls = child_controls.GetAllControls ();
3240 for (int i=0; i<controls.Length; i++) {
3241 controls [i].UpdateDistances ();
3244 if (performLayout && layout_pending) {
3250 public void Scale(float ratio) {
3251 ScaleCore(ratio, ratio);
3254 public void Scale(float dx, float dy) {
3259 public void Scale(SizeF factor) {
3260 ScaleCore(factor.Width, factor.Height);
3264 public void Select() {
3265 Select(false, false);
3269 private void printTree(Control c, string t) {
3270 foreach(Control i in c.child_controls) {
3271 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3272 printTree(i, t+"\t");
3276 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3280 Console.WriteLine("{0}", this.FindForm());
3281 printTree(this, "\t");
3284 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3289 c = GetNextControl(c, forward);
3298 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3299 c.Select (true, true);
3302 } while (c != ctl); // If we wrap back to ourselves we stop
3307 public void SendToBack() {
3308 if (parent != null) {
3309 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3313 public void SetBounds(int x, int y, int width, int height) {
3314 SetBounds(x, y, width, height, BoundsSpecified.All);
3317 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3318 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3322 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3326 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3330 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3334 SetBoundsCore(x, y, width, height, specified);
3335 if (parent != null) {
3336 parent.PerformLayout(this, "Bounds");
3340 public void Show() {
3342 this.CreateControl();
3348 public void SuspendLayout() {
3352 public void Update() {
3353 if (IsHandleCreated) {
3354 XplatUI.UpdateWindow(window.Handle);
3357 #endregion // Public Instance Methods
3359 #region Protected Instance Methods
3360 [EditorBrowsable(EditorBrowsableState.Advanced)]
3361 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3362 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3363 throw new NotImplementedException();
3366 [EditorBrowsable(EditorBrowsableState.Advanced)]
3367 protected virtual AccessibleObject CreateAccessibilityInstance() {
3368 return new Control.ControlAccessibleObject(this);
3371 [EditorBrowsable(EditorBrowsableState.Advanced)]
3372 protected virtual ControlCollection CreateControlsInstance() {
3373 return new ControlCollection(this);
3376 [EditorBrowsable(EditorBrowsableState.Advanced)]
3377 protected virtual void CreateHandle() {
3379 throw new ObjectDisposedException(GetType().FullName.ToString());
3382 if (IsHandleCreated && !is_recreating) {
3386 window.CreateHandle(CreateParams);
3388 if (window.Handle != IntPtr.Zero) {
3389 lock (Control.controls) {
3390 if (!Control.controls.Contains(window.Handle)) {
3391 Control.controls.Add(this);
3395 creator_thread = Thread.CurrentThread;
3397 XplatUI.EnableWindow(window.Handle, is_enabled);
3398 XplatUI.SetVisible(window.Handle, is_visible, true);
3400 if (clip_region != null) {
3401 XplatUI.SetClipRegion(Handle, clip_region);
3404 // Set our handle with our parent
3405 if ((parent != null) && (parent.IsHandleCreated)) {
3406 XplatUI.SetParent(window.Handle, parent.Handle);
3409 // Set our handle as parent for our children
3410 Control [] children;
3412 children = child_controls.GetAllControls ();
3413 for (int i = 0; i < children.Length; i++ ) {
3414 if (!children[i].RecreatingHandle)
3415 XplatUI.SetParent(children[i].Handle, window.Handle);
3419 XplatUI.SetAllowDrop (Handle, allow_drop);
3421 // Find out where the window manager placed us
3422 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3423 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3427 OnHandleCreated(EventArgs.Empty);
3431 [EditorBrowsable(EditorBrowsableState.Advanced)]
3432 protected virtual void DefWndProc(ref Message m) {
3433 window.DefWndProc(ref m);
3436 [EditorBrowsable(EditorBrowsableState.Advanced)]
3437 protected virtual void DestroyHandle() {
3438 if (IsHandleCreated) {
3439 if (window != null) {
3440 window.DestroyHandle();
3445 protected bool GetStyle(ControlStyles flag) {
3446 return (control_style & flag) != 0;
3449 protected bool GetTopLevel() {
3453 [EditorBrowsable(EditorBrowsableState.Advanced)]
3454 protected virtual void InitLayout() {
3458 [EditorBrowsable(EditorBrowsableState.Advanced)]
3459 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3460 toInvoke.OnGotFocus(e);
3463 [EditorBrowsable(EditorBrowsableState.Advanced)]
3464 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3465 toInvoke.OnLostFocus(e);
3468 [EditorBrowsable(EditorBrowsableState.Advanced)]
3469 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3470 toInvoke.OnClick(e);
3473 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3474 toInvoke.OnPaint(e);
3477 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3478 toInvoke.OnPaintBackground(e);
3481 protected virtual bool IsInputChar (char charCode) {
3485 protected virtual bool IsInputKey (Keys keyData) {
3486 // Doc says this one calls IsInputChar; not sure what to do with that
3490 [EditorBrowsable(EditorBrowsableState.Advanced)]
3491 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3495 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3496 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3500 if (parent != null) {
3501 return parent.ProcessCmdKey(ref msg, keyData);
3507 protected virtual bool ProcessDialogChar(char charCode) {
3508 if (parent != null) {
3509 return parent.ProcessDialogChar (charCode);
3515 protected virtual bool ProcessDialogKey (Keys keyData) {
3516 if (parent != null) {
3517 return parent.ProcessDialogKey (keyData);
3523 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3525 KeyEventArgs key_event;
3528 case (int)Msg.WM_SYSKEYDOWN:
3529 case (int)Msg.WM_KEYDOWN: {
3530 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3531 OnKeyDown (key_event);
3532 return key_event.Handled;
3535 case (int)Msg.WM_SYSKEYUP:
3536 case (int)Msg.WM_KEYUP: {
3537 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3538 OnKeyUp (key_event);
3539 return key_event.Handled;
3542 case (int)Msg.WM_SYSCHAR:
3543 case (int)Msg.WM_CHAR: {
3544 KeyPressEventArgs key_press_event;
3546 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3547 OnKeyPress(key_press_event);
3549 msg.WParam = (IntPtr)key_press_event.KeyChar;
3551 return key_press_event.Handled;
3562 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3563 if (parent != null) {
3564 if (parent.ProcessKeyPreview(ref msg)) {
3569 return ProcessKeyEventArgs(ref msg);
3572 protected virtual bool ProcessKeyPreview(ref Message msg) {
3573 if (parent != null) {
3574 return parent.ProcessKeyPreview(ref msg);
3580 protected virtual bool ProcessMnemonic(char charCode) {
3585 [EditorBrowsable(EditorBrowsableState.Advanced)]
3586 protected void RaiseDragEvent(object key, DragEventArgs e) {
3590 [EditorBrowsable(EditorBrowsableState.Advanced)]
3591 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3595 [EditorBrowsable(EditorBrowsableState.Advanced)]
3596 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3600 [EditorBrowsable(EditorBrowsableState.Advanced)]
3601 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3605 private void SetIsRecreating ()
3609 foreach (Control c in Controls.GetAllControls()) {
3610 c.SetIsRecreating ();
3614 [EditorBrowsable(EditorBrowsableState.Advanced)]
3615 protected void RecreateHandle() {
3617 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3622 if (IsHandleCreated) {
3624 Console.WriteLine(" + handle is created, destroying it.");
3627 // WM_DESTROY will CreateHandle for us
3630 Console.WriteLine(" + handle is not created, creating it.");
3638 is_recreating = false;
3640 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3646 [EditorBrowsable(EditorBrowsableState.Advanced)]
3647 protected void ResetMouseEventArgs() {
3651 [EditorBrowsable(EditorBrowsableState.Advanced)]
3652 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3653 if (right_to_left == RightToLeft.No) {
3658 case ContentAlignment.TopLeft: {
3659 return ContentAlignment.TopRight;
3662 case ContentAlignment.TopRight: {
3663 return ContentAlignment.TopLeft;
3666 case ContentAlignment.MiddleLeft: {
3667 return ContentAlignment.MiddleRight;
3670 case ContentAlignment.MiddleRight: {
3671 return ContentAlignment.MiddleLeft;
3674 case ContentAlignment.BottomLeft: {
3675 return ContentAlignment.BottomRight;
3678 case ContentAlignment.BottomRight: {
3679 return ContentAlignment.BottomLeft;
3683 // if it's center it doesn't change
3689 [EditorBrowsable(EditorBrowsableState.Advanced)]
3690 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3691 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3695 if (align == HorizontalAlignment.Left) {
3696 return HorizontalAlignment.Right;
3699 // align must be HorizontalAlignment.Right
3700 return HorizontalAlignment.Left;
3703 [EditorBrowsable(EditorBrowsableState.Advanced)]
3704 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3705 if (right_to_left == RightToLeft.No) {
3709 if (align == LeftRightAlignment.Left) {
3710 return LeftRightAlignment.Right;
3713 // align must be LeftRightAlignment.Right;
3714 return LeftRightAlignment.Left;
3717 [EditorBrowsable(EditorBrowsableState.Advanced)]
3718 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3719 return RtlTranslateAlignment(align);
3722 [EditorBrowsable(EditorBrowsableState.Advanced)]
3723 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3724 return RtlTranslateAlignment(align);
3727 [EditorBrowsable(EditorBrowsableState.Advanced)]
3728 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3729 return RtlTranslateAlignment(align);
3732 [EditorBrowsable(EditorBrowsableState.Advanced)]
3733 protected virtual void ScaleCore(float dx, float dy) {
3739 location = new Point((int)(Left * dx), (int)(Top * dy));
3740 size = this.ClientSize;
3742 if (!GetStyle(ControlStyles.FixedWidth)) {
3743 size.Width = (int)(size.Width * dx);
3746 if (!GetStyle(ControlStyles.FixedHeight)) {
3747 size.Height = (int)(size.Height * dy);
3750 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3752 /* Now scale our children */
3753 Control [] controls = child_controls.GetAllControls ();
3754 for (int i=0; i < controls.Length; i++) {
3755 controls[i].Scale(dx, dy);
3761 protected virtual void Select(bool directed, bool forward) {
3762 IContainerControl container;
3764 container = GetContainerControl();
3765 if (container != null)
3766 container.ActiveControl = this;
3769 [EditorBrowsable(EditorBrowsableState.Advanced)]
3770 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3771 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3772 if (IsHandleCreated) {
3773 XplatUI.SetWindowPos(Handle, x, y, width, height);
3775 // Win32 automatically changes negative width/height to 0.
3776 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3777 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3779 if (width < 0 || height < 0) {
3781 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3785 UpdateBounds(x, y, width, height);
3790 [EditorBrowsable(EditorBrowsableState.Advanced)]
3791 protected virtual void SetClientSizeCore(int x, int y) {
3792 // Calculate the actual window size from the client size (it usually stays the same or grows)
3793 Rectangle ClientRect;
3794 Rectangle WindowRect;
3797 ClientRect = new Rectangle(0, 0, x, y);
3798 cp = this.CreateParams;
3800 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3804 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3807 [EditorBrowsable(EditorBrowsableState.Advanced)]
3808 protected void SetStyle(ControlStyles flag, bool value) {
3810 control_style |= flag;
3812 control_style &= ~flag;
3816 protected void SetTopLevel(bool value) {
3817 if ((GetTopLevel() != value) && (parent != null)) {
3818 throw new Exception();
3822 if (value == true) {
3832 is_toplevel = value;
3835 protected virtual void SetVisibleCore(bool value) {
3836 if (value!=is_visible) {
3837 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3843 if (IsHandleCreated) {
3844 XplatUI.SetVisible(Handle, value, true);
3845 // Explicitly move Toplevel windows to where we want them;
3846 // apparently moving unmapped toplevel windows doesn't work
3847 if (is_visible && (this is Form)) {
3848 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3852 OnVisibleChanged(EventArgs.Empty);
3854 if (value == false && parent != null && Focused) {
3857 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3858 container = (Control)parent.GetContainerControl();
3859 if (container != null) {
3860 container.SelectNextControl(this, true, true, true, true);
3864 if (parent != null) {
3865 parent.PerformLayout(this, "visible");
3867 PerformLayout(this, "visible");
3872 [EditorBrowsable(EditorBrowsableState.Advanced)]
3873 protected void UpdateBounds() {
3881 if (!IsHandleCreated) {
3885 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3887 UpdateBounds(x, y, width, height, client_width, client_height);
3890 [EditorBrowsable(EditorBrowsableState.Advanced)]
3891 protected void UpdateBounds(int x, int y, int width, int height) {
3895 // Calculate client rectangle
3896 rect = new Rectangle(0, 0, 0, 0);
3899 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3900 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3903 [EditorBrowsable(EditorBrowsableState.Advanced)]
3904 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3905 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3907 bool resized = false;
3909 // Needed to generate required notifications
3910 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3914 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3921 bounds.Height=height;
3923 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3924 explicit_bounds = bounds;
3926 client_size.Width=clientWidth;
3927 client_size.Height=clientHeight;
3930 OnLocationChanged(EventArgs.Empty);
3934 OnSizeChanged(EventArgs.Empty);
3938 [EditorBrowsable(EditorBrowsableState.Advanced)]
3939 protected void UpdateStyles() {
3940 if (!IsHandleCreated) {
3944 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3945 OnStyleChanged(EventArgs.Empty);
3948 private void UpdateZOrderOfChild(Control child) {
3949 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3952 index = child_controls.IndexOf(child);
3955 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3957 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3962 private void UpdateChildrenZOrder() {
3963 Control [] controls;
3965 if (!IsHandleCreated) {
3969 controls = child_controls.GetAllControls ();
3970 for (int i = 1; i < controls.Length; i++ ) {
3971 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3975 [EditorBrowsable(EditorBrowsableState.Advanced)]
3976 protected void UpdateZOrder() {
3977 if (parent != null) {
3978 parent.UpdateZOrderOfChild(this);
3982 protected virtual void WndProc(ref Message m) {
3984 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), (Msg)m.Msg);
3986 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3990 switch((Msg)m.Msg) {
3991 case Msg.WM_DESTROY: {
3992 OnHandleDestroyed(EventArgs.Empty);
3994 IntPtr handle = window.Handle;
3996 window.InvalidateHandle();
3998 if (is_recreating) {
4000 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4004 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4006 is_recreating = false;
4011 case Msg.WM_WINDOWPOSCHANGED: {
4013 Rectangle save_bounds = explicit_bounds;
4015 explicit_bounds = save_bounds;
4016 if (GetStyle(ControlStyles.ResizeRedraw)) {
4023 // Nice description of what should happen when handling WM_PAINT
4024 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4025 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4026 case Msg.WM_PAINT: {
4027 PaintEventArgs paint_event;
4029 paint_event = XplatUI.PaintEventStart(Handle, true);
4031 if (paint_event == null) {
4035 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4036 // Just blit the previous image
4037 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4038 XplatUI.PaintEventEnd(Handle, true);
4043 Graphics back_dc = null;
4044 Bitmap backbuffer = null;
4045 if (ThemeEngine.Current.DoubleBufferingSupported) {
4046 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4047 backbuffer = ImageBuffer;
4048 back_dc = Graphics.FromImage (backbuffer);
4049 dc = paint_event.SetGraphics (back_dc);
4053 if (!GetStyle(ControlStyles.Opaque)) {
4054 OnPaintBackground(paint_event);
4057 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4058 OnPaintBackgroundInternal(paint_event);
4060 OnPaintInternal(paint_event);
4061 if (!paint_event.Handled) {
4062 OnPaint(paint_event);
4065 if (ThemeEngine.Current.DoubleBufferingSupported)
4066 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4067 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4068 paint_event.SetGraphics (dc);
4069 invalid_region.Exclude (paint_event.ClipRectangle);
4071 if (backbuffer != bmp_mem)
4072 backbuffer.Dispose();
4075 XplatUI.PaintEventEnd(Handle, true);
4080 case Msg.WM_ERASEBKGND: {
4081 // The DefWndProc will never have to handle this, we always paint the background in managed code
4082 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4083 // here but it just makes things more complicated...
4084 m.Result = (IntPtr)1;
4088 case Msg.WM_LBUTTONUP: {
4091 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4093 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4096 HandleClick(mouse_clicks, me);
4099 if (InternalCapture) {
4100 InternalCapture = false;
4103 if (mouse_clicks > 1) {
4109 case Msg.WM_LBUTTONDOWN: {
4111 Select (true, true);
4113 InternalCapture = true;
4114 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4115 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4121 case Msg.WM_LBUTTONDBLCLK: {
4122 InternalCapture = true;
4124 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4125 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4131 case Msg.WM_MBUTTONUP: {
4134 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4136 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4139 HandleClick(mouse_clicks, me);
4141 if (InternalCapture) {
4142 InternalCapture = false;
4144 if (mouse_clicks > 1) {
4150 case Msg.WM_MBUTTONDOWN: {
4151 InternalCapture = true;
4152 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4153 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4159 case Msg.WM_MBUTTONDBLCLK: {
4160 InternalCapture = true;
4162 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4163 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4168 case Msg.WM_RBUTTONUP: {
4172 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4173 pt = PointToScreen(pt);
4175 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4177 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4179 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4182 HandleClick(mouse_clicks, me);
4185 if (InternalCapture) {
4186 InternalCapture = false;
4189 if (mouse_clicks > 1) {
4195 case Msg.WM_RBUTTONDOWN: {
4196 InternalCapture = true;
4197 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4198 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4203 case Msg.WM_RBUTTONDBLCLK: {
4204 InternalCapture = true;
4206 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4207 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4212 case Msg.WM_CONTEXTMENU: {
4213 if (context_menu != null) {
4216 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4217 context_menu.Show(this, PointToClient(pt));
4225 case Msg.WM_MOUSEWHEEL: {
4227 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4228 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4229 HighOrder(m.WParam.ToInt32())));
4234 case Msg.WM_MOUSEMOVE: {
4235 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4237 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4242 case Msg.WM_MOUSE_ENTER: {
4247 OnMouseEnter(EventArgs.Empty);
4251 case Msg.WM_MOUSE_LEAVE: {
4253 OnMouseLeave(EventArgs.Empty);
4257 case Msg.WM_MOUSEHOVER: {
4258 OnMouseHover(EventArgs.Empty);
4262 case Msg.WM_SYSKEYUP: {
4263 if (ProcessKeyMessage(ref m)) {
4264 m.Result = IntPtr.Zero;
4268 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4272 if (form != null && form.ActiveMenu != null) {
4273 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4281 case Msg.WM_SYSKEYDOWN:
4282 case Msg.WM_KEYDOWN:
4284 case Msg.WM_SYSCHAR:
4286 if (ProcessKeyMessage(ref m)) {
4287 m.Result = IntPtr.Zero;
4296 if (m.LParam != IntPtr.Zero) {
4299 hi = new HELPINFO();
4301 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4302 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4304 mouse_pos = Control.MousePosition;
4306 OnHelpRequested(new HelpEventArgs(mouse_pos));
4307 m.Result = (IntPtr)1;
4311 case Msg.WM_KILLFOCUS: {
4312 this.has_focus = false;
4313 OnLostFocusInternal (EventArgs.Empty);
4317 case Msg.WM_SETFOCUS: {
4319 this.has_focus = true;
4320 OnGotFocusInternal (EventArgs.Empty);
4326 case Msg.WM_SYSCOLORCHANGE: {
4327 ThemeEngine.Current.ResetDefaults();
4328 OnSystemColorsChanged(EventArgs.Empty);
4333 case Msg.WM_SETCURSOR: {
4334 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4339 XplatUI.SetCursor(window.Handle, cursor.handle);
4340 m.Result = (IntPtr)1;
4351 #endregion // Public Instance Methods
4353 #region OnXXX methods
4354 [EditorBrowsable(EditorBrowsableState.Advanced)]
4355 protected virtual void OnBackColorChanged(EventArgs e) {
4356 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4359 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4362 [EditorBrowsable(EditorBrowsableState.Advanced)]
4363 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4364 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4367 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4370 [EditorBrowsable(EditorBrowsableState.Advanced)]
4371 protected virtual void OnBindingContextChanged(EventArgs e) {
4372 CheckDataBindings ();
4373 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4376 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4379 [EditorBrowsable(EditorBrowsableState.Advanced)]
4380 protected virtual void OnCausesValidationChanged(EventArgs e) {
4381 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4386 [EditorBrowsable(EditorBrowsableState.Advanced)]
4387 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4388 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4393 [EditorBrowsable(EditorBrowsableState.Advanced)]
4394 protected virtual void OnClick(EventArgs e) {
4395 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4400 [EditorBrowsable(EditorBrowsableState.Advanced)]
4401 protected virtual void OnContextMenuChanged(EventArgs e) {
4402 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4407 [EditorBrowsable(EditorBrowsableState.Advanced)]
4408 protected virtual void OnControlAdded(ControlEventArgs e) {
4409 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4414 [EditorBrowsable(EditorBrowsableState.Advanced)]
4415 protected virtual void OnControlRemoved(ControlEventArgs e) {
4416 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4421 [EditorBrowsable(EditorBrowsableState.Advanced)]
4422 protected virtual void OnCreateControl() {
4426 [EditorBrowsable(EditorBrowsableState.Advanced)]
4427 protected virtual void OnCursorChanged(EventArgs e) {
4428 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4433 [EditorBrowsable(EditorBrowsableState.Advanced)]
4434 protected virtual void OnDockChanged(EventArgs e) {
4435 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4440 [EditorBrowsable(EditorBrowsableState.Advanced)]
4441 protected virtual void OnDoubleClick(EventArgs e) {
4442 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4447 [EditorBrowsable(EditorBrowsableState.Advanced)]
4448 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4449 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4451 eh (this, drgevent);
4454 [EditorBrowsable(EditorBrowsableState.Advanced)]
4455 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4456 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4458 eh (this, drgevent);
4461 [EditorBrowsable(EditorBrowsableState.Advanced)]
4462 protected virtual void OnDragLeave(EventArgs e) {
4463 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4468 [EditorBrowsable(EditorBrowsableState.Advanced)]
4469 protected virtual void OnDragOver(DragEventArgs drgevent) {
4470 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4472 eh (this, drgevent);
4475 [EditorBrowsable(EditorBrowsableState.Advanced)]
4476 protected virtual void OnEnabledChanged(EventArgs e) {
4477 if (IsHandleCreated) {
4479 if (((Form)this).context == null) {
4480 XplatUI.EnableWindow(window.Handle, Enabled);
4483 XplatUI.EnableWindow(window.Handle, Enabled);
4488 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4492 for (int i=0; i<child_controls.Count; i++) {
4493 child_controls[i].OnParentEnabledChanged(e);
4497 [EditorBrowsable(EditorBrowsableState.Advanced)]
4498 protected virtual void OnEnter(EventArgs e) {
4499 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4504 [EditorBrowsable(EditorBrowsableState.Advanced)]
4505 protected virtual void OnFontChanged(EventArgs e) {
4506 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4509 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4512 [EditorBrowsable(EditorBrowsableState.Advanced)]
4513 protected virtual void OnForeColorChanged(EventArgs e) {
4514 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4517 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4520 [EditorBrowsable(EditorBrowsableState.Advanced)]
4521 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4522 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4524 eh (this, gfbevent);
4527 [EditorBrowsable(EditorBrowsableState.Advanced)]
4528 protected virtual void OnGotFocus(EventArgs e) {
4529 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4534 [EditorBrowsable(EditorBrowsableState.Advanced)]
4535 protected virtual void OnHandleCreated(EventArgs e) {
4536 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4541 [EditorBrowsable(EditorBrowsableState.Advanced)]
4542 protected virtual void OnHandleDestroyed(EventArgs e) {
4543 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4548 [EditorBrowsable(EditorBrowsableState.Advanced)]
4549 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4550 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4555 protected virtual void OnImeModeChanged(EventArgs e) {
4556 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4561 [EditorBrowsable(EditorBrowsableState.Advanced)]
4562 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4563 if (ThemeEngine.Current.DoubleBufferingSupported)
4564 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4565 // should this block be here? seems like it
4566 // would be more at home in
4567 // NotifyInvalidated..
4568 if (e.InvalidRect == ClientRectangle) {
4569 ImageBufferNeedsRedraw ();
4572 // we need this Inflate call here so
4573 // that the border of the rectangle is
4574 // considered Visible (the
4575 // invalid_region.IsVisible call) in
4576 // the WM_PAINT handling below.
4577 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4578 if (invalid_region == null)
4579 invalid_region = new Region (r);
4581 invalid_region.Union (r);
4585 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4590 [EditorBrowsable(EditorBrowsableState.Advanced)]
4591 protected virtual void OnKeyDown(KeyEventArgs e) {
4592 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4597 [EditorBrowsable(EditorBrowsableState.Advanced)]
4598 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4599 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4604 [EditorBrowsable(EditorBrowsableState.Advanced)]
4605 protected virtual void OnKeyUp(KeyEventArgs e) {
4606 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4611 [EditorBrowsable(EditorBrowsableState.Advanced)]
4612 protected virtual void OnLayout(LayoutEventArgs levent) {
4613 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4618 [EditorBrowsable(EditorBrowsableState.Advanced)]
4619 protected virtual void OnLeave(EventArgs e) {
4620 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4625 [EditorBrowsable(EditorBrowsableState.Advanced)]
4626 protected virtual void OnLocationChanged(EventArgs e) {
4628 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4633 [EditorBrowsable(EditorBrowsableState.Advanced)]
4634 protected virtual void OnLostFocus(EventArgs e) {
4635 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4640 [EditorBrowsable(EditorBrowsableState.Advanced)]
4641 protected virtual void OnMouseDown(MouseEventArgs e) {
4642 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4647 [EditorBrowsable(EditorBrowsableState.Advanced)]
4648 protected virtual void OnMouseEnter(EventArgs e) {
4649 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4654 [EditorBrowsable(EditorBrowsableState.Advanced)]
4655 protected virtual void OnMouseHover(EventArgs e) {
4656 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4661 [EditorBrowsable(EditorBrowsableState.Advanced)]
4662 protected virtual void OnMouseLeave(EventArgs e) {
4663 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4668 [EditorBrowsable(EditorBrowsableState.Advanced)]
4669 protected virtual void OnMouseMove(MouseEventArgs e) {
4670 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4675 [EditorBrowsable(EditorBrowsableState.Advanced)]
4676 protected virtual void OnMouseUp(MouseEventArgs e) {
4677 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4682 [EditorBrowsable(EditorBrowsableState.Advanced)]
4683 protected virtual void OnMouseWheel(MouseEventArgs e) {
4684 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4689 [EditorBrowsable(EditorBrowsableState.Advanced)]
4690 protected virtual void OnMove(EventArgs e) {
4691 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4696 [EditorBrowsable(EditorBrowsableState.Advanced)]
4697 protected virtual void OnNotifyMessage(Message m) {
4701 [EditorBrowsable(EditorBrowsableState.Advanced)]
4702 protected virtual void OnPaint(PaintEventArgs e) {
4703 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4708 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4712 internal virtual void OnPaintInternal(PaintEventArgs e) {
4716 internal virtual void OnGotFocusInternal (EventArgs e)
4721 internal virtual void OnLostFocusInternal (EventArgs e)
4726 [EditorBrowsable(EditorBrowsableState.Advanced)]
4727 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4728 PaintControlBackground (pevent);
4731 [EditorBrowsable(EditorBrowsableState.Advanced)]
4732 protected virtual void OnParentBackColorChanged(EventArgs e) {
4733 if (background_color.IsEmpty && background_image==null) {
4735 OnBackColorChanged(e);
4739 [EditorBrowsable(EditorBrowsableState.Advanced)]
4740 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4741 if (background_color.IsEmpty && background_image==null) {
4743 OnBackgroundImageChanged(e);
4747 [EditorBrowsable(EditorBrowsableState.Advanced)]
4748 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4749 if (binding_context==null) {
4750 binding_context=Parent.binding_context;
4751 OnBindingContextChanged(e);
4755 [EditorBrowsable(EditorBrowsableState.Advanced)]
4756 protected virtual void OnParentChanged(EventArgs e) {
4757 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4762 [EditorBrowsable(EditorBrowsableState.Advanced)]
4763 protected virtual void OnParentEnabledChanged(EventArgs e) {
4765 OnEnabledChanged(e);
4769 [EditorBrowsable(EditorBrowsableState.Advanced)]
4770 protected virtual void OnParentFontChanged(EventArgs e) {
4777 [EditorBrowsable(EditorBrowsableState.Advanced)]
4778 protected virtual void OnParentForeColorChanged(EventArgs e) {
4779 if (foreground_color.IsEmpty) {
4781 OnForeColorChanged(e);
4785 [EditorBrowsable(EditorBrowsableState.Advanced)]
4786 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4787 if (right_to_left==RightToLeft.Inherit) {
4789 OnRightToLeftChanged(e);
4793 [EditorBrowsable(EditorBrowsableState.Advanced)]
4794 protected virtual void OnParentVisibleChanged(EventArgs e) {
4796 OnVisibleChanged(e);
4800 [EditorBrowsable(EditorBrowsableState.Advanced)]
4801 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4802 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4807 [EditorBrowsable(EditorBrowsableState.Advanced)]
4808 protected virtual void OnResize(EventArgs e) {
4809 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4813 PerformLayout(this, "bounds");
4815 if (parent != null) {
4816 parent.PerformLayout();
4820 [EditorBrowsable(EditorBrowsableState.Advanced)]
4821 protected virtual void OnRightToLeftChanged(EventArgs e) {
4822 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4825 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4828 [EditorBrowsable(EditorBrowsableState.Advanced)]
4829 protected virtual void OnSizeChanged(EventArgs e) {
4830 InvalidateBuffers ();
4832 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4837 [EditorBrowsable(EditorBrowsableState.Advanced)]
4838 protected virtual void OnStyleChanged(EventArgs e) {
4839 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4844 [EditorBrowsable(EditorBrowsableState.Advanced)]
4845 protected virtual void OnSystemColorsChanged(EventArgs e) {
4846 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4851 [EditorBrowsable(EditorBrowsableState.Advanced)]
4852 protected virtual void OnTabIndexChanged(EventArgs e) {
4853 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4858 [EditorBrowsable(EditorBrowsableState.Advanced)]
4859 protected virtual void OnTabStopChanged(EventArgs e) {
4860 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4865 [EditorBrowsable(EditorBrowsableState.Advanced)]
4866 protected virtual void OnTextChanged(EventArgs e) {
4867 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4872 [EditorBrowsable(EditorBrowsableState.Advanced)]
4873 protected virtual void OnValidated(EventArgs e) {
4874 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4879 [EditorBrowsable(EditorBrowsableState.Advanced)]
4880 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4881 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4886 [EditorBrowsable(EditorBrowsableState.Advanced)]
4887 protected virtual void OnVisibleChanged(EventArgs e) {
4888 if ((parent != null) && !Created && Visible) {
4895 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4899 // We need to tell our kids
4900 for (int i=0; i<child_controls.Count; i++) {
4901 if (child_controls[i].Visible) {
4902 child_controls[i].OnParentVisibleChanged(e);
4906 #endregion // OnXXX methods
4909 static object BackColorChangedEvent = new object ();
4910 static object BackgroundImageChangedEvent = new object ();
4911 static object BindingContextChangedEvent = new object ();
4912 static object CausesValidationChangedEvent = new object ();
4913 static object ChangeUICuesEvent = new object ();
4914 static object ClickEvent = new object ();
4915 static object ContextMenuChangedEvent = new object ();
4916 static object ControlAddedEvent = new object ();
4917 static object ControlRemovedEvent = new object ();
4918 static object CursorChangedEvent = new object ();
4919 static object DockChangedEvent = new object ();
4920 static object DoubleClickEvent = new object ();
4921 static object DragDropEvent = new object ();
4922 static object DragEnterEvent = new object ();
4923 static object DragLeaveEvent = new object ();
4924 static object DragOverEvent = new object ();
4925 static object EnabledChangedEvent = new object ();
4926 static object EnterEvent = new object ();
4927 static object FontChangedEvent = new object ();
4928 static object ForeColorChangedEvent = new object ();
4929 static object GiveFeedbackEvent = new object ();
4930 static object GotFocusEvent = new object ();
4931 static object HandleCreatedEvent = new object ();
4932 static object HandleDestroyedEvent = new object ();
4933 static object HelpRequestedEvent = new object ();
4934 static object ImeModeChangedEvent = new object ();
4935 static object InvalidatedEvent = new object ();
4936 static object KeyDownEvent = new object ();
4937 static object KeyPressEvent = new object ();
4938 static object KeyUpEvent = new object ();
4939 static object LayoutEvent = new object ();
4940 static object LeaveEvent = new object ();
4941 static object LocationChangedEvent = new object ();
4942 static object LostFocusEvent = new object ();
4943 static object MouseDownEvent = new object ();
4944 static object MouseEnterEvent = new object ();
4945 static object MouseHoverEvent = new object ();
4946 static object MouseLeaveEvent = new object ();
4947 static object MouseMoveEvent = new object ();
4948 static object MouseUpEvent = new object ();
4949 static object MouseWheelEvent = new object ();
4950 static object MoveEvent = new object ();
4951 static object PaintEvent = new object ();
4952 static object ParentChangedEvent = new object ();
4953 static object QueryAccessibilityHelpEvent = new object ();
4954 static object QueryContinueDragEvent = new object ();
4955 static object ResizeEvent = new object ();
4956 static object RightToLeftChangedEvent = new object ();
4957 static object SizeChangedEvent = new object ();
4958 static object StyleChangedEvent = new object ();
4959 static object SystemColorsChangedEvent = new object ();
4960 static object TabIndexChangedEvent = new object ();
4961 static object TabStopChangedEvent = new object ();
4962 static object TextChangedEvent = new object ();
4963 static object ValidatedEvent = new object ();
4964 static object ValidatingEvent = new object ();
4965 static object VisibleChangedEvent = new object ();
4967 public event EventHandler BackColorChanged {
4968 add { Events.AddHandler (BackColorChangedEvent, value); }
4969 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4972 public event EventHandler BackgroundImageChanged {
4973 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4974 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4977 public event EventHandler BindingContextChanged {
4978 add { Events.AddHandler (BindingContextChangedEvent, value); }
4979 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4982 public event EventHandler CausesValidationChanged {
4983 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4984 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4987 public event UICuesEventHandler ChangeUICues {
4988 add { Events.AddHandler (ChangeUICuesEvent, value); }
4989 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4992 public event EventHandler Click {
4993 add { Events.AddHandler (ClickEvent, value); }
4994 remove { Events.RemoveHandler (ClickEvent, value); }
4997 public event EventHandler ContextMenuChanged {
4998 add { Events.AddHandler (ContextMenuChangedEvent, value); }
4999 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5002 [EditorBrowsable(EditorBrowsableState.Advanced)]
5004 public event ControlEventHandler ControlAdded {
5005 add { Events.AddHandler (ControlAddedEvent, value); }
5006 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5009 [EditorBrowsable(EditorBrowsableState.Advanced)]
5011 public event ControlEventHandler ControlRemoved {
5012 add { Events.AddHandler (ControlRemovedEvent, value); }
5013 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5016 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5017 public event EventHandler CursorChanged {
5018 add { Events.AddHandler (CursorChangedEvent, value); }
5019 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5021 public event EventHandler DockChanged {
5022 add { Events.AddHandler (DockChangedEvent, value); }
5023 remove { Events.RemoveHandler (DockChangedEvent, value); }
5026 public event EventHandler DoubleClick {
5027 add { Events.AddHandler (DoubleClickEvent, value); }
5028 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5031 public event DragEventHandler DragDrop {
5032 add { Events.AddHandler (DragDropEvent, value); }
5033 remove { Events.RemoveHandler (DragDropEvent, value); }
5036 public event DragEventHandler DragEnter {
5037 add { Events.AddHandler (DragEnterEvent, value); }
5038 remove { Events.RemoveHandler (DragEnterEvent, value); }
5041 public event EventHandler DragLeave {
5042 add { Events.AddHandler (DragLeaveEvent, value); }
5043 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5046 public event DragEventHandler DragOver {
5047 add { Events.AddHandler (DragOverEvent, value); }
5048 remove { Events.RemoveHandler (DragOverEvent, value); }
5051 public event EventHandler EnabledChanged {
5052 add { Events.AddHandler (EnabledChangedEvent, value); }
5053 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5056 public event EventHandler Enter {
5057 add { Events.AddHandler (EnterEvent, value); }
5058 remove { Events.RemoveHandler (EnterEvent, value); }
5061 public event EventHandler FontChanged {
5062 add { Events.AddHandler (FontChangedEvent, value); }
5063 remove { Events.RemoveHandler (FontChangedEvent, value); }
5066 public event EventHandler ForeColorChanged {
5067 add { Events.AddHandler (ForeColorChangedEvent, value); }
5068 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5071 public event GiveFeedbackEventHandler GiveFeedback {
5072 add { Events.AddHandler (GiveFeedbackEvent, value); }
5073 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5076 [EditorBrowsable(EditorBrowsableState.Advanced)]
5078 public event EventHandler GotFocus {
5079 add { Events.AddHandler (GotFocusEvent, value); }
5080 remove { Events.RemoveHandler (GotFocusEvent, value); }
5084 [EditorBrowsable(EditorBrowsableState.Advanced)]
5086 public event EventHandler HandleCreated {
5087 add { Events.AddHandler (HandleCreatedEvent, value); }
5088 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5091 [EditorBrowsable(EditorBrowsableState.Advanced)]
5093 public event EventHandler HandleDestroyed {
5094 add { Events.AddHandler (HandleDestroyedEvent, value); }
5095 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5098 public event HelpEventHandler HelpRequested {
5099 add { Events.AddHandler (HelpRequestedEvent, value); }
5100 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5103 public event EventHandler ImeModeChanged {
5104 add { Events.AddHandler (ImeModeChangedEvent, value); }
5105 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5108 [EditorBrowsable(EditorBrowsableState.Advanced)]
5110 public event InvalidateEventHandler Invalidated {
5111 add { Events.AddHandler (InvalidatedEvent, value); }
5112 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5115 public event KeyEventHandler KeyDown {
5116 add { Events.AddHandler (KeyDownEvent, value); }
5117 remove { Events.RemoveHandler (KeyDownEvent, value); }
5120 public event KeyPressEventHandler KeyPress {
5121 add { Events.AddHandler (KeyPressEvent, value); }
5122 remove { Events.RemoveHandler (KeyPressEvent, value); }
5125 public event KeyEventHandler KeyUp {
5126 add { Events.AddHandler (KeyUpEvent, value); }
5127 remove { Events.RemoveHandler (KeyUpEvent, value); }
5130 public event LayoutEventHandler Layout {
5131 add { Events.AddHandler (LayoutEvent, value); }
5132 remove { Events.RemoveHandler (LayoutEvent, value); }
5135 public event EventHandler Leave {
5136 add { Events.AddHandler (LeaveEvent, value); }
5137 remove { Events.RemoveHandler (LeaveEvent, value); }
5140 public event EventHandler LocationChanged {
5141 add { Events.AddHandler (LocationChangedEvent, value); }
5142 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5145 [EditorBrowsable(EditorBrowsableState.Advanced)]
5147 public event EventHandler LostFocus {
5148 add { Events.AddHandler (LostFocusEvent, value); }
5149 remove { Events.RemoveHandler (LostFocusEvent, value); }
5152 public event MouseEventHandler MouseDown {
5153 add { Events.AddHandler (MouseDownEvent, value); }
5154 remove { Events.RemoveHandler (MouseDownEvent, value); }
5157 public event EventHandler MouseEnter {
5158 add { Events.AddHandler (MouseEnterEvent, value); }
5159 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5162 public event EventHandler MouseHover {
5163 add { Events.AddHandler (MouseHoverEvent, value); }
5164 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5167 public event EventHandler MouseLeave {
5168 add { Events.AddHandler (MouseLeaveEvent, value); }
5169 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5172 public event MouseEventHandler MouseMove {
5173 add { Events.AddHandler (MouseMoveEvent, value); }
5174 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5177 public event MouseEventHandler MouseUp {
5178 add { Events.AddHandler (MouseUpEvent, value); }
5179 remove { Events.RemoveHandler (MouseUpEvent, value); }
5182 [EditorBrowsable(EditorBrowsableState.Advanced)]
5184 public event MouseEventHandler MouseWheel {
5185 add { Events.AddHandler (MouseWheelEvent, value); }
5186 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5189 public event EventHandler Move {
5190 add { Events.AddHandler (MoveEvent, value); }
5191 remove { Events.RemoveHandler (MoveEvent, value); }
5194 public event PaintEventHandler Paint {
5195 add { Events.AddHandler (PaintEvent, value); }
5196 remove { Events.RemoveHandler (PaintEvent, value); }
5199 public event EventHandler ParentChanged {
5200 add { Events.AddHandler (ParentChangedEvent, value); }
5201 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5204 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5205 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5206 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5209 public event QueryContinueDragEventHandler QueryContinueDrag {
5210 add { Events.AddHandler (QueryContinueDragEvent, value); }
5211 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5214 public event EventHandler Resize {
5215 add { Events.AddHandler (ResizeEvent, value); }
5216 remove { Events.RemoveHandler (ResizeEvent, value); }
5219 public event EventHandler RightToLeftChanged {
5220 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5221 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5224 public event EventHandler SizeChanged {
5225 add { Events.AddHandler (SizeChangedEvent, value); }
5226 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5229 public event EventHandler StyleChanged {
5230 add { Events.AddHandler (StyleChangedEvent, value); }
5231 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5234 public event EventHandler SystemColorsChanged {
5235 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5236 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5239 public event EventHandler TabIndexChanged {
5240 add { Events.AddHandler (TabIndexChangedEvent, value); }
5241 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5244 public event EventHandler TabStopChanged {
5245 add { Events.AddHandler (TabStopChangedEvent, value); }
5246 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5249 public event EventHandler TextChanged {
5250 add { Events.AddHandler (TextChangedEvent, value); }
5251 remove { Events.RemoveHandler (TextChangedEvent, value); }
5254 public event EventHandler Validated {
5255 add { Events.AddHandler (ValidatedEvent, value); }
5256 remove { Events.RemoveHandler (ValidatedEvent, value); }
5259 public event CancelEventHandler Validating {
5260 add { Events.AddHandler (ValidatingEvent, value); }
5261 remove { Events.RemoveHandler (ValidatingEvent, value); }
5264 public event EventHandler VisibleChanged {
5265 add { Events.AddHandler (VisibleChangedEvent, value); }
5266 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5269 #endregion // Events