1 // Permission is hereby granted, free of charge, to any person obtaining
2 // a copy of this software and associated documentation files (the
3 // "Software"), to deal in the Software without restriction, including
4 // without limitation the rights to use, copy, modify, merge, publish,
5 // distribute, sublicense, and/or sell copies of the Software, and to
6 // permit persons to whom the Software is furnished to do so, subject to
7 // the following conditions:
9 // The above copyright notice and this permission notice shall be
10 // included in all copies or substantial portions of the Software.
12 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
13 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
14 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
15 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
16 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
17 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
18 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 // Copyright (c) 2004-2006 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
25 // Partially based on work by:
26 // Aleksey Ryabchuk ryabchuk@yahoo.com
27 // Alexandre Pigolkine pigolkine@gmx.de
28 // Dennis Hayes dennish@raytek.com
29 // Jaak Simm jaaksimm@firm.ee
30 // John Sohn jsohn@columbus.rr.com
39 using System.ComponentModel;
40 using System.ComponentModel.Design;
41 using System.ComponentModel.Design.Serialization;
42 using System.Collections;
43 using System.Diagnostics;
45 using System.Drawing.Drawing2D;
46 using System.Reflection;
47 using System.Runtime.InteropServices;
48 using System.Security;
49 using System.Threading;
51 namespace System.Windows.Forms
53 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
54 [DefaultProperty("Text")]
55 [DefaultEvent("Click")]
56 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
57 [ToolboxItemFilter("System.Windows.Forms")]
58 public class Control : Component, ISynchronizeInvoke, IWin32Window
60 #region Local Variables
63 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
64 Rectangle explicit_bounds; // explicitly set bounds
65 internal object creator_thread; // thread that created the control
66 internal ControlNativeWindow window; // object for native window handle
67 string name; // for object naming
70 bool is_created; // true if OnCreateControl has been sent
71 internal bool has_focus; // true if control has focus
72 internal bool is_visible; // true if control is visible
73 internal bool is_entered; // is the mouse inside the control?
74 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
75 internal bool is_accessible; // true if the control is visible to accessibility applications
76 bool is_captured; // tracks if the control has captured the mouse
77 internal bool is_toplevel; // tracks if the control is a toplevel window
78 bool is_recreating; // tracks if the handle for the control is being recreated
79 bool causes_validation; // tracks if validation is executed on changes
80 internal bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
81 int tab_index; // position in tab order of siblings
82 internal bool tab_stop = true; // is the control a tab stop?
83 bool is_disposed; // has the window already been disposed?
84 internal Size client_size; // size of the client area (window excluding decorations)
85 internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
86 internal ControlStyles control_style; // rather win32-specific, style bits for control
87 internal ImeMode ime_mode = ImeMode.Inherit;
88 bool layout_pending; // true if our parent needs to re-layout us
89 internal object control_tag; // object that contains data about our control
90 internal int mouse_clicks; // Counter for mouse clicks
91 internal Cursor cursor; // Cursor for the window
92 internal bool allow_drop; // true if the control accepts droping objects on it
93 Region clip_region; // User-specified clip region for the window
96 internal Color foreground_color; // foreground color for control
97 internal Color background_color; // background color for control
98 internal Image background_image; // background image for control
99 internal Font font; // font for control
100 string text; // window/title text for control
101 internal BorderStyle border_style; // Border style of control
104 int layout_suspended;
105 internal AnchorStyles anchor_style; // anchoring requirements for our control
106 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
107 internal int dist_left; // distance to the left border of the parent
108 int dist_top; // distance to the top border of the parent
109 int dist_right; // distance to the right border of the parent
110 int dist_bottom; // distance to the bottom border of the parent
112 // to be categorized...
113 static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
114 internal ControlCollection child_controls; // our children
115 internal Control parent; // our parent control
116 AccessibleObject accessibility_object; // object that contains accessibility information about our control
117 BindingContext binding_context;
118 internal RightToLeft right_to_left; // drawing direction for control
119 internal ContextMenu context_menu; // Context menu associated with the control
122 Graphics dc_mem; // Graphics context for double buffering
123 Bitmap bmp_mem; // Bitmap for double buffering control
124 Region invalid_region;
126 ControlBindingsCollection data_bindings;
129 internal bool use_compatible_text_rendering;
130 static bool verify_thread_handle;
136 Layout.LayoutEngine layout_engine;
139 #endregion // Local Variables
141 #region Private Classes
142 // This helper class allows us to dispatch messages to Control.WndProc
143 internal class ControlNativeWindow : NativeWindow {
144 private Control owner;
146 public ControlNativeWindow(Control control) : base() {
151 public Control Owner {
157 static internal Control ControlFromHandle(IntPtr hWnd) {
158 ControlNativeWindow window;
160 window = (ControlNativeWindow)window_collection[hWnd];
161 if (window != null) {
168 static internal Control ControlFromChildHandle (IntPtr handle) {
169 ControlNativeWindow window;
171 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
172 while (hwnd != null) {
173 window = (ControlNativeWindow)window_collection[hwnd.Handle];
174 if (window != null) {
183 protected override void WndProc(ref Message m) {
184 owner.WndProc(ref m);
189 #region Public Classes
191 public class ControlAccessibleObject : AccessibleObject {
194 #region ControlAccessibleObject Constructors
195 public ControlAccessibleObject(Control ownerControl)
196 : base (ownerControl)
198 this.owner = ownerControl;
200 #endregion // ControlAccessibleObject Constructors
202 #region ControlAccessibleObject Public Instance Properties
203 public override string DefaultAction {
205 return base.DefaultAction;
209 public override string Description {
211 return base.Description;
215 public IntPtr Handle {
221 // We don't want to let them set it
225 public override string Help {
231 public override string KeyboardShortcut {
233 return base.KeyboardShortcut;
237 public override string Name {
247 public Control Owner {
253 public override AccessibleObject Parent {
260 public override AccessibleRole Role {
265 #endregion // ControlAccessibleObject Public Instance Properties
267 #region ControlAccessibleObject Public Instance Methods
268 public override int GetHelpTopic(out string FileName) {
269 return base.GetHelpTopic (out FileName);
272 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
273 public void NotifyClients(AccessibleEvents accEvent) {
274 throw new NotImplementedException();
277 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
278 public void NotifyClients(AccessibleEvents accEvent, int childID) {
279 throw new NotImplementedException();
282 public override string ToString() {
283 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
286 #endregion // ControlAccessibleObject Public Instance Methods
289 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
290 [ListBindable(false)]
291 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
292 #region ControlCollection Local Variables
295 Control[] all_controls;
297 #endregion // ControlCollection Local Variables
299 #region ControlCollection Public Constructor
300 public ControlCollection(Control owner) {
302 this.list=new ArrayList();
306 #region ControlCollection Public Instance Properties
313 public bool IsReadOnly {
315 return list.IsReadOnly;
319 public virtual Control this[int index] {
321 if (index < 0 || index >= list.Count) {
322 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
324 return (Control)list[index];
327 #endregion // ControlCollection Public Instance Properties
329 #region ControlCollection Private Instance Methods
330 public virtual void Add (Control value)
335 if (Contains (value)) {
336 owner.PerformLayout();
340 if (value.tab_index == -1) {
346 end = owner.child_controls.Count;
347 for (int i = 0; i < end; i++) {
348 index = owner.child_controls[i].tab_index;
353 value.tab_index = use;
356 if (value.parent != null) {
357 value.parent.Controls.Remove(value);
363 value.ChangeParent(owner);
367 owner.UpdateChildrenZOrder();
368 owner.PerformLayout(value, "Parent");
369 owner.OnControlAdded(new ControlEventArgs(value));
372 internal void AddToList (Control c)
378 internal virtual void AddImplicit (Control control)
380 if (impl_list == null)
381 impl_list = new ArrayList ();
383 if (AllContains (control))
387 impl_list.Add (control);
389 control.ChangeParent (owner);
390 control.InitLayout ();
391 owner.UpdateChildrenZOrder ();
392 owner.PerformLayout (control, "Parent");
393 owner.OnControlAdded (new ControlEventArgs (control));
396 public virtual void AddRange (Control[] controls)
398 if (controls == null)
399 throw new ArgumentNullException ("controls");
401 owner.SuspendLayout ();
404 for (int i = 0; i < controls.Length; i++)
407 owner.ResumeLayout ();
411 internal virtual void AddRangeImplicit (Control [] controls)
413 if (controls == null)
414 throw new ArgumentNullException ("controls");
416 owner.SuspendLayout ();
419 for (int i = 0; i < controls.Length; i++)
420 AddImplicit (controls [i]);
422 owner.ResumeLayout ();
426 public virtual void Clear ()
430 // MS sends remove events in reverse order
431 while (list.Count > 0) {
432 Remove((Control)list[list.Count - 1]);
436 internal virtual void ClearImplicit ()
438 if (impl_list == null)
444 public bool Contains (Control value)
446 for (int i = list.Count; i > 0; ) {
449 if (list [i] == value) {
450 // Do we need to do anything here?
457 internal bool ImplicitContains (Control value)
459 if (impl_list == null)
462 for (int i = impl_list.Count; i > 0; ) {
465 if (impl_list [i] == value) {
466 // Do we need to do anything here?
473 internal bool AllContains (Control value)
475 return Contains (value) || ImplicitContains (value);
478 public void CopyTo (Array array, int index)
480 list.CopyTo(array, index);
483 public override bool Equals(object other) {
484 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
491 public int GetChildIndex(Control child) {
492 return GetChildIndex(child, false);
495 public int GetChildIndex(Control child, bool throwException) {
498 index=list.IndexOf(child);
500 if (index==-1 && throwException) {
501 throw new ArgumentException("Not a child control", "child");
506 public IEnumerator GetEnumerator() {
507 return list.GetEnumerator();
510 internal IEnumerator GetAllEnumerator ()
512 Control [] res = GetAllControls ();
513 return res.GetEnumerator ();
516 internal Control [] GetAllControls ()
518 if (all_controls != null)
521 if (impl_list == null) {
522 all_controls = (Control []) list.ToArray (typeof (Control));
526 all_controls = new Control [list.Count + impl_list.Count];
527 impl_list.CopyTo (all_controls);
528 list.CopyTo (all_controls, impl_list.Count);
533 public override int GetHashCode() {
534 return base.GetHashCode();
537 public int IndexOf(Control control) {
538 return list.IndexOf(control);
541 public virtual void Remove(Control value) {
542 owner.PerformLayout(value, "Parent");
543 owner.OnControlRemoved(new ControlEventArgs(value));
548 value.ChangeParent(null);
550 owner.UpdateChildrenZOrder();
553 internal virtual void RemoveImplicit (Control control)
555 if (impl_list != null) {
557 owner.PerformLayout (control, "Parent");
558 owner.OnControlRemoved (new ControlEventArgs (control));
559 impl_list.Remove (control);
561 control.ChangeParent (null);
562 owner.UpdateChildrenZOrder ();
565 public void RemoveAt(int index) {
566 if (index < 0 || index >= list.Count) {
567 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
569 Remove ((Control)list[index]);
572 public void SetChildIndex(Control child, int newIndex) {
575 old_index=list.IndexOf(child);
577 throw new ArgumentException("Not a child control", "child");
580 if (old_index==newIndex) {
585 list.RemoveAt(old_index);
587 if (newIndex>list.Count) {
590 list.Insert(newIndex, child);
592 child.UpdateZOrder();
593 owner.PerformLayout();
595 #endregion // ControlCollection Private Instance Methods
597 #region ControlCollection Interface Properties
598 object IList.this[int index] {
600 if (index<0 || index>=list.Count) {
601 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
607 if (!(value is Control)) {
608 throw new ArgumentException("Object of type Control required", "value");
612 Control ctrl = (Control) value;
615 ctrl.ChangeParent(owner);
619 owner.UpdateChildrenZOrder();
620 owner.PerformLayout(ctrl, "Parent");
624 bool IList.IsFixedSize {
630 bool ICollection.IsSynchronized {
632 return list.IsSynchronized;
636 object ICollection.SyncRoot {
638 return list.SyncRoot;
641 #endregion // ControlCollection Interface Properties
643 #region ControlCollection Interface Methods
644 int IList.Add(object value) {
646 throw new ArgumentNullException("value", "Cannot add null controls");
649 if (!(value is Control)) {
650 throw new ArgumentException("Object of type Control required", "value");
653 return list.Add(value);
656 bool IList.Contains(object value) {
657 if (!(value is Control)) {
658 throw new ArgumentException("Object of type Control required", "value");
661 return this.Contains((Control) value);
664 int IList.IndexOf(object value) {
665 if (!(value is Control)) {
666 throw new ArgumentException("Object of type Control required", "value");
669 return this.IndexOf((Control) value);
672 void IList.Insert(int index, object value) {
673 if (!(value is Control)) {
674 throw new ArgumentException("Object of type Control required", "value");
677 list.Insert(index, value);
680 void IList.Remove(object value) {
681 if (!(value is Control)) {
682 throw new ArgumentException("Object of type Control required", "value");
688 Object ICloneable.Clone() {
689 ControlCollection clone = new ControlCollection(this.owner);
690 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
693 #endregion // ControlCollection Interface Methods
695 #endregion // ControlCollection Class
697 #region Public Constructors
700 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
708 layout_pending = false;
710 causes_validation = true;
712 layout_suspended = 0;
716 right_to_left = RightToLeft.Inherit;
717 border_style = BorderStyle.None;
718 background_color = Color.Empty;
725 use_compatible_text_rendering = Application.use_compatible_text_rendering;
726 padding = new Padding(0);
727 maximum_size = new Size();
728 minimum_size = new Size();
729 preferred_size = new Size();
730 margin = this.DefaultMargin;
731 layout_engine = this.LayoutEngine;
734 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
735 ControlStyles.Selectable | ControlStyles.StandardClick |
736 ControlStyles.StandardDoubleClick;
738 control_style |= ControlStyles.UseTextForAccessibility;
742 background_image = null;
746 window = new ControlNativeWindow(this);
747 child_controls = CreateControlsInstance();
748 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
749 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
750 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
751 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
757 public Control(Control parent, string text) : this() {
762 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
767 bounds.Height=height;
768 SetBounds(left, top, width, height, BoundsSpecified.All);
772 public Control(string text) : this() {
776 public Control(string text, int left, int top, int width, int height) : this() {
780 bounds.Height=height;
781 SetBounds(left, top, width, height, BoundsSpecified.All);
785 private delegate void RemoveDelegate(object c);
787 protected override void Dispose(bool disposing) {
788 if (!is_disposed && disposing) {
801 if (invalid_region!=null) {
802 invalid_region.Dispose();
805 if (this.InvokeRequired) {
806 if (Application.MessageLoop) {
807 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
808 this.BeginInvokeInternal(new RemoveDelegate(controls.Remove), new object[] {this}, true);
812 lock (Control.controls) {
813 Control.controls.Remove(this);
818 if (parent != null) {
819 parent.Controls.Remove(this);
822 Control [] children = child_controls.GetAllControls ();
823 for (int i=0; i<children.Length; i++) {
824 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
825 children[i].Dispose();
830 base.Dispose(disposing);
832 #endregion // Public Constructors
834 #region Internal Properties
835 internal BorderStyle InternalBorderStyle {
841 if (!Enum.IsDefined (typeof (BorderStyle), value))
842 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
844 if (border_style != value) {
845 border_style = value;
847 if (IsHandleCreated) {
848 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
854 #endregion // Internal Properties
856 #region Private & Internal Methods
857 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
858 AsyncMethodResult result;
859 AsyncMethodData data;
866 if (!p.IsHandleCreated) {
867 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
873 result = new AsyncMethodResult ();
874 data = new AsyncMethodData ();
876 data.Handle = window.Handle;
877 data.Method = method;
879 data.Result = result;
882 if (!ExecutionContext.IsFlowSuppressed ()) {
883 data.Context = ExecutionContext.Capture ();
886 #if !MWF_ON_MSRUNTIME
887 if (SecurityManager.SecurityEnabled) {
888 data.Stack = CompressedStack.GetCompressedStack ();
893 XplatUI.SendAsyncMethod (data);
898 internal void PointToClient (ref int x, ref int y)
900 XplatUI.ScreenToClient (Handle, ref x, ref y);
903 internal void PointToScreen (ref int x, ref int y)
905 XplatUI.ClientToScreen (Handle, ref x, ref y);
908 internal bool IsRecreating {
910 return is_recreating;
914 internal Graphics DeviceContext {
916 if (dc_mem == null) {
917 CreateBuffers(this.Width, this.Height);
923 private void ImageBufferNeedsRedraw () {
924 if (invalid_region != null)
925 invalid_region.Dispose();
926 invalid_region = new Region (ClientRectangle);
929 private Bitmap ImageBuffer {
932 CreateBuffers(this.Width, this.Height);
938 internal void CreateBuffers (int width, int height) {
947 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
948 dc_mem = Graphics.FromImage (bmp_mem);
949 ImageBufferNeedsRedraw ();
952 internal void InvalidateBuffers ()
954 if (dc_mem != null) {
960 ImageBufferNeedsRedraw ();
963 internal static void SetChildColor(Control parent) {
966 for (int i=0; i < parent.child_controls.Count; i++) {
967 child=parent.child_controls[i];
968 if (child.child_controls.Count>0) {
969 SetChildColor(child);
975 internal bool Select(Control control) {
976 IContainerControl container;
978 if (control == null) {
982 container = GetContainerControl();
983 if (container != null) {
984 container.ActiveControl = control;
986 if (control.IsHandleCreated) {
987 XplatUI.SetFocus(control.window.Handle);
992 internal void SelectChild (Control control)
994 if (control.IsHandleCreated)
995 XplatUI.SetFocus (control.window.Handle);
998 internal virtual void DoDefaultAction() {
999 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1002 internal static int LowOrder (int param) {
1003 return ((int)(short)(param & 0xffff));
1006 internal static int HighOrder (int param) {
1007 return ((int)(short)(param >> 16));
1010 // This method exists so controls overriding OnPaintBackground can have default background painting done
1011 internal virtual void PaintControlBackground (PaintEventArgs pevent)
1013 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1014 if (parent != null) {
1015 PaintEventArgs parent_pe;
1016 GraphicsState state;
1018 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1020 state = parent_pe.Graphics.Save();
1021 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1022 parent.OnPaintBackground(parent_pe);
1023 parent_pe.Graphics.Restore(state);
1025 state = parent_pe.Graphics.Save();
1026 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1027 parent.OnPaint(parent_pe);
1028 parent_pe.Graphics.Restore(state);
1029 parent_pe.SetGraphics(null);
1033 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1034 if (parent != null) {
1035 PaintEventArgs parent_pe;
1037 GraphicsState state;
1040 hwnd = Hwnd.ObjectFromHandle(Handle);
1043 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1045 region = new Region ();
1047 region.Union(ClientRectangle);
1049 foreach (Rectangle r in hwnd.ClipRectangles) {
1053 state = parent_pe.Graphics.Save();
1054 parent_pe.Graphics.Clip = region;
1056 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1057 parent.OnPaintBackground(parent_pe);
1058 parent_pe.Graphics.Restore(state);
1060 state = parent_pe.Graphics.Save();
1061 parent_pe.Graphics.Clip = region;
1063 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1064 parent.OnPaint(parent_pe);
1065 parent_pe.Graphics.Restore(state);
1066 parent_pe.SetGraphics(null);
1068 region.Intersect(clip_region);
1069 pevent.Graphics.Clip = region;
1074 if (background_image == null) {
1075 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));
1079 DrawBackgroundImage (pevent.Graphics);
1082 void DrawBackgroundImage (Graphics g)
1084 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1085 g.FillRectangle (b, ClientRectangle);
1089 internal virtual void DndEnter (DragEventArgs e)
1096 internal virtual void DndOver (DragEventArgs e)
1103 internal virtual void DndDrop (DragEventArgs e)
1107 } catch (Exception exc) {
1108 Console.Error.WriteLine ("MWF: Exception while dropping:");
1109 Console.Error.WriteLine (exc);
1113 internal virtual void DndLeave (EventArgs e)
1120 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1127 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1130 OnQueryContinueDrag(e);
1134 internal static MouseButtons FromParamToMouseButtons (int param) {
1135 MouseButtons buttons = MouseButtons.None;
1137 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1138 buttons |= MouseButtons.Left;
1140 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1141 buttons |= MouseButtons.Middle;
1143 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1144 buttons |= MouseButtons.Right;
1150 internal void FireEnter ()
1152 OnEnter (EventArgs.Empty);
1155 internal void FireLeave ()
1157 OnLeave (EventArgs.Empty);
1160 internal void FireValidating (CancelEventArgs ce)
1165 internal void FireValidated ()
1167 OnValidated (EventArgs.Empty);
1170 internal virtual bool ProcessControlMnemonic(char charCode) {
1171 return ProcessMnemonic(charCode);
1174 private static Control FindFlatForward(Control container, Control start) {
1180 end = container.child_controls.Count;
1182 if (start != null) {
1183 index = start.tab_index;
1189 for (int i = 0, pos = -1; i < end; i++) {
1190 if (start == container.child_controls[i]) {
1195 if (found == null) {
1196 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1197 found = container.child_controls[i];
1199 } else if (found.tab_index > container.child_controls[i].tab_index) {
1200 if (container.child_controls[i].tab_index > index) {
1201 found = container.child_controls[i];
1208 private static Control FindControlForward(Control container, Control start) {
1213 if (start == null) {
1214 return FindFlatForward(container, start);
1217 if (start.child_controls != null && start.child_controls.Count > 0 &&
1218 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1219 return FindControlForward(start, null);
1222 while (start != container) {
1223 found = FindFlatForward(start.parent, start);
1224 if (found != null) {
1227 start = start.parent;
1233 private static Control FindFlatBackward(Control container, Control start) {
1239 end = container.child_controls.Count;
1241 if (start != null) {
1242 index = start.tab_index;
1244 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1246 for (int i = 0; i < end; i++) {
1247 if (container.child_controls[i].tab_index > index) {
1248 index = container.child_controls[i].tab_index;
1256 for (int i = end - 1; i >= 0; i--) {
1257 if (start == container.child_controls[i]) {
1262 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1263 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1264 found = container.child_controls[i];
1271 private static Control FindControlBackward(Control container, Control start) {
1273 Control found = null;
1275 if (start == null) {
1276 found = FindFlatBackward(container, start);
1278 else if (start != container) {
1279 if (start.parent != null) {
1280 found = FindFlatBackward(start.parent, start);
1282 if (found == null) {
1283 if (start.parent != container)
1284 return start.parent;
1290 if (found == null || start.parent == null)
1293 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1294 found.child_controls != null && found.child_controls.Count > 0)) {
1295 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1296 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1297 found = FindFlatBackward(found, null);
1307 if (start != null) {
1308 found = FindFlatBackward(start.parent, start);
1309 if (found == null) {
1310 if (start.parent != container) {
1311 return start.parent;
1315 if (found == null) {
1316 found = FindFlatBackward(container, start);
1319 if (container != start) {
1320 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1321 found = FindControlBackward(found, null);
1322 if (found != null) {
1331 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1332 if (GetStyle(ControlStyles.StandardClick)) {
1333 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1335 OnDoubleClick(EventArgs.Empty);
1337 OnClick(EventArgs.Empty);
1347 private void CheckDataBindings ()
1349 if (data_bindings == null)
1352 BindingContext binding_context = BindingContext;
1353 foreach (Binding binding in data_bindings) {
1354 binding.Check (binding_context);
1359 private void ChangeParent(Control new_parent) {
1363 Color pre_fore_color;
1364 Color pre_back_color;
1365 RightToLeft pre_rtl;
1367 // These properties are inherited from our parent
1368 // Get them pre parent-change and then send events
1369 // if they are changed after we have our new parent
1370 pre_enabled = Enabled;
1371 pre_visible = Visible;
1373 pre_fore_color = ForeColor;
1374 pre_back_color = BackColor;
1375 pre_rtl = RightToLeft;
1376 // MS doesn't seem to send a CursorChangedEvent
1378 parent = new_parent;
1380 if (IsHandleCreated)
1381 XplatUI.SetParent(Handle,
1382 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1384 OnParentChanged(EventArgs.Empty);
1386 if (pre_enabled != Enabled) {
1387 OnEnabledChanged(EventArgs.Empty);
1390 if (pre_visible != Visible) {
1391 OnVisibleChanged(EventArgs.Empty);
1394 if (pre_font != Font) {
1395 OnFontChanged(EventArgs.Empty);
1398 if (pre_fore_color != ForeColor) {
1399 OnForeColorChanged(EventArgs.Empty);
1402 if (pre_back_color != BackColor) {
1403 OnBackColorChanged(EventArgs.Empty);
1406 if (pre_rtl != RightToLeft) {
1407 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1408 // because when RTL changes they have to recreate the win32 control
1409 // We don't really need that (until someone runs into compatibility issues)
1410 OnRightToLeftChanged(EventArgs.Empty);
1413 if ((new_parent != null) && new_parent.Created && !Created) {
1417 if ((binding_context == null) && Created) {
1418 OnBindingContextChanged(EventArgs.Empty);
1422 private void UpdateDistances() {
1423 if ((parent != null) && (parent.layout_suspended == 0)) {
1424 dist_left = bounds.X;
1425 dist_top = bounds.Y;
1426 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1427 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1430 #endregion // Private & Internal Methods
1432 #region Public Static Properties
1433 public static Color DefaultBackColor {
1435 return ThemeEngine.Current.DefaultControlBackColor;
1439 public static Font DefaultFont {
1441 return ThemeEngine.Current.DefaultFont;
1445 public static Color DefaultForeColor {
1447 return ThemeEngine.Current.DefaultControlForeColor;
1451 public static Keys ModifierKeys {
1453 return XplatUI.State.ModifierKeys;
1457 public static MouseButtons MouseButtons {
1459 return XplatUI.State.MouseButtons;
1463 public static Point MousePosition {
1465 return Cursor.Position;
1471 public static bool CheckForIllegalCrossThreadCalls
1474 return verify_thread_handle;
1478 verify_thread_handle = value;
1482 #endregion // Public Static Properties
1484 #region Public Instance Properties
1485 [EditorBrowsable(EditorBrowsableState.Advanced)]
1487 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1488 public AccessibleObject AccessibilityObject {
1490 if (accessibility_object==null) {
1491 accessibility_object=CreateAccessibilityInstance();
1493 return accessibility_object;
1497 [EditorBrowsable(EditorBrowsableState.Advanced)]
1499 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1500 public string AccessibleDefaultActionDescription {
1502 return AccessibilityObject.default_action;
1506 AccessibilityObject.default_action=value;
1511 [DefaultValue(null)]
1512 [MWFCategory("Accessibility")]
1513 public string AccessibleDescription {
1515 return AccessibilityObject.description;
1519 AccessibilityObject.description=value;
1524 [DefaultValue(null)]
1525 [MWFCategory("Accessibility")]
1526 public string AccessibleName {
1528 return AccessibilityObject.Name;
1532 AccessibilityObject.Name=value;
1536 [DefaultValue(AccessibleRole.Default)]
1537 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1538 public AccessibleRole AccessibleRole {
1540 return AccessibilityObject.role;
1544 AccessibilityObject.role=value;
1548 [DefaultValue(false)]
1549 [MWFCategory("Behavior")]
1550 public virtual bool AllowDrop {
1556 if (allow_drop == value)
1559 if (IsHandleCreated) {
1561 XplatUI.SetAllowDrop (Handle, value);
1567 [RefreshProperties(RefreshProperties.Repaint)]
1568 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1569 [MWFCategory("Layout")]
1570 public virtual AnchorStyles Anchor {
1572 return anchor_style;
1578 if (parent != null) {
1579 parent.PerformLayout(this, "Parent");
1585 // XXX: Implement me!
1588 public virtual bool AutoSize {
1590 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1594 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1599 public virtual Size MaximumSize {
1601 return maximum_size;
1604 maximum_size = value;
1608 public virtual Size MinimumSize {
1610 return minimum_size;
1613 minimum_size = value;
1619 [MWFCategory("Appearance")]
1620 public virtual Color BackColor {
1622 if (background_color.IsEmpty) {
1624 Color pcolor = parent.BackColor;
1625 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1628 return DefaultBackColor;
1630 return background_color;
1634 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1635 throw new ArgumentException("Transparent background colors are not supported on this control");
1638 if (background_color != value) {
1639 background_color=value;
1640 SetChildColor(this);
1641 OnBackColorChanged(EventArgs.Empty);
1648 [DefaultValue(null)]
1649 [MWFCategory("Appearance")]
1650 public virtual Image BackgroundImage {
1652 return background_image;
1656 if (background_image!=value) {
1657 background_image=value;
1658 OnBackgroundImageChanged(EventArgs.Empty);
1663 [EditorBrowsable(EditorBrowsableState.Advanced)]
1665 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1666 public virtual BindingContext BindingContext {
1668 if (binding_context != null)
1669 return binding_context;
1672 binding_context = Parent.BindingContext;
1673 return binding_context;
1676 if (binding_context != value) {
1677 binding_context = value;
1678 OnBindingContextChanged(EventArgs.Empty);
1683 [EditorBrowsable(EditorBrowsableState.Advanced)]
1685 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1688 return bounds.Y+bounds.Height;
1692 [EditorBrowsable(EditorBrowsableState.Advanced)]
1694 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1695 public Rectangle Bounds {
1701 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1705 [EditorBrowsable(EditorBrowsableState.Advanced)]
1707 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1708 public bool CanFocus {
1710 if (IsHandleCreated && Visible && Enabled) {
1717 [EditorBrowsable(EditorBrowsableState.Advanced)]
1719 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1720 public bool CanSelect {
1724 if (!GetStyle(ControlStyles.Selectable)) {
1729 while (parent != null) {
1730 if (!parent.is_visible || !parent.is_enabled) {
1734 parent = parent.parent;
1740 internal virtual bool InternalCapture {
1750 [EditorBrowsable(EditorBrowsableState.Advanced)]
1752 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1753 public bool Capture {
1755 return this.is_captured;
1759 if (this.IsHandleCreated && value != is_captured) {
1762 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1764 XplatUI.UngrabWindow(this.window.Handle);
1765 is_captured = false;
1771 [DefaultValue(true)]
1772 [MWFCategory("Focus")]
1773 public bool CausesValidation {
1775 return this.causes_validation;
1779 if (this.causes_validation != value) {
1780 causes_validation = value;
1781 OnCausesValidationChanged(EventArgs.Empty);
1786 [EditorBrowsable(EditorBrowsableState.Advanced)]
1788 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1789 public Rectangle ClientRectangle {
1791 client_rect.Width = client_size.Width;
1792 client_rect.Height = client_size.Height;
1797 [EditorBrowsable(EditorBrowsableState.Advanced)]
1799 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1800 public Size ClientSize {
1803 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1804 return ((Form)this).form_parent_window.ClientSize;
1812 this.SetClientSizeCore(value.Width, value.Height);
1816 [EditorBrowsable(EditorBrowsableState.Advanced)]
1818 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1819 [DescriptionAttribute("ControlCompanyNameDescr")]
1820 public String CompanyName {
1822 return "Mono Project, Novell, Inc.";
1826 [EditorBrowsable(EditorBrowsableState.Advanced)]
1828 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1829 public bool ContainsFocus {
1831 IntPtr focused_window;
1833 focused_window = XplatUI.GetFocus();
1834 if (IsHandleCreated) {
1835 if (focused_window == Handle) {
1839 for (int i=0; i < child_controls.Count; i++) {
1840 if (child_controls[i].ContainsFocus) {
1849 [DefaultValue(null)]
1850 [MWFCategory("Behavior")]
1851 public virtual ContextMenu ContextMenu {
1853 return context_menu;
1857 if (context_menu != value) {
1858 context_menu = value;
1859 OnContextMenuChanged(EventArgs.Empty);
1865 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1866 public ControlCollection Controls {
1868 return this.child_controls;
1872 [EditorBrowsable(EditorBrowsableState.Advanced)]
1874 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1875 public bool Created {
1877 return (!is_disposed && is_created);
1881 [AmbientValue(null)]
1882 [MWFCategory("Appearance")]
1883 public virtual Cursor Cursor {
1885 if (cursor != null) {
1889 if (parent != null) {
1890 return parent.Cursor;
1893 return Cursors.Default;
1897 if (cursor != value) {
1902 if (IsHandleCreated) {
1903 pt = Cursor.Position;
1905 if (bounds.Contains(pt) || Capture) {
1906 if (GetChildAtPoint(pt) == null) {
1907 if (cursor != null) {
1908 XplatUI.SetCursor(window.Handle, cursor.handle);
1910 if (parent != null) {
1911 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1913 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
1920 OnCursorChanged(EventArgs.Empty);
1926 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1927 [ParenthesizePropertyName(true)]
1928 [RefreshProperties(RefreshProperties.All)]
1929 [MWFCategory("Data")]
1930 public ControlBindingsCollection DataBindings {
1932 if (data_bindings == null)
1933 data_bindings = new ControlBindingsCollection (this);
1934 return data_bindings;
1938 [EditorBrowsable(EditorBrowsableState.Advanced)]
1940 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1941 public virtual Rectangle DisplayRectangle {
1943 return ClientRectangle;
1947 [EditorBrowsable(EditorBrowsableState.Advanced)]
1949 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1950 public bool Disposing {
1957 [RefreshProperties(RefreshProperties.Repaint)]
1958 [DefaultValue(DockStyle.None)]
1959 [MWFCategory("Layout")]
1960 public virtual DockStyle Dock {
1966 if (dock_style == value) {
1972 if (dock_style == DockStyle.None) {
1973 if (explicit_bounds == Rectangle.Empty)
1974 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
1976 Bounds = explicit_bounds;
1979 if (parent != null) {
1980 parent.PerformLayout(this, "Parent");
1983 OnDockChanged(EventArgs.Empty);
1989 [MWFCategory("Behavior")]
1990 public bool Enabled {
1996 if (parent != null) {
1997 return parent.Enabled;
2005 bool old_value = is_enabled;
2008 if (old_value != value && !value && this.has_focus)
2009 SelectNextControl(this, true, true, true, true);
2011 OnEnabledChanged (EventArgs.Empty);
2015 [EditorBrowsable(EditorBrowsableState.Advanced)]
2017 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2018 public virtual bool Focused {
2020 return this.has_focus;
2025 [AmbientValue(null)]
2027 [MWFCategory("Appearance")]
2028 public virtual Font Font {
2034 if (Parent != null && Parent.Font != null) {
2041 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2043 if (font != null && font.Equals (value)) {
2049 OnFontChanged (EventArgs.Empty);
2054 [MWFCategory("Appearance")]
2055 public virtual Color ForeColor {
2057 if (foreground_color.IsEmpty) {
2059 return parent.ForeColor;
2061 return DefaultForeColor;
2063 return foreground_color;
2067 if (foreground_color != value) {
2068 foreground_color=value;
2070 OnForeColorChanged(EventArgs.Empty);
2077 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2078 public IntPtr Handle { // IWin32Window
2081 if (verify_thread_handle) {
2082 if (this.InvokeRequired) {
2083 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2087 if (!IsHandleCreated) {
2090 return window.Handle;
2094 [EditorBrowsable(EditorBrowsableState.Advanced)]
2096 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2097 public bool HasChildren {
2099 if (this.child_controls.Count>0) {
2106 [EditorBrowsable(EditorBrowsableState.Always)]
2108 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2111 return this.bounds.Height;
2115 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2119 [AmbientValue(ImeMode.Inherit)]
2121 [MWFCategory("Behavior")]
2122 public ImeMode ImeMode {
2124 if (ime_mode == DefaultImeMode) {
2126 return parent.ImeMode;
2128 return ImeMode.NoControl; // default value
2134 if (ime_mode != value) {
2137 OnImeModeChanged(EventArgs.Empty);
2142 [EditorBrowsable(EditorBrowsableState.Advanced)]
2144 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2145 public bool InvokeRequired { // ISynchronizeInvoke
2147 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2154 [EditorBrowsable(EditorBrowsableState.Advanced)]
2156 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2157 public bool IsAccessible {
2159 return is_accessible;
2163 is_accessible = value;
2167 [EditorBrowsable(EditorBrowsableState.Advanced)]
2169 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2170 public bool IsDisposed {
2172 return this.is_disposed;
2176 [EditorBrowsable(EditorBrowsableState.Advanced)]
2178 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2179 public bool IsHandleCreated {
2181 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2182 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2183 if (hwnd != null && !hwnd.zombie)
2192 public virtual Layout.LayoutEngine LayoutEngine {
2193 get { return new Layout.DefaultLayout (); }
2197 [EditorBrowsable(EditorBrowsableState.Always)]
2199 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2202 return this.bounds.X;
2206 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2211 [MWFCategory("Layout")]
2212 public Point Location {
2214 return new Point(bounds.X, bounds.Y);
2218 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2223 [Localizable (true)]
2224 public Padding Margin {
2225 get { return this.margin; }
2226 set { this.margin = value; }
2231 public string Name {
2243 public Padding Padding {
2255 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2256 public Control Parent {
2262 if (value == this) {
2263 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2266 if (parent!=value) {
2268 parent.Controls.Remove(this);
2273 value.Controls.Add(this);
2278 [EditorBrowsable(EditorBrowsableState.Advanced)]
2280 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2281 public string ProductName {
2283 Type t = typeof (AssemblyProductAttribute);
2284 Assembly assembly = GetType().Module.Assembly;
2285 object [] attrs = assembly.GetCustomAttributes (t, false);
2286 AssemblyProductAttribute a = null;
2287 // On MS we get a NullRefException if product attribute is not
2289 if (attrs != null && attrs.Length > 0)
2290 a = (AssemblyProductAttribute) attrs [0];
2295 [EditorBrowsable(EditorBrowsableState.Advanced)]
2297 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2298 public string ProductVersion {
2300 Type t = typeof (AssemblyVersionAttribute);
2301 Assembly assembly = GetType().Module.Assembly;
2302 object [] attrs = assembly.GetCustomAttributes (t, false);
2303 if (attrs == null || attrs.Length < 1)
2305 return ((AssemblyVersionAttribute)attrs [0]).Version;
2309 [EditorBrowsable(EditorBrowsableState.Advanced)]
2311 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2312 public bool RecreatingHandle {
2314 return is_recreating;
2318 [EditorBrowsable(EditorBrowsableState.Advanced)]
2320 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2321 public Region Region {
2327 if (IsHandleCreated) {
2328 XplatUI.SetClipRegion(Handle, value);
2330 clip_region = value;
2334 [EditorBrowsable(EditorBrowsableState.Advanced)]
2336 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2339 return this.bounds.X+this.bounds.Width;
2343 [AmbientValue(RightToLeft.Inherit)]
2345 [MWFCategory("Appearance")]
2346 public virtual RightToLeft RightToLeft {
2348 if (right_to_left == RightToLeft.Inherit) {
2350 return parent.RightToLeft;
2352 return RightToLeft.No; // default value
2354 return right_to_left;
2358 if (value != right_to_left) {
2359 right_to_left = value;
2360 OnRightToLeftChanged(EventArgs.Empty);
2365 [EditorBrowsable(EditorBrowsableState.Advanced)]
2366 public override ISite Site {
2374 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2376 BackColor = ap.BackColor;
2377 ForeColor = ap.ForeColor;
2385 [MWFCategory("Layout")]
2388 return new Size(Width, Height);
2392 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2397 [MergableProperty(false)]
2398 [MWFCategory("Behavior")]
2399 public int TabIndex {
2401 if (tab_index != -1) {
2408 if (tab_index != value) {
2410 OnTabIndexChanged(EventArgs.Empty);
2416 [DefaultValue(true)]
2417 [MWFCategory("Behavior")]
2418 public bool TabStop {
2424 if (tab_stop != value) {
2426 OnTabStopChanged(EventArgs.Empty);
2431 [Localizable(false)]
2433 [TypeConverter(typeof(StringConverter))]
2434 [DefaultValue(null)]
2435 [MWFCategory("Data")]
2442 control_tag = value;
2448 [BindableAttribute(true)]
2449 [MWFCategory("Appearance")]
2450 public virtual string Text {
2452 // Our implementation ignores ControlStyles.CacheText - we always cache
2457 if (value == null) {
2458 value = String.Empty;
2463 if (IsHandleCreated) {
2464 /* we need to call .SetWindowStyle here instead of just .Text
2465 because the presence/absence of Text (== "" or not) can cause
2466 other window style things to appear/disappear */
2467 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2468 XplatUI.Text(Handle, text);
2470 OnTextChanged (EventArgs.Empty);
2475 [EditorBrowsable(EditorBrowsableState.Always)]
2477 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2480 return this.bounds.Y;
2484 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2488 [EditorBrowsable(EditorBrowsableState.Advanced)]
2490 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2491 public Control TopLevelControl {
2495 while (p.parent != null) {
2499 return p is Form ? p : null;
2504 [MWFCategory("Behavior")]
2505 public bool Visible {
2509 } else if (parent != null) {
2510 return parent.Visible;
2517 SetVisibleCore(value);
2521 [EditorBrowsable(EditorBrowsableState.Always)]
2523 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2526 return this.bounds.Width;
2530 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2534 [EditorBrowsable(EditorBrowsableState.Never)]
2536 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2537 public IWindowTarget WindowTarget {
2546 #endregion // Public Instance Properties
2548 #region Protected Instance Properties
2549 protected virtual CreateParams CreateParams {
2551 CreateParams create_params = new CreateParams();
2554 create_params.Caption = Text;
2557 create_params.Caption = text;
2561 create_params.X = Left;
2564 create_params.X = this.bounds.X;
2568 create_params.Y = Top;
2571 create_params.Y = this.bounds.Y;
2575 create_params.Width = Width;
2578 create_params.Width = this.bounds.Width;
2582 create_params.Height = Height;
2585 create_params.Height = this.bounds.Height;
2589 create_params.ClassName = XplatUI.DefaultClassName;
2590 create_params.ClassStyle = 0;
2591 create_params.ExStyle = 0;
2592 create_params.Param = 0;
2595 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2598 if ((parent!=null) && (parent.IsHandleCreated)) {
2599 create_params.Parent = parent.Handle;
2602 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2605 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2609 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2612 switch (border_style) {
2613 case BorderStyle.FixedSingle:
2614 create_params.Style |= (int) WindowStyles.WS_BORDER;
2616 case BorderStyle.Fixed3D:
2617 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2621 return create_params;
2625 protected virtual ImeMode DefaultImeMode {
2627 return ImeMode.Inherit;
2632 protected virtual Padding DefaultMargin {
2633 get { return new Padding (3); }
2637 protected virtual Size DefaultSize {
2639 return new Size(0, 0);
2643 protected int FontHeight {
2653 protected bool RenderRightToLeft {
2655 return (this.right_to_left == RightToLeft.Yes);
2659 protected bool ResizeRedraw {
2661 return GetStyle(ControlStyles.ResizeRedraw);
2665 SetStyle(ControlStyles.ResizeRedraw, value);
2669 [EditorBrowsable(EditorBrowsableState.Advanced)]
2671 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2672 protected virtual bool ShowFocusCues {
2678 [EditorBrowsable(EditorBrowsableState.Advanced)]
2680 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2681 protected bool ShowKeyboardCues {
2686 #endregion // Protected Instance Properties
2688 #region Public Static Methods
2689 [EditorBrowsable(EditorBrowsableState.Advanced)]
2690 public static Control FromChildHandle(IntPtr handle) {
2691 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2694 [EditorBrowsable(EditorBrowsableState.Advanced)]
2695 public static Control FromHandle(IntPtr handle) {
2696 return Control.ControlNativeWindow.ControlFromHandle(handle);
2699 public static bool IsMnemonic(char charCode, string text) {
2702 amp = text.IndexOf('&');
2705 if (amp + 1 < text.Length) {
2706 if (text[amp + 1] != '&') {
2707 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2717 #region Protected Static Methods
2718 [EditorBrowsable(EditorBrowsableState.Advanced)]
2719 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2722 c = Control.FromHandle(hWnd);
2732 #region Public Instance Methods
2733 [EditorBrowsable(EditorBrowsableState.Advanced)]
2734 public IAsyncResult BeginInvoke(Delegate method) {
2735 object [] prms = null;
2736 if (method is EventHandler)
2737 prms = new object [] { this, EventArgs.Empty };
2738 return BeginInvokeInternal(method, prms, false);
2741 [EditorBrowsable(EditorBrowsableState.Advanced)]
2742 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2743 return BeginInvokeInternal (method, args, false);
2746 public void BringToFront() {
2747 if (parent != null) {
2748 parent.child_controls.SetChildIndex(this, 0);
2751 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2755 public bool Contains(Control ctl) {
2756 while (ctl != null) {
2765 public void CreateControl() {
2767 throw new ObjectDisposedException(GetType().FullName.ToString());
2773 if (!IsHandleCreated) {
2781 Control [] controls = child_controls.GetAllControls ();
2782 for (int i=0; i<controls.Length; i++) {
2783 controls [i].CreateControl ();
2786 UpdateChildrenZOrder();
2788 if (binding_context == null) { // seem to be sent whenever it's null?
2789 OnBindingContextChanged(EventArgs.Empty);
2795 public Graphics CreateGraphics() {
2796 if (!IsHandleCreated) {
2797 this.CreateHandle();
2799 return Graphics.FromHwnd(this.window.Handle);
2802 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2803 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2806 [EditorBrowsable(EditorBrowsableState.Advanced)]
2807 public object EndInvoke (IAsyncResult async_result) {
2808 AsyncMethodResult result = (AsyncMethodResult) async_result;
2809 return result.EndInvoke ();
2812 public Form FindForm() {
2825 public bool Focus() {
2826 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2829 is_focusing = false;
2834 public Control GetChildAtPoint(Point pt) {
2835 // Microsoft's version of this function doesn't seem to work, so I can't check
2836 // if we only consider children or also grandchildren, etc.
2837 // I'm gonna say 'children only'
2838 for (int i=0; i<child_controls.Count; i++) {
2839 if (child_controls[i].Bounds.Contains(pt)) {
2840 return child_controls[i];
2846 public IContainerControl GetContainerControl() {
2847 Control current = this;
2849 while (current!=null) {
2850 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2851 return (IContainerControl)current;
2853 current = current.parent;
2858 public Control GetNextControl(Control ctl, bool forward) {
2860 if (!this.Contains(ctl)) {
2865 ctl = FindControlForward(this, ctl);
2868 ctl = FindControlBackward(this, ctl);
2878 public virtual Size GetPreferredSize (Size proposedSize) {
2879 return preferred_size;
2883 public void Hide() {
2884 this.Visible = false;
2887 public void Invalidate() {
2888 Invalidate(ClientRectangle, false);
2891 public void Invalidate(bool invalidateChildren) {
2892 Invalidate(ClientRectangle, invalidateChildren);
2895 public void Invalidate(System.Drawing.Rectangle rc) {
2896 Invalidate(rc, false);
2899 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2900 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
2904 NotifyInvalidate(rc);
2906 XplatUI.Invalidate(Handle, rc, false);
2908 if (invalidateChildren) {
2909 Control [] controls = child_controls.GetAllControls ();
2910 for (int i=0; i<controls.Length; i++)
2911 controls [i].Invalidate ();
2913 OnInvalidated(new InvalidateEventArgs(rc));
2916 public void Invalidate(System.Drawing.Region region) {
2917 Invalidate(region, false);
2920 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2921 RectangleF bounds = region.GetBounds (CreateGraphics ());
2922 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
2923 invalidateChildren);
2926 public object Invoke (Delegate method) {
2927 object [] prms = null;
2928 if (method is EventHandler)
2929 prms = new object [] { this, EventArgs.Empty };
2931 return Invoke(method, prms);
2934 public object Invoke (Delegate method, object[] args) {
2935 if (!this.InvokeRequired) {
2936 return method.DynamicInvoke(args);
2939 IAsyncResult result = BeginInvoke (method, args);
2940 return EndInvoke(result);
2943 internal object InvokeInternal (Delegate method, bool disposing) {
2944 return InvokeInternal(method, null, disposing);
2947 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
2948 if (!this.InvokeRequired) {
2949 return method.DynamicInvoke(args);
2952 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
2953 return EndInvoke(result);
2956 [EditorBrowsable(EditorBrowsableState.Advanced)]
2957 public void PerformLayout() {
2958 PerformLayout(null, null);
2962 private void SetImplicitBounds (int x, int y, int width, int height)
2964 Rectangle saved_bounds = explicit_bounds;
2965 SetBounds (x, y, width, height);
2966 explicit_bounds = saved_bounds;
2970 [EditorBrowsable(EditorBrowsableState.Advanced)]
2971 public void PerformLayout(Control affectedControl, string affectedProperty) {
2972 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2974 if (layout_suspended > 0) {
2975 layout_pending = true;
2979 layout_pending = false;
2981 // Prevent us from getting messed up
2984 // Perform all Dock and Anchor calculations
2988 this.layout_engine.Layout(this, levent);
2990 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
2992 AnchorStyles anchor;
2995 space = DisplayRectangle;
2997 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2998 Control [] controls = child_controls.GetAllControls ();
2999 for (int i = controls.Length - 1; i >= 0; i--) {
3000 child = controls [i];
3002 if (!child.Visible) {
3006 switch (child.Dock) {
3007 case DockStyle.None: {
3012 case DockStyle.Left: {
3013 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3014 space.X+=child.Width;
3015 space.Width-=child.Width;
3019 case DockStyle.Top: {
3020 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3021 space.Y+=child.Height;
3022 space.Height-=child.Height;
3026 case DockStyle.Right: {
3027 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3028 space.Width-=child.Width;
3032 case DockStyle.Bottom: {
3033 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3034 space.Height-=child.Height;
3040 for (int i = controls.Length - 1; i >= 0; i--) {
3043 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3044 if (child.Dock == DockStyle.Fill) {
3045 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3049 space = DisplayRectangle;
3051 for (int i=0; i < controls.Length; i++) {
3057 child = controls[i];
3059 // If the control is docked we don't need to do anything
3060 if (child.Dock != DockStyle.None) {
3064 anchor = child.Anchor;
3068 width = child.Width;
3069 height = child.Height;
3071 if ((anchor & AnchorStyles.Left) !=0 ) {
3072 if ((anchor & AnchorStyles.Right) != 0) {
3073 width = space.Width - child.dist_right - left;
3075 ; // Left anchored only, nothing to be done
3077 } else if ((anchor & AnchorStyles.Right) != 0) {
3078 left = space.Width - child.dist_right - width;
3080 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3081 // This calculates from scratch every time:
3082 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3085 if ((anchor & AnchorStyles.Top) !=0 ) {
3086 if ((anchor & AnchorStyles.Bottom) != 0) {
3087 height = space.Height - child.dist_bottom - top;
3089 ; // Top anchored only, nothing to be done
3091 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3092 top = space.Height - child.dist_bottom - height;
3094 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3095 // This calculates from scratch every time:
3096 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3108 child.SetImplicitBounds(left, top, width, height);
3112 // Let everyone know
3116 // Need to make sure we decremend layout_suspended
3122 public Point PointToClient (Point p) {
3126 XplatUI.ScreenToClient (Handle, ref x, ref y);
3128 return new Point (x, y);
3131 public Point PointToScreen(Point p) {
3135 XplatUI.ClientToScreen(Handle, ref x, ref y);
3137 return new Point(x, y);
3140 public virtual bool PreProcessMessage(ref Message msg) {
3141 return InternalPreProcessMessage (ref msg);
3144 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3147 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3148 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3150 if (!ProcessCmdKey(ref msg, key_data)) {
3151 if (IsInputKey(key_data)) {
3155 return ProcessDialogKey(key_data);
3159 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3160 if (IsInputChar((char)msg.WParam)) {
3163 return ProcessDialogChar((char)msg.WParam);
3164 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3165 return ProcessDialogChar((char)msg.WParam);
3170 public Rectangle RectangleToClient(Rectangle r) {
3171 return new Rectangle(PointToClient(r.Location), r.Size);
3174 public Rectangle RectangleToScreen(Rectangle r) {
3175 return new Rectangle(PointToScreen(r.Location), r.Size);
3178 public virtual void Refresh() {
3179 if (IsHandleCreated == true) {
3181 XplatUI.UpdateWindow(window.Handle);
3183 Control [] controls = child_controls.GetAllControls ();
3184 for (int i=0; i < controls.Length; i++) {
3185 controls[i].Refresh();
3191 [EditorBrowsable(EditorBrowsableState.Never)]
3192 public virtual void ResetBackColor() {
3193 BackColor = Color.Empty;
3196 [EditorBrowsable(EditorBrowsableState.Never)]
3197 public void ResetBindings() {
3198 data_bindings.Clear();
3201 [EditorBrowsable(EditorBrowsableState.Never)]
3202 public virtual void ResetCursor() {
3206 [EditorBrowsable(EditorBrowsableState.Never)]
3207 public virtual void ResetFont() {
3211 [EditorBrowsable(EditorBrowsableState.Never)]
3212 public virtual void ResetForeColor() {
3213 foreground_color = Color.Empty;
3216 [EditorBrowsable(EditorBrowsableState.Never)]
3217 public void ResetImeMode() {
3218 ime_mode = DefaultImeMode;
3221 [EditorBrowsable(EditorBrowsableState.Never)]
3222 public virtual void ResetRightToLeft() {
3223 right_to_left = RightToLeft.Inherit;
3226 public virtual void ResetText() {
3227 text = String.Empty;
3230 public void ResumeLayout() {
3231 ResumeLayout (true);
3234 public void ResumeLayout(bool performLayout) {
3235 if (layout_suspended > 0) {
3239 if (layout_suspended == 0) {
3240 Control [] controls = child_controls.GetAllControls ();
3241 for (int i=0; i<controls.Length; i++) {
3242 controls [i].UpdateDistances ();
3245 if (performLayout && layout_pending) {
3251 public void Scale(float ratio) {
3252 ScaleCore(ratio, ratio);
3255 public void Scale(float dx, float dy) {
3260 public void Scale(SizeF factor) {
3261 ScaleCore(factor.Width, factor.Height);
3265 public void Select() {
3266 Select(false, false);
3270 private void printTree(Control c, string t) {
3271 foreach(Control i in c.child_controls) {
3272 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3273 printTree(i, t+"\t");
3277 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3281 Console.WriteLine("{0}", this.FindForm());
3282 printTree(this, "\t");
3285 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3290 c = GetNextControl(c, forward);
3299 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3300 c.Select (true, true);
3303 } while (c != ctl); // If we wrap back to ourselves we stop
3308 public void SendToBack() {
3309 if (parent != null) {
3310 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3314 public void SetBounds(int x, int y, int width, int height) {
3315 SetBounds(x, y, width, height, BoundsSpecified.All);
3318 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3319 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3323 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3327 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3331 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3335 SetBoundsCore(x, y, width, height, specified);
3336 if (parent != null) {
3337 parent.PerformLayout(this, "Bounds");
3341 public void Show() {
3343 this.CreateControl();
3349 public void SuspendLayout() {
3353 public void Update() {
3354 if (IsHandleCreated) {
3355 XplatUI.UpdateWindow(window.Handle);
3358 #endregion // Public Instance Methods
3360 #region Protected Instance Methods
3361 [EditorBrowsable(EditorBrowsableState.Advanced)]
3362 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3363 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3364 throw new NotImplementedException();
3367 [EditorBrowsable(EditorBrowsableState.Advanced)]
3368 protected virtual AccessibleObject CreateAccessibilityInstance() {
3369 return new Control.ControlAccessibleObject(this);
3372 [EditorBrowsable(EditorBrowsableState.Advanced)]
3373 protected virtual ControlCollection CreateControlsInstance() {
3374 return new ControlCollection(this);
3377 [EditorBrowsable(EditorBrowsableState.Advanced)]
3378 protected virtual void CreateHandle() {
3380 throw new ObjectDisposedException(GetType().FullName.ToString());
3383 if (IsHandleCreated && !is_recreating) {
3387 window.CreateHandle(CreateParams);
3389 if (window.Handle != IntPtr.Zero) {
3390 lock (Control.controls) {
3391 if (!Control.controls.Contains(window.Handle)) {
3392 Control.controls.Add(this);
3396 creator_thread = Thread.CurrentThread;
3398 XplatUI.EnableWindow(window.Handle, is_enabled);
3399 XplatUI.SetVisible(window.Handle, is_visible, true);
3401 if (clip_region != null) {
3402 XplatUI.SetClipRegion(Handle, clip_region);
3405 // Set our handle with our parent
3406 if ((parent != null) && (parent.IsHandleCreated)) {
3407 XplatUI.SetParent(window.Handle, parent.Handle);
3410 // Set our handle as parent for our children
3411 Control [] children;
3413 children = child_controls.GetAllControls ();
3414 for (int i = 0; i < children.Length; i++ ) {
3415 if (!children[i].RecreatingHandle)
3416 XplatUI.SetParent(children[i].Handle, window.Handle);
3420 XplatUI.SetAllowDrop (Handle, allow_drop);
3422 // Find out where the window manager placed us
3423 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3424 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3428 OnHandleCreated(EventArgs.Empty);
3432 [EditorBrowsable(EditorBrowsableState.Advanced)]
3433 protected virtual void DefWndProc(ref Message m) {
3434 window.DefWndProc(ref m);
3437 [EditorBrowsable(EditorBrowsableState.Advanced)]
3438 protected virtual void DestroyHandle() {
3439 if (IsHandleCreated) {
3440 if (window != null) {
3441 window.DestroyHandle();
3446 protected bool GetStyle(ControlStyles flag) {
3447 return (control_style & flag) != 0;
3450 protected bool GetTopLevel() {
3454 [EditorBrowsable(EditorBrowsableState.Advanced)]
3455 protected virtual void InitLayout() {
3459 [EditorBrowsable(EditorBrowsableState.Advanced)]
3460 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3461 toInvoke.OnGotFocus(e);
3464 [EditorBrowsable(EditorBrowsableState.Advanced)]
3465 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3466 toInvoke.OnLostFocus(e);
3469 [EditorBrowsable(EditorBrowsableState.Advanced)]
3470 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3471 toInvoke.OnClick(e);
3474 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3475 toInvoke.OnPaint(e);
3478 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3479 toInvoke.OnPaintBackground(e);
3482 protected virtual bool IsInputChar (char charCode) {
3486 protected virtual bool IsInputKey (Keys keyData) {
3487 // Doc says this one calls IsInputChar; not sure what to do with that
3491 [EditorBrowsable(EditorBrowsableState.Advanced)]
3492 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3496 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3497 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3501 if (parent != null) {
3502 return parent.ProcessCmdKey(ref msg, keyData);
3508 protected virtual bool ProcessDialogChar(char charCode) {
3509 if (parent != null) {
3510 return parent.ProcessDialogChar (charCode);
3516 protected virtual bool ProcessDialogKey (Keys keyData) {
3517 if (parent != null) {
3518 return parent.ProcessDialogKey (keyData);
3524 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3526 KeyEventArgs key_event;
3529 case (int)Msg.WM_SYSKEYDOWN:
3530 case (int)Msg.WM_KEYDOWN: {
3531 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3532 OnKeyDown (key_event);
3533 return key_event.Handled;
3536 case (int)Msg.WM_SYSKEYUP:
3537 case (int)Msg.WM_KEYUP: {
3538 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3539 OnKeyUp (key_event);
3540 return key_event.Handled;
3543 case (int)Msg.WM_SYSCHAR:
3544 case (int)Msg.WM_CHAR: {
3545 KeyPressEventArgs key_press_event;
3547 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3548 OnKeyPress(key_press_event);
3550 msg.WParam = (IntPtr)key_press_event.KeyChar;
3552 return key_press_event.Handled;
3563 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3564 if (parent != null) {
3565 if (parent.ProcessKeyPreview(ref msg)) {
3570 return ProcessKeyEventArgs(ref msg);
3573 protected virtual bool ProcessKeyPreview(ref Message msg) {
3574 if (parent != null) {
3575 return parent.ProcessKeyPreview(ref msg);
3581 protected virtual bool ProcessMnemonic(char charCode) {
3586 [EditorBrowsable(EditorBrowsableState.Advanced)]
3587 protected void RaiseDragEvent(object key, DragEventArgs e) {
3591 [EditorBrowsable(EditorBrowsableState.Advanced)]
3592 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3596 [EditorBrowsable(EditorBrowsableState.Advanced)]
3597 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3601 [EditorBrowsable(EditorBrowsableState.Advanced)]
3602 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3606 private void SetIsRecreating ()
3610 foreach (Control c in Controls.GetAllControls()) {
3611 c.SetIsRecreating ();
3615 [EditorBrowsable(EditorBrowsableState.Advanced)]
3616 protected void RecreateHandle() {
3618 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3623 if (IsHandleCreated) {
3625 Console.WriteLine(" + handle is created, destroying it.");
3628 // WM_DESTROY will CreateHandle for us
3631 Console.WriteLine(" + handle is not created, creating it.");
3639 is_recreating = false;
3641 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3647 [EditorBrowsable(EditorBrowsableState.Advanced)]
3648 protected void ResetMouseEventArgs() {
3652 [EditorBrowsable(EditorBrowsableState.Advanced)]
3653 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3654 if (right_to_left == RightToLeft.No) {
3659 case ContentAlignment.TopLeft: {
3660 return ContentAlignment.TopRight;
3663 case ContentAlignment.TopRight: {
3664 return ContentAlignment.TopLeft;
3667 case ContentAlignment.MiddleLeft: {
3668 return ContentAlignment.MiddleRight;
3671 case ContentAlignment.MiddleRight: {
3672 return ContentAlignment.MiddleLeft;
3675 case ContentAlignment.BottomLeft: {
3676 return ContentAlignment.BottomRight;
3679 case ContentAlignment.BottomRight: {
3680 return ContentAlignment.BottomLeft;
3684 // if it's center it doesn't change
3690 [EditorBrowsable(EditorBrowsableState.Advanced)]
3691 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3692 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3696 if (align == HorizontalAlignment.Left) {
3697 return HorizontalAlignment.Right;
3700 // align must be HorizontalAlignment.Right
3701 return HorizontalAlignment.Left;
3704 [EditorBrowsable(EditorBrowsableState.Advanced)]
3705 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3706 if (right_to_left == RightToLeft.No) {
3710 if (align == LeftRightAlignment.Left) {
3711 return LeftRightAlignment.Right;
3714 // align must be LeftRightAlignment.Right;
3715 return LeftRightAlignment.Left;
3718 [EditorBrowsable(EditorBrowsableState.Advanced)]
3719 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3720 return RtlTranslateAlignment(align);
3723 [EditorBrowsable(EditorBrowsableState.Advanced)]
3724 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3725 return RtlTranslateAlignment(align);
3728 [EditorBrowsable(EditorBrowsableState.Advanced)]
3729 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3730 return RtlTranslateAlignment(align);
3733 [EditorBrowsable(EditorBrowsableState.Advanced)]
3734 protected virtual void ScaleCore(float dx, float dy) {
3740 location = new Point((int)(Left * dx), (int)(Top * dy));
3741 size = this.ClientSize;
3743 if (!GetStyle(ControlStyles.FixedWidth)) {
3744 size.Width = (int)(size.Width * dx);
3747 if (!GetStyle(ControlStyles.FixedHeight)) {
3748 size.Height = (int)(size.Height * dy);
3751 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3753 /* Now scale our children */
3754 Control [] controls = child_controls.GetAllControls ();
3755 for (int i=0; i < controls.Length; i++) {
3756 controls[i].Scale(dx, dy);
3762 protected virtual void Select(bool directed, bool forward) {
3763 IContainerControl container;
3765 container = GetContainerControl();
3766 if (container != null)
3767 container.ActiveControl = this;
3770 [EditorBrowsable(EditorBrowsableState.Advanced)]
3771 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3772 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3773 if (IsHandleCreated) {
3774 XplatUI.SetWindowPos(Handle, x, y, width, height);
3776 // Win32 automatically changes negative width/height to 0.
3777 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3778 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3780 if (width < 0 || height < 0) {
3782 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3786 UpdateBounds(x, y, width, height);
3791 [EditorBrowsable(EditorBrowsableState.Advanced)]
3792 protected virtual void SetClientSizeCore(int x, int y) {
3793 // Calculate the actual window size from the client size (it usually stays the same or grows)
3794 Rectangle ClientRect;
3795 Rectangle WindowRect;
3798 ClientRect = new Rectangle(0, 0, x, y);
3799 cp = this.CreateParams;
3801 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3805 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3808 [EditorBrowsable(EditorBrowsableState.Advanced)]
3809 protected void SetStyle(ControlStyles flag, bool value) {
3811 control_style |= flag;
3813 control_style &= ~flag;
3817 protected void SetTopLevel(bool value) {
3818 if ((GetTopLevel() != value) && (parent != null)) {
3819 throw new Exception();
3823 if (value == true) {
3833 is_toplevel = value;
3836 protected virtual void SetVisibleCore(bool value) {
3837 if (value!=is_visible) {
3838 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3844 if (IsHandleCreated) {
3845 XplatUI.SetVisible(Handle, value, true);
3846 // Explicitly move Toplevel windows to where we want them;
3847 // apparently moving unmapped toplevel windows doesn't work
3848 if (is_visible && (this is Form)) {
3849 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3853 OnVisibleChanged(EventArgs.Empty);
3855 if (value == false && parent != null && Focused) {
3858 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3859 container = (Control)parent.GetContainerControl();
3860 if (container != null) {
3861 container.SelectNextControl(this, true, true, true, true);
3865 if (parent != null) {
3866 parent.PerformLayout(this, "visible");
3868 PerformLayout(this, "visible");
3873 [EditorBrowsable(EditorBrowsableState.Advanced)]
3874 protected void UpdateBounds() {
3882 if (!IsHandleCreated) {
3886 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3888 UpdateBounds(x, y, width, height, client_width, client_height);
3891 [EditorBrowsable(EditorBrowsableState.Advanced)]
3892 protected void UpdateBounds(int x, int y, int width, int height) {
3896 // Calculate client rectangle
3897 rect = new Rectangle(0, 0, 0, 0);
3900 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
3901 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
3904 [EditorBrowsable(EditorBrowsableState.Advanced)]
3905 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3906 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3908 bool resized = false;
3910 // Needed to generate required notifications
3911 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3915 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3922 bounds.Height=height;
3924 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
3925 explicit_bounds = bounds;
3927 client_size.Width=clientWidth;
3928 client_size.Height=clientHeight;
3931 OnLocationChanged(EventArgs.Empty);
3935 OnSizeChanged(EventArgs.Empty);
3939 [EditorBrowsable(EditorBrowsableState.Advanced)]
3940 protected void UpdateStyles() {
3941 if (!IsHandleCreated) {
3945 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3946 OnStyleChanged(EventArgs.Empty);
3949 private void UpdateZOrderOfChild(Control child) {
3950 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
3953 index = child_controls.IndexOf(child);
3956 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
3958 XplatUI.SetZOrder(child.Handle, IntPtr.Zero, true, false);
3963 private void UpdateChildrenZOrder() {
3964 Control [] controls;
3966 if (!IsHandleCreated) {
3970 controls = child_controls.GetAllControls ();
3971 for (int i = 1; i < controls.Length; i++ ) {
3972 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
3976 [EditorBrowsable(EditorBrowsableState.Advanced)]
3977 protected void UpdateZOrder() {
3978 if (parent != null) {
3979 parent.UpdateZOrderOfChild(this);
3983 protected virtual void WndProc(ref Message m) {
3985 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
3987 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3991 switch((Msg)m.Msg) {
3992 case Msg.WM_DESTROY: {
3993 OnHandleDestroyed(EventArgs.Empty);
3995 IntPtr handle = window.Handle;
3997 window.InvalidateHandle();
3999 if (is_recreating) {
4001 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4005 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4007 is_recreating = false;
4012 case Msg.WM_WINDOWPOSCHANGED: {
4014 Rectangle save_bounds = explicit_bounds;
4016 explicit_bounds = save_bounds;
4017 if (GetStyle(ControlStyles.ResizeRedraw)) {
4024 // Nice description of what should happen when handling WM_PAINT
4025 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4026 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4027 case Msg.WM_PAINT: {
4028 PaintEventArgs paint_event;
4030 paint_event = XplatUI.PaintEventStart(Handle, true);
4032 if (paint_event == null) {
4036 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4037 // Just blit the previous image
4038 paint_event.Graphics.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4039 XplatUI.PaintEventEnd(Handle, true);
4044 Graphics back_dc = null;
4045 Bitmap backbuffer = null;
4046 if (ThemeEngine.Current.DoubleBufferingSupported) {
4047 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4048 backbuffer = ImageBuffer;
4049 back_dc = Graphics.FromImage (backbuffer);
4050 dc = paint_event.SetGraphics (back_dc);
4054 if (!GetStyle(ControlStyles.Opaque)) {
4055 OnPaintBackground(paint_event);
4058 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4059 OnPaintBackgroundInternal(paint_event);
4061 OnPaintInternal(paint_event);
4062 if (!paint_event.Handled) {
4063 OnPaint(paint_event);
4066 if (ThemeEngine.Current.DoubleBufferingSupported)
4067 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4068 dc.DrawImage (ImageBuffer, paint_event.ClipRectangle, paint_event.ClipRectangle, GraphicsUnit.Pixel);
4069 paint_event.SetGraphics (dc);
4070 invalid_region.Exclude (paint_event.ClipRectangle);
4072 if (backbuffer != bmp_mem)
4073 backbuffer.Dispose();
4076 XplatUI.PaintEventEnd(Handle, true);
4081 case Msg.WM_ERASEBKGND: {
4082 // The DefWndProc will never have to handle this, we always paint the background in managed code
4083 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4084 // here but it just makes things more complicated...
4085 m.Result = (IntPtr)1;
4089 case Msg.WM_LBUTTONUP: {
4092 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4094 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4097 HandleClick(mouse_clicks, me);
4100 if (InternalCapture) {
4101 InternalCapture = false;
4104 if (mouse_clicks > 1) {
4110 case Msg.WM_LBUTTONDOWN: {
4112 Select (true, true);
4114 InternalCapture = true;
4115 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4116 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4122 case Msg.WM_LBUTTONDBLCLK: {
4123 InternalCapture = true;
4125 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4126 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4132 case Msg.WM_MBUTTONUP: {
4135 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4137 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4140 HandleClick(mouse_clicks, me);
4142 if (InternalCapture) {
4143 InternalCapture = false;
4145 if (mouse_clicks > 1) {
4151 case Msg.WM_MBUTTONDOWN: {
4152 InternalCapture = true;
4153 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4154 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4160 case Msg.WM_MBUTTONDBLCLK: {
4161 InternalCapture = true;
4163 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4164 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4169 case Msg.WM_RBUTTONUP: {
4173 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4174 pt = PointToScreen(pt);
4176 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4178 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4180 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4183 HandleClick(mouse_clicks, me);
4186 if (InternalCapture) {
4187 InternalCapture = false;
4190 if (mouse_clicks > 1) {
4196 case Msg.WM_RBUTTONDOWN: {
4197 InternalCapture = true;
4198 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4199 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4204 case Msg.WM_RBUTTONDBLCLK: {
4205 InternalCapture = true;
4207 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4208 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4213 case Msg.WM_CONTEXTMENU: {
4214 if (context_menu != null) {
4217 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4218 context_menu.Show(this, PointToClient(pt));
4226 case Msg.WM_MOUSEWHEEL: {
4228 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4229 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4230 HighOrder(m.WParam.ToInt32())));
4235 case Msg.WM_MOUSEMOVE: {
4236 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4238 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4243 case Msg.WM_MOUSE_ENTER: {
4248 OnMouseEnter(EventArgs.Empty);
4252 case Msg.WM_MOUSE_LEAVE: {
4254 OnMouseLeave(EventArgs.Empty);
4258 case Msg.WM_MOUSEHOVER: {
4259 OnMouseHover(EventArgs.Empty);
4263 case Msg.WM_SYSKEYUP: {
4264 if (ProcessKeyMessage(ref m)) {
4265 m.Result = IntPtr.Zero;
4269 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4273 if (form != null && form.ActiveMenu != null) {
4274 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4282 case Msg.WM_SYSKEYDOWN:
4283 case Msg.WM_KEYDOWN:
4285 case Msg.WM_SYSCHAR:
4287 if (ProcessKeyMessage(ref m)) {
4288 m.Result = IntPtr.Zero;
4297 if (m.LParam != IntPtr.Zero) {
4300 hi = new HELPINFO();
4302 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4303 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4305 mouse_pos = Control.MousePosition;
4307 OnHelpRequested(new HelpEventArgs(mouse_pos));
4308 m.Result = (IntPtr)1;
4312 case Msg.WM_KILLFOCUS: {
4313 this.has_focus = false;
4314 OnLostFocusInternal (EventArgs.Empty);
4318 case Msg.WM_SETFOCUS: {
4320 this.has_focus = true;
4321 OnGotFocusInternal (EventArgs.Empty);
4327 case Msg.WM_SYSCOLORCHANGE: {
4328 ThemeEngine.Current.ResetDefaults();
4329 OnSystemColorsChanged(EventArgs.Empty);
4334 case Msg.WM_SETCURSOR: {
4335 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4340 XplatUI.SetCursor(window.Handle, cursor.handle);
4341 m.Result = (IntPtr)1;
4352 #endregion // Public Instance Methods
4354 #region OnXXX methods
4355 [EditorBrowsable(EditorBrowsableState.Advanced)]
4356 protected virtual void OnBackColorChanged(EventArgs e) {
4357 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4360 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4363 [EditorBrowsable(EditorBrowsableState.Advanced)]
4364 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4365 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4368 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4371 [EditorBrowsable(EditorBrowsableState.Advanced)]
4372 protected virtual void OnBindingContextChanged(EventArgs e) {
4373 CheckDataBindings ();
4374 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4377 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4380 [EditorBrowsable(EditorBrowsableState.Advanced)]
4381 protected virtual void OnCausesValidationChanged(EventArgs e) {
4382 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4387 [EditorBrowsable(EditorBrowsableState.Advanced)]
4388 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4389 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4394 [EditorBrowsable(EditorBrowsableState.Advanced)]
4395 protected virtual void OnClick(EventArgs e) {
4396 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4401 [EditorBrowsable(EditorBrowsableState.Advanced)]
4402 protected virtual void OnContextMenuChanged(EventArgs e) {
4403 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4408 [EditorBrowsable(EditorBrowsableState.Advanced)]
4409 protected virtual void OnControlAdded(ControlEventArgs e) {
4410 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4415 [EditorBrowsable(EditorBrowsableState.Advanced)]
4416 protected virtual void OnControlRemoved(ControlEventArgs e) {
4417 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4422 [EditorBrowsable(EditorBrowsableState.Advanced)]
4423 protected virtual void OnCreateControl() {
4427 [EditorBrowsable(EditorBrowsableState.Advanced)]
4428 protected virtual void OnCursorChanged(EventArgs e) {
4429 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4434 [EditorBrowsable(EditorBrowsableState.Advanced)]
4435 protected virtual void OnDockChanged(EventArgs e) {
4436 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4441 [EditorBrowsable(EditorBrowsableState.Advanced)]
4442 protected virtual void OnDoubleClick(EventArgs e) {
4443 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4448 [EditorBrowsable(EditorBrowsableState.Advanced)]
4449 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4450 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4452 eh (this, drgevent);
4455 [EditorBrowsable(EditorBrowsableState.Advanced)]
4456 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4457 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4459 eh (this, drgevent);
4462 [EditorBrowsable(EditorBrowsableState.Advanced)]
4463 protected virtual void OnDragLeave(EventArgs e) {
4464 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4469 [EditorBrowsable(EditorBrowsableState.Advanced)]
4470 protected virtual void OnDragOver(DragEventArgs drgevent) {
4471 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4473 eh (this, drgevent);
4476 [EditorBrowsable(EditorBrowsableState.Advanced)]
4477 protected virtual void OnEnabledChanged(EventArgs e) {
4478 if (IsHandleCreated) {
4480 if (((Form)this).context == null) {
4481 XplatUI.EnableWindow(window.Handle, Enabled);
4484 XplatUI.EnableWindow(window.Handle, Enabled);
4489 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4493 for (int i=0; i<child_controls.Count; i++) {
4494 child_controls[i].OnParentEnabledChanged(e);
4498 [EditorBrowsable(EditorBrowsableState.Advanced)]
4499 protected virtual void OnEnter(EventArgs e) {
4500 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4505 [EditorBrowsable(EditorBrowsableState.Advanced)]
4506 protected virtual void OnFontChanged(EventArgs e) {
4507 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4510 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4513 [EditorBrowsable(EditorBrowsableState.Advanced)]
4514 protected virtual void OnForeColorChanged(EventArgs e) {
4515 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4518 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4521 [EditorBrowsable(EditorBrowsableState.Advanced)]
4522 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4523 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4525 eh (this, gfbevent);
4528 [EditorBrowsable(EditorBrowsableState.Advanced)]
4529 protected virtual void OnGotFocus(EventArgs e) {
4530 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4535 [EditorBrowsable(EditorBrowsableState.Advanced)]
4536 protected virtual void OnHandleCreated(EventArgs e) {
4537 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4542 [EditorBrowsable(EditorBrowsableState.Advanced)]
4543 protected virtual void OnHandleDestroyed(EventArgs e) {
4544 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4549 [EditorBrowsable(EditorBrowsableState.Advanced)]
4550 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4551 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4556 protected virtual void OnImeModeChanged(EventArgs e) {
4557 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4562 [EditorBrowsable(EditorBrowsableState.Advanced)]
4563 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4564 if (ThemeEngine.Current.DoubleBufferingSupported)
4565 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4566 // should this block be here? seems like it
4567 // would be more at home in
4568 // NotifyInvalidated..
4569 if (e.InvalidRect == ClientRectangle) {
4570 ImageBufferNeedsRedraw ();
4573 // we need this Inflate call here so
4574 // that the border of the rectangle is
4575 // considered Visible (the
4576 // invalid_region.IsVisible call) in
4577 // the WM_PAINT handling below.
4578 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4579 if (invalid_region == null)
4580 invalid_region = new Region (r);
4582 invalid_region.Union (r);
4586 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4591 [EditorBrowsable(EditorBrowsableState.Advanced)]
4592 protected virtual void OnKeyDown(KeyEventArgs e) {
4593 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4598 [EditorBrowsable(EditorBrowsableState.Advanced)]
4599 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4600 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4605 [EditorBrowsable(EditorBrowsableState.Advanced)]
4606 protected virtual void OnKeyUp(KeyEventArgs e) {
4607 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4612 [EditorBrowsable(EditorBrowsableState.Advanced)]
4613 protected virtual void OnLayout(LayoutEventArgs levent) {
4614 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4619 [EditorBrowsable(EditorBrowsableState.Advanced)]
4620 protected virtual void OnLeave(EventArgs e) {
4621 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4626 [EditorBrowsable(EditorBrowsableState.Advanced)]
4627 protected virtual void OnLocationChanged(EventArgs e) {
4629 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4634 [EditorBrowsable(EditorBrowsableState.Advanced)]
4635 protected virtual void OnLostFocus(EventArgs e) {
4636 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4641 [EditorBrowsable(EditorBrowsableState.Advanced)]
4642 protected virtual void OnMouseDown(MouseEventArgs e) {
4643 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4648 [EditorBrowsable(EditorBrowsableState.Advanced)]
4649 protected virtual void OnMouseEnter(EventArgs e) {
4650 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4655 [EditorBrowsable(EditorBrowsableState.Advanced)]
4656 protected virtual void OnMouseHover(EventArgs e) {
4657 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4662 [EditorBrowsable(EditorBrowsableState.Advanced)]
4663 protected virtual void OnMouseLeave(EventArgs e) {
4664 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4669 [EditorBrowsable(EditorBrowsableState.Advanced)]
4670 protected virtual void OnMouseMove(MouseEventArgs e) {
4671 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4676 [EditorBrowsable(EditorBrowsableState.Advanced)]
4677 protected virtual void OnMouseUp(MouseEventArgs e) {
4678 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4683 [EditorBrowsable(EditorBrowsableState.Advanced)]
4684 protected virtual void OnMouseWheel(MouseEventArgs e) {
4685 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4690 [EditorBrowsable(EditorBrowsableState.Advanced)]
4691 protected virtual void OnMove(EventArgs e) {
4692 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4697 [EditorBrowsable(EditorBrowsableState.Advanced)]
4698 protected virtual void OnNotifyMessage(Message m) {
4702 [EditorBrowsable(EditorBrowsableState.Advanced)]
4703 protected virtual void OnPaint(PaintEventArgs e) {
4704 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4709 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4713 internal virtual void OnPaintInternal(PaintEventArgs e) {
4717 internal virtual void OnGotFocusInternal (EventArgs e)
4722 internal virtual void OnLostFocusInternal (EventArgs e)
4727 [EditorBrowsable(EditorBrowsableState.Advanced)]
4728 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4729 PaintControlBackground (pevent);
4732 [EditorBrowsable(EditorBrowsableState.Advanced)]
4733 protected virtual void OnParentBackColorChanged(EventArgs e) {
4734 if (background_color.IsEmpty && background_image==null) {
4736 OnBackColorChanged(e);
4740 [EditorBrowsable(EditorBrowsableState.Advanced)]
4741 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4742 if (background_color.IsEmpty && background_image==null) {
4744 OnBackgroundImageChanged(e);
4748 [EditorBrowsable(EditorBrowsableState.Advanced)]
4749 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4750 if (binding_context==null) {
4751 binding_context=Parent.binding_context;
4752 OnBindingContextChanged(e);
4756 [EditorBrowsable(EditorBrowsableState.Advanced)]
4757 protected virtual void OnParentChanged(EventArgs e) {
4758 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4763 [EditorBrowsable(EditorBrowsableState.Advanced)]
4764 protected virtual void OnParentEnabledChanged(EventArgs e) {
4766 OnEnabledChanged(e);
4770 [EditorBrowsable(EditorBrowsableState.Advanced)]
4771 protected virtual void OnParentFontChanged(EventArgs e) {
4778 [EditorBrowsable(EditorBrowsableState.Advanced)]
4779 protected virtual void OnParentForeColorChanged(EventArgs e) {
4780 if (foreground_color.IsEmpty) {
4782 OnForeColorChanged(e);
4786 [EditorBrowsable(EditorBrowsableState.Advanced)]
4787 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4788 if (right_to_left==RightToLeft.Inherit) {
4790 OnRightToLeftChanged(e);
4794 [EditorBrowsable(EditorBrowsableState.Advanced)]
4795 protected virtual void OnParentVisibleChanged(EventArgs e) {
4797 OnVisibleChanged(e);
4801 [EditorBrowsable(EditorBrowsableState.Advanced)]
4802 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4803 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4808 [EditorBrowsable(EditorBrowsableState.Advanced)]
4809 protected virtual void OnResize(EventArgs e) {
4810 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4814 PerformLayout(this, "bounds");
4816 if (parent != null) {
4817 parent.PerformLayout();
4821 [EditorBrowsable(EditorBrowsableState.Advanced)]
4822 protected virtual void OnRightToLeftChanged(EventArgs e) {
4823 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4826 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4829 [EditorBrowsable(EditorBrowsableState.Advanced)]
4830 protected virtual void OnSizeChanged(EventArgs e) {
4831 InvalidateBuffers ();
4833 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4838 [EditorBrowsable(EditorBrowsableState.Advanced)]
4839 protected virtual void OnStyleChanged(EventArgs e) {
4840 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4845 [EditorBrowsable(EditorBrowsableState.Advanced)]
4846 protected virtual void OnSystemColorsChanged(EventArgs e) {
4847 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4852 [EditorBrowsable(EditorBrowsableState.Advanced)]
4853 protected virtual void OnTabIndexChanged(EventArgs e) {
4854 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
4859 [EditorBrowsable(EditorBrowsableState.Advanced)]
4860 protected virtual void OnTabStopChanged(EventArgs e) {
4861 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
4866 [EditorBrowsable(EditorBrowsableState.Advanced)]
4867 protected virtual void OnTextChanged(EventArgs e) {
4868 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
4873 [EditorBrowsable(EditorBrowsableState.Advanced)]
4874 protected virtual void OnValidated(EventArgs e) {
4875 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
4880 [EditorBrowsable(EditorBrowsableState.Advanced)]
4881 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
4882 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
4887 [EditorBrowsable(EditorBrowsableState.Advanced)]
4888 protected virtual void OnVisibleChanged(EventArgs e) {
4889 if ((parent != null) && !Created && Visible) {
4896 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
4900 // We need to tell our kids
4901 for (int i=0; i<child_controls.Count; i++) {
4902 if (child_controls[i].Visible) {
4903 child_controls[i].OnParentVisibleChanged(e);
4907 #endregion // OnXXX methods
4910 static object BackColorChangedEvent = new object ();
4911 static object BackgroundImageChangedEvent = new object ();
4912 static object BindingContextChangedEvent = new object ();
4913 static object CausesValidationChangedEvent = new object ();
4914 static object ChangeUICuesEvent = new object ();
4915 static object ClickEvent = new object ();
4916 static object ContextMenuChangedEvent = new object ();
4917 static object ControlAddedEvent = new object ();
4918 static object ControlRemovedEvent = new object ();
4919 static object CursorChangedEvent = new object ();
4920 static object DockChangedEvent = new object ();
4921 static object DoubleClickEvent = new object ();
4922 static object DragDropEvent = new object ();
4923 static object DragEnterEvent = new object ();
4924 static object DragLeaveEvent = new object ();
4925 static object DragOverEvent = new object ();
4926 static object EnabledChangedEvent = new object ();
4927 static object EnterEvent = new object ();
4928 static object FontChangedEvent = new object ();
4929 static object ForeColorChangedEvent = new object ();
4930 static object GiveFeedbackEvent = new object ();
4931 static object GotFocusEvent = new object ();
4932 static object HandleCreatedEvent = new object ();
4933 static object HandleDestroyedEvent = new object ();
4934 static object HelpRequestedEvent = new object ();
4935 static object ImeModeChangedEvent = new object ();
4936 static object InvalidatedEvent = new object ();
4937 static object KeyDownEvent = new object ();
4938 static object KeyPressEvent = new object ();
4939 static object KeyUpEvent = new object ();
4940 static object LayoutEvent = new object ();
4941 static object LeaveEvent = new object ();
4942 static object LocationChangedEvent = new object ();
4943 static object LostFocusEvent = new object ();
4944 static object MouseDownEvent = new object ();
4945 static object MouseEnterEvent = new object ();
4946 static object MouseHoverEvent = new object ();
4947 static object MouseLeaveEvent = new object ();
4948 static object MouseMoveEvent = new object ();
4949 static object MouseUpEvent = new object ();
4950 static object MouseWheelEvent = new object ();
4951 static object MoveEvent = new object ();
4952 static object PaintEvent = new object ();
4953 static object ParentChangedEvent = new object ();
4954 static object QueryAccessibilityHelpEvent = new object ();
4955 static object QueryContinueDragEvent = new object ();
4956 static object ResizeEvent = new object ();
4957 static object RightToLeftChangedEvent = new object ();
4958 static object SizeChangedEvent = new object ();
4959 static object StyleChangedEvent = new object ();
4960 static object SystemColorsChangedEvent = new object ();
4961 static object TabIndexChangedEvent = new object ();
4962 static object TabStopChangedEvent = new object ();
4963 static object TextChangedEvent = new object ();
4964 static object ValidatedEvent = new object ();
4965 static object ValidatingEvent = new object ();
4966 static object VisibleChangedEvent = new object ();
4968 public event EventHandler BackColorChanged {
4969 add { Events.AddHandler (BackColorChangedEvent, value); }
4970 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
4973 public event EventHandler BackgroundImageChanged {
4974 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
4975 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
4978 public event EventHandler BindingContextChanged {
4979 add { Events.AddHandler (BindingContextChangedEvent, value); }
4980 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
4983 public event EventHandler CausesValidationChanged {
4984 add { Events.AddHandler (CausesValidationChangedEvent, value); }
4985 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
4988 public event UICuesEventHandler ChangeUICues {
4989 add { Events.AddHandler (ChangeUICuesEvent, value); }
4990 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
4993 public event EventHandler Click {
4994 add { Events.AddHandler (ClickEvent, value); }
4995 remove { Events.RemoveHandler (ClickEvent, value); }
4998 public event EventHandler ContextMenuChanged {
4999 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5000 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5003 [EditorBrowsable(EditorBrowsableState.Advanced)]
5005 public event ControlEventHandler ControlAdded {
5006 add { Events.AddHandler (ControlAddedEvent, value); }
5007 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5010 [EditorBrowsable(EditorBrowsableState.Advanced)]
5012 public event ControlEventHandler ControlRemoved {
5013 add { Events.AddHandler (ControlRemovedEvent, value); }
5014 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5017 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5018 public event EventHandler CursorChanged {
5019 add { Events.AddHandler (CursorChangedEvent, value); }
5020 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5022 public event EventHandler DockChanged {
5023 add { Events.AddHandler (DockChangedEvent, value); }
5024 remove { Events.RemoveHandler (DockChangedEvent, value); }
5027 public event EventHandler DoubleClick {
5028 add { Events.AddHandler (DoubleClickEvent, value); }
5029 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5032 public event DragEventHandler DragDrop {
5033 add { Events.AddHandler (DragDropEvent, value); }
5034 remove { Events.RemoveHandler (DragDropEvent, value); }
5037 public event DragEventHandler DragEnter {
5038 add { Events.AddHandler (DragEnterEvent, value); }
5039 remove { Events.RemoveHandler (DragEnterEvent, value); }
5042 public event EventHandler DragLeave {
5043 add { Events.AddHandler (DragLeaveEvent, value); }
5044 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5047 public event DragEventHandler DragOver {
5048 add { Events.AddHandler (DragOverEvent, value); }
5049 remove { Events.RemoveHandler (DragOverEvent, value); }
5052 public event EventHandler EnabledChanged {
5053 add { Events.AddHandler (EnabledChangedEvent, value); }
5054 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5057 public event EventHandler Enter {
5058 add { Events.AddHandler (EnterEvent, value); }
5059 remove { Events.RemoveHandler (EnterEvent, value); }
5062 public event EventHandler FontChanged {
5063 add { Events.AddHandler (FontChangedEvent, value); }
5064 remove { Events.RemoveHandler (FontChangedEvent, value); }
5067 public event EventHandler ForeColorChanged {
5068 add { Events.AddHandler (ForeColorChangedEvent, value); }
5069 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5072 public event GiveFeedbackEventHandler GiveFeedback {
5073 add { Events.AddHandler (GiveFeedbackEvent, value); }
5074 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5077 [EditorBrowsable(EditorBrowsableState.Advanced)]
5079 public event EventHandler GotFocus {
5080 add { Events.AddHandler (GotFocusEvent, value); }
5081 remove { Events.RemoveHandler (GotFocusEvent, value); }
5085 [EditorBrowsable(EditorBrowsableState.Advanced)]
5087 public event EventHandler HandleCreated {
5088 add { Events.AddHandler (HandleCreatedEvent, value); }
5089 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5092 [EditorBrowsable(EditorBrowsableState.Advanced)]
5094 public event EventHandler HandleDestroyed {
5095 add { Events.AddHandler (HandleDestroyedEvent, value); }
5096 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5099 public event HelpEventHandler HelpRequested {
5100 add { Events.AddHandler (HelpRequestedEvent, value); }
5101 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5104 public event EventHandler ImeModeChanged {
5105 add { Events.AddHandler (ImeModeChangedEvent, value); }
5106 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5109 [EditorBrowsable(EditorBrowsableState.Advanced)]
5111 public event InvalidateEventHandler Invalidated {
5112 add { Events.AddHandler (InvalidatedEvent, value); }
5113 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5116 public event KeyEventHandler KeyDown {
5117 add { Events.AddHandler (KeyDownEvent, value); }
5118 remove { Events.RemoveHandler (KeyDownEvent, value); }
5121 public event KeyPressEventHandler KeyPress {
5122 add { Events.AddHandler (KeyPressEvent, value); }
5123 remove { Events.RemoveHandler (KeyPressEvent, value); }
5126 public event KeyEventHandler KeyUp {
5127 add { Events.AddHandler (KeyUpEvent, value); }
5128 remove { Events.RemoveHandler (KeyUpEvent, value); }
5131 public event LayoutEventHandler Layout {
5132 add { Events.AddHandler (LayoutEvent, value); }
5133 remove { Events.RemoveHandler (LayoutEvent, value); }
5136 public event EventHandler Leave {
5137 add { Events.AddHandler (LeaveEvent, value); }
5138 remove { Events.RemoveHandler (LeaveEvent, value); }
5141 public event EventHandler LocationChanged {
5142 add { Events.AddHandler (LocationChangedEvent, value); }
5143 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5146 [EditorBrowsable(EditorBrowsableState.Advanced)]
5148 public event EventHandler LostFocus {
5149 add { Events.AddHandler (LostFocusEvent, value); }
5150 remove { Events.RemoveHandler (LostFocusEvent, value); }
5153 public event MouseEventHandler MouseDown {
5154 add { Events.AddHandler (MouseDownEvent, value); }
5155 remove { Events.RemoveHandler (MouseDownEvent, value); }
5158 public event EventHandler MouseEnter {
5159 add { Events.AddHandler (MouseEnterEvent, value); }
5160 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5163 public event EventHandler MouseHover {
5164 add { Events.AddHandler (MouseHoverEvent, value); }
5165 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5168 public event EventHandler MouseLeave {
5169 add { Events.AddHandler (MouseLeaveEvent, value); }
5170 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5173 public event MouseEventHandler MouseMove {
5174 add { Events.AddHandler (MouseMoveEvent, value); }
5175 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5178 public event MouseEventHandler MouseUp {
5179 add { Events.AddHandler (MouseUpEvent, value); }
5180 remove { Events.RemoveHandler (MouseUpEvent, value); }
5183 [EditorBrowsable(EditorBrowsableState.Advanced)]
5185 public event MouseEventHandler MouseWheel {
5186 add { Events.AddHandler (MouseWheelEvent, value); }
5187 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5190 public event EventHandler Move {
5191 add { Events.AddHandler (MoveEvent, value); }
5192 remove { Events.RemoveHandler (MoveEvent, value); }
5195 public event PaintEventHandler Paint {
5196 add { Events.AddHandler (PaintEvent, value); }
5197 remove { Events.RemoveHandler (PaintEvent, value); }
5200 public event EventHandler ParentChanged {
5201 add { Events.AddHandler (ParentChangedEvent, value); }
5202 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5205 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5206 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5207 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5210 public event QueryContinueDragEventHandler QueryContinueDrag {
5211 add { Events.AddHandler (QueryContinueDragEvent, value); }
5212 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5215 public event EventHandler Resize {
5216 add { Events.AddHandler (ResizeEvent, value); }
5217 remove { Events.RemoveHandler (ResizeEvent, value); }
5220 public event EventHandler RightToLeftChanged {
5221 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5222 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5225 public event EventHandler SizeChanged {
5226 add { Events.AddHandler (SizeChangedEvent, value); }
5227 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5230 public event EventHandler StyleChanged {
5231 add { Events.AddHandler (StyleChangedEvent, value); }
5232 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5235 public event EventHandler SystemColorsChanged {
5236 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5237 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5240 public event EventHandler TabIndexChanged {
5241 add { Events.AddHandler (TabIndexChangedEvent, value); }
5242 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5245 public event EventHandler TabStopChanged {
5246 add { Events.AddHandler (TabStopChangedEvent, value); }
5247 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5250 public event EventHandler TextChanged {
5251 add { Events.AddHandler (TextChangedEvent, value); }
5252 remove { Events.RemoveHandler (TextChangedEvent, value); }
5255 public event EventHandler Validated {
5256 add { Events.AddHandler (ValidatedEvent, value); }
5257 remove { Events.RemoveHandler (ValidatedEvent, value); }
5260 public event CancelEventHandler Validating {
5261 add { Events.AddHandler (ValidatingEvent, value); }
5262 remove { Events.RemoveHandler (ValidatingEvent, value); }
5265 public event EventHandler VisibleChanged {
5266 add { Events.AddHandler (VisibleChangedEvent, value); }
5267 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5270 #endregion // Events