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
37 using System
.ComponentModel
;
38 using System
.ComponentModel
.Design
;
39 using System
.ComponentModel
.Design
.Serialization
;
40 using System
.Collections
;
41 using System
.Diagnostics
;
43 using System
.Drawing
.Drawing2D
;
44 using System
.Reflection
;
45 using System
.Runtime
.InteropServices
;
46 using System
.Security
;
47 using System
.Threading
;
49 namespace System
.Windows
.Forms
53 [ClassInterface (ClassInterfaceType
.AutoDispatch
)]
55 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts
.AssemblySystem_Design
, "System.ComponentModel.Design.IDesigner")]
56 [DefaultProperty("Text")]
57 [DefaultEvent("Click")]
58 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts
.AssemblySystem_Design
, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts
.AssemblySystem_Design
)]
59 [ToolboxItemFilter("System.Windows.Forms")]
60 public class Control
: Component
, ISynchronizeInvoke
, IWin32Window
62 , IBindableComponent
, IDropTarget
65 #region Local Variables
68 internal Rectangle bounds
; // bounding rectangle for control (client area + decorations)
69 Rectangle explicit_bounds
; // explicitly set bounds
70 internal object creator_thread
; // thread that created the control
71 internal ControlNativeWindow window
; // object for native window handle
72 string name
; // for object naming
75 bool is_created
; // true if OnCreateControl has been sent
76 internal bool has_focus
; // true if control has focus
77 internal bool is_visible
; // true if control is visible
78 internal bool is_entered
; // is the mouse inside the control?
79 internal bool is_enabled
; // true if control is enabled (usable/not grayed out)
80 bool is_accessible
; // true if the control is visible to accessibility applications
81 bool is_captured
; // tracks if the control has captured the mouse
82 internal bool is_toplevel
; // tracks if the control is a toplevel window
83 bool is_recreating
; // tracks if the handle for the control is being recreated
84 bool causes_validation
; // tracks if validation is executed on changes
85 bool is_focusing
; // tracks if Focus has been called on the control and has not yet finished
86 int tab_index
; // position in tab order of siblings
87 bool tab_stop
; // is the control a tab stop?
88 bool is_disposed
; // has the window already been disposed?
89 Size client_size
; // size of the client area (window excluding decorations)
90 Rectangle client_rect
; // rectangle with the client area (window excluding decorations)
91 ControlStyles control_style
; // rather win32-specific, style bits for control
93 object control_tag
; // object that contains data about our control
94 internal int mouse_clicks
; // Counter for mouse clicks
95 Cursor cursor
; // Cursor for the window
96 internal bool allow_drop
; // true if the control accepts droping objects on it
97 Region clip_region
; // User-specified clip region for the window
100 internal Color foreground_color
; // foreground color for control
101 internal Color background_color
; // background color for control
102 Image background_image
; // background image for control
103 internal Font font
; // font for control
104 string text
; // window/title text for control
105 internal BorderStyle border_style
; // Border style of control
108 internal enum LayoutType
{
112 Layout
.LayoutEngine layout_engine
;
113 int layout_suspended
;
114 bool layout_pending
; // true if our parent needs to re-layout us
115 internal AnchorStyles anchor_style
; // anchoring requirements for our control
116 internal DockStyle dock_style
; // docking requirements for our control
117 LayoutType layout_type
;
119 // Please leave the next 2 as internal until DefaultLayout (2.0) is rewritten
120 internal int dist_right
; // distance to the right border of the parent
121 internal int dist_bottom
; // distance to the bottom border of the parent
123 // to be categorized...
124 ControlCollection child_controls
; // our children
125 Control parent
; // our parent control
126 AccessibleObject accessibility_object
; // object that contains accessibility information about our control
127 BindingContext binding_context
;
128 RightToLeft right_to_left
; // drawing direction for control
129 ContextMenu context_menu
; // Context menu associated with the control
130 internal bool use_compatible_text_rendering
;
133 DoubleBuffer backbuffer
;
135 // to implement DeviceContext without depending on double buffering
139 ControlBindingsCollection data_bindings
;
142 static bool verify_thread_handle
;
144 ImageLayout backgroundimage_layout
;
148 private ContextMenuStrip context_menu_strip
;
151 #endregion // Local Variables
153 #region Private Classes
154 // This helper class allows us to dispatch messages to Control.WndProc
155 internal class ControlNativeWindow
: NativeWindow
{
156 private Control owner
;
158 public ControlNativeWindow(Control control
) : base() {
163 public Control Owner
{
169 static internal Control
ControlFromHandle(IntPtr hWnd
) {
170 ControlNativeWindow window
;
172 window
= (ControlNativeWindow
)window_collection
[hWnd
];
173 if (window
!= null) {
180 static internal Control
ControlFromChildHandle (IntPtr handle
) {
181 ControlNativeWindow window
;
183 Hwnd hwnd
= Hwnd
.ObjectFromHandle (handle
);
184 while (hwnd
!= null) {
185 window
= (ControlNativeWindow
)window_collection
[hwnd
.Handle
];
186 if (window
!= null) {
195 protected override void WndProc(ref Message m
) {
196 owner
.WndProc(ref m
);
201 #region Public Classes
203 public class ControlAccessibleObject
: AccessibleObject
{
206 #region ControlAccessibleObject Constructors
207 public ControlAccessibleObject(Control ownerControl
)
208 : base (ownerControl
)
210 if (ownerControl
== null)
211 throw new ArgumentNullException ("owner");
213 handle
= ownerControl
.Handle
;
215 #endregion // ControlAccessibleObject Constructors
217 #region ControlAccessibleObject Public Instance Properties
218 public override string DefaultAction
{
220 return base.DefaultAction
;
224 public override string Description
{
226 return base.Description
;
230 public IntPtr Handle
{
236 // We don't want to let them set it
240 public override string Help
{
246 public override string KeyboardShortcut
{
248 return base.KeyboardShortcut
;
252 public override string Name
{
262 public Control Owner
{
268 public override AccessibleObject Parent
{
275 public override AccessibleRole Role
{
280 #endregion // ControlAccessibleObject Public Instance Properties
282 #region ControlAccessibleObject Public Instance Methods
283 public override int GetHelpTopic(out string FileName
) {
284 return base.GetHelpTopic (out FileName
);
287 [MonoTODO ("Implement this")]
288 public void NotifyClients(AccessibleEvents accEvent
) {
289 throw new NotImplementedException();
292 [MonoTODO ("Implement this")]
293 public void NotifyClients(AccessibleEvents accEvent
, int childID
) {
296 public override string ToString() {
297 return "ControlAccessibleObject: Owner = " + owner
.ToString() + ", Text: " + owner
.text
;
300 #endregion // ControlAccessibleObject Public Instance Methods
303 private class DoubleBuffer
: IDisposable
305 public Region InvalidRegion
;
306 private Stack real_graphics
;
307 private object back_buffer
;
308 private Control parent
;
309 private bool pending_disposal
;
311 public DoubleBuffer (Control parent
) {
312 this.parent
= parent
;
313 real_graphics
= new Stack ();
314 int width
= parent
.Width
;
315 int height
= parent
.Height
;
317 if (width
< 1) width
= 1;
318 if (height
< 1) height
= 1;
320 XplatUI
.CreateOffscreenDrawable (parent
.Handle
, width
, height
, out back_buffer
);
324 public void Blit (PaintEventArgs pe
) {
325 Graphics buffered_graphics
;
326 buffered_graphics
= XplatUI
.GetOffscreenGraphics (back_buffer
);
327 XplatUI
.BlitFromOffscreen (parent
.Handle
, pe
.Graphics
, back_buffer
, buffered_graphics
, pe
.ClipRectangle
);
328 buffered_graphics
.Dispose ();
331 public void Start (PaintEventArgs pe
) {
332 // We need to get the graphics for every paint.
333 real_graphics
.Push(pe
.SetGraphics (XplatUI
.GetOffscreenGraphics (back_buffer
)));
336 public void End (PaintEventArgs pe
) {
337 Graphics buffered_graphics
;
338 buffered_graphics
= pe
.SetGraphics ((Graphics
) real_graphics
.Pop ());
340 if (pending_disposal
)
343 XplatUI
.BlitFromOffscreen (parent
.Handle
, pe
.Graphics
, back_buffer
, buffered_graphics
, pe
.ClipRectangle
);
344 InvalidRegion
.Exclude (pe
.ClipRectangle
);
346 buffered_graphics
.Dispose ();
349 public void Invalidate () {
350 if (InvalidRegion
!= null)
351 InvalidRegion
.Dispose ();
352 InvalidRegion
= new Region (parent
.ClientRectangle
);
355 public void Dispose () {
356 if (real_graphics
.Count
> 0) {
357 pending_disposal
= true;
361 XplatUI
.DestroyOffscreenDrawable (back_buffer
);
363 if (InvalidRegion
!= null)
364 InvalidRegion
.Dispose ();
365 InvalidRegion
= null;
367 GC
.SuppressFinalize (this);
370 #region IDisposable Members
371 void IDisposable
.Dispose () {
381 [ListBindable (false)]
384 public class ControlCollection
: Layout
.ArrangedElementCollection
, IList
, ICollection
, ICloneable
, IEnumerable
{
386 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts
.AssemblySystem_Design
, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts
.AssemblySystem_Design
)]
387 public class ControlCollection
: IList
, ICollection
, ICloneable
, IEnumerable
{
389 #region ControlCollection Local Variables
394 Control
[] all_controls
;
396 #endregion // ControlCollection Local Variables
398 #region ControlCollection Public Constructor
399 public ControlCollection(Control owner
) {
402 this.list
=new ArrayList();
407 #region ControlCollection Public Instance Properties
408 int ICollection
.Count
{
409 get { return Count; }
415 get { return list.Count; }
420 bool IList
.IsReadOnly
422 public bool IsReadOnly
426 return list
.IsReadOnly
;
431 public Control Owner { get { return this.owner; }
}
433 public virtual Control
this[string key
] {
435 int index
= IndexOfKey (key
);
446 public virtual Control
this[int index
] {
448 if (index
< 0 || index
>= list
.Count
) {
449 throw new ArgumentOutOfRangeException("index", index
, "ControlCollection does not have that many controls");
451 return (Control
)list
[index
];
456 #endregion // ControlCollection Public Instance Properties
458 #region ControlCollection Instance Methods
459 public virtual void Add (Control
value) {
463 bool owner_permits_toplevels
= (owner
is MdiClient
) || (owner
is Form
&& ((Form
)owner
).IsMdiContainer
);
464 bool child_is_toplevel
= ((Control
)value).GetTopLevel();
465 bool child_is_mdichild
= (value is Form
&& ((Form
)value).IsMdiChild
);
467 if (child_is_toplevel
&& !(owner_permits_toplevels
&& child_is_mdichild
))
468 throw new ArgumentException("Cannot add a top level control to a control.", "value");
470 if (Contains (value)) {
471 owner
.PerformLayout();
475 if (value.tab_index
== -1) {
481 end
= owner
.child_controls
.Count
;
482 for (int i
= 0; i
< end
; i
++) {
483 index
= owner
.child_controls
[i
].tab_index
;
488 value.tab_index
= use
;
491 if (value.parent
!= null) {
492 value.parent
.Controls
.Remove(value);
498 value.ChangeParent(owner
);
503 owner
.UpdateChildrenZOrder();
504 owner
.PerformLayout(value, "Parent");
505 owner
.OnControlAdded(new ControlEventArgs(value));
508 internal void AddToList (Control c
) {
513 internal virtual void AddImplicit (Control control
) {
514 if (impl_list
== null)
515 impl_list
= new ArrayList ();
517 if (AllContains (control
)) {
518 owner
.PerformLayout ();
522 if (control
.parent
!= null) {
523 control
.parent
.Controls
.Remove(control
);
527 impl_list
.Add (control
);
529 control
.ChangeParent (owner
);
530 control
.InitLayout ();
532 owner
.UpdateChildrenZOrder ();
533 owner
.PerformLayout (control
, "Parent");
534 owner
.OnControlAdded (new ControlEventArgs (control
));
537 [DesignerSerializationVisibility (DesignerSerializationVisibility
.Hidden
)]
539 public virtual void AddRange (Control
[] controls
) {
540 if (controls
== null)
541 throw new ArgumentNullException ("controls");
543 owner
.SuspendLayout ();
546 for (int i
= 0; i
< controls
.Length
; i
++)
549 owner
.ResumeLayout ();
553 internal virtual void AddRangeImplicit (Control
[] controls
) {
554 if (controls
== null)
555 throw new ArgumentNullException ("controls");
557 owner
.SuspendLayout ();
560 for (int i
= 0; i
< controls
.Length
; i
++)
561 AddImplicit (controls
[i
]);
563 owner
.ResumeLayout ();
570 public virtual void Clear () {
573 // MS sends remove events in reverse order
574 while (list
.Count
> 0) {
575 Remove((Control
)list
[list
.Count
- 1]);
579 internal virtual void ClearImplicit () {
580 if (impl_list
== null)
586 public bool Contains (Control
value) {
587 for (int i
= list
.Count
; i
> 0; ) {
590 if (list
[i
] == value) {
591 // Do we need to do anything here?
598 internal bool ImplicitContains (Control
value) {
599 if (impl_list
== null)
602 for (int i
= impl_list
.Count
; i
> 0; ) {
605 if (impl_list
[i
] == value) {
606 // Do we need to do anything here?
613 internal bool AllContains (Control
value) {
614 return Contains (value) || ImplicitContains (value);
618 public virtual bool ContainsKey (string key
)
620 return IndexOfKey (key
) >= 0;
624 void ICollection
.CopyTo (Array array
, int index
) {
625 CopyTo (array
, index
);
629 public void CopyTo (Array array
, int index
) {
630 list
.CopyTo(array
, index
);
633 public override bool Equals (object other
) {
634 if (other
is ControlCollection
&& (((ControlCollection
)other
).owner
==this.owner
)) {
643 // LAMESPEC: MSDN says AE, MS implementation throws ANE
644 public Control
[] Find (string key
, bool searchAllChildren
)
646 if (string.IsNullOrEmpty (key
))
647 throw new ArgumentNullException ("key");
649 ArrayList al
= new ArrayList ();
651 foreach (Control c
in list
) {
652 if (c
.Name
.Equals (key
, StringComparison
.CurrentCultureIgnoreCase
))
655 if (searchAllChildren
)
656 al
.AddRange (c
.Controls
.Find (key
, true));
659 return (Control
[])al
.ToArray (typeof (Control
));
663 public int GetChildIndex(Control child
) {
664 return GetChildIndex(child
, false);
672 GetChildIndex(Control child
, bool throwException
) {
675 index
=list
.IndexOf(child
);
677 if (index
==-1 && throwException
) {
678 throw new ArgumentException("Not a child control", "child");
684 public override IEnumerator
689 return list
.GetEnumerator();
692 internal IEnumerator
GetAllEnumerator () {
693 Control
[] res
= GetAllControls ();
694 return res
.GetEnumerator ();
697 internal Control
[] GetAllControls () {
698 if (all_controls
!= null)
701 if (impl_list
== null) {
702 all_controls
= (Control
[]) list
.ToArray (typeof (Control
));
706 all_controls
= new Control
[list
.Count
+ impl_list
.Count
];
707 impl_list
.CopyTo (all_controls
);
708 list
.CopyTo (all_controls
, impl_list
.Count
);
714 public override int GetHashCode() {
715 return base.GetHashCode();
719 public int IndexOf(Control control
) {
720 return list
.IndexOf(control
);
724 public virtual int IndexOfKey (string key
)
726 if (string.IsNullOrEmpty (key
))
729 for (int i
= 0; i
< list
.Count
; i
++)
730 if (((Control
)list
[i
]).Name
.Equals (key
, StringComparison
.CurrentCultureIgnoreCase
))
737 public virtual void Remove(Control
value) {
741 owner
.PerformLayout(value, "Parent");
742 owner
.OnControlRemoved(new ControlEventArgs(value));
747 value.ChangeParent(null);
749 owner
.UpdateChildrenZOrder();
752 internal virtual void RemoveImplicit (Control control
) {
753 if (impl_list
!= null) {
755 owner
.PerformLayout (control
, "Parent");
756 owner
.OnControlRemoved (new ControlEventArgs (control
));
757 impl_list
.Remove (control
);
759 control
.ChangeParent (null);
760 owner
.UpdateChildrenZOrder ();
766 public void RemoveAt(int index
) {
767 if (index
< 0 || index
>= list
.Count
) {
768 throw new ArgumentOutOfRangeException("index", index
, "ControlCollection does not have that many controls");
770 Remove ((Control
)list
[index
]);
774 public virtual void RemoveByKey (string key
)
776 int index
= IndexOfKey (key
);
788 SetChildIndex(Control child
, int newIndex
) {
790 throw new ArgumentNullException ("child");
794 old_index
=list
.IndexOf(child
);
796 throw new ArgumentException("Not a child control", "child");
799 if (old_index
==newIndex
) {
804 list
.RemoveAt(old_index
);
806 if (newIndex
>list
.Count
) {
809 list
.Insert(newIndex
, child
);
811 child
.UpdateZOrder();
812 owner
.PerformLayout();
814 #endregion // ControlCollection Private Instance Methods
816 #region ControlCollection Interface Properties
817 object IList
.this[int index
] {
819 if (index
<0 || index
>=list
.Count
) {
820 throw new ArgumentOutOfRangeException("index", index
, "ControlCollection does not have that many controls");
826 if (!(value is Control
)) {
827 throw new ArgumentException("Object of type Control required", "value");
831 Control ctrl
= (Control
) value;
834 ctrl
.ChangeParent(owner
);
838 owner
.UpdateChildrenZOrder();
839 owner
.PerformLayout(ctrl
, "Parent");
843 bool IList
.IsFixedSize
{
849 bool ICollection
.IsSynchronized
{
851 return list
.IsSynchronized
;
855 object ICollection
.SyncRoot
{
857 return list
.SyncRoot
;
860 #endregion // ControlCollection Interface Properties
862 #region ControlCollection Interface Methods
863 int IList
.Add(object value) {
864 if (!(value is Control
)) {
865 throw new ArgumentException("Object of type Control required", "value");
869 throw new ArgumentException("value", "Cannot add null controls");
872 bool owner_permits_toplevels
= (owner
is MdiClient
) || (owner
is Form
&& ((Form
)owner
).IsMdiContainer
);
873 bool child_is_toplevel
= ((Control
)value).GetTopLevel();
874 bool child_is_mdichild
= (value is Form
&& ((Form
)value).IsMdiChild
);
876 if (child_is_toplevel
&& !(owner_permits_toplevels
&& child_is_mdichild
))
877 throw new ArgumentException("Cannot add a top level control to a control.", "value");
879 return list
.Add(value);
882 bool IList
.Contains(object value) {
883 if (!(value is Control
)) {
884 throw new ArgumentException("Object of type Control required", "value");
887 return this.Contains((Control
) value);
890 int IList
.IndexOf(object value) {
891 if (!(value is Control
)) {
892 throw new ArgumentException("Object of type Control required", "value");
895 return this.IndexOf((Control
) value);
898 void IList
.Insert(int index
, object value) {
899 if (!(value is Control
)) {
900 throw new ArgumentException("Object of type Control required", "value");
903 list
.Insert(index
, value);
906 void IList
.Remove(object value) {
907 if (!(value is Control
)) {
908 throw new ArgumentException("Object of type Control required", "value");
914 Object ICloneable
.Clone() {
915 ControlCollection clone
= new ControlCollection(this.owner
);
916 clone
.list
=(ArrayList
)list
.Clone(); // FIXME: Do we need this?
919 #endregion // ControlCollection Interface Methods
921 #endregion // ControlCollection Class
923 #region Public Constructors
926 layout_type
= LayoutType
.Anchor
;
927 anchor_style
= AnchorStyles
.Top
| AnchorStyles
.Left
;
935 layout_pending
= false;
937 causes_validation
= true;
939 layout_suspended
= 0;
943 right_to_left
= RightToLeft
.Inherit
;
944 border_style
= BorderStyle
.None
;
945 background_color
= Color
.Empty
;
949 ime_mode
= ImeMode
.Inherit
;
950 use_compatible_text_rendering
= true;
953 backgroundimage_layout
= ImageLayout
.Tile
;
954 use_compatible_text_rendering
= Application
.use_compatible_text_rendering
;
955 padding
= new Padding(0);
956 maximum_size
= new Size();
957 minimum_size
= new Size();
958 margin
= this.DefaultMargin
;
961 control_style
= ControlStyles
.UserPaint
| ControlStyles
.AllPaintingInWmPaint
|
962 ControlStyles
.Selectable
| ControlStyles
.StandardClick
|
963 ControlStyles
.StandardDoubleClick
;
965 control_style
|= ControlStyles
.UseTextForAccessibility
;
969 background_image
= null;
973 window
= new ControlNativeWindow(this);
974 child_controls
= CreateControlsInstance();
975 client_size
= new Size(DefaultSize
.Width
, DefaultSize
.Height
);
976 client_rect
= new Rectangle(0, 0, DefaultSize
.Width
, DefaultSize
.Height
);
977 bounds
.Size
= SizeFromClientSize (client_size
);
978 explicit_bounds
= bounds
;
981 public Control (Control parent
, string text
) : this()
987 public Control (Control parent
, string text
, int left
, int top
, int width
, int height
) : this()
993 bounds
.Height
=height
;
994 SetBounds(left
, top
, width
, height
, BoundsSpecified
.All
);
998 public Control (string text
) : this()
1003 public Control (string text
, int left
, int top
, int width
, int height
) : this()
1008 bounds
.Height
=height
;
1009 SetBounds(left
, top
, width
, height
, BoundsSpecified
.All
);
1013 private delegate void RemoveDelegate(object c
);
1015 protected override void Dispose (bool disposing
)
1017 if (!is_disposed
&& disposing
) {
1020 DisposeBackBuffer ();
1026 if (bmp_g
!= null) {
1031 if (this.InvokeRequired
) {
1032 if (Application
.MessageLoop
) {
1033 this.BeginInvokeInternal(new MethodInvoker(DestroyHandle
), null, true);
1039 if (parent
!= null) {
1040 parent
.Controls
.Remove(this);
1043 Control
[] children
= child_controls
.GetAllControls ();
1044 for (int i
=0; i
<children
.Length
; i
++) {
1045 children
[i
].parent
= null; // Need to set to null or our child will try and remove from ourselves and crash
1046 children
[i
].Dispose();
1051 base.Dispose(disposing
);
1053 #endregion // Public Constructors
1055 #region Internal Properties
1056 // Control is currently selected, like Focused, except maintains state
1057 // when Form loses focus
1058 internal bool InternalSelected
{
1060 IContainerControl container
;
1062 container
= GetContainerControl();
1064 if (container
!= null && container
.ActiveControl
== this)
1071 // Mouse is currently within the control's bounds
1072 internal bool Entered
{
1073 get { return this.is_entered; }
1076 internal bool VisibleInternal
{
1077 get { return is_visible; }
1080 internal LayoutType ControlLayoutType
{
1081 get { return layout_type; }
1084 internal BorderStyle InternalBorderStyle
{
1086 return border_style
;
1090 if (!Enum
.IsDefined (typeof (BorderStyle
), value))
1091 throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
1093 if (border_style
!= value) {
1094 border_style
= value;
1096 if (IsHandleCreated
) {
1097 XplatUI
.SetBorderStyle (window
.Handle
, (FormBorderStyle
)border_style
);
1105 internal Size InternalClientSize { set { this.client_size = value; }
}
1106 internal virtual bool ActivateOnShow { get { return true; }
}
1107 #endregion // Internal Properties
1109 #region Private & Internal Methods
1112 void IDropTarget
.OnDragDrop (DragEventArgs e
)
1117 void IDropTarget
.OnDragEnter (DragEventArgs e
)
1122 void IDropTarget
.OnDragLeave (EventArgs e
)
1127 void IDropTarget
.OnDragOver (DragEventArgs e
)
1133 internal IAsyncResult
BeginInvokeInternal (Delegate method
, object [] args
, bool disposing
) {
1134 AsyncMethodResult result
;
1135 AsyncMethodData data
;
1140 if (!p
.IsHandleCreated
)
1141 throw new InvalidOperationException("Cannot call Invoke or BeginInvoke on a control until the window handle is created");
1143 } while (p
!= null);
1146 result
= new AsyncMethodResult ();
1147 data
= new AsyncMethodData ();
1149 data
.Handle
= window
.Handle
;
1150 data
.Method
= method
;
1152 data
.Result
= result
;
1155 if (!ExecutionContext
.IsFlowSuppressed ()) {
1156 data
.Context
= ExecutionContext
.Capture ();
1159 #if !MWF_ON_MSRUNTIME
1160 if (SecurityManager
.SecurityEnabled
) {
1161 data
.Stack
= CompressedStack
.GetCompressedStack ();
1166 XplatUI
.SendAsyncMethod (data
);
1171 internal void PointToClient (ref int x
, ref int y
) {
1172 XplatUI
.ScreenToClient (Handle
, ref x
, ref y
);
1175 internal void PointToScreen (ref int x
, ref int y
) {
1176 XplatUI
.ClientToScreen (Handle
, ref x
, ref y
);
1179 internal bool IsRecreating
{
1181 return is_recreating
;
1185 internal Graphics DeviceContext
{
1187 if (bmp_g
== null) {
1188 bmp
= new Bitmap(1, 1, System
.Drawing
.Imaging
.PixelFormat
.Format32bppArgb
);
1189 bmp_g
= Graphics
.FromImage (bmp
);
1195 private void InvalidateBackBuffer () {
1196 if (backbuffer
!= null)
1197 backbuffer
.Invalidate ();
1200 private DoubleBuffer
GetBackBuffer () {
1201 if (backbuffer
== null)
1202 backbuffer
= new DoubleBuffer (this);
1206 private void DisposeBackBuffer () {
1207 if (backbuffer
!= null) {
1208 backbuffer
.Dispose ();
1213 internal static void SetChildColor(Control parent
) {
1216 for (int i
=0; i
< parent
.child_controls
.Count
; i
++) {
1217 child
=parent
.child_controls
[i
];
1218 if (child
.child_controls
.Count
>0) {
1219 SetChildColor(child
);
1224 internal bool Select(Control control
) {
1225 IContainerControl container
;
1227 if (control
== null) {
1231 container
= GetContainerControl();
1232 if (container
!= null && (Control
)container
!= control
) {
1233 container
.ActiveControl
= control
;
1235 else if (control
.IsHandleCreated
) {
1236 XplatUI
.SetFocus(control
.window
.Handle
);
1241 internal virtual void DoDefaultAction() {
1242 // Only here to be overriden by our actual controls; this is needed by the accessibility class
1245 internal static IntPtr
MakeParam (int low
, int high
){
1246 return new IntPtr (high
<< 16 | low
& 0xffff);
1249 internal static int LowOrder (int param
) {
1250 return ((int)(short)(param
& 0xffff));
1253 internal static int HighOrder (int param
) {
1254 return ((int)(short)(param
>> 16));
1257 // This method exists so controls overriding OnPaintBackground can have default background painting done
1258 internal virtual void PaintControlBackground (PaintEventArgs pevent
) {
1259 if (GetStyle(ControlStyles
.SupportsTransparentBackColor
) && (BackColor
.A
!= 0xff)) {
1260 if (parent
!= null) {
1261 PaintEventArgs parent_pe
;
1262 GraphicsState state
;
1264 parent_pe
= new PaintEventArgs(pevent
.Graphics
, new Rectangle(pevent
.ClipRectangle
.X
+ Left
, pevent
.ClipRectangle
.Y
+ Top
, pevent
.ClipRectangle
.Width
, pevent
.ClipRectangle
.Height
));
1266 state
= parent_pe
.Graphics
.Save();
1267 parent_pe
.Graphics
.TranslateTransform(-Left
, -Top
);
1268 parent
.OnPaintBackground(parent_pe
);
1269 parent_pe
.Graphics
.Restore(state
);
1271 state
= parent_pe
.Graphics
.Save();
1272 parent_pe
.Graphics
.TranslateTransform(-Left
, -Top
);
1273 parent
.OnPaint(parent_pe
);
1274 parent_pe
.Graphics
.Restore(state
);
1275 parent_pe
.SetGraphics(null);
1279 if ((clip_region
!= null) && (XplatUI
.UserClipWontExposeParent
)) {
1280 if (parent
!= null) {
1281 PaintEventArgs parent_pe
;
1283 GraphicsState state
;
1286 hwnd
= Hwnd
.ObjectFromHandle(Handle
);
1289 parent_pe
= new PaintEventArgs(pevent
.Graphics
, new Rectangle(pevent
.ClipRectangle
.X
+ Left
, pevent
.ClipRectangle
.Y
+ Top
, pevent
.ClipRectangle
.Width
, pevent
.ClipRectangle
.Height
));
1291 region
= new Region ();
1293 region
.Union(ClientRectangle
);
1295 foreach (Rectangle r
in hwnd
.ClipRectangles
) {
1299 state
= parent_pe
.Graphics
.Save();
1300 parent_pe
.Graphics
.Clip
= region
;
1302 parent_pe
.Graphics
.TranslateTransform(-Left
, -Top
);
1303 parent
.OnPaintBackground(parent_pe
);
1304 parent_pe
.Graphics
.Restore(state
);
1306 state
= parent_pe
.Graphics
.Save();
1307 parent_pe
.Graphics
.Clip
= region
;
1309 parent_pe
.Graphics
.TranslateTransform(-Left
, -Top
);
1310 parent
.OnPaint(parent_pe
);
1311 parent_pe
.Graphics
.Restore(state
);
1312 parent_pe
.SetGraphics(null);
1314 region
.Intersect(clip_region
);
1315 pevent
.Graphics
.Clip
= region
;
1320 if (background_image
== null) {
1321 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));
1325 DrawBackgroundImage (pevent
.Graphics
);
1328 void DrawBackgroundImage (Graphics g
) {
1330 Rectangle drawing_rectangle
= new Rectangle ();
1331 g
.FillRectangle (ThemeEngine
.Current
.ResPool
.GetSolidBrush (BackColor
), ClientRectangle
);
1333 switch (backgroundimage_layout
)
1335 case ImageLayout
.Tile
:
1336 using (TextureBrush b
= new TextureBrush (background_image
, WrapMode
.Tile
)) {
1337 g
.FillRectangle (b
, ClientRectangle
);
1340 case ImageLayout
.Center
:
1341 drawing_rectangle
.Location
= new Point (ClientSize
.Width
/ 2 - background_image
.Width
/ 2, ClientSize
.Height
/ 2 - background_image
.Height
/ 2);
1342 drawing_rectangle
.Size
= background_image
.Size
;
1344 case ImageLayout
.None
:
1345 drawing_rectangle
.Location
= Point
.Empty
;
1346 drawing_rectangle
.Size
= background_image
.Size
;
1348 case ImageLayout
.Stretch
:
1349 drawing_rectangle
= ClientRectangle
;
1351 case ImageLayout
.Zoom
:
1352 drawing_rectangle
= ClientRectangle
;
1353 if ((float)background_image
.Width
/ (float)background_image
.Height
< (float)drawing_rectangle
.Width
/ (float) drawing_rectangle
.Height
) {
1354 drawing_rectangle
.Width
= (int) (background_image
.Width
* ((float)drawing_rectangle
.Height
/ (float)background_image
.Height
));
1355 drawing_rectangle
.X
= (ClientRectangle
.Width
- drawing_rectangle
.Width
) / 2;
1357 drawing_rectangle
.Height
= (int) (background_image
.Height
* ((float)drawing_rectangle
.Width
/ (float)background_image
.Width
));
1358 drawing_rectangle
.Y
= (ClientRectangle
.Height
- drawing_rectangle
.Height
) / 2;
1365 g
.DrawImage (background_image
, drawing_rectangle
);
1368 using (TextureBrush b
= new TextureBrush (background_image
, WrapMode
.Tile
)) {
1369 g
.FillRectangle (b
, ClientRectangle
);
1374 internal virtual void DndEnter (DragEventArgs e
) {
1380 internal virtual void DndOver (DragEventArgs e
) {
1386 internal virtual void DndDrop (DragEventArgs e
) {
1389 } catch (Exception exc
) {
1390 Console
.Error
.WriteLine ("MWF: Exception while dropping:");
1391 Console
.Error
.WriteLine (exc
);
1395 internal virtual void DndLeave (EventArgs e
) {
1401 internal virtual void DndFeedback(GiveFeedbackEventArgs e
) {
1407 internal virtual void DndContinueDrag(QueryContinueDragEventArgs e
) {
1409 OnQueryContinueDrag(e
);
1413 internal static MouseButtons
FromParamToMouseButtons (int param
) {
1414 MouseButtons buttons
= MouseButtons
.None
;
1416 if ((param
& (int) MsgButtons
.MK_LBUTTON
) != 0)
1417 buttons
|= MouseButtons
.Left
;
1419 if ((param
& (int) MsgButtons
.MK_MBUTTON
) != 0)
1420 buttons
|= MouseButtons
.Middle
;
1422 if ((param
& (int) MsgButtons
.MK_RBUTTON
) != 0)
1423 buttons
|= MouseButtons
.Right
;
1429 internal virtual void FireEnter () {
1430 OnEnter (EventArgs
.Empty
);
1433 internal virtual void FireLeave () {
1434 OnLeave (EventArgs
.Empty
);
1437 internal virtual void FireValidating (CancelEventArgs ce
) {
1441 internal virtual void FireValidated () {
1442 OnValidated (EventArgs
.Empty
);
1445 internal virtual bool ProcessControlMnemonic(char charCode
) {
1446 return ProcessMnemonic(charCode
);
1449 private static Control
FindFlatForward(Control container
, Control start
) {
1455 end
= container
.child_controls
.Count
;
1457 if (start
!= null) {
1458 index
= start
.tab_index
;
1463 for (int i
= 0, pos
= -1; i
< end
; i
++) {
1464 if (start
== container
.child_controls
[i
]) {
1469 if (found
== null) {
1470 if (container
.child_controls
[i
].tab_index
> index
|| (pos
> -1 && pos
< i
&& container
.child_controls
[i
].tab_index
== index
)) {
1471 found
= container
.child_controls
[i
];
1473 } else if (found
.tab_index
> container
.child_controls
[i
].tab_index
) {
1474 if (container
.child_controls
[i
].tab_index
> index
) {
1475 found
= container
.child_controls
[i
];
1482 private static Control
FindControlForward(Control container
, Control start
) {
1487 if (start
== null) {
1488 return FindFlatForward(container
, start
);
1491 if (start
.child_controls
!= null && start
.child_controls
.Count
> 0 &&
1492 (start
== container
|| !((start
is IContainerControl
) && start
.GetStyle(ControlStyles
.ContainerControl
)))) {
1493 return FindControlForward(start
, null);
1496 while (start
!= container
) {
1497 found
= FindFlatForward(start
.parent
, start
);
1498 if (found
!= null) {
1501 start
= start
.parent
;
1507 private static Control
FindFlatBackward(Control container
, Control start
) {
1513 end
= container
.child_controls
.Count
;
1515 if (start
!= null) {
1516 index
= start
.tab_index
;
1518 // FIXME: Possible speed-up: Keep the highest taborder index in the container
1520 for (int i
= 0; i
< end
; i
++) {
1521 if (container
.child_controls
[i
].tab_index
> index
) {
1522 index
= container
.child_controls
[i
].tab_index
;
1530 for (int i
= end
- 1; i
>= 0; i
--) {
1531 if (start
== container
.child_controls
[i
]) {
1536 if (found
== null || found
.tab_index
< container
.child_controls
[i
].tab_index
) {
1537 if (container
.child_controls
[i
].tab_index
< index
|| (hit
&& container
.child_controls
[i
].tab_index
== index
))
1538 found
= container
.child_controls
[i
];
1545 private static Control
FindControlBackward(Control container
, Control start
) {
1547 Control found
= null;
1549 if (start
== null) {
1550 found
= FindFlatBackward(container
, start
);
1552 else if (start
!= container
) {
1553 if (start
.parent
!= null) {
1554 found
= FindFlatBackward(start
.parent
, start
);
1556 if (found
== null) {
1557 if (start
.parent
!= container
)
1558 return start
.parent
;
1564 if (found
== null || start
.parent
== null)
1567 while (found
!= null && (found
== container
|| (!((found
is IContainerControl
) && found
.GetStyle(ControlStyles
.ContainerControl
))) &&
1568 found
.child_controls
!= null && found
.child_controls
.Count
> 0)) {
1569 // while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
1570 // (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
1571 found
= FindFlatBackward(found
, null);
1581 if (start != null) {
1582 found = FindFlatBackward(start.parent, start);
1583 if (found == null) {
1584 if (start.parent != container) {
1585 return start.parent;
1589 if (found == null) {
1590 found = FindFlatBackward(container, start);
1593 if (container != start) {
1594 while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
1595 found = FindControlBackward(found, null);
1596 if (found != null) {
1605 internal virtual void HandleClick(int clicks
, MouseEventArgs me
) {
1606 if (GetStyle(ControlStyles
.StandardClick
)) {
1607 if ((clicks
> 1) && GetStyle(ControlStyles
.StandardDoubleClick
)) {
1609 OnDoubleClick(EventArgs
.Empty
);
1611 OnClick(EventArgs
.Empty
);
1614 OnMouseDoubleClick (me
);
1623 internal void CaptureWithConfine (Control ConfineWindow
) {
1624 if (this.IsHandleCreated
&& !is_captured
) {
1626 XplatUI
.GrabWindow (this.window
.Handle
, ConfineWindow
.Handle
);
1630 private void CheckDataBindings () {
1631 if (data_bindings
== null)
1634 BindingContext binding_context
= BindingContext
;
1635 foreach (Binding binding
in data_bindings
) {
1636 binding
.Check (binding_context
);
1640 private void ChangeParent(Control new_parent
) {
1644 Color pre_fore_color
;
1645 Color pre_back_color
;
1646 RightToLeft pre_rtl
;
1648 // These properties are inherited from our parent
1649 // Get them pre parent-change and then send events
1650 // if they are changed after we have our new parent
1651 pre_enabled
= Enabled
;
1652 pre_visible
= Visible
;
1654 pre_fore_color
= ForeColor
;
1655 pre_back_color
= BackColor
;
1656 pre_rtl
= RightToLeft
;
1657 // MS doesn't seem to send a CursorChangedEvent
1659 parent
= new_parent
;
1661 if (IsHandleCreated
) {
1662 XplatUI
.SetParent(Handle
,
1663 (new_parent
== null || !new_parent
.IsHandleCreated
) ? IntPtr
.Zero
: new_parent
.Handle
);
1664 if (this is Form
) {
1665 ((Form
) this).ChangingParent (new_parent
);
1669 OnParentChanged(EventArgs
.Empty
);
1671 if (pre_enabled
!= Enabled
) {
1672 OnEnabledChanged(EventArgs
.Empty
);
1675 if (pre_visible
!= Visible
) {
1676 OnVisibleChanged(EventArgs
.Empty
);
1679 if (pre_font
!= Font
) {
1680 OnFontChanged(EventArgs
.Empty
);
1683 if (pre_fore_color
!= ForeColor
) {
1684 OnForeColorChanged(EventArgs
.Empty
);
1687 if (pre_back_color
!= BackColor
) {
1688 OnBackColorChanged(EventArgs
.Empty
);
1691 if (pre_rtl
!= RightToLeft
) {
1692 // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
1693 // because when RTL changes they have to recreate the win32 control
1694 // We don't really need that (until someone runs into compatibility issues)
1695 OnRightToLeftChanged(EventArgs
.Empty
);
1698 if ((new_parent
!= null) && new_parent
.Created
&& is_visible
&& !Created
) {
1702 if ((binding_context
== null) && Created
) {
1703 OnBindingContextChanged(EventArgs
.Empty
);
1707 private void UpdateDistances() {
1708 if (parent
!= null) {
1709 if (bounds
.Width
> 0)
1710 dist_right
= parent
.ClientSize
.Width
- bounds
.X
- bounds
.Width
;
1711 if (bounds
.Height
> 0)
1712 dist_bottom
= parent
.ClientSize
.Height
- bounds
.Y
- bounds
.Height
;
1716 private bool UseDoubleBuffering
{
1718 if (!ThemeEngine
.Current
.DoubleBufferingSupported
)
1725 return (control_style
& ControlStyles
.DoubleBuffer
) != 0;
1728 #endregion // Private & Internal Methods
1730 #region Public Static Properties
1731 public static Color DefaultBackColor
{
1733 return ThemeEngine
.Current
.DefaultControlBackColor
;
1737 public static Font DefaultFont
{
1739 return ThemeEngine
.Current
.DefaultFont
;
1743 public static Color DefaultForeColor
{
1745 return ThemeEngine
.Current
.DefaultControlForeColor
;
1749 public static Keys ModifierKeys
{
1751 return XplatUI
.State
.ModifierKeys
;
1755 public static MouseButtons MouseButtons
{
1757 return XplatUI
.State
.MouseButtons
;
1761 public static Point MousePosition
{
1763 return Cursor
.Position
;
1768 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
1769 [DesignerSerializationVisibility (DesignerSerializationVisibility
.Hidden
)]
1772 public static bool CheckForIllegalCrossThreadCalls
1775 return verify_thread_handle
;
1779 verify_thread_handle
= value;
1783 #endregion // Public Static Properties
1785 #region Public Instance Properties
1786 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1788 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
1789 public AccessibleObject AccessibilityObject
{
1791 if (accessibility_object
==null) {
1792 accessibility_object
=CreateAccessibilityInstance();
1794 return accessibility_object
;
1798 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
1800 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
1801 public string AccessibleDefaultActionDescription
{
1803 if (accessibility_object
!= null)
1804 return accessibility_object
.default_action
;
1810 if (accessibility_object
!= null)
1811 accessibility_object
.default_action
= value;
1816 [DefaultValue(null)]
1817 [MWFCategory("Accessibility")]
1818 public string AccessibleDescription
{
1820 if (accessibility_object
!= null)
1821 return accessibility_object
.description
;
1827 if (accessibility_object
!= null)
1828 accessibility_object
.description
= value;
1833 [DefaultValue(null)]
1834 [MWFCategory("Accessibility")]
1835 public string AccessibleName
{
1837 if (accessibility_object
!= null)
1838 return accessibility_object
.Name
;
1844 if (accessibility_object
!= null)
1845 accessibility_object
.Name
= value;
1849 [DefaultValue(AccessibleRole
.Default
)]
1850 [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
1851 public AccessibleRole AccessibleRole
{
1853 if (accessibility_object
!= null)
1854 return accessibility_object
.role
;
1856 return AccessibleRole
.Default
;
1860 if (accessibility_object
!= null)
1861 accessibility_object
.role
= value;
1865 [DefaultValue(false)]
1866 [MWFCategory("Behavior")]
1867 public virtual bool AllowDrop
{
1873 if (allow_drop
== value)
1876 if (IsHandleCreated
) {
1878 XplatUI
.SetAllowDrop (Handle
, value);
1884 [RefreshProperties(RefreshProperties
.Repaint
)]
1885 [DefaultValue(AnchorStyles
.Top
| AnchorStyles
.Left
)]
1886 [MWFCategory("Layout")]
1887 public virtual AnchorStyles Anchor
{
1889 return anchor_style
;
1893 layout_type
= LayoutType
.Anchor
;
1895 if (anchor_style
== value)
1899 dock_style
= DockStyle
.None
;
1904 parent
.PerformLayout(this, "Anchor");
1909 // XXX: Implement me!
1912 [RefreshProperties (RefreshProperties
.All
)]
1913 [Localizable (true)]
1914 [DesignerSerializationVisibility (DesignerSerializationVisibility
.Hidden
)]
1916 [EditorBrowsable (EditorBrowsableState
.Never
)]
1917 [DefaultValue (false)]
1918 [MonoTODO("This method currently does nothing")]
1919 public virtual bool AutoSize
{
1920 get { return auto_size; }
1922 if (this.auto_size
!= value) {
1924 OnAutoSizeChanged (EventArgs
.Empty
);
1930 [AmbientValue ("{Width=0, Height=0}")]
1932 [AmbientValue (typeof(Size
), "0, 0")]
1934 public virtual Size MaximumSize
{
1936 return maximum_size
;
1939 if (maximum_size
!= value) {
1940 maximum_size
= value;
1941 Size
= PreferredSize
;
1946 public virtual Size MinimumSize
{
1948 return minimum_size
;
1951 if (minimum_size
!= value) {
1952 minimum_size
= value;
1953 Size
= PreferredSize
;
1960 [MWFCategory("Appearance")]
1961 public virtual Color BackColor
{
1963 if (background_color
.IsEmpty
) {
1965 Color pcolor
= parent
.BackColor
;
1966 if (pcolor
.A
== 0xff || GetStyle(ControlStyles
.SupportsTransparentBackColor
))
1969 return DefaultBackColor
;
1971 return background_color
;
1975 if (!value.IsEmpty
&& (value.A
!= 0xff) && !GetStyle(ControlStyles
.SupportsTransparentBackColor
)) {
1976 throw new ArgumentException("Transparent background colors are not supported on this control");
1979 if (background_color
!= value) {
1980 background_color
=value;
1981 SetChildColor(this);
1982 OnBackColorChanged(EventArgs
.Empty
);
1989 [DefaultValue(null)]
1990 [MWFCategory("Appearance")]
1991 public virtual Image BackgroundImage
{
1993 return background_image
;
1997 if (background_image
!=value) {
1998 background_image
=value;
1999 OnBackgroundImageChanged(EventArgs
.Empty
);
2006 [DefaultValue (ImageLayout
.Tile
)]
2007 [Localizable (true)]
2008 public virtual ImageLayout BackgroundImageLayout
{
2010 return backgroundimage_layout
;
2013 if (Array
.IndexOf (Enum
.GetValues (typeof (ImageLayout
)), value) == -1)
2014 throw new InvalidEnumArgumentException ("value", (int) value, typeof(ImageLayout
));
2016 if (value != backgroundimage_layout
) {
2017 backgroundimage_layout
= value;
2019 OnBackgroundImageLayoutChanged (EventArgs
.Empty
);
2025 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2027 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2028 public virtual BindingContext BindingContext
{
2030 if (binding_context
!= null)
2031 return binding_context
;
2034 binding_context
= Parent
.BindingContext
;
2035 return binding_context
;
2038 if (binding_context
!= value) {
2039 binding_context
= value;
2040 OnBindingContextChanged(EventArgs
.Empty
);
2045 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2047 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2050 return bounds
.Y
+bounds
.Height
;
2054 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2056 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2057 public Rectangle Bounds
{
2063 SetBounds(value.Left
, value.Top
, value.Width
, value.Height
, BoundsSpecified
.All
);
2067 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2069 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2070 public bool CanFocus
{
2072 if (IsHandleCreated
&& Visible
&& Enabled
) {
2079 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2081 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2082 public bool CanSelect
{
2086 if (!GetStyle(ControlStyles
.Selectable
)) {
2091 while (parent
!= null) {
2092 if (!parent
.is_visible
|| !parent
.is_enabled
) {
2096 parent
= parent
.parent
;
2102 internal virtual bool InternalCapture
{
2112 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2114 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2115 public bool Capture
{
2117 return this.is_captured
;
2121 // Call OnMouseCaptureChanged when we get WM_CAPTURECHANGED.
2122 if (value != is_captured
) {
2125 XplatUI
.GrabWindow(Handle
, IntPtr
.Zero
);
2127 if (IsHandleCreated
)
2128 XplatUI
.UngrabWindow(Handle
);
2129 is_captured
= false;
2135 [DefaultValue(true)]
2136 [MWFCategory("Focus")]
2137 public bool CausesValidation
{
2139 return this.causes_validation
;
2143 if (this.causes_validation
!= value) {
2144 causes_validation
= value;
2145 OnCausesValidationChanged(EventArgs
.Empty
);
2150 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2152 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2153 public Rectangle ClientRectangle
{
2155 client_rect
.Width
= client_size
.Width
;
2156 client_rect
.Height
= client_size
.Height
;
2161 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2163 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2164 public Size ClientSize
{
2167 if ((this is Form
) && (((Form
)this).form_parent_window
!= null)) {
2168 return ((Form
)this).form_parent_window
.ClientSize
;
2176 this.SetClientSizeCore(value.Width
, value.Height
);
2178 this.OnClientSizeChanged (EventArgs
.Empty
);
2183 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2185 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2186 [DescriptionAttribute("ControlCompanyNameDescr")]
2187 public String CompanyName
{
2189 return "Mono Project, Novell, Inc.";
2193 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2195 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2196 public bool ContainsFocus
{
2198 IntPtr focused_window
;
2200 focused_window
= XplatUI
.GetFocus();
2201 if (IsHandleCreated
) {
2202 if (focused_window
== Handle
) {
2206 for (int i
=0; i
< child_controls
.Count
; i
++) {
2207 if (child_controls
[i
].ContainsFocus
) {
2218 [DefaultValue(null)]
2219 [MWFCategory("Behavior")]
2220 public virtual ContextMenu ContextMenu
{
2222 return GetContextMenuInternal ();
2226 if (context_menu
!= value) {
2227 context_menu
= value;
2228 OnContextMenuChanged(EventArgs
.Empty
);
2233 internal virtual ContextMenu
GetContextMenuInternal () {
2234 return context_menu
;
2238 [DefaultValue (null)]
2239 public virtual ContextMenuStrip ContextMenuStrip
{
2240 get { return this.context_menu_strip; }
2242 if (this.context_menu_strip
!= value) {
2243 this.context_menu_strip
= value;
2244 OnContextMenuStripChanged (EventArgs
.Empty
);
2251 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Content
)]
2252 public ControlCollection Controls
{
2254 return this.child_controls
;
2258 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2260 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2261 public bool Created
{
2263 return (!is_disposed
&& is_created
);
2267 [AmbientValue(null)]
2268 [MWFCategory("Appearance")]
2269 public virtual Cursor Cursor
{
2271 if (cursor
!= null) {
2275 if (parent
!= null) {
2276 return parent
.Cursor
;
2279 return Cursors
.Default
;
2283 if (cursor
!= value) {
2288 if (IsHandleCreated
) {
2289 pt
= Cursor
.Position
;
2291 if (bounds
.Contains(pt
) || Capture
) {
2292 if (GetChildAtPoint(pt
) == null) {
2293 if (cursor
!= null) {
2294 XplatUI
.SetCursor(window
.Handle
, cursor
.handle
);
2296 if (parent
!= null) {
2297 XplatUI
.SetCursor(window
.Handle
, parent
.Cursor
.handle
);
2299 XplatUI
.SetCursor(window
.Handle
, Cursors
.Default
.handle
);
2306 OnCursorChanged(EventArgs
.Empty
);
2312 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Content
)]
2313 [ParenthesizePropertyName(true)]
2314 [RefreshProperties(RefreshProperties
.All
)]
2315 [MWFCategory("Data")]
2316 public ControlBindingsCollection DataBindings
{
2318 if (data_bindings
== null)
2319 data_bindings
= new ControlBindingsCollection (this);
2320 return data_bindings
;
2324 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2326 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2327 public virtual Rectangle DisplayRectangle
{
2329 return ClientRectangle
;
2333 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2335 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2336 public bool Disposing
{
2343 [RefreshProperties(RefreshProperties
.Repaint
)]
2344 [DefaultValue(DockStyle
.None
)]
2345 [MWFCategory("Layout")]
2346 public virtual DockStyle Dock
{
2352 layout_type
= LayoutType
.Dock
;
2354 if (dock_style
== value) {
2358 if (!Enum
.IsDefined (typeof (DockStyle
), value)) {
2359 throw new InvalidEnumArgumentException ("value", (int) value,
2360 typeof (DockStyle
));
2364 anchor_style
= AnchorStyles
.Top
| AnchorStyles
.Left
;
2366 if (dock_style
== DockStyle
.None
) {
2367 if (explicit_bounds
== Rectangle
.Empty
)
2368 Bounds
= new Rectangle (new Point (0, 0), DefaultSize
);
2370 Bounds
= explicit_bounds
;
2373 if (parent
!= null) {
2374 parent
.PerformLayout(this, "Dock");
2377 OnDockChanged(EventArgs
.Empty
);
2382 protected virtual bool DoubleBuffered
{
2384 return (control_style
& ControlStyles
.OptimizedDoubleBuffer
) != 0;
2388 if (value == DoubleBuffered
)
2391 SetStyle (ControlStyles
.OptimizedDoubleBuffer
| ControlStyles
.AllPaintingInWmPaint
, true);
2393 SetStyle (ControlStyles
.OptimizedDoubleBuffer
, false);
2402 [MWFCategory("Behavior")]
2403 public bool Enabled
{
2409 if (parent
!= null) {
2410 return parent
.Enabled
;
2417 if (this.is_enabled
!= value) {
2418 bool old_value
= is_enabled
;
2421 if (old_value
!= value && !value && this.has_focus
)
2422 SelectNextControl(this, true, true, true, true);
2424 OnEnabledChanged (EventArgs
.Empty
);
2429 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2431 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2432 public virtual bool Focused
{
2434 return this.has_focus
;
2439 [AmbientValue(null)]
2441 [MWFCategory("Appearance")]
2442 public virtual Font Font
{
2448 if (Parent
!= null && Parent
.Font
!= null) {
2455 [param
:MarshalAs(UnmanagedType
.CustomMarshaler
, MarshalTypeRef
=typeof(Font
))]
2457 if (font
!= null && font
.Equals (value)) {
2463 OnFontChanged (EventArgs
.Empty
);
2469 [MWFCategory("Appearance")]
2470 public virtual Color ForeColor
{
2472 if (foreground_color
.IsEmpty
) {
2474 return parent
.ForeColor
;
2476 return DefaultForeColor
;
2478 return foreground_color
;
2482 if (foreground_color
!= value) {
2483 foreground_color
=value;
2485 OnForeColorChanged(EventArgs
.Empty
);
2492 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2493 public IntPtr Handle
{ // IWin32Window
2496 if (verify_thread_handle
) {
2497 if (this.InvokeRequired
) {
2498 throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
2502 if (!IsHandleCreated
) {
2505 return window
.Handle
;
2509 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2511 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2512 public bool HasChildren
{
2514 if (this.child_controls
.Count
>0) {
2521 [EditorBrowsable(EditorBrowsableState
.Always
)]
2523 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2526 return this.bounds
.Height
;
2530 SetBounds(bounds
.X
, bounds
.Y
, bounds
.Width
, value, BoundsSpecified
.Height
);
2534 [AmbientValue(ImeMode
.Inherit
)]
2536 [MWFCategory("Behavior")]
2537 public ImeMode ImeMode
{
2539 if (ime_mode
== ImeMode
.Inherit
) {
2541 return parent
.ImeMode
;
2543 return ImeMode
.NoControl
; // default value
2549 if (ime_mode
!= value) {
2552 OnImeModeChanged(EventArgs
.Empty
);
2557 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2559 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2560 public bool InvokeRequired
{ // ISynchronizeInvoke
2562 if (creator_thread
!= null && creator_thread
!=Thread
.CurrentThread
) {
2569 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2571 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2572 public bool IsAccessible
{
2574 return is_accessible
;
2578 is_accessible
= value;
2582 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2584 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2585 public bool IsDisposed
{
2587 return this.is_disposed
;
2591 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2593 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2594 public bool IsHandleCreated
{
2596 if (window
== null || window
.Handle
== IntPtr
.Zero
)
2599 Hwnd hwnd
= Hwnd
.ObjectFromHandle (window
.Handle
);
2600 if (hwnd
!= null && hwnd
.zombie
)
2608 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
2612 Layout
.LayoutEngine LayoutEngine
{
2614 if (layout_engine
== null)
2615 layout_engine
= new Layout
.DefaultLayout ();
2616 return layout_engine
;
2620 [EditorBrowsable(EditorBrowsableState
.Always
)]
2622 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2625 return this.bounds
.X
;
2629 SetBounds(value, bounds
.Y
, bounds
.Width
, bounds
.Height
, BoundsSpecified
.X
);
2634 [MWFCategory("Layout")]
2635 public Point Location
{
2637 return new Point(bounds
.X
, bounds
.Y
);
2641 SetBounds(value.X
, value.Y
, bounds
.Width
, bounds
.Height
, BoundsSpecified
.Location
);
2646 [Localizable (true)]
2647 public Padding Margin
{
2648 get { return this.margin; }
2650 if (this.margin
!= value) {
2651 this.margin
= value;
2652 OnMarginChanged (EventArgs
.Empty
);
2659 public string Name
{
2671 public Padding Padding
{
2677 if (padding
!= value) {
2679 OnPaddingChanged (EventArgs
.Empty
);
2687 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2688 public Control Parent
{
2694 if (value == this) {
2695 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
2698 if (parent
!=value) {
2700 parent
.Controls
.Remove(this);
2705 value.Controls
.Add(this);
2712 public Size PreferredSize
{
2713 get { return this.GetPreferredSize (Size.Empty); }
2717 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2719 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2720 public string ProductName
{
2722 Type t
= typeof (AssemblyProductAttribute
);
2723 Assembly assembly
= GetType().Module
.Assembly
;
2724 object [] attrs
= assembly
.GetCustomAttributes (t
, false);
2725 AssemblyProductAttribute a
= null;
2726 // On MS we get a NullRefException if product attribute is not
2728 if (attrs
!= null && attrs
.Length
> 0)
2729 a
= (AssemblyProductAttribute
) attrs
[0];
2734 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2736 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2737 public string ProductVersion
{
2739 Type t
= typeof (AssemblyVersionAttribute
);
2740 Assembly assembly
= GetType().Module
.Assembly
;
2741 object [] attrs
= assembly
.GetCustomAttributes (t
, false);
2742 if (attrs
== null || attrs
.Length
< 1)
2744 return ((AssemblyVersionAttribute
)attrs
[0]).Version
;
2748 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2750 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2751 public bool RecreatingHandle
{
2753 return is_recreating
;
2757 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2759 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2760 public Region Region
{
2766 if (clip_region
!= value) {
2767 if (value != null && IsHandleCreated
)
2768 XplatUI
.SetClipRegion(Handle
, value);
2770 clip_region
= value;
2772 OnRegionChanged (EventArgs
.Empty
);
2778 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2780 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2783 return this.bounds
.X
+this.bounds
.Width
;
2787 [AmbientValue(RightToLeft
.Inherit
)]
2789 [MWFCategory("Appearance")]
2790 public virtual RightToLeft RightToLeft
{
2792 if (right_to_left
== RightToLeft
.Inherit
) {
2794 return parent
.RightToLeft
;
2796 return RightToLeft
.No
; // default value
2798 return right_to_left
;
2802 if (value != right_to_left
) {
2803 right_to_left
= value;
2804 OnRightToLeftChanged(EventArgs
.Empty
);
2810 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2811 public override ISite Site
{
2819 if (value != null) {
2820 AmbientProperties ap
= (AmbientProperties
) value.GetService (typeof (AmbientProperties
));
2822 BackColor
= ap
.BackColor
;
2823 ForeColor
= ap
.ForeColor
;
2832 [MWFCategory("Layout")]
2835 return new Size(Width
, Height
);
2839 SetBounds(bounds
.X
, bounds
.Y
, value.Width
, value.Height
, BoundsSpecified
.Size
);
2844 [MergableProperty(false)]
2845 [MWFCategory("Behavior")]
2846 public int TabIndex
{
2848 if (tab_index
!= -1) {
2855 if (tab_index
!= value) {
2857 OnTabIndexChanged(EventArgs
.Empty
);
2863 [DefaultValue(true)]
2864 [MWFCategory("Behavior")]
2865 public bool TabStop
{
2871 if (tab_stop
!= value) {
2873 OnTabStopChanged(EventArgs
.Empty
);
2878 [Localizable(false)]
2880 [TypeConverter(typeof(StringConverter
))]
2881 [DefaultValue(null)]
2882 [MWFCategory("Data")]
2889 control_tag
= value;
2895 [BindableAttribute(true)]
2896 [MWFCategory("Appearance")]
2897 public virtual string Text
{
2899 // Our implementation ignores ControlStyles.CacheText - we always cache
2904 if (value == null) {
2905 value = String
.Empty
;
2910 if (IsHandleCreated
) {
2911 /* we need to call .SetWindowStyle here instead of just .Text
2912 because the presence/absence of Text (== "" or not) can cause
2913 other window style things to appear/disappear */
2914 XplatUI
.SetWindowStyle(window
.Handle
, CreateParams
);
2915 XplatUI
.Text(Handle
, text
);
2917 OnTextChanged (EventArgs
.Empty
);
2922 [EditorBrowsable(EditorBrowsableState
.Always
)]
2924 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2927 return this.bounds
.Y
;
2931 SetBounds(bounds
.X
, value, bounds
.Width
, bounds
.Height
, BoundsSpecified
.Y
);
2935 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
2937 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2938 public Control TopLevelControl
{
2942 while (p
.parent
!= null) {
2946 return p
is Form
? p
: null;
2951 [MWFCategory("Behavior")]
2952 public bool Visible
{
2956 } else if (parent
!= null) {
2957 return parent
.Visible
;
2964 SetVisibleCore(value);
2968 [EditorBrowsable(EditorBrowsableState
.Always
)]
2970 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2973 return this.bounds
.Width
;
2977 SetBounds(bounds
.X
, bounds
.Y
, value, bounds
.Height
, BoundsSpecified
.Width
);
2981 [EditorBrowsable(EditorBrowsableState
.Never
)]
2983 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
2984 public IWindowTarget WindowTarget
{
2993 #endregion // Public Instance Properties
2995 #region Protected Instance Properties
2996 protected virtual CreateParams CreateParams
{
2998 CreateParams create_params
= new CreateParams();
3001 create_params
.Caption
= Text
;
3004 create_params
.Caption
= text
;
3008 create_params
.X
= Left
;
3011 create_params
.X
= this.bounds
.X
;
3015 create_params
.Y
= Top
;
3018 create_params
.Y
= this.bounds
.Y
;
3022 create_params
.Width
= Width
;
3025 create_params
.Width
= this.bounds
.Width
;
3029 create_params
.Height
= Height
;
3032 create_params
.Height
= this.bounds
.Height
;
3036 create_params
.ClassName
= XplatUI
.DefaultClassName
;
3037 create_params
.ClassStyle
= (int)(XplatUIWin32
.ClassStyle
.CS_OWNDC
| XplatUIWin32
.ClassStyle
.CS_DBLCLKS
);
3038 create_params
.ExStyle
= 0;
3039 create_params
.Param
= 0;
3042 create_params
.ExStyle
|= (int)WindowExStyles
.WS_EX_ACCEPTFILES
;
3045 if ((parent
!=null) && (parent
.IsHandleCreated
)) {
3046 create_params
.Parent
= parent
.Handle
;
3049 create_params
.Style
= (int)WindowStyles
.WS_CHILD
| (int)WindowStyles
.WS_CLIPCHILDREN
| (int)WindowStyles
.WS_CLIPSIBLINGS
;
3052 create_params
.Style
|= (int)WindowStyles
.WS_VISIBLE
;
3056 create_params
.Style
|= (int)WindowStyles
.WS_DISABLED
;
3059 switch (border_style
) {
3060 case BorderStyle
.FixedSingle
:
3061 create_params
.Style
|= (int) WindowStyles
.WS_BORDER
;
3063 case BorderStyle
.Fixed3D
:
3064 create_params
.ExStyle
|= (int) WindowExStyles
.WS_EX_CLIENTEDGE
;
3068 return create_params
;
3073 protected virtual Cursor DefaultCursor { get { return Cursors.Default; }
}
3076 protected virtual ImeMode DefaultImeMode
{
3078 return ImeMode
.Inherit
;
3083 protected virtual Padding DefaultMargin
{
3084 get { return new Padding (3); }
3087 protected virtual Size DefaultMaximumSize { get { return new Size (); }
}
3088 protected virtual Size DefaultMinimumSize { get { return new Size (); }
}
3089 protected virtual Padding DefaultPadding { get { return new Padding (); }
}
3092 protected virtual Size DefaultSize
{
3094 return new Size(0, 0);
3098 protected int FontHeight
{
3110 protected bool RenderRightToLeft
{
3112 return (this.right_to_left
== RightToLeft
.Yes
);
3116 protected bool ResizeRedraw
{
3118 return GetStyle(ControlStyles
.ResizeRedraw
);
3122 SetStyle(ControlStyles
.ResizeRedraw
, value);
3126 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3128 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
3129 protected virtual bool ShowFocusCues
{
3135 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3137 [DesignerSerializationVisibility(DesignerSerializationVisibility
.Hidden
)]
3141 protected bool ShowKeyboardCues
{
3146 #endregion // Protected Instance Properties
3148 #region Public Static Methods
3149 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3150 public static Control
FromChildHandle(IntPtr handle
) {
3151 return Control
.ControlNativeWindow
.ControlFromChildHandle (handle
);
3154 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3155 public static Control
FromHandle(IntPtr handle
) {
3156 return Control
.ControlNativeWindow
.ControlFromHandle(handle
);
3159 public static bool IsMnemonic(char charCode
, string text
) {
3162 amp
= text
.IndexOf('&');
3165 if (amp
+ 1 < text
.Length
) {
3166 if (text
[amp
+ 1] != '&') {
3167 if (Char
.ToUpper(charCode
) == Char
.ToUpper(text
.ToCharArray(amp
+ 1, 1)[0])) {
3177 #region Protected Static Methods
3178 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3179 protected static bool ReflectMessage(IntPtr hWnd
, ref Message m
) {
3182 c
= Control
.FromHandle(hWnd
);
3192 #region Public Instance Methods
3193 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3194 public IAsyncResult
BeginInvoke(Delegate method
) {
3195 object [] prms
= null;
3196 if (method
is EventHandler
)
3197 prms
= new object [] { this, EventArgs.Empty }
;
3198 return BeginInvokeInternal(method
, prms
, false);
3201 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3203 public IAsyncResult
BeginInvoke (Delegate method
, params object[] args
)
3205 public IAsyncResult
BeginInvoke (Delegate method
, object[] args
)
3208 return BeginInvokeInternal (method
, args
, false);
3211 public void BringToFront() {
3212 if (parent
!= null) {
3213 parent
.child_controls
.SetChildIndex(this, 0);
3215 else if (IsHandleCreated
) {
3216 XplatUI
.SetZOrder(Handle
, IntPtr
.Zero
, false, false);
3220 public bool Contains(Control ctl
) {
3221 while (ctl
!= null) {
3230 public void CreateControl () {
3232 throw new ObjectDisposedException(GetType().FullName
.ToString());
3238 if (!IsHandleCreated
) {
3246 if (binding_context
== null) { // seem to be sent whenever it's null?
3247 OnBindingContextChanged(EventArgs
.Empty
);
3253 public Graphics
CreateGraphics() {
3254 if (!IsHandleCreated
) {
3255 this.CreateHandle();
3257 return Graphics
.FromHwnd(this.window
.Handle
);
3260 public DragDropEffects
DoDragDrop(object data
, DragDropEffects allowedEffects
) {
3261 if (IsHandleCreated
)
3262 return XplatUI
.StartDrag(Handle
, data
, allowedEffects
);
3264 return DragDropEffects
.None
;
3267 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3268 public object EndInvoke (IAsyncResult async_result
) {
3269 AsyncMethodResult result
= (AsyncMethodResult
) async_result
;
3270 return result
.EndInvoke ();
3273 public Form
FindForm() {
3286 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
3288 public bool Focus() {
3289 if (CanFocus
&& IsHandleCreated
&& !has_focus
&& !is_focusing
) {
3292 is_focusing
= false;
3297 internal void FocusInternal () {
3300 is_focusing
= false;
3303 public Control
GetChildAtPoint(Point pt
) {
3304 // MS's version causes the handle to be created. The stack trace shows that get_Handle is called here, but
3305 // we'll just call CreateHandle instead.
3308 // Microsoft's version of this function doesn't seem to work, so I can't check
3309 // if we only consider children or also grandchildren, etc.
3310 // I'm gonna say 'children only'
3311 for (int i
=0; i
<child_controls
.Count
; i
++) {
3312 if (child_controls
[i
].Bounds
.Contains(pt
)) {
3313 return child_controls
[i
];
3319 public IContainerControl
GetContainerControl() {
3320 Control current
= this;
3322 while (current
!=null) {
3323 if ((current
is IContainerControl
) && ((current
.control_style
& ControlStyles
.ContainerControl
)!=0)) {
3324 return (IContainerControl
)current
;
3326 current
= current
.parent
;
3331 public Control
GetNextControl(Control ctl
, bool forward
) {
3333 if (!this.Contains(ctl
)) {
3338 ctl
= FindControlForward(this, ctl
);
3341 ctl
= FindControlBackward(this, ctl
);
3351 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
3352 public virtual Size
GetPreferredSize (Size proposedSize
) {
3353 Size retsize
= this.explicit_bounds
.Size
;
3355 // If we're bigger than the MaximumSize, fix that
3356 if (this.maximum_size
.Width
!= 0 && retsize
.Width
> this.maximum_size
.Width
)
3357 retsize
.Width
= this.maximum_size
.Width
;
3358 if (this.maximum_size
.Height
!= 0 && retsize
.Height
> this.maximum_size
.Height
)
3359 retsize
.Height
= this.maximum_size
.Height
;
3361 // If we're smaller than the MinimumSize, fix that
3362 if (this.minimum_size
.Width
!= 0 && retsize
.Width
< this.minimum_size
.Width
)
3363 retsize
.Width
= this.minimum_size
.Width
;
3364 if (this.minimum_size
.Height
!= 0 && retsize
.Height
< this.minimum_size
.Height
)
3365 retsize
.Height
= this.minimum_size
.Height
;
3371 public void Hide() {
3372 this.Visible
= false;
3375 public void Invalidate() {
3376 Invalidate(ClientRectangle
, false);
3379 public void Invalidate(bool invalidateChildren
) {
3380 Invalidate(ClientRectangle
, invalidateChildren
);
3383 public void Invalidate(System
.Drawing
.Rectangle rc
) {
3384 Invalidate(rc
, false);
3387 public void Invalidate(System
.Drawing
.Rectangle rc
, bool invalidateChildren
) {
3388 // Win32 invalidates control including when Width and Height is equal 0
3389 // or is not visible, only Paint event must be care about this.
3390 if (!IsHandleCreated
)
3393 if (rc
.Width
> 0 && rc
.Height
> 0) {
3395 NotifyInvalidate(rc
);
3397 XplatUI
.Invalidate(Handle
, rc
, false);
3399 if (invalidateChildren
) {
3400 Control
[] controls
= child_controls
.GetAllControls ();
3401 for (int i
=0; i
<controls
.Length
; i
++)
3402 controls
[i
].Invalidate ();
3405 OnInvalidated(new InvalidateEventArgs(rc
));
3408 public void Invalidate(System
.Drawing
.Region region
) {
3409 Invalidate(region
, false);
3412 public void Invalidate(System
.Drawing
.Region region
, bool invalidateChildren
) {
3413 RectangleF bounds
= region
.GetBounds (CreateGraphics ());
3414 Invalidate (new Rectangle ((int) bounds
.X
, (int) bounds
.Y
, (int) bounds
.Width
, (int) bounds
.Height
),
3415 invalidateChildren
);
3418 public object Invoke (Delegate method
) {
3419 object [] prms
= null;
3420 if (method
is EventHandler
)
3421 prms
= new object [] { this, EventArgs.Empty }
;
3423 return Invoke(method
, prms
);
3426 public object Invoke (Delegate method
, object[] args
) {
3429 if (!p
.IsHandleCreated
)
3430 throw new InvalidOperationException("Cannot call Invoke or BeginInvoke on a control until the window handle is created");
3432 } while (p
!= null);
3434 if (!this.InvokeRequired
) {
3435 return method
.DynamicInvoke(args
);
3438 IAsyncResult result
= BeginInvoke (method
, args
);
3439 return EndInvoke(result
);
3442 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3443 public void PerformLayout() {
3444 PerformLayout(null, null);
3447 internal void SetImplicitBounds (int x
, int y
, int width
, int height
) {
3448 Rectangle saved_bounds
= explicit_bounds
;
3449 SetBounds (x
, y
, width
, height
);
3450 explicit_bounds
= saved_bounds
;
3453 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3454 public void PerformLayout(Control affectedControl
, string affectedProperty
) {
3455 LayoutEventArgs levent
= new LayoutEventArgs(affectedControl
, affectedProperty
);
3457 if (layout_suspended
> 0) {
3458 layout_pending
= true;
3462 layout_pending
= false;
3464 // Prevent us from getting messed up
3467 // Perform all Dock and Anchor calculations
3472 // Need to make sure we decremend layout_suspended
3478 public Point
PointToClient (Point p
) {
3482 XplatUI
.ScreenToClient (Handle
, ref x
, ref y
);
3484 return new Point (x
, y
);
3487 public Point
PointToScreen(Point p
) {
3491 XplatUI
.ClientToScreen(Handle
, ref x
, ref y
);
3493 return new Point(x
, y
);
3496 public virtual bool PreProcessMessage(ref Message msg
) {
3497 return InternalPreProcessMessage (ref msg
);
3500 internal virtual bool InternalPreProcessMessage (ref Message msg
) {
3503 if ((msg
.Msg
== (int)Msg
.WM_KEYDOWN
) || (msg
.Msg
== (int)Msg
.WM_SYSKEYDOWN
)) {
3504 key_data
= (Keys
)msg
.WParam
.ToInt32() | XplatUI
.State
.ModifierKeys
;
3506 if (!ProcessCmdKey(ref msg
, key_data
)) {
3507 if (IsInputKey(key_data
)) {
3511 return ProcessDialogKey(key_data
);
3515 } else if (msg
.Msg
== (int)Msg
.WM_CHAR
) {
3516 if (IsInputChar((char)msg
.WParam
)) {
3519 return ProcessDialogChar((char)msg
.WParam
);
3520 } else if (msg
.Msg
== (int)Msg
.WM_SYSCHAR
) {
3521 return ProcessDialogChar((char)msg
.WParam
);
3526 public Rectangle
RectangleToClient(Rectangle r
) {
3527 return new Rectangle(PointToClient(r
.Location
), r
.Size
);
3530 public Rectangle
RectangleToScreen(Rectangle r
) {
3531 return new Rectangle(PointToScreen(r
.Location
), r
.Size
);
3534 public virtual void Refresh() {
3535 if (IsHandleCreated
&& Visible
) {
3537 XplatUI
.UpdateWindow(window
.Handle
);
3539 Control
[] controls
= child_controls
.GetAllControls ();
3540 for (int i
=0; i
< controls
.Length
; i
++) {
3541 controls
[i
].Refresh();
3547 [EditorBrowsable(EditorBrowsableState
.Never
)]
3548 public virtual void ResetBackColor() {
3549 BackColor
= Color
.Empty
;
3552 [EditorBrowsable(EditorBrowsableState
.Never
)]
3553 public void ResetBindings() {
3554 if (data_bindings
!= null)
3555 data_bindings
.Clear();
3558 [EditorBrowsable(EditorBrowsableState
.Never
)]
3559 public virtual void ResetCursor() {
3563 [EditorBrowsable(EditorBrowsableState
.Never
)]
3564 public virtual void ResetFont() {
3568 [EditorBrowsable(EditorBrowsableState
.Never
)]
3569 public virtual void ResetForeColor() {
3570 foreground_color
= Color
.Empty
;
3573 [EditorBrowsable(EditorBrowsableState
.Never
)]
3574 public void ResetImeMode() {
3575 ime_mode
= DefaultImeMode
;
3578 [EditorBrowsable(EditorBrowsableState
.Never
)]
3579 public virtual void ResetRightToLeft() {
3580 right_to_left
= RightToLeft
.Inherit
;
3583 public virtual void ResetText() {
3584 text
= String
.Empty
;
3587 public void ResumeLayout() {
3588 ResumeLayout (true);
3591 public void ResumeLayout(bool performLayout
) {
3592 if (layout_suspended
> 0) {
3596 if (layout_suspended
== 0) {
3597 if (performLayout
&& layout_pending
) {
3603 [EditorBrowsable (EditorBrowsableState
.Never
)]
3606 public void Scale(float ratio
) {
3607 ScaleCore(ratio
, ratio
);
3611 [EditorBrowsable (EditorBrowsableState
.Never
)]
3614 public void Scale(float dx
, float dy
) {
3619 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
3620 public void Scale(SizeF factor
) {
3621 ScaleCore(factor
.Width
, factor
.Height
);
3625 public void Select() {
3626 Select(false, false);
3630 private void printTree(Control c
, string t
) {
3631 foreach(Control i
in c
.child_controls
) {
3632 Console
.WriteLine ("{2}{0}.TabIndex={1}", i
, i
.tab_index
, t
);
3633 printTree (i
, t
+"\t");
3637 public bool SelectNextControl(Control ctl
, bool forward
, bool tabStopOnly
, bool nested
, bool wrap
) {
3641 Console
.WriteLine("{0}", this.FindForm());
3642 printTree(this, "\t");
3645 if (!this.Contains(ctl
) || (!nested
&& (ctl
.parent
!= this))) {
3650 c
= GetNextControl(c
, forward
);
3659 if (c
.CanSelect
&& ((c
.parent
== this) || nested
) && (c
.tab_stop
|| !tabStopOnly
)) {
3660 c
.Select (true, true);
3663 } while (c
!= ctl
); // If we wrap back to ourselves we stop
3668 public void SendToBack() {
3669 if (parent
!= null) {
3670 parent
.child_controls
.SetChildIndex(this, parent
.child_controls
.Count
);
3674 public void SetBounds(int x
, int y
, int width
, int height
) {
3675 SetBounds(x
, y
, width
, height
, BoundsSpecified
.All
);
3678 public void SetBounds(int x
, int y
, int width
, int height
, BoundsSpecified specified
) {
3679 if ((specified
& BoundsSpecified
.X
) != BoundsSpecified
.X
) {
3683 if ((specified
& BoundsSpecified
.Y
) != BoundsSpecified
.Y
) {
3687 if ((specified
& BoundsSpecified
.Width
) != BoundsSpecified
.Width
) {
3691 if ((specified
& BoundsSpecified
.Height
) != BoundsSpecified
.Height
) {
3695 SetBoundsCore(x
, y
, width
, height
, specified
);
3697 parent
.PerformLayout(this, "Bounds");
3700 public void Show () {
3701 this.Visible
= true;
3704 public void SuspendLayout() {
3708 public void Update() {
3709 if (IsHandleCreated
) {
3710 XplatUI
.UpdateWindow(window
.Handle
);
3713 #endregion // Public Instance Methods
3715 #region Protected Instance Methods
3716 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3717 protected void AccessibilityNotifyClients(AccessibleEvents accEvent
, int childID
) {
3718 // turns out this method causes handle
3719 // creation in 1.1. at first I thought this
3720 // would be accomplished just by using
3721 // get_AccessibilityObject, which would route
3722 // through CreateAccessibilityInstance, which
3723 // calls CreateControl. This isn't the case,
3724 // though (as overriding
3725 // CreateAccessibilityInstance and adding a
3726 // CWL shows nothing. So we fudge it and put
3727 // a CreateHandle here.
3733 if (accessibility_object
!= null && accessibility_object
is ControlAccessibleObject
)
3734 ((ControlAccessibleObject
)accessibility_object
).NotifyClients (accEvent
, childID
);
3737 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3738 protected virtual AccessibleObject
CreateAccessibilityInstance() {
3740 return new Control
.ControlAccessibleObject(this);
3743 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3744 protected virtual ControlCollection
CreateControlsInstance() {
3745 return new ControlCollection(this);
3748 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3749 protected virtual void CreateHandle() {
3751 throw new ObjectDisposedException(GetType().FullName
.ToString());
3754 if (IsHandleCreated
&& !is_recreating
) {
3758 window
.CreateHandle(CreateParams
);
3760 if (window
.Handle
!= IntPtr
.Zero
) {
3761 creator_thread
= Thread
.CurrentThread
;
3763 XplatUI
.EnableWindow(window
.Handle
, is_enabled
);
3765 if (clip_region
!= null) {
3766 XplatUI
.SetClipRegion(window
.Handle
, clip_region
);
3769 // Set our handle with our parent
3770 if ((parent
!= null) && (parent
.IsHandleCreated
)) {
3771 XplatUI
.SetParent(window
.Handle
, parent
.Handle
);
3775 XplatUI
.SetAllowDrop (window
.Handle
, allow_drop
);
3777 // Find out where the window manager placed us
3778 if ((CreateParams
.Style
& (int)WindowStyles
.WS_CHILD
) != 0) {
3779 XplatUI
.SetBorderStyle(window
.Handle
, (FormBorderStyle
)border_style
);
3785 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3786 protected virtual void DefWndProc(ref Message m
) {
3787 window
.DefWndProc(ref m
);
3790 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3791 protected virtual void DestroyHandle() {
3792 if (IsHandleCreated
) {
3793 if (window
!= null) {
3794 window
.DestroyHandle();
3800 protected virtual AccessibleObject
GetAccessibilityObjectById (int objectId
)
3802 // XXX need to implement this.
3807 protected internal bool GetStyle(ControlStyles flag
) {
3808 return (control_style
& flag
) != 0;
3811 protected bool GetTopLevel() {
3815 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3816 protected virtual void InitLayout() {
3820 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3821 protected void InvokeGotFocus(Control toInvoke
, EventArgs e
) {
3822 toInvoke
.OnGotFocus(e
);
3825 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3826 protected void InvokeLostFocus(Control toInvoke
, EventArgs e
) {
3827 toInvoke
.OnLostFocus(e
);
3830 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3831 protected void InvokeOnClick(Control toInvoke
, EventArgs e
) {
3832 toInvoke
.OnClick(e
);
3835 protected void InvokePaint(Control toInvoke
, PaintEventArgs e
) {
3836 toInvoke
.OnPaint(e
);
3839 protected void InvokePaintBackground(Control toInvoke
, PaintEventArgs e
) {
3840 toInvoke
.OnPaintBackground(e
);
3843 protected virtual bool IsInputChar (char charCode
) {
3844 // XXX on MS.NET this method causes the handle to be created..
3850 protected virtual bool IsInputKey (Keys keyData
) {
3851 // Doc says this one calls IsInputChar; not sure what to do with that
3855 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3856 protected virtual void NotifyInvalidate(Rectangle invalidatedArea
) {
3860 protected virtual bool ProcessCmdKey(ref Message msg
, Keys keyData
) {
3861 if ((context_menu
!= null) && context_menu
.ProcessCmdKey(ref msg
, keyData
)) {
3865 if (parent
!= null) {
3866 return parent
.ProcessCmdKey(ref msg
, keyData
);
3872 protected virtual bool ProcessDialogChar(char charCode
) {
3873 if (parent
!= null) {
3874 return parent
.ProcessDialogChar (charCode
);
3880 protected virtual bool ProcessDialogKey (Keys keyData
) {
3881 if (parent
!= null) {
3882 return parent
.ProcessDialogKey (keyData
);
3888 protected virtual bool ProcessKeyEventArgs (ref Message msg
) {
3889 KeyEventArgs key_event
;
3892 case (int)Msg
.WM_SYSKEYDOWN
:
3893 case (int)Msg
.WM_KEYDOWN
: {
3894 key_event
= new KeyEventArgs ((Keys
)msg
.WParam
.ToInt32 ());
3895 OnKeyDown (key_event
);
3896 return key_event
.Handled
;
3899 case (int)Msg
.WM_SYSKEYUP
:
3900 case (int)Msg
.WM_KEYUP
: {
3901 key_event
= new KeyEventArgs ((Keys
)msg
.WParam
.ToInt32 ());
3902 OnKeyUp (key_event
);
3903 return key_event
.Handled
;
3906 case (int)Msg
.WM_SYSCHAR
:
3907 case (int)Msg
.WM_CHAR
: {
3908 KeyPressEventArgs key_press_event
;
3910 key_press_event
= new KeyPressEventArgs((char)msg
.WParam
);
3911 OnKeyPress(key_press_event
);
3913 msg
.WParam
= (IntPtr
)key_press_event
.KeyChar
;
3915 return key_press_event
.Handled
;
3926 protected internal virtual bool ProcessKeyMessage(ref Message msg
) {
3927 if (parent
!= null) {
3928 if (parent
.ProcessKeyPreview(ref msg
)) {
3933 return ProcessKeyEventArgs(ref msg
);
3936 protected virtual bool ProcessKeyPreview(ref Message msg
) {
3937 if (parent
!= null) {
3938 return parent
.ProcessKeyPreview(ref msg
);
3944 protected virtual bool ProcessMnemonic(char charCode
) {
3949 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3950 protected void RaiseDragEvent(object key
, DragEventArgs e
) {
3954 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3955 protected void RaiseKeyEvent(object key
, KeyEventArgs e
) {
3959 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3960 protected void RaiseMouseEvent(object key
, MouseEventArgs e
) {
3964 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3965 protected void RaisePaintEvent(object key
, PaintEventArgs e
) {
3969 private void SetIsRecreating () {
3972 foreach (Control c
in Controls
.GetAllControls()) {
3973 c
.SetIsRecreating ();
3977 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
3978 protected void RecreateHandle() {
3979 if (!IsHandleCreated
)
3983 Console
.WriteLine("Recreating control {0}", XplatUI
.Window(window
.Handle
));
3988 if (IsHandleCreated
) {
3990 Console
.WriteLine(" + handle is created, destroying it.");
3993 // WM_DESTROY will CreateHandle for us
3996 Console
.WriteLine(" + handle is not created, creating it.");
4004 is_recreating
= false;
4006 Console
.WriteLine (" + new handle = {0:X}", Handle
.ToInt32());
4012 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4013 protected void ResetMouseEventArgs() {
4017 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4018 protected ContentAlignment
RtlTranslateAlignment(ContentAlignment align
) {
4019 if (right_to_left
== RightToLeft
.No
) {
4024 case ContentAlignment
.TopLeft
: {
4025 return ContentAlignment
.TopRight
;
4028 case ContentAlignment
.TopRight
: {
4029 return ContentAlignment
.TopLeft
;
4032 case ContentAlignment
.MiddleLeft
: {
4033 return ContentAlignment
.MiddleRight
;
4036 case ContentAlignment
.MiddleRight
: {
4037 return ContentAlignment
.MiddleLeft
;
4040 case ContentAlignment
.BottomLeft
: {
4041 return ContentAlignment
.BottomRight
;
4044 case ContentAlignment
.BottomRight
: {
4045 return ContentAlignment
.BottomLeft
;
4049 // if it's center it doesn't change
4055 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4056 protected HorizontalAlignment
RtlTranslateAlignment(HorizontalAlignment align
) {
4057 if ((right_to_left
== RightToLeft
.No
) || (align
== HorizontalAlignment
.Center
)) {
4061 if (align
== HorizontalAlignment
.Left
) {
4062 return HorizontalAlignment
.Right
;
4065 // align must be HorizontalAlignment.Right
4066 return HorizontalAlignment
.Left
;
4069 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4070 protected LeftRightAlignment
RtlTranslateAlignment(LeftRightAlignment align
) {
4071 if (right_to_left
== RightToLeft
.No
) {
4075 if (align
== LeftRightAlignment
.Left
) {
4076 return LeftRightAlignment
.Right
;
4079 // align must be LeftRightAlignment.Right;
4080 return LeftRightAlignment
.Left
;
4083 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4084 protected ContentAlignment
RtlTranslateContent(ContentAlignment align
) {
4085 return RtlTranslateAlignment(align
);
4088 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4089 protected HorizontalAlignment
RtlTranslateHorizontal(HorizontalAlignment align
) {
4090 return RtlTranslateAlignment(align
);
4093 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4094 protected LeftRightAlignment
RtlTranslateLeftRight(LeftRightAlignment align
) {
4095 return RtlTranslateAlignment(align
);
4099 [EditorBrowsable (EditorBrowsableState
.Never
)]
4101 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4103 protected virtual void ScaleCore(float dx
, float dy
) {
4109 location
= new Point((int)(Left
* dx
), (int)(Top
* dy
));
4110 size
= this.ClientSize
;
4112 if (!GetStyle(ControlStyles
.FixedWidth
)) {
4113 size
.Width
= (int)(size
.Width
* dx
);
4116 if (!GetStyle(ControlStyles
.FixedHeight
)) {
4117 size
.Height
= (int)(size
.Height
* dy
);
4120 SetBounds(location
.X
, location
.Y
, size
.Width
, size
.Height
, BoundsSpecified
.All
);
4122 /* Now scale our children */
4123 Control
[] controls
= child_controls
.GetAllControls ();
4124 for (int i
=0; i
< controls
.Length
; i
++) {
4125 controls
[i
].Scale(dx
, dy
);
4131 protected virtual void Select(bool directed
, bool forward
) {
4132 IContainerControl container
;
4134 container
= GetContainerControl();
4135 if (container
!= null && (Control
)container
!= this)
4136 container
.ActiveControl
= this;
4139 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4140 protected virtual void SetBoundsCore(int x
, int y
, int width
, int height
, BoundsSpecified specified
) {
4141 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
4142 if (IsHandleCreated
) {
4143 XplatUI
.SetWindowPos(Handle
, x
, y
, width
, height
);
4145 // Win32 automatically changes negative width/height to 0.
4146 // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
4147 // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
4149 if (width
< 0 || height
< 0) {
4151 XplatUI
.GetWindowPos(Handle
, this is Form
, out ix
, out iy
, out width
, out height
, out cw
, out ch
);
4155 UpdateBounds(x
, y
, width
, height
);
4160 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4161 protected virtual void SetClientSizeCore(int x
, int y
) {
4162 Size NewSize
= SizeFromClientSize (new Size (x
, y
));
4164 if (NewSize
!= Size
.Empty
)
4165 SetBounds (bounds
.X
, bounds
.Y
, NewSize
.Width
, NewSize
.Height
, BoundsSpecified
.Size
);
4168 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4169 protected internal void SetStyle(ControlStyles flag
, bool value) {
4171 control_style
|= flag
;
4173 control_style
&= ~flag
;
4177 protected void SetTopLevel(bool value) {
4178 if ((GetTopLevel() != value) && (parent
!= null)) {
4179 throw new ArgumentException ("Cannot change toplevel style of a parented control.");
4182 // XXX MS.NET causes handle to be created here
4186 if (value == true) {
4196 is_toplevel
= value;
4199 protected virtual void SetVisibleCore(bool value) {
4200 if (value != is_visible
) {
4203 if (is_visible
&& ((window
.Handle
== IntPtr
.Zero
) || !is_created
)) {
4207 if (IsHandleCreated
) {
4208 XplatUI
.SetVisible(Handle
, is_visible
, true);
4209 // Explicitly move Toplevel windows to where we want them;
4210 // apparently moving unmapped toplevel windows doesn't work
4211 if (is_visible
&& (this is Form
)) {
4212 XplatUI
.SetWindowPos(window
.Handle
, bounds
.X
, bounds
.Y
, bounds
.Width
, bounds
.Height
);
4216 OnVisibleChanged(EventArgs
.Empty
);
4221 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
4227 virtual Size
SizeFromClientSize (Size clientSize
) {
4228 Rectangle ClientRect
;
4229 Rectangle WindowRect
;
4232 ClientRect
= new Rectangle (0, 0, clientSize
.Width
, clientSize
.Height
);
4233 cp
= this.CreateParams
;
4235 if (XplatUI
.CalculateWindowRect (ref ClientRect
, cp
.Style
, cp
.ExStyle
, null, out WindowRect
))
4236 return new Size (WindowRect
.Width
, WindowRect
.Height
);
4241 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4242 protected void UpdateBounds() {
4243 if (!IsHandleCreated
)
4253 XplatUI
.GetWindowPos(this.Handle
, this is Form
, out x
, out y
, out width
, out height
, out client_width
, out client_height
);
4255 UpdateBounds(x
, y
, width
, height
, client_width
, client_height
);
4258 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4259 protected void UpdateBounds(int x
, int y
, int width
, int height
) {
4263 // Calculate client rectangle
4264 rect
= new Rectangle(0, 0, 0, 0);
4267 XplatUI
.CalculateWindowRect(ref rect
, cp
.Style
, cp
.ExStyle
, cp
.menu
, out rect
);
4268 UpdateBounds(x
, y
, width
, height
, width
- (rect
.Right
- rect
.Left
), height
- (rect
.Bottom
- rect
.Top
));
4271 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4272 protected void UpdateBounds(int x
, int y
, int width
, int height
, int clientWidth
, int clientHeight
) {
4273 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
4275 bool resized
= false;
4277 // Needed to generate required notifications
4278 if ((this.bounds
.X
!=x
) || (this.bounds
.Y
!=y
)) {
4282 if ((this.Bounds
.Width
!=width
) || (this.Bounds
.Height
!=height
)) {
4289 bounds
.Height
=height
;
4291 // Assume explicit bounds set. SetImplicitBounds will restore old bounds
4292 explicit_bounds
= bounds
;
4294 client_size
.Width
=clientWidth
;
4295 client_size
.Height
=clientHeight
;
4298 OnLocationChanged(EventArgs
.Empty
);
4300 if (!background_color
.IsEmpty
&& background_color
.A
< byte.MaxValue
)
4305 OnSizeChanged(EventArgs
.Empty
);
4307 OnClientSizeChanged (EventArgs
.Empty
);
4312 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4313 protected void UpdateStyles() {
4314 if (!IsHandleCreated
) {
4318 XplatUI
.SetWindowStyle(window
.Handle
, CreateParams
);
4319 OnStyleChanged(EventArgs
.Empty
);
4322 private void UpdateZOrderOfChild(Control child
) {
4323 if (IsHandleCreated
&& child
.IsHandleCreated
&& (child
.parent
== this)) {
4326 index
= child_controls
.IndexOf(child
);
4329 XplatUI
.SetZOrder(child
.Handle
, child_controls
[index
- 1].Handle
, false, false);
4331 IntPtr after
= AfterTopMostControl ();
4332 if (after
!= IntPtr
.Zero
)
4333 XplatUI
.SetZOrder (child
.Handle
, after
, false, false);
4335 XplatUI
.SetZOrder (child
.Handle
, IntPtr
.Zero
, true, false);
4340 // Override this if there is a control that shall always remain on
4341 // top of other controls (such as scrollbars). If there are several
4342 // of these controls, the bottom-most should be returned.
4343 internal virtual IntPtr
AfterTopMostControl () {
4347 // internal because we need to call it from ScrollableControl.OnVisibleChanged
4348 internal void UpdateChildrenZOrder() {
4349 Control
[] controls
;
4351 if (!IsHandleCreated
) {
4355 // XXX This code is severely broken. It leaks
4356 // the "zero_sized" abstraction out of the X11
4357 // backend and into Control.cs. It'll work on
4358 // windows simply by virtue of windows never
4359 // setting that field to true.
4361 // basically what we need to guard against is
4362 // calling XplatUI.SetZOrder on an hwnd that
4363 // corresponds to an unmapped X window.
4364 controls
= child_controls
.GetAllControls ();
4366 ArrayList children_to_order
= new ArrayList ();
4368 for (int i
= 0; i
< controls
.Length
; i
++) {
4369 if (!controls
[i
].IsHandleCreated
|| !controls
[i
].VisibleInternal
)
4372 Hwnd hwnd
= Hwnd
.ObjectFromHandle (controls
[i
].Handle
);
4373 if (hwnd
.zero_sized
)
4376 children_to_order
.Add (controls
[i
]);
4379 for (int i
= 1; i
< children_to_order
.Count
; i
++) {
4380 Control upper
= (Control
)children_to_order
[i
-1];
4381 Control lower
= (Control
)children_to_order
[i
];
4383 XplatUI
.SetZOrder(lower
.Handle
, upper
.Handle
, false, false);
4387 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4388 protected void UpdateZOrder() {
4389 if (parent
!= null) {
4390 parent
.UpdateZOrderOfChild(this);
4394 protected virtual void WndProc(ref Message m
) {
4396 Console
.WriteLine("Control {0} received message {1}", window
.Handle
== IntPtr
.Zero
? this.Text
: XplatUI
.Window(window
.Handle
), m
.ToString ());
4398 if ((this.control_style
& ControlStyles
.EnableNotifyMessage
) != 0) {
4402 switch((Msg
)m
.Msg
) {
4403 case Msg
.WM_DESTROY
: {
4408 case Msg
.WM_WINDOWPOSCHANGED
: {
4409 WmWindowPosChanged(ref m
);
4413 // Nice description of what should happen when handling WM_PAINT
4414 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4415 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4416 case Msg
.WM_PAINT
: {
4421 // The DefWndProc will never have to handle this, we always paint the background in managed code
4422 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4423 // here but it just makes things more complicated...
4424 case Msg
.WM_ERASEBKGND
: {
4425 WmEraseBackground (ref m
);
4429 case Msg
.WM_LBUTTONUP
: {
4430 WmLButtonUp (ref m
);
4434 case Msg
.WM_LBUTTONDOWN
: {
4435 WmLButtonDown (ref m
);
4439 case Msg
.WM_LBUTTONDBLCLK
: {
4440 WmLButtonDblClick (ref m
);
4444 case Msg
.WM_MBUTTONUP
: {
4445 WmMButtonUp (ref m
);
4449 case Msg
.WM_MBUTTONDOWN
: {
4450 WmMButtonDown (ref m
);
4454 case Msg
.WM_MBUTTONDBLCLK
: {
4455 WmMButtonDblClick (ref m
);
4459 case Msg
.WM_RBUTTONUP
: {
4460 WmRButtonUp (ref m
);
4464 case Msg
.WM_RBUTTONDOWN
: {
4465 WmRButtonDown (ref m
);
4469 case Msg
.WM_RBUTTONDBLCLK
: {
4470 WmRButtonDblClick (ref m
);
4474 case Msg
.WM_CONTEXTMENU
: {
4475 WmContextMenu (ref m
);
4479 case Msg
.WM_MOUSEWHEEL
: {
4480 WmMouseWheel (ref m
);
4485 case Msg
.WM_MOUSEMOVE
: {
4486 WmMouseMove (ref m
);
4490 case Msg
.WM_SHOWWINDOW
: {
4491 WmShowWindow (ref m
);
4495 case Msg
.WM_CREATE
: {
4500 case Msg
.WM_MOUSE_ENTER
: {
4501 WmMouseEnter (ref m
);
4505 case Msg
.WM_MOUSE_LEAVE
: {
4506 WmMouseLeave (ref m
);
4510 case Msg
.WM_MOUSEHOVER
: {
4511 WmMouseHover (ref m
);
4515 case Msg
.WM_SYSKEYUP
: {
4520 case Msg
.WM_SYSKEYDOWN
:
4521 case Msg
.WM_KEYDOWN
:
4523 case Msg
.WM_SYSCHAR
:
4534 case Msg
.WM_KILLFOCUS
: {
4535 WmKillFocus (ref m
);
4539 case Msg
.WM_SETFOCUS
: {
4544 case Msg
.WM_SYSCOLORCHANGE
: {
4545 WmSysColorChange (ref m
);
4549 case Msg
.WM_SETCURSOR
: {
4550 WmSetCursor (ref m
);
4554 case Msg
.WM_CAPTURECHANGED
: {
4555 WmCaptureChanged (ref m
);
4564 #endregion // Public Instance Methods
4568 private void WmDestroy (ref Message m
) {
4569 OnHandleDestroyed(EventArgs
.Empty
);
4571 IntPtr handle
= window
.Handle
;
4573 window
.InvalidateHandle();
4575 if (is_recreating
) {
4577 Console
.WriteLine ("Creating handle for {0:X}", handle
.ToInt32());
4581 Console
.WriteLine (" + new handle = {0:X}", Handle
.ToInt32());
4583 is_recreating
= false;
4587 private void WmWindowPosChanged (ref Message m
) {
4589 Rectangle save_bounds
= explicit_bounds
;
4591 explicit_bounds
= save_bounds
;
4592 if (GetStyle(ControlStyles
.ResizeRedraw
)) {
4599 // Nice description of what should happen when handling WM_PAINT
4600 // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
4601 // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
4602 private void WmPaint (ref Message m
) {
4603 PaintEventArgs paint_event
;
4605 paint_event
= XplatUI
.PaintEventStart(Handle
, true);
4607 if (paint_event
== null) {
4610 DoubleBuffer current_buffer
= null;
4611 if (UseDoubleBuffering
) {
4612 current_buffer
= GetBackBuffer ();
4613 if (!current_buffer
.InvalidRegion
.IsVisible (paint_event
.ClipRectangle
)) {
4614 // Just blit the previous image
4615 current_buffer
.Blit (paint_event
);
4616 XplatUI
.PaintEventEnd (Handle
, true);
4619 current_buffer
.Start (paint_event
);
4622 if (!GetStyle(ControlStyles
.Opaque
)) {
4623 OnPaintBackground(paint_event
);
4626 // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
4627 OnPaintBackgroundInternal(paint_event
);
4629 OnPaintInternal(paint_event
);
4630 if (!paint_event
.Handled
) {
4631 OnPaint(paint_event
);
4634 if (current_buffer
!= null) {
4635 current_buffer
.End (paint_event
);
4639 XplatUI
.PaintEventEnd(Handle
, true);
4643 private void WmEraseBackground (ref Message m
) {
4644 // The DefWndProc will never have to handle this, we always paint the background in managed code
4645 // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
4646 // here but it just makes things more complicated...
4647 m
.Result
= (IntPtr
)1;
4650 private void WmLButtonUp (ref Message m
) {
4653 me
= new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()) | MouseButtons
.Left
,
4655 LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4658 HandleClick(mouse_clicks
, me
);
4661 if (InternalCapture
) {
4662 InternalCapture
= false;
4665 if (mouse_clicks
> 1) {
4670 private void WmLButtonDown (ref Message m
) {
4672 Select (true, true);
4674 InternalCapture
= true;
4675 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
4676 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4680 private void WmLButtonDblClick (ref Message m
) {
4681 InternalCapture
= true;
4683 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
4684 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4688 private void WmMButtonUp (ref Message m
) {
4691 me
= new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()) | MouseButtons
.Middle
,
4693 LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4696 HandleClick(mouse_clicks
, me
);
4698 if (InternalCapture
) {
4699 InternalCapture
= false;
4701 if (mouse_clicks
> 1) {
4706 private void WmMButtonDown (ref Message m
) {
4707 InternalCapture
= true;
4708 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
4709 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4713 private void WmMButtonDblClick (ref Message m
) {
4714 InternalCapture
= true;
4716 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
4717 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4721 private void WmRButtonUp (ref Message m
) {
4725 pt
= new Point(LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()));
4726 pt
= PointToScreen(pt
);
4728 XplatUI
.SendMessage(m
.HWnd
, Msg
.WM_CONTEXTMENU
, m
.HWnd
, (IntPtr
)(pt
.X
+ (pt
.Y
<< 16)));
4730 me
= new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()) | MouseButtons
.Right
,
4732 LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4735 HandleClick(mouse_clicks
, me
);
4738 if (InternalCapture
) {
4739 InternalCapture
= false;
4742 if (mouse_clicks
> 1) {
4747 private void WmRButtonDown (ref Message m
) {
4748 InternalCapture
= true;
4749 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
4750 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4754 private void WmRButtonDblClick (ref Message m
) {
4755 InternalCapture
= true;
4757 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
4758 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4762 private void WmContextMenu (ref Message m
) {
4763 if (context_menu
!= null) {
4766 pt
= new Point(LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()));
4768 if (pt
.X
== -1 || pt
.Y
== -1) {
4769 pt
.X
= (this.Width
/ 2) + this.Left
;
4770 pt
.Y
= (this.Height
/ 2) + this.Top
;
4771 pt
= this.PointToScreen (pt
);
4774 context_menu
.Show (this, PointToClient (pt
));
4779 // If there isn't a regular context menu, show the Strip version
4780 if (context_menu
== null && context_menu_strip
!= null) {
4783 pt
= new Point (LowOrder ((int)m
.LParam
.ToInt32 ()), HighOrder ((int)m
.LParam
.ToInt32 ()));
4785 if (pt
.X
== -1 || pt
.Y
== -1) {
4786 pt
.X
= (this.Width
/ 2) + this.Left
;
4787 pt
.Y
= (this.Height
/2) + this.Top
;
4788 pt
= this.PointToScreen (pt
);
4791 context_menu_strip
.Show (this, PointToClient (pt
));
4798 private void WmCreate (ref Message m
) {
4799 OnHandleCreated(EventArgs
.Empty
);
4802 private void WmMouseWheel (ref Message m
) {
4804 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
4805 mouse_clicks
, LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4806 HighOrder(m
.WParam
.ToInt32())));
4810 private void WmMouseMove (ref Message m
) {
4811 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m
.WParam
.ToInt32()),
4813 LowOrder ((int) m
.LParam
.ToInt32 ()), HighOrder ((int) m
.LParam
.ToInt32 ()),
4817 private void WmMouseEnter (ref Message m
) {
4822 OnMouseEnter(EventArgs
.Empty
);
4825 private void WmMouseLeave (ref Message m
) {
4827 OnMouseLeave(EventArgs
.Empty
);
4830 private void WmMouseHover (ref Message m
) {
4831 OnMouseHover(EventArgs
.Empty
);
4834 private void WmShowWindow (ref Message m
) {
4835 if (m
.WParam
.ToInt32() != 0) {
4836 /* if we're being shown, make sure our child controls all have their handles created */
4837 Control
[] controls
= child_controls
.GetAllControls ();
4838 for (int i
=0; i
<controls
.Length
; i
++) {
4839 if (controls
[i
].is_visible
) {
4840 controls
[i
].CreateControl ();
4841 XplatUI
.SetParent(controls
[i
].Handle
, window
.Handle
);
4846 if (parent
!= null && Focused
) {
4849 // Need to start at parent, GetContainerControl might return ourselves if we're a container
4850 container
= (Control
)parent
.GetContainerControl();
4851 if (container
!= null) {
4852 container
.SelectNextControl(this, true, true, true, true);
4857 if (is_toplevel
) /* XXX make sure this works for mdi forms */
4858 OnVisibleChanged(EventArgs
.Empty
);
4861 private void WmSysKeyUp (ref Message m
) {
4862 if (ProcessKeyMessage(ref m
)) {
4863 m
.Result
= IntPtr
.Zero
;
4867 if ((m
.WParam
.ToInt32() & (int)Keys
.KeyCode
) == (int)Keys
.Menu
) {
4871 if (form
!= null && form
.ActiveMenu
!= null) {
4872 form
.ActiveMenu
.ProcessCmdKey(ref m
, (Keys
)m
.WParam
.ToInt32());
4879 private void WmKeys (ref Message m
) {
4880 if (ProcessKeyMessage(ref m
)) {
4881 m
.Result
= IntPtr
.Zero
;
4887 private void WmHelp (ref Message m
) {
4889 if (m
.LParam
!= IntPtr
.Zero
) {
4892 hi
= new HELPINFO();
4894 hi
= (HELPINFO
) Marshal
.PtrToStructure (m
.LParam
, typeof (HELPINFO
));
4895 mouse_pos
= new Point(hi
.MousePos
.x
, hi
.MousePos
.y
);
4897 mouse_pos
= Control
.MousePosition
;
4899 OnHelpRequested(new HelpEventArgs(mouse_pos
));
4900 m
.Result
= (IntPtr
)1;
4903 private void WmKillFocus (ref Message m
) {
4904 this.has_focus
= false;
4905 OnLostFocus (EventArgs
.Empty
);
4908 private void WmSetFocus (ref Message m
) {
4910 this.has_focus
= true;
4911 OnGotFocus (EventArgs
.Empty
);
4915 private void WmSysColorChange (ref Message m
) {
4916 ThemeEngine
.Current
.ResetDefaults();
4917 OnSystemColorsChanged(EventArgs
.Empty
);
4920 private void WmSetCursor (ref Message m
) {
4921 if ((cursor
== null) || ((HitTest
)(m
.LParam
.ToInt32() & 0xffff) != HitTest
.HTCLIENT
)) {
4926 XplatUI
.SetCursor(window
.Handle
, cursor
.handle
);
4927 m
.Result
= (IntPtr
)1;
4930 private void WmCaptureChanged (ref Message m
) {
4931 is_captured
= false;
4932 OnMouseCaptureChanged (EventArgs
.Empty
);
4933 m
.Result
= (IntPtr
) 0;
4939 #region OnXXX methods
4941 protected virtual void OnAutoSizeChanged (EventArgs e
)
4943 EventHandler eh
= (EventHandler
)(Events
[AutoSizeChangedEvent
]);
4949 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
4950 protected virtual void OnBackColorChanged(EventArgs e
) {
4951 EventHandler eh
= (EventHandler
)(Events
[BackColorChangedEvent
]);
4954 for (int i
=0; i
<child_controls
.Count
; i
++) child_controls
[i
].OnParentBackColorChanged(e
);
4957 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4958 protected virtual void OnBackgroundImageChanged(EventArgs e
) {
4959 EventHandler eh
= (EventHandler
)(Events
[BackgroundImageChangedEvent
]);
4962 for (int i
=0; i
<child_controls
.Count
; i
++) child_controls
[i
].OnParentBackgroundImageChanged(e
);
4966 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
4967 protected virtual void OnBackgroundImageLayoutChanged (EventArgs e
)
4969 EventHandler eh
= (EventHandler
)(Events
[BackgroundImageLayoutChangedEvent
]);
4975 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4976 protected virtual void OnBindingContextChanged(EventArgs e
) {
4977 CheckDataBindings ();
4978 EventHandler eh
= (EventHandler
)(Events
[BindingContextChangedEvent
]);
4981 for (int i
=0; i
<child_controls
.Count
; i
++) child_controls
[i
].OnParentBindingContextChanged(e
);
4984 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4985 protected virtual void OnCausesValidationChanged(EventArgs e
) {
4986 EventHandler eh
= (EventHandler
)(Events
[CausesValidationChangedEvent
]);
4991 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4992 protected virtual void OnChangeUICues(UICuesEventArgs e
) {
4993 UICuesEventHandler eh
= (UICuesEventHandler
)(Events
[ChangeUICuesEvent
]);
4998 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
4999 protected virtual void OnClick(EventArgs e
) {
5000 EventHandler eh
= (EventHandler
)(Events
[ClickEvent
]);
5006 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
5007 protected virtual void OnClientSizeChanged (EventArgs e
)
5009 EventHandler eh
= (EventHandler
)(Events
[ClientSizeChangedEvent
]);
5015 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5016 protected virtual void OnContextMenuChanged(EventArgs e
) {
5017 EventHandler eh
= (EventHandler
)(Events
[ContextMenuChangedEvent
]);
5023 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
5024 protected virtual void OnContextMenuStripChanged (EventArgs e
) {
5025 EventHandler eh
= (EventHandler
)(Events
[ContextMenuStripChangedEvent
]);
5031 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5032 protected virtual void OnControlAdded(ControlEventArgs e
) {
5033 ControlEventHandler eh
= (ControlEventHandler
)(Events
[ControlAddedEvent
]);
5038 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5039 protected virtual void OnControlRemoved(ControlEventArgs e
) {
5040 ControlEventHandler eh
= (ControlEventHandler
)(Events
[ControlRemovedEvent
]);
5045 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5046 protected virtual void OnCreateControl() {
5050 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5051 protected virtual void OnCursorChanged(EventArgs e
) {
5052 EventHandler eh
= (EventHandler
)(Events
[CursorChangedEvent
]);
5057 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5058 protected virtual void OnDockChanged(EventArgs e
) {
5059 EventHandler eh
= (EventHandler
)(Events
[DockChangedEvent
]);
5064 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5065 protected virtual void OnDoubleClick(EventArgs e
) {
5066 EventHandler eh
= (EventHandler
)(Events
[DoubleClickEvent
]);
5071 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5072 protected virtual void OnDragDrop(DragEventArgs drgevent
) {
5073 DragEventHandler eh
= (DragEventHandler
)(Events
[DragDropEvent
]);
5075 eh (this, drgevent
);
5078 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5079 protected virtual void OnDragEnter(DragEventArgs drgevent
) {
5080 DragEventHandler eh
= (DragEventHandler
)(Events
[DragEnterEvent
]);
5082 eh (this, drgevent
);
5085 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5086 protected virtual void OnDragLeave(EventArgs e
) {
5087 EventHandler eh
= (EventHandler
)(Events
[DragLeaveEvent
]);
5092 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5093 protected virtual void OnDragOver(DragEventArgs drgevent
) {
5094 DragEventHandler eh
= (DragEventHandler
)(Events
[DragOverEvent
]);
5096 eh (this, drgevent
);
5099 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5100 protected virtual void OnEnabledChanged(EventArgs e
) {
5101 if (IsHandleCreated
) {
5103 if (((Form
)this).context
== null) {
5104 XplatUI
.EnableWindow(window
.Handle
, Enabled
);
5107 XplatUI
.EnableWindow(window
.Handle
, Enabled
);
5112 EventHandler eh
= (EventHandler
)(Events
[EnabledChangedEvent
]);
5116 for (int i
=0; i
<child_controls
.Count
; i
++) {
5117 child_controls
[i
].OnParentEnabledChanged(e
);
5121 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5122 protected virtual void OnEnter(EventArgs e
) {
5123 EventHandler eh
= (EventHandler
)(Events
[EnterEvent
]);
5128 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5129 protected virtual void OnFontChanged(EventArgs e
) {
5130 EventHandler eh
= (EventHandler
)(Events
[FontChangedEvent
]);
5133 for (int i
=0; i
<child_controls
.Count
; i
++) child_controls
[i
].OnParentFontChanged(e
);
5136 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5137 protected virtual void OnForeColorChanged(EventArgs e
) {
5138 EventHandler eh
= (EventHandler
)(Events
[ForeColorChangedEvent
]);
5141 for (int i
=0; i
<child_controls
.Count
; i
++) child_controls
[i
].OnParentForeColorChanged(e
);
5144 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5145 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent
) {
5146 GiveFeedbackEventHandler eh
= (GiveFeedbackEventHandler
)(Events
[GiveFeedbackEvent
]);
5148 eh (this, gfbevent
);
5151 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5152 protected virtual void OnGotFocus(EventArgs e
) {
5153 EventHandler eh
= (EventHandler
)(Events
[GotFocusEvent
]);
5158 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5159 protected virtual void OnHandleCreated(EventArgs e
) {
5160 EventHandler eh
= (EventHandler
)(Events
[HandleCreatedEvent
]);
5165 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5166 protected virtual void OnHandleDestroyed(EventArgs e
) {
5167 EventHandler eh
= (EventHandler
)(Events
[HandleDestroyedEvent
]);
5172 internal void RaiseHelpRequested (HelpEventArgs hevent
) {
5173 OnHelpRequested (hevent
);
5176 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5177 protected virtual void OnHelpRequested(HelpEventArgs hevent
) {
5178 HelpEventHandler eh
= (HelpEventHandler
)(Events
[HelpRequestedEvent
]);
5183 protected virtual void OnImeModeChanged(EventArgs e
) {
5184 EventHandler eh
= (EventHandler
)(Events
[ImeModeChangedEvent
]);
5189 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5190 protected virtual void OnInvalidated(InvalidateEventArgs e
) {
5191 if (UseDoubleBuffering
) {
5192 // should this block be here? seems like it
5193 // would be more at home in
5194 // NotifyInvalidated..
5195 if (e
.InvalidRect
== ClientRectangle
) {
5196 InvalidateBackBuffer ();
5197 } else if (backbuffer
!= null){
5198 // we need this Inflate call here so
5199 // that the border of the rectangle is
5200 // considered Visible (the
5201 // invalid_region.IsVisible call) in
5202 // the WM_PAINT handling below.
5203 Rectangle r
= Rectangle
.Inflate(e
.InvalidRect
, 1,1);
5204 backbuffer
.InvalidRegion
.Union (r
);
5208 InvalidateEventHandler eh
= (InvalidateEventHandler
)(Events
[InvalidatedEvent
]);
5213 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5214 protected virtual void OnKeyDown(KeyEventArgs e
) {
5215 KeyEventHandler eh
= (KeyEventHandler
)(Events
[KeyDownEvent
]);
5220 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5221 protected virtual void OnKeyPress(KeyPressEventArgs e
) {
5222 KeyPressEventHandler eh
= (KeyPressEventHandler
)(Events
[KeyPressEvent
]);
5227 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5228 protected virtual void OnKeyUp(KeyEventArgs e
) {
5229 KeyEventHandler eh
= (KeyEventHandler
)(Events
[KeyUpEvent
]);
5234 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5235 protected virtual void OnLayout(LayoutEventArgs levent
) {
5236 LayoutEventHandler eh
= (LayoutEventHandler
)(Events
[LayoutEvent
]);
5240 LayoutEngine
.Layout (this, levent
);
5243 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5244 protected virtual void OnLeave(EventArgs e
) {
5245 EventHandler eh
= (EventHandler
)(Events
[LeaveEvent
]);
5250 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5251 protected virtual void OnLocationChanged(EventArgs e
) {
5253 EventHandler eh
= (EventHandler
)(Events
[LocationChangedEvent
]);
5258 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5259 protected virtual void OnLostFocus(EventArgs e
) {
5260 EventHandler eh
= (EventHandler
)(Events
[LostFocusEvent
]);
5266 protected virtual void OnMarginChanged (EventArgs e
)
5268 EventHandler eh
= (EventHandler
)(Events
[MarginChangedEvent
]);
5273 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
5275 protected virtual void OnMouseCaptureChanged (EventArgs e
)
5277 internal virtual void OnMouseCaptureChanged (EventArgs e
)
5280 EventHandler eh
= (EventHandler
)(Events
[MouseCaptureChangedEvent
]);
5286 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
5287 protected virtual void OnMouseClick (MouseEventArgs e
)
5289 MouseEventHandler eh
= (MouseEventHandler
)(Events
[MouseClickEvent
]);
5294 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
5295 protected virtual void OnMouseDoubleClick (MouseEventArgs e
)
5297 MouseEventHandler eh
= (MouseEventHandler
)(Events
[MouseDoubleClickEvent
]);
5303 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5304 protected virtual void OnMouseDown(MouseEventArgs e
) {
5305 MouseEventHandler eh
= (MouseEventHandler
)(Events
[MouseDownEvent
]);
5310 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5311 protected virtual void OnMouseEnter(EventArgs e
) {
5312 EventHandler eh
= (EventHandler
)(Events
[MouseEnterEvent
]);
5317 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5318 protected virtual void OnMouseHover(EventArgs e
) {
5319 EventHandler eh
= (EventHandler
)(Events
[MouseHoverEvent
]);
5324 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5325 protected virtual void OnMouseLeave(EventArgs e
) {
5326 EventHandler eh
= (EventHandler
)(Events
[MouseLeaveEvent
]);
5331 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5332 protected virtual void OnMouseMove(MouseEventArgs e
) {
5333 MouseEventHandler eh
= (MouseEventHandler
)(Events
[MouseMoveEvent
]);
5338 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5339 protected virtual void OnMouseUp(MouseEventArgs e
) {
5340 MouseEventHandler eh
= (MouseEventHandler
)(Events
[MouseUpEvent
]);
5345 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5346 protected virtual void OnMouseWheel(MouseEventArgs e
) {
5347 MouseEventHandler eh
= (MouseEventHandler
)(Events
[MouseWheelEvent
]);
5352 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5353 protected virtual void OnMove(EventArgs e
) {
5354 EventHandler eh
= (EventHandler
)(Events
[MoveEvent
]);
5359 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5360 protected virtual void OnNotifyMessage(Message m
) {
5365 protected virtual void OnPaddingChanged (EventArgs e
) {
5366 EventHandler eh
= (EventHandler
) (Events
[PaddingChangedEvent
]);
5372 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5373 protected virtual void OnPaint(PaintEventArgs e
) {
5374 PaintEventHandler eh
= (PaintEventHandler
)(Events
[PaintEvent
]);
5379 internal virtual void OnPaintBackgroundInternal(PaintEventArgs e
) {
5383 internal virtual void OnPaintInternal(PaintEventArgs e
) {
5387 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5388 protected virtual void OnPaintBackground(PaintEventArgs pevent
) {
5389 PaintControlBackground (pevent
);
5392 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5393 protected virtual void OnParentBackColorChanged(EventArgs e
) {
5394 if (background_color
.IsEmpty
&& background_image
==null) {
5396 OnBackColorChanged(e
);
5400 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5401 protected virtual void OnParentBackgroundImageChanged(EventArgs e
) {
5403 OnBackgroundImageChanged(e
);
5406 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5407 protected virtual void OnParentBindingContextChanged(EventArgs e
) {
5408 if (binding_context
==null) {
5409 binding_context
=Parent
.binding_context
;
5410 OnBindingContextChanged(e
);
5414 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5415 protected virtual void OnParentChanged(EventArgs e
) {
5416 EventHandler eh
= (EventHandler
)(Events
[ParentChangedEvent
]);
5421 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5422 protected virtual void OnParentEnabledChanged(EventArgs e
) {
5424 OnEnabledChanged(e
);
5428 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5429 protected virtual void OnParentFontChanged(EventArgs e
) {
5436 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5437 protected virtual void OnParentForeColorChanged(EventArgs e
) {
5438 if (foreground_color
.IsEmpty
) {
5440 OnForeColorChanged(e
);
5444 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5445 protected virtual void OnParentRightToLeftChanged(EventArgs e
) {
5446 if (right_to_left
==RightToLeft
.Inherit
) {
5448 OnRightToLeftChanged(e
);
5452 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5453 protected virtual void OnParentVisibleChanged(EventArgs e
) {
5455 OnVisibleChanged(e
);
5459 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5460 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e
) {
5461 QueryContinueDragEventHandler eh
= (QueryContinueDragEventHandler
)(Events
[QueryContinueDragEvent
]);
5467 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
5468 protected virtual void OnRegionChanged (EventArgs e
)
5470 EventHandler eh
= (EventHandler
)(Events
[RegionChangedEvent
]);
5476 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5477 protected virtual void OnResize(EventArgs e
) {
5478 PerformLayout(this, "Bounds");
5480 EventHandler eh
= (EventHandler
)(Events
[ResizeEvent
]);
5485 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5486 protected virtual void OnRightToLeftChanged(EventArgs e
) {
5487 EventHandler eh
= (EventHandler
)(Events
[RightToLeftChangedEvent
]);
5490 for (int i
=0; i
<child_controls
.Count
; i
++) child_controls
[i
].OnParentRightToLeftChanged(e
);
5493 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5494 protected virtual void OnSizeChanged(EventArgs e
) {
5495 DisposeBackBuffer ();
5497 EventHandler eh
= (EventHandler
)(Events
[SizeChangedEvent
]);
5502 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5503 protected virtual void OnStyleChanged(EventArgs e
) {
5504 EventHandler eh
= (EventHandler
)(Events
[StyleChangedEvent
]);
5509 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5510 protected virtual void OnSystemColorsChanged(EventArgs e
) {
5511 EventHandler eh
= (EventHandler
)(Events
[SystemColorsChangedEvent
]);
5516 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5517 protected virtual void OnTabIndexChanged(EventArgs e
) {
5518 EventHandler eh
= (EventHandler
)(Events
[TabIndexChangedEvent
]);
5523 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5524 protected virtual void OnTabStopChanged(EventArgs e
) {
5525 EventHandler eh
= (EventHandler
)(Events
[TabStopChangedEvent
]);
5530 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5531 protected virtual void OnTextChanged(EventArgs e
) {
5532 EventHandler eh
= (EventHandler
)(Events
[TextChangedEvent
]);
5537 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5538 protected virtual void OnValidated(EventArgs e
) {
5539 EventHandler eh
= (EventHandler
)(Events
[ValidatedEvent
]);
5544 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5545 protected virtual void OnValidating(System
.ComponentModel
.CancelEventArgs e
) {
5546 CancelEventHandler eh
= (CancelEventHandler
)(Events
[ValidatingEvent
]);
5551 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5552 protected virtual void OnVisibleChanged(EventArgs e
) {
5553 EventHandler eh
= (EventHandler
)(Events
[VisibleChangedEvent
]);
5557 // We need to tell our kids
5558 for (int i
=0; i
<child_controls
.Count
; i
++) {
5559 if (child_controls
[i
].Visible
) {
5560 child_controls
[i
].OnParentVisibleChanged(e
);
5564 #endregion // OnXXX methods
5568 static object AutoSizeChangedEvent
= new object ();
5570 static object BackColorChangedEvent
= new object ();
5571 static object BackgroundImageChangedEvent
= new object ();
5573 static object BackgroundImageLayoutChangedEvent
= new object ();
5575 static object BindingContextChangedEvent
= new object ();
5576 static object CausesValidationChangedEvent
= new object ();
5577 static object ChangeUICuesEvent
= new object ();
5578 static object ClickEvent
= new object ();
5580 static object ClientSizeChangedEvent
= new object ();
5582 static object ContextMenuChangedEvent
= new object ();
5584 static object ContextMenuStripChangedEvent
= new object ();
5586 static object ControlAddedEvent
= new object ();
5587 static object ControlRemovedEvent
= new object ();
5588 static object CursorChangedEvent
= new object ();
5589 static object DockChangedEvent
= new object ();
5590 static object DoubleClickEvent
= new object ();
5591 static object DragDropEvent
= new object ();
5592 static object DragEnterEvent
= new object ();
5593 static object DragLeaveEvent
= new object ();
5594 static object DragOverEvent
= new object ();
5595 static object EnabledChangedEvent
= new object ();
5596 static object EnterEvent
= new object ();
5597 static object FontChangedEvent
= new object ();
5598 static object ForeColorChangedEvent
= new object ();
5599 static object GiveFeedbackEvent
= new object ();
5600 static object GotFocusEvent
= new object ();
5601 static object HandleCreatedEvent
= new object ();
5602 static object HandleDestroyedEvent
= new object ();
5603 static object HelpRequestedEvent
= new object ();
5604 static object ImeModeChangedEvent
= new object ();
5605 static object InvalidatedEvent
= new object ();
5606 static object KeyDownEvent
= new object ();
5607 static object KeyPressEvent
= new object ();
5608 static object KeyUpEvent
= new object ();
5609 static object LayoutEvent
= new object ();
5610 static object LeaveEvent
= new object ();
5611 static object LocationChangedEvent
= new object ();
5612 static object LostFocusEvent
= new object ();
5614 static object MarginChangedEvent
= new object ();
5616 static object MouseCaptureChangedEvent
= new object ();
5618 static object MouseClickEvent
= new object ();
5619 static object MouseDoubleClickEvent
= new object ();
5621 static object MouseDownEvent
= new object ();
5622 static object MouseEnterEvent
= new object ();
5623 static object MouseHoverEvent
= new object ();
5624 static object MouseLeaveEvent
= new object ();
5625 static object MouseMoveEvent
= new object ();
5626 static object MouseUpEvent
= new object ();
5627 static object MouseWheelEvent
= new object ();
5628 static object MoveEvent
= new object ();
5630 static object PaddingChangedEvent
= new object ();
5632 static object PaintEvent
= new object ();
5633 static object ParentChangedEvent
= new object ();
5635 static object PreviewKeyDownEvent
= new object ();
5637 static object QueryAccessibilityHelpEvent
= new object ();
5638 static object QueryContinueDragEvent
= new object ();
5640 static object RegionChangedEvent
= new object ();
5642 static object ResizeEvent
= new object ();
5643 static object RightToLeftChangedEvent
= new object ();
5644 static object SizeChangedEvent
= new object ();
5645 static object StyleChangedEvent
= new object ();
5646 static object SystemColorsChangedEvent
= new object ();
5647 static object TabIndexChangedEvent
= new object ();
5648 static object TabStopChangedEvent
= new object ();
5649 static object TextChangedEvent
= new object ();
5650 static object ValidatedEvent
= new object ();
5651 static object ValidatingEvent
= new object ();
5652 static object VisibleChangedEvent
= new object ();
5656 [EditorBrowsable (EditorBrowsableState
.Never
)]
5657 public event EventHandler AutoSizeChanged
{
5658 add { Events.AddHandler (AutoSizeChangedEvent, value);}
5659 remove {Events.RemoveHandler (AutoSizeChangedEvent, value);}
5662 public event EventHandler BackColorChanged
{
5663 add { Events.AddHandler (BackColorChangedEvent, value); }
5664 remove { Events.RemoveHandler (BackColorChangedEvent, value); }
5667 public event EventHandler BackgroundImageChanged
{
5668 add { Events.AddHandler (BackgroundImageChangedEvent, value); }
5669 remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
5673 public event EventHandler BackgroundImageLayoutChanged
{
5674 add {Events.AddHandler (BackgroundImageLayoutChangedEvent, value);}
5675 remove {Events.RemoveHandler (BackgroundImageLayoutChangedEvent, value);}
5679 public event EventHandler BindingContextChanged
{
5680 add { Events.AddHandler (BindingContextChangedEvent, value); }
5681 remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
5684 public event EventHandler CausesValidationChanged
{
5685 add { Events.AddHandler (CausesValidationChangedEvent, value); }
5686 remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
5689 public event UICuesEventHandler ChangeUICues
{
5690 add { Events.AddHandler (ChangeUICuesEvent, value); }
5691 remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
5694 public event EventHandler Click
{
5695 add { Events.AddHandler (ClickEvent, value); }
5696 remove { Events.RemoveHandler (ClickEvent, value); }
5700 public event EventHandler ClientSizeChanged
{
5701 add {Events.AddHandler (ClientSizeChangedEvent, value);}
5702 remove {Events.RemoveHandler (ClientSizeChangedEvent, value);}
5709 public event EventHandler ContextMenuChanged
{
5710 add { Events.AddHandler (ContextMenuChangedEvent, value); }
5711 remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
5715 public event EventHandler ContextMenuStripChanged
{
5716 add { Events.AddHandler (ContextMenuStripChangedEvent, value); }
5717 remove { Events.RemoveHandler (ContextMenuStripChangedEvent, value);}
5722 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5728 public event ControlEventHandler ControlAdded
{
5729 add { Events.AddHandler (ControlAddedEvent, value); }
5730 remove { Events.RemoveHandler (ControlAddedEvent, value); }
5733 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5739 public event ControlEventHandler ControlRemoved
{
5740 add { Events.AddHandler (ControlRemovedEvent, value); }
5741 remove { Events.RemoveHandler (ControlRemovedEvent, value); }
5744 [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
5745 public event EventHandler CursorChanged
{
5746 add { Events.AddHandler (CursorChangedEvent, value); }
5747 remove { Events.RemoveHandler (CursorChangedEvent, value); }
5749 public event EventHandler DockChanged
{
5750 add { Events.AddHandler (DockChangedEvent, value); }
5751 remove { Events.RemoveHandler (DockChangedEvent, value); }
5754 public event EventHandler DoubleClick
{
5755 add { Events.AddHandler (DoubleClickEvent, value); }
5756 remove { Events.RemoveHandler (DoubleClickEvent, value); }
5759 public event DragEventHandler DragDrop
{
5760 add { Events.AddHandler (DragDropEvent, value); }
5761 remove { Events.RemoveHandler (DragDropEvent, value); }
5764 public event DragEventHandler DragEnter
{
5765 add { Events.AddHandler (DragEnterEvent, value); }
5766 remove { Events.RemoveHandler (DragEnterEvent, value); }
5769 public event EventHandler DragLeave
{
5770 add { Events.AddHandler (DragLeaveEvent, value); }
5771 remove { Events.RemoveHandler (DragLeaveEvent, value); }
5774 public event DragEventHandler DragOver
{
5775 add { Events.AddHandler (DragOverEvent, value); }
5776 remove { Events.RemoveHandler (DragOverEvent, value); }
5779 public event EventHandler EnabledChanged
{
5780 add { Events.AddHandler (EnabledChangedEvent, value); }
5781 remove { Events.RemoveHandler (EnabledChangedEvent, value); }
5784 public event EventHandler Enter
{
5785 add { Events.AddHandler (EnterEvent, value); }
5786 remove { Events.RemoveHandler (EnterEvent, value); }
5789 public event EventHandler FontChanged
{
5790 add { Events.AddHandler (FontChangedEvent, value); }
5791 remove { Events.RemoveHandler (FontChangedEvent, value); }
5794 public event EventHandler ForeColorChanged
{
5795 add { Events.AddHandler (ForeColorChangedEvent, value); }
5796 remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
5799 public event GiveFeedbackEventHandler GiveFeedback
{
5800 add { Events.AddHandler (GiveFeedbackEvent, value); }
5801 remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
5804 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5806 public event EventHandler GotFocus
{
5807 add { Events.AddHandler (GotFocusEvent, value); }
5808 remove { Events.RemoveHandler (GotFocusEvent, value); }
5812 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5814 public event EventHandler HandleCreated
{
5815 add { Events.AddHandler (HandleCreatedEvent, value); }
5816 remove { Events.RemoveHandler (HandleCreatedEvent, value); }
5819 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5821 public event EventHandler HandleDestroyed
{
5822 add { Events.AddHandler (HandleDestroyedEvent, value); }
5823 remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
5826 public event HelpEventHandler HelpRequested
{
5827 add { Events.AddHandler (HelpRequestedEvent, value); }
5828 remove { Events.RemoveHandler (HelpRequestedEvent, value); }
5831 public event EventHandler ImeModeChanged
{
5832 add { Events.AddHandler (ImeModeChangedEvent, value); }
5833 remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
5836 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5838 public event InvalidateEventHandler Invalidated
{
5839 add { Events.AddHandler (InvalidatedEvent, value); }
5840 remove { Events.RemoveHandler (InvalidatedEvent, value); }
5843 public event KeyEventHandler KeyDown
{
5844 add { Events.AddHandler (KeyDownEvent, value); }
5845 remove { Events.RemoveHandler (KeyDownEvent, value); }
5848 public event KeyPressEventHandler KeyPress
{
5849 add { Events.AddHandler (KeyPressEvent, value); }
5850 remove { Events.RemoveHandler (KeyPressEvent, value); }
5853 public event KeyEventHandler KeyUp
{
5854 add { Events.AddHandler (KeyUpEvent, value); }
5855 remove { Events.RemoveHandler (KeyUpEvent, value); }
5858 public event LayoutEventHandler Layout
{
5859 add { Events.AddHandler (LayoutEvent, value); }
5860 remove { Events.RemoveHandler (LayoutEvent, value); }
5863 public event EventHandler Leave
{
5864 add { Events.AddHandler (LeaveEvent, value); }
5865 remove { Events.RemoveHandler (LeaveEvent, value); }
5868 public event EventHandler LocationChanged
{
5869 add { Events.AddHandler (LocationChangedEvent, value); }
5870 remove { Events.RemoveHandler (LocationChangedEvent, value); }
5873 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5875 public event EventHandler LostFocus
{
5876 add { Events.AddHandler (LostFocusEvent, value); }
5877 remove { Events.RemoveHandler (LostFocusEvent, value); }
5881 public event EventHandler MarginChanged
{
5882 add { Events.AddHandler (MarginChangedEvent, value); }
5883 remove {Events.RemoveHandler (MarginChangedEvent, value); }
5887 public event EventHandler MouseCaptureChanged
{
5889 internal event EventHandler MouseCaptureChanged
{
5891 add { Events.AddHandler (MouseCaptureChangedEvent, value); }
5892 remove { Events.RemoveHandler (MouseCaptureChangedEvent, value); }
5895 public event MouseEventHandler MouseClick
5897 add { Events.AddHandler (MouseClickEvent, value); }
5898 remove { Events.RemoveHandler (MouseClickEvent, value); }
5900 public event MouseEventHandler MouseDoubleClick
5902 add { Events.AddHandler (MouseDoubleClickEvent, value); }
5903 remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
5906 public event MouseEventHandler MouseDown
{
5907 add { Events.AddHandler (MouseDownEvent, value); }
5908 remove { Events.RemoveHandler (MouseDownEvent, value); }
5911 public event EventHandler MouseEnter
{
5912 add { Events.AddHandler (MouseEnterEvent, value); }
5913 remove { Events.RemoveHandler (MouseEnterEvent, value); }
5916 public event EventHandler MouseHover
{
5917 add { Events.AddHandler (MouseHoverEvent, value); }
5918 remove { Events.RemoveHandler (MouseHoverEvent, value); }
5921 public event EventHandler MouseLeave
{
5922 add { Events.AddHandler (MouseLeaveEvent, value); }
5923 remove { Events.RemoveHandler (MouseLeaveEvent, value); }
5926 public event MouseEventHandler MouseMove
{
5927 add { Events.AddHandler (MouseMoveEvent, value); }
5928 remove { Events.RemoveHandler (MouseMoveEvent, value); }
5931 public event MouseEventHandler MouseUp
{
5932 add { Events.AddHandler (MouseUpEvent, value); }
5933 remove { Events.RemoveHandler (MouseUpEvent, value); }
5936 [EditorBrowsable(EditorBrowsableState
.Advanced
)]
5938 public event MouseEventHandler MouseWheel
{
5939 add { Events.AddHandler (MouseWheelEvent, value); }
5940 remove { Events.RemoveHandler (MouseWheelEvent, value); }
5943 public event EventHandler Move
{
5944 add { Events.AddHandler (MoveEvent, value); }
5945 remove { Events.RemoveHandler (MoveEvent, value); }
5948 public event EventHandler PaddingChanged
5950 add { Events.AddHandler (PaddingChangedEvent, value); }
5951 remove { Events.RemoveHandler (PaddingChangedEvent, value); }
5954 public event PaintEventHandler Paint
{
5955 add { Events.AddHandler (PaintEvent, value); }
5956 remove { Events.RemoveHandler (PaintEvent, value); }
5959 public event EventHandler ParentChanged
{
5960 add { Events.AddHandler (ParentChangedEvent, value); }
5961 remove { Events.RemoveHandler (ParentChangedEvent, value); }
5965 public event PreviewKeyDownEventHandler PreviewKeyDown
{
5966 add { Events.AddHandler (PreviewKeyDownEvent, value); }
5967 remove { Events.RemoveHandler (PreviewKeyDownEvent, value); }
5971 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp
{
5972 add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
5973 remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
5976 public event QueryContinueDragEventHandler QueryContinueDrag
{
5977 add { Events.AddHandler (QueryContinueDragEvent, value); }
5978 remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
5982 public event EventHandler RegionChanged
{
5983 add { Events.AddHandler (RegionChangedEvent, value); }
5984 remove { Events.RemoveHandler (RegionChangedEvent, value); }
5989 [EditorBrowsable (EditorBrowsableState
.Advanced
)]
5991 public event EventHandler Resize
{
5992 add { Events.AddHandler (ResizeEvent, value); }
5993 remove { Events.RemoveHandler (ResizeEvent, value); }
5996 public event EventHandler RightToLeftChanged
{
5997 add { Events.AddHandler (RightToLeftChangedEvent, value); }
5998 remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
6001 public event EventHandler SizeChanged
{
6002 add { Events.AddHandler (SizeChangedEvent, value); }
6003 remove { Events.RemoveHandler (SizeChangedEvent, value); }
6006 public event EventHandler StyleChanged
{
6007 add { Events.AddHandler (StyleChangedEvent, value); }
6008 remove { Events.RemoveHandler (StyleChangedEvent, value); }
6011 public event EventHandler SystemColorsChanged
{
6012 add { Events.AddHandler (SystemColorsChangedEvent, value); }
6013 remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
6016 public event EventHandler TabIndexChanged
{
6017 add { Events.AddHandler (TabIndexChangedEvent, value); }
6018 remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
6021 public event EventHandler TabStopChanged
{
6022 add { Events.AddHandler (TabStopChangedEvent, value); }
6023 remove { Events.RemoveHandler (TabStopChangedEvent, value); }
6026 public event EventHandler TextChanged
{
6027 add { Events.AddHandler (TextChangedEvent, value); }
6028 remove { Events.RemoveHandler (TextChangedEvent, value); }
6031 public event EventHandler Validated
{
6032 add { Events.AddHandler (ValidatedEvent, value); }
6033 remove { Events.RemoveHandler (ValidatedEvent, value); }
6036 public event CancelEventHandler Validating
{
6037 add { Events.AddHandler (ValidatingEvent, value); }
6038 remove { Events.RemoveHandler (ValidatingEvent, value); }
6041 public event EventHandler VisibleChanged
{
6042 add { Events.AddHandler (VisibleChangedEvent, value); }
6043 remove { Events.RemoveHandler (VisibleChangedEvent, value); }
6046 #endregion // Events