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
55 [ClassInterface (ClassInterfaceType.AutoDispatch)]
57 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
58 [DefaultProperty("Text")]
59 [DefaultEvent("Click")]
60 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
61 [ToolboxItemFilter("System.Windows.Forms")]
62 public class Control : Component, ISynchronizeInvoke, IWin32Window
64 , IBindableComponent, IDropTarget
67 #region Local Variables
70 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
71 Rectangle explicit_bounds; // explicitly set bounds
72 internal object creator_thread; // thread that created the control
73 internal ControlNativeWindow window; // object for native window handle
74 string name; // for object naming
77 bool is_created; // true if OnCreateControl has been sent
78 internal bool has_focus; // true if control has focus
79 internal bool is_visible; // true if control is visible
80 internal bool is_entered; // is the mouse inside the control?
81 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
82 bool is_accessible; // true if the control is visible to accessibility applications
83 bool is_captured; // tracks if the control has captured the mouse
84 internal bool is_toplevel; // tracks if the control is a toplevel window
85 bool is_recreating; // tracks if the handle for the control is being recreated
86 bool causes_validation; // tracks if validation is executed on changes
87 bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
88 int tab_index; // position in tab order of siblings
89 bool tab_stop; // is the control a tab stop?
90 bool is_disposed; // has the window already been disposed?
91 Size client_size; // size of the client area (window excluding decorations)
92 Rectangle client_rect; // rectangle with the client area (window excluding decorations)
93 ControlStyles control_style; // rather win32-specific, style bits for control
95 bool layout_pending; // true if our parent needs to re-layout us
96 object control_tag; // object that contains data about our control
97 internal int mouse_clicks; // Counter for mouse clicks
98 Cursor cursor; // Cursor for the window
99 internal bool allow_drop; // true if the control accepts droping objects on it
100 Region clip_region; // User-specified clip region for the window
103 internal Color foreground_color; // foreground color for control
104 internal Color background_color; // background color for control
105 Image background_image; // background image for control
106 internal Font font; // font for control
107 string text; // window/title text for control
108 internal BorderStyle border_style; // Border style of control
111 int layout_suspended;
112 internal AnchorStyles anchor_style; // anchoring requirements for our control
113 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
114 // Please leave the next 4 as internal until DefaultLayout (2.0) is rewritten
115 internal int dist_left; // distance to the left border of the parent
116 internal int dist_top; // distance to the top border of the parent
117 internal int dist_right; // distance to the right border of the parent
118 internal int dist_bottom; // distance to the bottom border of the parent
120 // to be categorized...
121 ControlCollection child_controls; // our children
122 Control parent; // our parent control
123 AccessibleObject accessibility_object; // object that contains accessibility information about our control
124 BindingContext binding_context;
125 RightToLeft right_to_left; // drawing direction for control
126 ContextMenu context_menu; // Context menu associated with the control
129 Graphics backbuffer_dc;
131 Region invalid_region;
133 ControlBindingsCollection data_bindings;
136 internal bool use_compatible_text_rendering;
137 static bool verify_thread_handle;
139 ImageLayout backgroundimage_layout;
144 Layout.LayoutEngine layout_engine;
147 #endregion // Local Variables
149 #region Private Classes
150 // This helper class allows us to dispatch messages to Control.WndProc
151 internal class ControlNativeWindow : NativeWindow {
152 private Control owner;
154 public ControlNativeWindow(Control control) : base() {
159 public Control Owner {
165 static internal Control ControlFromHandle(IntPtr hWnd) {
166 ControlNativeWindow window;
168 window = (ControlNativeWindow)window_collection[hWnd];
169 if (window != null) {
176 static internal Control ControlFromChildHandle (IntPtr handle) {
177 ControlNativeWindow window;
179 Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
180 while (hwnd != null) {
181 window = (ControlNativeWindow)window_collection[hwnd.Handle];
182 if (window != null) {
191 protected override void WndProc(ref Message m) {
192 owner.WndProc(ref m);
197 #region Public Classes
199 public class ControlAccessibleObject : AccessibleObject {
202 #region ControlAccessibleObject Constructors
203 public ControlAccessibleObject(Control ownerControl)
204 : base (ownerControl)
206 this.owner = ownerControl;
208 #endregion // ControlAccessibleObject Constructors
210 #region ControlAccessibleObject Public Instance Properties
211 public override string DefaultAction {
213 return base.DefaultAction;
217 public override string Description {
219 return base.Description;
223 public IntPtr Handle {
229 // We don't want to let them set it
233 public override string Help {
239 public override string KeyboardShortcut {
241 return base.KeyboardShortcut;
245 public override string Name {
255 public Control Owner {
261 public override AccessibleObject Parent {
268 public override AccessibleRole Role {
273 #endregion // ControlAccessibleObject Public Instance Properties
275 #region ControlAccessibleObject Public Instance Methods
276 public override int GetHelpTopic(out string FileName) {
277 return base.GetHelpTopic (out FileName);
280 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
281 public void NotifyClients(AccessibleEvents accEvent) {
282 throw new NotImplementedException();
285 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
286 public void NotifyClients(AccessibleEvents accEvent, int childID) {
287 throw new NotImplementedException();
290 public override string ToString() {
291 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
294 #endregion // ControlAccessibleObject Public Instance Methods
300 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
302 [ListBindable(false)]
303 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
304 #region ControlCollection Local Variables
307 Control[] all_controls;
309 #endregion // ControlCollection Local Variables
311 #region ControlCollection Public Constructor
312 public ControlCollection(Control owner) {
314 this.list=new ArrayList();
318 #region ControlCollection Public Instance Properties
325 public bool IsReadOnly {
327 return list.IsReadOnly;
331 public virtual Control this[int index] {
333 if (index < 0 || index >= list.Count) {
334 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
336 return (Control)list[index];
339 #endregion // ControlCollection Public Instance Properties
341 #region ControlCollection Private Instance Methods
342 public virtual void Add (Control value)
347 if (Contains (value)) {
348 owner.PerformLayout();
352 if (value.tab_index == -1) {
358 end = owner.child_controls.Count;
359 for (int i = 0; i < end; i++) {
360 index = owner.child_controls[i].tab_index;
365 value.tab_index = use;
368 if (value.parent != null) {
369 value.parent.Controls.Remove(value);
375 value.ChangeParent(owner);
379 owner.UpdateChildrenZOrder();
380 owner.PerformLayout(value, "Parent");
381 owner.OnControlAdded(new ControlEventArgs(value));
384 internal void AddToList (Control c)
390 internal virtual void AddImplicit (Control control)
392 if (impl_list == null)
393 impl_list = new ArrayList ();
395 if (AllContains (control))
399 impl_list.Add (control);
401 control.ChangeParent (owner);
402 control.InitLayout ();
403 owner.UpdateChildrenZOrder ();
404 owner.PerformLayout (control, "Parent");
405 owner.OnControlAdded (new ControlEventArgs (control));
408 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
410 public virtual void AddRange (Control[] controls)
412 if (controls == null)
413 throw new ArgumentNullException ("controls");
415 owner.SuspendLayout ();
418 for (int i = 0; i < controls.Length; i++)
421 owner.ResumeLayout ();
425 internal virtual void AddRangeImplicit (Control [] controls)
427 if (controls == null)
428 throw new ArgumentNullException ("controls");
430 owner.SuspendLayout ();
433 for (int i = 0; i < controls.Length; i++)
434 AddImplicit (controls [i]);
436 owner.ResumeLayout ();
440 public virtual void Clear ()
444 // MS sends remove events in reverse order
445 while (list.Count > 0) {
446 Remove((Control)list[list.Count - 1]);
450 internal virtual void ClearImplicit ()
452 if (impl_list == null)
458 public bool Contains (Control value)
460 for (int i = list.Count; i > 0; ) {
463 if (list [i] == value) {
464 // Do we need to do anything here?
471 internal bool ImplicitContains (Control value)
473 if (impl_list == null)
476 for (int i = impl_list.Count; i > 0; ) {
479 if (impl_list [i] == value) {
480 // Do we need to do anything here?
487 internal bool AllContains (Control value)
489 return Contains (value) || ImplicitContains (value);
492 public void CopyTo (Array array, int index)
494 list.CopyTo(array, index);
497 public override bool Equals(object other) {
498 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
505 public int GetChildIndex(Control child) {
506 return GetChildIndex(child, false);
509 public int GetChildIndex(Control child, bool throwException) {
512 index=list.IndexOf(child);
514 if (index==-1 && throwException) {
515 throw new ArgumentException("Not a child control", "child");
520 public IEnumerator GetEnumerator() {
521 return list.GetEnumerator();
524 internal IEnumerator GetAllEnumerator ()
526 Control [] res = GetAllControls ();
527 return res.GetEnumerator ();
530 internal Control [] GetAllControls ()
532 if (all_controls != null)
535 if (impl_list == null) {
536 all_controls = (Control []) list.ToArray (typeof (Control));
540 all_controls = new Control [list.Count + impl_list.Count];
541 impl_list.CopyTo (all_controls);
542 list.CopyTo (all_controls, impl_list.Count);
547 public override int GetHashCode() {
548 return base.GetHashCode();
551 public int IndexOf(Control control) {
552 return list.IndexOf(control);
555 public virtual void Remove(Control value) {
559 owner.PerformLayout(value, "Parent");
560 owner.OnControlRemoved(new ControlEventArgs(value));
565 value.ChangeParent(null);
567 owner.UpdateChildrenZOrder();
570 internal virtual void RemoveImplicit (Control control)
572 if (impl_list != null) {
574 owner.PerformLayout (control, "Parent");
575 owner.OnControlRemoved (new ControlEventArgs (control));
576 impl_list.Remove (control);
578 control.ChangeParent (null);
579 owner.UpdateChildrenZOrder ();
582 public void RemoveAt(int index) {
583 if (index < 0 || index >= list.Count) {
584 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
586 Remove ((Control)list[index]);
589 public void SetChildIndex(Control child, int newIndex) {
591 throw new ArgumentNullException ("child");
595 old_index=list.IndexOf(child);
597 throw new ArgumentException("Not a child control", "child");
600 if (old_index==newIndex) {
605 list.RemoveAt(old_index);
607 if (newIndex>list.Count) {
610 list.Insert(newIndex, child);
612 child.UpdateZOrder();
613 owner.PerformLayout();
615 #endregion // ControlCollection Private Instance Methods
617 #region ControlCollection Interface Properties
618 object IList.this[int index] {
620 if (index<0 || index>=list.Count) {
621 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
627 if (!(value is Control)) {
628 throw new ArgumentException("Object of type Control required", "value");
632 Control ctrl = (Control) value;
635 ctrl.ChangeParent(owner);
639 owner.UpdateChildrenZOrder();
640 owner.PerformLayout(ctrl, "Parent");
644 bool IList.IsFixedSize {
650 bool ICollection.IsSynchronized {
652 return list.IsSynchronized;
656 object ICollection.SyncRoot {
658 return list.SyncRoot;
661 #endregion // ControlCollection Interface Properties
663 #region ControlCollection Interface Methods
664 int IList.Add(object value) {
666 throw new ArgumentNullException("value", "Cannot add null controls");
669 if (!(value is Control)) {
670 throw new ArgumentException("Object of type Control required", "value");
673 return list.Add(value);
676 bool IList.Contains(object value) {
677 if (!(value is Control)) {
678 throw new ArgumentException("Object of type Control required", "value");
681 return this.Contains((Control) value);
684 int IList.IndexOf(object value) {
685 if (!(value is Control)) {
686 throw new ArgumentException("Object of type Control required", "value");
689 return this.IndexOf((Control) value);
692 void IList.Insert(int index, object value) {
693 if (!(value is Control)) {
694 throw new ArgumentException("Object of type Control required", "value");
697 list.Insert(index, value);
700 void IList.Remove(object value) {
701 if (!(value is Control)) {
702 throw new ArgumentException("Object of type Control required", "value");
708 Object ICloneable.Clone() {
709 ControlCollection clone = new ControlCollection(this.owner);
710 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
713 #endregion // ControlCollection Interface Methods
715 #endregion // ControlCollection Class
717 #region Public Constructors
720 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
728 layout_pending = false;
730 causes_validation = true;
732 layout_suspended = 0;
736 right_to_left = RightToLeft.Inherit;
737 border_style = BorderStyle.None;
738 background_color = Color.Empty;
744 ime_mode = ImeMode.Inherit;
747 backgroundimage_layout = ImageLayout.Tile;
748 use_compatible_text_rendering = Application.use_compatible_text_rendering;
749 padding = new Padding(0);
750 maximum_size = new Size();
751 minimum_size = new Size();
752 preferred_size = new Size();
753 margin = this.DefaultMargin;
754 layout_engine = this.LayoutEngine;
757 control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
758 ControlStyles.Selectable | ControlStyles.StandardClick |
759 ControlStyles.StandardDoubleClick;
761 control_style |= ControlStyles.UseTextForAccessibility;
765 background_image = null;
769 window = new ControlNativeWindow(this);
770 child_controls = CreateControlsInstance();
771 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
772 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
773 XplatUI.CalculateWindowRect(ref client_rect, CreateParams.Style, CreateParams.ExStyle, null, out bounds);
774 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
780 public Control(Control parent, string text) : this() {
785 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
790 bounds.Height=height;
791 SetBounds(left, top, width, height, BoundsSpecified.All);
795 public Control(string text) : this() {
799 public Control(string text, int left, int top, int width, int height) : this() {
803 bounds.Height=height;
804 SetBounds(left, top, width, height, BoundsSpecified.All);
808 private delegate void RemoveDelegate(object c);
810 protected override void Dispose(bool disposing) {
811 if (!is_disposed && disposing) {
814 DisposeBackBuffer ();
816 if (invalid_region!=null) {
817 invalid_region.Dispose();
820 if (this.InvokeRequired) {
821 if (Application.MessageLoop) {
822 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
828 if (parent != null) {
829 parent.Controls.Remove(this);
832 Control [] children = child_controls.GetAllControls ();
833 for (int i=0; i<children.Length; i++) {
834 children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
835 children[i].Dispose();
840 base.Dispose(disposing);
842 #endregion // Public Constructors
844 #region Internal Properties
845 internal BorderStyle InternalBorderStyle {
851 if (!Enum.IsDefined (typeof (BorderStyle), value))
852 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
854 if (border_style != value) {
855 border_style = value;
857 if (IsHandleCreated) {
858 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
864 #endregion // Internal Properties
866 #region Private & Internal Methods
869 void IDropTarget.OnDragDrop (DragEventArgs e)
874 void IDropTarget.OnDragEnter (DragEventArgs e)
879 void IDropTarget.OnDragLeave (EventArgs e)
884 void IDropTarget.OnDragOver (DragEventArgs e)
890 internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
891 AsyncMethodResult result;
892 AsyncMethodData data;
897 if (!p.IsHandleCreated) {
898 throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
904 result = new AsyncMethodResult ();
905 data = new AsyncMethodData ();
907 data.Handle = window.Handle;
908 data.Method = method;
910 data.Result = result;
913 if (!ExecutionContext.IsFlowSuppressed ()) {
914 data.Context = ExecutionContext.Capture ();
917 #if !MWF_ON_MSRUNTIME
918 if (SecurityManager.SecurityEnabled) {
919 data.Stack = CompressedStack.GetCompressedStack ();
924 XplatUI.SendAsyncMethod (data);
929 internal void PointToClient (ref int x, ref int y)
931 XplatUI.ScreenToClient (Handle, ref x, ref y);
934 internal void PointToScreen (ref int x, ref int y)
936 XplatUI.ClientToScreen (Handle, ref x, ref y);
939 internal bool IsRecreating {
941 return is_recreating;
945 internal Graphics DeviceContext {
946 get { return Hwnd.bmp_g; }
949 private void InvalidateBackBuffer ()
951 if (invalid_region != null)
952 invalid_region.Dispose();
953 invalid_region = new Region (ClientRectangle);
956 private void CreateBackBuffer ()
958 if (backbuffer != null)
964 if (width < 1) width = 1;
965 if (height < 1) height = 1;
967 XplatUI.CreateOffscreenDrawable (Handle, width, height, out backbuffer, out backbuffer_dc);
968 InvalidateBackBuffer ();
971 private void DisposeBackBuffer ()
973 if (backbuffer == null)
976 XplatUI.DestroyOffscreenDrawable (backbuffer, backbuffer_dc);
978 backbuffer_dc = null;
981 if (invalid_region != null)
982 invalid_region.Dispose ();
983 invalid_region = null;
986 internal static void SetChildColor(Control parent) {
989 for (int i=0; i < parent.child_controls.Count; i++) {
990 child=parent.child_controls[i];
991 if (child.child_controls.Count>0) {
992 SetChildColor(child);
997 internal bool Select(Control control) {
998 IContainerControl container;
1000 if (control == null) {
1004 container = GetContainerControl();
1005 if (container != null) {
1006 container.ActiveControl = control;
1008 if (control.IsHandleCreated) {
1009 XplatUI.SetFocus(control.window.Handle);
1014 internal void SelectChild (Control control)
1016 if (control.IsHandleCreated)
1017 XplatUI.SetFocus (control.window.Handle);
1020 internal virtual void DoDefaultAction() {
1021 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1024 internal static IntPtr MakeParam (int low, int high){
1025 return new IntPtr (high << 16 | low & 0xffff);
1028 internal static int LowOrder (int param) {
1029 return ((int)(short)(param & 0xffff));
1032 internal static int HighOrder (int param) {
1033 return ((int)(short)(param >> 16));
1036 // This method exists so controls overriding OnPaintBackground can have default background painting done
1037 internal virtual void PaintControlBackground (PaintEventArgs pevent)
1039 if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
1040 if (parent != null) {
1041 PaintEventArgs parent_pe;
1042 GraphicsState state;
1044 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1046 state = parent_pe.Graphics.Save();
1047 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1048 parent.OnPaintBackground(parent_pe);
1049 parent_pe.Graphics.Restore(state);
1051 state = parent_pe.Graphics.Save();
1052 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1053 parent.OnPaint(parent_pe);
1054 parent_pe.Graphics.Restore(state);
1055 parent_pe.SetGraphics(null);
1059 if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
1060 if (parent != null) {
1061 PaintEventArgs parent_pe;
1063 GraphicsState state;
1066 hwnd = Hwnd.ObjectFromHandle(Handle);
1069 parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
1071 region = new Region ();
1073 region.Union(ClientRectangle);
1075 foreach (Rectangle r in hwnd.ClipRectangles) {
1079 state = parent_pe.Graphics.Save();
1080 parent_pe.Graphics.Clip = region;
1082 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1083 parent.OnPaintBackground(parent_pe);
1084 parent_pe.Graphics.Restore(state);
1086 state = parent_pe.Graphics.Save();
1087 parent_pe.Graphics.Clip = region;
1089 parent_pe.Graphics.TranslateTransform(-Left, -Top);
1090 parent.OnPaint(parent_pe);
1091 parent_pe.Graphics.Restore(state);
1092 parent_pe.SetGraphics(null);
1094 region.Intersect(clip_region);
1095 pevent.Graphics.Clip = region;
1100 if (background_image == null) {
1101 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));
1105 DrawBackgroundImage (pevent.Graphics);
1108 void DrawBackgroundImage (Graphics g)
1111 Rectangle drawing_rectangle = new Rectangle ();
1112 g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
1114 switch (backgroundimage_layout)
1116 case ImageLayout.Tile:
1117 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1118 g.FillRectangle (b, ClientRectangle);
1121 case ImageLayout.Center:
1122 drawing_rectangle.Location = new Point (ClientSize.Width / 2 - background_image.Width / 2, ClientSize.Height / 2 - background_image.Height / 2);
1123 drawing_rectangle.Size = background_image.Size;
1125 case ImageLayout.None:
1126 drawing_rectangle.Location = Point.Empty;
1127 drawing_rectangle.Size = background_image.Size;
1129 case ImageLayout.Stretch:
1130 drawing_rectangle = ClientRectangle;
1132 case ImageLayout.Zoom:
1133 drawing_rectangle = ClientRectangle;
1134 if ((float)background_image.Width / (float)background_image.Height < (float)drawing_rectangle.Width / (float) drawing_rectangle.Height) {
1135 drawing_rectangle.Width = (int) (background_image.Width * ((float)drawing_rectangle.Height / (float)background_image.Height));
1136 drawing_rectangle.X = (ClientRectangle.Width - drawing_rectangle.Width) / 2;
1138 drawing_rectangle.Height = (int) (background_image.Height * ((float)drawing_rectangle.Width / (float)background_image.Width));
1139 drawing_rectangle.Y = (ClientRectangle.Height - drawing_rectangle.Height) / 2;
1146 g.DrawImage (background_image, drawing_rectangle);
1149 using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
1150 g.FillRectangle (b, ClientRectangle);
1155 internal virtual void DndEnter (DragEventArgs e)
1162 internal virtual void DndOver (DragEventArgs e)
1169 internal virtual void DndDrop (DragEventArgs e)
1173 } catch (Exception exc) {
1174 Console.Error.WriteLine ("MWF: Exception while dropping:");
1175 Console.Error.WriteLine (exc);
1179 internal virtual void DndLeave (EventArgs e)
1186 internal virtual void DndFeedback(GiveFeedbackEventArgs e)
1193 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
1196 OnQueryContinueDrag(e);
1200 internal static MouseButtons FromParamToMouseButtons (int param) {
1201 MouseButtons buttons = MouseButtons.None;
1203 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
1204 buttons |= MouseButtons.Left;
1206 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
1207 buttons |= MouseButtons.Middle;
1209 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
1210 buttons |= MouseButtons.Right;
1216 internal void FireEnter ()
1218 OnEnter (EventArgs.Empty);
1221 internal void FireLeave ()
1223 OnLeave (EventArgs.Empty);
1226 internal void FireValidating (CancelEventArgs ce)
1231 internal void FireValidated ()
1233 OnValidated (EventArgs.Empty);
1236 internal virtual bool ProcessControlMnemonic(char charCode) {
1237 return ProcessMnemonic(charCode);
1240 private static Control FindFlatForward(Control container, Control start) {
1246 end = container.child_controls.Count;
1248 if (start != null) {
1249 index = start.tab_index;
1254 for (int i = 0, pos = -1; i < end; i++) {
1255 if (start == container.child_controls[i]) {
1260 if (found == null) {
1261 if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
1262 found = container.child_controls[i];
1264 } else if (found.tab_index > container.child_controls[i].tab_index) {
1265 if (container.child_controls[i].tab_index > index) {
1266 found = container.child_controls[i];
1273 private static Control FindControlForward(Control container, Control start) {
1278 if (start == null) {
1279 return FindFlatForward(container, start);
1282 if (start.child_controls != null && start.child_controls.Count > 0 &&
1283 (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
1284 return FindControlForward(start, null);
1287 while (start != container) {
1288 found = FindFlatForward(start.parent, start);
1289 if (found != null) {
1292 start = start.parent;
1298 private static Control FindFlatBackward(Control container, Control start) {
1304 end = container.child_controls.Count;
1306 if (start != null) {
1307 index = start.tab_index;
1309 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1311 for (int i = 0; i < end; i++) {
1312 if (container.child_controls[i].tab_index > index) {
1313 index = container.child_controls[i].tab_index;
1321 for (int i = end - 1; i >= 0; i--) {
1322 if (start == container.child_controls[i]) {
1327 if (found == null || found.tab_index < container.child_controls[i].tab_index) {
1328 if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
1329 found = container.child_controls[i];
1336 private static Control FindControlBackward(Control container, Control start) {
1338 Control found = null;
1340 if (start == null) {
1341 found = FindFlatBackward(container, start);
1343 else if (start != container) {
1344 if (start.parent != null) {
1345 found = FindFlatBackward(start.parent, start);
1347 if (found == null) {
1348 if (start.parent != container)
1349 return start.parent;
1355 if (found == null || start.parent == null)
1358 while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
1359 found.child_controls != null && found.child_controls.Count > 0)) {
1360 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1361 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1362 found = FindFlatBackward(found, null);
1372 if (start != null) {
1373 found = FindFlatBackward(start.parent, start);
1374 if (found == null) {
1375 if (start.parent != container) {
1376 return start.parent;
1380 if (found == null) {
1381 found = FindFlatBackward(container, start);
1384 if (container != start) {
1385 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1386 found = FindControlBackward(found, null);
1387 if (found != null) {
1396 internal virtual void HandleClick(int clicks, MouseEventArgs me) {
1397 if (GetStyle(ControlStyles.StandardClick)) {
1398 if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
1400 OnDoubleClick(EventArgs.Empty);
1402 OnClick(EventArgs.Empty);
1412 private void CheckDataBindings ()
1414 if (data_bindings == null)
1417 BindingContext binding_context = BindingContext;
1418 foreach (Binding binding in data_bindings) {
1419 binding.Check (binding_context);
1423 private void ChangeParent(Control new_parent) {
1427 Color pre_fore_color;
1428 Color pre_back_color;
1429 RightToLeft pre_rtl;
1431 // These properties are inherited from our parent
1432 // Get them pre parent-change and then send events
1433 // if they are changed after we have our new parent
1434 pre_enabled = Enabled;
1435 pre_visible = Visible;
1437 pre_fore_color = ForeColor;
1438 pre_back_color = BackColor;
1439 pre_rtl = RightToLeft;
1440 // MS doesn't seem to send a CursorChangedEvent
1442 parent = new_parent;
1444 if (IsHandleCreated)
1445 XplatUI.SetParent(Handle,
1446 (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
1448 OnParentChanged(EventArgs.Empty);
1450 if (pre_enabled != Enabled) {
1451 OnEnabledChanged(EventArgs.Empty);
1454 if (pre_visible != Visible) {
1455 OnVisibleChanged(EventArgs.Empty);
1458 if (pre_font != Font) {
1459 OnFontChanged(EventArgs.Empty);
1462 if (pre_fore_color != ForeColor) {
1463 OnForeColorChanged(EventArgs.Empty);
1466 if (pre_back_color != BackColor) {
1467 OnBackColorChanged(EventArgs.Empty);
1470 if (pre_rtl != RightToLeft) {
1471 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1472 // because when RTL changes they have to recreate the win32 control
1473 // We don't really need that (until someone runs into compatibility issues)
1474 OnRightToLeftChanged(EventArgs.Empty);
1477 if ((new_parent != null) && new_parent.Created && !Created) {
1481 if ((binding_context == null) && Created) {
1482 OnBindingContextChanged(EventArgs.Empty);
1486 private void UpdateDistances() {
1487 if ((parent != null) && (parent.layout_suspended == 0)) {
1488 dist_left = bounds.X;
1489 dist_top = bounds.Y;
1490 dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
1491 dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
1494 #endregion // Private & Internal Methods
1496 #region Public Static Properties
1497 public static Color DefaultBackColor {
1499 return ThemeEngine.Current.DefaultControlBackColor;
1503 public static Font DefaultFont {
1505 return ThemeEngine.Current.DefaultFont;
1509 public static Color DefaultForeColor {
1511 return ThemeEngine.Current.DefaultControlForeColor;
1515 public static Keys ModifierKeys {
1517 return XplatUI.State.ModifierKeys;
1521 public static MouseButtons MouseButtons {
1523 return XplatUI.State.MouseButtons;
1527 public static Point MousePosition {
1529 return Cursor.Position;
1534 [EditorBrowsable (EditorBrowsableState.Advanced)]
1535 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1538 public static bool CheckForIllegalCrossThreadCalls
1541 return verify_thread_handle;
1545 verify_thread_handle = value;
1549 #endregion // Public Static Properties
1551 #region Public Instance Properties
1552 [EditorBrowsable(EditorBrowsableState.Advanced)]
1554 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1555 public AccessibleObject AccessibilityObject {
1557 if (accessibility_object==null) {
1558 accessibility_object=CreateAccessibilityInstance();
1560 return accessibility_object;
1564 [EditorBrowsable(EditorBrowsableState.Advanced)]
1566 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1567 public string AccessibleDefaultActionDescription {
1569 return AccessibilityObject.default_action;
1573 AccessibilityObject.default_action=value;
1578 [DefaultValue(null)]
1579 [MWFCategory("Accessibility")]
1580 public string AccessibleDescription {
1582 return AccessibilityObject.description;
1586 AccessibilityObject.description=value;
1591 [DefaultValue(null)]
1592 [MWFCategory("Accessibility")]
1593 public string AccessibleName {
1595 return AccessibilityObject.Name;
1599 AccessibilityObject.Name=value;
1603 [DefaultValue(AccessibleRole.Default)]
1604 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1605 public AccessibleRole AccessibleRole {
1607 return AccessibilityObject.role;
1611 AccessibilityObject.role=value;
1615 [DefaultValue(false)]
1616 [MWFCategory("Behavior")]
1617 public virtual bool AllowDrop {
1623 if (allow_drop == value)
1626 if (IsHandleCreated) {
1628 XplatUI.SetAllowDrop (Handle, value);
1634 [RefreshProperties(RefreshProperties.Repaint)]
1635 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1636 [MWFCategory("Layout")]
1637 public virtual AnchorStyles Anchor {
1639 return anchor_style;
1645 if (parent != null) {
1646 parent.PerformLayout(this, "Parent");
1652 // XXX: Implement me!
1655 [RefreshProperties (RefreshProperties.All)]
1656 [Localizable (true)]
1657 [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
1659 [EditorBrowsable (EditorBrowsableState.Never)]
1660 [DefaultValue (false)]
1661 public virtual bool AutoSize {
1663 //Console.Error.WriteLine("Unimplemented: Control::get_AutoSize()");
1667 Console.Error.WriteLine("Unimplemented: Control::set_AutoSize(bool)");
1672 [AmbientValue (typeof(Size), "0, 0")]
1673 public virtual Size MaximumSize {
1675 return maximum_size;
1678 maximum_size = value;
1682 public virtual Size MinimumSize {
1684 return minimum_size;
1687 minimum_size = value;
1693 [MWFCategory("Appearance")]
1694 public virtual Color BackColor {
1696 if (background_color.IsEmpty) {
1698 Color pcolor = parent.BackColor;
1699 if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
1702 return DefaultBackColor;
1704 return background_color;
1708 if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
1709 throw new ArgumentException("Transparent background colors are not supported on this control");
1712 if (background_color != value) {
1713 background_color=value;
1714 SetChildColor(this);
1715 OnBackColorChanged(EventArgs.Empty);
1722 [DefaultValue(null)]
1723 [MWFCategory("Appearance")]
1724 public virtual Image BackgroundImage {
1726 return background_image;
1730 if (background_image!=value) {
1731 background_image=value;
1732 OnBackgroundImageChanged(EventArgs.Empty);
1740 [Localizable (true)]
1741 public virtual ImageLayout BackgroundImageLayout {
1743 return backgroundimage_layout;
1746 if (Array.IndexOf (Enum.GetValues (typeof (ImageLayout)), value) == -1)
1747 throw new InvalidEnumArgumentException ("value", (int) value, typeof(ImageLayout));
1749 if (value != backgroundimage_layout) {
1750 backgroundimage_layout = value;
1757 [EditorBrowsable(EditorBrowsableState.Advanced)]
1759 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1760 public virtual BindingContext BindingContext {
1762 if (binding_context != null)
1763 return binding_context;
1766 binding_context = Parent.BindingContext;
1767 return binding_context;
1770 if (binding_context != value) {
1771 binding_context = value;
1772 OnBindingContextChanged(EventArgs.Empty);
1777 [EditorBrowsable(EditorBrowsableState.Advanced)]
1779 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1782 return bounds.Y+bounds.Height;
1786 [EditorBrowsable(EditorBrowsableState.Advanced)]
1788 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1789 public Rectangle Bounds {
1795 SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1799 [EditorBrowsable(EditorBrowsableState.Advanced)]
1801 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1802 public bool CanFocus {
1804 if (IsHandleCreated && Visible && Enabled) {
1811 [EditorBrowsable(EditorBrowsableState.Advanced)]
1813 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1814 public bool CanSelect {
1818 if (!GetStyle(ControlStyles.Selectable)) {
1823 while (parent != null) {
1824 if (!parent.is_visible || !parent.is_enabled) {
1828 parent = parent.parent;
1834 internal virtual bool InternalCapture {
1844 [EditorBrowsable(EditorBrowsableState.Advanced)]
1846 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1847 public bool Capture {
1849 return this.is_captured;
1853 if (this.IsHandleCreated && value != is_captured) {
1856 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1858 XplatUI.UngrabWindow(this.window.Handle);
1859 is_captured = false;
1865 [DefaultValue(true)]
1866 [MWFCategory("Focus")]
1867 public bool CausesValidation {
1869 return this.causes_validation;
1873 if (this.causes_validation != value) {
1874 causes_validation = value;
1875 OnCausesValidationChanged(EventArgs.Empty);
1880 [EditorBrowsable(EditorBrowsableState.Advanced)]
1882 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1883 public Rectangle ClientRectangle {
1885 client_rect.Width = client_size.Width;
1886 client_rect.Height = client_size.Height;
1891 [EditorBrowsable(EditorBrowsableState.Advanced)]
1893 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1894 public Size ClientSize {
1897 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1898 return ((Form)this).form_parent_window.ClientSize;
1906 this.SetClientSizeCore(value.Width, value.Height);
1910 [EditorBrowsable(EditorBrowsableState.Advanced)]
1912 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1913 [DescriptionAttribute("ControlCompanyNameDescr")]
1914 public String CompanyName {
1916 return "Mono Project, Novell, Inc.";
1920 [EditorBrowsable(EditorBrowsableState.Advanced)]
1922 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1923 public bool ContainsFocus {
1925 IntPtr focused_window;
1927 focused_window = XplatUI.GetFocus();
1928 if (IsHandleCreated) {
1929 if (focused_window == Handle) {
1933 for (int i=0; i < child_controls.Count; i++) {
1934 if (child_controls[i].ContainsFocus) {
1945 [DefaultValue(null)]
1946 [MWFCategory("Behavior")]
1947 public virtual ContextMenu ContextMenu {
1949 return GetContextMenuInternal ();
1953 if (context_menu != value) {
1954 context_menu = value;
1955 OnContextMenuChanged(EventArgs.Empty);
1960 internal virtual ContextMenu GetContextMenuInternal ()
1962 return context_menu;
1966 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1967 public ControlCollection Controls {
1969 return this.child_controls;
1973 [EditorBrowsable(EditorBrowsableState.Advanced)]
1975 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1976 public bool Created {
1978 return (!is_disposed && is_created);
1982 [AmbientValue(null)]
1983 [MWFCategory("Appearance")]
1984 public virtual Cursor Cursor {
1986 if (cursor != null) {
1990 if (parent != null) {
1991 return parent.Cursor;
1994 return Cursors.Default;
1998 if (cursor != value) {
2003 if (IsHandleCreated) {
2004 pt = Cursor.Position;
2006 if (bounds.Contains(pt) || Capture) {
2007 if (GetChildAtPoint(pt) == null) {
2008 if (cursor != null) {
2009 XplatUI.SetCursor(window.Handle, cursor.handle);
2011 if (parent != null) {
2012 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
2014 XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
2021 OnCursorChanged(EventArgs.Empty);
2027 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
2028 [ParenthesizePropertyName(true)]
2029 [RefreshProperties(RefreshProperties.All)]
2030 [MWFCategory("Data")]
2031 public ControlBindingsCollection DataBindings {
2033 if (data_bindings == null)
2034 data_bindings = new ControlBindingsCollection (this);
2035 return data_bindings;
2039 [EditorBrowsable(EditorBrowsableState.Advanced)]
2041 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2042 public virtual Rectangle DisplayRectangle {
2044 return ClientRectangle;
2048 [EditorBrowsable(EditorBrowsableState.Advanced)]
2050 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2051 public bool Disposing {
2058 [RefreshProperties(RefreshProperties.Repaint)]
2059 [DefaultValue(DockStyle.None)]
2060 [MWFCategory("Layout")]
2061 public virtual DockStyle Dock {
2067 if (dock_style == value) {
2071 if (!Enum.IsDefined (typeof (DockStyle), value)) {
2072 throw new InvalidEnumArgumentException ("value", (int) value,
2073 typeof (DockStyle));
2078 if (dock_style == DockStyle.None) {
2079 if (explicit_bounds == Rectangle.Empty)
2080 Bounds = new Rectangle (new Point (0, 0), DefaultSize);
2082 Bounds = explicit_bounds;
2085 if (parent != null) {
2086 parent.PerformLayout(this, "Parent");
2089 OnDockChanged(EventArgs.Empty);
2094 protected virtual bool DoubleBuffered {
2096 return (control_style & ControlStyles.DoubleBuffer) != 0;
2100 SetStyle (ControlStyles.DoubleBuffer, value);
2107 [MWFCategory("Behavior")]
2108 public bool Enabled {
2114 if (parent != null) {
2115 return parent.Enabled;
2123 bool old_value = is_enabled;
2126 if (old_value != value && !value && this.has_focus)
2127 SelectNextControl(this, true, true, true, true);
2129 OnEnabledChanged (EventArgs.Empty);
2133 [EditorBrowsable(EditorBrowsableState.Advanced)]
2135 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2136 public virtual bool Focused {
2138 return this.has_focus;
2143 [AmbientValue(null)]
2145 [MWFCategory("Appearance")]
2146 public virtual Font Font {
2152 if (Parent != null && Parent.Font != null) {
2159 [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
2161 if (font != null && font.Equals (value)) {
2167 OnFontChanged (EventArgs.Empty);
2172 [MWFCategory("Appearance")]
2173 public virtual Color ForeColor {
2175 if (foreground_color.IsEmpty) {
2177 return parent.ForeColor;
2179 return DefaultForeColor;
2181 return foreground_color;
2185 if (foreground_color != value) {
2186 foreground_color=value;
2188 OnForeColorChanged(EventArgs.Empty);
2195 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2196 public IntPtr Handle { // IWin32Window
2199 if (verify_thread_handle) {
2200 if (this.InvokeRequired) {
2201 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2205 if (!IsHandleCreated) {
2208 return window.Handle;
2212 [EditorBrowsable(EditorBrowsableState.Advanced)]
2214 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2215 public bool HasChildren {
2217 if (this.child_controls.Count>0) {
2224 [EditorBrowsable(EditorBrowsableState.Always)]
2226 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2229 return this.bounds.Height;
2233 SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
2237 [AmbientValue(ImeMode.Inherit)]
2239 [MWFCategory("Behavior")]
2240 public ImeMode ImeMode {
2242 if (ime_mode == ImeMode.Inherit) {
2244 return parent.ImeMode;
2246 return ImeMode.NoControl; // default value
2252 if (ime_mode != value) {
2255 OnImeModeChanged(EventArgs.Empty);
2260 [EditorBrowsable(EditorBrowsableState.Advanced)]
2262 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2263 public bool InvokeRequired { // ISynchronizeInvoke
2265 if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
2272 [EditorBrowsable(EditorBrowsableState.Advanced)]
2274 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2275 public bool IsAccessible {
2277 return is_accessible;
2281 is_accessible = value;
2285 [EditorBrowsable(EditorBrowsableState.Advanced)]
2287 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2288 public bool IsDisposed {
2290 return this.is_disposed;
2294 [EditorBrowsable(EditorBrowsableState.Advanced)]
2296 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2297 public bool IsHandleCreated {
2299 if ((window != null) && (window.Handle != IntPtr.Zero)) {
2300 Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
2301 if (hwnd != null && !hwnd.zombie)
2311 [EditorBrowsable (EditorBrowsableState.Advanced)]
2312 public virtual Layout.LayoutEngine LayoutEngine {
2313 get { return new Layout.DefaultLayout (); }
2317 [EditorBrowsable(EditorBrowsableState.Always)]
2319 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2322 return this.bounds.X;
2326 SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
2331 [MWFCategory("Layout")]
2332 public Point Location {
2334 return new Point(bounds.X, bounds.Y);
2338 SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
2343 [Localizable (true)]
2344 public Padding Margin {
2345 get { return this.margin; }
2346 set { this.margin = value; }
2351 public string Name {
2363 public Padding Padding {
2370 OnPaddingChanged (EventArgs.Empty);
2376 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2377 public Control Parent {
2383 if (value == this) {
2384 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2387 if (parent!=value) {
2389 parent.Controls.Remove(this);
2394 value.Controls.Add(this);
2399 [EditorBrowsable(EditorBrowsableState.Advanced)]
2401 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2402 public string ProductName {
2404 Type t = typeof (AssemblyProductAttribute);
2405 Assembly assembly = GetType().Module.Assembly;
2406 object [] attrs = assembly.GetCustomAttributes (t, false);
2407 AssemblyProductAttribute a = null;
2408 // On MS we get a NullRefException if product attribute is not
2410 if (attrs != null && attrs.Length > 0)
2411 a = (AssemblyProductAttribute) attrs [0];
2416 [EditorBrowsable(EditorBrowsableState.Advanced)]
2418 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2419 public string ProductVersion {
2421 Type t = typeof (AssemblyVersionAttribute);
2422 Assembly assembly = GetType().Module.Assembly;
2423 object [] attrs = assembly.GetCustomAttributes (t, false);
2424 if (attrs == null || attrs.Length < 1)
2426 return ((AssemblyVersionAttribute)attrs [0]).Version;
2430 [EditorBrowsable(EditorBrowsableState.Advanced)]
2432 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2433 public bool RecreatingHandle {
2435 return is_recreating;
2439 [EditorBrowsable(EditorBrowsableState.Advanced)]
2441 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2442 public Region Region {
2448 if (value != null && IsHandleCreated) {
2449 XplatUI.SetClipRegion(Handle, value);
2451 clip_region = value;
2455 [EditorBrowsable(EditorBrowsableState.Advanced)]
2457 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2460 return this.bounds.X+this.bounds.Width;
2464 [AmbientValue(RightToLeft.Inherit)]
2466 [MWFCategory("Appearance")]
2467 public virtual RightToLeft RightToLeft {
2469 if (right_to_left == RightToLeft.Inherit) {
2471 return parent.RightToLeft;
2473 return RightToLeft.No; // default value
2475 return right_to_left;
2479 if (value != right_to_left) {
2480 right_to_left = value;
2481 OnRightToLeftChanged(EventArgs.Empty);
2486 [EditorBrowsable(EditorBrowsableState.Advanced)]
2487 public override ISite Site {
2495 if (value != null) {
2496 AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
2498 BackColor = ap.BackColor;
2499 ForeColor = ap.ForeColor;
2508 [MWFCategory("Layout")]
2511 return new Size(Width, Height);
2515 SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
2520 [MergableProperty(false)]
2521 [MWFCategory("Behavior")]
2522 public int TabIndex {
2524 if (tab_index != -1) {
2531 if (tab_index != value) {
2533 OnTabIndexChanged(EventArgs.Empty);
2539 [DefaultValue(true)]
2540 [MWFCategory("Behavior")]
2541 public bool TabStop {
2547 if (tab_stop != value) {
2549 OnTabStopChanged(EventArgs.Empty);
2554 [Localizable(false)]
2556 [TypeConverter(typeof(StringConverter))]
2557 [DefaultValue(null)]
2558 [MWFCategory("Data")]
2565 control_tag = value;
2571 [BindableAttribute(true)]
2572 [MWFCategory("Appearance")]
2573 public virtual string Text {
2575 // Our implementation ignores ControlStyles.CacheText - we always cache
2580 if (value == null) {
2581 value = String.Empty;
2586 if (IsHandleCreated) {
2587 /* we need to call .SetWindowStyle here instead of just .Text
2588 because the presence/absence of Text (== "" or not) can cause
2589 other window style things to appear/disappear */
2590 XplatUI.SetWindowStyle(window.Handle, CreateParams);
2591 XplatUI.Text(Handle, text);
2593 OnTextChanged (EventArgs.Empty);
2598 [EditorBrowsable(EditorBrowsableState.Always)]
2600 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2603 return this.bounds.Y;
2607 SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
2611 [EditorBrowsable(EditorBrowsableState.Advanced)]
2613 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2614 public Control TopLevelControl {
2618 while (p.parent != null) {
2622 return p is Form ? p : null;
2627 [MWFCategory("Behavior")]
2628 public bool Visible {
2632 } else if (parent != null) {
2633 return parent.Visible;
2640 SetVisibleCore(value);
2644 [EditorBrowsable(EditorBrowsableState.Always)]
2646 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2649 return this.bounds.Width;
2653 SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
2657 [EditorBrowsable(EditorBrowsableState.Never)]
2659 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2660 public IWindowTarget WindowTarget {
2669 #endregion // Public Instance Properties
2671 #region Protected Instance Properties
2672 protected virtual CreateParams CreateParams {
2674 CreateParams create_params = new CreateParams();
2677 create_params.Caption = Text;
2680 create_params.Caption = text;
2684 create_params.X = Left;
2687 create_params.X = this.bounds.X;
2691 create_params.Y = Top;
2694 create_params.Y = this.bounds.Y;
2698 create_params.Width = Width;
2701 create_params.Width = this.bounds.Width;
2705 create_params.Height = Height;
2708 create_params.Height = this.bounds.Height;
2712 create_params.ClassName = XplatUI.DefaultClassName;
2713 create_params.ClassStyle = 0;
2714 create_params.ExStyle = 0;
2715 create_params.Param = 0;
2718 create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
2721 if ((parent!=null) && (parent.IsHandleCreated)) {
2722 create_params.Parent = parent.Handle;
2725 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
2728 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
2732 create_params.Style |= (int)WindowStyles.WS_DISABLED;
2735 switch (border_style) {
2736 case BorderStyle.FixedSingle:
2737 create_params.Style |= (int) WindowStyles.WS_BORDER;
2739 case BorderStyle.Fixed3D:
2740 create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
2744 return create_params;
2748 protected virtual ImeMode DefaultImeMode {
2750 return ImeMode.Inherit;
2755 protected virtual Padding DefaultMargin {
2756 get { return new Padding (3); }
2760 protected virtual Size DefaultSize {
2762 return new Size(0, 0);
2766 protected int FontHeight {
2778 protected bool RenderRightToLeft {
2780 return (this.right_to_left == RightToLeft.Yes);
2784 protected bool ResizeRedraw {
2786 return GetStyle(ControlStyles.ResizeRedraw);
2790 SetStyle(ControlStyles.ResizeRedraw, value);
2794 [EditorBrowsable(EditorBrowsableState.Advanced)]
2796 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2797 protected virtual bool ShowFocusCues {
2803 [EditorBrowsable(EditorBrowsableState.Advanced)]
2805 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
2806 protected bool ShowKeyboardCues {
2811 #endregion // Protected Instance Properties
2813 #region Public Static Methods
2814 [EditorBrowsable(EditorBrowsableState.Advanced)]
2815 public static Control FromChildHandle(IntPtr handle) {
2816 return Control.ControlNativeWindow.ControlFromChildHandle (handle);
2819 [EditorBrowsable(EditorBrowsableState.Advanced)]
2820 public static Control FromHandle(IntPtr handle) {
2821 return Control.ControlNativeWindow.ControlFromHandle(handle);
2824 public static bool IsMnemonic(char charCode, string text) {
2827 amp = text.IndexOf('&');
2830 if (amp + 1 < text.Length) {
2831 if (text[amp + 1] != '&') {
2832 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2842 #region Protected Static Methods
2843 [EditorBrowsable(EditorBrowsableState.Advanced)]
2844 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2847 c = Control.FromHandle(hWnd);
2857 #region Public Instance Methods
2858 [EditorBrowsable(EditorBrowsableState.Advanced)]
2859 public IAsyncResult BeginInvoke(Delegate method) {
2860 object [] prms = null;
2861 if (method is EventHandler)
2862 prms = new object [] { this, EventArgs.Empty };
2863 return BeginInvokeInternal(method, prms, false);
2866 [EditorBrowsable(EditorBrowsableState.Advanced)]
2867 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2868 return BeginInvokeInternal (method, args, false);
2871 public void BringToFront() {
2872 if (parent != null) {
2873 parent.child_controls.SetChildIndex(this, 0);
2876 XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
2880 public bool Contains(Control ctl) {
2881 while (ctl != null) {
2890 public void CreateControl() {
2892 throw new ObjectDisposedException(GetType().FullName.ToString());
2898 if (!IsHandleCreated) {
2906 Control [] controls = child_controls.GetAllControls ();
2907 for (int i=0; i<controls.Length; i++) {
2908 controls [i].CreateControl ();
2911 UpdateChildrenZOrder();
2913 if (binding_context == null) { // seem to be sent whenever it's null?
2914 OnBindingContextChanged(EventArgs.Empty);
2920 public Graphics CreateGraphics() {
2921 if (!IsHandleCreated) {
2922 this.CreateHandle();
2924 return Graphics.FromHwnd(this.window.Handle);
2927 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2928 return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
2931 [EditorBrowsable(EditorBrowsableState.Advanced)]
2932 public object EndInvoke (IAsyncResult async_result) {
2933 AsyncMethodResult result = (AsyncMethodResult) async_result;
2934 return result.EndInvoke ();
2937 public Form FindForm() {
2950 [EditorBrowsable (EditorBrowsableState.Advanced)]
2952 public bool Focus() {
2953 if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
2956 is_focusing = false;
2961 public Control GetChildAtPoint(Point pt) {
2962 // Microsoft's version of this function doesn't seem to work, so I can't check
2963 // if we only consider children or also grandchildren, etc.
2964 // I'm gonna say 'children only'
2965 for (int i=0; i<child_controls.Count; i++) {
2966 if (child_controls[i].Bounds.Contains(pt)) {
2967 return child_controls[i];
2973 public IContainerControl GetContainerControl() {
2974 Control current = this;
2976 while (current!=null) {
2977 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2978 return (IContainerControl)current;
2980 current = current.parent;
2985 public Control GetNextControl(Control ctl, bool forward) {
2987 if (!this.Contains(ctl)) {
2992 ctl = FindControlForward(this, ctl);
2995 ctl = FindControlBackward(this, ctl);
3005 [EditorBrowsable (EditorBrowsableState.Advanced)]
3006 public virtual Size GetPreferredSize (Size proposedSize) {
3007 return preferred_size;
3011 public void Hide() {
3012 this.Visible = false;
3015 public void Invalidate() {
3016 Invalidate(ClientRectangle, false);
3019 public void Invalidate(bool invalidateChildren) {
3020 Invalidate(ClientRectangle, invalidateChildren);
3023 public void Invalidate(System.Drawing.Rectangle rc) {
3024 Invalidate(rc, false);
3027 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
3028 if (!IsHandleCreated || !Visible || rc.Width == 0 || rc.Height == 0) {
3032 NotifyInvalidate(rc);
3034 XplatUI.Invalidate(Handle, rc, false);
3036 if (invalidateChildren) {
3037 Control [] controls = child_controls.GetAllControls ();
3038 for (int i=0; i<controls.Length; i++)
3039 controls [i].Invalidate ();
3041 OnInvalidated(new InvalidateEventArgs(rc));
3044 public void Invalidate(System.Drawing.Region region) {
3045 Invalidate(region, false);
3048 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
3049 RectangleF bounds = region.GetBounds (CreateGraphics ());
3050 Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
3051 invalidateChildren);
3054 public object Invoke (Delegate method) {
3055 object [] prms = null;
3056 if (method is EventHandler)
3057 prms = new object [] { this, EventArgs.Empty };
3059 return Invoke(method, prms);
3062 public object Invoke (Delegate method, object[] args) {
3063 if (!this.InvokeRequired) {
3064 return method.DynamicInvoke(args);
3067 IAsyncResult result = BeginInvoke (method, args);
3068 return EndInvoke(result);
3071 internal object InvokeInternal (Delegate method, bool disposing) {
3072 return InvokeInternal(method, null, disposing);
3075 internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
3076 if (!this.InvokeRequired) {
3077 return method.DynamicInvoke(args);
3080 IAsyncResult result = BeginInvokeInternal (method, args, disposing);
3081 return EndInvoke(result);
3084 [EditorBrowsable(EditorBrowsableState.Advanced)]
3085 public void PerformLayout() {
3086 PerformLayout(null, null);
3090 private void SetImplicitBounds (int x, int y, int width, int height)
3092 Rectangle saved_bounds = explicit_bounds;
3093 SetBounds (x, y, width, height);
3094 explicit_bounds = saved_bounds;
3098 [EditorBrowsable(EditorBrowsableState.Advanced)]
3099 public void PerformLayout(Control affectedControl, string affectedProperty) {
3100 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
3102 if (layout_suspended > 0) {
3103 layout_pending = true;
3107 layout_pending = false;
3109 // Prevent us from getting messed up
3112 // Perform all Dock and Anchor calculations
3116 this.layout_engine.Layout(this, levent);
3118 // This has been moved to Layout/DefaultLayout.cs for 2.0, please duplicate any changes/fixes there.
3120 AnchorStyles anchor;
3123 space = DisplayRectangle;
3125 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
3126 Control [] controls = child_controls.GetAllControls ();
3127 for (int i = controls.Length - 1; i >= 0; i--) {
3128 child = controls [i];
3130 if (!child.Visible) {
3134 switch (child.Dock) {
3135 case DockStyle.None: {
3140 case DockStyle.Left: {
3141 child.SetImplicitBounds(space.Left, space.Y, child.Width, space.Height);
3142 space.X+=child.Width;
3143 space.Width-=child.Width;
3147 case DockStyle.Top: {
3148 child.SetImplicitBounds(space.Left, space.Y, space.Width, child.Height);
3149 space.Y+=child.Height;
3150 space.Height-=child.Height;
3154 case DockStyle.Right: {
3155 child.SetImplicitBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
3156 space.Width-=child.Width;
3160 case DockStyle.Bottom: {
3161 child.SetImplicitBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
3162 space.Height-=child.Height;
3168 for (int i = controls.Length - 1; i >= 0; i--) {
3171 //if (child.Visible && (child.Dock == DockStyle.Fill)) {
3172 if (child.Dock == DockStyle.Fill) {
3173 child.SetImplicitBounds(space.Left, space.Top, space.Width, space.Height);
3177 space = DisplayRectangle;
3179 for (int i=0; i < controls.Length; i++) {
3185 child = controls[i];
3187 // If the control is docked we don't need to do anything
3188 if (child.Dock != DockStyle.None) {
3192 anchor = child.Anchor;
3196 width = child.Width;
3197 height = child.Height;
3199 if ((anchor & AnchorStyles.Left) !=0 ) {
3200 if ((anchor & AnchorStyles.Right) != 0) {
3201 width = space.Width - child.dist_right - left;
3203 ; // Left anchored only, nothing to be done
3205 } else if ((anchor & AnchorStyles.Right) != 0) {
3206 left = space.Width - child.dist_right - width;
3208 // left+=diff_width/2 will introduce rounding errors (diff_width removed from svn after r51780)
3209 // This calculates from scratch every time:
3210 left = child.dist_left + (space.Width - (child.dist_left + width + child.dist_right)) / 2;
3213 if ((anchor & AnchorStyles.Top) !=0 ) {
3214 if ((anchor & AnchorStyles.Bottom) != 0) {
3215 height = space.Height - child.dist_bottom - top;
3217 ; // Top anchored only, nothing to be done
3219 } else if ((anchor & AnchorStyles.Bottom) != 0) {
3220 top = space.Height - child.dist_bottom - height;
3222 // top += diff_height/2 will introduce rounding errors (diff_height removed from after r51780)
3223 // This calculates from scratch every time:
3224 top = child.dist_top + (space.Height - (child.dist_top + height + child.dist_bottom)) / 2;
3236 child.SetImplicitBounds(left, top, width, height);
3240 // Let everyone know
3244 // Need to make sure we decremend layout_suspended
3250 public Point PointToClient (Point p) {
3254 XplatUI.ScreenToClient (Handle, ref x, ref y);
3256 return new Point (x, y);
3259 public Point PointToScreen(Point p) {
3263 XplatUI.ClientToScreen(Handle, ref x, ref y);
3265 return new Point(x, y);
3268 public virtual bool PreProcessMessage(ref Message msg) {
3269 return InternalPreProcessMessage (ref msg);
3272 internal virtual bool InternalPreProcessMessage (ref Message msg) {
3275 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
3276 key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
3278 if (!ProcessCmdKey(ref msg, key_data)) {
3279 if (IsInputKey(key_data)) {
3283 return ProcessDialogKey(key_data);
3287 } else if (msg.Msg == (int)Msg.WM_CHAR) {
3288 if (IsInputChar((char)msg.WParam)) {
3291 return ProcessDialogChar((char)msg.WParam);
3292 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
3293 return ProcessDialogChar((char)msg.WParam);
3298 public Rectangle RectangleToClient(Rectangle r) {
3299 return new Rectangle(PointToClient(r.Location), r.Size);
3302 public Rectangle RectangleToScreen(Rectangle r) {
3303 return new Rectangle(PointToScreen(r.Location), r.Size);
3306 public virtual void Refresh() {
3307 if (IsHandleCreated == true) {
3309 XplatUI.UpdateWindow(window.Handle);
3311 Control [] controls = child_controls.GetAllControls ();
3312 for (int i=0; i < controls.Length; i++) {
3313 controls[i].Refresh();
3319 [EditorBrowsable(EditorBrowsableState.Never)]
3320 public virtual void ResetBackColor() {
3321 BackColor = Color.Empty;
3324 [EditorBrowsable(EditorBrowsableState.Never)]
3325 public void ResetBindings() {
3326 data_bindings.Clear();
3329 [EditorBrowsable(EditorBrowsableState.Never)]
3330 public virtual void ResetCursor() {
3334 [EditorBrowsable(EditorBrowsableState.Never)]
3335 public virtual void ResetFont() {
3339 [EditorBrowsable(EditorBrowsableState.Never)]
3340 public virtual void ResetForeColor() {
3341 foreground_color = Color.Empty;
3344 [EditorBrowsable(EditorBrowsableState.Never)]
3345 public void ResetImeMode() {
3346 ime_mode = DefaultImeMode;
3349 [EditorBrowsable(EditorBrowsableState.Never)]
3350 public virtual void ResetRightToLeft() {
3351 right_to_left = RightToLeft.Inherit;
3354 public virtual void ResetText() {
3355 text = String.Empty;
3358 public void ResumeLayout() {
3359 ResumeLayout (true);
3362 public void ResumeLayout(bool performLayout) {
3363 if (layout_suspended > 0) {
3367 if (layout_suspended == 0) {
3368 Control [] controls = child_controls.GetAllControls ();
3369 for (int i=0; i<controls.Length; i++) {
3370 controls [i].UpdateDistances ();
3373 if (performLayout && layout_pending) {
3379 [EditorBrowsable (EditorBrowsableState.Never)]
3382 public void Scale(float ratio) {
3383 ScaleCore(ratio, ratio);
3387 [EditorBrowsable (EditorBrowsableState.Never)]
3390 public void Scale(float dx, float dy) {
3395 [EditorBrowsable (EditorBrowsableState.Advanced)]
3396 public void Scale(SizeF factor) {
3397 ScaleCore(factor.Width, factor.Height);
3401 public void Select() {
3402 Select(false, false);
3406 private void printTree(Control c, string t) {
3407 foreach(Control i in c.child_controls) {
3408 Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
3409 printTree(i, t+"\t");
3413 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
3417 Console.WriteLine("{0}", this.FindForm());
3418 printTree(this, "\t");
3421 if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
3426 c = GetNextControl(c, forward);
3435 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
3436 c.Select (true, true);
3439 } while (c != ctl); // If we wrap back to ourselves we stop
3444 public void SendToBack() {
3445 if (parent != null) {
3446 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
3450 public void SetBounds(int x, int y, int width, int height) {
3451 SetBounds(x, y, width, height, BoundsSpecified.All);
3454 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
3455 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
3459 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
3463 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
3467 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
3471 SetBoundsCore(x, y, width, height, specified);
3472 if (parent != null) {
3473 parent.PerformLayout(this, "Bounds");
3477 public void Show() {
3479 this.CreateControl();
3485 public void SuspendLayout() {
3489 public void Update() {
3490 if (IsHandleCreated) {
3491 XplatUI.UpdateWindow(window.Handle);
3494 #endregion // Public Instance Methods
3496 #region Protected Instance Methods
3497 [EditorBrowsable(EditorBrowsableState.Advanced)]
3498 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
3499 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
3500 throw new NotImplementedException();
3503 [EditorBrowsable(EditorBrowsableState.Advanced)]
3504 protected virtual AccessibleObject CreateAccessibilityInstance() {
3505 return new Control.ControlAccessibleObject(this);
3508 [EditorBrowsable(EditorBrowsableState.Advanced)]
3509 protected virtual ControlCollection CreateControlsInstance() {
3510 return new ControlCollection(this);
3513 [EditorBrowsable(EditorBrowsableState.Advanced)]
3514 protected virtual void CreateHandle() {
3516 throw new ObjectDisposedException(GetType().FullName.ToString());
3519 if (IsHandleCreated && !is_recreating) {
3523 window.CreateHandle(CreateParams);
3525 if (window.Handle != IntPtr.Zero) {
3526 creator_thread = Thread.CurrentThread;
3528 XplatUI.EnableWindow(window.Handle, is_enabled);
3529 XplatUI.SetVisible(window.Handle, is_visible, true);
3531 if (clip_region != null) {
3532 XplatUI.SetClipRegion(Handle, clip_region);
3535 // Set our handle with our parent
3536 if ((parent != null) && (parent.IsHandleCreated)) {
3537 XplatUI.SetParent(window.Handle, parent.Handle);
3540 // Set our handle as parent for our children
3541 Control [] children;
3543 children = child_controls.GetAllControls ();
3544 for (int i = 0; i < children.Length; i++ ) {
3545 if (!children[i].RecreatingHandle)
3546 XplatUI.SetParent(children[i].Handle, window.Handle);
3550 XplatUI.SetAllowDrop (Handle, allow_drop);
3552 // Find out where the window manager placed us
3553 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
3554 XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
3558 OnHandleCreated(EventArgs.Empty);
3562 [EditorBrowsable(EditorBrowsableState.Advanced)]
3563 protected virtual void DefWndProc(ref Message m) {
3564 window.DefWndProc(ref m);
3567 [EditorBrowsable(EditorBrowsableState.Advanced)]
3568 protected virtual void DestroyHandle() {
3569 if (IsHandleCreated) {
3570 if (window != null) {
3571 window.DestroyHandle();
3576 protected internal bool GetStyle(ControlStyles flag) {
3577 return (control_style & flag) != 0;
3580 protected bool GetTopLevel() {
3584 [EditorBrowsable(EditorBrowsableState.Advanced)]
3585 protected virtual void InitLayout() {
3589 [EditorBrowsable(EditorBrowsableState.Advanced)]
3590 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
3591 toInvoke.OnGotFocus(e);
3594 [EditorBrowsable(EditorBrowsableState.Advanced)]
3595 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
3596 toInvoke.OnLostFocus(e);
3599 [EditorBrowsable(EditorBrowsableState.Advanced)]
3600 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
3601 toInvoke.OnClick(e);
3604 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
3605 toInvoke.OnPaint(e);
3608 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
3609 toInvoke.OnPaintBackground(e);
3612 protected virtual bool IsInputChar (char charCode) {
3616 protected virtual bool IsInputKey (Keys keyData) {
3617 // Doc says this one calls IsInputChar; not sure what to do with that
3621 [EditorBrowsable(EditorBrowsableState.Advanced)]
3622 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
3626 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
3627 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
3631 if (parent != null) {
3632 return parent.ProcessCmdKey(ref msg, keyData);
3638 protected virtual bool ProcessDialogChar(char charCode) {
3639 if (parent != null) {
3640 return parent.ProcessDialogChar (charCode);
3646 protected virtual bool ProcessDialogKey (Keys keyData) {
3647 if (parent != null) {
3648 return parent.ProcessDialogKey (keyData);
3654 protected virtual bool ProcessKeyEventArgs (ref Message msg)
3656 KeyEventArgs key_event;
3659 case (int)Msg.WM_SYSKEYDOWN:
3660 case (int)Msg.WM_KEYDOWN: {
3661 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3662 OnKeyDown (key_event);
3663 return key_event.Handled;
3666 case (int)Msg.WM_SYSKEYUP:
3667 case (int)Msg.WM_KEYUP: {
3668 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
3669 OnKeyUp (key_event);
3670 return key_event.Handled;
3673 case (int)Msg.WM_SYSCHAR:
3674 case (int)Msg.WM_CHAR: {
3675 KeyPressEventArgs key_press_event;
3677 key_press_event = new KeyPressEventArgs((char)msg.WParam);
3678 OnKeyPress(key_press_event);
3680 msg.WParam = (IntPtr)key_press_event.KeyChar;
3682 return key_press_event.Handled;
3693 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
3694 if (parent != null) {
3695 if (parent.ProcessKeyPreview(ref msg)) {
3700 return ProcessKeyEventArgs(ref msg);
3703 protected virtual bool ProcessKeyPreview(ref Message msg) {
3704 if (parent != null) {
3705 return parent.ProcessKeyPreview(ref msg);
3711 protected virtual bool ProcessMnemonic(char charCode) {
3716 [EditorBrowsable(EditorBrowsableState.Advanced)]
3717 protected void RaiseDragEvent(object key, DragEventArgs e) {
3721 [EditorBrowsable(EditorBrowsableState.Advanced)]
3722 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
3726 [EditorBrowsable(EditorBrowsableState.Advanced)]
3727 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
3731 [EditorBrowsable(EditorBrowsableState.Advanced)]
3732 protected void RaisePaintEvent(object key, PaintEventArgs e) {
3736 private void SetIsRecreating ()
3740 foreach (Control c in Controls.GetAllControls()) {
3741 c.SetIsRecreating ();
3745 [EditorBrowsable(EditorBrowsableState.Advanced)]
3746 protected void RecreateHandle() {
3748 Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
3753 if (IsHandleCreated) {
3755 Console.WriteLine(" + handle is created, destroying it.");
3758 // WM_DESTROY will CreateHandle for us
3761 Console.WriteLine(" + handle is not created, creating it.");
3769 is_recreating = false;
3771 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
3777 [EditorBrowsable(EditorBrowsableState.Advanced)]
3778 protected void ResetMouseEventArgs() {
3782 [EditorBrowsable(EditorBrowsableState.Advanced)]
3783 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
3784 if (right_to_left == RightToLeft.No) {
3789 case ContentAlignment.TopLeft: {
3790 return ContentAlignment.TopRight;
3793 case ContentAlignment.TopRight: {
3794 return ContentAlignment.TopLeft;
3797 case ContentAlignment.MiddleLeft: {
3798 return ContentAlignment.MiddleRight;
3801 case ContentAlignment.MiddleRight: {
3802 return ContentAlignment.MiddleLeft;
3805 case ContentAlignment.BottomLeft: {
3806 return ContentAlignment.BottomRight;
3809 case ContentAlignment.BottomRight: {
3810 return ContentAlignment.BottomLeft;
3814 // if it's center it doesn't change
3820 [EditorBrowsable(EditorBrowsableState.Advanced)]
3821 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
3822 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
3826 if (align == HorizontalAlignment.Left) {
3827 return HorizontalAlignment.Right;
3830 // align must be HorizontalAlignment.Right
3831 return HorizontalAlignment.Left;
3834 [EditorBrowsable(EditorBrowsableState.Advanced)]
3835 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
3836 if (right_to_left == RightToLeft.No) {
3840 if (align == LeftRightAlignment.Left) {
3841 return LeftRightAlignment.Right;
3844 // align must be LeftRightAlignment.Right;
3845 return LeftRightAlignment.Left;
3848 [EditorBrowsable(EditorBrowsableState.Advanced)]
3849 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
3850 return RtlTranslateAlignment(align);
3853 [EditorBrowsable(EditorBrowsableState.Advanced)]
3854 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
3855 return RtlTranslateAlignment(align);
3858 [EditorBrowsable(EditorBrowsableState.Advanced)]
3859 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
3860 return RtlTranslateAlignment(align);
3863 [EditorBrowsable(EditorBrowsableState.Advanced)]
3864 protected virtual void ScaleCore(float dx, float dy) {
3870 location = new Point((int)(Left * dx), (int)(Top * dy));
3871 size = this.ClientSize;
3873 if (!GetStyle(ControlStyles.FixedWidth)) {
3874 size.Width = (int)(size.Width * dx);
3877 if (!GetStyle(ControlStyles.FixedHeight)) {
3878 size.Height = (int)(size.Height * dy);
3881 SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
3883 /* Now scale our children */
3884 Control [] controls = child_controls.GetAllControls ();
3885 for (int i=0; i < controls.Length; i++) {
3886 controls[i].Scale(dx, dy);
3892 protected virtual void Select(bool directed, bool forward) {
3893 IContainerControl container;
3895 container = GetContainerControl();
3896 if (container != null)
3897 container.ActiveControl = this;
3900 [EditorBrowsable(EditorBrowsableState.Advanced)]
3901 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
3902 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
3903 if (IsHandleCreated) {
3904 XplatUI.SetWindowPos(Handle, x, y, width, height);
3906 // Win32 automatically changes negative width/height to 0.
3907 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
3908 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
3910 if (width < 0 || height < 0) {
3912 XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
3916 UpdateBounds(x, y, width, height);
3921 [EditorBrowsable(EditorBrowsableState.Advanced)]
3922 protected virtual void SetClientSizeCore(int x, int y) {
3923 // Calculate the actual window size from the client size (it usually stays the same or grows)
3924 Rectangle ClientRect;
3925 Rectangle WindowRect;
3928 ClientRect = new Rectangle(0, 0, x, y);
3929 cp = this.CreateParams;
3931 if (XplatUI.CalculateWindowRect(ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect)==false) {
3935 SetBounds(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
3938 [EditorBrowsable(EditorBrowsableState.Advanced)]
3939 protected internal void SetStyle(ControlStyles flag, bool value) {
3941 control_style |= flag;
3943 control_style &= ~flag;
3947 protected void SetTopLevel(bool value) {
3948 if ((GetTopLevel() != value) && (parent != null)) {
3949 throw new Exception();
3953 if (value == true) {
3963 is_toplevel = value;
3966 protected virtual void SetVisibleCore(bool value) {
3967 if (value!=is_visible) {
3968 if (value && (window.Handle == IntPtr.Zero) || !is_created) {
3974 if (IsHandleCreated) {
3975 XplatUI.SetVisible(Handle, value, true);
3976 // Explicitly move Toplevel windows to where we want them;
3977 // apparently moving unmapped toplevel windows doesn't work
3978 if (is_visible && (this is Form)) {
3979 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
3983 OnVisibleChanged(EventArgs.Empty);
3985 if (value == false && parent != null && Focused) {
3988 // Need to start at parent, GetContainerControl might return ourselves if we're a container
3989 container = (Control)parent.GetContainerControl();
3990 if (container != null) {
3991 container.SelectNextControl(this, true, true, true, true);
3995 if (parent != null) {
3996 parent.PerformLayout(this, "visible");
3998 PerformLayout(this, "visible");
4003 [EditorBrowsable(EditorBrowsableState.Advanced)]
4004 protected void UpdateBounds() {
4012 if (!IsHandleCreated) {
4016 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
4018 UpdateBounds(x, y, width, height, client_width, client_height);
4021 [EditorBrowsable(EditorBrowsableState.Advanced)]
4022 protected void UpdateBounds(int x, int y, int width, int height) {
4026 // Calculate client rectangle
4027 rect = new Rectangle(0, 0, 0, 0);
4030 XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
4031 UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
4034 [EditorBrowsable(EditorBrowsableState.Advanced)]
4035 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
4036 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
4038 bool resized = false;
4040 // Needed to generate required notifications
4041 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
4045 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
4052 bounds.Height=height;
4054 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
4055 explicit_bounds = bounds;
4057 client_size.Width=clientWidth;
4058 client_size.Height=clientHeight;
4061 OnLocationChanged(EventArgs.Empty);
4065 OnSizeChanged(EventArgs.Empty);
4069 [EditorBrowsable(EditorBrowsableState.Advanced)]
4070 protected void UpdateStyles() {
4071 if (!IsHandleCreated) {
4075 XplatUI.SetWindowStyle(window.Handle, CreateParams);
4076 OnStyleChanged(EventArgs.Empty);
4079 private void UpdateZOrderOfChild(Control child) {
4080 if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
4083 index = child_controls.IndexOf(child);
4086 XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
4088 IntPtr after = AfterTopMostControl ();
4089 if (after != IntPtr.Zero)
4090 XplatUI.SetZOrder (child.Handle, after, false, false);
4092 XplatUI.SetZOrder (child.Handle, IntPtr.Zero, true, false);
4097 // Override this if there is a control that shall always remain on
4098 // top of other controls (such as scrollbars). If there are several
4099 // of these controls, the bottom-most should be returned.
4100 internal virtual IntPtr AfterTopMostControl ()
4105 private void UpdateChildrenZOrder() {
4106 Control [] controls;
4108 if (!IsHandleCreated) {
4112 controls = child_controls.GetAllControls ();
4113 for (int i = 1; i < controls.Length; i++ ) {
4114 XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
4118 [EditorBrowsable(EditorBrowsableState.Advanced)]
4119 protected void UpdateZOrder() {
4120 if (parent != null) {
4121 parent.UpdateZOrderOfChild(this);
4125 protected virtual void WndProc(ref Message m) {
4127 Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
4129 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
4133 switch((Msg)m.Msg) {
4134 case Msg.WM_DESTROY: {
4135 OnHandleDestroyed(EventArgs.Empty);
4137 IntPtr handle = window.Handle;
4139 window.InvalidateHandle();
4141 if (is_recreating) {
4143 Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
4147 Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
4149 is_recreating = false;
4154 case Msg.WM_WINDOWPOSCHANGED: {
4156 Rectangle save_bounds = explicit_bounds;
4158 explicit_bounds = save_bounds;
4159 if (GetStyle(ControlStyles.ResizeRedraw)) {
4166 // Nice description of what should happen when handling WM_PAINT
4167 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4168 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4169 case Msg.WM_PAINT: {
4170 PaintEventArgs paint_event;
4172 paint_event = XplatUI.PaintEventStart(Handle, true);
4174 if (paint_event == null) {
4178 if (invalid_region != null && !invalid_region.IsVisible (paint_event.ClipRectangle)) {
4180 // Just blit the previous image
4181 XplatUI.BlitFromOffscreen (Handle, paint_event.Graphics, backbuffer, backbuffer_dc, paint_event.ClipRectangle);
4182 XplatUI.PaintEventEnd (Handle, true);
4187 Graphics back_dc = null;
4189 if (ThemeEngine.Current.DoubleBufferingSupported) {
4190 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4191 CreateBackBuffer ();
4193 back_dc = backbuffer_dc;
4194 dc = paint_event.SetGraphics (back_dc);
4198 if (!GetStyle(ControlStyles.Opaque)) {
4199 OnPaintBackground(paint_event);
4202 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4203 OnPaintBackgroundInternal(paint_event);
4205 OnPaintInternal(paint_event);
4206 if (!paint_event.Handled) {
4207 OnPaint(paint_event);
4210 if (ThemeEngine.Current.DoubleBufferingSupported)
4211 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4212 XplatUI.BlitFromOffscreen (Handle, dc, back, back_dc, paint_event.ClipRectangle);
4213 paint_event.SetGraphics (dc);
4214 invalid_region.Exclude (paint_event.ClipRectangle);
4216 if (back != backbuffer)
4217 XplatUI.DestroyOffscreenDrawable (back, back_dc);
4220 XplatUI.PaintEventEnd(Handle, true);
4225 case Msg.WM_ERASEBKGND: {
4226 // The DefWndProc will never have to handle this, we always paint the background in managed code
4227 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4228 // here but it just makes things more complicated...
4229 m.Result = (IntPtr)1;
4233 case Msg.WM_LBUTTONUP: {
4236 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
4238 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4241 HandleClick(mouse_clicks, me);
4244 if (InternalCapture) {
4245 InternalCapture = false;
4248 if (mouse_clicks > 1) {
4254 case Msg.WM_LBUTTONDOWN: {
4256 Select (true, true);
4258 InternalCapture = true;
4259 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4260 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4266 case Msg.WM_LBUTTONDBLCLK: {
4267 InternalCapture = true;
4269 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4270 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4275 case Msg.WM_MBUTTONUP: {
4278 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
4280 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4283 HandleClick(mouse_clicks, me);
4285 if (InternalCapture) {
4286 InternalCapture = false;
4288 if (mouse_clicks > 1) {
4294 case Msg.WM_MBUTTONDOWN: {
4295 InternalCapture = true;
4296 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4297 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4302 case Msg.WM_MBUTTONDBLCLK: {
4303 InternalCapture = true;
4305 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4306 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4311 case Msg.WM_RBUTTONUP: {
4315 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4316 pt = PointToScreen(pt);
4318 XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
4320 me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
4322 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4325 HandleClick(mouse_clicks, me);
4328 if (InternalCapture) {
4329 InternalCapture = false;
4332 if (mouse_clicks > 1) {
4338 case Msg.WM_RBUTTONDOWN: {
4339 InternalCapture = true;
4340 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4341 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4346 case Msg.WM_RBUTTONDBLCLK: {
4347 InternalCapture = true;
4349 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4350 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4355 case Msg.WM_CONTEXTMENU: {
4356 if (context_menu != null) {
4359 pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
4360 context_menu.Show(this, PointToClient(pt));
4368 case Msg.WM_MOUSEWHEEL: {
4370 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4371 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4372 HighOrder(m.WParam.ToInt32())));
4377 case Msg.WM_MOUSEMOVE: {
4378 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
4380 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
4385 case Msg.WM_MOUSE_ENTER: {
4390 OnMouseEnter(EventArgs.Empty);
4394 case Msg.WM_MOUSE_LEAVE: {
4396 OnMouseLeave(EventArgs.Empty);
4400 case Msg.WM_MOUSEHOVER: {
4401 OnMouseHover(EventArgs.Empty);
4405 case Msg.WM_SYSKEYUP: {
4406 if (ProcessKeyMessage(ref m)) {
4407 m.Result = IntPtr.Zero;
4411 if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
4415 if (form != null && form.ActiveMenu != null) {
4416 form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
4424 case Msg.WM_SYSKEYDOWN:
4425 case Msg.WM_KEYDOWN:
4427 case Msg.WM_SYSCHAR:
4429 if (ProcessKeyMessage(ref m)) {
4430 m.Result = IntPtr.Zero;
4439 if (m.LParam != IntPtr.Zero) {
4442 hi = new HELPINFO();
4444 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
4445 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
4447 mouse_pos = Control.MousePosition;
4449 OnHelpRequested(new HelpEventArgs(mouse_pos));
4450 m.Result = (IntPtr)1;
4454 case Msg.WM_KILLFOCUS: {
4455 this.has_focus = false;
4456 OnLostFocusInternal (EventArgs.Empty);
4460 case Msg.WM_SETFOCUS: {
4462 this.has_focus = true;
4463 OnGotFocusInternal (EventArgs.Empty);
4468 case Msg.WM_SYSCOLORCHANGE: {
4469 ThemeEngine.Current.ResetDefaults();
4470 OnSystemColorsChanged(EventArgs.Empty);
4474 case Msg.WM_SETCURSOR: {
4475 if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
4480 XplatUI.SetCursor(window.Handle, cursor.handle);
4481 m.Result = (IntPtr)1;
4491 #endregion // Public Instance Methods
4493 #region OnXXX methods
4494 [EditorBrowsable(EditorBrowsableState.Advanced)]
4495 protected virtual void OnBackColorChanged(EventArgs e) {
4496 EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
4499 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
4502 [EditorBrowsable(EditorBrowsableState.Advanced)]
4503 protected virtual void OnBackgroundImageChanged(EventArgs e) {
4504 EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
4507 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
4510 [EditorBrowsable(EditorBrowsableState.Advanced)]
4511 protected virtual void OnBindingContextChanged(EventArgs e) {
4512 CheckDataBindings ();
4513 EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
4516 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
4519 [EditorBrowsable(EditorBrowsableState.Advanced)]
4520 protected virtual void OnCausesValidationChanged(EventArgs e) {
4521 EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
4526 [EditorBrowsable(EditorBrowsableState.Advanced)]
4527 protected virtual void OnChangeUICues(UICuesEventArgs e) {
4528 UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
4533 [EditorBrowsable(EditorBrowsableState.Advanced)]
4534 protected virtual void OnClick(EventArgs e) {
4535 EventHandler eh = (EventHandler)(Events [ClickEvent]);
4540 [EditorBrowsable(EditorBrowsableState.Advanced)]
4541 protected virtual void OnContextMenuChanged(EventArgs e) {
4542 EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
4547 [EditorBrowsable(EditorBrowsableState.Advanced)]
4548 protected virtual void OnControlAdded(ControlEventArgs e) {
4549 ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
4554 [EditorBrowsable(EditorBrowsableState.Advanced)]
4555 protected virtual void OnControlRemoved(ControlEventArgs e) {
4556 ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
4561 [EditorBrowsable(EditorBrowsableState.Advanced)]
4562 protected virtual void OnCreateControl() {
4566 [EditorBrowsable(EditorBrowsableState.Advanced)]
4567 protected virtual void OnCursorChanged(EventArgs e) {
4568 EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
4573 [EditorBrowsable(EditorBrowsableState.Advanced)]
4574 protected virtual void OnDockChanged(EventArgs e) {
4575 EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
4580 [EditorBrowsable(EditorBrowsableState.Advanced)]
4581 protected virtual void OnDoubleClick(EventArgs e) {
4582 EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
4587 [EditorBrowsable(EditorBrowsableState.Advanced)]
4588 protected virtual void OnDragDrop(DragEventArgs drgevent) {
4589 DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
4591 eh (this, drgevent);
4594 [EditorBrowsable(EditorBrowsableState.Advanced)]
4595 protected virtual void OnDragEnter(DragEventArgs drgevent) {
4596 DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
4598 eh (this, drgevent);
4601 [EditorBrowsable(EditorBrowsableState.Advanced)]
4602 protected virtual void OnDragLeave(EventArgs e) {
4603 EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
4608 [EditorBrowsable(EditorBrowsableState.Advanced)]
4609 protected virtual void OnDragOver(DragEventArgs drgevent) {
4610 DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
4612 eh (this, drgevent);
4615 [EditorBrowsable(EditorBrowsableState.Advanced)]
4616 protected virtual void OnEnabledChanged(EventArgs e) {
4617 if (IsHandleCreated) {
4619 if (((Form)this).context == null) {
4620 XplatUI.EnableWindow(window.Handle, Enabled);
4623 XplatUI.EnableWindow(window.Handle, Enabled);
4628 EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
4632 for (int i=0; i<child_controls.Count; i++) {
4633 child_controls[i].OnParentEnabledChanged(e);
4637 [EditorBrowsable(EditorBrowsableState.Advanced)]
4638 protected virtual void OnEnter(EventArgs e) {
4639 EventHandler eh = (EventHandler)(Events [EnterEvent]);
4644 [EditorBrowsable(EditorBrowsableState.Advanced)]
4645 protected virtual void OnFontChanged(EventArgs e) {
4646 EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
4649 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
4652 [EditorBrowsable(EditorBrowsableState.Advanced)]
4653 protected virtual void OnForeColorChanged(EventArgs e) {
4654 EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
4657 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
4660 [EditorBrowsable(EditorBrowsableState.Advanced)]
4661 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
4662 GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
4664 eh (this, gfbevent);
4667 [EditorBrowsable(EditorBrowsableState.Advanced)]
4668 protected virtual void OnGotFocus(EventArgs e) {
4669 EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
4674 [EditorBrowsable(EditorBrowsableState.Advanced)]
4675 protected virtual void OnHandleCreated(EventArgs e) {
4676 EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
4681 [EditorBrowsable(EditorBrowsableState.Advanced)]
4682 protected virtual void OnHandleDestroyed(EventArgs e) {
4683 EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
4688 [EditorBrowsable(EditorBrowsableState.Advanced)]
4689 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
4690 HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
4695 protected virtual void OnImeModeChanged(EventArgs e) {
4696 EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
4701 [EditorBrowsable(EditorBrowsableState.Advanced)]
4702 protected virtual void OnInvalidated(InvalidateEventArgs e) {
4703 if (ThemeEngine.Current.DoubleBufferingSupported)
4704 if ((control_style & ControlStyles.DoubleBuffer) != 0) {
4705 // should this block be here? seems like it
4706 // would be more at home in
4707 // NotifyInvalidated..
4708 if (e.InvalidRect == ClientRectangle) {
4709 InvalidateBackBuffer ();
4712 // we need this Inflate call here so
4713 // that the border of the rectangle is
4714 // considered Visible (the
4715 // invalid_region.IsVisible call) in
4716 // the WM_PAINT handling below.
4717 Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
4718 if (invalid_region == null)
4719 invalid_region = new Region (r);
4721 invalid_region.Union (r);
4725 InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
4730 [EditorBrowsable(EditorBrowsableState.Advanced)]
4731 protected virtual void OnKeyDown(KeyEventArgs e) {
4732 KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
4737 [EditorBrowsable(EditorBrowsableState.Advanced)]
4738 protected virtual void OnKeyPress(KeyPressEventArgs e) {
4739 KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
4744 [EditorBrowsable(EditorBrowsableState.Advanced)]
4745 protected virtual void OnKeyUp(KeyEventArgs e) {
4746 KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
4751 [EditorBrowsable(EditorBrowsableState.Advanced)]
4752 protected virtual void OnLayout(LayoutEventArgs levent) {
4753 LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
4758 [EditorBrowsable(EditorBrowsableState.Advanced)]
4759 protected virtual void OnLeave(EventArgs e) {
4760 EventHandler eh = (EventHandler)(Events [LeaveEvent]);
4765 [EditorBrowsable(EditorBrowsableState.Advanced)]
4766 protected virtual void OnLocationChanged(EventArgs e) {
4768 EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
4773 [EditorBrowsable(EditorBrowsableState.Advanced)]
4774 protected virtual void OnLostFocus(EventArgs e) {
4775 EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
4780 [EditorBrowsable(EditorBrowsableState.Advanced)]
4781 protected virtual void OnMouseDown(MouseEventArgs e) {
4782 MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
4787 [EditorBrowsable(EditorBrowsableState.Advanced)]
4788 protected virtual void OnMouseEnter(EventArgs e) {
4789 EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
4794 [EditorBrowsable(EditorBrowsableState.Advanced)]
4795 protected virtual void OnMouseHover(EventArgs e) {
4796 EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
4801 [EditorBrowsable(EditorBrowsableState.Advanced)]
4802 protected virtual void OnMouseLeave(EventArgs e) {
4803 EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
4808 [EditorBrowsable(EditorBrowsableState.Advanced)]
4809 protected virtual void OnMouseMove(MouseEventArgs e) {
4810 MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
4815 [EditorBrowsable(EditorBrowsableState.Advanced)]
4816 protected virtual void OnMouseUp(MouseEventArgs e) {
4817 MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
4822 [EditorBrowsable(EditorBrowsableState.Advanced)]
4823 protected virtual void OnMouseWheel(MouseEventArgs e) {
4824 MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
4829 [EditorBrowsable(EditorBrowsableState.Advanced)]
4830 protected virtual void OnMove(EventArgs e) {
4831 EventHandler eh = (EventHandler)(Events [MoveEvent]);
4836 [EditorBrowsable(EditorBrowsableState.Advanced)]
4837 protected virtual void OnNotifyMessage(Message m) {
4842 protected virtual void OnPaddingChanged (EventArgs e) {
4843 EventHandler eh = (EventHandler) (Events [PaddingChangedEvent]);
4849 [EditorBrowsable(EditorBrowsableState.Advanced)]
4850 protected virtual void OnPaint(PaintEventArgs e) {
4851 PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
4856 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
4860 internal virtual void OnPaintInternal(PaintEventArgs e) {
4864 internal virtual void OnGotFocusInternal (EventArgs e)
4869 internal virtual void OnLostFocusInternal (EventArgs e)
4874 [EditorBrowsable(EditorBrowsableState.Advanced)]
4875 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
4876 PaintControlBackground (pevent);
4879 [EditorBrowsable(EditorBrowsableState.Advanced)]
4880 protected virtual void OnParentBackColorChanged(EventArgs e) {
4881 if (background_color.IsEmpty && background_image==null) {
4883 OnBackColorChanged(e);
4887 [EditorBrowsable(EditorBrowsableState.Advanced)]
4888 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
4889 if (background_color.IsEmpty && background_image==null) {
4891 OnBackgroundImageChanged(e);
4895 [EditorBrowsable(EditorBrowsableState.Advanced)]
4896 protected virtual void OnParentBindingContextChanged(EventArgs e) {
4897 if (binding_context==null) {
4898 binding_context=Parent.binding_context;
4899 OnBindingContextChanged(e);
4903 [EditorBrowsable(EditorBrowsableState.Advanced)]
4904 protected virtual void OnParentChanged(EventArgs e) {
4905 EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
4910 [EditorBrowsable(EditorBrowsableState.Advanced)]
4911 protected virtual void OnParentEnabledChanged(EventArgs e) {
4913 OnEnabledChanged(e);
4917 [EditorBrowsable(EditorBrowsableState.Advanced)]
4918 protected virtual void OnParentFontChanged(EventArgs e) {
4925 [EditorBrowsable(EditorBrowsableState.Advanced)]
4926 protected virtual void OnParentForeColorChanged(EventArgs e) {
4927 if (foreground_color.IsEmpty) {
4929 OnForeColorChanged(e);
4933 [EditorBrowsable(EditorBrowsableState.Advanced)]
4934 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
4935 if (right_to_left==RightToLeft.Inherit) {
4937 OnRightToLeftChanged(e);
4941 [EditorBrowsable(EditorBrowsableState.Advanced)]
4942 protected virtual void OnParentVisibleChanged(EventArgs e) {
4944 OnVisibleChanged(e);
4948 [EditorBrowsable(EditorBrowsableState.Advanced)]
4949 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
4950 QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
4955 [EditorBrowsable(EditorBrowsableState.Advanced)]
4956 protected virtual void OnResize(EventArgs e) {
4957 EventHandler eh = (EventHandler)(Events [ResizeEvent]);
4961 PerformLayout(this, "bounds");
4963 if (parent != null) {
4964 parent.PerformLayout();
4968 [EditorBrowsable(EditorBrowsableState.Advanced)]
4969 protected virtual void OnRightToLeftChanged(EventArgs e) {
4970 EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
4973 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
4976 [EditorBrowsable(EditorBrowsableState.Advanced)]
4977 protected virtual void OnSizeChanged(EventArgs e) {
4978 DisposeBackBuffer ();
4980 EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
4985 [EditorBrowsable(EditorBrowsableState.Advanced)]
4986 protected virtual void OnStyleChanged(EventArgs e) {
4987 EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
4992 [EditorBrowsable(EditorBrowsableState.Advanced)]
4993 protected virtual void OnSystemColorsChanged(EventArgs e) {
4994 EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
4999 [EditorBrowsable(EditorBrowsableState.Advanced)]
5000 protected virtual void OnTabIndexChanged(EventArgs e) {
5001 EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
5006 [EditorBrowsable(EditorBrowsableState.Advanced)]
5007 protected virtual void OnTabStopChanged(EventArgs e) {
5008 EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
5013 [EditorBrowsable(EditorBrowsableState.Advanced)]
5014 protected virtual void OnTextChanged(EventArgs e) {
5015 EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
5020 [EditorBrowsable(EditorBrowsableState.Advanced)]
5021 protected virtual void OnValidated(EventArgs e) {
5022 EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
5027 [EditorBrowsable(EditorBrowsableState.Advanced)]
5028 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
5029 CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
5034 [EditorBrowsable(EditorBrowsableState.Advanced)]
5035 protected virtual void OnVisibleChanged(EventArgs e) {
5036 if ((parent != null) && !Created && Visible) {
5043 EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
5047 // We need to tell our kids
5048 for (int i=0; i<child_controls.Count; i++) {
5049 if (child_controls[i].Visible) {
5050 child_controls[i].OnParentVisibleChanged(e);
5054 #endregion // OnXXX methods
5057 static object BackColorChangedEvent = new object ();
5058 static object BackgroundImageChangedEvent = new object ();
5060 static object BackgroundImageLayoutChangedEvent = new object ();
5062 static object BindingContextChangedEvent = new object ();
5063 static object CausesValidationChangedEvent = new object ();
5064 static object ChangeUICuesEvent = new object ();
5065 static object ClickEvent = new object ();
5066 static object ContextMenuChangedEvent = new object ();
5067 static object ControlAddedEvent = new object ();
5068 static object ControlRemovedEvent = new object ();
5069 static object CursorChangedEvent = new object ();
5070 static object DockChangedEvent = new object ();
5071 static object DoubleClickEvent = new object ();
5072 static object DragDropEvent = new object ();
5073 static object DragEnterEvent = new object ();
5074 static object DragLeaveEvent = new object ();
5075 static object DragOverEvent = new object ();
5076 static object EnabledChangedEvent = new object ();
5077 static object EnterEvent = new object ();
5078 static object FontChangedEvent = new object ();
5079 static object ForeColorChangedEvent = new object ();
5080 static object GiveFeedbackEvent = new object ();
5081 static object GotFocusEvent = new object ();
5082 static object HandleCreatedEvent = new object ();
5083 static object HandleDestroyedEvent = new object ();
5084 static object HelpRequestedEvent = new object ();
5085 static object ImeModeChangedEvent = new object ();
5086 static object InvalidatedEvent = new object ();
5087 static object KeyDownEvent = new object ();
5088 static object KeyPressEvent = new object ();
5089 static object KeyUpEvent = new object ();
5090 static object LayoutEvent = new object ();
5091 static object LeaveEvent = new object ();
5092 static object LocationChangedEvent = new object ();
5093 static object LostFocusEvent = new object ();
5095 static object MouseClickEvent = new object ();
5096 static object MouseDoubleClickEvent = new object ();
5098 static object MouseDownEvent = new object ();
5099 static object MouseEnterEvent = new object ();
5100 static object MouseHoverEvent = new object ();
5101 static object MouseLeaveEvent = new object ();
5102 static object MouseMoveEvent = new object ();
5103 static object MouseUpEvent = new object ();
5104 static object MouseWheelEvent = new object ();
5105 static object MoveEvent = new object ();
5107 static object PaddingChangedEvent = new object ();
5109 static object PaintEvent = new object ();
5110 static object ParentChangedEvent = new object ();
5111 static object QueryAccessibilityHelpEvent = new object ();
5112 static object QueryContinueDragEvent = new object ();
5113 static object ResizeEvent = new object ();
5114 static object RightToLeftChangedEvent = new object ();
5115 static object SizeChangedEvent = new object ();
5116 static object StyleChangedEvent = new object ();
5117 static object SystemColorsChangedEvent = new object ();
5118 static object TabIndexChangedEvent = new object ();
5119 static object TabStopChangedEvent = new object ();
5120 static object TextChangedEvent = new object ();
5121 static object ValidatedEvent = new object ();
5122 static object ValidatingEvent = new object ();
5123 static object VisibleChangedEvent = new object ();
5125 public event EventHandler BackColorChanged {
5126 add { Events.AddHandler (BackColorChangedEvent, value); }
5127 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
5130 public event EventHandler BackgroundImageChanged {
5131 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
5132 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
5136 public event EventHandler BackgroundImageLayoutChanged {
5137 add {Events.AddHandler (BackgroundImageLayoutChangedEvent, value);}
5138 remove {Events.RemoveHandler (BackgroundImageLayoutChangedEvent, value);}
5142 public event EventHandler BindingContextChanged {
5143 add { Events.AddHandler (BindingContextChangedEvent, value); }
5144 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
5147 public event EventHandler CausesValidationChanged {
5148 add { Events.AddHandler (CausesValidationChangedEvent, value); }
5149 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
5152 public event UICuesEventHandler ChangeUICues {
5153 add { Events.AddHandler (ChangeUICuesEvent, value); }
5154 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
5157 public event EventHandler Click {
5158 add { Events.AddHandler (ClickEvent, value); }
5159 remove { Events.RemoveHandler (ClickEvent, value); }
5164 public event EventHandler ContextMenuChanged {
5165 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5166 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5169 [EditorBrowsable(EditorBrowsableState.Advanced)]
5175 public event ControlEventHandler ControlAdded {
5176 add { Events.AddHandler (ControlAddedEvent, value); }
5177 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5180 [EditorBrowsable(EditorBrowsableState.Advanced)]
5186 public event ControlEventHandler ControlRemoved {
5187 add { Events.AddHandler (ControlRemovedEvent, value); }
5188 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5191 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5192 public event EventHandler CursorChanged {
5193 add { Events.AddHandler (CursorChangedEvent, value); }
5194 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5196 public event EventHandler DockChanged {
5197 add { Events.AddHandler (DockChangedEvent, value); }
5198 remove { Events.RemoveHandler (DockChangedEvent, value); }
5201 public event EventHandler DoubleClick {
5202 add { Events.AddHandler (DoubleClickEvent, value); }
5203 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5206 public event DragEventHandler DragDrop {
5207 add { Events.AddHandler (DragDropEvent, value); }
5208 remove { Events.RemoveHandler (DragDropEvent, value); }
5211 public event DragEventHandler DragEnter {
5212 add { Events.AddHandler (DragEnterEvent, value); }
5213 remove { Events.RemoveHandler (DragEnterEvent, value); }
5216 public event EventHandler DragLeave {
5217 add { Events.AddHandler (DragLeaveEvent, value); }
5218 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5221 public event DragEventHandler DragOver {
5222 add { Events.AddHandler (DragOverEvent, value); }
5223 remove { Events.RemoveHandler (DragOverEvent, value); }
5226 public event EventHandler EnabledChanged {
5227 add { Events.AddHandler (EnabledChangedEvent, value); }
5228 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5231 public event EventHandler Enter {
5232 add { Events.AddHandler (EnterEvent, value); }
5233 remove { Events.RemoveHandler (EnterEvent, value); }
5236 public event EventHandler FontChanged {
5237 add { Events.AddHandler (FontChangedEvent, value); }
5238 remove { Events.RemoveHandler (FontChangedEvent, value); }
5241 public event EventHandler ForeColorChanged {
5242 add { Events.AddHandler (ForeColorChangedEvent, value); }
5243 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5246 public event GiveFeedbackEventHandler GiveFeedback {
5247 add { Events.AddHandler (GiveFeedbackEvent, value); }
5248 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5251 [EditorBrowsable(EditorBrowsableState.Advanced)]
5253 public event EventHandler GotFocus {
5254 add { Events.AddHandler (GotFocusEvent, value); }
5255 remove { Events.RemoveHandler (GotFocusEvent, value); }
5259 [EditorBrowsable(EditorBrowsableState.Advanced)]
5261 public event EventHandler HandleCreated {
5262 add { Events.AddHandler (HandleCreatedEvent, value); }
5263 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5266 [EditorBrowsable(EditorBrowsableState.Advanced)]
5268 public event EventHandler HandleDestroyed {
5269 add { Events.AddHandler (HandleDestroyedEvent, value); }
5270 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5273 public event HelpEventHandler HelpRequested {
5274 add { Events.AddHandler (HelpRequestedEvent, value); }
5275 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5278 public event EventHandler ImeModeChanged {
5279 add { Events.AddHandler (ImeModeChangedEvent, value); }
5280 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5283 [EditorBrowsable(EditorBrowsableState.Advanced)]
5285 public event InvalidateEventHandler Invalidated {
5286 add { Events.AddHandler (InvalidatedEvent, value); }
5287 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5290 public event KeyEventHandler KeyDown {
5291 add { Events.AddHandler (KeyDownEvent, value); }
5292 remove { Events.RemoveHandler (KeyDownEvent, value); }
5295 public event KeyPressEventHandler KeyPress {
5296 add { Events.AddHandler (KeyPressEvent, value); }
5297 remove { Events.RemoveHandler (KeyPressEvent, value); }
5300 public event KeyEventHandler KeyUp {
5301 add { Events.AddHandler (KeyUpEvent, value); }
5302 remove { Events.RemoveHandler (KeyUpEvent, value); }
5305 public event LayoutEventHandler Layout {
5306 add { Events.AddHandler (LayoutEvent, value); }
5307 remove { Events.RemoveHandler (LayoutEvent, value); }
5310 public event EventHandler Leave {
5311 add { Events.AddHandler (LeaveEvent, value); }
5312 remove { Events.RemoveHandler (LeaveEvent, value); }
5315 public event EventHandler LocationChanged {
5316 add { Events.AddHandler (LocationChangedEvent, value); }
5317 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5320 [EditorBrowsable(EditorBrowsableState.Advanced)]
5322 public event EventHandler LostFocus {
5323 add { Events.AddHandler (LostFocusEvent, value); }
5324 remove { Events.RemoveHandler (LostFocusEvent, value); }
5328 public event MouseEventHandler MouseClick
5330 add { Events.AddHandler (MouseClickEvent, value); }
5331 remove { Events.RemoveHandler (MouseClickEvent, value); }
5333 public event MouseEventHandler MouseDoubleClick
5335 add { Events.AddHandler (MouseDoubleClickEvent, value); }
5336 remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
5339 public event MouseEventHandler MouseDown {
5340 add { Events.AddHandler (MouseDownEvent, value); }
5341 remove { Events.RemoveHandler (MouseDownEvent, value); }
5344 public event EventHandler MouseEnter {
5345 add { Events.AddHandler (MouseEnterEvent, value); }
5346 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5349 public event EventHandler MouseHover {
5350 add { Events.AddHandler (MouseHoverEvent, value); }
5351 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5354 public event EventHandler MouseLeave {
5355 add { Events.AddHandler (MouseLeaveEvent, value); }
5356 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5359 public event MouseEventHandler MouseMove {
5360 add { Events.AddHandler (MouseMoveEvent, value); }
5361 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5364 public event MouseEventHandler MouseUp {
5365 add { Events.AddHandler (MouseUpEvent, value); }
5366 remove { Events.RemoveHandler (MouseUpEvent, value); }
5369 [EditorBrowsable(EditorBrowsableState.Advanced)]
5371 public event MouseEventHandler MouseWheel {
5372 add { Events.AddHandler (MouseWheelEvent, value); }
5373 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5376 public event EventHandler Move {
5377 add { Events.AddHandler (MoveEvent, value); }
5378 remove { Events.RemoveHandler (MoveEvent, value); }
5381 public event EventHandler PaddingChanged
5383 add { Events.AddHandler (PaddingChangedEvent, value); }
5384 remove { Events.RemoveHandler (PaddingChangedEvent, value); }
5387 public event PaintEventHandler Paint {
5388 add { Events.AddHandler (PaintEvent, value); }
5389 remove { Events.RemoveHandler (PaintEvent, value); }
5392 public event EventHandler ParentChanged {
5393 add { Events.AddHandler (ParentChangedEvent, value); }
5394 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5397 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
5398 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5399 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5402 public event QueryContinueDragEventHandler QueryContinueDrag {
5403 add { Events.AddHandler (QueryContinueDragEvent, value); }
5404 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5408 [EditorBrowsable (EditorBrowsableState.Advanced)]
5410 public event EventHandler Resize {
5411 add { Events.AddHandler (ResizeEvent, value); }
5412 remove { Events.RemoveHandler (ResizeEvent, value); }
5415 public event EventHandler RightToLeftChanged {
5416 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5417 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
5420 public event EventHandler SizeChanged {
5421 add { Events.AddHandler (SizeChangedEvent, value); }
5422 remove { Events.RemoveHandler (SizeChangedEvent, value); }
5425 public event EventHandler StyleChanged {
5426 add { Events.AddHandler (StyleChangedEvent, value); }
5427 remove { Events.RemoveHandler (StyleChangedEvent, value); }
5430 public event EventHandler SystemColorsChanged {
5431 add { Events.AddHandler (SystemColorsChangedEvent, value); }
5432 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
5435 public event EventHandler TabIndexChanged {
5436 add { Events.AddHandler (TabIndexChangedEvent, value); }
5437 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
5440 public event EventHandler TabStopChanged {
5441 add { Events.AddHandler (TabStopChangedEvent, value); }
5442 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
5445 public event EventHandler TextChanged {
5446 add { Events.AddHandler (TextChangedEvent, value); }
5447 remove { Events.RemoveHandler (TextChangedEvent, value); }
5450 public event EventHandler Validated {
5451 add { Events.AddHandler (ValidatedEvent, value); }
5452 remove { Events.RemoveHandler (ValidatedEvent, value); }
5455 public event CancelEventHandler Validating {
5456 add { Events.AddHandler (ValidatingEvent, value); }
5457 remove { Events.RemoveHandler (ValidatingEvent, value); }
5460 public event EventHandler VisibleChanged {
5461 add { Events.AddHandler (VisibleChangedEvent, value); }
5462 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
5465 #endregion // Events