1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2006 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
25 // Partially based on work by:
26 // Aleksey Ryabchuk ryabchuk@yahoo.com
27 // Alexandre Pigolkine pigolkine@gmx.de
28 // Dennis Hayes dennish@raytek.com
29 // Jaak Simm jaaksimm@firm.ee
30 // John Sohn jsohn@columbus.rr.com
39 using System.ComponentModel;
40 using System.ComponentModel.Design;
41 using System.ComponentModel.Design.Serialization;
42 using System.Collections;
43 using System.Diagnostics;
45 using System.Drawing.Drawing2D;
46 using System.Reflection;
47 using System.Runtime.InteropServices;
48 using System.Security;
49 using System.Threading;
51 namespace System.Windows.Forms
53 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
54 [DefaultProperty("Text")]
55 [DefaultEvent("Click")]
56 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
57 [ToolboxItemFilter("System.Windows.Forms")]
58 public class Control : Component, ISynchronizeInvoke, IWin32Window
60 #region Local Variables
63 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
64 Rectangle explicit_bounds; // explicitly set bounds
65 internal object creator_thread; // thread that created the control
66 internal ControlNativeWindow window; // object for native window handle
67 string name; // for object naming
70 bool is_created; // true if OnCreateControl has been sent
71 internal bool has_focus; // true if control has focus
72 internal bool is_visible; // true if control is visible
73 internal bool is_entered; // is the mouse inside the control?
74 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
75 bool is_accessible; // true if the control is visible to accessibility applications
76 bool is_captured; // tracks if the control has captured the mouse
77 internal bool is_toplevel; // tracks if the control is a toplevel window
78 bool is_recreating; // tracks if the handle for the control is being recreated
79 bool causes_validation; // tracks if validation is executed on changes
80 bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
81 int tab_index; // position in tab order of siblings
82 internal bool tab_stop; // is the control a tab stop?
83 bool is_disposed; // has the window already been disposed?
84 Size client_size; // size of the client area (window excluding decorations)
85 Rectangle client_rect; // rectangle with the client area (window excluding decorations)
86 internal ControlStyles control_style; // rather win32-specific, style bits for control
87 internal ImeMode ime_mode = ImeMode.Inherit;
88 bool layout_pending; // true if our parent needs to re-layout us
89 internal object control_tag; // object that contains data about our control
90 internal int mouse_clicks; // Counter for mouse clicks
91 internal Cursor cursor; // Cursor for the window
92 internal bool allow_drop; // true if the control accepts droping objects on it
93 Region clip_region; // User-specified clip region for the window
96 internal Color foreground_color; // foreground color for control
97 internal Color background_color; // background color for control
98 internal Image background_image; // background image for control
99 internal Font font; // font for control
100 string text; // window/title text for control
101 internal BorderStyle border_style; // Border style of control
104 int layout_suspended;
105 internal AnchorStyles anchor_style; // anchoring requirements for our control
106 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
107 // Please leave the next 4 as internal until DefaultLayout (2.0) is rewritten
108 internal int dist_left; // distance to the left border of the parent
109 internal int dist_top; // distance to the top border of the parent
110 internal int dist_right; // distance to the right border of the parent
111 internal int dist_bottom; // distance to the bottom border of the parent
113 // to be categorized...
114 static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
115 internal ControlCollection child_controls; // our children
116 Control parent; // our parent control
117 AccessibleObject accessibility_object; // object that contains accessibility information about our control
118 BindingContext binding_context;
119 internal RightToLeft right_to_left; // drawing direction for control
120 internal ContextMenu context_menu; // Context menu associated with the control
123 Graphics dc_mem; // Graphics context for double buffering
124 Bitmap bmp_mem; // Bitmap for double buffering control
125 Region invalid_region;
127 ControlBindingsCollection data_bindings;
130 internal bool use_compatible_text_rendering;
131 static bool verify_thread_handle;
137 Layout.LayoutEngine layout_engine;
140 #endregion // Local Variables
142 #region Private Classes
143 // This helper class allows us to dispatch messages to Control.WndProc
144 internal class ControlNativeWindow : NativeWindow {
145 private Control owner;
147 public ControlNativeWindow(Control control) : base() {
152 public Control Owner {
158 static internal Control ControlFromHandle(IntPtr hWnd) {
159 ControlNativeWindow window;
161 window = (ControlNativeWindow)window_collection[hWnd];
162 if (window != null) {
169 static internal Control ControlFromChildHandle (IntPtr handle) {
170 ControlNativeWindow window;
172 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
173 while (hwnd != null) {
174 window = (ControlNativeWindow)window_collection[hwnd.Handle];
175 if (window != null) {
184 protected override void WndProc(ref Message m) {
185 owner.WndProc(ref m);
190 #region Public Classes
192 public class ControlAccessibleObject : AccessibleObject {
195 #region ControlAccessibleObject Constructors
196 public ControlAccessibleObject(Control ownerControl)
197 : base (ownerControl)
199 this.owner = ownerControl;
201 #endregion // ControlAccessibleObject Constructors
203 #region ControlAccessibleObject Public Instance Properties
204 public override string DefaultAction {
206 return base.DefaultAction;
210 public override string Description {
212 return base.Description;
216 public IntPtr Handle {
222 // We don't want to let them set it
226 public override string Help {
232 public override string KeyboardShortcut {
234 return base.KeyboardShortcut;
238 public override string Name {
248 public Control Owner {
254 public override AccessibleObject Parent {
261 public override AccessibleRole Role {
266 #endregion // ControlAccessibleObject Public Instance Properties
268 #region ControlAccessibleObject Public Instance Methods
269 public override int GetHelpTopic(out string FileName) {
270 return base.GetHelpTopic (out FileName);
273 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
274 public void NotifyClients(AccessibleEvents accEvent) {
275 throw new NotImplementedException();
278 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
279 public void NotifyClients(AccessibleEvents accEvent, int childID) {
280 throw new NotImplementedException();
283 public override string ToString() {
284 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
287 #endregion // ControlAccessibleObject Public Instance Methods
290 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
291 [ListBindable(false)]
292 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
293 #region ControlCollection Local Variables
296 Control[] all_controls;
298 #endregion // ControlCollection Local Variables
300 #region ControlCollection Public Constructor
301 public ControlCollection(Control owner) {
303 this.list=new ArrayList();
307 #region ControlCollection Public Instance Properties
314 public bool IsReadOnly {
316 return list.IsReadOnly;
320 public virtual Control this[int index] {
322 if (index < 0 || index >= list.Count) {
323 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
325 return (Control)list[index];
328 #endregion // ControlCollection Public Instance Properties
330 #region ControlCollection Private Instance Methods
331 public virtual void Add (Control value)
336 if (Contains (value)) {
337 owner.PerformLayout();
341 if (value.tab_index == -1) {
347 end = owner.child_controls.Count;
348 for (int i = 0; i < end; i++) {
349 index = owner.child_controls[i].tab_index;
354 value.tab_index = use;
357 if (value.parent != null) {
358 value.parent.Controls.Remove(value);
364 value.ChangeParent(owner);
368 owner.UpdateChildrenZOrder();
369 owner.PerformLayout(value, "Parent");
370 owner.OnControlAdded(new ControlEventArgs(value));
373 internal void AddToList (Control c)
379 internal virtual void AddImplicit (Control control)
381 if (impl_list == null)
382 impl_list = new ArrayList ();
384 if (AllContains (control))
388 impl_list.Add (control);
390 control.ChangeParent (owner);
391 control.InitLayout ();
392 owner.UpdateChildrenZOrder ();
393 owner.PerformLayout (control, "Parent");
394 owner.OnControlAdded (new ControlEventArgs (control));
397 public virtual void AddRange (Control[] controls)
399 if (controls == null)
400 throw new ArgumentNullException ("controls");
402 owner.SuspendLayout ();
405 for (int i = 0; i < controls.Length; i++)
408 owner.ResumeLayout ();
412 internal virtual void AddRangeImplicit (Control [] controls)
414 if (controls == null)
415 throw new ArgumentNullException ("controls");
417 owner.SuspendLayout ();
420 for (int i = 0; i < controls.Length; i++)
421 AddImplicit (controls [i]);
423 owner.ResumeLayout ();
427 public virtual void Clear ()
431 // MS sends remove events in reverse order
432 while (list.Count > 0) {
433 Remove((Control)list[list.Count - 1]);
437 internal virtual void ClearImplicit ()
439 if (impl_list == null)
445 public bool Contains (Control value)
447 for (int i = list.Count; i > 0; ) {
450 if (list [i] == value) {
451 // Do we need to do anything here?
458 internal bool ImplicitContains (Control value)
460 if (impl_list == null)
463 for (int i = impl_list.Count; i > 0; ) {
466 if (impl_list [i] == value) {
467 // Do we need to do anything here?
474 internal bool AllContains (Control value)
476 return Contains (value) || ImplicitContains (value);
479 public void CopyTo (Array array, int index)
481 list.CopyTo(array, index);
484 public override bool Equals(object other) {
485 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
492 public int GetChildIndex(Control child) {
493 return GetChildIndex(child, false);
496 public int GetChildIndex(Control child, bool throwException) {
499 index=list.IndexOf(child);
501 if (index==-1 && throwException) {
502 throw new ArgumentException("Not a child control", "child");
507 public IEnumerator GetEnumerator() {
508 return list.GetEnumerator();
511 internal IEnumerator GetAllEnumerator ()
513 Control [] res = GetAllControls ();
514 return res.GetEnumerator ();
517 internal Control [] GetAllControls ()
519 if (all_controls != null)
522 if (impl_list == null) {
523 all_controls = (Control []) list.ToArray (typeof (Control));
527 all_controls = new Control [list.Count + impl_list.Count];
528 impl_list.CopyTo (all_controls);
529 list.CopyTo (all_controls, impl_list.Count);
534 public override int GetHashCode() {
535 return base.GetHashCode();
538 public int IndexOf(Control control) {
539 return list.IndexOf(control);
542 public virtual void Remove(Control value) {
543 owner.PerformLayout(value, "Parent");
544 owner.OnControlRemoved(new ControlEventArgs(value));
549 value.ChangeParent(null);
551 owner.UpdateChildrenZOrder();
554 internal virtual void RemoveImplicit (Control control)
556 if (impl_list != null) {
558 owner.PerformLayout (control, "Parent");
559 owner.OnControlRemoved (new ControlEventArgs (control));
560 impl_list.Remove (control);
562 control.ChangeParent (null);
563 owner.UpdateChildrenZOrder ();
566 public void RemoveAt(int index) {
567 if (index < 0 || index >= list.Count) {
568 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
570 Remove ((Control)list[index]);
573 public void SetChildIndex(Control child, int newIndex) {
576 old_index=list.IndexOf(child);
578 throw new ArgumentException("Not a child control", "child");
581 if (old_index==newIndex) {
586 list.RemoveAt(old_index);
588 if (newIndex>list.Count) {
591 list.Insert(newIndex, child);
593 child.UpdateZOrder();
594 owner.PerformLayout();
596 #endregion // ControlCollection Private Instance Methods
598 #region ControlCollection Interface Properties
599 object IList.this[int index] {
601 if (index<0 || index>=list.Count) {
602 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
608 if (!(value is Control)) {
609 throw new ArgumentException("Object of type Control required", "value");
613 Control ctrl = (Control) value;
616 ctrl.ChangeParent(owner);
620 owner.UpdateChildrenZOrder();
621 owner.PerformLayout(ctrl, "Parent");
625 bool IList.IsFixedSize {
631 bool ICollection.IsSynchronized {
633 return list.IsSynchronized;
637 object ICollection.SyncRoot {
639 return list.SyncRoot;
642 #endregion // ControlCollection Interface Properties
644 #region ControlCollection Interface Methods
645 int IList.Add(object value) {
647 throw new ArgumentNullException("value", "Cannot add null controls");
650 if (!(value is Control)) {
651 throw new ArgumentException("Object of type Control required", "value");
654 return list.Add(value);
657 bool IList.Contains(object value) {
658 if (!(value is Control)) {
659 throw new ArgumentException("Object of type Control required", "value");
662 return this.Contains((Control) value);
665 int IList.IndexOf(object value) {
666 if (!(value is Control)) {
667 throw new ArgumentException("Object of type Control required", "value");
670 return this.IndexOf((Control) value);
673 void IList.Insert(int index, object value) {
674 if (!(value is Control)) {
675 throw new ArgumentException("Object of type Control required", "value");
678 list.Insert(index, value);
681 void IList.Remove(object value) {
682 if (!(value is Control)) {
683 throw new ArgumentException("Object of type Control required", "value");
689 Object ICloneable.Clone() {
690 ControlCollection clone = new ControlCollection(this.owner);
691 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
694 #endregion // ControlCollection Interface Methods
696 #endregion // ControlCollection Class
698 #region Public Constructors
701 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
709 layout_pending = false;
711 causes_validation = true;
713 layout_suspended = 0;
717 right_to_left = RightToLeft.Inherit;
718 border_style = BorderStyle.None;
719 background_color = Color.Empty;
727 use_compatible_text_rendering = Application.use_compatible_text_rendering;
728 padding = new Padding(0);
729 maximum_size = new Size();
730 minimum_size = new Size();
731 preferred_size = new Size();
732 margin = this.DefaultMargin;
733 layout_engine = this.LayoutEngine;
736 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
737 ControlStyles.Selectable | ControlStyles.StandardClick |
738 ControlStyles.StandardDoubleClick;
740 control_style |= ControlStyles.UseTextForAccessibility;
744 background_image = null;
748 window = new ControlNativeWindow(this);
749 child_controls = CreateControlsInstance();
750 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
751 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
752 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
753 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
759 public Control(Control parent, string text) : this() {
764 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
769 bounds.Height=height;
770 SetBounds(left, top, width, height, BoundsSpecified.All);
774 public Control(string text) : this() {
778 public Control(string text, int left, int top, int width, int height) : this() {
782 bounds.Height=height;
783 SetBounds(left, top, width, height, BoundsSpecified.All);
787 private delegate void RemoveDelegate(object c);
789 protected override void Dispose(bool disposing) {
790 if (!is_disposed && disposing) {
803 if (invalid_region!=null) {
804 invalid_region.Dispose();
807 if (this.InvokeRequired) {
808 if (Application.MessageLoop) {
809 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
810 this.BeginInvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
814 lock (Control.controls) {
815 Control.controls.Remove(this);
820 if (parent != null) {
821 parent.Controls.Remove(this);
824 Control [] children = child_controls.GetAllControls ();
825 for (int i=0; i<children.Length; i++) {
826 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
827 children[i].Dispose();
832 base.Dispose(disposing);
834 #endregion // Public Constructors
836 #region Internal Properties
837 internal BorderStyle InternalBorderStyle {
843 if (!Enum.IsDefined (typeof (BorderStyle), value))
844 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
846 if (border_style != value) {
847 border_style = value;
849 if (IsHandleCreated) {
850 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
856 #endregion // Internal Properties
858 #region Private & Internal Methods
859 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
860 AsyncMethodResult result;
861 AsyncMethodData data;
868 if (!p.IsHandleCreated) {
869 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
875 result = new AsyncMethodResult ();
876 data = new AsyncMethodData ();
878 data.Handle = window.Handle;
879 data.Method = method;
881 data.Result = result;
884 if (!ExecutionContext.IsFlowSuppressed ()) {
885 data.Context = ExecutionContext.Capture ();
888 #if !MWF_ON_MSRUNTIME
889 if (SecurityManager.SecurityEnabled) {
890 data.Stack = CompressedStack.GetCompressedStack ();
895 XplatUI.SendAsyncMethod (data);
900 internal void PointToClient (ref int x, ref int y)
902 XplatUI.ScreenToClient (Handle, ref x, ref y);
905 internal void PointToScreen (ref int x, ref int y)
907 XplatUI.ClientToScreen (Handle, ref x, ref y);
910 internal bool IsRecreating {
912 return is_recreating;
916 internal Graphics DeviceContext {
918 if (dc_mem == null) {
919 CreateBuffers(this.Width, this.Height);
925 private void ImageBufferNeedsRedraw () {
926 if (invalid_region != null)
927 invalid_region.Dispose();
928 invalid_region = new Region (ClientRectangle);
931 private Bitmap ImageBuffer {
934 CreateBuffers(this.Width, this.Height);
940 internal void CreateBuffers (int width, int height) {
949 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
950 dc_mem = Graphics.FromImage (bmp_mem);
951 ImageBufferNeedsRedraw ();
954 internal void InvalidateBuffers ()
956 if (dc_mem != null) {
962 ImageBufferNeedsRedraw ();
965 internal static void SetChildColor(Control parent) {
968 for (int i=0; i < parent.child_controls.Count; i++) {
969 child=parent.child_controls[i];
970 if (child.child_controls.Count>0) {
971 SetChildColor(child);
977 internal bool Select(Control control) {
978 IContainerControl container;
980 if (control == null) {
984 container = GetContainerControl();
985 if (container != null) {
986 container.ActiveControl = control;
988 if (control.IsHandleCreated) {
989 XplatUI.SetFocus(control.window.Handle);
994 internal void SelectChild (Control control)
996 if (control.IsHandleCreated)
997 XplatUI.SetFocus (control.window.Handle);
1000 internal virtual void DoDefaultAction() {
1001 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1004 internal static int LowOrder (int param) {
1005 return ((int)(short)(param & 0xffff));
1008 internal static int HighOrder (int param) {
1009 return ((int)(short)(param >> 16));
1012 // This method exists so controls overriding OnPaintBackground can have default background painting done
1013 internal virtual void PaintControlBackground (PaintEventArgs pevent)
1015 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1016 if (parent != null) {
1017 PaintEventArgs parent_pe;
1018 GraphicsState state;
1020 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1022 state = parent_pe.Graphics.Save();
1023 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1024 parent.OnPaintBackground(parent_pe);
1025 parent_pe.Graphics.Restore(state);
1027 state = parent_pe.Graphics.Save();
1028 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1029 parent.OnPaint(parent_pe);
1030 parent_pe.Graphics.Restore(state);
1031 parent_pe.SetGraphics(null);
1035 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1036 if (parent != null) {
1037 PaintEventArgs parent_pe;
1039 GraphicsState state;
1042 hwnd = Hwnd.ObjectFromHandle(Handle);
1045 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1047 region = new Region ();
1049 region.Union(ClientRectangle);
1051 foreach (Rectangle r in hwnd.ClipRectangles) {
1055 state = parent_pe.Graphics.Save();
1056 parent_pe.Graphics.Clip = region;
1058 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1059 parent.OnPaintBackground(parent_pe);
1060 parent_pe.Graphics.Restore(state);
1062 state = parent_pe.Graphics.Save();
1063 parent_pe.Graphics.Clip = region;
1065 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1066 parent.OnPaint(parent_pe);
1067 parent_pe.Graphics.Restore(state);
1068 parent_pe.SetGraphics(null);
1070 region.Intersect(clip_region);
1071 pevent.Graphics.Clip = region;
1076 if (background_image == null) {
1077 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));
1081 DrawBackgroundImage (pevent.Graphics);
1084 void DrawBackgroundImage (Graphics g)
1086 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1087 g.FillRectangle (b, ClientRectangle);
1091 internal virtual void DndEnter (DragEventArgs e)
1098 internal virtual void DndOver (DragEventArgs e)
1105 internal virtual void DndDrop (DragEventArgs e)
1109 } catch (Exception exc) {
1110 Console.Error.WriteLine ("MWF: Exception while dropping:");
1111 Console.Error.WriteLine (exc);
1115 internal virtual void DndLeave (EventArgs e)
1122 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1129 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1132 OnQueryContinueDrag(e);
1136 internal static MouseButtons FromParamToMouseButtons (int param) {
1137 MouseButtons buttons = MouseButtons.None;
1139 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1140 buttons |= MouseButtons.Left;
1142 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1143 buttons |= MouseButtons.Middle;
1145 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1146 buttons |= MouseButtons.Right;
1152 internal void FireEnter ()
1154 OnEnter (EventArgs.Empty);
1157 internal void FireLeave ()
1159 OnLeave (EventArgs.Empty);
1162 internal void FireValidating (CancelEventArgs ce)
1167 internal void FireValidated ()
1169 OnValidated (EventArgs.Empty);
1172 internal virtual bool ProcessControlMnemonic(char charCode) {
1173 return ProcessMnemonic(charCode);
1176 private static Control FindFlatForward(Control container, Control start) {
1182 end = container.child_controls.Count;
1184 if (start != null) {
1185 index = start.tab_index;
1191 for (int i = 0, pos = -1; i < end; i++) {
1192 if (start == container.child_controls[i]) {
1197 if (found == null) {
1198 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1199 found = container.child_controls[i];
1201 } else if (found.tab_index > container.child_controls[i].tab_index) {
1202 if (container.child_controls[i].tab_index > index) {
1203 found = container.child_controls[i];
1210 private static Control FindControlForward(Control container, Control start) {
1215 if (start == null) {
1216 return FindFlatForward(container, start);
1219 if (start.child_controls != null && start.child_controls.Count > 0 &&
1220 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1221 return FindControlForward(start, null);
1224 while (start != container) {
1225 found = FindFlatForward(start.parent, start);
1226 if (found != null) {
1229 start = start.parent;
1235 private static Control FindFlatBackward(Control container, Control start) {
1241 end = container.child_controls.Count;
1243 if (start != null) {
1244 index = start.tab_index;
1246 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1248 for (int i = 0; i < end; i++) {
1249 if (container.child_controls[i].tab_index > index) {
1250 index = container.child_controls[i].tab_index;
1258 for (int i = end - 1; i >= 0; i--) {
1259 if (start == container.child_controls[i]) {
1264 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1265 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1266 found = container.child_controls[i];
1273 private static Control FindControlBackward(Control container, Control start) {
1275 Control found = null;
1277 if (start == null) {
1278 found = FindFlatBackward(container, start);
1280 else if (start != container) {
1281 if (start.parent != null) {
1282 found = FindFlatBackward(start.parent, start);
1284 if (found == null) {
1285 if (start.parent != container)
1286 return start.parent;
1292 if (found == null || start.parent == null)
1295 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1296 found.child_controls != null && found.child_controls.Count > 0)) {
1297 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1298 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1299 found = FindFlatBackward(found, null);
1309 if (start != null) {
1310 found = FindFlatBackward(start.parent, start);
1311 if (found == null) {
1312 if (start.parent != container) {
1313 return start.parent;
1317 if (found == null) {
1318 found = FindFlatBackward(container, start);
1321 if (container != start) {
1322 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1323 found = FindControlBackward(found, null);
1324 if (found != null) {
1333 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1334 if (GetStyle(ControlStyles.StandardClick)) {
1335 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1337 OnDoubleClick(EventArgs.Empty);
1339 OnClick(EventArgs.Empty);
1349 private void CheckDataBindings ()
1351 if (data_bindings == null)
1354 BindingContext binding_context = BindingContext;
1355 foreach (Binding binding in data_bindings) {
1356 binding.Check (binding_context);
1361 private void ChangeParent(Control new_parent) {
1365 Color pre_fore_color;
1366 Color pre_back_color;
1367 RightToLeft pre_rtl;
1369 // These properties are inherited from our parent
1370 // Get them pre parent-change and then send events
1371 // if they are changed after we have our new parent
1372 pre_enabled = Enabled;
1373 pre_visible = Visible;
1375 pre_fore_color = ForeColor;
1376 pre_back_color = BackColor;
1377 pre_rtl = RightToLeft;
1378 // MS doesn't seem to send a CursorChangedEvent
1380 parent = new_parent;
1382 if (IsHandleCreated)
1383 XplatUI.SetParent(Handle,
1384 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1386 OnParentChanged(EventArgs.Empty);
1388 if (pre_enabled != Enabled) {
1389 OnEnabledChanged(EventArgs.Empty);
1392 if (pre_visible != Visible) {
1393 OnVisibleChanged(EventArgs.Empty);
1396 if (pre_font != Font) {
1397 OnFontChanged(EventArgs.Empty);
1400 if (pre_fore_color != ForeColor) {
1401 OnForeColorChanged(EventArgs.Empty);
1404 if (pre_back_color != BackColor) {
1405 OnBackColorChanged(EventArgs.Empty);
1408 if (pre_rtl != RightToLeft) {
1409 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1410 // because when RTL changes they have to recreate the win32 control
1411 // We don't really need that (until someone runs into compatibility issues)
1412 OnRightToLeftChanged(EventArgs.Empty);
1415 if ((new_parent != null) && new_parent.Created && !Created) {
1419 if ((binding_context == null) && Created) {
1420 OnBindingContextChanged(EventArgs.Empty);
1424 private void UpdateDistances() {
1425 if ((parent != null) && (parent.layout_suspended == 0)) {
1426 dist_left = bounds.X;
1427 dist_top = bounds.Y;
1428 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1429 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1432 #endregion // Private & Internal Methods
1434 #region Public Static Properties
1435 public static Color DefaultBackColor {
1437 return ThemeEngine.Current.DefaultControlBackColor;
1441 public static Font DefaultFont {
1443 return ThemeEngine.Current.DefaultFont;
1447 public static Color DefaultForeColor {
1449 return ThemeEngine.Current.DefaultControlForeColor;
1453 public static Keys ModifierKeys {
1455 return XplatUI.State.ModifierKeys;
1459 public static MouseButtons MouseButtons {
1461 return XplatUI.State.MouseButtons;
1465 public static Point MousePosition {
1467 return Cursor.Position;
1473 public static bool CheckForIllegalCrossThreadCalls
1476 return verify_thread_handle;
1480 verify_thread_handle = value;
1484 #endregion // Public Static Properties
1486 #region Public Instance Properties
1487 [EditorBrowsable(EditorBrowsableState.Advanced)]
1489 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1490 public AccessibleObject AccessibilityObject {
1492 if (accessibility_object==null) {
1493 accessibility_object=CreateAccessibilityInstance();
1495 return accessibility_object;
1499 [EditorBrowsable(EditorBrowsableState.Advanced)]
1501 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1502 public string AccessibleDefaultActionDescription {
1504 return AccessibilityObject.default_action;
1508 AccessibilityObject.default_action=value;
1513 [DefaultValue(null)]
1514 [MWFCategory("Accessibility")]
1515 public string AccessibleDescription {
1517 return AccessibilityObject.description;
1521 AccessibilityObject.description=value;
1526 [DefaultValue(null)]
1527 [MWFCategory("Accessibility")]
1528 public string AccessibleName {
1530 return AccessibilityObject.Name;
1534 AccessibilityObject.Name=value;
1538 [DefaultValue(AccessibleRole.Default)]
1539 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1540 public AccessibleRole AccessibleRole {
1542 return AccessibilityObject.role;
1546 AccessibilityObject.role=value;
1550 [DefaultValue(false)]
1551 [MWFCategory("Behavior")]
1552 public virtual bool AllowDrop {
1558 if (allow_drop == value)
1561 if (IsHandleCreated) {
1563 XplatUI.SetAllowDrop (Handle, value);
1569 [RefreshProperties(RefreshProperties.Repaint)]
1570 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1571 [MWFCategory("Layout")]
1572 public virtual AnchorStyles Anchor {
1574 return anchor_style;
1580 if (parent != null) {
1581 parent.PerformLayout(this, "Parent");
1587 // XXX: Implement me!
1590 public virtual bool AutoSize {
1592 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1596 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1601 public virtual Size MaximumSize {
1603 return maximum_size;
1606 maximum_size = value;
1610 public virtual Size MinimumSize {
1612 return minimum_size;
1615 minimum_size = value;
1621 [MWFCategory("Appearance")]
1622 public virtual Color BackColor {
1624 if (background_color.IsEmpty) {
1626 Color pcolor = parent.BackColor;
1627 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1630 return DefaultBackColor;
1632 return background_color;
1636 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1637 throw new ArgumentException("Transparent background colors are not supported on this control");
1640 if (background_color != value) {
1641 background_color=value;
1642 SetChildColor(this);
1643 OnBackColorChanged(EventArgs.Empty);
1650 [DefaultValue(null)]
1651 [MWFCategory("Appearance")]
1652 public virtual Image BackgroundImage {
1654 return background_image;
1658 if (background_image!=value) {
1659 background_image=value;
1660 OnBackgroundImageChanged(EventArgs.Empty);
1665 [EditorBrowsable(EditorBrowsableState.Advanced)]
1667 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1668 public virtual BindingContext BindingContext {
1670 if (binding_context != null)
1671 return binding_context;
1674 binding_context = Parent.BindingContext;
1675 return binding_context;
1678 if (binding_context != value) {
1679 binding_context = value;
1680 OnBindingContextChanged(EventArgs.Empty);
1685 [EditorBrowsable(EditorBrowsableState.Advanced)]
1687 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1690 return bounds.Y+bounds.Height;
1694 [EditorBrowsable(EditorBrowsableState.Advanced)]
1696 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1697 public Rectangle Bounds {
1703 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1707 [EditorBrowsable(EditorBrowsableState.Advanced)]
1709 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1710 public bool CanFocus {
1712 if (IsHandleCreated && Visible && Enabled) {
1719 [EditorBrowsable(EditorBrowsableState.Advanced)]
1721 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1722 public bool CanSelect {
1726 if (!GetStyle(ControlStyles.Selectable)) {
1731 while (parent != null) {
1732 if (!parent.is_visible || !parent.is_enabled) {
1736 parent = parent.parent;
1742 internal virtual bool InternalCapture {
1752 [EditorBrowsable(EditorBrowsableState.Advanced)]
1754 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1755 public bool Capture {
1757 return this.is_captured;
1761 if (this.IsHandleCreated && value != is_captured) {
1764 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1766 XplatUI.UngrabWindow(this.window.Handle);
1767 is_captured = false;
1773 [DefaultValue(true)]
1774 [MWFCategory("Focus")]
1775 public bool CausesValidation {
1777 return this.causes_validation;
1781 if (this.causes_validation != value) {
1782 causes_validation = value;
1783 OnCausesValidationChanged(EventArgs.Empty);
1788 [EditorBrowsable(EditorBrowsableState.Advanced)]
1790 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1791 public Rectangle ClientRectangle {
1793 client_rect.Width = client_size.Width;
1794 client_rect.Height = client_size.Height;
1799 [EditorBrowsable(EditorBrowsableState.Advanced)]
1801 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1802 public Size ClientSize {
1805 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1806 return ((Form)this).form_parent_window.ClientSize;
1814 this.SetClientSizeCore(value.Width, value.Height);
1818 [EditorBrowsable(EditorBrowsableState.Advanced)]
1820 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1821 [DescriptionAttribute("ControlCompanyNameDescr")]
1822 public String CompanyName {
1824 return "Mono Project, Novell, Inc.";
1828 [EditorBrowsable(EditorBrowsableState.Advanced)]
1830 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1831 public bool ContainsFocus {
1833 IntPtr focused_window;
1835 focused_window = XplatUI.GetFocus();
1836 if (IsHandleCreated) {
1837 if (focused_window == Handle) {
1841 for (int i=0; i < child_controls.Count; i++) {
1842 if (child_controls[i].ContainsFocus) {
1851 [DefaultValue(null)]
1852 [MWFCategory("Behavior")]
1853 public virtual ContextMenu ContextMenu {
1855 return context_menu;
1859 if (context_menu != value) {
1860 context_menu = value;
1861 OnContextMenuChanged(EventArgs.Empty);
1867 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1868 public ControlCollection Controls {
1870 return this.child_controls;
1874 [EditorBrowsable(EditorBrowsableState.Advanced)]
1876 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1877 public bool Created {
1879 return (!is_disposed && is_created);
1883 [AmbientValue(null)]
1884 [MWFCategory("Appearance")]
1885 public virtual Cursor Cursor {
1887 if (cursor != null) {
1891 if (parent != null) {
1892 return parent.Cursor;
1895 return Cursors.Default;
1899 if (cursor != value) {
1904 if (IsHandleCreated) {
1905 pt = Cursor.Position;
1907 if (bounds.Contains(pt) || Capture) {
1908 if (GetChildAtPoint(pt) == null) {
1909 if (cursor != null) {
1910 XplatUI.SetCursor(window.Handle, cursor.handle);
1912 if (parent != null) {
1913 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1915 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1922 OnCursorChanged(EventArgs.Empty);
1928 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1929 [ParenthesizePropertyName(true)]
1930 [RefreshProperties(RefreshProperties.All)]
1931 [MWFCategory("Data")]
1932 public ControlBindingsCollection DataBindings {
1934 if (data_bindings == null)
1935 data_bindings = new ControlBindingsCollection (this);
1936 return data_bindings;
1940 [EditorBrowsable(EditorBrowsableState.Advanced)]
1942 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1943 public virtual Rectangle DisplayRectangle {
1945 return ClientRectangle;
1949 [EditorBrowsable(EditorBrowsableState.Advanced)]
1951 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1952 public bool Disposing {
1959 [RefreshProperties(RefreshProperties.Repaint)]
1960 [DefaultValue(DockStyle.None)]
1961 [MWFCategory("Layout")]
1962 public virtual DockStyle Dock {
1968 if (dock_style == value) {
1974 if (dock_style == DockStyle.None) {
1975 if (explicit_bounds == Rectangle.Empty)
1976 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1978 Bounds = explicit_bounds;
1981 if (parent != null) {
1982 parent.PerformLayout(this, "Parent");
1985 OnDockChanged(EventArgs.Empty);
1991 [MWFCategory("Behavior")]
1992 public bool Enabled {
1998 if (parent != null) {
1999 return parent.Enabled;
2007 bool old_value = is_enabled;
2010 if (old_value != value && !value && this.has_focus)
2011 SelectNextControl(this, true, true, true, true);
2013 OnEnabledChanged (EventArgs.Empty);
2017 [EditorBrowsable(EditorBrowsableState.Advanced)]
2019 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2020 public virtual bool Focused {
2022 return this.has_focus;
2027 [AmbientValue(null)]
2029 [MWFCategory("Appearance")]
2030 public virtual Font Font {
2036 if (Parent != null && Parent.Font != null) {
2043 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2045 if (font != null && font.Equals (value)) {
2051 OnFontChanged (EventArgs.Empty);
2056 [MWFCategory("Appearance")]
2057 public virtual Color ForeColor {
2059 if (foreground_color.IsEmpty) {
2061 return parent.ForeColor;
2063 return DefaultForeColor;
2065 return foreground_color;
2069 if (foreground_color != value) {
2070 foreground_color=value;
2072 OnForeColorChanged(EventArgs.Empty);
2079 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2080 public IntPtr Handle { // IWin32Window
2083 if (verify_thread_handle) {
2084 if (this.InvokeRequired) {
2085 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2089 if (!IsHandleCreated) {
2092 return window.Handle;
2096 [EditorBrowsable(EditorBrowsableState.Advanced)]
2098 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2099 public bool HasChildren {
2101 if (this.child_controls.Count>0) {
2108 [EditorBrowsable(EditorBrowsableState.Always)]
2110 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2113 return this.bounds.Height;
2117 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2121 [AmbientValue(ImeMode.Inherit)]
2123 [MWFCategory("Behavior")]
2124 public ImeMode ImeMode {
2126 if (ime_mode == DefaultImeMode) {
2128 return parent.ImeMode;
2130 return ImeMode.NoControl; // default value
2136 if (ime_mode != value) {
2139 OnImeModeChanged(EventArgs.Empty);
2144 [EditorBrowsable(EditorBrowsableState.Advanced)]
2146 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2147 public bool InvokeRequired { // ISynchronizeInvoke
2149 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2156 [EditorBrowsable(EditorBrowsableState.Advanced)]
2158 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2159 public bool IsAccessible {
2161 return is_accessible;
2165 is_accessible = value;
2169 [EditorBrowsable(EditorBrowsableState.Advanced)]
2171 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2172 public bool IsDisposed {
2174 return this.is_disposed;
2178 [EditorBrowsable(EditorBrowsableState.Advanced)]
2180 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2181 public bool IsHandleCreated {
2183 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2184 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2185 if (hwnd != null && !hwnd.zombie)
2194 public virtual Layout.LayoutEngine LayoutEngine {
2195 get { return new Layout.DefaultLayout (); }
2199 [EditorBrowsable(EditorBrowsableState.Always)]
2201 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2204 return this.bounds.X;
2208 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2213 [MWFCategory("Layout")]
2214 public Point Location {
2216 return new Point(bounds.X, bounds.Y);
2220 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2225 [Localizable (true)]
2226 public Padding Margin {
2227 get { return this.margin; }
2228 set { this.margin = value; }
2233 public string Name {
2245 public Padding Padding {
2257 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2258 public Control Parent {
2264 if (value == this) {
2265 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2268 if (parent!=value) {
2270 parent.Controls.Remove(this);
2275 value.Controls.Add(this);
2280 [EditorBrowsable(EditorBrowsableState.Advanced)]
2282 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2283 public string ProductName {
2285 Type t = typeof (AssemblyProductAttribute);
2286 Assembly assembly = GetType().Module.Assembly;
2287 object [] attrs = assembly.GetCustomAttributes (t, false);
2288 AssemblyProductAttribute a = null;
2289 // On MS we get a NullRefException if product attribute is not
2291 if (attrs != null && attrs.Length > 0)
2292 a = (AssemblyProductAttribute) attrs [0];
2297 [EditorBrowsable(EditorBrowsableState.Advanced)]
2299 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2300 public string ProductVersion {
2302 Type t = typeof (AssemblyVersionAttribute);
2303 Assembly assembly = GetType().Module.Assembly;
2304 object [] attrs = assembly.GetCustomAttributes (t, false);
2305 if (attrs == null || attrs.Length < 1)
2307 return ((AssemblyVersionAttribute)attrs [0]).Version;
2311 [EditorBrowsable(EditorBrowsableState.Advanced)]
2313 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2314 public bool RecreatingHandle {
2316 return is_recreating;
2320 [EditorBrowsable(EditorBrowsableState.Advanced)]
2322 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2323 public Region Region {
2329 if (IsHandleCreated) {
2330 XplatUI.SetClipRegion(Handle, value);
2332 clip_region = value;
2336 [EditorBrowsable(EditorBrowsableState.Advanced)]
2338 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2341 return this.bounds.X+this.bounds.Width;
2345 [AmbientValue(RightToLeft.Inherit)]
2347 [MWFCategory("Appearance")]
2348 public virtual RightToLeft RightToLeft {
2350 if (right_to_left == RightToLeft.Inherit) {
2352 return parent.RightToLeft;
2354 return RightToLeft.No; // default value
2356 return right_to_left;
2360 if (value != right_to_left) {
2361 right_to_left = value;
2362 OnRightToLeftChanged(EventArgs.Empty);
2367 [EditorBrowsable(EditorBrowsableState.Advanced)]
2368 public override ISite Site {
2376 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2378 BackColor = ap.BackColor;
2379 ForeColor = ap.ForeColor;
2387 [MWFCategory("Layout")]
2390 return new Size(Width, Height);
2394 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2399 [MergableProperty(false)]
2400 [MWFCategory("Behavior")]
2401 public int TabIndex {
2403 if (tab_index != -1) {
2410 if (tab_index != value) {
2412 OnTabIndexChanged(EventArgs.Empty);
2418 [DefaultValue(true)]
2419 [MWFCategory("Behavior")]
2420 public bool TabStop {
2426 if (tab_stop != value) {
2428 OnTabStopChanged(EventArgs.Empty);
2433 [Localizable(false)]
2435 [TypeConverter(typeof(StringConverter))]
2436 [DefaultValue(null)]
2437 [MWFCategory("Data")]
2444 control_tag = value;
2450 [BindableAttribute(true)]
2451 [MWFCategory("Appearance")]
2452 public virtual string Text {
2454 // Our implementation ignores ControlStyles.CacheText - we always cache
2459 if (value == null) {
2460 value = String.Empty;
2465 if (IsHandleCreated) {
2466 /* we need to call .SetWindowStyle here instead of just .Text
2467 because the presence/absence of Text (== "" or not) can cause
2468 other window style things to appear/disappear */
2469 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2470 XplatUI.Text(Handle, text);
2472 OnTextChanged (EventArgs.Empty);
2477 [EditorBrowsable(EditorBrowsableState.Always)]
2479 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2482 return this.bounds.Y;
2486 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2490 [EditorBrowsable(EditorBrowsableState.Advanced)]
2492 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2493 public Control TopLevelControl {
2497 while (p.parent != null) {
2501 return p is Form ? p : null;
2506 [MWFCategory("Behavior")]
2507 public bool Visible {
2511 } else if (parent != null) {
2512 return parent.Visible;
2519 SetVisibleCore(value);
2523 [EditorBrowsable(EditorBrowsableState.Always)]
2525 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2528 return this.bounds.Width;
2532 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2536 [EditorBrowsable(EditorBrowsableState.Never)]
2538 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2539 public IWindowTarget WindowTarget {
2548 #endregion // Public Instance Properties
2550 #region Protected Instance Properties
2551 protected virtual CreateParams CreateParams {
2553 CreateParams create_params = new CreateParams();
2556 create_params.Caption = Text;
2559 create_params.Caption = text;
2563 create_params.X = Left;
2566 create_params.X = this.bounds.X;
2570 create_params.Y = Top;
2573 create_params.Y = this.bounds.Y;
2577 create_params.Width = Width;
2580 create_params.Width = this.bounds.Width;
2584 create_params.Height = Height;
2587 create_params.Height = this.bounds.Height;
2591 create_params.ClassName = XplatUI.DefaultClassName;
2592 create_params.ClassStyle = 0;
2593 create_params.ExStyle = 0;
2594 create_params.Param = 0;
2597 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2600 if ((parent!=null) && (parent.IsHandleCreated)) {
2601 create_params.Parent = parent.Handle;
2604 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2607 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2611 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2614 switch (border_style) {
2615 case BorderStyle.FixedSingle:
2616 create_params.Style |= (int) WindowStyles.WS_BORDER;
2618 case BorderStyle.Fixed3D:
2619 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2623 return create_params;
2627 protected virtual ImeMode DefaultImeMode {
2629 return ImeMode.Inherit;
2634 protected virtual Padding DefaultMargin {
2635 get { return new Padding (3); }
2639 protected virtual Size DefaultSize {
2641 return new Size(0, 0);
2645 protected int FontHeight {
2655 protected bool RenderRightToLeft {
2657 return (this.right_to_left == RightToLeft.Yes);
2661 protected bool ResizeRedraw {
2663 return GetStyle(ControlStyles.ResizeRedraw);
2667 SetStyle(ControlStyles.ResizeRedraw, value);
2671 [EditorBrowsable(EditorBrowsableState.Advanced)]
2673 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2674 protected virtual bool ShowFocusCues {
2680 [EditorBrowsable(EditorBrowsableState.Advanced)]
2682 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2683 protected bool ShowKeyboardCues {
2688 #endregion // Protected Instance Properties
2690 #region Public Static Methods
2691 [EditorBrowsable(EditorBrowsableState.Advanced)]
2692 public static Control FromChildHandle(IntPtr handle) {
2693 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2696 [EditorBrowsable(EditorBrowsableState.Advanced)]
2697 public static Control FromHandle(IntPtr handle) {
2698 return Control.ControlNativeWindow.ControlFromHandle(handle);
2701 public static bool IsMnemonic(char charCode, string text) {
2704 amp = text.IndexOf('&');
2707 if (amp + 1 < text.Length) {
2708 if (text[amp + 1] != '&') {
2709 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2719 #region Protected Static Methods
2720 [EditorBrowsable(EditorBrowsableState.Advanced)]
2721 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2724 c = Control.FromHandle(hWnd);
2734 #region Public Instance Methods
2735 [EditorBrowsable(EditorBrowsableState.Advanced)]
2736 public IAsyncResult BeginInvoke(Delegate method) {
2737 object [] prms = null;
2738 if (method is EventHandler)
2739 prms = new object [] { this, EventArgs.Empty };
2740 return BeginInvokeInternal(method, prms, false);
2743 [EditorBrowsable(EditorBrowsableState.Advanced)]
2744 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2745 return BeginInvokeInternal (method, args, false);
2748 public void BringToFront() {
2749 if (parent != null) {
2750 parent.child_controls.SetChildIndex(this, 0);
2753 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2757 public bool Contains(Control ctl) {
2758 while (ctl != null) {
2767 public void CreateControl() {
2769 throw new ObjectDisposedException(GetType().FullName.ToString());
2775 if (!IsHandleCreated) {
2783 Control [] controls = child_controls.GetAllControls ();
2784 for (int i=0; i<controls.Length; i++) {
2785 controls [i].CreateControl ();
2788 UpdateChildrenZOrder();
2790 if (binding_context == null) { // seem to be sent whenever it's null?
2791 OnBindingContextChanged(EventArgs.Empty);
2797 public Graphics CreateGraphics() {
2798 if (!IsHandleCreated) {
2799 this.CreateHandle();
2801 return Graphics.FromHwnd(this.window.Handle);
2804 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2805 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2808 [EditorBrowsable(EditorBrowsableState.Advanced)]
2809 public object EndInvoke (IAsyncResult async_result) {
2810 AsyncMethodResult result = (AsyncMethodResult) async_result;
2811 return result.EndInvoke ();
2814 public Form FindForm() {
2827 public bool Focus() {
2828 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2831 is_focusing = false;
2836 public Control GetChildAtPoint(Point pt) {
2837 // Microsoft's version of this function doesn't seem to work, so I can't check
2838 // if we only consider children or also grandchildren, etc.
2839 // I'm gonna say 'children only'
2840 for (int i=0; i<child_controls.Count; i++) {
2841 if (child_controls[i].Bounds.Contains(pt)) {
2842 return child_controls[i];
2848 public IContainerControl GetContainerControl() {
2849 Control current = this;
2851 while (current!=null) {
2852 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2853 return (IContainerControl)current;
2855 current = current.parent;
2860 public Control GetNextControl(Control ctl, bool forward) {
2862 if (!this.Contains(ctl)) {
2867 ctl = FindControlForward(this, ctl);
2870 ctl = FindControlBackward(this, ctl);
2880 public virtual Size GetPreferredSize (Size proposedSize) {
2881 return preferred_size;
2885 public void Hide() {
2886 this.Visible = false;
2889 public void Invalidate() {
2890 Invalidate(ClientRectangle, false);
2893 public void Invalidate(bool invalidateChildren) {
2894 Invalidate(ClientRectangle, invalidateChildren);
2897 public void Invalidate(System.Drawing.Rectangle rc) {
2898 Invalidate(rc, false);
2901 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2902 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2906 NotifyInvalidate(rc);
2908 XplatUI.Invalidate(Handle, rc, false);
2910 if (invalidateChildren) {
2911 Control [] controls = child_controls.GetAllControls ();
2912 for (int i=0; i<controls.Length; i++)
2913 controls [i].Invalidate ();
2915 OnInvalidated(new InvalidateEventArgs(rc));
2918 public void Invalidate(System.Drawing.Region region) {
2919 Invalidate(region, false);
2922 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2923 RectangleF bounds = region.GetBounds (CreateGraphics ());
2924 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2925 invalidateChildren);
2928 public object Invoke (Delegate method) {
2929 object [] prms = null;
2930 if (method is EventHandler)
2931 prms = new object [] { this, EventArgs.Empty };
2933 return Invoke(method, prms);
2936 public object Invoke (Delegate method, object[] args) {
2937 if (!this.InvokeRequired) {
2938 return method.DynamicInvoke(args);
2941 IAsyncResult result = BeginInvoke (method, args);
2942 return EndInvoke(result);
2945 internal object InvokeInternal (Delegate method, bool disposing) {
2946 return InvokeInternal(method, null, disposing);
2949 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2950 if (!this.InvokeRequired) {
2951 return method.DynamicInvoke(args);
2954 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2955 return EndInvoke(result);
2958 [EditorBrowsable(EditorBrowsableState.Advanced)]
2959 public void PerformLayout() {
2960 PerformLayout(null, null);
2964 private void SetImplicitBounds (int x, int y, int width, int height)
2966 Rectangle saved_bounds = explicit_bounds;
2967 SetBounds (x, y, width, height);
2968 explicit_bounds = saved_bounds;
2972 [EditorBrowsable(EditorBrowsableState.Advanced)]
2973 public void PerformLayout(Control affectedControl, string affectedProperty) {
2974 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2976 if (layout_suspended > 0) {
2977 layout_pending = true;
2981 layout_pending = false;
2983 // Prevent us from getting messed up
2986 // Perform all Dock and Anchor calculations
2990 this.layout_engine.Layout(this, levent);
2992 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2994 AnchorStyles anchor;
2997 space = DisplayRectangle;
2999 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
3000 Control [] controls = child_controls.GetAllControls ();
3001 for (int i = controls.Length - 1; i >= 0; i--) {
3002 child = controls [i];
3004 if (!child.Visible) {
3008 switch (child.Dock) {
3009 case DockStyle.None: {
3014 case DockStyle.Left: {
3015 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3016 space.X+=child.Width;
3017 space.Width-=child.Width;
3021 case DockStyle.Top: {
3022 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3023 space.Y+=child.Height;
3024 space.Height-=child.Height;
3028 case DockStyle.Right: {
3029 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3030 space.Width-=child.Width;
3034 case DockStyle.Bottom: {
3035 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3036 space.Height-=child.Height;
3042 for (int i = controls.Length - 1; i >= 0; i--) {
3045 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3046 if (child.Dock == DockStyle.Fill) {
3047 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3051 space = DisplayRectangle;
3053 for (int i=0; i < controls.Length; i++) {
3059 child = controls[i];
3061 // If the control is docked we don't need to do anything
3062 if (child.Dock != DockStyle.None) {
3066 anchor = child.Anchor;
3070 width = child.Width;
3071 height = child.Height;
3073 if ((anchor & AnchorStyles.Left) !=0 ) {
3074 if ((anchor & AnchorStyles.Right) != 0) {
3075 width = space.Width - child.dist_right - left;
3077 ; // Left anchored only, nothing to be done
3079 } else if ((anchor & AnchorStyles.Right) != 0) {
3080 left = space.Width - child.dist_right - width;
3082 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3083 // This calculates from scratch every time:
3084 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3087 if ((anchor & AnchorStyles.Top) !=0 ) {
3088 if ((anchor & AnchorStyles.Bottom) != 0) {
3089 height = space.Height - child.dist_bottom - top;
3091 ; // Top anchored only, nothing to be done
3093 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3094 top = space.Height - child.dist_bottom - height;
3096 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3097 // This calculates from scratch every time:
3098 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3110 child.SetImplicitBounds(left, top, width, height);
3114 // Let everyone know
3118 // Need to make sure we decremend layout_suspended
3124 public Point PointToClient (Point p) {
3128 XplatUI.ScreenToClient (Handle, ref x, ref y);
3130 return new Point (x, y);
3133 public Point PointToScreen(Point p) {
3137 XplatUI.ClientToScreen(Handle, ref x, ref y);
3139 return new Point(x, y);
3142 public virtual bool PreProcessMessage(ref Message msg) {
3143 return InternalPreProcessMessage (ref msg);
3146 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3149 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3150 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3152 if (!ProcessCmdKey(ref msg, key_data)) {
3153 if (IsInputKey(key_data)) {
3157 return ProcessDialogKey(key_data);
3161 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3162 if (IsInputChar((char)msg.WParam)) {
3165 return ProcessDialogChar((char)msg.WParam);
3166 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3167 return ProcessDialogChar((char)msg.WParam);
3172 public Rectangle RectangleToClient(Rectangle r) {
3173 return new Rectangle(PointToClient(r.Location), r.Size);
3176 public Rectangle RectangleToScreen(Rectangle r) {
3177 return new Rectangle(PointToScreen(r.Location), r.Size);
3180 public virtual void Refresh() {
3181 if (IsHandleCreated == true) {
3183 XplatUI.UpdateWindow(window.Handle);
3185 Control [] controls = child_controls.GetAllControls ();
3186 for (int i=0; i < controls.Length; i++) {
3187 controls[i].Refresh();
3193 [EditorBrowsable(EditorBrowsableState.Never)]
3194 public virtual void ResetBackColor() {
3195 BackColor = Color.Empty;
3198 [EditorBrowsable(EditorBrowsableState.Never)]
3199 public void ResetBindings() {
3200 data_bindings.Clear();
3203 [EditorBrowsable(EditorBrowsableState.Never)]
3204 public virtual void ResetCursor() {
3208 [EditorBrowsable(EditorBrowsableState.Never)]
3209 public virtual void ResetFont() {
3213 [EditorBrowsable(EditorBrowsableState.Never)]
3214 public virtual void ResetForeColor() {
3215 foreground_color = Color.Empty;
3218 [EditorBrowsable(EditorBrowsableState.Never)]
3219 public void ResetImeMode() {
3220 ime_mode = DefaultImeMode;
3223 [EditorBrowsable(EditorBrowsableState.Never)]
3224 public virtual void ResetRightToLeft() {
3225 right_to_left = RightToLeft.Inherit;
3228 public virtual void ResetText() {
3229 text = String.Empty;
3232 public void ResumeLayout() {
3233 ResumeLayout (true);
3236 public void ResumeLayout(bool performLayout) {
3237 if (layout_suspended > 0) {
3241 if (layout_suspended == 0) {
3242 Control [] controls = child_controls.GetAllControls ();
3243 for (int i=0; i<controls.Length; i++) {
3244 controls [i].UpdateDistances ();
3247 if (performLayout && layout_pending) {
3253 public void Scale(float ratio) {
3254 ScaleCore(ratio, ratio);
3257 public void Scale(float dx, float dy) {
3262 public void Scale(SizeF factor) {
3263 ScaleCore(factor.Width, factor.Height);
3267 public void Select() {
3268 Select(false, false);
3272 private void printTree(Control c, string t) {
3273 foreach(Control i in c.child_controls) {
3274 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3275 printTree(i, t+"\t");
3279 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3283 Console.WriteLine("{0}", this.FindForm());
3284 printTree(this, "\t");
3287 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3292 c = GetNextControl(c, forward);
3301 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3302 c.Select (true, true);
3305 } while (c != ctl); // If we wrap back to ourselves we stop
3310 public void SendToBack() {
3311 if (parent != null) {
3312 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3316 public void SetBounds(int x, int y, int width, int height) {
3317 SetBounds(x, y, width, height, BoundsSpecified.All);
3320 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3321 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3325 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3329 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3333 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3337 SetBoundsCore(x, y, width, height, specified);
3338 if (parent != null) {
3339 parent.PerformLayout(this, "Bounds");
3343 public void Show() {
3345 this.CreateControl();
3351 public void SuspendLayout() {
3355 public void Update() {
3356 if (IsHandleCreated) {
3357 XplatUI.UpdateWindow(window.Handle);
3360 #endregion // Public Instance Methods
3362 #region Protected Instance Methods
3363 [EditorBrowsable(EditorBrowsableState.Advanced)]
3364 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3365 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3366 throw new NotImplementedException();
3369 [EditorBrowsable(EditorBrowsableState.Advanced)]
3370 protected virtual AccessibleObject CreateAccessibilityInstance() {
3371 return new Control.ControlAccessibleObject(this);
3374 [EditorBrowsable(EditorBrowsableState.Advanced)]
3375 protected virtual ControlCollection CreateControlsInstance() {
3376 return new ControlCollection(this);
3379 [EditorBrowsable(EditorBrowsableState.Advanced)]
3380 protected virtual void CreateHandle() {
3382 throw new ObjectDisposedException(GetType().FullName.ToString());
3385 if (IsHandleCreated && !is_recreating) {
3389 window.CreateHandle(CreateParams);
3391 if (window.Handle != IntPtr.Zero) {
3392 lock (Control.controls) {
3393 if (!Control.controls.Contains(window.Handle)) {
3394 Control.controls.Add(this);
3398 creator_thread = Thread.CurrentThread;
3400 XplatUI.EnableWindow(window.Handle, is_enabled);
3401 XplatUI.SetVisible(window.Handle, is_visible, true);
3403 if (clip_region != null) {
3404 XplatUI.SetClipRegion(Handle, clip_region);
3407 // Set our handle with our parent
3408 if ((parent != null) && (parent.IsHandleCreated)) {
3409 XplatUI.SetParent(window.Handle, parent.Handle);
3412 // Set our handle as parent for our children
3413 Control [] children;
3415 children = child_controls.GetAllControls ();
3416 for (int i = 0; i < children.Length; i++ ) {
3417 if (!children[i].RecreatingHandle)
3418 XplatUI.SetParent(children[i].Handle, window.Handle);
3422 XplatUI.SetAllowDrop (Handle, allow_drop);
3424 // Find out where the window manager placed us
3425 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3426 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3430 OnHandleCreated(EventArgs.Empty);
3434 [EditorBrowsable(EditorBrowsableState.Advanced)]
3435 protected virtual void DefWndProc(ref Message m) {
3436 window.DefWndProc(ref m);
3439 [EditorBrowsable(EditorBrowsableState.Advanced)]
3440 protected virtual void DestroyHandle() {
3441 if (IsHandleCreated) {
3442 if (window != null) {
3443 window.DestroyHandle();
3448 protected bool GetStyle(ControlStyles flag) {
3449 return (control_style & flag) != 0;
3452 protected bool GetTopLevel() {
3456 [EditorBrowsable(EditorBrowsableState.Advanced)]
3457 protected virtual void InitLayout() {
3461 [EditorBrowsable(EditorBrowsableState.Advanced)]
3462 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3463 toInvoke.OnGotFocus(e);
3466 [EditorBrowsable(EditorBrowsableState.Advanced)]
3467 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3468 toInvoke.OnLostFocus(e);
3471 [EditorBrowsable(EditorBrowsableState.Advanced)]
3472 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3473 toInvoke.OnClick(e);
3476 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3477 toInvoke.OnPaint(e);
3480 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3481 toInvoke.OnPaintBackground(e);
3484 protected virtual bool IsInputChar (char charCode) {
3488 protected virtual bool IsInputKey (Keys keyData) {
3489 // Doc says this one calls IsInputChar; not sure what to do with that
3493 [EditorBrowsable(EditorBrowsableState.Advanced)]
3494 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3498 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3499 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3503 if (parent != null) {
3504 return parent.ProcessCmdKey(ref msg, keyData);
3510 protected virtual bool ProcessDialogChar(char charCode) {
3511 if (parent != null) {
3512 return parent.ProcessDialogChar (charCode);
3518 protected virtual bool ProcessDialogKey (Keys keyData) {
3519 if (parent != null) {
3520 return parent.ProcessDialogKey (keyData);
3526 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3528 KeyEventArgs key_event;
3531 case (int)Msg.WM_SYSKEYDOWN:
3532 case (int)Msg.WM_KEYDOWN: {
3533 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3534 OnKeyDown (key_event);
3535 return key_event.Handled;
3538 case (int)Msg.WM_SYSKEYUP:
3539 case (int)Msg.WM_KEYUP: {
3540 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3541 OnKeyUp (key_event);
3542 return key_event.Handled;
3545 case (int)Msg.WM_SYSCHAR:
3546 case (int)Msg.WM_CHAR: {
3547 KeyPressEventArgs key_press_event;
3549 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3550 OnKeyPress(key_press_event);
3552 msg.WParam = (IntPtr)key_press_event.KeyChar;
3554 return key_press_event.Handled;
3565 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3566 if (parent != null) {
3567 if (parent.ProcessKeyPreview(ref msg)) {
3572 return ProcessKeyEventArgs(ref msg);
3575 protected virtual bool ProcessKeyPreview(ref Message msg) {
3576 if (parent != null) {
3577 return parent.ProcessKeyPreview(ref msg);
3583 protected virtual bool ProcessMnemonic(char charCode) {
3588 [EditorBrowsable(EditorBrowsableState.Advanced)]
3589 protected void RaiseDragEvent(object key, DragEventArgs e) {
3593 [EditorBrowsable(EditorBrowsableState.Advanced)]
3594 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3598 [EditorBrowsable(EditorBrowsableState.Advanced)]
3599 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3603 [EditorBrowsable(EditorBrowsableState.Advanced)]
3604 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3608 private void SetIsRecreating ()
3612 foreach (Control c in Controls.GetAllControls()) {
3613 c.SetIsRecreating ();
3617 [EditorBrowsable(EditorBrowsableState.Advanced)]
3618 protected void RecreateHandle() {
3620 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3625 if (IsHandleCreated) {
3627 Console.WriteLine(" + handle is created, destroying it.");
3630 // WM_DESTROY will CreateHandle for us
3633 Console.WriteLine(" + handle is not created, creating it.");
3641 is_recreating = false;
3643 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3649 [EditorBrowsable(EditorBrowsableState.Advanced)]
3650 protected void ResetMouseEventArgs() {
3654 [EditorBrowsable(EditorBrowsableState.Advanced)]
3655 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3656 if (right_to_left == RightToLeft.No) {
3661 case ContentAlignment.TopLeft: {
3662 return ContentAlignment.TopRight;
3665 case ContentAlignment.TopRight: {
3666 return ContentAlignment.TopLeft;
3669 case ContentAlignment.MiddleLeft: {
3670 return ContentAlignment.MiddleRight;
3673 case ContentAlignment.MiddleRight: {
3674 return ContentAlignment.MiddleLeft;
3677 case ContentAlignment.BottomLeft: {
3678 return ContentAlignment.BottomRight;
3681 case ContentAlignment.BottomRight: {
3682 return ContentAlignment.BottomLeft;
3686 // if it's center it doesn't change
3692 [EditorBrowsable(EditorBrowsableState.Advanced)]
3693 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3694 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3698 if (align == HorizontalAlignment.Left) {
3699 return HorizontalAlignment.Right;
3702 // align must be HorizontalAlignment.Right
3703 return HorizontalAlignment.Left;
3706 [EditorBrowsable(EditorBrowsableState.Advanced)]
3707 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3708 if (right_to_left == RightToLeft.No) {
3712 if (align == LeftRightAlignment.Left) {
3713 return LeftRightAlignment.Right;
3716 // align must be LeftRightAlignment.Right;
3717 return LeftRightAlignment.Left;
3720 [EditorBrowsable(EditorBrowsableState.Advanced)]
3721 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3722 return RtlTranslateAlignment(align);
3725 [EditorBrowsable(EditorBrowsableState.Advanced)]
3726 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3727 return RtlTranslateAlignment(align);
3730 [EditorBrowsable(EditorBrowsableState.Advanced)]
3731 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3732 return RtlTranslateAlignment(align);
3735 [EditorBrowsable(EditorBrowsableState.Advanced)]
3736 protected virtual void ScaleCore(float dx, float dy) {
3742 location = new Point((int)(Left * dx), (int)(Top * dy));
3743 size = this.ClientSize;
3745 if (!GetStyle(ControlStyles.FixedWidth)) {
3746 size.Width = (int)(size.Width * dx);
3749 if (!GetStyle(ControlStyles.FixedHeight)) {
3750 size.Height = (int)(size.Height * dy);
3753 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3755 /* Now scale our children */
3756 Control [] controls = child_controls.GetAllControls ();
3757 for (int i=0; i < controls.Length; i++) {
3758 controls[i].Scale(dx, dy);
3764 protected virtual void Select(bool directed, bool forward) {
3765 IContainerControl container;
3767 container = GetContainerControl();
3768 if (container != null)
3769 container.ActiveControl = this;
3772 [EditorBrowsable(EditorBrowsableState.Advanced)]
3773 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3774 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3775 if (IsHandleCreated) {
3776 XplatUI.SetWindowPos(Handle, x, y, width, height);
3778 // Win32 automatically changes negative width/height to 0.
3779 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3780 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3782 if (width < 0 || height < 0) {
3784 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3788 UpdateBounds(x, y, width, height);
3793 [EditorBrowsable(EditorBrowsableState.Advanced)]
3794 protected virtual void SetClientSizeCore(int x, int y) {
3795 // Calculate the actual window size from the client size (it usually stays the same or grows)
3796 Rectangle ClientRect;
3797 Rectangle WindowRect;
3800 ClientRect = new Rectangle(0, 0, x, y);
3801 cp = this.CreateParams;
3803 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3807 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3810 [EditorBrowsable(EditorBrowsableState.Advanced)]
3811 protected void SetStyle(ControlStyles flag, bool value) {
3813 control_style |= flag;
3815 control_style &= ~flag;
3819 protected void SetTopLevel(bool value) {
3820 if ((GetTopLevel() != value) && (parent != null)) {
3821 throw new Exception();
3825 if (value == true) {
3835 is_toplevel = value;
3838 protected virtual void SetVisibleCore(bool value) {
3839 if (value!=is_visible) {
3840 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3846 if (IsHandleCreated) {
3847 XplatUI.SetVisible(Handle, value, true);
3848 // Explicitly move Toplevel windows to where we want them;
3849 // apparently moving unmapped toplevel windows doesn't work
3850 if (is_visible && (this is Form)) {
3851 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3855 OnVisibleChanged(EventArgs.Empty);
3857 if (value == false && parent != null && Focused) {
3860 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3861 container = (Control)parent.GetContainerControl();
3862 if (container != null) {
3863 container.SelectNextControl(this, true, true, true, true);
3867 if (parent != null) {
3868 parent.PerformLayout(this, "visible");
3870 PerformLayout(this, "visible");
3875 [EditorBrowsable(EditorBrowsableState.Advanced)]
3876 protected void UpdateBounds() {
3884 if (!IsHandleCreated) {
3888 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3890 UpdateBounds(x, y, width, height, client_width, client_height);
3893 [EditorBrowsable(EditorBrowsableState.Advanced)]
3894 protected void UpdateBounds(int x, int y, int width, int height) {
3898 // Calculate client rectangle
3899 rect = new Rectangle(0, 0, 0, 0);
3902 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3903 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3906 [EditorBrowsable(EditorBrowsableState.Advanced)]
3907 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3908 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3910 bool resized = false;
3912 // Needed to generate required notifications
3913 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3917 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3924 bounds.Height=height;
3926 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3927 explicit_bounds = bounds;
3929 client_size.Width=clientWidth;
3930 client_size.Height=clientHeight;
3933 OnLocationChanged(EventArgs.Empty);
3937 OnSizeChanged(EventArgs.Empty);
3941 [EditorBrowsable(EditorBrowsableState.Advanced)]
3942 protected void UpdateStyles() {
3943 if (!IsHandleCreated) {
3947 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3948 OnStyleChanged(EventArgs.Empty);
3951 private void UpdateZOrderOfChild(Control child) {
3952 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3955 index = child_controls.IndexOf(child);
3958 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3960 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3965 private void UpdateChildrenZOrder() {
3966 Control [] controls;
3968 if (!IsHandleCreated) {
3972 controls = child_controls.GetAllControls ();
3973 for (int i = 1; i < controls.Length; i++ ) {
3974 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3978 [EditorBrowsable(EditorBrowsableState.Advanced)]
3979 protected void UpdateZOrder() {
3980 if (parent != null) {
3981 parent.UpdateZOrderOfChild(this);
3985 protected virtual void WndProc(ref Message m) {
3987 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3989 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3993 switch((Msg)m.Msg) {
3994 case Msg.WM_DESTROY: {
3995 OnHandleDestroyed(EventArgs.Empty);
3997 IntPtr handle = window.Handle;
3999 window.InvalidateHandle();
4001 if (is_recreating) {
4003 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4007 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4009 is_recreating = false;
4014 case Msg.WM_WINDOWPOSCHANGED: {
4016 Rectangle save_bounds = explicit_bounds;
4018 explicit_bounds = save_bounds;
4019 if (GetStyle(ControlStyles.ResizeRedraw)) {
4026 // Nice description of what should happen when handling WM_PAINT
4027 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4028 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4029 case Msg.WM_PAINT: {
4030 PaintEventArgs paint_event;
4032 paint_event = XplatUI.PaintEventStart(Handle, true);
4034 if (paint_event == null) {
4038 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4039 // Just blit the previous image
4040 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4041 XplatUI.PaintEventEnd(Handle, true);
4046 Graphics back_dc = null;
4047 Bitmap backbuffer = null;
4048 if (ThemeEngine.Current.DoubleBufferingSupported) {
4049 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4050 backbuffer = ImageBuffer;
4051 back_dc = Graphics.FromImage (backbuffer);
4052 dc = paint_event.SetGraphics (back_dc);
4056 if (!GetStyle(ControlStyles.Opaque)) {
4057 OnPaintBackground(paint_event);
4060 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4061 OnPaintBackgroundInternal(paint_event);
4063 OnPaintInternal(paint_event);
4064 if (!paint_event.Handled) {
4065 OnPaint(paint_event);
4068 if (ThemeEngine.Current.DoubleBufferingSupported)
4069 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4070 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4071 paint_event.SetGraphics (dc);
4072 invalid_region.Exclude (paint_event.ClipRectangle);
4074 if (backbuffer != bmp_mem)
4075 backbuffer.Dispose();
4078 XplatUI.PaintEventEnd(Handle, true);
4083 case Msg.WM_ERASEBKGND: {
4084 // The DefWndProc will never have to handle this, we always paint the background in managed code
4085 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4086 // here but it just makes things more complicated...
4087 m.Result = (IntPtr)1;
4091 case Msg.WM_LBUTTONUP: {
4094 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4096 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4099 HandleClick(mouse_clicks, me);
4102 if (InternalCapture) {
4103 InternalCapture = false;
4106 if (mouse_clicks > 1) {
4112 case Msg.WM_LBUTTONDOWN: {
4114 Select (true, true);
4116 InternalCapture = true;
4117 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4118 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4124 case Msg.WM_LBUTTONDBLCLK: {
4125 InternalCapture = true;
4127 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4128 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4134 case Msg.WM_MBUTTONUP: {
4137 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4139 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4142 HandleClick(mouse_clicks, me);
4144 if (InternalCapture) {
4145 InternalCapture = false;
4147 if (mouse_clicks > 1) {
4153 case Msg.WM_MBUTTONDOWN: {
4154 InternalCapture = true;
4155 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4156 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4162 case Msg.WM_MBUTTONDBLCLK: {
4163 InternalCapture = true;
4165 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4166 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4171 case Msg.WM_RBUTTONUP: {
4175 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4176 pt = PointToScreen(pt);
4178 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4180 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4182 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4185 HandleClick(mouse_clicks, me);
4188 if (InternalCapture) {
4189 InternalCapture = false;
4192 if (mouse_clicks > 1) {
4198 case Msg.WM_RBUTTONDOWN: {
4199 InternalCapture = true;
4200 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4201 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4206 case Msg.WM_RBUTTONDBLCLK: {
4207 InternalCapture = true;
4209 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4210 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4215 case Msg.WM_CONTEXTMENU: {
4216 if (context_menu != null) {
4219 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4220 context_menu.Show(this, PointToClient(pt));
4228 case Msg.WM_MOUSEWHEEL: {
4230 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4231 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4232 HighOrder(m.WParam.ToInt32())));
4237 case Msg.WM_MOUSEMOVE: {
4238 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4240 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4245 case Msg.WM_MOUSE_ENTER: {
4250 OnMouseEnter(EventArgs.Empty);
4254 case Msg.WM_MOUSE_LEAVE: {
4256 OnMouseLeave(EventArgs.Empty);
4260 case Msg.WM_MOUSEHOVER: {
4261 OnMouseHover(EventArgs.Empty);
4265 case Msg.WM_SYSKEYUP: {
4266 if (ProcessKeyMessage(ref m)) {
4267 m.Result = IntPtr.Zero;
4271 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4275 if (form != null && form.ActiveMenu != null) {
4276 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4284 case Msg.WM_SYSKEYDOWN:
4285 case Msg.WM_KEYDOWN:
4287 case Msg.WM_SYSCHAR:
4289 if (ProcessKeyMessage(ref m)) {
4290 m.Result = IntPtr.Zero;
4299 if (m.LParam != IntPtr.Zero) {
4302 hi = new HELPINFO();
4304 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4305 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4307 mouse_pos = Control.MousePosition;
4309 OnHelpRequested(new HelpEventArgs(mouse_pos));
4310 m.Result = (IntPtr)1;
4314 case Msg.WM_KILLFOCUS: {
4315 this.has_focus = false;
4316 OnLostFocusInternal (EventArgs.Empty);
4320 case Msg.WM_SETFOCUS: {
4322 this.has_focus = true;
4323 OnGotFocusInternal (EventArgs.Empty);
4329 case Msg.WM_SYSCOLORCHANGE: {
4330 ThemeEngine.Current.ResetDefaults();
4331 OnSystemColorsChanged(EventArgs.Empty);
4336 case Msg.WM_SETCURSOR: {
4337 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4342 XplatUI.SetCursor(window.Handle, cursor.handle);
4343 m.Result = (IntPtr)1;
4354 #endregion // Public Instance Methods
4356 #region OnXXX methods
4357 [EditorBrowsable(EditorBrowsableState.Advanced)]
4358 protected virtual void OnBackColorChanged(EventArgs e) {
4359 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4362 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4365 [EditorBrowsable(EditorBrowsableState.Advanced)]
4366 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4367 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4370 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4373 [EditorBrowsable(EditorBrowsableState.Advanced)]
4374 protected virtual void OnBindingContextChanged(EventArgs e) {
4375 CheckDataBindings ();
4376 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4379 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4382 [EditorBrowsable(EditorBrowsableState.Advanced)]
4383 protected virtual void OnCausesValidationChanged(EventArgs e) {
4384 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4389 [EditorBrowsable(EditorBrowsableState.Advanced)]
4390 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4391 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4396 [EditorBrowsable(EditorBrowsableState.Advanced)]
4397 protected virtual void OnClick(EventArgs e) {
4398 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4403 [EditorBrowsable(EditorBrowsableState.Advanced)]
4404 protected virtual void OnContextMenuChanged(EventArgs e) {
4405 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4410 [EditorBrowsable(EditorBrowsableState.Advanced)]
4411 protected virtual void OnControlAdded(ControlEventArgs e) {
4412 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4417 [EditorBrowsable(EditorBrowsableState.Advanced)]
4418 protected virtual void OnControlRemoved(ControlEventArgs e) {
4419 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4424 [EditorBrowsable(EditorBrowsableState.Advanced)]
4425 protected virtual void OnCreateControl() {
4429 [EditorBrowsable(EditorBrowsableState.Advanced)]
4430 protected virtual void OnCursorChanged(EventArgs e) {
4431 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4436 [EditorBrowsable(EditorBrowsableState.Advanced)]
4437 protected virtual void OnDockChanged(EventArgs e) {
4438 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4443 [EditorBrowsable(EditorBrowsableState.Advanced)]
4444 protected virtual void OnDoubleClick(EventArgs e) {
4445 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4450 [EditorBrowsable(EditorBrowsableState.Advanced)]
4451 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4452 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4454 eh (this, drgevent);
4457 [EditorBrowsable(EditorBrowsableState.Advanced)]
4458 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4459 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4461 eh (this, drgevent);
4464 [EditorBrowsable(EditorBrowsableState.Advanced)]
4465 protected virtual void OnDragLeave(EventArgs e) {
4466 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4471 [EditorBrowsable(EditorBrowsableState.Advanced)]
4472 protected virtual void OnDragOver(DragEventArgs drgevent) {
4473 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4475 eh (this, drgevent);
4478 [EditorBrowsable(EditorBrowsableState.Advanced)]
4479 protected virtual void OnEnabledChanged(EventArgs e) {
4480 if (IsHandleCreated) {
4482 if (((Form)this).context == null) {
4483 XplatUI.EnableWindow(window.Handle, Enabled);
4486 XplatUI.EnableWindow(window.Handle, Enabled);
4491 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4495 for (int i=0; i<child_controls.Count; i++) {
4496 child_controls[i].OnParentEnabledChanged(e);
4500 [EditorBrowsable(EditorBrowsableState.Advanced)]
4501 protected virtual void OnEnter(EventArgs e) {
4502 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4507 [EditorBrowsable(EditorBrowsableState.Advanced)]
4508 protected virtual void OnFontChanged(EventArgs e) {
4509 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4512 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4515 [EditorBrowsable(EditorBrowsableState.Advanced)]
4516 protected virtual void OnForeColorChanged(EventArgs e) {
4517 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4520 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4523 [EditorBrowsable(EditorBrowsableState.Advanced)]
4524 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4525 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4527 eh (this, gfbevent);
4530 [EditorBrowsable(EditorBrowsableState.Advanced)]
4531 protected virtual void OnGotFocus(EventArgs e) {
4532 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4537 [EditorBrowsable(EditorBrowsableState.Advanced)]
4538 protected virtual void OnHandleCreated(EventArgs e) {
4539 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4544 [EditorBrowsable(EditorBrowsableState.Advanced)]
4545 protected virtual void OnHandleDestroyed(EventArgs e) {
4546 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4551 [EditorBrowsable(EditorBrowsableState.Advanced)]
4552 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4553 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4558 protected virtual void OnImeModeChanged(EventArgs e) {
4559 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4564 [EditorBrowsable(EditorBrowsableState.Advanced)]
4565 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4566 if (ThemeEngine.Current.DoubleBufferingSupported)
4567 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4568 // should this block be here? seems like it
4569 // would be more at home in
4570 // NotifyInvalidated..
4571 if (e.InvalidRect == ClientRectangle) {
4572 ImageBufferNeedsRedraw ();
4575 // we need this Inflate call here so
4576 // that the border of the rectangle is
4577 // considered Visible (the
4578 // invalid_region.IsVisible call) in
4579 // the WM_PAINT handling below.
4580 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4581 if (invalid_region == null)
4582 invalid_region = new Region (r);
4584 invalid_region.Union (r);
4588 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4593 [EditorBrowsable(EditorBrowsableState.Advanced)]
4594 protected virtual void OnKeyDown(KeyEventArgs e) {
4595 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4600 [EditorBrowsable(EditorBrowsableState.Advanced)]
4601 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4602 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4607 [EditorBrowsable(EditorBrowsableState.Advanced)]
4608 protected virtual void OnKeyUp(KeyEventArgs e) {
4609 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4614 [EditorBrowsable(EditorBrowsableState.Advanced)]
4615 protected virtual void OnLayout(LayoutEventArgs levent) {
4616 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4621 [EditorBrowsable(EditorBrowsableState.Advanced)]
4622 protected virtual void OnLeave(EventArgs e) {
4623 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4628 [EditorBrowsable(EditorBrowsableState.Advanced)]
4629 protected virtual void OnLocationChanged(EventArgs e) {
4631 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4636 [EditorBrowsable(EditorBrowsableState.Advanced)]
4637 protected virtual void OnLostFocus(EventArgs e) {
4638 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4643 [EditorBrowsable(EditorBrowsableState.Advanced)]
4644 protected virtual void OnMouseDown(MouseEventArgs e) {
4645 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4650 [EditorBrowsable(EditorBrowsableState.Advanced)]
4651 protected virtual void OnMouseEnter(EventArgs e) {
4652 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4657 [EditorBrowsable(EditorBrowsableState.Advanced)]
4658 protected virtual void OnMouseHover(EventArgs e) {
4659 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4664 [EditorBrowsable(EditorBrowsableState.Advanced)]
4665 protected virtual void OnMouseLeave(EventArgs e) {
4666 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4671 [EditorBrowsable(EditorBrowsableState.Advanced)]
4672 protected virtual void OnMouseMove(MouseEventArgs e) {
4673 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4678 [EditorBrowsable(EditorBrowsableState.Advanced)]
4679 protected virtual void OnMouseUp(MouseEventArgs e) {
4680 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4685 [EditorBrowsable(EditorBrowsableState.Advanced)]
4686 protected virtual void OnMouseWheel(MouseEventArgs e) {
4687 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4692 [EditorBrowsable(EditorBrowsableState.Advanced)]
4693 protected virtual void OnMove(EventArgs e) {
4694 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4699 [EditorBrowsable(EditorBrowsableState.Advanced)]
4700 protected virtual void OnNotifyMessage(Message m) {
4704 [EditorBrowsable(EditorBrowsableState.Advanced)]
4705 protected virtual void OnPaint(PaintEventArgs e) {
4706 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4711 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4715 internal virtual void OnPaintInternal(PaintEventArgs e) {
4719 internal virtual void OnGotFocusInternal (EventArgs e)
4724 internal virtual void OnLostFocusInternal (EventArgs e)
4729 [EditorBrowsable(EditorBrowsableState.Advanced)]
4730 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4731 PaintControlBackground (pevent);
4734 [EditorBrowsable(EditorBrowsableState.Advanced)]
4735 protected virtual void OnParentBackColorChanged(EventArgs e) {
4736 if (background_color.IsEmpty && background_image==null) {
4738 OnBackColorChanged(e);
4742 [EditorBrowsable(EditorBrowsableState.Advanced)]
4743 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4744 if (background_color.IsEmpty && background_image==null) {
4746 OnBackgroundImageChanged(e);
4750 [EditorBrowsable(EditorBrowsableState.Advanced)]
4751 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4752 if (binding_context==null) {
4753 binding_context=Parent.binding_context;
4754 OnBindingContextChanged(e);
4758 [EditorBrowsable(EditorBrowsableState.Advanced)]
4759 protected virtual void OnParentChanged(EventArgs e) {
4760 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4765 [EditorBrowsable(EditorBrowsableState.Advanced)]
4766 protected virtual void OnParentEnabledChanged(EventArgs e) {
4768 OnEnabledChanged(e);
4772 [EditorBrowsable(EditorBrowsableState.Advanced)]
4773 protected virtual void OnParentFontChanged(EventArgs e) {
4780 [EditorBrowsable(EditorBrowsableState.Advanced)]
4781 protected virtual void OnParentForeColorChanged(EventArgs e) {
4782 if (foreground_color.IsEmpty) {
4784 OnForeColorChanged(e);
4788 [EditorBrowsable(EditorBrowsableState.Advanced)]
4789 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4790 if (right_to_left==RightToLeft.Inherit) {
4792 OnRightToLeftChanged(e);
4796 [EditorBrowsable(EditorBrowsableState.Advanced)]
4797 protected virtual void OnParentVisibleChanged(EventArgs e) {
4799 OnVisibleChanged(e);
4803 [EditorBrowsable(EditorBrowsableState.Advanced)]
4804 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4805 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4810 [EditorBrowsable(EditorBrowsableState.Advanced)]
4811 protected virtual void OnResize(EventArgs e) {
4812 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4816 PerformLayout(this, "bounds");
4818 if (parent != null) {
4819 parent.PerformLayout();
4823 [EditorBrowsable(EditorBrowsableState.Advanced)]
4824 protected virtual void OnRightToLeftChanged(EventArgs e) {
4825 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4828 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4831 [EditorBrowsable(EditorBrowsableState.Advanced)]
4832 protected virtual void OnSizeChanged(EventArgs e) {
4833 InvalidateBuffers ();
4835 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4840 [EditorBrowsable(EditorBrowsableState.Advanced)]
4841 protected virtual void OnStyleChanged(EventArgs e) {
4842 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4847 [EditorBrowsable(EditorBrowsableState.Advanced)]
4848 protected virtual void OnSystemColorsChanged(EventArgs e) {
4849 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4854 [EditorBrowsable(EditorBrowsableState.Advanced)]
4855 protected virtual void OnTabIndexChanged(EventArgs e) {
4856 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4861 [EditorBrowsable(EditorBrowsableState.Advanced)]
4862 protected virtual void OnTabStopChanged(EventArgs e) {
4863 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4868 [EditorBrowsable(EditorBrowsableState.Advanced)]
4869 protected virtual void OnTextChanged(EventArgs e) {
4870 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4875 [EditorBrowsable(EditorBrowsableState.Advanced)]
4876 protected virtual void OnValidated(EventArgs e) {
4877 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4882 [EditorBrowsable(EditorBrowsableState.Advanced)]
4883 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4884 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4889 [EditorBrowsable(EditorBrowsableState.Advanced)]
4890 protected virtual void OnVisibleChanged(EventArgs e) {
4891 if ((parent != null) && !Created && Visible) {
4898 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4902 // We need to tell our kids
4903 for (int i=0; i<child_controls.Count; i++) {
4904 if (child_controls[i].Visible) {
4905 child_controls[i].OnParentVisibleChanged(e);
4909 #endregion // OnXXX methods
4912 static object BackColorChangedEvent = new object ();
4913 static object BackgroundImageChangedEvent = new object ();
4914 static object BindingContextChangedEvent = new object ();
4915 static object CausesValidationChangedEvent = new object ();
4916 static object ChangeUICuesEvent = new object ();
4917 static object ClickEvent = new object ();
4918 static object ContextMenuChangedEvent = new object ();
4919 static object ControlAddedEvent = new object ();
4920 static object ControlRemovedEvent = new object ();
4921 static object CursorChangedEvent = new object ();
4922 static object DockChangedEvent = new object ();
4923 static object DoubleClickEvent = new object ();
4924 static object DragDropEvent = new object ();
4925 static object DragEnterEvent = new object ();
4926 static object DragLeaveEvent = new object ();
4927 static object DragOverEvent = new object ();
4928 static object EnabledChangedEvent = new object ();
4929 static object EnterEvent = new object ();
4930 static object FontChangedEvent = new object ();
4931 static object ForeColorChangedEvent = new object ();
4932 static object GiveFeedbackEvent = new object ();
4933 static object GotFocusEvent = new object ();
4934 static object HandleCreatedEvent = new object ();
4935 static object HandleDestroyedEvent = new object ();
4936 static object HelpRequestedEvent = new object ();
4937 static object ImeModeChangedEvent = new object ();
4938 static object InvalidatedEvent = new object ();
4939 static object KeyDownEvent = new object ();
4940 static object KeyPressEvent = new object ();
4941 static object KeyUpEvent = new object ();
4942 static object LayoutEvent = new object ();
4943 static object LeaveEvent = new object ();
4944 static object LocationChangedEvent = new object ();
4945 static object LostFocusEvent = new object ();
4946 static object MouseDownEvent = new object ();
4947 static object MouseEnterEvent = new object ();
4948 static object MouseHoverEvent = new object ();
4949 static object MouseLeaveEvent = new object ();
4950 static object MouseMoveEvent = new object ();
4951 static object MouseUpEvent = new object ();
4952 static object MouseWheelEvent = new object ();
4953 static object MoveEvent = new object ();
4954 static object PaintEvent = new object ();
4955 static object ParentChangedEvent = new object ();
4956 static object QueryAccessibilityHelpEvent = new object ();
4957 static object QueryContinueDragEvent = new object ();
4958 static object ResizeEvent = new object ();
4959 static object RightToLeftChangedEvent = new object ();
4960 static object SizeChangedEvent = new object ();
4961 static object StyleChangedEvent = new object ();
4962 static object SystemColorsChangedEvent = new object ();
4963 static object TabIndexChangedEvent = new object ();
4964 static object TabStopChangedEvent = new object ();
4965 static object TextChangedEvent = new object ();
4966 static object ValidatedEvent = new object ();
4967 static object ValidatingEvent = new object ();
4968 static object VisibleChangedEvent = new object ();
4970 public event EventHandler BackColorChanged {
4971 add { Events.AddHandler (BackColorChangedEvent, value); }
4972 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4975 public event EventHandler BackgroundImageChanged {
4976 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4977 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4980 public event EventHandler BindingContextChanged {
4981 add { Events.AddHandler (BindingContextChangedEvent, value); }
4982 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4985 public event EventHandler CausesValidationChanged {
4986 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4987 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4990 public event UICuesEventHandler ChangeUICues {
4991 add { Events.AddHandler (ChangeUICuesEvent, value); }
4992 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4995 public event EventHandler Click {
4996 add { Events.AddHandler (ClickEvent, value); }
4997 remove { Events.RemoveHandler (ClickEvent, value); }
5000 public event EventHandler ContextMenuChanged {
5001 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5002 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5005 [EditorBrowsable(EditorBrowsableState.Advanced)]
5007 public event ControlEventHandler ControlAdded {
5008 add { Events.AddHandler (ControlAddedEvent, value); }
5009 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5012 [EditorBrowsable(EditorBrowsableState.Advanced)]
5014 public event ControlEventHandler ControlRemoved {
5015 add { Events.AddHandler (ControlRemovedEvent, value); }
5016 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5019 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5020 public event EventHandler CursorChanged {
5021 add { Events.AddHandler (CursorChangedEvent, value); }
5022 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5024 public event EventHandler DockChanged {
5025 add { Events.AddHandler (DockChangedEvent, value); }
5026 remove { Events.RemoveHandler (DockChangedEvent, value); }
5029 public event EventHandler DoubleClick {
5030 add { Events.AddHandler (DoubleClickEvent, value); }
5031 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5034 public event DragEventHandler DragDrop {
5035 add { Events.AddHandler (DragDropEvent, value); }
5036 remove { Events.RemoveHandler (DragDropEvent, value); }
5039 public event DragEventHandler DragEnter {
5040 add { Events.AddHandler (DragEnterEvent, value); }
5041 remove { Events.RemoveHandler (DragEnterEvent, value); }
5044 public event EventHandler DragLeave {
5045 add { Events.AddHandler (DragLeaveEvent, value); }
5046 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5049 public event DragEventHandler DragOver {
5050 add { Events.AddHandler (DragOverEvent, value); }
5051 remove { Events.RemoveHandler (DragOverEvent, value); }
5054 public event EventHandler EnabledChanged {
5055 add { Events.AddHandler (EnabledChangedEvent, value); }
5056 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5059 public event EventHandler Enter {
5060 add { Events.AddHandler (EnterEvent, value); }
5061 remove { Events.RemoveHandler (EnterEvent, value); }
5064 public event EventHandler FontChanged {
5065 add { Events.AddHandler (FontChangedEvent, value); }
5066 remove { Events.RemoveHandler (FontChangedEvent, value); }
5069 public event EventHandler ForeColorChanged {
5070 add { Events.AddHandler (ForeColorChangedEvent, value); }
5071 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5074 public event GiveFeedbackEventHandler GiveFeedback {
5075 add { Events.AddHandler (GiveFeedbackEvent, value); }
5076 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5079 [EditorBrowsable(EditorBrowsableState.Advanced)]
5081 public event EventHandler GotFocus {
5082 add { Events.AddHandler (GotFocusEvent, value); }
5083 remove { Events.RemoveHandler (GotFocusEvent, value); }
5087 [EditorBrowsable(EditorBrowsableState.Advanced)]
5089 public event EventHandler HandleCreated {
5090 add { Events.AddHandler (HandleCreatedEvent, value); }
5091 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5094 [EditorBrowsable(EditorBrowsableState.Advanced)]
5096 public event EventHandler HandleDestroyed {
5097 add { Events.AddHandler (HandleDestroyedEvent, value); }
5098 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5101 public event HelpEventHandler HelpRequested {
5102 add { Events.AddHandler (HelpRequestedEvent, value); }
5103 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5106 public event EventHandler ImeModeChanged {
5107 add { Events.AddHandler (ImeModeChangedEvent, value); }
5108 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5111 [EditorBrowsable(EditorBrowsableState.Advanced)]
5113 public event InvalidateEventHandler Invalidated {
5114 add { Events.AddHandler (InvalidatedEvent, value); }
5115 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5118 public event KeyEventHandler KeyDown {
5119 add { Events.AddHandler (KeyDownEvent, value); }
5120 remove { Events.RemoveHandler (KeyDownEvent, value); }
5123 public event KeyPressEventHandler KeyPress {
5124 add { Events.AddHandler (KeyPressEvent, value); }
5125 remove { Events.RemoveHandler (KeyPressEvent, value); }
5128 public event KeyEventHandler KeyUp {
5129 add { Events.AddHandler (KeyUpEvent, value); }
5130 remove { Events.RemoveHandler (KeyUpEvent, value); }
5133 public event LayoutEventHandler Layout {
5134 add { Events.AddHandler (LayoutEvent, value); }
5135 remove { Events.RemoveHandler (LayoutEvent, value); }
5138 public event EventHandler Leave {
5139 add { Events.AddHandler (LeaveEvent, value); }
5140 remove { Events.RemoveHandler (LeaveEvent, value); }
5143 public event EventHandler LocationChanged {
5144 add { Events.AddHandler (LocationChangedEvent, value); }
5145 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5148 [EditorBrowsable(EditorBrowsableState.Advanced)]
5150 public event EventHandler LostFocus {
5151 add { Events.AddHandler (LostFocusEvent, value); }
5152 remove { Events.RemoveHandler (LostFocusEvent, value); }
5155 public event MouseEventHandler MouseDown {
5156 add { Events.AddHandler (MouseDownEvent, value); }
5157 remove { Events.RemoveHandler (MouseDownEvent, value); }
5160 public event EventHandler MouseEnter {
5161 add { Events.AddHandler (MouseEnterEvent, value); }
5162 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5165 public event EventHandler MouseHover {
5166 add { Events.AddHandler (MouseHoverEvent, value); }
5167 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5170 public event EventHandler MouseLeave {
5171 add { Events.AddHandler (MouseLeaveEvent, value); }
5172 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5175 public event MouseEventHandler MouseMove {
5176 add { Events.AddHandler (MouseMoveEvent, value); }
5177 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5180 public event MouseEventHandler MouseUp {
5181 add { Events.AddHandler (MouseUpEvent, value); }
5182 remove { Events.RemoveHandler (MouseUpEvent, value); }
5185 [EditorBrowsable(EditorBrowsableState.Advanced)]
5187 public event MouseEventHandler MouseWheel {
5188 add { Events.AddHandler (MouseWheelEvent, value); }
5189 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5192 public event EventHandler Move {
5193 add { Events.AddHandler (MoveEvent, value); }
5194 remove { Events.RemoveHandler (MoveEvent, value); }
5197 public event PaintEventHandler Paint {
5198 add { Events.AddHandler (PaintEvent, value); }
5199 remove { Events.RemoveHandler (PaintEvent, value); }
5202 public event EventHandler ParentChanged {
5203 add { Events.AddHandler (ParentChangedEvent, value); }
5204 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5207 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5208 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5209 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5212 public event QueryContinueDragEventHandler QueryContinueDrag {
5213 add { Events.AddHandler (QueryContinueDragEvent, value); }
5214 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5217 public event EventHandler Resize {
5218 add { Events.AddHandler (ResizeEvent, value); }
5219 remove { Events.RemoveHandler (ResizeEvent, value); }
5222 public event EventHandler RightToLeftChanged {
5223 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5224 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5227 public event EventHandler SizeChanged {
5228 add { Events.AddHandler (SizeChangedEvent, value); }
5229 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5232 public event EventHandler StyleChanged {
5233 add { Events.AddHandler (StyleChangedEvent, value); }
5234 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5237 public event EventHandler SystemColorsChanged {
5238 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5239 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5242 public event EventHandler TabIndexChanged {
5243 add { Events.AddHandler (TabIndexChangedEvent, value); }
5244 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5247 public event EventHandler TabStopChanged {
5248 add { Events.AddHandler (TabStopChangedEvent, value); }
5249 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5252 public event EventHandler TextChanged {
5253 add { Events.AddHandler (TextChangedEvent, value); }
5254 remove { Events.RemoveHandler (TextChangedEvent, value); }
5257 public event EventHandler Validated {
5258 add { Events.AddHandler (ValidatedEvent, value); }
5259 remove { Events.RemoveHandler (ValidatedEvent, value); }
5262 public event CancelEventHandler Validating {
5263 add { Events.AddHandler (ValidatingEvent, value); }
5264 remove { Events.RemoveHandler (ValidatingEvent, value); }
5267 public event EventHandler VisibleChanged {
5268 add { Events.AddHandler (VisibleChangedEvent, value); }
5269 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5272 #endregion // Events