1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2006 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
25 // Partially based on work by:
26 // Aleksey Ryabchuk ryabchuk@yahoo.com
27 // Alexandre Pigolkine pigolkine@gmx.de
28 // Dennis Hayes dennish@raytek.com
29 // Jaak Simm jaaksimm@firm.ee
30 // John Sohn jsohn@columbus.rr.com
39 using System.ComponentModel;
40 using System.ComponentModel.Design;
41 using System.ComponentModel.Design.Serialization;
42 using System.Collections;
43 using System.Diagnostics;
45 using System.Drawing.Drawing2D;
46 using System.Reflection;
47 using System.Runtime.InteropServices;
48 using System.Security;
49 using System.Threading;
51 namespace System.Windows.Forms
53 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
54 [DefaultProperty("Text")]
55 [DefaultEvent("Click")]
56 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
57 [ToolboxItemFilter("System.Windows.Forms")]
58 public class Control : Component, ISynchronizeInvoke, IWin32Window
60 #region Local Variables
63 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
64 Rectangle explicit_bounds; // explicitly set bounds
65 internal object creator_thread; // thread that created the control
66 internal ControlNativeWindow window; // object for native window handle
67 string name; // for object naming
70 bool is_created; // true if OnCreateControl has been sent
71 internal bool has_focus; // true if control has focus
72 internal bool is_visible; // true if control is visible
73 internal bool is_entered; // is the mouse inside the control?
74 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
75 bool is_accessible; // true if the control is visible to accessibility applications
76 bool is_captured; // tracks if the control has captured the mouse
77 internal bool is_toplevel; // tracks if the control is a toplevel window
78 bool is_recreating; // tracks if the handle for the control is being recreated
79 bool causes_validation; // tracks if validation is executed on changes
80 bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
81 int tab_index; // position in tab order of siblings
82 bool tab_stop; // is the control a tab stop?
83 bool is_disposed; // has the window already been disposed?
84 Size client_size; // size of the client area (window excluding decorations)
85 Rectangle client_rect; // rectangle with the client area (window excluding decorations)
86 ControlStyles control_style; // rather win32-specific, style bits for control
88 bool layout_pending; // true if our parent needs to re-layout us
89 object control_tag; // object that contains data about our control
90 internal int mouse_clicks; // Counter for mouse clicks
91 Cursor cursor; // Cursor for the window
92 internal bool allow_drop; // true if the control accepts droping objects on it
93 Region clip_region; // User-specified clip region for the window
96 internal Color foreground_color; // foreground color for control
97 internal Color background_color; // background color for control
98 Image background_image; // background image for control
99 internal Font font; // font for control
100 string text; // window/title text for control
101 internal BorderStyle border_style; // Border style of control
104 int layout_suspended;
105 internal AnchorStyles anchor_style; // anchoring requirements for our control
106 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
107 // Please leave the next 4 as internal until DefaultLayout (2.0) is rewritten
108 internal int dist_left; // distance to the left border of the parent
109 internal int dist_top; // distance to the top border of the parent
110 internal int dist_right; // distance to the right border of the parent
111 internal int dist_bottom; // distance to the bottom border of the parent
113 // to be categorized...
114 static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
115 ControlCollection child_controls; // our children
116 Control parent; // our parent control
117 AccessibleObject accessibility_object; // object that contains accessibility information about our control
118 BindingContext binding_context;
119 RightToLeft right_to_left; // drawing direction for control
120 ContextMenu context_menu; // Context menu associated with the control
123 Graphics 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;
725 ime_mode = ImeMode.Inherit;
728 use_compatible_text_rendering = Application.use_compatible_text_rendering;
729 padding = new Padding(0);
730 maximum_size = new Size();
731 minimum_size = new Size();
732 preferred_size = new Size();
733 margin = this.DefaultMargin;
734 layout_engine = this.LayoutEngine;
737 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
738 ControlStyles.Selectable | ControlStyles.StandardClick |
739 ControlStyles.StandardDoubleClick;
741 control_style |= ControlStyles.UseTextForAccessibility;
745 background_image = null;
749 window = new ControlNativeWindow(this);
750 child_controls = CreateControlsInstance();
751 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
752 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
753 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
754 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
760 public Control(Control parent, string text) : this() {
765 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
770 bounds.Height=height;
771 SetBounds(left, top, width, height, BoundsSpecified.All);
775 public Control(string text) : this() {
779 public Control(string text, int left, int top, int width, int height) : this() {
783 bounds.Height=height;
784 SetBounds(left, top, width, height, BoundsSpecified.All);
788 private delegate void RemoveDelegate(object c);
790 protected override void Dispose(bool disposing) {
791 if (!is_disposed && disposing) {
804 if (invalid_region!=null) {
805 invalid_region.Dispose();
808 if (this.InvokeRequired) {
809 if (Application.MessageLoop) {
810 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
811 this.BeginInvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
815 lock (Control.controls) {
816 Control.controls.Remove(this);
821 if (parent != null) {
822 parent.Controls.Remove(this);
825 Control [] children = child_controls.GetAllControls ();
826 for (int i=0; i<children.Length; i++) {
827 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
828 children[i].Dispose();
833 base.Dispose(disposing);
835 #endregion // Public Constructors
837 #region Internal Properties
838 internal BorderStyle InternalBorderStyle {
844 if (!Enum.IsDefined (typeof (BorderStyle), value))
845 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
847 if (border_style != value) {
848 border_style = value;
850 if (IsHandleCreated) {
851 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
857 #endregion // Internal Properties
859 #region Private & Internal Methods
860 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
861 AsyncMethodResult result;
862 AsyncMethodData data;
869 if (!p.IsHandleCreated) {
870 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
876 result = new AsyncMethodResult ();
877 data = new AsyncMethodData ();
879 data.Handle = window.Handle;
880 data.Method = method;
882 data.Result = result;
885 if (!ExecutionContext.IsFlowSuppressed ()) {
886 data.Context = ExecutionContext.Capture ();
889 #if !MWF_ON_MSRUNTIME
890 if (SecurityManager.SecurityEnabled) {
891 data.Stack = CompressedStack.GetCompressedStack ();
896 XplatUI.SendAsyncMethod (data);
901 internal void PointToClient (ref int x, ref int y)
903 XplatUI.ScreenToClient (Handle, ref x, ref y);
906 internal void PointToScreen (ref int x, ref int y)
908 XplatUI.ClientToScreen (Handle, ref x, ref y);
911 internal bool IsRecreating {
913 return is_recreating;
917 internal Graphics DeviceContext {
918 get { return Hwnd.bmp_g; }
921 private void ImageBufferNeedsRedraw () {
922 if (invalid_region != null)
923 invalid_region.Dispose();
924 invalid_region = new Region (ClientRectangle);
927 private Bitmap ImageBuffer {
930 CreateBuffers(this.Width, this.Height);
936 internal void CreateBuffers (int width, int height) {
945 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
946 dc_mem = Graphics.FromImage (bmp_mem);
947 ImageBufferNeedsRedraw ();
950 internal void InvalidateBuffers ()
952 if (dc_mem != null) {
958 ImageBufferNeedsRedraw ();
961 internal static void SetChildColor(Control parent) {
964 for (int i=0; i < parent.child_controls.Count; i++) {
965 child=parent.child_controls[i];
966 if (child.child_controls.Count>0) {
967 SetChildColor(child);
973 internal bool Select(Control control) {
974 IContainerControl container;
976 if (control == null) {
980 container = GetContainerControl();
981 if (container != null) {
982 container.ActiveControl = control;
984 if (control.IsHandleCreated) {
985 XplatUI.SetFocus(control.window.Handle);
990 internal void SelectChild (Control control)
992 if (control.IsHandleCreated)
993 XplatUI.SetFocus (control.window.Handle);
996 internal virtual void DoDefaultAction() {
997 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1000 internal static int LowOrder (int param) {
1001 return ((int)(short)(param & 0xffff));
1004 internal static int HighOrder (int param) {
1005 return ((int)(short)(param >> 16));
1008 // This method exists so controls overriding OnPaintBackground can have default background painting done
1009 internal virtual void PaintControlBackground (PaintEventArgs pevent)
1011 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1012 if (parent != null) {
1013 PaintEventArgs parent_pe;
1014 GraphicsState state;
1016 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1018 state = parent_pe.Graphics.Save();
1019 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1020 parent.OnPaintBackground(parent_pe);
1021 parent_pe.Graphics.Restore(state);
1023 state = parent_pe.Graphics.Save();
1024 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1025 parent.OnPaint(parent_pe);
1026 parent_pe.Graphics.Restore(state);
1027 parent_pe.SetGraphics(null);
1031 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1032 if (parent != null) {
1033 PaintEventArgs parent_pe;
1035 GraphicsState state;
1038 hwnd = Hwnd.ObjectFromHandle(Handle);
1041 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1043 region = new Region ();
1045 region.Union(ClientRectangle);
1047 foreach (Rectangle r in hwnd.ClipRectangles) {
1051 state = parent_pe.Graphics.Save();
1052 parent_pe.Graphics.Clip = region;
1054 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1055 parent.OnPaintBackground(parent_pe);
1056 parent_pe.Graphics.Restore(state);
1058 state = parent_pe.Graphics.Save();
1059 parent_pe.Graphics.Clip = region;
1061 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1062 parent.OnPaint(parent_pe);
1063 parent_pe.Graphics.Restore(state);
1064 parent_pe.SetGraphics(null);
1066 region.Intersect(clip_region);
1067 pevent.Graphics.Clip = region;
1072 if (background_image == null) {
1073 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));
1077 DrawBackgroundImage (pevent.Graphics);
1080 void DrawBackgroundImage (Graphics g)
1082 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1083 g.FillRectangle (b, ClientRectangle);
1087 internal virtual void DndEnter (DragEventArgs e)
1094 internal virtual void DndOver (DragEventArgs e)
1101 internal virtual void DndDrop (DragEventArgs e)
1105 } catch (Exception exc) {
1106 Console.Error.WriteLine ("MWF: Exception while dropping:");
1107 Console.Error.WriteLine (exc);
1111 internal virtual void DndLeave (EventArgs e)
1118 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1125 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1128 OnQueryContinueDrag(e);
1132 internal static MouseButtons FromParamToMouseButtons (int param) {
1133 MouseButtons buttons = MouseButtons.None;
1135 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1136 buttons |= MouseButtons.Left;
1138 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1139 buttons |= MouseButtons.Middle;
1141 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1142 buttons |= MouseButtons.Right;
1148 internal void FireEnter ()
1150 OnEnter (EventArgs.Empty);
1153 internal void FireLeave ()
1155 OnLeave (EventArgs.Empty);
1158 internal void FireValidating (CancelEventArgs ce)
1163 internal void FireValidated ()
1165 OnValidated (EventArgs.Empty);
1168 internal virtual bool ProcessControlMnemonic(char charCode) {
1169 return ProcessMnemonic(charCode);
1172 private static Control FindFlatForward(Control container, Control start) {
1178 end = container.child_controls.Count;
1180 if (start != null) {
1181 index = start.tab_index;
1187 for (int i = 0, pos = -1; i < end; i++) {
1188 if (start == container.child_controls[i]) {
1193 if (found == null) {
1194 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1195 found = container.child_controls[i];
1197 } else if (found.tab_index > container.child_controls[i].tab_index) {
1198 if (container.child_controls[i].tab_index > index) {
1199 found = container.child_controls[i];
1206 private static Control FindControlForward(Control container, Control start) {
1211 if (start == null) {
1212 return FindFlatForward(container, start);
1215 if (start.child_controls != null && start.child_controls.Count > 0 &&
1216 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1217 return FindControlForward(start, null);
1220 while (start != container) {
1221 found = FindFlatForward(start.parent, start);
1222 if (found != null) {
1225 start = start.parent;
1231 private static Control FindFlatBackward(Control container, Control start) {
1237 end = container.child_controls.Count;
1239 if (start != null) {
1240 index = start.tab_index;
1242 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1244 for (int i = 0; i < end; i++) {
1245 if (container.child_controls[i].tab_index > index) {
1246 index = container.child_controls[i].tab_index;
1254 for (int i = end - 1; i >= 0; i--) {
1255 if (start == container.child_controls[i]) {
1260 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1261 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1262 found = container.child_controls[i];
1269 private static Control FindControlBackward(Control container, Control start) {
1271 Control found = null;
1273 if (start == null) {
1274 found = FindFlatBackward(container, start);
1276 else if (start != container) {
1277 if (start.parent != null) {
1278 found = FindFlatBackward(start.parent, start);
1280 if (found == null) {
1281 if (start.parent != container)
1282 return start.parent;
1288 if (found == null || start.parent == null)
1291 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1292 found.child_controls != null && found.child_controls.Count > 0)) {
1293 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1294 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1295 found = FindFlatBackward(found, null);
1305 if (start != null) {
1306 found = FindFlatBackward(start.parent, start);
1307 if (found == null) {
1308 if (start.parent != container) {
1309 return start.parent;
1313 if (found == null) {
1314 found = FindFlatBackward(container, start);
1317 if (container != start) {
1318 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1319 found = FindControlBackward(found, null);
1320 if (found != null) {
1329 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1330 if (GetStyle(ControlStyles.StandardClick)) {
1331 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1333 OnDoubleClick(EventArgs.Empty);
1335 OnClick(EventArgs.Empty);
1345 private void CheckDataBindings ()
1347 if (data_bindings == null)
1350 BindingContext binding_context = BindingContext;
1351 foreach (Binding binding in data_bindings) {
1352 binding.Check (binding_context);
1357 private void ChangeParent(Control new_parent) {
1361 Color pre_fore_color;
1362 Color pre_back_color;
1363 RightToLeft pre_rtl;
1365 // These properties are inherited from our parent
1366 // Get them pre parent-change and then send events
1367 // if they are changed after we have our new parent
1368 pre_enabled = Enabled;
1369 pre_visible = Visible;
1371 pre_fore_color = ForeColor;
1372 pre_back_color = BackColor;
1373 pre_rtl = RightToLeft;
1374 // MS doesn't seem to send a CursorChangedEvent
1376 parent = new_parent;
1378 if (IsHandleCreated)
1379 XplatUI.SetParent(Handle,
1380 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1382 OnParentChanged(EventArgs.Empty);
1384 if (pre_enabled != Enabled) {
1385 OnEnabledChanged(EventArgs.Empty);
1388 if (pre_visible != Visible) {
1389 OnVisibleChanged(EventArgs.Empty);
1392 if (pre_font != Font) {
1393 OnFontChanged(EventArgs.Empty);
1396 if (pre_fore_color != ForeColor) {
1397 OnForeColorChanged(EventArgs.Empty);
1400 if (pre_back_color != BackColor) {
1401 OnBackColorChanged(EventArgs.Empty);
1404 if (pre_rtl != RightToLeft) {
1405 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1406 // because when RTL changes they have to recreate the win32 control
1407 // We don't really need that (until someone runs into compatibility issues)
1408 OnRightToLeftChanged(EventArgs.Empty);
1411 if ((new_parent != null) && new_parent.Created && !Created) {
1415 if ((binding_context == null) && Created) {
1416 OnBindingContextChanged(EventArgs.Empty);
1420 private void UpdateDistances() {
1421 if ((parent != null) && (parent.layout_suspended == 0)) {
1422 dist_left = bounds.X;
1423 dist_top = bounds.Y;
1424 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1425 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1428 #endregion // Private & Internal Methods
1430 #region Public Static Properties
1431 public static Color DefaultBackColor {
1433 return ThemeEngine.Current.DefaultControlBackColor;
1437 public static Font DefaultFont {
1439 return ThemeEngine.Current.DefaultFont;
1443 public static Color DefaultForeColor {
1445 return ThemeEngine.Current.DefaultControlForeColor;
1449 public static Keys ModifierKeys {
1451 return XplatUI.State.ModifierKeys;
1455 public static MouseButtons MouseButtons {
1457 return XplatUI.State.MouseButtons;
1461 public static Point MousePosition {
1463 return Cursor.Position;
1469 public static bool CheckForIllegalCrossThreadCalls
1472 return verify_thread_handle;
1476 verify_thread_handle = value;
1480 #endregion // Public Static Properties
1482 #region Public Instance Properties
1483 [EditorBrowsable(EditorBrowsableState.Advanced)]
1485 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1486 public AccessibleObject AccessibilityObject {
1488 if (accessibility_object==null) {
1489 accessibility_object=CreateAccessibilityInstance();
1491 return accessibility_object;
1495 [EditorBrowsable(EditorBrowsableState.Advanced)]
1497 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1498 public string AccessibleDefaultActionDescription {
1500 return AccessibilityObject.default_action;
1504 AccessibilityObject.default_action=value;
1509 [DefaultValue(null)]
1510 [MWFCategory("Accessibility")]
1511 public string AccessibleDescription {
1513 return AccessibilityObject.description;
1517 AccessibilityObject.description=value;
1522 [DefaultValue(null)]
1523 [MWFCategory("Accessibility")]
1524 public string AccessibleName {
1526 return AccessibilityObject.Name;
1530 AccessibilityObject.Name=value;
1534 [DefaultValue(AccessibleRole.Default)]
1535 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1536 public AccessibleRole AccessibleRole {
1538 return AccessibilityObject.role;
1542 AccessibilityObject.role=value;
1546 [DefaultValue(false)]
1547 [MWFCategory("Behavior")]
1548 public virtual bool AllowDrop {
1554 if (allow_drop == value)
1557 if (IsHandleCreated) {
1559 XplatUI.SetAllowDrop (Handle, value);
1565 [RefreshProperties(RefreshProperties.Repaint)]
1566 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1567 [MWFCategory("Layout")]
1568 public virtual AnchorStyles Anchor {
1570 return anchor_style;
1576 if (parent != null) {
1577 parent.PerformLayout(this, "Parent");
1583 // XXX: Implement me!
1586 public virtual bool AutoSize {
1588 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1592 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1597 public virtual Size MaximumSize {
1599 return maximum_size;
1602 maximum_size = value;
1606 public virtual Size MinimumSize {
1608 return minimum_size;
1611 minimum_size = value;
1617 [MWFCategory("Appearance")]
1618 public virtual Color BackColor {
1620 if (background_color.IsEmpty) {
1622 Color pcolor = parent.BackColor;
1623 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1626 return DefaultBackColor;
1628 return background_color;
1632 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1633 throw new ArgumentException("Transparent background colors are not supported on this control");
1636 if (background_color != value) {
1637 background_color=value;
1638 SetChildColor(this);
1639 OnBackColorChanged(EventArgs.Empty);
1646 [DefaultValue(null)]
1647 [MWFCategory("Appearance")]
1648 public virtual Image BackgroundImage {
1650 return background_image;
1654 if (background_image!=value) {
1655 background_image=value;
1656 OnBackgroundImageChanged(EventArgs.Empty);
1661 [EditorBrowsable(EditorBrowsableState.Advanced)]
1663 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1664 public virtual BindingContext BindingContext {
1666 if (binding_context != null)
1667 return binding_context;
1670 binding_context = Parent.BindingContext;
1671 return binding_context;
1674 if (binding_context != value) {
1675 binding_context = value;
1676 OnBindingContextChanged(EventArgs.Empty);
1681 [EditorBrowsable(EditorBrowsableState.Advanced)]
1683 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1686 return bounds.Y+bounds.Height;
1690 [EditorBrowsable(EditorBrowsableState.Advanced)]
1692 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1693 public Rectangle Bounds {
1699 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1703 [EditorBrowsable(EditorBrowsableState.Advanced)]
1705 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1706 public bool CanFocus {
1708 if (IsHandleCreated && Visible && Enabled) {
1715 [EditorBrowsable(EditorBrowsableState.Advanced)]
1717 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1718 public bool CanSelect {
1722 if (!GetStyle(ControlStyles.Selectable)) {
1727 while (parent != null) {
1728 if (!parent.is_visible || !parent.is_enabled) {
1732 parent = parent.parent;
1738 internal virtual bool InternalCapture {
1748 [EditorBrowsable(EditorBrowsableState.Advanced)]
1750 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1751 public bool Capture {
1753 return this.is_captured;
1757 if (this.IsHandleCreated && value != is_captured) {
1760 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1762 XplatUI.UngrabWindow(this.window.Handle);
1763 is_captured = false;
1769 [DefaultValue(true)]
1770 [MWFCategory("Focus")]
1771 public bool CausesValidation {
1773 return this.causes_validation;
1777 if (this.causes_validation != value) {
1778 causes_validation = value;
1779 OnCausesValidationChanged(EventArgs.Empty);
1784 [EditorBrowsable(EditorBrowsableState.Advanced)]
1786 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1787 public Rectangle ClientRectangle {
1789 client_rect.Width = client_size.Width;
1790 client_rect.Height = client_size.Height;
1795 [EditorBrowsable(EditorBrowsableState.Advanced)]
1797 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1798 public Size ClientSize {
1801 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1802 return ((Form)this).form_parent_window.ClientSize;
1810 this.SetClientSizeCore(value.Width, value.Height);
1814 [EditorBrowsable(EditorBrowsableState.Advanced)]
1816 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1817 [DescriptionAttribute("ControlCompanyNameDescr")]
1818 public String CompanyName {
1820 return "Mono Project, Novell, Inc.";
1824 [EditorBrowsable(EditorBrowsableState.Advanced)]
1826 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1827 public bool ContainsFocus {
1829 IntPtr focused_window;
1831 focused_window = XplatUI.GetFocus();
1832 if (IsHandleCreated) {
1833 if (focused_window == Handle) {
1837 for (int i=0; i < child_controls.Count; i++) {
1838 if (child_controls[i].ContainsFocus) {
1847 [DefaultValue(null)]
1848 [MWFCategory("Behavior")]
1849 public virtual ContextMenu ContextMenu {
1851 return context_menu;
1855 if (context_menu != value) {
1856 context_menu = value;
1857 OnContextMenuChanged(EventArgs.Empty);
1863 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1864 public ControlCollection Controls {
1866 return this.child_controls;
1870 [EditorBrowsable(EditorBrowsableState.Advanced)]
1872 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1873 public bool Created {
1875 return (!is_disposed && is_created);
1879 [AmbientValue(null)]
1880 [MWFCategory("Appearance")]
1881 public virtual Cursor Cursor {
1883 if (cursor != null) {
1887 if (parent != null) {
1888 return parent.Cursor;
1891 return Cursors.Default;
1895 if (cursor != value) {
1900 if (IsHandleCreated) {
1901 pt = Cursor.Position;
1903 if (bounds.Contains(pt) || Capture) {
1904 if (GetChildAtPoint(pt) == null) {
1905 if (cursor != null) {
1906 XplatUI.SetCursor(window.Handle, cursor.handle);
1908 if (parent != null) {
1909 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1911 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1918 OnCursorChanged(EventArgs.Empty);
1924 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1925 [ParenthesizePropertyName(true)]
1926 [RefreshProperties(RefreshProperties.All)]
1927 [MWFCategory("Data")]
1928 public ControlBindingsCollection DataBindings {
1930 if (data_bindings == null)
1931 data_bindings = new ControlBindingsCollection (this);
1932 return data_bindings;
1936 [EditorBrowsable(EditorBrowsableState.Advanced)]
1938 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1939 public virtual Rectangle DisplayRectangle {
1941 return ClientRectangle;
1945 [EditorBrowsable(EditorBrowsableState.Advanced)]
1947 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1948 public bool Disposing {
1955 [RefreshProperties(RefreshProperties.Repaint)]
1956 [DefaultValue(DockStyle.None)]
1957 [MWFCategory("Layout")]
1958 public virtual DockStyle Dock {
1964 if (dock_style == value) {
1970 if (dock_style == DockStyle.None) {
1971 if (explicit_bounds == Rectangle.Empty)
1972 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1974 Bounds = explicit_bounds;
1977 if (parent != null) {
1978 parent.PerformLayout(this, "Parent");
1981 OnDockChanged(EventArgs.Empty);
1987 [MWFCategory("Behavior")]
1988 public bool Enabled {
1994 if (parent != null) {
1995 return parent.Enabled;
2003 bool old_value = is_enabled;
2006 if (old_value != value && !value && this.has_focus)
2007 SelectNextControl(this, true, true, true, true);
2009 OnEnabledChanged (EventArgs.Empty);
2013 [EditorBrowsable(EditorBrowsableState.Advanced)]
2015 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2016 public virtual bool Focused {
2018 return this.has_focus;
2023 [AmbientValue(null)]
2025 [MWFCategory("Appearance")]
2026 public virtual Font Font {
2032 if (Parent != null && Parent.Font != null) {
2039 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2041 if (font != null && font.Equals (value)) {
2047 OnFontChanged (EventArgs.Empty);
2052 [MWFCategory("Appearance")]
2053 public virtual Color ForeColor {
2055 if (foreground_color.IsEmpty) {
2057 return parent.ForeColor;
2059 return DefaultForeColor;
2061 return foreground_color;
2065 if (foreground_color != value) {
2066 foreground_color=value;
2068 OnForeColorChanged(EventArgs.Empty);
2075 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2076 public IntPtr Handle { // IWin32Window
2079 if (verify_thread_handle) {
2080 if (this.InvokeRequired) {
2081 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2085 if (!IsHandleCreated) {
2088 return window.Handle;
2092 [EditorBrowsable(EditorBrowsableState.Advanced)]
2094 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2095 public bool HasChildren {
2097 if (this.child_controls.Count>0) {
2104 [EditorBrowsable(EditorBrowsableState.Always)]
2106 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2109 return this.bounds.Height;
2113 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2117 [AmbientValue(ImeMode.Inherit)]
2119 [MWFCategory("Behavior")]
2120 public ImeMode ImeMode {
2122 if (ime_mode == ImeMode.Inherit) {
2124 return parent.ImeMode;
2126 return ImeMode.NoControl; // default value
2132 if (ime_mode != value) {
2135 OnImeModeChanged(EventArgs.Empty);
2140 [EditorBrowsable(EditorBrowsableState.Advanced)]
2142 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2143 public bool InvokeRequired { // ISynchronizeInvoke
2145 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2152 [EditorBrowsable(EditorBrowsableState.Advanced)]
2154 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2155 public bool IsAccessible {
2157 return is_accessible;
2161 is_accessible = value;
2165 [EditorBrowsable(EditorBrowsableState.Advanced)]
2167 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2168 public bool IsDisposed {
2170 return this.is_disposed;
2174 [EditorBrowsable(EditorBrowsableState.Advanced)]
2176 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2177 public bool IsHandleCreated {
2179 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2180 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2181 if (hwnd != null && !hwnd.zombie)
2190 public virtual Layout.LayoutEngine LayoutEngine {
2191 get { return new Layout.DefaultLayout (); }
2195 [EditorBrowsable(EditorBrowsableState.Always)]
2197 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2200 return this.bounds.X;
2204 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2209 [MWFCategory("Layout")]
2210 public Point Location {
2212 return new Point(bounds.X, bounds.Y);
2216 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2221 [Localizable (true)]
2222 public Padding Margin {
2223 get { return this.margin; }
2224 set { this.margin = value; }
2229 public string Name {
2241 public Padding Padding {
2253 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2254 public Control Parent {
2260 if (value == this) {
2261 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2264 if (parent!=value) {
2266 parent.Controls.Remove(this);
2271 value.Controls.Add(this);
2276 [EditorBrowsable(EditorBrowsableState.Advanced)]
2278 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2279 public string ProductName {
2281 Type t = typeof (AssemblyProductAttribute);
2282 Assembly assembly = GetType().Module.Assembly;
2283 object [] attrs = assembly.GetCustomAttributes (t, false);
2284 AssemblyProductAttribute a = null;
2285 // On MS we get a NullRefException if product attribute is not
2287 if (attrs != null && attrs.Length > 0)
2288 a = (AssemblyProductAttribute) attrs [0];
2293 [EditorBrowsable(EditorBrowsableState.Advanced)]
2295 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2296 public string ProductVersion {
2298 Type t = typeof (AssemblyVersionAttribute);
2299 Assembly assembly = GetType().Module.Assembly;
2300 object [] attrs = assembly.GetCustomAttributes (t, false);
2301 if (attrs == null || attrs.Length < 1)
2303 return ((AssemblyVersionAttribute)attrs [0]).Version;
2307 [EditorBrowsable(EditorBrowsableState.Advanced)]
2309 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2310 public bool RecreatingHandle {
2312 return is_recreating;
2316 [EditorBrowsable(EditorBrowsableState.Advanced)]
2318 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2319 public Region Region {
2325 if (IsHandleCreated) {
2326 XplatUI.SetClipRegion(Handle, value);
2328 clip_region = value;
2332 [EditorBrowsable(EditorBrowsableState.Advanced)]
2334 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2337 return this.bounds.X+this.bounds.Width;
2341 [AmbientValue(RightToLeft.Inherit)]
2343 [MWFCategory("Appearance")]
2344 public virtual RightToLeft RightToLeft {
2346 if (right_to_left == RightToLeft.Inherit) {
2348 return parent.RightToLeft;
2350 return RightToLeft.No; // default value
2352 return right_to_left;
2356 if (value != right_to_left) {
2357 right_to_left = value;
2358 OnRightToLeftChanged(EventArgs.Empty);
2363 [EditorBrowsable(EditorBrowsableState.Advanced)]
2364 public override ISite Site {
2372 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2374 BackColor = ap.BackColor;
2375 ForeColor = ap.ForeColor;
2383 [MWFCategory("Layout")]
2386 return new Size(Width, Height);
2390 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2395 [MergableProperty(false)]
2396 [MWFCategory("Behavior")]
2397 public int TabIndex {
2399 if (tab_index != -1) {
2406 if (tab_index != value) {
2408 OnTabIndexChanged(EventArgs.Empty);
2414 [DefaultValue(true)]
2415 [MWFCategory("Behavior")]
2416 public bool TabStop {
2422 if (tab_stop != value) {
2424 OnTabStopChanged(EventArgs.Empty);
2429 [Localizable(false)]
2431 [TypeConverter(typeof(StringConverter))]
2432 [DefaultValue(null)]
2433 [MWFCategory("Data")]
2440 control_tag = value;
2446 [BindableAttribute(true)]
2447 [MWFCategory("Appearance")]
2448 public virtual string Text {
2450 // Our implementation ignores ControlStyles.CacheText - we always cache
2455 if (value == null) {
2456 value = String.Empty;
2461 if (IsHandleCreated) {
2462 /* we need to call .SetWindowStyle here instead of just .Text
2463 because the presence/absence of Text (== "" or not) can cause
2464 other window style things to appear/disappear */
2465 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2466 XplatUI.Text(Handle, text);
2468 OnTextChanged (EventArgs.Empty);
2473 [EditorBrowsable(EditorBrowsableState.Always)]
2475 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2478 return this.bounds.Y;
2482 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2486 [EditorBrowsable(EditorBrowsableState.Advanced)]
2488 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2489 public Control TopLevelControl {
2493 while (p.parent != null) {
2497 return p is Form ? p : null;
2502 [MWFCategory("Behavior")]
2503 public bool Visible {
2507 } else if (parent != null) {
2508 return parent.Visible;
2515 SetVisibleCore(value);
2519 [EditorBrowsable(EditorBrowsableState.Always)]
2521 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2524 return this.bounds.Width;
2528 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2532 [EditorBrowsable(EditorBrowsableState.Never)]
2534 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2535 public IWindowTarget WindowTarget {
2544 #endregion // Public Instance Properties
2546 #region Protected Instance Properties
2547 protected virtual CreateParams CreateParams {
2549 CreateParams create_params = new CreateParams();
2552 create_params.Caption = Text;
2555 create_params.Caption = text;
2559 create_params.X = Left;
2562 create_params.X = this.bounds.X;
2566 create_params.Y = Top;
2569 create_params.Y = this.bounds.Y;
2573 create_params.Width = Width;
2576 create_params.Width = this.bounds.Width;
2580 create_params.Height = Height;
2583 create_params.Height = this.bounds.Height;
2587 create_params.ClassName = XplatUI.DefaultClassName;
2588 create_params.ClassStyle = 0;
2589 create_params.ExStyle = 0;
2590 create_params.Param = 0;
2593 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2596 if ((parent!=null) && (parent.IsHandleCreated)) {
2597 create_params.Parent = parent.Handle;
2600 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2603 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2607 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2610 switch (border_style) {
2611 case BorderStyle.FixedSingle:
2612 create_params.Style |= (int) WindowStyles.WS_BORDER;
2614 case BorderStyle.Fixed3D:
2615 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2619 return create_params;
2623 protected virtual ImeMode DefaultImeMode {
2625 return ImeMode.Inherit;
2630 protected virtual Padding DefaultMargin {
2631 get { return new Padding (3); }
2635 protected virtual Size DefaultSize {
2637 return new Size(0, 0);
2641 protected int FontHeight {
2651 protected bool RenderRightToLeft {
2653 return (this.right_to_left == RightToLeft.Yes);
2657 protected bool ResizeRedraw {
2659 return GetStyle(ControlStyles.ResizeRedraw);
2663 SetStyle(ControlStyles.ResizeRedraw, value);
2667 [EditorBrowsable(EditorBrowsableState.Advanced)]
2669 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2670 protected virtual bool ShowFocusCues {
2676 [EditorBrowsable(EditorBrowsableState.Advanced)]
2678 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2679 protected bool ShowKeyboardCues {
2684 #endregion // Protected Instance Properties
2686 #region Public Static Methods
2687 [EditorBrowsable(EditorBrowsableState.Advanced)]
2688 public static Control FromChildHandle(IntPtr handle) {
2689 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2692 [EditorBrowsable(EditorBrowsableState.Advanced)]
2693 public static Control FromHandle(IntPtr handle) {
2694 return Control.ControlNativeWindow.ControlFromHandle(handle);
2697 public static bool IsMnemonic(char charCode, string text) {
2700 amp = text.IndexOf('&');
2703 if (amp + 1 < text.Length) {
2704 if (text[amp + 1] != '&') {
2705 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2715 #region Protected Static Methods
2716 [EditorBrowsable(EditorBrowsableState.Advanced)]
2717 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2720 c = Control.FromHandle(hWnd);
2730 #region Public Instance Methods
2731 [EditorBrowsable(EditorBrowsableState.Advanced)]
2732 public IAsyncResult BeginInvoke(Delegate method) {
2733 object [] prms = null;
2734 if (method is EventHandler)
2735 prms = new object [] { this, EventArgs.Empty };
2736 return BeginInvokeInternal(method, prms, false);
2739 [EditorBrowsable(EditorBrowsableState.Advanced)]
2740 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2741 return BeginInvokeInternal (method, args, false);
2744 public void BringToFront() {
2745 if (parent != null) {
2746 parent.child_controls.SetChildIndex(this, 0);
2749 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2753 public bool Contains(Control ctl) {
2754 while (ctl != null) {
2763 public void CreateControl() {
2765 throw new ObjectDisposedException(GetType().FullName.ToString());
2771 if (!IsHandleCreated) {
2779 Control [] controls = child_controls.GetAllControls ();
2780 for (int i=0; i<controls.Length; i++) {
2781 controls [i].CreateControl ();
2784 UpdateChildrenZOrder();
2786 if (binding_context == null) { // seem to be sent whenever it's null?
2787 OnBindingContextChanged(EventArgs.Empty);
2793 public Graphics CreateGraphics() {
2794 if (!IsHandleCreated) {
2795 this.CreateHandle();
2797 return Graphics.FromHwnd(this.window.Handle);
2800 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2801 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2804 [EditorBrowsable(EditorBrowsableState.Advanced)]
2805 public object EndInvoke (IAsyncResult async_result) {
2806 AsyncMethodResult result = (AsyncMethodResult) async_result;
2807 return result.EndInvoke ();
2810 public Form FindForm() {
2823 public bool Focus() {
2824 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2827 is_focusing = false;
2832 public Control GetChildAtPoint(Point pt) {
2833 // Microsoft's version of this function doesn't seem to work, so I can't check
2834 // if we only consider children or also grandchildren, etc.
2835 // I'm gonna say 'children only'
2836 for (int i=0; i<child_controls.Count; i++) {
2837 if (child_controls[i].Bounds.Contains(pt)) {
2838 return child_controls[i];
2844 public IContainerControl GetContainerControl() {
2845 Control current = this;
2847 while (current!=null) {
2848 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2849 return (IContainerControl)current;
2851 current = current.parent;
2856 public Control GetNextControl(Control ctl, bool forward) {
2858 if (!this.Contains(ctl)) {
2863 ctl = FindControlForward(this, ctl);
2866 ctl = FindControlBackward(this, ctl);
2876 public virtual Size GetPreferredSize (Size proposedSize) {
2877 return preferred_size;
2881 public void Hide() {
2882 this.Visible = false;
2885 public void Invalidate() {
2886 Invalidate(ClientRectangle, false);
2889 public void Invalidate(bool invalidateChildren) {
2890 Invalidate(ClientRectangle, invalidateChildren);
2893 public void Invalidate(System.Drawing.Rectangle rc) {
2894 Invalidate(rc, false);
2897 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2898 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2902 NotifyInvalidate(rc);
2904 XplatUI.Invalidate(Handle, rc, false);
2906 if (invalidateChildren) {
2907 Control [] controls = child_controls.GetAllControls ();
2908 for (int i=0; i<controls.Length; i++)
2909 controls [i].Invalidate ();
2911 OnInvalidated(new InvalidateEventArgs(rc));
2914 public void Invalidate(System.Drawing.Region region) {
2915 Invalidate(region, false);
2918 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2919 RectangleF bounds = region.GetBounds (CreateGraphics ());
2920 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2921 invalidateChildren);
2924 public object Invoke (Delegate method) {
2925 object [] prms = null;
2926 if (method is EventHandler)
2927 prms = new object [] { this, EventArgs.Empty };
2929 return Invoke(method, prms);
2932 public object Invoke (Delegate method, object[] args) {
2933 if (!this.InvokeRequired) {
2934 return method.DynamicInvoke(args);
2937 IAsyncResult result = BeginInvoke (method, args);
2938 return EndInvoke(result);
2941 internal object InvokeInternal (Delegate method, bool disposing) {
2942 return InvokeInternal(method, null, disposing);
2945 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2946 if (!this.InvokeRequired) {
2947 return method.DynamicInvoke(args);
2950 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2951 return EndInvoke(result);
2954 [EditorBrowsable(EditorBrowsableState.Advanced)]
2955 public void PerformLayout() {
2956 PerformLayout(null, null);
2960 private void SetImplicitBounds (int x, int y, int width, int height)
2962 Rectangle saved_bounds = explicit_bounds;
2963 SetBounds (x, y, width, height);
2964 explicit_bounds = saved_bounds;
2968 [EditorBrowsable(EditorBrowsableState.Advanced)]
2969 public void PerformLayout(Control affectedControl, string affectedProperty) {
2970 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2972 if (layout_suspended > 0) {
2973 layout_pending = true;
2977 layout_pending = false;
2979 // Prevent us from getting messed up
2982 // Perform all Dock and Anchor calculations
2986 this.layout_engine.Layout(this, levent);
2988 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2990 AnchorStyles anchor;
2993 space = DisplayRectangle;
2995 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2996 Control [] controls = child_controls.GetAllControls ();
2997 for (int i = controls.Length - 1; i >= 0; i--) {
2998 child = controls [i];
3000 if (!child.Visible) {
3004 switch (child.Dock) {
3005 case DockStyle.None: {
3010 case DockStyle.Left: {
3011 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3012 space.X+=child.Width;
3013 space.Width-=child.Width;
3017 case DockStyle.Top: {
3018 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3019 space.Y+=child.Height;
3020 space.Height-=child.Height;
3024 case DockStyle.Right: {
3025 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3026 space.Width-=child.Width;
3030 case DockStyle.Bottom: {
3031 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3032 space.Height-=child.Height;
3038 for (int i = controls.Length - 1; i >= 0; i--) {
3041 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3042 if (child.Dock == DockStyle.Fill) {
3043 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3047 space = DisplayRectangle;
3049 for (int i=0; i < controls.Length; i++) {
3055 child = controls[i];
3057 // If the control is docked we don't need to do anything
3058 if (child.Dock != DockStyle.None) {
3062 anchor = child.Anchor;
3066 width = child.Width;
3067 height = child.Height;
3069 if ((anchor & AnchorStyles.Left) !=0 ) {
3070 if ((anchor & AnchorStyles.Right) != 0) {
3071 width = space.Width - child.dist_right - left;
3073 ; // Left anchored only, nothing to be done
3075 } else if ((anchor & AnchorStyles.Right) != 0) {
3076 left = space.Width - child.dist_right - width;
3078 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3079 // This calculates from scratch every time:
3080 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3083 if ((anchor & AnchorStyles.Top) !=0 ) {
3084 if ((anchor & AnchorStyles.Bottom) != 0) {
3085 height = space.Height - child.dist_bottom - top;
3087 ; // Top anchored only, nothing to be done
3089 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3090 top = space.Height - child.dist_bottom - height;
3092 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3093 // This calculates from scratch every time:
3094 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3106 child.SetImplicitBounds(left, top, width, height);
3110 // Let everyone know
3114 // Need to make sure we decremend layout_suspended
3120 public Point PointToClient (Point p) {
3124 XplatUI.ScreenToClient (Handle, ref x, ref y);
3126 return new Point (x, y);
3129 public Point PointToScreen(Point p) {
3133 XplatUI.ClientToScreen(Handle, ref x, ref y);
3135 return new Point(x, y);
3138 public virtual bool PreProcessMessage(ref Message msg) {
3139 return InternalPreProcessMessage (ref msg);
3142 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3145 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3146 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3148 if (!ProcessCmdKey(ref msg, key_data)) {
3149 if (IsInputKey(key_data)) {
3153 return ProcessDialogKey(key_data);
3157 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3158 if (IsInputChar((char)msg.WParam)) {
3161 return ProcessDialogChar((char)msg.WParam);
3162 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3163 return ProcessDialogChar((char)msg.WParam);
3168 public Rectangle RectangleToClient(Rectangle r) {
3169 return new Rectangle(PointToClient(r.Location), r.Size);
3172 public Rectangle RectangleToScreen(Rectangle r) {
3173 return new Rectangle(PointToScreen(r.Location), r.Size);
3176 public virtual void Refresh() {
3177 if (IsHandleCreated == true) {
3179 XplatUI.UpdateWindow(window.Handle);
3181 Control [] controls = child_controls.GetAllControls ();
3182 for (int i=0; i < controls.Length; i++) {
3183 controls[i].Refresh();
3189 [EditorBrowsable(EditorBrowsableState.Never)]
3190 public virtual void ResetBackColor() {
3191 BackColor = Color.Empty;
3194 [EditorBrowsable(EditorBrowsableState.Never)]
3195 public void ResetBindings() {
3196 data_bindings.Clear();
3199 [EditorBrowsable(EditorBrowsableState.Never)]
3200 public virtual void ResetCursor() {
3204 [EditorBrowsable(EditorBrowsableState.Never)]
3205 public virtual void ResetFont() {
3209 [EditorBrowsable(EditorBrowsableState.Never)]
3210 public virtual void ResetForeColor() {
3211 foreground_color = Color.Empty;
3214 [EditorBrowsable(EditorBrowsableState.Never)]
3215 public void ResetImeMode() {
3216 ime_mode = DefaultImeMode;
3219 [EditorBrowsable(EditorBrowsableState.Never)]
3220 public virtual void ResetRightToLeft() {
3221 right_to_left = RightToLeft.Inherit;
3224 public virtual void ResetText() {
3225 text = String.Empty;
3228 public void ResumeLayout() {
3229 ResumeLayout (true);
3232 public void ResumeLayout(bool performLayout) {
3233 if (layout_suspended > 0) {
3237 if (layout_suspended == 0) {
3238 Control [] controls = child_controls.GetAllControls ();
3239 for (int i=0; i<controls.Length; i++) {
3240 controls [i].UpdateDistances ();
3243 if (performLayout && layout_pending) {
3249 public void Scale(float ratio) {
3250 ScaleCore(ratio, ratio);
3253 public void Scale(float dx, float dy) {
3258 public void Scale(SizeF factor) {
3259 ScaleCore(factor.Width, factor.Height);
3263 public void Select() {
3264 Select(false, false);
3268 private void printTree(Control c, string t) {
3269 foreach(Control i in c.child_controls) {
3270 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3271 printTree(i, t+"\t");
3275 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3279 Console.WriteLine("{0}", this.FindForm());
3280 printTree(this, "\t");
3283 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3288 c = GetNextControl(c, forward);
3297 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3298 c.Select (true, true);
3301 } while (c != ctl); // If we wrap back to ourselves we stop
3306 public void SendToBack() {
3307 if (parent != null) {
3308 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3312 public void SetBounds(int x, int y, int width, int height) {
3313 SetBounds(x, y, width, height, BoundsSpecified.All);
3316 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3317 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3321 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3325 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3329 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3333 SetBoundsCore(x, y, width, height, specified);
3334 if (parent != null) {
3335 parent.PerformLayout(this, "Bounds");
3339 public void Show() {
3341 this.CreateControl();
3347 public void SuspendLayout() {
3351 public void Update() {
3352 if (IsHandleCreated) {
3353 XplatUI.UpdateWindow(window.Handle);
3356 #endregion // Public Instance Methods
3358 #region Protected Instance Methods
3359 [EditorBrowsable(EditorBrowsableState.Advanced)]
3360 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3361 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3362 throw new NotImplementedException();
3365 [EditorBrowsable(EditorBrowsableState.Advanced)]
3366 protected virtual AccessibleObject CreateAccessibilityInstance() {
3367 return new Control.ControlAccessibleObject(this);
3370 [EditorBrowsable(EditorBrowsableState.Advanced)]
3371 protected virtual ControlCollection CreateControlsInstance() {
3372 return new ControlCollection(this);
3375 [EditorBrowsable(EditorBrowsableState.Advanced)]
3376 protected virtual void CreateHandle() {
3378 throw new ObjectDisposedException(GetType().FullName.ToString());
3381 if (IsHandleCreated && !is_recreating) {
3385 window.CreateHandle(CreateParams);
3387 if (window.Handle != IntPtr.Zero) {
3388 lock (Control.controls) {
3389 if (!Control.controls.Contains(window.Handle)) {
3390 Control.controls.Add(this);
3394 creator_thread = Thread.CurrentThread;
3396 XplatUI.EnableWindow(window.Handle, is_enabled);
3397 XplatUI.SetVisible(window.Handle, is_visible, true);
3399 if (clip_region != null) {
3400 XplatUI.SetClipRegion(Handle, clip_region);
3403 // Set our handle with our parent
3404 if ((parent != null) && (parent.IsHandleCreated)) {
3405 XplatUI.SetParent(window.Handle, parent.Handle);
3408 // Set our handle as parent for our children
3409 Control [] children;
3411 children = child_controls.GetAllControls ();
3412 for (int i = 0; i < children.Length; i++ ) {
3413 if (!children[i].RecreatingHandle)
3414 XplatUI.SetParent(children[i].Handle, window.Handle);
3418 XplatUI.SetAllowDrop (Handle, allow_drop);
3420 // Find out where the window manager placed us
3421 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3422 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3426 OnHandleCreated(EventArgs.Empty);
3430 [EditorBrowsable(EditorBrowsableState.Advanced)]
3431 protected virtual void DefWndProc(ref Message m) {
3432 window.DefWndProc(ref m);
3435 [EditorBrowsable(EditorBrowsableState.Advanced)]
3436 protected virtual void DestroyHandle() {
3437 if (IsHandleCreated) {
3438 if (window != null) {
3439 window.DestroyHandle();
3444 protected internal bool GetStyle(ControlStyles flag) {
3445 return (control_style & flag) != 0;
3448 protected bool GetTopLevel() {
3452 [EditorBrowsable(EditorBrowsableState.Advanced)]
3453 protected virtual void InitLayout() {
3457 [EditorBrowsable(EditorBrowsableState.Advanced)]
3458 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3459 toInvoke.OnGotFocus(e);
3462 [EditorBrowsable(EditorBrowsableState.Advanced)]
3463 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3464 toInvoke.OnLostFocus(e);
3467 [EditorBrowsable(EditorBrowsableState.Advanced)]
3468 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3469 toInvoke.OnClick(e);
3472 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3473 toInvoke.OnPaint(e);
3476 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3477 toInvoke.OnPaintBackground(e);
3480 protected virtual bool IsInputChar (char charCode) {
3484 protected virtual bool IsInputKey (Keys keyData) {
3485 // Doc says this one calls IsInputChar; not sure what to do with that
3489 [EditorBrowsable(EditorBrowsableState.Advanced)]
3490 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3494 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3495 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3499 if (parent != null) {
3500 return parent.ProcessCmdKey(ref msg, keyData);
3506 protected virtual bool ProcessDialogChar(char charCode) {
3507 if (parent != null) {
3508 return parent.ProcessDialogChar (charCode);
3514 protected virtual bool ProcessDialogKey (Keys keyData) {
3515 if (parent != null) {
3516 return parent.ProcessDialogKey (keyData);
3522 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3524 KeyEventArgs key_event;
3527 case (int)Msg.WM_SYSKEYDOWN:
3528 case (int)Msg.WM_KEYDOWN: {
3529 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3530 OnKeyDown (key_event);
3531 return key_event.Handled;
3534 case (int)Msg.WM_SYSKEYUP:
3535 case (int)Msg.WM_KEYUP: {
3536 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3537 OnKeyUp (key_event);
3538 return key_event.Handled;
3541 case (int)Msg.WM_SYSCHAR:
3542 case (int)Msg.WM_CHAR: {
3543 KeyPressEventArgs key_press_event;
3545 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3546 OnKeyPress(key_press_event);
3548 msg.WParam = (IntPtr)key_press_event.KeyChar;
3550 return key_press_event.Handled;
3561 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3562 if (parent != null) {
3563 if (parent.ProcessKeyPreview(ref msg)) {
3568 return ProcessKeyEventArgs(ref msg);
3571 protected virtual bool ProcessKeyPreview(ref Message msg) {
3572 if (parent != null) {
3573 return parent.ProcessKeyPreview(ref msg);
3579 protected virtual bool ProcessMnemonic(char charCode) {
3584 [EditorBrowsable(EditorBrowsableState.Advanced)]
3585 protected void RaiseDragEvent(object key, DragEventArgs e) {
3589 [EditorBrowsable(EditorBrowsableState.Advanced)]
3590 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3594 [EditorBrowsable(EditorBrowsableState.Advanced)]
3595 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3599 [EditorBrowsable(EditorBrowsableState.Advanced)]
3600 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3604 private void SetIsRecreating ()
3608 foreach (Control c in Controls.GetAllControls()) {
3609 c.SetIsRecreating ();
3613 [EditorBrowsable(EditorBrowsableState.Advanced)]
3614 protected void RecreateHandle() {
3616 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3621 if (IsHandleCreated) {
3623 Console.WriteLine(" + handle is created, destroying it.");
3626 // WM_DESTROY will CreateHandle for us
3629 Console.WriteLine(" + handle is not created, creating it.");
3637 is_recreating = false;
3639 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3645 [EditorBrowsable(EditorBrowsableState.Advanced)]
3646 protected void ResetMouseEventArgs() {
3650 [EditorBrowsable(EditorBrowsableState.Advanced)]
3651 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3652 if (right_to_left == RightToLeft.No) {
3657 case ContentAlignment.TopLeft: {
3658 return ContentAlignment.TopRight;
3661 case ContentAlignment.TopRight: {
3662 return ContentAlignment.TopLeft;
3665 case ContentAlignment.MiddleLeft: {
3666 return ContentAlignment.MiddleRight;
3669 case ContentAlignment.MiddleRight: {
3670 return ContentAlignment.MiddleLeft;
3673 case ContentAlignment.BottomLeft: {
3674 return ContentAlignment.BottomRight;
3677 case ContentAlignment.BottomRight: {
3678 return ContentAlignment.BottomLeft;
3682 // if it's center it doesn't change
3688 [EditorBrowsable(EditorBrowsableState.Advanced)]
3689 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3690 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3694 if (align == HorizontalAlignment.Left) {
3695 return HorizontalAlignment.Right;
3698 // align must be HorizontalAlignment.Right
3699 return HorizontalAlignment.Left;
3702 [EditorBrowsable(EditorBrowsableState.Advanced)]
3703 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3704 if (right_to_left == RightToLeft.No) {
3708 if (align == LeftRightAlignment.Left) {
3709 return LeftRightAlignment.Right;
3712 // align must be LeftRightAlignment.Right;
3713 return LeftRightAlignment.Left;
3716 [EditorBrowsable(EditorBrowsableState.Advanced)]
3717 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3718 return RtlTranslateAlignment(align);
3721 [EditorBrowsable(EditorBrowsableState.Advanced)]
3722 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3723 return RtlTranslateAlignment(align);
3726 [EditorBrowsable(EditorBrowsableState.Advanced)]
3727 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3728 return RtlTranslateAlignment(align);
3731 [EditorBrowsable(EditorBrowsableState.Advanced)]
3732 protected virtual void ScaleCore(float dx, float dy) {
3738 location = new Point((int)(Left * dx), (int)(Top * dy));
3739 size = this.ClientSize;
3741 if (!GetStyle(ControlStyles.FixedWidth)) {
3742 size.Width = (int)(size.Width * dx);
3745 if (!GetStyle(ControlStyles.FixedHeight)) {
3746 size.Height = (int)(size.Height * dy);
3749 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3751 /* Now scale our children */
3752 Control [] controls = child_controls.GetAllControls ();
3753 for (int i=0; i < controls.Length; i++) {
3754 controls[i].Scale(dx, dy);
3760 protected virtual void Select(bool directed, bool forward) {
3761 IContainerControl container;
3763 container = GetContainerControl();
3764 if (container != null)
3765 container.ActiveControl = this;
3768 [EditorBrowsable(EditorBrowsableState.Advanced)]
3769 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3770 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3771 if (IsHandleCreated) {
3772 XplatUI.SetWindowPos(Handle, x, y, width, height);
3774 // Win32 automatically changes negative width/height to 0.
3775 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3776 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3778 if (width < 0 || height < 0) {
3780 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3784 UpdateBounds(x, y, width, height);
3789 [EditorBrowsable(EditorBrowsableState.Advanced)]
3790 protected virtual void SetClientSizeCore(int x, int y) {
3791 // Calculate the actual window size from the client size (it usually stays the same or grows)
3792 Rectangle ClientRect;
3793 Rectangle WindowRect;
3796 ClientRect = new Rectangle(0, 0, x, y);
3797 cp = this.CreateParams;
3799 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3803 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3806 [EditorBrowsable(EditorBrowsableState.Advanced)]
3807 protected internal void SetStyle(ControlStyles flag, bool value) {
3809 control_style |= flag;
3811 control_style &= ~flag;
3815 protected void SetTopLevel(bool value) {
3816 if ((GetTopLevel() != value) && (parent != null)) {
3817 throw new Exception();
3821 if (value == true) {
3831 is_toplevel = value;
3834 protected virtual void SetVisibleCore(bool value) {
3835 if (value!=is_visible) {
3836 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3842 if (IsHandleCreated) {
3843 XplatUI.SetVisible(Handle, value, true);
3844 // Explicitly move Toplevel windows to where we want them;
3845 // apparently moving unmapped toplevel windows doesn't work
3846 if (is_visible && (this is Form)) {
3847 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3851 OnVisibleChanged(EventArgs.Empty);
3853 if (value == false && parent != null && Focused) {
3856 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3857 container = (Control)parent.GetContainerControl();
3858 if (container != null) {
3859 container.SelectNextControl(this, true, true, true, true);
3863 if (parent != null) {
3864 parent.PerformLayout(this, "visible");
3866 PerformLayout(this, "visible");
3871 [EditorBrowsable(EditorBrowsableState.Advanced)]
3872 protected void UpdateBounds() {
3880 if (!IsHandleCreated) {
3884 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3886 UpdateBounds(x, y, width, height, client_width, client_height);
3889 [EditorBrowsable(EditorBrowsableState.Advanced)]
3890 protected void UpdateBounds(int x, int y, int width, int height) {
3894 // Calculate client rectangle
3895 rect = new Rectangle(0, 0, 0, 0);
3898 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3899 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3902 [EditorBrowsable(EditorBrowsableState.Advanced)]
3903 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3904 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3906 bool resized = false;
3908 // Needed to generate required notifications
3909 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3913 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3920 bounds.Height=height;
3922 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3923 explicit_bounds = bounds;
3925 client_size.Width=clientWidth;
3926 client_size.Height=clientHeight;
3929 OnLocationChanged(EventArgs.Empty);
3933 OnSizeChanged(EventArgs.Empty);
3937 [EditorBrowsable(EditorBrowsableState.Advanced)]
3938 protected void UpdateStyles() {
3939 if (!IsHandleCreated) {
3943 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3944 OnStyleChanged(EventArgs.Empty);
3947 private void UpdateZOrderOfChild(Control child) {
3948 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3951 index = child_controls.IndexOf(child);
3954 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3956 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3961 private void UpdateChildrenZOrder() {
3962 Control [] controls;
3964 if (!IsHandleCreated) {
3968 controls = child_controls.GetAllControls ();
3969 for (int i = 1; i < controls.Length; i++ ) {
3970 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3974 [EditorBrowsable(EditorBrowsableState.Advanced)]
3975 protected void UpdateZOrder() {
3976 if (parent != null) {
3977 parent.UpdateZOrderOfChild(this);
3981 protected virtual void WndProc(ref Message m) {
3983 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3985 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3989 switch((Msg)m.Msg) {
3990 case Msg.WM_DESTROY: {
3991 OnHandleDestroyed(EventArgs.Empty);
3993 IntPtr handle = window.Handle;
3995 window.InvalidateHandle();
3997 if (is_recreating) {
3999 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4003 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4005 is_recreating = false;
4010 case Msg.WM_WINDOWPOSCHANGED: {
4012 Rectangle save_bounds = explicit_bounds;
4014 explicit_bounds = save_bounds;
4015 if (GetStyle(ControlStyles.ResizeRedraw)) {
4022 // Nice description of what should happen when handling WM_PAINT
4023 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4024 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4025 case Msg.WM_PAINT: {
4026 PaintEventArgs paint_event;
4028 paint_event = XplatUI.PaintEventStart(Handle, true);
4030 if (paint_event == null) {
4034 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4035 // Just blit the previous image
4036 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4037 XplatUI.PaintEventEnd(Handle, true);
4042 Graphics back_dc = null;
4043 Bitmap backbuffer = null;
4044 if (ThemeEngine.Current.DoubleBufferingSupported) {
4045 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4046 backbuffer = ImageBuffer;
4047 back_dc = Graphics.FromImage (backbuffer);
4048 dc = paint_event.SetGraphics (back_dc);
4052 if (!GetStyle(ControlStyles.Opaque)) {
4053 OnPaintBackground(paint_event);
4056 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4057 OnPaintBackgroundInternal(paint_event);
4059 OnPaintInternal(paint_event);
4060 if (!paint_event.Handled) {
4061 OnPaint(paint_event);
4064 if (ThemeEngine.Current.DoubleBufferingSupported)
4065 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4066 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4067 paint_event.SetGraphics (dc);
4068 invalid_region.Exclude (paint_event.ClipRectangle);
4070 if (backbuffer != bmp_mem)
4071 backbuffer.Dispose();
4074 XplatUI.PaintEventEnd(Handle, true);
4079 case Msg.WM_ERASEBKGND: {
4080 // The DefWndProc will never have to handle this, we always paint the background in managed code
4081 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4082 // here but it just makes things more complicated...
4083 m.Result = (IntPtr)1;
4087 case Msg.WM_LBUTTONUP: {
4090 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4092 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4095 HandleClick(mouse_clicks, me);
4098 if (InternalCapture) {
4099 InternalCapture = false;
4102 if (mouse_clicks > 1) {
4108 case Msg.WM_LBUTTONDOWN: {
4110 Select (true, true);
4112 InternalCapture = true;
4113 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4114 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4120 case Msg.WM_LBUTTONDBLCLK: {
4121 InternalCapture = true;
4123 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4124 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4130 case Msg.WM_MBUTTONUP: {
4133 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4135 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4138 HandleClick(mouse_clicks, me);
4140 if (InternalCapture) {
4141 InternalCapture = false;
4143 if (mouse_clicks > 1) {
4149 case Msg.WM_MBUTTONDOWN: {
4150 InternalCapture = true;
4151 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4152 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4158 case Msg.WM_MBUTTONDBLCLK: {
4159 InternalCapture = true;
4161 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4162 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4167 case Msg.WM_RBUTTONUP: {
4171 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4172 pt = PointToScreen(pt);
4174 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4176 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4178 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4181 HandleClick(mouse_clicks, me);
4184 if (InternalCapture) {
4185 InternalCapture = false;
4188 if (mouse_clicks > 1) {
4194 case Msg.WM_RBUTTONDOWN: {
4195 InternalCapture = true;
4196 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4197 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4202 case Msg.WM_RBUTTONDBLCLK: {
4203 InternalCapture = true;
4205 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4206 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4211 case Msg.WM_CONTEXTMENU: {
4212 if (context_menu != null) {
4215 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4216 context_menu.Show(this, PointToClient(pt));
4224 case Msg.WM_MOUSEWHEEL: {
4226 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4227 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4228 HighOrder(m.WParam.ToInt32())));
4233 case Msg.WM_MOUSEMOVE: {
4234 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4236 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4241 case Msg.WM_MOUSE_ENTER: {
4246 OnMouseEnter(EventArgs.Empty);
4250 case Msg.WM_MOUSE_LEAVE: {
4252 OnMouseLeave(EventArgs.Empty);
4256 case Msg.WM_MOUSEHOVER: {
4257 OnMouseHover(EventArgs.Empty);
4261 case Msg.WM_SYSKEYUP: {
4262 if (ProcessKeyMessage(ref m)) {
4263 m.Result = IntPtr.Zero;
4267 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4271 if (form != null && form.ActiveMenu != null) {
4272 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4280 case Msg.WM_SYSKEYDOWN:
4281 case Msg.WM_KEYDOWN:
4283 case Msg.WM_SYSCHAR:
4285 if (ProcessKeyMessage(ref m)) {
4286 m.Result = IntPtr.Zero;
4295 if (m.LParam != IntPtr.Zero) {
4298 hi = new HELPINFO();
4300 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4301 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4303 mouse_pos = Control.MousePosition;
4305 OnHelpRequested(new HelpEventArgs(mouse_pos));
4306 m.Result = (IntPtr)1;
4310 case Msg.WM_KILLFOCUS: {
4311 this.has_focus = false;
4312 OnLostFocusInternal (EventArgs.Empty);
4316 case Msg.WM_SETFOCUS: {
4318 this.has_focus = true;
4319 OnGotFocusInternal (EventArgs.Empty);
4325 case Msg.WM_SYSCOLORCHANGE: {
4326 ThemeEngine.Current.ResetDefaults();
4327 OnSystemColorsChanged(EventArgs.Empty);
4332 case Msg.WM_SETCURSOR: {
4333 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4338 XplatUI.SetCursor(window.Handle, cursor.handle);
4339 m.Result = (IntPtr)1;
4350 #endregion // Public Instance Methods
4352 #region OnXXX methods
4353 [EditorBrowsable(EditorBrowsableState.Advanced)]
4354 protected virtual void OnBackColorChanged(EventArgs e) {
4355 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4358 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4361 [EditorBrowsable(EditorBrowsableState.Advanced)]
4362 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4363 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4366 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4369 [EditorBrowsable(EditorBrowsableState.Advanced)]
4370 protected virtual void OnBindingContextChanged(EventArgs e) {
4371 CheckDataBindings ();
4372 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4375 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4378 [EditorBrowsable(EditorBrowsableState.Advanced)]
4379 protected virtual void OnCausesValidationChanged(EventArgs e) {
4380 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4385 [EditorBrowsable(EditorBrowsableState.Advanced)]
4386 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4387 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4392 [EditorBrowsable(EditorBrowsableState.Advanced)]
4393 protected virtual void OnClick(EventArgs e) {
4394 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4399 [EditorBrowsable(EditorBrowsableState.Advanced)]
4400 protected virtual void OnContextMenuChanged(EventArgs e) {
4401 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4406 [EditorBrowsable(EditorBrowsableState.Advanced)]
4407 protected virtual void OnControlAdded(ControlEventArgs e) {
4408 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4413 [EditorBrowsable(EditorBrowsableState.Advanced)]
4414 protected virtual void OnControlRemoved(ControlEventArgs e) {
4415 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4420 [EditorBrowsable(EditorBrowsableState.Advanced)]
4421 protected virtual void OnCreateControl() {
4425 [EditorBrowsable(EditorBrowsableState.Advanced)]
4426 protected virtual void OnCursorChanged(EventArgs e) {
4427 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4432 [EditorBrowsable(EditorBrowsableState.Advanced)]
4433 protected virtual void OnDockChanged(EventArgs e) {
4434 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4439 [EditorBrowsable(EditorBrowsableState.Advanced)]
4440 protected virtual void OnDoubleClick(EventArgs e) {
4441 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4446 [EditorBrowsable(EditorBrowsableState.Advanced)]
4447 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4448 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4450 eh (this, drgevent);
4453 [EditorBrowsable(EditorBrowsableState.Advanced)]
4454 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4455 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4457 eh (this, drgevent);
4460 [EditorBrowsable(EditorBrowsableState.Advanced)]
4461 protected virtual void OnDragLeave(EventArgs e) {
4462 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4467 [EditorBrowsable(EditorBrowsableState.Advanced)]
4468 protected virtual void OnDragOver(DragEventArgs drgevent) {
4469 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4471 eh (this, drgevent);
4474 [EditorBrowsable(EditorBrowsableState.Advanced)]
4475 protected virtual void OnEnabledChanged(EventArgs e) {
4476 if (IsHandleCreated) {
4478 if (((Form)this).context == null) {
4479 XplatUI.EnableWindow(window.Handle, Enabled);
4482 XplatUI.EnableWindow(window.Handle, Enabled);
4487 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4491 for (int i=0; i<child_controls.Count; i++) {
4492 child_controls[i].OnParentEnabledChanged(e);
4496 [EditorBrowsable(EditorBrowsableState.Advanced)]
4497 protected virtual void OnEnter(EventArgs e) {
4498 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4503 [EditorBrowsable(EditorBrowsableState.Advanced)]
4504 protected virtual void OnFontChanged(EventArgs e) {
4505 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4508 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4511 [EditorBrowsable(EditorBrowsableState.Advanced)]
4512 protected virtual void OnForeColorChanged(EventArgs e) {
4513 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4516 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4519 [EditorBrowsable(EditorBrowsableState.Advanced)]
4520 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4521 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4523 eh (this, gfbevent);
4526 [EditorBrowsable(EditorBrowsableState.Advanced)]
4527 protected virtual void OnGotFocus(EventArgs e) {
4528 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4533 [EditorBrowsable(EditorBrowsableState.Advanced)]
4534 protected virtual void OnHandleCreated(EventArgs e) {
4535 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4540 [EditorBrowsable(EditorBrowsableState.Advanced)]
4541 protected virtual void OnHandleDestroyed(EventArgs e) {
4542 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4547 [EditorBrowsable(EditorBrowsableState.Advanced)]
4548 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4549 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4554 protected virtual void OnImeModeChanged(EventArgs e) {
4555 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4560 [EditorBrowsable(EditorBrowsableState.Advanced)]
4561 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4562 if (ThemeEngine.Current.DoubleBufferingSupported)
4563 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4564 // should this block be here? seems like it
4565 // would be more at home in
4566 // NotifyInvalidated..
4567 if (e.InvalidRect == ClientRectangle) {
4568 ImageBufferNeedsRedraw ();
4571 // we need this Inflate call here so
4572 // that the border of the rectangle is
4573 // considered Visible (the
4574 // invalid_region.IsVisible call) in
4575 // the WM_PAINT handling below.
4576 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4577 if (invalid_region == null)
4578 invalid_region = new Region (r);
4580 invalid_region.Union (r);
4584 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4589 [EditorBrowsable(EditorBrowsableState.Advanced)]
4590 protected virtual void OnKeyDown(KeyEventArgs e) {
4591 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4596 [EditorBrowsable(EditorBrowsableState.Advanced)]
4597 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4598 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4603 [EditorBrowsable(EditorBrowsableState.Advanced)]
4604 protected virtual void OnKeyUp(KeyEventArgs e) {
4605 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4610 [EditorBrowsable(EditorBrowsableState.Advanced)]
4611 protected virtual void OnLayout(LayoutEventArgs levent) {
4612 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4617 [EditorBrowsable(EditorBrowsableState.Advanced)]
4618 protected virtual void OnLeave(EventArgs e) {
4619 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4624 [EditorBrowsable(EditorBrowsableState.Advanced)]
4625 protected virtual void OnLocationChanged(EventArgs e) {
4627 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4632 [EditorBrowsable(EditorBrowsableState.Advanced)]
4633 protected virtual void OnLostFocus(EventArgs e) {
4634 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4639 [EditorBrowsable(EditorBrowsableState.Advanced)]
4640 protected virtual void OnMouseDown(MouseEventArgs e) {
4641 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4646 [EditorBrowsable(EditorBrowsableState.Advanced)]
4647 protected virtual void OnMouseEnter(EventArgs e) {
4648 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4653 [EditorBrowsable(EditorBrowsableState.Advanced)]
4654 protected virtual void OnMouseHover(EventArgs e) {
4655 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4660 [EditorBrowsable(EditorBrowsableState.Advanced)]
4661 protected virtual void OnMouseLeave(EventArgs e) {
4662 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4667 [EditorBrowsable(EditorBrowsableState.Advanced)]
4668 protected virtual void OnMouseMove(MouseEventArgs e) {
4669 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4674 [EditorBrowsable(EditorBrowsableState.Advanced)]
4675 protected virtual void OnMouseUp(MouseEventArgs e) {
4676 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4681 [EditorBrowsable(EditorBrowsableState.Advanced)]
4682 protected virtual void OnMouseWheel(MouseEventArgs e) {
4683 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4688 [EditorBrowsable(EditorBrowsableState.Advanced)]
4689 protected virtual void OnMove(EventArgs e) {
4690 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4695 [EditorBrowsable(EditorBrowsableState.Advanced)]
4696 protected virtual void OnNotifyMessage(Message m) {
4700 [EditorBrowsable(EditorBrowsableState.Advanced)]
4701 protected virtual void OnPaint(PaintEventArgs e) {
4702 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4707 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4711 internal virtual void OnPaintInternal(PaintEventArgs e) {
4715 internal virtual void OnGotFocusInternal (EventArgs e)
4720 internal virtual void OnLostFocusInternal (EventArgs e)
4725 [EditorBrowsable(EditorBrowsableState.Advanced)]
4726 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4727 PaintControlBackground (pevent);
4730 [EditorBrowsable(EditorBrowsableState.Advanced)]
4731 protected virtual void OnParentBackColorChanged(EventArgs e) {
4732 if (background_color.IsEmpty && background_image==null) {
4734 OnBackColorChanged(e);
4738 [EditorBrowsable(EditorBrowsableState.Advanced)]
4739 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4740 if (background_color.IsEmpty && background_image==null) {
4742 OnBackgroundImageChanged(e);
4746 [EditorBrowsable(EditorBrowsableState.Advanced)]
4747 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4748 if (binding_context==null) {
4749 binding_context=Parent.binding_context;
4750 OnBindingContextChanged(e);
4754 [EditorBrowsable(EditorBrowsableState.Advanced)]
4755 protected virtual void OnParentChanged(EventArgs e) {
4756 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4761 [EditorBrowsable(EditorBrowsableState.Advanced)]
4762 protected virtual void OnParentEnabledChanged(EventArgs e) {
4764 OnEnabledChanged(e);
4768 [EditorBrowsable(EditorBrowsableState.Advanced)]
4769 protected virtual void OnParentFontChanged(EventArgs e) {
4776 [EditorBrowsable(EditorBrowsableState.Advanced)]
4777 protected virtual void OnParentForeColorChanged(EventArgs e) {
4778 if (foreground_color.IsEmpty) {
4780 OnForeColorChanged(e);
4784 [EditorBrowsable(EditorBrowsableState.Advanced)]
4785 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4786 if (right_to_left==RightToLeft.Inherit) {
4788 OnRightToLeftChanged(e);
4792 [EditorBrowsable(EditorBrowsableState.Advanced)]
4793 protected virtual void OnParentVisibleChanged(EventArgs e) {
4795 OnVisibleChanged(e);
4799 [EditorBrowsable(EditorBrowsableState.Advanced)]
4800 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4801 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4806 [EditorBrowsable(EditorBrowsableState.Advanced)]
4807 protected virtual void OnResize(EventArgs e) {
4808 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4812 PerformLayout(this, "bounds");
4814 if (parent != null) {
4815 parent.PerformLayout();
4819 [EditorBrowsable(EditorBrowsableState.Advanced)]
4820 protected virtual void OnRightToLeftChanged(EventArgs e) {
4821 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4824 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4827 [EditorBrowsable(EditorBrowsableState.Advanced)]
4828 protected virtual void OnSizeChanged(EventArgs e) {
4829 InvalidateBuffers ();
4831 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4836 [EditorBrowsable(EditorBrowsableState.Advanced)]
4837 protected virtual void OnStyleChanged(EventArgs e) {
4838 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4843 [EditorBrowsable(EditorBrowsableState.Advanced)]
4844 protected virtual void OnSystemColorsChanged(EventArgs e) {
4845 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4850 [EditorBrowsable(EditorBrowsableState.Advanced)]
4851 protected virtual void OnTabIndexChanged(EventArgs e) {
4852 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4857 [EditorBrowsable(EditorBrowsableState.Advanced)]
4858 protected virtual void OnTabStopChanged(EventArgs e) {
4859 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4864 [EditorBrowsable(EditorBrowsableState.Advanced)]
4865 protected virtual void OnTextChanged(EventArgs e) {
4866 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4871 [EditorBrowsable(EditorBrowsableState.Advanced)]
4872 protected virtual void OnValidated(EventArgs e) {
4873 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4878 [EditorBrowsable(EditorBrowsableState.Advanced)]
4879 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4880 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4885 [EditorBrowsable(EditorBrowsableState.Advanced)]
4886 protected virtual void OnVisibleChanged(EventArgs e) {
4887 if ((parent != null) && !Created && Visible) {
4894 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4898 // We need to tell our kids
4899 for (int i=0; i<child_controls.Count; i++) {
4900 if (child_controls[i].Visible) {
4901 child_controls[i].OnParentVisibleChanged(e);
4905 #endregion // OnXXX methods
4908 static object BackColorChangedEvent = new object ();
4909 static object BackgroundImageChangedEvent = new object ();
4910 static object BindingContextChangedEvent = new object ();
4911 static object CausesValidationChangedEvent = new object ();
4912 static object ChangeUICuesEvent = new object ();
4913 static object ClickEvent = new object ();
4914 static object ContextMenuChangedEvent = new object ();
4915 static object ControlAddedEvent = new object ();
4916 static object ControlRemovedEvent = new object ();
4917 static object CursorChangedEvent = new object ();
4918 static object DockChangedEvent = new object ();
4919 static object DoubleClickEvent = new object ();
4920 static object DragDropEvent = new object ();
4921 static object DragEnterEvent = new object ();
4922 static object DragLeaveEvent = new object ();
4923 static object DragOverEvent = new object ();
4924 static object EnabledChangedEvent = new object ();
4925 static object EnterEvent = new object ();
4926 static object FontChangedEvent = new object ();
4927 static object ForeColorChangedEvent = new object ();
4928 static object GiveFeedbackEvent = new object ();
4929 static object GotFocusEvent = new object ();
4930 static object HandleCreatedEvent = new object ();
4931 static object HandleDestroyedEvent = new object ();
4932 static object HelpRequestedEvent = new object ();
4933 static object ImeModeChangedEvent = new object ();
4934 static object InvalidatedEvent = new object ();
4935 static object KeyDownEvent = new object ();
4936 static object KeyPressEvent = new object ();
4937 static object KeyUpEvent = new object ();
4938 static object LayoutEvent = new object ();
4939 static object LeaveEvent = new object ();
4940 static object LocationChangedEvent = new object ();
4941 static object LostFocusEvent = new object ();
4942 static object MouseDownEvent = new object ();
4943 static object MouseEnterEvent = new object ();
4944 static object MouseHoverEvent = new object ();
4945 static object MouseLeaveEvent = new object ();
4946 static object MouseMoveEvent = new object ();
4947 static object MouseUpEvent = new object ();
4948 static object MouseWheelEvent = new object ();
4949 static object MoveEvent = new object ();
4950 static object PaintEvent = new object ();
4951 static object ParentChangedEvent = new object ();
4952 static object QueryAccessibilityHelpEvent = new object ();
4953 static object QueryContinueDragEvent = new object ();
4954 static object ResizeEvent = new object ();
4955 static object RightToLeftChangedEvent = new object ();
4956 static object SizeChangedEvent = new object ();
4957 static object StyleChangedEvent = new object ();
4958 static object SystemColorsChangedEvent = new object ();
4959 static object TabIndexChangedEvent = new object ();
4960 static object TabStopChangedEvent = new object ();
4961 static object TextChangedEvent = new object ();
4962 static object ValidatedEvent = new object ();
4963 static object ValidatingEvent = new object ();
4964 static object VisibleChangedEvent = new object ();
4966 public event EventHandler BackColorChanged {
4967 add { Events.AddHandler (BackColorChangedEvent, value); }
4968 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4971 public event EventHandler BackgroundImageChanged {
4972 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4973 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4976 public event EventHandler BindingContextChanged {
4977 add { Events.AddHandler (BindingContextChangedEvent, value); }
4978 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4981 public event EventHandler CausesValidationChanged {
4982 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4983 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4986 public event UICuesEventHandler ChangeUICues {
4987 add { Events.AddHandler (ChangeUICuesEvent, value); }
4988 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4991 public event EventHandler Click {
4992 add { Events.AddHandler (ClickEvent, value); }
4993 remove { Events.RemoveHandler (ClickEvent, value); }
4996 public event EventHandler ContextMenuChanged {
4997 add { Events.AddHandler (ContextMenuChangedEvent, value); }
4998 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5001 [EditorBrowsable(EditorBrowsableState.Advanced)]
5003 public event ControlEventHandler ControlAdded {
5004 add { Events.AddHandler (ControlAddedEvent, value); }
5005 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5008 [EditorBrowsable(EditorBrowsableState.Advanced)]
5010 public event ControlEventHandler ControlRemoved {
5011 add { Events.AddHandler (ControlRemovedEvent, value); }
5012 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5015 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5016 public event EventHandler CursorChanged {
5017 add { Events.AddHandler (CursorChangedEvent, value); }
5018 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5020 public event EventHandler DockChanged {
5021 add { Events.AddHandler (DockChangedEvent, value); }
5022 remove { Events.RemoveHandler (DockChangedEvent, value); }
5025 public event EventHandler DoubleClick {
5026 add { Events.AddHandler (DoubleClickEvent, value); }
5027 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5030 public event DragEventHandler DragDrop {
5031 add { Events.AddHandler (DragDropEvent, value); }
5032 remove { Events.RemoveHandler (DragDropEvent, value); }
5035 public event DragEventHandler DragEnter {
5036 add { Events.AddHandler (DragEnterEvent, value); }
5037 remove { Events.RemoveHandler (DragEnterEvent, value); }
5040 public event EventHandler DragLeave {
5041 add { Events.AddHandler (DragLeaveEvent, value); }
5042 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5045 public event DragEventHandler DragOver {
5046 add { Events.AddHandler (DragOverEvent, value); }
5047 remove { Events.RemoveHandler (DragOverEvent, value); }
5050 public event EventHandler EnabledChanged {
5051 add { Events.AddHandler (EnabledChangedEvent, value); }
5052 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5055 public event EventHandler Enter {
5056 add { Events.AddHandler (EnterEvent, value); }
5057 remove { Events.RemoveHandler (EnterEvent, value); }
5060 public event EventHandler FontChanged {
5061 add { Events.AddHandler (FontChangedEvent, value); }
5062 remove { Events.RemoveHandler (FontChangedEvent, value); }
5065 public event EventHandler ForeColorChanged {
5066 add { Events.AddHandler (ForeColorChangedEvent, value); }
5067 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5070 public event GiveFeedbackEventHandler GiveFeedback {
5071 add { Events.AddHandler (GiveFeedbackEvent, value); }
5072 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5075 [EditorBrowsable(EditorBrowsableState.Advanced)]
5077 public event EventHandler GotFocus {
5078 add { Events.AddHandler (GotFocusEvent, value); }
5079 remove { Events.RemoveHandler (GotFocusEvent, value); }
5083 [EditorBrowsable(EditorBrowsableState.Advanced)]
5085 public event EventHandler HandleCreated {
5086 add { Events.AddHandler (HandleCreatedEvent, value); }
5087 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5090 [EditorBrowsable(EditorBrowsableState.Advanced)]
5092 public event EventHandler HandleDestroyed {
5093 add { Events.AddHandler (HandleDestroyedEvent, value); }
5094 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5097 public event HelpEventHandler HelpRequested {
5098 add { Events.AddHandler (HelpRequestedEvent, value); }
5099 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5102 public event EventHandler ImeModeChanged {
5103 add { Events.AddHandler (ImeModeChangedEvent, value); }
5104 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5107 [EditorBrowsable(EditorBrowsableState.Advanced)]
5109 public event InvalidateEventHandler Invalidated {
5110 add { Events.AddHandler (InvalidatedEvent, value); }
5111 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5114 public event KeyEventHandler KeyDown {
5115 add { Events.AddHandler (KeyDownEvent, value); }
5116 remove { Events.RemoveHandler (KeyDownEvent, value); }
5119 public event KeyPressEventHandler KeyPress {
5120 add { Events.AddHandler (KeyPressEvent, value); }
5121 remove { Events.RemoveHandler (KeyPressEvent, value); }
5124 public event KeyEventHandler KeyUp {
5125 add { Events.AddHandler (KeyUpEvent, value); }
5126 remove { Events.RemoveHandler (KeyUpEvent, value); }
5129 public event LayoutEventHandler Layout {
5130 add { Events.AddHandler (LayoutEvent, value); }
5131 remove { Events.RemoveHandler (LayoutEvent, value); }
5134 public event EventHandler Leave {
5135 add { Events.AddHandler (LeaveEvent, value); }
5136 remove { Events.RemoveHandler (LeaveEvent, value); }
5139 public event EventHandler LocationChanged {
5140 add { Events.AddHandler (LocationChangedEvent, value); }
5141 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5144 [EditorBrowsable(EditorBrowsableState.Advanced)]
5146 public event EventHandler LostFocus {
5147 add { Events.AddHandler (LostFocusEvent, value); }
5148 remove { Events.RemoveHandler (LostFocusEvent, value); }
5151 public event MouseEventHandler MouseDown {
5152 add { Events.AddHandler (MouseDownEvent, value); }
5153 remove { Events.RemoveHandler (MouseDownEvent, value); }
5156 public event EventHandler MouseEnter {
5157 add { Events.AddHandler (MouseEnterEvent, value); }
5158 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5161 public event EventHandler MouseHover {
5162 add { Events.AddHandler (MouseHoverEvent, value); }
5163 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5166 public event EventHandler MouseLeave {
5167 add { Events.AddHandler (MouseLeaveEvent, value); }
5168 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5171 public event MouseEventHandler MouseMove {
5172 add { Events.AddHandler (MouseMoveEvent, value); }
5173 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5176 public event MouseEventHandler MouseUp {
5177 add { Events.AddHandler (MouseUpEvent, value); }
5178 remove { Events.RemoveHandler (MouseUpEvent, value); }
5181 [EditorBrowsable(EditorBrowsableState.Advanced)]
5183 public event MouseEventHandler MouseWheel {
5184 add { Events.AddHandler (MouseWheelEvent, value); }
5185 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5188 public event EventHandler Move {
5189 add { Events.AddHandler (MoveEvent, value); }
5190 remove { Events.RemoveHandler (MoveEvent, value); }
5193 public event PaintEventHandler Paint {
5194 add { Events.AddHandler (PaintEvent, value); }
5195 remove { Events.RemoveHandler (PaintEvent, value); }
5198 public event EventHandler ParentChanged {
5199 add { Events.AddHandler (ParentChangedEvent, value); }
5200 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5203 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5204 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5205 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5208 public event QueryContinueDragEventHandler QueryContinueDrag {
5209 add { Events.AddHandler (QueryContinueDragEvent, value); }
5210 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5213 public event EventHandler Resize {
5214 add { Events.AddHandler (ResizeEvent, value); }
5215 remove { Events.RemoveHandler (ResizeEvent, value); }
5218 public event EventHandler RightToLeftChanged {
5219 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5220 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5223 public event EventHandler SizeChanged {
5224 add { Events.AddHandler (SizeChangedEvent, value); }
5225 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5228 public event EventHandler StyleChanged {
5229 add { Events.AddHandler (StyleChangedEvent, value); }
5230 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5233 public event EventHandler SystemColorsChanged {
5234 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5235 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5238 public event EventHandler TabIndexChanged {
5239 add { Events.AddHandler (TabIndexChangedEvent, value); }
5240 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5243 public event EventHandler TabStopChanged {
5244 add { Events.AddHandler (TabStopChangedEvent, value); }
5245 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5248 public event EventHandler TextChanged {
5249 add { Events.AddHandler (TextChangedEvent, value); }
5250 remove { Events.RemoveHandler (TextChangedEvent, value); }
5253 public event EventHandler Validated {
5254 add { Events.AddHandler (ValidatedEvent, value); }
5255 remove { Events.RemoveHandler (ValidatedEvent, value); }
5258 public event CancelEventHandler Validating {
5259 add { Events.AddHandler (ValidatingEvent, value); }
5260 remove { Events.RemoveHandler (ValidatingEvent, value); }
5263 public event EventHandler VisibleChanged {
5264 add { Events.AddHandler (VisibleChangedEvent, value); }
5265 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5268 #endregion // Events