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 internal bool verify_thread_handle;
130 private Padding padding;
131 private Size maximum_size;
132 private Size minimum_size;
133 private Size preferred_size;
134 private Padding margin;
135 internal 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);
2960 private void SetImplicitBounds (int x, int y, int width, int height)
2962 Rectangle saved_bounds = explicit_bounds;
2963 SetBounds (x, y, width, height);
2964 explicit_bounds = saved_bounds;
2967 [EditorBrowsable(EditorBrowsableState.Advanced)]
2968 public void PerformLayout(Control affectedControl, string affectedProperty) {
2969 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2971 if (layout_suspended > 0) {
2972 layout_pending = true;
2976 layout_pending = false;
2978 // Prevent us from getting messed up
2981 // Perform all Dock and Anchor calculations
2985 this.layout_engine.Layout(this, levent);
2987 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2989 AnchorStyles anchor;
2992 space = DisplayRectangle;
2994 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2995 Control [] controls = child_controls.GetAllControls ();
2996 for (int i = controls.Length - 1; i >= 0; i--) {
2997 child = controls [i];
2999 if (!child.Visible) {
3003 switch (child.Dock) {
3004 case DockStyle.None: {
3009 case DockStyle.Left: {
3010 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3011 space.X+=child.Width;
3012 space.Width-=child.Width;
3016 case DockStyle.Top: {
3017 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3018 space.Y+=child.Height;
3019 space.Height-=child.Height;
3023 case DockStyle.Right: {
3024 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3025 space.Width-=child.Width;
3029 case DockStyle.Bottom: {
3030 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3031 space.Height-=child.Height;
3037 for (int i = controls.Length - 1; i >= 0; i--) {
3040 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3041 if (child.Dock == DockStyle.Fill) {
3042 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3046 space = DisplayRectangle;
3048 for (int i=0; i < controls.Length; i++) {
3054 child = controls[i];
3056 // If the control is docked we don't need to do anything
3057 if (child.Dock != DockStyle.None) {
3061 anchor = child.Anchor;
3065 width = child.Width;
3066 height = child.Height;
3068 if ((anchor & AnchorStyles.Left) !=0 ) {
3069 if ((anchor & AnchorStyles.Right) != 0) {
3070 width = space.Width - child.dist_right - left;
3072 ; // Left anchored only, nothing to be done
3074 } else if ((anchor & AnchorStyles.Right) != 0) {
3075 left = space.Width - child.dist_right - width;
3077 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3078 // This calculates from scratch every time:
3079 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3082 if ((anchor & AnchorStyles.Top) !=0 ) {
3083 if ((anchor & AnchorStyles.Bottom) != 0) {
3084 height = space.Height - child.dist_bottom - top;
3086 ; // Top anchored only, nothing to be done
3088 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3089 top = space.Height - child.dist_bottom - height;
3091 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3092 // This calculates from scratch every time:
3093 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3105 child.SetImplicitBounds(left, top, width, height);
3109 // Let everyone know
3113 // Need to make sure we decremend layout_suspended
3119 public Point PointToClient (Point p) {
3123 XplatUI.ScreenToClient (Handle, ref x, ref y);
3125 return new Point (x, y);
3128 public Point PointToScreen(Point p) {
3132 XplatUI.ClientToScreen(Handle, ref x, ref y);
3134 return new Point(x, y);
3137 public virtual bool PreProcessMessage(ref Message msg) {
3138 return InternalPreProcessMessage (ref msg);
3141 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3144 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3145 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3147 if (!ProcessCmdKey(ref msg, key_data)) {
3148 if (IsInputKey(key_data)) {
3152 return ProcessDialogKey(key_data);
3156 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3157 if (IsInputChar((char)msg.WParam)) {
3160 return ProcessDialogChar((char)msg.WParam);
3161 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3162 return ProcessDialogChar((char)msg.WParam);
3167 public Rectangle RectangleToClient(Rectangle r) {
3168 return new Rectangle(PointToClient(r.Location), r.Size);
3171 public Rectangle RectangleToScreen(Rectangle r) {
3172 return new Rectangle(PointToScreen(r.Location), r.Size);
3175 public virtual void Refresh() {
3176 if (IsHandleCreated == true) {
3178 XplatUI.UpdateWindow(window.Handle);
3180 Control [] controls = child_controls.GetAllControls ();
3181 for (int i=0; i < controls.Length; i++) {
3182 controls[i].Refresh();
3188 [EditorBrowsable(EditorBrowsableState.Never)]
3189 public virtual void ResetBackColor() {
3190 BackColor = Color.Empty;
3193 [EditorBrowsable(EditorBrowsableState.Never)]
3194 public void ResetBindings() {
3195 data_bindings.Clear();
3198 [EditorBrowsable(EditorBrowsableState.Never)]
3199 public virtual void ResetCursor() {
3203 [EditorBrowsable(EditorBrowsableState.Never)]
3204 public virtual void ResetFont() {
3208 [EditorBrowsable(EditorBrowsableState.Never)]
3209 public virtual void ResetForeColor() {
3210 foreground_color = Color.Empty;
3213 [EditorBrowsable(EditorBrowsableState.Never)]
3214 public void ResetImeMode() {
3215 ime_mode = DefaultImeMode;
3218 [EditorBrowsable(EditorBrowsableState.Never)]
3219 public virtual void ResetRightToLeft() {
3220 right_to_left = RightToLeft.Inherit;
3223 public virtual void ResetText() {
3224 text = String.Empty;
3227 public void ResumeLayout() {
3228 ResumeLayout (true);
3231 public void ResumeLayout(bool performLayout) {
3232 if (layout_suspended > 0) {
3236 if (layout_suspended == 0) {
3237 Control [] controls = child_controls.GetAllControls ();
3238 for (int i=0; i<controls.Length; i++) {
3239 controls [i].UpdateDistances ();
3242 if (performLayout && layout_pending) {
3248 public void Scale(float ratio) {
3249 ScaleCore(ratio, ratio);
3252 public void Scale(float dx, float dy) {
3257 public void Scale(SizeF factor) {
3258 ScaleCore(factor.Width, factor.Height);
3262 public void Select() {
3263 Select(false, false);
3267 private void printTree(Control c, string t) {
3268 foreach(Control i in c.child_controls) {
3269 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3270 printTree(i, t+"\t");
3274 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3278 Console.WriteLine("{0}", this.FindForm());
3279 printTree(this, "\t");
3282 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3287 c = GetNextControl(c, forward);
3296 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3297 c.Select (true, true);
3300 } while (c != ctl); // If we wrap back to ourselves we stop
3305 public void SendToBack() {
3306 if (parent != null) {
3307 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3311 public void SetBounds(int x, int y, int width, int height) {
3312 SetBounds(x, y, width, height, BoundsSpecified.All);
3315 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3316 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3320 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3324 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3328 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3332 SetBoundsCore(x, y, width, height, specified);
3333 if (parent != null) {
3334 parent.PerformLayout(this, "Bounds");
3338 public void Show() {
3340 this.CreateControl();
3346 public void SuspendLayout() {
3350 public void Update() {
3351 if (IsHandleCreated) {
3352 XplatUI.UpdateWindow(window.Handle);
3355 #endregion // Public Instance Methods
3357 #region Protected Instance Methods
3358 [EditorBrowsable(EditorBrowsableState.Advanced)]
3359 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3360 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3361 throw new NotImplementedException();
3364 [EditorBrowsable(EditorBrowsableState.Advanced)]
3365 protected virtual AccessibleObject CreateAccessibilityInstance() {
3366 return new Control.ControlAccessibleObject(this);
3369 [EditorBrowsable(EditorBrowsableState.Advanced)]
3370 protected virtual ControlCollection CreateControlsInstance() {
3371 return new ControlCollection(this);
3374 [EditorBrowsable(EditorBrowsableState.Advanced)]
3375 protected virtual void CreateHandle() {
3377 throw new ObjectDisposedException(GetType().FullName.ToString());
3380 if (IsHandleCreated && !is_recreating) {
3384 window.CreateHandle(CreateParams);
3386 if (window.Handle != IntPtr.Zero) {
3387 lock (Control.controls) {
3388 if (!Control.controls.Contains(window.Handle)) {
3389 Control.controls.Add(this);
3393 creator_thread = Thread.CurrentThread;
3395 XplatUI.EnableWindow(window.Handle, is_enabled);
3396 XplatUI.SetVisible(window.Handle, is_visible, true);
3398 if (clip_region != null) {
3399 XplatUI.SetClipRegion(Handle, clip_region);
3402 // Set our handle with our parent
3403 if ((parent != null) && (parent.IsHandleCreated)) {
3404 XplatUI.SetParent(window.Handle, parent.Handle);
3407 // Set our handle as parent for our children
3408 Control [] children;
3410 children = child_controls.GetAllControls ();
3411 for (int i = 0; i < children.Length; i++ ) {
3412 if (!children[i].RecreatingHandle)
3413 XplatUI.SetParent(children[i].Handle, window.Handle);
3417 XplatUI.SetAllowDrop (Handle, allow_drop);
3419 // Find out where the window manager placed us
3420 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3421 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3425 OnHandleCreated(EventArgs.Empty);
3429 [EditorBrowsable(EditorBrowsableState.Advanced)]
3430 protected virtual void DefWndProc(ref Message m) {
3431 window.DefWndProc(ref m);
3434 [EditorBrowsable(EditorBrowsableState.Advanced)]
3435 protected virtual void DestroyHandle() {
3436 if (IsHandleCreated) {
3437 if (window != null) {
3438 window.DestroyHandle();
3443 protected bool GetStyle(ControlStyles flag) {
3444 return (control_style & flag) != 0;
3447 protected bool GetTopLevel() {
3451 [EditorBrowsable(EditorBrowsableState.Advanced)]
3452 protected virtual void InitLayout() {
3456 [EditorBrowsable(EditorBrowsableState.Advanced)]
3457 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3458 toInvoke.OnGotFocus(e);
3461 [EditorBrowsable(EditorBrowsableState.Advanced)]
3462 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3463 toInvoke.OnLostFocus(e);
3466 [EditorBrowsable(EditorBrowsableState.Advanced)]
3467 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3468 toInvoke.OnClick(e);
3471 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3472 toInvoke.OnPaint(e);
3475 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3476 toInvoke.OnPaintBackground(e);
3479 protected virtual bool IsInputChar (char charCode) {
3483 protected virtual bool IsInputKey (Keys keyData) {
3484 // Doc says this one calls IsInputChar; not sure what to do with that
3488 [EditorBrowsable(EditorBrowsableState.Advanced)]
3489 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3493 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3494 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3498 if (parent != null) {
3499 return parent.ProcessCmdKey(ref msg, keyData);
3505 protected virtual bool ProcessDialogChar(char charCode) {
3506 if (parent != null) {
3507 return parent.ProcessDialogChar (charCode);
3513 protected virtual bool ProcessDialogKey (Keys keyData) {
3514 if (parent != null) {
3515 return parent.ProcessDialogKey (keyData);
3521 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3523 KeyEventArgs key_event;
3526 case (int)Msg.WM_SYSKEYDOWN:
3527 case (int)Msg.WM_KEYDOWN: {
3528 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3529 OnKeyDown (key_event);
3530 return key_event.Handled;
3533 case (int)Msg.WM_SYSKEYUP:
3534 case (int)Msg.WM_KEYUP: {
3535 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3536 OnKeyUp (key_event);
3537 return key_event.Handled;
3540 case (int)Msg.WM_SYSCHAR:
3541 case (int)Msg.WM_CHAR: {
3542 KeyPressEventArgs key_press_event;
3544 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3545 OnKeyPress(key_press_event);
3547 msg.WParam = (IntPtr)key_press_event.KeyChar;
3549 return key_press_event.Handled;
3560 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3561 if (parent != null) {
3562 if (parent.ProcessKeyPreview(ref msg)) {
3567 return ProcessKeyEventArgs(ref msg);
3570 protected virtual bool ProcessKeyPreview(ref Message msg) {
3571 if (parent != null) {
3572 return parent.ProcessKeyPreview(ref msg);
3578 protected virtual bool ProcessMnemonic(char charCode) {
3583 [EditorBrowsable(EditorBrowsableState.Advanced)]
3584 protected void RaiseDragEvent(object key, DragEventArgs e) {
3588 [EditorBrowsable(EditorBrowsableState.Advanced)]
3589 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3593 [EditorBrowsable(EditorBrowsableState.Advanced)]
3594 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3598 [EditorBrowsable(EditorBrowsableState.Advanced)]
3599 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3603 private void SetIsRecreating ()
3607 foreach (Control c in Controls.GetAllControls()) {
3608 c.SetIsRecreating ();
3612 [EditorBrowsable(EditorBrowsableState.Advanced)]
3613 protected void RecreateHandle() {
3615 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3620 if (IsHandleCreated) {
3622 Console.WriteLine(" + handle is created, destroying it.");
3625 // WM_DESTROY will CreateHandle for us
3628 Console.WriteLine(" + handle is not created, creating it.");
3636 is_recreating = false;
3638 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3644 [EditorBrowsable(EditorBrowsableState.Advanced)]
3645 protected void ResetMouseEventArgs() {
3649 [EditorBrowsable(EditorBrowsableState.Advanced)]
3650 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3651 if (right_to_left == RightToLeft.No) {
3656 case ContentAlignment.TopLeft: {
3657 return ContentAlignment.TopRight;
3660 case ContentAlignment.TopRight: {
3661 return ContentAlignment.TopLeft;
3664 case ContentAlignment.MiddleLeft: {
3665 return ContentAlignment.MiddleRight;
3668 case ContentAlignment.MiddleRight: {
3669 return ContentAlignment.MiddleLeft;
3672 case ContentAlignment.BottomLeft: {
3673 return ContentAlignment.BottomRight;
3676 case ContentAlignment.BottomRight: {
3677 return ContentAlignment.BottomLeft;
3681 // if it's center it doesn't change
3687 [EditorBrowsable(EditorBrowsableState.Advanced)]
3688 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3689 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3693 if (align == HorizontalAlignment.Left) {
3694 return HorizontalAlignment.Right;
3697 // align must be HorizontalAlignment.Right
3698 return HorizontalAlignment.Left;
3701 [EditorBrowsable(EditorBrowsableState.Advanced)]
3702 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3703 if (right_to_left == RightToLeft.No) {
3707 if (align == LeftRightAlignment.Left) {
3708 return LeftRightAlignment.Right;
3711 // align must be LeftRightAlignment.Right;
3712 return LeftRightAlignment.Left;
3715 [EditorBrowsable(EditorBrowsableState.Advanced)]
3716 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3717 return RtlTranslateAlignment(align);
3720 [EditorBrowsable(EditorBrowsableState.Advanced)]
3721 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3722 return RtlTranslateAlignment(align);
3725 [EditorBrowsable(EditorBrowsableState.Advanced)]
3726 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3727 return RtlTranslateAlignment(align);
3730 [EditorBrowsable(EditorBrowsableState.Advanced)]
3731 protected virtual void ScaleCore(float dx, float dy) {
3737 location = new Point((int)(Left * dx), (int)(Top * dy));
3738 size = this.ClientSize;
3740 if (!GetStyle(ControlStyles.FixedWidth)) {
3741 size.Width = (int)(size.Width * dx);
3744 if (!GetStyle(ControlStyles.FixedHeight)) {
3745 size.Height = (int)(size.Height * dy);
3748 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3750 /* Now scale our children */
3751 Control [] controls = child_controls.GetAllControls ();
3752 for (int i=0; i < controls.Length; i++) {
3753 controls[i].Scale(dx, dy);
3759 protected virtual void Select(bool directed, bool forward) {
3760 IContainerControl container;
3762 container = GetContainerControl();
3763 if (container != null)
3764 container.ActiveControl = this;
3767 [EditorBrowsable(EditorBrowsableState.Advanced)]
3768 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3769 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3770 if (IsHandleCreated) {
3771 XplatUI.SetWindowPos(Handle, x, y, width, height);
3773 // Win32 automatically changes negative width/height to 0.
3774 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3775 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3777 if (width < 0 || height < 0) {
3779 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3783 UpdateBounds(x, y, width, height);
3788 [EditorBrowsable(EditorBrowsableState.Advanced)]
3789 protected virtual void SetClientSizeCore(int x, int y) {
3790 // Calculate the actual window size from the client size (it usually stays the same or grows)
3791 Rectangle ClientRect;
3792 Rectangle WindowRect;
3795 ClientRect = new Rectangle(0, 0, x, y);
3796 cp = this.CreateParams;
3798 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3802 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3805 [EditorBrowsable(EditorBrowsableState.Advanced)]
3806 protected void SetStyle(ControlStyles flag, bool value) {
3808 control_style |= flag;
3810 control_style &= ~flag;
3814 protected void SetTopLevel(bool value) {
3815 if ((GetTopLevel() != value) && (parent != null)) {
3816 throw new Exception();
3820 if (value == true) {
3830 is_toplevel = value;
3833 protected virtual void SetVisibleCore(bool value) {
3834 if (value!=is_visible) {
3835 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3841 if (IsHandleCreated) {
3842 XplatUI.SetVisible(Handle, value, true);
3843 // Explicitly move Toplevel windows to where we want them;
3844 // apparently moving unmapped toplevel windows doesn't work
3845 if (is_visible && (this is Form)) {
3846 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3850 OnVisibleChanged(EventArgs.Empty);
3852 if (value == false && parent != null && Focused) {
3855 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3856 container = (Control)parent.GetContainerControl();
3857 if (container != null) {
3858 container.SelectNextControl(this, true, true, true, true);
3862 if (parent != null) {
3863 parent.PerformLayout(this, "visible");
3865 PerformLayout(this, "visible");
3870 [EditorBrowsable(EditorBrowsableState.Advanced)]
3871 protected void UpdateBounds() {
3879 if (!IsHandleCreated) {
3883 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3885 UpdateBounds(x, y, width, height, client_width, client_height);
3888 [EditorBrowsable(EditorBrowsableState.Advanced)]
3889 protected void UpdateBounds(int x, int y, int width, int height) {
3893 // Calculate client rectangle
3894 rect = new Rectangle(0, 0, 0, 0);
3897 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3898 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3901 [EditorBrowsable(EditorBrowsableState.Advanced)]
3902 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3903 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3905 bool resized = false;
3907 // Needed to generate required notifications
3908 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3912 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3919 bounds.Height=height;
3921 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3922 explicit_bounds = bounds;
3924 client_size.Width=clientWidth;
3925 client_size.Height=clientHeight;
3928 OnLocationChanged(EventArgs.Empty);
3932 OnSizeChanged(EventArgs.Empty);
3936 [EditorBrowsable(EditorBrowsableState.Advanced)]
3937 protected void UpdateStyles() {
3938 if (!IsHandleCreated) {
3942 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3943 OnStyleChanged(EventArgs.Empty);
3946 private void UpdateZOrderOfChild(Control child) {
3947 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3950 index = child_controls.IndexOf(child);
3953 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3955 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3960 private void UpdateChildrenZOrder() {
3961 Control [] controls;
3963 if (!IsHandleCreated) {
3967 controls = child_controls.GetAllControls ();
3968 for (int i = 1; i < controls.Length; i++ ) {
3969 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3973 [EditorBrowsable(EditorBrowsableState.Advanced)]
3974 protected void UpdateZOrder() {
3975 if (parent != null) {
3976 parent.UpdateZOrderOfChild(this);
3980 protected virtual void WndProc(ref Message m) {
3982 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), (Msg)m.Msg);
3984 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3988 switch((Msg)m.Msg) {
3989 case Msg.WM_DESTROY: {
3990 OnHandleDestroyed(EventArgs.Empty);
3992 IntPtr handle = window.Handle;
3994 window.InvalidateHandle();
3996 if (is_recreating) {
3998 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4002 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4004 is_recreating = false;
4009 case Msg.WM_WINDOWPOSCHANGED: {
4011 Rectangle save_bounds = explicit_bounds;
4013 explicit_bounds = save_bounds;
4014 if (GetStyle(ControlStyles.ResizeRedraw)) {
4021 // Nice description of what should happen when handling WM_PAINT
4022 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4023 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4024 case Msg.WM_PAINT: {
4025 PaintEventArgs paint_event;
4027 paint_event = XplatUI.PaintEventStart(Handle, true);
4029 if (paint_event == null) {
4033 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4034 // Just blit the previous image
4035 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4036 XplatUI.PaintEventEnd(Handle, true);
4041 Graphics back_dc = null;
4042 Bitmap backbuffer = null;
4043 if (ThemeEngine.Current.DoubleBufferingSupported) {
4044 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4045 backbuffer = ImageBuffer;
4046 back_dc = Graphics.FromImage (backbuffer);
4047 dc = paint_event.SetGraphics (back_dc);
4051 if (!GetStyle(ControlStyles.Opaque)) {
4052 OnPaintBackground(paint_event);
4055 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4056 OnPaintBackgroundInternal(paint_event);
4058 OnPaintInternal(paint_event);
4059 if (!paint_event.Handled) {
4060 OnPaint(paint_event);
4063 if (ThemeEngine.Current.DoubleBufferingSupported)
4064 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4065 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4066 paint_event.SetGraphics (dc);
4067 invalid_region.Exclude (paint_event.ClipRectangle);
4069 if (backbuffer != bmp_mem)
4070 backbuffer.Dispose();
4073 XplatUI.PaintEventEnd(Handle, true);
4078 case Msg.WM_ERASEBKGND: {
4079 // The DefWndProc will never have to handle this, we always paint the background in managed code
4080 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4081 // here but it just makes things more complicated...
4082 m.Result = (IntPtr)1;
4086 case Msg.WM_LBUTTONUP: {
4089 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4091 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4094 HandleClick(mouse_clicks, me);
4097 if (InternalCapture) {
4098 InternalCapture = false;
4101 if (mouse_clicks > 1) {
4107 case Msg.WM_LBUTTONDOWN: {
4109 Select (true, true);
4111 InternalCapture = true;
4112 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4113 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4119 case Msg.WM_LBUTTONDBLCLK: {
4120 InternalCapture = true;
4122 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4123 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4129 case Msg.WM_MBUTTONUP: {
4132 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4134 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4137 HandleClick(mouse_clicks, me);
4139 if (InternalCapture) {
4140 InternalCapture = false;
4142 if (mouse_clicks > 1) {
4148 case Msg.WM_MBUTTONDOWN: {
4149 InternalCapture = true;
4150 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4151 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4157 case Msg.WM_MBUTTONDBLCLK: {
4158 InternalCapture = true;
4160 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4161 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4166 case Msg.WM_RBUTTONUP: {
4170 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4171 pt = PointToScreen(pt);
4173 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4175 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4177 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4180 HandleClick(mouse_clicks, me);
4183 if (InternalCapture) {
4184 InternalCapture = false;
4187 if (mouse_clicks > 1) {
4193 case Msg.WM_RBUTTONDOWN: {
4194 InternalCapture = true;
4195 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4196 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4201 case Msg.WM_RBUTTONDBLCLK: {
4202 InternalCapture = true;
4204 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4205 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4210 case Msg.WM_CONTEXTMENU: {
4211 if (context_menu != null) {
4214 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4215 context_menu.Show(this, PointToClient(pt));
4223 case Msg.WM_MOUSEWHEEL: {
4225 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4226 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4227 HighOrder(m.WParam.ToInt32())));
4232 case Msg.WM_MOUSEMOVE: {
4233 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4235 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4240 case Msg.WM_MOUSE_ENTER: {
4245 OnMouseEnter(EventArgs.Empty);
4249 case Msg.WM_MOUSE_LEAVE: {
4251 OnMouseLeave(EventArgs.Empty);
4255 case Msg.WM_MOUSEHOVER: {
4256 OnMouseHover(EventArgs.Empty);
4260 case Msg.WM_SYSKEYUP: {
4261 if (ProcessKeyMessage(ref m)) {
4262 m.Result = IntPtr.Zero;
4266 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4270 if (form != null && form.ActiveMenu != null) {
4271 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4279 case Msg.WM_SYSKEYDOWN:
4280 case Msg.WM_KEYDOWN:
4282 case Msg.WM_SYSCHAR:
4284 if (ProcessKeyMessage(ref m)) {
4285 m.Result = IntPtr.Zero;
4294 if (m.LParam != IntPtr.Zero) {
4297 hi = new HELPINFO();
4299 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4300 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4302 mouse_pos = Control.MousePosition;
4304 OnHelpRequested(new HelpEventArgs(mouse_pos));
4305 m.Result = (IntPtr)1;
4309 case Msg.WM_KILLFOCUS: {
4310 this.has_focus = false;
4311 OnLostFocusInternal (EventArgs.Empty);
4315 case Msg.WM_SETFOCUS: {
4317 this.has_focus = true;
4318 OnGotFocusInternal (EventArgs.Empty);
4324 case Msg.WM_SYSCOLORCHANGE: {
4325 ThemeEngine.Current.ResetDefaults();
4326 OnSystemColorsChanged(EventArgs.Empty);
4331 case Msg.WM_SETCURSOR: {
4332 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4337 XplatUI.SetCursor(window.Handle, cursor.handle);
4338 m.Result = (IntPtr)1;
4349 #endregion // Public Instance Methods
4351 #region OnXXX methods
4352 [EditorBrowsable(EditorBrowsableState.Advanced)]
4353 protected virtual void OnBackColorChanged(EventArgs e) {
4354 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4357 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4360 [EditorBrowsable(EditorBrowsableState.Advanced)]
4361 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4362 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4365 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4368 [EditorBrowsable(EditorBrowsableState.Advanced)]
4369 protected virtual void OnBindingContextChanged(EventArgs e) {
4370 CheckDataBindings ();
4371 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4374 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4377 [EditorBrowsable(EditorBrowsableState.Advanced)]
4378 protected virtual void OnCausesValidationChanged(EventArgs e) {
4379 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4384 [EditorBrowsable(EditorBrowsableState.Advanced)]
4385 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4386 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4391 [EditorBrowsable(EditorBrowsableState.Advanced)]
4392 protected virtual void OnClick(EventArgs e) {
4393 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4398 [EditorBrowsable(EditorBrowsableState.Advanced)]
4399 protected virtual void OnContextMenuChanged(EventArgs e) {
4400 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4405 [EditorBrowsable(EditorBrowsableState.Advanced)]
4406 protected virtual void OnControlAdded(ControlEventArgs e) {
4407 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4412 [EditorBrowsable(EditorBrowsableState.Advanced)]
4413 protected virtual void OnControlRemoved(ControlEventArgs e) {
4414 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4419 [EditorBrowsable(EditorBrowsableState.Advanced)]
4420 protected virtual void OnCreateControl() {
4424 [EditorBrowsable(EditorBrowsableState.Advanced)]
4425 protected virtual void OnCursorChanged(EventArgs e) {
4426 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4431 [EditorBrowsable(EditorBrowsableState.Advanced)]
4432 protected virtual void OnDockChanged(EventArgs e) {
4433 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4438 [EditorBrowsable(EditorBrowsableState.Advanced)]
4439 protected virtual void OnDoubleClick(EventArgs e) {
4440 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4445 [EditorBrowsable(EditorBrowsableState.Advanced)]
4446 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4447 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4449 eh (this, drgevent);
4452 [EditorBrowsable(EditorBrowsableState.Advanced)]
4453 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4454 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4456 eh (this, drgevent);
4459 [EditorBrowsable(EditorBrowsableState.Advanced)]
4460 protected virtual void OnDragLeave(EventArgs e) {
4461 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4466 [EditorBrowsable(EditorBrowsableState.Advanced)]
4467 protected virtual void OnDragOver(DragEventArgs drgevent) {
4468 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4470 eh (this, drgevent);
4473 [EditorBrowsable(EditorBrowsableState.Advanced)]
4474 protected virtual void OnEnabledChanged(EventArgs e) {
4475 if (IsHandleCreated) {
4477 if (((Form)this).context == null) {
4478 XplatUI.EnableWindow(window.Handle, Enabled);
4481 XplatUI.EnableWindow(window.Handle, Enabled);
4486 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4490 for (int i=0; i<child_controls.Count; i++) {
4491 child_controls[i].OnParentEnabledChanged(e);
4495 [EditorBrowsable(EditorBrowsableState.Advanced)]
4496 protected virtual void OnEnter(EventArgs e) {
4497 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4502 [EditorBrowsable(EditorBrowsableState.Advanced)]
4503 protected virtual void OnFontChanged(EventArgs e) {
4504 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4507 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4510 [EditorBrowsable(EditorBrowsableState.Advanced)]
4511 protected virtual void OnForeColorChanged(EventArgs e) {
4512 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4515 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4518 [EditorBrowsable(EditorBrowsableState.Advanced)]
4519 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4520 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4522 eh (this, gfbevent);
4525 [EditorBrowsable(EditorBrowsableState.Advanced)]
4526 protected virtual void OnGotFocus(EventArgs e) {
4527 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4532 [EditorBrowsable(EditorBrowsableState.Advanced)]
4533 protected virtual void OnHandleCreated(EventArgs e) {
4534 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4539 [EditorBrowsable(EditorBrowsableState.Advanced)]
4540 protected virtual void OnHandleDestroyed(EventArgs e) {
4541 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4546 [EditorBrowsable(EditorBrowsableState.Advanced)]
4547 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4548 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4553 protected virtual void OnImeModeChanged(EventArgs e) {
4554 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4559 [EditorBrowsable(EditorBrowsableState.Advanced)]
4560 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4561 if (ThemeEngine.Current.DoubleBufferingSupported)
4562 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4563 // should this block be here? seems like it
4564 // would be more at home in
4565 // NotifyInvalidated..
4566 if (e.InvalidRect == ClientRectangle) {
4567 ImageBufferNeedsRedraw ();
4570 // we need this Inflate call here so
4571 // that the border of the rectangle is
4572 // considered Visible (the
4573 // invalid_region.IsVisible call) in
4574 // the WM_PAINT handling below.
4575 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4576 if (invalid_region == null)
4577 invalid_region = new Region (r);
4579 invalid_region.Union (r);
4583 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4588 [EditorBrowsable(EditorBrowsableState.Advanced)]
4589 protected virtual void OnKeyDown(KeyEventArgs e) {
4590 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4595 [EditorBrowsable(EditorBrowsableState.Advanced)]
4596 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4597 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4602 [EditorBrowsable(EditorBrowsableState.Advanced)]
4603 protected virtual void OnKeyUp(KeyEventArgs e) {
4604 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4609 [EditorBrowsable(EditorBrowsableState.Advanced)]
4610 protected virtual void OnLayout(LayoutEventArgs levent) {
4611 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4616 [EditorBrowsable(EditorBrowsableState.Advanced)]
4617 protected virtual void OnLeave(EventArgs e) {
4618 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4623 [EditorBrowsable(EditorBrowsableState.Advanced)]
4624 protected virtual void OnLocationChanged(EventArgs e) {
4626 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4631 [EditorBrowsable(EditorBrowsableState.Advanced)]
4632 protected virtual void OnLostFocus(EventArgs e) {
4633 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4638 [EditorBrowsable(EditorBrowsableState.Advanced)]
4639 protected virtual void OnMouseDown(MouseEventArgs e) {
4640 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4645 [EditorBrowsable(EditorBrowsableState.Advanced)]
4646 protected virtual void OnMouseEnter(EventArgs e) {
4647 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4652 [EditorBrowsable(EditorBrowsableState.Advanced)]
4653 protected virtual void OnMouseHover(EventArgs e) {
4654 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4659 [EditorBrowsable(EditorBrowsableState.Advanced)]
4660 protected virtual void OnMouseLeave(EventArgs e) {
4661 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4666 [EditorBrowsable(EditorBrowsableState.Advanced)]
4667 protected virtual void OnMouseMove(MouseEventArgs e) {
4668 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4673 [EditorBrowsable(EditorBrowsableState.Advanced)]
4674 protected virtual void OnMouseUp(MouseEventArgs e) {
4675 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4680 [EditorBrowsable(EditorBrowsableState.Advanced)]
4681 protected virtual void OnMouseWheel(MouseEventArgs e) {
4682 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4687 [EditorBrowsable(EditorBrowsableState.Advanced)]
4688 protected virtual void OnMove(EventArgs e) {
4689 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4694 [EditorBrowsable(EditorBrowsableState.Advanced)]
4695 protected virtual void OnNotifyMessage(Message m) {
4699 [EditorBrowsable(EditorBrowsableState.Advanced)]
4700 protected virtual void OnPaint(PaintEventArgs e) {
4701 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4706 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4710 internal virtual void OnPaintInternal(PaintEventArgs e) {
4714 internal virtual void OnGotFocusInternal (EventArgs e)
4719 internal virtual void OnLostFocusInternal (EventArgs e)
4724 [EditorBrowsable(EditorBrowsableState.Advanced)]
4725 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4726 PaintControlBackground (pevent);
4729 [EditorBrowsable(EditorBrowsableState.Advanced)]
4730 protected virtual void OnParentBackColorChanged(EventArgs e) {
4731 if (background_color.IsEmpty && background_image==null) {
4733 OnBackColorChanged(e);
4737 [EditorBrowsable(EditorBrowsableState.Advanced)]
4738 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4739 if (background_color.IsEmpty && background_image==null) {
4741 OnBackgroundImageChanged(e);
4745 [EditorBrowsable(EditorBrowsableState.Advanced)]
4746 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4747 if (binding_context==null) {
4748 binding_context=Parent.binding_context;
4749 OnBindingContextChanged(e);
4753 [EditorBrowsable(EditorBrowsableState.Advanced)]
4754 protected virtual void OnParentChanged(EventArgs e) {
4755 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4760 [EditorBrowsable(EditorBrowsableState.Advanced)]
4761 protected virtual void OnParentEnabledChanged(EventArgs e) {
4763 OnEnabledChanged(e);
4767 [EditorBrowsable(EditorBrowsableState.Advanced)]
4768 protected virtual void OnParentFontChanged(EventArgs e) {
4775 [EditorBrowsable(EditorBrowsableState.Advanced)]
4776 protected virtual void OnParentForeColorChanged(EventArgs e) {
4777 if (foreground_color.IsEmpty) {
4779 OnForeColorChanged(e);
4783 [EditorBrowsable(EditorBrowsableState.Advanced)]
4784 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4785 if (right_to_left==RightToLeft.Inherit) {
4787 OnRightToLeftChanged(e);
4791 [EditorBrowsable(EditorBrowsableState.Advanced)]
4792 protected virtual void OnParentVisibleChanged(EventArgs e) {
4794 OnVisibleChanged(e);
4798 [EditorBrowsable(EditorBrowsableState.Advanced)]
4799 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4800 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4805 [EditorBrowsable(EditorBrowsableState.Advanced)]
4806 protected virtual void OnResize(EventArgs e) {
4807 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4811 PerformLayout(this, "bounds");
4813 if (parent != null) {
4814 parent.PerformLayout();
4818 [EditorBrowsable(EditorBrowsableState.Advanced)]
4819 protected virtual void OnRightToLeftChanged(EventArgs e) {
4820 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4823 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4826 [EditorBrowsable(EditorBrowsableState.Advanced)]
4827 protected virtual void OnSizeChanged(EventArgs e) {
4828 InvalidateBuffers ();
4830 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4835 [EditorBrowsable(EditorBrowsableState.Advanced)]
4836 protected virtual void OnStyleChanged(EventArgs e) {
4837 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4842 [EditorBrowsable(EditorBrowsableState.Advanced)]
4843 protected virtual void OnSystemColorsChanged(EventArgs e) {
4844 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4849 [EditorBrowsable(EditorBrowsableState.Advanced)]
4850 protected virtual void OnTabIndexChanged(EventArgs e) {
4851 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4856 [EditorBrowsable(EditorBrowsableState.Advanced)]
4857 protected virtual void OnTabStopChanged(EventArgs e) {
4858 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4863 [EditorBrowsable(EditorBrowsableState.Advanced)]
4864 protected virtual void OnTextChanged(EventArgs e) {
4865 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4870 [EditorBrowsable(EditorBrowsableState.Advanced)]
4871 protected virtual void OnValidated(EventArgs e) {
4872 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4877 [EditorBrowsable(EditorBrowsableState.Advanced)]
4878 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4879 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4884 [EditorBrowsable(EditorBrowsableState.Advanced)]
4885 protected virtual void OnVisibleChanged(EventArgs e) {
4886 if ((parent != null) && !Created && Visible) {
4893 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4897 // We need to tell our kids
4898 for (int i=0; i<child_controls.Count; i++) {
4899 if (child_controls[i].Visible) {
4900 child_controls[i].OnParentVisibleChanged(e);
4904 #endregion // OnXXX methods
4907 static object BackColorChangedEvent = new object ();
4908 static object BackgroundImageChangedEvent = new object ();
4909 static object BindingContextChangedEvent = new object ();
4910 static object CausesValidationChangedEvent = new object ();
4911 static object ChangeUICuesEvent = new object ();
4912 static object ClickEvent = new object ();
4913 static object ContextMenuChangedEvent = new object ();
4914 static object ControlAddedEvent = new object ();
4915 static object ControlRemovedEvent = new object ();
4916 static object CursorChangedEvent = new object ();
4917 static object DockChangedEvent = new object ();
4918 static object DoubleClickEvent = new object ();
4919 static object DragDropEvent = new object ();
4920 static object DragEnterEvent = new object ();
4921 static object DragLeaveEvent = new object ();
4922 static object DragOverEvent = new object ();
4923 static object EnabledChangedEvent = new object ();
4924 static object EnterEvent = new object ();
4925 static object FontChangedEvent = new object ();
4926 static object ForeColorChangedEvent = new object ();
4927 static object GiveFeedbackEvent = new object ();
4928 static object GotFocusEvent = new object ();
4929 static object HandleCreatedEvent = new object ();
4930 static object HandleDestroyedEvent = new object ();
4931 static object HelpRequestedEvent = new object ();
4932 static object ImeModeChangedEvent = new object ();
4933 static object InvalidatedEvent = new object ();
4934 static object KeyDownEvent = new object ();
4935 static object KeyPressEvent = new object ();
4936 static object KeyUpEvent = new object ();
4937 static object LayoutEvent = new object ();
4938 static object LeaveEvent = new object ();
4939 static object LocationChangedEvent = new object ();
4940 static object LostFocusEvent = new object ();
4941 static object MouseDownEvent = new object ();
4942 static object MouseEnterEvent = new object ();
4943 static object MouseHoverEvent = new object ();
4944 static object MouseLeaveEvent = new object ();
4945 static object MouseMoveEvent = new object ();
4946 static object MouseUpEvent = new object ();
4947 static object MouseWheelEvent = new object ();
4948 static object MoveEvent = new object ();
4949 static object PaintEvent = new object ();
4950 static object ParentChangedEvent = new object ();
4951 static object QueryAccessibilityHelpEvent = new object ();
4952 static object QueryContinueDragEvent = new object ();
4953 static object ResizeEvent = new object ();
4954 static object RightToLeftChangedEvent = new object ();
4955 static object SizeChangedEvent = new object ();
4956 static object StyleChangedEvent = new object ();
4957 static object SystemColorsChangedEvent = new object ();
4958 static object TabIndexChangedEvent = new object ();
4959 static object TabStopChangedEvent = new object ();
4960 static object TextChangedEvent = new object ();
4961 static object ValidatedEvent = new object ();
4962 static object ValidatingEvent = new object ();
4963 static object VisibleChangedEvent = new object ();
4965 public event EventHandler BackColorChanged {
4966 add { Events.AddHandler (BackColorChangedEvent, value); }
4967 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4970 public event EventHandler BackgroundImageChanged {
4971 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4972 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4975 public event EventHandler BindingContextChanged {
4976 add { Events.AddHandler (BindingContextChangedEvent, value); }
4977 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4980 public event EventHandler CausesValidationChanged {
4981 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4982 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4985 public event UICuesEventHandler ChangeUICues {
4986 add { Events.AddHandler (ChangeUICuesEvent, value); }
4987 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4990 public event EventHandler Click {
4991 add { Events.AddHandler (ClickEvent, value); }
4992 remove { Events.RemoveHandler (ClickEvent, value); }
4995 public event EventHandler ContextMenuChanged {
4996 add { Events.AddHandler (ContextMenuChangedEvent, value); }
4997 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5000 [EditorBrowsable(EditorBrowsableState.Advanced)]
5002 public event ControlEventHandler ControlAdded {
5003 add { Events.AddHandler (ControlAddedEvent, value); }
5004 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5007 [EditorBrowsable(EditorBrowsableState.Advanced)]
5009 public event ControlEventHandler ControlRemoved {
5010 add { Events.AddHandler (ControlRemovedEvent, value); }
5011 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5014 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5015 public event EventHandler CursorChanged {
5016 add { Events.AddHandler (CursorChangedEvent, value); }
5017 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5019 public event EventHandler DockChanged {
5020 add { Events.AddHandler (DockChangedEvent, value); }
5021 remove { Events.RemoveHandler (DockChangedEvent, value); }
5024 public event EventHandler DoubleClick {
5025 add { Events.AddHandler (DoubleClickEvent, value); }
5026 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5029 public event DragEventHandler DragDrop {
5030 add { Events.AddHandler (DragDropEvent, value); }
5031 remove { Events.RemoveHandler (DragDropEvent, value); }
5034 public event DragEventHandler DragEnter {
5035 add { Events.AddHandler (DragEnterEvent, value); }
5036 remove { Events.RemoveHandler (DragEnterEvent, value); }
5039 public event EventHandler DragLeave {
5040 add { Events.AddHandler (DragLeaveEvent, value); }
5041 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5044 public event DragEventHandler DragOver {
5045 add { Events.AddHandler (DragOverEvent, value); }
5046 remove { Events.RemoveHandler (DragOverEvent, value); }
5049 public event EventHandler EnabledChanged {
5050 add { Events.AddHandler (EnabledChangedEvent, value); }
5051 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5054 public event EventHandler Enter {
5055 add { Events.AddHandler (EnterEvent, value); }
5056 remove { Events.RemoveHandler (EnterEvent, value); }
5059 public event EventHandler FontChanged {
5060 add { Events.AddHandler (FontChangedEvent, value); }
5061 remove { Events.RemoveHandler (FontChangedEvent, value); }
5064 public event EventHandler ForeColorChanged {
5065 add { Events.AddHandler (ForeColorChangedEvent, value); }
5066 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5069 public event GiveFeedbackEventHandler GiveFeedback {
5070 add { Events.AddHandler (GiveFeedbackEvent, value); }
5071 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5074 [EditorBrowsable(EditorBrowsableState.Advanced)]
5076 public event EventHandler GotFocus {
5077 add { Events.AddHandler (GotFocusEvent, value); }
5078 remove { Events.RemoveHandler (GotFocusEvent, value); }
5082 [EditorBrowsable(EditorBrowsableState.Advanced)]
5084 public event EventHandler HandleCreated {
5085 add { Events.AddHandler (HandleCreatedEvent, value); }
5086 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5089 [EditorBrowsable(EditorBrowsableState.Advanced)]
5091 public event EventHandler HandleDestroyed {
5092 add { Events.AddHandler (HandleDestroyedEvent, value); }
5093 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5096 public event HelpEventHandler HelpRequested {
5097 add { Events.AddHandler (HelpRequestedEvent, value); }
5098 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5101 public event EventHandler ImeModeChanged {
5102 add { Events.AddHandler (ImeModeChangedEvent, value); }
5103 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5106 [EditorBrowsable(EditorBrowsableState.Advanced)]
5108 public event InvalidateEventHandler Invalidated {
5109 add { Events.AddHandler (InvalidatedEvent, value); }
5110 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5113 public event KeyEventHandler KeyDown {
5114 add { Events.AddHandler (KeyDownEvent, value); }
5115 remove { Events.RemoveHandler (KeyDownEvent, value); }
5118 public event KeyPressEventHandler KeyPress {
5119 add { Events.AddHandler (KeyPressEvent, value); }
5120 remove { Events.RemoveHandler (KeyPressEvent, value); }
5123 public event KeyEventHandler KeyUp {
5124 add { Events.AddHandler (KeyUpEvent, value); }
5125 remove { Events.RemoveHandler (KeyUpEvent, value); }
5128 public event LayoutEventHandler Layout {
5129 add { Events.AddHandler (LayoutEvent, value); }
5130 remove { Events.RemoveHandler (LayoutEvent, value); }
5133 public event EventHandler Leave {
5134 add { Events.AddHandler (LeaveEvent, value); }
5135 remove { Events.RemoveHandler (LeaveEvent, value); }
5138 public event EventHandler LocationChanged {
5139 add { Events.AddHandler (LocationChangedEvent, value); }
5140 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5143 [EditorBrowsable(EditorBrowsableState.Advanced)]
5145 public event EventHandler LostFocus {
5146 add { Events.AddHandler (LostFocusEvent, value); }
5147 remove { Events.RemoveHandler (LostFocusEvent, value); }
5150 public event MouseEventHandler MouseDown {
5151 add { Events.AddHandler (MouseDownEvent, value); }
5152 remove { Events.RemoveHandler (MouseDownEvent, value); }
5155 public event EventHandler MouseEnter {
5156 add { Events.AddHandler (MouseEnterEvent, value); }
5157 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5160 public event EventHandler MouseHover {
5161 add { Events.AddHandler (MouseHoverEvent, value); }
5162 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5165 public event EventHandler MouseLeave {
5166 add { Events.AddHandler (MouseLeaveEvent, value); }
5167 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5170 public event MouseEventHandler MouseMove {
5171 add { Events.AddHandler (MouseMoveEvent, value); }
5172 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5175 public event MouseEventHandler MouseUp {
5176 add { Events.AddHandler (MouseUpEvent, value); }
5177 remove { Events.RemoveHandler (MouseUpEvent, value); }
5180 [EditorBrowsable(EditorBrowsableState.Advanced)]
5182 public event MouseEventHandler MouseWheel {
5183 add { Events.AddHandler (MouseWheelEvent, value); }
5184 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5187 public event EventHandler Move {
5188 add { Events.AddHandler (MoveEvent, value); }
5189 remove { Events.RemoveHandler (MoveEvent, value); }
5192 public event PaintEventHandler Paint {
5193 add { Events.AddHandler (PaintEvent, value); }
5194 remove { Events.RemoveHandler (PaintEvent, value); }
5197 public event EventHandler ParentChanged {
5198 add { Events.AddHandler (ParentChangedEvent, value); }
5199 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5202 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5203 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5204 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5207 public event QueryContinueDragEventHandler QueryContinueDrag {
5208 add { Events.AddHandler (QueryContinueDragEvent, value); }
5209 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5212 public event EventHandler Resize {
5213 add { Events.AddHandler (ResizeEvent, value); }
5214 remove { Events.RemoveHandler (ResizeEvent, value); }
5217 public event EventHandler RightToLeftChanged {
5218 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5219 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5222 public event EventHandler SizeChanged {
5223 add { Events.AddHandler (SizeChangedEvent, value); }
5224 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5227 public event EventHandler StyleChanged {
5228 add { Events.AddHandler (StyleChangedEvent, value); }
5229 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5232 public event EventHandler SystemColorsChanged {
5233 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5234 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5237 public event EventHandler TabIndexChanged {
5238 add { Events.AddHandler (TabIndexChangedEvent, value); }
5239 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5242 public event EventHandler TabStopChanged {
5243 add { Events.AddHandler (TabStopChangedEvent, value); }
5244 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5247 public event EventHandler TextChanged {
5248 add { Events.AddHandler (TextChangedEvent, value); }
5249 remove { Events.RemoveHandler (TextChangedEvent, value); }
5252 public event EventHandler Validated {
5253 add { Events.AddHandler (ValidatedEvent, value); }
5254 remove { Events.RemoveHandler (ValidatedEvent, value); }
5257 public event CancelEventHandler Validating {
5258 add { Events.AddHandler (ValidatingEvent, value); }
5259 remove { Events.RemoveHandler (ValidatingEvent, value); }
5262 public event EventHandler VisibleChanged {
5263 add { Events.AddHandler (VisibleChangedEvent, value); }
5264 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5267 #endregion // Events