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 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
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
34 // $Log: Control.cs,v $
35 // Revision 1.76 2004/11/05 19:16:48 jackson
36 // Do not call CreateHandle if the handle is already created
38 // Revision 1.75 2004/10/22 17:49:35 jackson
41 // Revision 1.74 2004/10/22 17:41:28 jackson
42 // Check to see if the window should have its background repainted by X when drawing.
44 // Revision 1.73 2004/10/20 03:52:06 pbartok
45 // - Removed unneeded locals
46 // - Added code to all size and location properties to understand and
47 // deal with the parent container of Form
49 // Revision 1.71 2004/10/18 06:27:39 ravindra
50 // Default value of visible property must be true.
52 // Revision 1.70 2004/10/18 04:16:29 pbartok
53 // - Fixed/implemented flat list of controls
55 // Revision 1.69 2004/10/13 02:57:36 pbartok
56 // - Fix from John BouAntoun: Raise ForeColorChanged event when text color is
59 // Revision 1.68 2004/10/06 09:59:05 jordi
60 // removes warnings from compilation
62 // Revision 1.67 2004/10/05 03:18:16 jackson
63 // When resizing the buffers should be invalidated. This should be handled in Control not in derived classes.
65 // Revision 1.66 2004/10/02 19:02:56 pbartok
66 // - Added private method to get the Control object from the window handle
67 // - Implemented ContextMenu property
68 // - Implemented PointToScreen
69 // - Implemented PreProcessMessage
70 // - Implemented IsInputChar
71 // - Implemented IsInputKey
72 // - Implemented ProcessCmdKey
73 // - Completed ProcessKeyEventArgs
74 // - Fixed message loop to call the proper chain of functions on key events
75 // - Implemented ProcessDialogChar
76 // - Implemented ProcessDialogKey
77 // - Implemented ProcessKeyMessage
78 // - Implemented ProcessKeyPreview
79 // - Added RaiseDragEvent stub (MS internal method)
80 // - Added RaiseKeyEvent stub (MS internal method)
81 // - Added RaiseMouseEvent stub (MS Internal method)
82 // - Added RaisePaintEvent stub (MS Internal method)
83 // - Added ResetMouseEventArgs stub (MS Internal method)
84 // - Implemented RtlTranslateAlignment
85 // - Implemented RtlTranslateContent
86 // - Implemented RtlTranslateHorizontal
87 // - Implemented RtlTranslateLeftRight
88 // - Added generation of KeyPress event
90 // Revision 1.65 2004/09/22 18:01:28 jackson
93 // Revision 1.64 2004/09/16 23:44:19 pbartok
94 // - Added SendToBack and BringToFront methods
96 // Revision 1.63 2004/09/11 03:50:00 pbartok
97 // - Added DoDragDrop() [incomplete]
98 // - Properly implemented 'Visible' handling
99 // - Added SetVisibleCore()
100 // - Implemented FindChildAtPoint()
101 // - Implemented GetContainerControl()
102 // - Implemented Hide()
104 // Revision 1.62 2004/09/11 01:28:11 pbartok
105 // - Moved methods into their appropriate #regions
106 // - Reordered methods within regions alphabetically
108 // Revision 1.61 2004/09/11 00:56:33 pbartok
109 // - Moved some internal functions into the internal region
110 // - Implemented FontHeight
111 // - Implemented RenderRightToLeft
112 // - Implemented ResizeRedraw
113 // - Implemented ShowFocusCues
114 // - Implemented ShowKeyboardCues
115 // - Implemented FromChildHandle
116 // - Implemented FromHandle
117 // - Implemented IsMnemonic
118 // - Implemented ReflectMessage
119 // - All public and protected Static Methods are now complete
121 // Revision 1.60 2004/09/10 22:54:52 pbartok
122 // - Implemented remaining missing public instance properties
123 // - Alphabetized some out of order properties
125 // Revision 1.59 2004/09/06 12:55:07 jordi
126 // Caches ClientRectangle rectangle value
128 // Revision 1.58 2004/09/02 22:24:50 pbartok
129 // - Added sanity check to creation of double buffer bitmap
131 // Revision 1.57 2004/09/02 20:26:21 pbartok
132 // - Added missing Control.ControlAccessibleObject class
133 // - Started to implement Select()ion mechanisms, still very incomplete
135 // Revision 1.56 2004/09/01 13:19:19 jordi
136 // Init string variables with an empty object
138 // Revision 1.55 2004/09/01 10:20:57 jordi
139 // fires OnFontChanged event
141 // Revision 1.54 2004/09/01 01:41:31 pbartok
142 // - Added firing of BackColorChanged event
143 // - Added TopLevelControl property
144 // - Fixed handling of WM_ERASEBKGRND message
146 // Revision 1.53 2004/08/27 20:17:25 pbartok
147 // - Removed unneeded stack vars
148 // - First attempt to fix sizing issues when layout is suspended
150 // Revision 1.52 2004/08/25 19:20:47 pbartok
151 // - Control now properly passes the ambient background color to child
154 // Revision 1.51 2004/08/25 18:32:15 pbartok
155 // - Fixed generation of MouseUp message
157 // Revision 1.50 2004/08/24 18:24:25 jordi
158 // fire OnEnabledChanged event
160 // Revision 1.49 2004/08/23 21:22:53 pbartok
161 // - Added InitLayout() method
162 // - Added code to properly perform layout when Anchor or Dock property is
164 // - Changed 'interpretation' of ResumeLayout. MS seems to have a LAMESPEC,
165 // tried to do it in a way that makes sense
167 // Revision 1.48 2004/08/23 19:55:08 pbartok
168 // - Properly fixed Jordi's last fix
169 // - Now uses Cursor's Position property instead of calling XplatUI directly
171 // Revision 1.47 2004/08/23 19:16:23 jordi
172 // avoids null exception
174 // Revision 1.46 2004/08/22 21:10:30 pbartok
175 // - Removed OverlappedWindow style from Control, instead it's default
177 // - Made form windows OverlappedWindow by default
179 // Revision 1.45 2004/08/21 22:19:30 pbartok
182 // Revision 1.44 2004/08/21 20:53:13 pbartok
183 // - Updated to match new GrabWindow signature
185 // Revision 1.43 2004/08/21 19:32:15 pbartok
186 // - Implemented Created property
188 // Revision 1.42 2004/08/21 19:28:22 pbartok
189 // - Implemented ContainsFocus
191 // Revision 1.41 2004/08/21 19:26:24 pbartok
192 // - Implemented CausesValidation
194 // Revision 1.40 2004/08/21 19:21:50 pbartok
195 // - Implemented CanFocus
196 // - Implemented CanSelect
197 // - Implemented Capture
199 // Revision 1.39 2004/08/21 16:54:11 jackson
200 // Implement EndInvoke
202 // Revision 1.38 2004/08/20 23:38:54 ravindra
203 // Made RightToLeft property virtual and removed a Console.WriteLine.
205 // Revision 1.37 2004/08/20 20:09:24 pbartok
206 // - Added call to set window background color
208 // Revision 1.36 2004/08/20 19:18:30 jackson
209 // Implement Begininvoke
211 // Revision 1.35 2004/08/20 01:17:24 pbartok
212 // - Added handling of WM_MOUSEHOVER
213 // - Worked around 'bug' in Win32 WM_MOUSE_ENTER/WM_MOUSE_LEAVE driver code
215 // Revision 1.34 2004/08/19 23:09:22 pbartok
216 // - Added Right property
217 // - Added RightToLeft property
219 // Revision 1.33 2004/08/19 22:25:31 jordi
220 // theme enhancaments
222 // Revision 1.32 2004/08/17 21:25:12 pbartok
223 // - Drawing improvement; don't call UpdateBounds if we are not visible (or
224 // have been minimized)
226 // Revision 1.31 2004/08/17 20:25:28 pbartok
227 // - Fixed broken handling of default window sizes
229 // Revision 1.30 2004/08/16 21:47:11 pbartok
230 // - Added handling of WM_MOUSE_ENTER & WM_MOUSE_LEAVE to
231 // support OnMouseEnter/Leave()
232 // - Added WS_CLIPSIBLINGS and WS_CLIPCHILDREN window styles to improve
235 // Revision 1.29 2004/08/13 22:15:46 pbartok
236 // - Fixed Anchor default
238 // Revision 1.28 2004/08/13 21:43:39 pbartok
239 // - Changed GetCursorPos signature
241 // Revision 1.27 2004/08/13 19:00:15 jordi
242 // implements PointToClient (ScreenToClient)
244 // Revision 1.26 2004/08/13 18:52:07 pbartok
245 // - Added Dispose() and destructor
246 // - Fixed resizing and bounds calculation
248 // - Added memory savings for invisible windows
250 // Revision 1.25 2004/08/12 19:31:19 pbartok
251 // - Fixed Anchoring bugs
253 // Revision 1.24 2004/08/12 16:10:42 jackson
254 // Add missing properties
256 // Revision 1.23 2004/08/11 22:20:59 pbartok
259 // Revision 1.22 2004/08/11 19:19:44 pbartok
260 // - We had SetWindowPos and MoveWindow to set window positions and size,
261 // removed MoveWindow. We have GetWindowPos, so it made sense to keep
262 // SetWindowPos as matching counterpart
263 // - Added some X11 sanity checking
265 // Revision 1.21 2004/08/11 18:59:45 pbartok
266 // - Major cleanup of my SetBounds/SetBoundsCore/UpdateBounds mess
267 // (It seems that SetBounds is just a front for SetBoundsCore and
268 // SetBoundsCore updates the underlying window system and UpdateBounds is
269 // responsible for updating the variables associated with the Control and
270 // sending the events)
271 // - Major cleanup of Size handling; we now have two sizes, client_size and
272 // bounds. Bounds defines the window with decorations, client_size without
275 // Revision 1.20 2004/08/11 15:13:32 pbartok
276 // - Now properly reparents windows
278 // Revision 1.19 2004/08/11 14:37:11 pbartok
281 // Revision 1.18 2004/08/11 13:47:22 pbartok
282 // - Rewrote the collection stuff. Might not be as fast now, not keeping
283 // the number of children around and accessible directly, but it's more
286 // Revision 1.17 2004/08/10 18:32:10 jordi
287 // throw ontextchange event
289 // Revision 1.16 2004/08/10 17:43:04 pbartok
290 // - Added more to the still unfinished Dock/Anchor layout code
292 // Revision 1.15 2004/08/10 15:08:05 jackson
293 // Control will now handle the buffering code, so each control does not have to implement this.
295 // Revision 1.14 2004/08/09 22:11:25 pbartok
296 // - Added incomplete dock layout code
297 // - Added support for mouse wheel
299 // Revision 1.13 2004/08/09 17:25:56 jackson
300 // Use new color names
302 // Revision 1.12 2004/08/09 15:54:51 jackson
303 // Get default properties from the theme.
305 // Revision 1.11 2004/08/06 21:30:56 pbartok
306 // - Fixed recursive loop when resizing
307 // - Improved/fixed redrawing on expose messages
309 // Revision 1.10 2004/08/06 15:53:39 jordi
310 // X11 keyboard navigation
312 // Revision 1.9 2004/08/04 21:14:26 pbartok
313 // - Fixed Invalidation bug (calculated wrong client area)
314 // - Added ClientSize setter
316 // Revision 1.8 2004/08/04 20:11:24 pbartok
317 // - Added Invalidate handling
319 // Revision 1.7 2004/07/27 10:38:17 jordi
320 // changes to be able to run winforms samples
322 // Revision 1.6 2004/07/19 19:09:42 jordi
323 // label control re-written: added missing functionlity, events, and properties
325 // Revision 1.5 2004/07/19 16:49:23 jordi
326 // fixes SetBounds logic
328 // Revision 1.4 2004/07/19 07:29:35 jordi
329 // Call RefreshWindow only if the window has created
331 // Revision 1.3 2004/07/15 17:03:35 jordi
332 // added basic mouse handeling events
334 // Revision 1.2 2004/07/13 15:31:45 jordi
335 // commit: new properties and fixes form size problems
337 // Revision 1.1 2004/07/09 05:21:25 pbartok
338 // - Initial check-in
345 using System.Drawing;
346 using System.ComponentModel;
347 using System.Collections;
348 using System.Diagnostics;
349 using System.Threading;
350 using System.Runtime.InteropServices;
352 namespace System.Windows.Forms
354 public class Control : Component, ISynchronizeInvoke, IWin32Window
356 #region Local Variables
359 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
360 internal object creator_thread; // thread that created the control
361 internal ControlNativeWindow window; // object for native window handle
362 internal string name; // for object naming
365 internal bool has_focus; // true if control has focus
366 internal bool is_visible; // true if control is visible
367 internal bool is_entered; // is the mouse inside the control?
368 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
369 internal bool is_selected; // true if control is selected
370 internal bool is_accessible; // true if the control is visible to accessibility applications
371 internal bool is_captured; // tracks if the control has captured the mouse
372 internal bool is_recreating; // tracks if the handle for the control is being recreated
373 internal bool causes_validation; // tracks if validation is executed on changes
374 internal int tab_index; // position in tab order of siblings
375 internal bool tab_stop = true; // is the control a tab stop?
376 internal bool is_disposed; // has the window already been disposed?
377 internal Size client_size; // size of the client area (window excluding decorations)
378 internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
379 internal ControlStyles control_style; // rather win32-specific, style bits for control
380 internal ImeMode ime_mode = ImeMode.Inherit;
381 internal bool layout_pending; // true if our parent needs to re-layout us
382 internal object control_tag; // object that contains data about our control
383 internal int mouse_clicks; // Counter for mouse clicks
387 internal Color foreground_color; // foreground color for control
388 internal Color background_color; // background color for control
389 internal Image background_image; // background image for control
390 internal Font font; // font for control
391 internal string text; // window/title text for control
394 internal AnchorStyles anchor_style; // anchoring requirements for our control
395 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
396 internal SizeF size_ratio; // size ratio of our control to it's parent; required for anchoring
397 internal Size prev_size; // previous size of the control; required for anchoring
399 // to be categorized...
400 static internal ArrayList controls = new ArrayList(); // All of the applications controls, in a flat list
401 internal ControlCollection child_controls; // our children
402 internal Control parent; // our parent control
403 internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
404 internal BindingContext binding_context; // TODO
405 internal RightToLeft right_to_left; // drawing direction for control
406 internal int layout_suspended;
407 internal bool double_buffering;
408 internal ContextMenu context_menu; // Context menu associated with the control
410 private Graphics dc_mem; // Graphics context for double buffering
411 private Bitmap bmp_mem; // Bitmap for double buffering control
413 #endregion // Local Variables
415 #region Private Classes
416 // This helper class allows us to dispatch messages to Control.WndProc
417 internal class ControlNativeWindow : NativeWindow {
418 private Control control;
420 public ControlNativeWindow(Control control) : base() {
421 this.control=control;
424 static internal Control ControlFromHandle(IntPtr hWnd) {
425 ControlNativeWindow window;
427 window = (ControlNativeWindow)window_collection[hWnd];
429 return window.control;
432 protected override void WndProc(ref Message m) {
433 control.WndProc(ref m);
438 #region Public Classes
439 public class ControlAccessibleObject : AccessibleObject {
440 #region ControlAccessibleObject Local Variables
441 private Control owner;
442 #endregion // ControlAccessibleObject Local Variables
444 #region ControlAccessibleObject Constructors
445 public ControlAccessibleObject(Control ownerControl) {
446 this.owner = ownerControl;
448 #endregion // ControlAccessibleObject Constructors
450 #region ControlAccessibleObject Public Instance Properties
451 public override string DefaultAction {
453 return base.DefaultAction;
457 public override string Description {
459 return base.Description;
463 public IntPtr Handle {
469 // We don't want to let them set it
473 public override string Help {
479 public override string KeyboardShortcut {
481 return base.KeyboardShortcut;
485 public override string Name {
495 public Control Owner {
501 public override AccessibleRole Role {
506 #endregion // ControlAccessibleObject Public Instance Properties
508 #region ControlAccessibleObject Public Instance Methods
509 public override int GetHelpTopic(out string FileName) {
510 return base.GetHelpTopic (out FileName);
513 #endregion // ControlAccessibleObject Public Instance Methods
516 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
517 #region ControlCollection Local Variables
518 internal ArrayList list;
519 internal Control owner;
520 #endregion // ControlCollection Local Variables
522 #region ControlCollection Public Constructor
523 public ControlCollection(Control owner) {
525 this.list=new ArrayList();
529 #region ControlCollection Public Instance Properties
536 public bool IsReadOnly {
538 return list.IsReadOnly;
542 public virtual Control this[int index] {
544 if (index < 0 || index >= list.Count) {
545 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
547 return (Control)list[index];
550 #endregion // ControlCollection Public Instance Properties
552 #region ControlCollection Private Instance Methods
553 public virtual void Add (Control value)
556 for (int i = 0; i < list.Count; i++) {
557 if (list [i] == value) {
558 // Do we need to do anything here?
563 value.Parent = owner;
566 public virtual void AddRange (Control[] controls)
568 if (controls == null)
569 throw new ArgumentNullException ("controls");
571 owner.SuspendLayout ();
574 for (int i = 0; i < controls.Length; i++)
577 owner.ResumeLayout ();
581 public virtual void Clear ()
583 owner.SuspendLayout();
585 owner.ResumeLayout();
588 public virtual bool Contains (Control value)
590 return list.Contains (value);
593 public void CopyTo (Array array, int index)
595 list.CopyTo(array, index);
598 public override bool Equals(object other) {
599 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
606 public int GetChildIndex(Control child) {
607 return GetChildIndex(child, false);
610 public int GetChildIndex(Control child, bool throwException) {
613 index=list.IndexOf(child);
615 if (index==-1 && throwException) {
616 throw new ArgumentException("Not a child control", "child");
621 public IEnumerator GetEnumerator() {
622 return list.GetEnumerator();
625 public override int GetHashCode() {
626 return base.GetHashCode();
629 public int IndexOf(Control control) {
630 return list.IndexOf(control);
633 public virtual void Remove(Control value) {
637 public void RemoveAt(int index) {
638 if (index<0 || index>=list.Count) {
639 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
642 list.RemoveAt(index);
645 public void SetChildIndex(Control child, int newIndex) {
648 old_index=list.IndexOf(child);
650 throw new ArgumentException("Not a child control", "child");
653 if (old_index==newIndex) {
659 if (newIndex>list.Count) {
662 list.Insert(newIndex, child);
665 #endregion // ControlCollection Private Instance Methods
667 #region ControlCollection Interface Properties
668 object IList.this[int index] {
670 if (index<0 || index>=list.Count) {
671 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
677 if (!(value is Control)) {
678 throw new ArgumentException("Object of type Control required", "value");
681 list[index]=(Control)value;
685 bool IList.IsFixedSize {
691 bool IList.IsReadOnly {
693 return list.IsReadOnly;
697 bool ICollection.IsSynchronized {
699 return list.IsSynchronized;
703 object ICollection.SyncRoot {
705 return list.SyncRoot;
708 #endregion // ControlCollection Interface Properties
710 #region ControlCollection Interface Methods
711 int IList.Add(object value) {
713 throw new ArgumentNullException("value", "Cannot add null controls");
716 if (!(value is Control)) {
717 throw new ArgumentException("Object of type Control required", "value");
720 return list.Add(value);
723 bool IList.Contains(object value) {
724 if (!(value is Control)) {
725 throw new ArgumentException("Object of type Control required", "value");
728 return this.Contains((Control) value);
731 int IList.IndexOf(object value) {
732 if (!(value is Control)) {
733 throw new ArgumentException("Object of type Control required", "value");
736 return this.IndexOf((Control) value);
739 void IList.Insert(int index, object value) {
740 if (!(value is Control)) {
741 throw new ArgumentException("Object of type Control required", "value");
743 list.Insert(index, value);
746 void IList.Remove(object value) {
747 if (!(value is Control)) {
748 throw new ArgumentException("Object of type Control required", "value");
753 void ICollection.CopyTo(Array array, int index) {
755 list.CopyTo(array, index);
759 Object ICloneable.Clone() {
760 ControlCollection clone = new ControlCollection(this.owner);
761 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
764 #endregion // ControlCollection Interface Methods
766 #endregion // ControlCollection Class
768 #region Public Constructors
770 creator_thread = Thread.CurrentThread;
772 child_controls = CreateControlsInstance();
773 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
774 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
775 XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, false, out bounds);
776 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
780 prev_size = Size.Empty;
781 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
788 layout_pending = false;
789 causes_validation = true;
791 layout_suspended = 0;
792 double_buffering = true;
796 background_image = null;
801 public Control(Control parent, string text) : this() {
806 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
811 bounds.Height=height;
812 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
816 public Control(string text) : this() {
820 public Control(string text, int left, int top, int width, int height) : this() {
824 bounds.Height=height;
825 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
829 protected override void Dispose(bool disposing) {
842 controls.Remove(this);
844 #endregion // Public Constructors
846 #region Internal Properties
847 #endregion // Internal Properties
849 #region Private & Internal Methods
850 internal static IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
851 AsyncMethodResult result = new AsyncMethodResult ();
852 AsyncMethodData data = new AsyncMethodData ();
854 data.Method = method;
856 data.Result = new WeakReference (result);
858 XplatUI.SendAsyncMethod (data);
862 internal Graphics DeviceContext {
865 CreateBuffers(this.Width, this.Height);
871 internal Bitmap ImageBuffer {
874 CreateBuffers(this.Width, this.Height);
880 internal void CreateBuffers (int width, int height) {
881 if (double_buffering == false)
897 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
898 dc_mem = Graphics.FromImage (bmp_mem);
901 internal void InvalidateBuffers ()
903 if (double_buffering == false)
915 internal static void SetChildColor(Control parent) {
918 for (int i=0; i < parent.child_controls.Count; i++) {
919 child=parent.child_controls[i];
920 if (child.IsHandleCreated) {
921 XplatUI.SetWindowBackground(child.window.Handle, child.BackColor);
923 if (child.child_controls.Count>0) {
924 SetChildColor(child);
930 private bool Select(Control control) {
933 if (control == null) {
937 parent = control.parent;
939 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
940 while (parent != null) {
941 if (!parent.is_visible || !parent.is_enabled) {
947 control.is_selected = true;
953 private Control FindTabStop(Control control, bool forward) {
954 if (control == null) {
962 internal virtual void DoDefaultAction() {
963 // Only here to be overriden by our actual controls; this is needed by the accessibility class
966 internal static int LowOrder (int param) {
967 return (param & 0xffff);
970 internal static int HighOrder (int param) {
971 return (param >> 16);
974 internal static MouseButtons FromParamToMouseButtons (int param) {
975 MouseButtons buttons = MouseButtons.None;
977 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
978 buttons |= MouseButtons.Left;
980 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
981 buttons |= MouseButtons.Middle;
983 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
984 buttons |= MouseButtons.Right;
989 #endregion // Private & Internal Methods
991 #region Public Static Properties
992 public static Color DefaultBackColor {
994 return ThemeEngine.Current.DefaultControlBackColor;
998 public static Font DefaultFont {
1000 return ThemeEngine.Current.DefaultFont;
1004 public static Color DefaultForeColor {
1006 return ThemeEngine.Current.DefaultControlForeColor;
1010 public static Keys ModifierKeys {
1012 return XplatUI.State.ModifierKeys;
1016 public static MouseButtons MouseButtons {
1018 return XplatUI.State.MouseButtons;
1022 public static Point MousePosition {
1024 return Cursor.Position;
1027 #endregion // Public Static Properties
1029 #region Public Instance Properties
1030 public AccessibleObject AccessibilityObject {
1032 if (accessibility_object==null) {
1033 accessibility_object=CreateAccessibilityInstance();
1035 return accessibility_object;
1039 public string AccessibleDefaultActionDescription {
1041 return AccessibilityObject.default_action;
1045 AccessibilityObject.default_action=value;
1049 public string AccessibleDescription {
1051 return AccessibilityObject.description;
1055 AccessibilityObject.description=value;
1059 public string AccessibleName {
1061 return AccessibilityObject.Name;
1065 AccessibilityObject.Name=value;
1069 public AccessibleRole AccessibleRole {
1071 return AccessibilityObject.role;
1075 AccessibilityObject.role=value;
1079 public virtual bool AllowDrop {
1081 return XplatUI.State.DropTarget;
1085 XplatUI.State.DropTarget=value;
1089 public virtual AnchorStyles Anchor {
1091 return anchor_style;
1097 if (parent != null) {
1098 parent.PerformLayout(this, "Parent");
1103 public virtual Color BackColor {
1105 if (background_color.IsEmpty) {
1107 return parent.BackColor;
1109 return DefaultBackColor;
1111 return background_color;
1115 background_color=value;
1116 if (this.IsHandleCreated) {
1117 XplatUI.SetWindowBackground(this.window.Handle, value);
1119 SetChildColor(this);
1120 OnBackColorChanged(EventArgs.Empty);
1125 public virtual Image BackgroundImage {
1127 return background_image;
1131 if (background_image!=value) {
1132 background_image=value;
1133 OnBackgroundImageChanged(EventArgs.Empty);
1138 public virtual BindingContext BindingContext {
1140 throw new NotImplementedException();
1144 throw new NotImplementedException();
1150 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1151 return ((Form)this).form_parent_window.Bottom;
1154 return bounds.Y+bounds.Height;
1158 public Rectangle Bounds {
1164 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1168 public bool CanFocus {
1170 if (is_visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1177 public bool CanSelect {
1181 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1185 parent = this.parent;
1186 while (parent != null) {
1187 if (!parent.is_visible || !parent.is_enabled) {
1191 parent = parent.parent;
1197 public bool Capture {
1199 return this.is_captured;
1203 if (this.IsHandleCreated) {
1204 if (value && !is_captured) {
1206 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1207 } else if (!value && is_captured) {
1208 XplatUI.ReleaseWindow(this.window.Handle);
1209 is_captured = false;
1215 public bool CausesValidation {
1217 return this.causes_validation;
1221 if (this.causes_validation != value) {
1222 causes_validation = value;
1223 OnCausesValidationChanged(EventArgs.Empty);
1228 public Rectangle ClientRectangle {
1230 client_rect.Width = client_size.Width;
1231 client_rect.Height = client_size.Height;
1236 public Size ClientSize {
1239 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1240 return ((Form)this).form_parent_window.ClientSize;
1248 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1249 ((Form)this).form_parent_window.ClientSize = value;
1253 this.SetClientSizeCore(value.Width, value.Height);
1257 public String CompanyName {
1259 return "Mono Project, Novell, Inc.";
1263 public bool ContainsFocus {
1269 for (int i=0; i < child_controls.Count; i++) {
1270 if (child_controls[i].Focused) {
1277 public virtual ContextMenu ContextMenu {
1279 return context_menu;
1283 if (context_menu != value) {
1284 context_menu = value;
1285 OnContextMenuChanged(EventArgs.Empty);
1290 public ControlCollection Controls {
1292 return this.child_controls;
1296 public bool Created {
1298 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1306 public virtual Cursor Cursor {
1308 throw new NotImplementedException();
1312 throw new NotImplementedException();
1316 public ControlBidingsCollection DataBindings {
1318 throw new NotImplementedException();
1322 public virtual Rectangle DisplayRectangle {
1324 return ClientRectangle;
1328 public bool Disposing {
1334 public virtual DockStyle Dock {
1340 if (dock_style == value) {
1346 if (parent != null) {
1347 parent.PerformLayout(this, "Parent");
1350 OnDockChanged(EventArgs.Empty);
1354 public bool Enabled {
1360 if (is_enabled == value) {
1366 OnEnabledChanged (EventArgs.Empty);
1370 public virtual bool Focused {
1372 return this.has_focus;
1376 public virtual Font Font {
1382 if (Parent != null && Parent.Font != null) {
1390 if (font == value) {
1396 OnFontChanged (EventArgs.Empty);
1400 public virtual Color ForeColor {
1402 if (foreground_color.IsEmpty) {
1404 return parent.ForeColor;
1406 return DefaultForeColor;
1408 return foreground_color;
1412 if (foreground_color != value) {
1413 foreground_color=value;
1415 OnForeColorChanged(EventArgs.Empty);
1420 public IntPtr Handle { // IWin32Window
1422 if (!IsHandleCreated) {
1425 return window.Handle;
1429 public bool HasChildren {
1431 if (this.child_controls.Count>0) {
1440 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1441 return ((Form)this).form_parent_window.Height;
1443 return this.bounds.Height;
1447 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1448 ((Form)this).form_parent_window.Height = value;
1452 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1456 public ImeMode ImeMode {
1466 public bool InvokeRequired { // ISynchronizeInvoke
1468 if (creator_thread!=Thread.CurrentThread) {
1475 public bool IsAccessible {
1477 return is_accessible;
1481 is_accessible = value;
1485 public bool IsDisposed {
1487 return this.is_disposed;
1491 public bool IsHandleCreated {
1493 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1503 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1504 return ((Form)this).form_parent_window.Left;
1507 return this.bounds.X;
1511 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1512 ((Form)this).form_parent_window.Left = value;
1516 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1520 public Point Location {
1522 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1523 return ((Form)this).form_parent_window.Location;
1525 return new Point(bounds.X, bounds.Y);
1529 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1530 ((Form)this).form_parent_window.Location = value;
1534 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1538 public string Name {
1548 public Control Parent {
1554 if (value == this) {
1555 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1558 if (parent!=value) {
1560 parent.Controls.Remove(this);
1565 if (!parent.Controls.Contains(this)) {
1566 parent.Controls.Add(this);
1569 XplatUI.SetParent(Handle, value.Handle);
1576 public string ProductName {
1578 return "Novell Mono .NET Framework";
1582 public string ProductVersion {
1584 return "1.1.4322.573";
1588 public bool RecreatingHandle {
1590 return is_recreating;
1594 public Region Region {
1596 return new Region(this.bounds);
1603 g = this.CreateGraphics();
1604 r = value.GetBounds(g);
1606 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1614 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1615 return ((Form)this).form_parent_window.Right;
1618 return this.bounds.X+this.bounds.Width;
1622 public virtual RightToLeft RightToLeft {
1624 return right_to_left;
1628 if (value != right_to_left) {
1629 right_to_left = value;
1630 OnRightToLeftChanged(EventArgs.Empty);
1635 public override ISite Site {
1647 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1648 return ((Form)this).form_parent_window.Size;
1650 return new Size(Width, Height);
1654 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1655 ((Form)this).form_parent_window.Size = value;
1658 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1662 public int TabIndex {
1672 public bool TabStop {
1688 control_tag = value;
1692 public virtual string Text {
1698 if (value == null) {
1699 value = String.Empty;
1704 XplatUI.Text(Handle, text);
1705 // FIXME: Do we need a Refresh() here?
1706 OnTextChanged (EventArgs.Empty);
1713 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1714 return ((Form)this).form_parent_window.Top;
1716 return this.bounds.Y;
1720 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1721 ((Form)this).form_parent_window.Top = value;
1725 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
1729 public Control TopLevelControl {
1733 while (p.parent != null) {
1741 public bool Visible {
1747 if (parent != null) {
1748 return parent.Visible;
1755 SetVisibleCore(value);
1761 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1762 return ((Form)this).form_parent_window.Width;
1764 return this.bounds.Width;
1768 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1769 ((Form)this).form_parent_window.Width = value;
1773 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
1777 public IWindowTarget WindowTarget {
1786 #endregion // Public Instance Properties
1788 #region Protected Instance Properties
1789 protected virtual CreateParams CreateParams {
1791 CreateParams create_params = new CreateParams();
1793 create_params.Caption = Text;
1794 create_params.X = Left;
1795 create_params.Y = Top;
1796 create_params.Width = Width;
1797 create_params.Height = Height;
1799 create_params.ClassName = XplatUI.DefaultClassName;
1800 create_params.ClassStyle = 0;
1801 create_params.ExStyle = 0;
1802 create_params.Param = 0;
1805 create_params.Parent = parent.Handle;
1808 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
1811 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
1814 return create_params;
1818 protected virtual ImeMode DefaultImeMode {
1820 return ImeMode.Inherit;
1824 protected virtual Size DefaultSize {
1826 return new Size(100, 23);
1830 protected int FontHeight {
1840 protected bool RenderRightToLeft {
1842 return (this.right_to_left == RightToLeft.Yes);
1846 ;; // Nothing to do?
1850 protected bool ResizeRedraw {
1852 return GetStyle(ControlStyles.ResizeRedraw);
1856 SetStyle(ControlStyles.ResizeRedraw, value);
1860 protected virtual bool ShowFocusCues {
1866 protected bool ShowKeyboardCues {
1871 #endregion // Protected Instance Properties
1873 #region Public Static Methods
1874 public static Control FromChildHandle(IntPtr handle) {
1875 IEnumerator control = Control.controls.GetEnumerator();
1877 while (control.MoveNext()) {
1878 if (((Control)control.Current).window.Handle == handle) {
1880 if (((Control)control.Current).Parent != null) {
1881 return ((Control)control.Current).Parent;
1888 public static Control FromHandle(IntPtr handle) {
1889 IEnumerator control = Control.controls.GetEnumerator();
1891 while (control.MoveNext()) {
1892 if (((Control)control.Current).window.Handle == handle) {
1894 return ((Control)control.Current);
1900 public static bool IsMnemonic(char charCode, string text) {
1903 amp = text.IndexOf('&');
1906 if (amp + 1 < text.Length) {
1907 if (text[amp + 1] != '&') {
1908 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
1918 #region Protected Static Methods
1919 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
1922 c = Control.FromHandle(hWnd);
1932 #region Public Instance Methods
1933 public IAsyncResult BeginInvoke(Delegate method) {
1934 return BeginInvokeInternal(method, null);
1937 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
1938 return BeginInvokeInternal (method, args);
1941 public void BringToFront() {
1942 if ((parent != null) && (parent.child_controls[0]!=this)) {
1943 if (parent.child_controls.Contains(this)) {
1944 parent.child_controls.SetChildIndex(this, 0);
1948 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
1950 if (parent != null) {
1955 public bool Contains(Control ctl) {
1959 while (current!=null) {
1963 current=current.parent;
1968 public void CreateControl() {
1970 if (!IsHandleCreated)
1973 for (int i=0; i<child_controls.Count; i++) {
1974 child_controls[i].CreateControl();
1979 public Graphics CreateGraphics() {
1980 return Graphics.FromHwnd(this.window.Handle);
1983 [MonoTODO("Come up with cross platform drag-drop driver interface")]
1984 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
1985 return DragDropEffects.None;
1988 public object EndInvoke (IAsyncResult async_result) {
1989 AsyncMethodResult result = (AsyncMethodResult) async_result;
1990 return result.EndInvoke ();
1994 public Control GetChildAtPoint(Point pt) {
1995 // Microsoft's version of this function doesn't seem to work, so I can't check
1996 // if we only consider children or also grandchildren, etc.
1997 // I'm gonna say 'children only'
1998 for (int i=0; i<child_controls.Count; i++) {
1999 if (child_controls[i].Bounds.Contains(pt)) {
2000 return child_controls[i];
2006 public IContainerControl GetContainerControl() {
2007 Control current = this;
2009 while (current!=null) {
2010 if ((current.control_style & ControlStyles.ContainerControl)!=0) {
2011 return (IContainerControl)current;
2013 current = current.parent;
2018 public void Hide() {
2019 this.Visible = false;
2022 public void Invalidate() {
2023 Invalidate(ClientRectangle, false);
2026 public void Invalidate(bool invalidateChildren) {
2027 Invalidate(ClientRectangle, invalidateChildren);
2030 public void Invalidate(System.Drawing.Rectangle rc) {
2031 Invalidate(rc, false);
2034 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2035 if (!IsHandleCreated || !Visible) {
2039 XplatUI.Invalidate(Handle, rc, !GetStyle (ControlStyles.AllPaintingInWmPaint));
2041 if (invalidateChildren) {
2042 for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2046 public void Invalidate(System.Drawing.Region region) {
2047 Invalidate(region, false);
2050 [MonoTODO("Figure out if GetRegionScans is usable")]
2051 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2052 throw new NotImplementedException();
2054 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2055 //if (invalidateChildren) {
2056 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2060 public object Invoke (Delegate method) {
2061 return Invoke(method, null);
2064 public object Invoke (Delegate method, object[] args) {
2065 IAsyncResult result = BeginInvoke (method, args);
2066 return EndInvoke(result);
2069 public void PerformLayout() {
2070 PerformLayout(null, null);
2073 public void PerformLayout(Control affectedControl, string affectedProperty) {
2074 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2076 if (layout_suspended>0) {
2077 layout_pending = true;
2081 layout_pending = false;
2083 // Prevent us from getting messed up
2086 // Perform all Dock and Anchor calculations
2089 AnchorStyles anchor;
2094 space=this.DisplayRectangle;
2095 if (prev_size != Size.Empty) {
2096 diff_width = space.Width - prev_size.Width;
2097 diff_height = space.Height - prev_size.Height;
2103 // Deal with docking
2104 for (int i=0; i < child_controls.Count; i++) {
2105 child=child_controls[i];
2106 switch (child.Dock) {
2107 case DockStyle.None: {
2112 case DockStyle.Left: {
2113 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2114 space.X+=child.Width;
2115 space.Width-=child.Width;
2119 case DockStyle.Top: {
2120 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2121 space.Y+=child.Height;
2122 space.Height-=child.Height;
2126 case DockStyle.Right: {
2127 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2128 space.Width-=child.Width;
2132 case DockStyle.Bottom: {
2133 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2134 space.Height-=child.Height;
2138 case DockStyle.Fill: {
2139 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2147 space=this.DisplayRectangle;
2149 // Deal with anchoring
2150 for (int i=0; i < child_controls.Count; i++) {
2156 child=child_controls[i];
2157 anchor=child.Anchor;
2162 height=child.Height;
2164 // If the control is docked we don't need to do anything
2165 if (child.Dock != DockStyle.None) {
2169 if ((anchor & AnchorStyles.Left) !=0 ) {
2170 if ((anchor & AnchorStyles.Right) != 0) {
2171 // Anchoring to left and right
2172 width=width+diff_width;
2176 } else if ((anchor & AnchorStyles.Right) != 0) {
2182 if ((anchor & AnchorStyles.Top) !=0 ) {
2183 if ((anchor & AnchorStyles.Bottom) != 0) {
2184 height+=diff_height;
2188 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2203 child.SetBounds(left, top, width, height);
2206 // Let everyone know
2210 // Need to make sure we decremend layout_suspended
2216 public Point PointToClient (Point p) {
2220 XplatUI.ScreenToClient (Handle, ref x, ref y);
2222 return new Point (x, y);
2225 public Point PointToScreen(Point p) {
2229 XplatUI.ClientToScreen(Handle, ref x, ref y);
2231 return new Point(x, y);
2234 public virtual bool PreProcessMessage(ref Message msg) {
2237 if (msg.Msg == (int)Msg.WM_KEYDOWN) {
2238 key_data = (Keys)msg.WParam.ToInt32();
2239 if (!ProcessCmdKey(ref msg, key_data)) {
2240 if (IsInputKey(key_data)) {
2244 return ProcessDialogKey(key_data);
2248 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2249 if (IsInputChar((char)msg.WParam)) {
2253 return ProcessDialogChar((char)msg.WParam);
2259 public virtual void Refresh() {
2260 if (IsHandleCreated == true) {
2261 XplatUI.RefreshWindow(window.Handle);
2265 public void ResumeLayout() {
2266 ResumeLayout (true);
2269 public void ResumeLayout(bool performLayout) {
2272 if (layout_suspended > 0) {
2276 if (performLayout || layout_pending) {
2281 public void Select() {
2282 Select(false, false);
2285 [MonoTODO("Finish")]
2286 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2290 public void SendToBack() {
2291 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2292 if (parent.child_controls.Contains(this)) {
2293 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2297 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2298 if (parent != null) {
2303 public void SetBounds(int x, int y, int width, int height) {
2304 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2307 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2308 SetBoundsCore(x, y, width, height, specified);
2311 public void Show() {
2312 if (!IsHandleCreated) {
2313 this.CreateHandle();
2319 public void SuspendLayout() {
2323 #endregion // Public Instance Methods
2325 #region Protected Instance Methods
2326 protected virtual AccessibleObject CreateAccessibilityInstance() {
2327 return new AccessibleObject(this);
2330 protected virtual ControlCollection CreateControlsInstance() {
2331 return new ControlCollection(this);
2334 protected virtual void CreateHandle() {
2336 throw new ObjectDisposedException(Name);
2339 if (IsHandleCreated) {
2344 window = new ControlNativeWindow(this);
2345 window.CreateHandle(CreateParams);
2348 if (window.Handle!=IntPtr.Zero) {
2349 if (!controls.Contains(window.Handle)) {
2353 creator_thread = Thread.CurrentThread;
2355 XplatUI.SetWindowBackground(window.Handle, this.BackColor);
2357 OnHandleCreated(EventArgs.Empty);
2361 protected virtual void DefWndProc(ref Message m) {
2362 window.DefWndProc(ref m);
2365 protected virtual void DestroyHandle() {
2366 if (IsHandleCreated) {
2367 if (Handle != IntPtr.Zero) {
2368 controls.Remove(Handle);
2371 if (window != null) {
2372 window.DestroyHandle();
2377 protected bool GetStyle(ControlStyles flag) {
2378 return (control_style & flag) != 0;
2381 protected virtual void InitLayout() {
2382 if (parent != null) {
2383 parent.PerformLayout(this, "parent");
2387 protected virtual bool IsInputChar (char charCode) {
2388 if (parent != null) {
2389 return parent.IsInputChar(charCode);
2395 protected virtual bool IsInputKey (Keys keyData) {
2396 // Doc says this one calls IsInputChar; not sure what to do with that
2400 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2401 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2405 if (parent != null) {
2406 return parent.ProcessCmdKey(ref msg, keyData);
2412 protected virtual bool ProcessDialogChar(char charCode) {
2413 if (parent != null) {
2414 return parent.ProcessDialogChar (charCode);
2420 protected virtual bool ProcessDialogKey (Keys keyData) {
2421 if (parent != null) {
2422 return parent.ProcessDialogKey (keyData);
2428 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2430 KeyEventArgs key_event;
2432 PreProcessMessage(ref msg);
2435 case (int)Msg.WM_KEYDOWN: {
2436 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2437 OnKeyDown (key_event);
2438 return key_event.Handled;
2440 case (int)Msg.WM_KEYUP: {
2441 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2442 OnKeyUp (key_event);
2443 return key_event.Handled;
2446 case (int)Msg.WM_CHAR: {
2447 KeyPressEventArgs key_press_event;
2449 key_press_event = new KeyPressEventArgs((char)msg.WParam);
2450 OnKeyPress(key_press_event);
2451 return key_press_event.Handled;
2462 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
2463 if (parent != null) {
2464 if (parent.ProcessKeyPreview(ref msg)) {
2469 return ProcessKeyEventArgs(ref msg);
2472 protected virtual bool ProcessKeyPreview(ref Message msg) {
2473 if (parent != null) {
2474 return parent.ProcessKeyPreview(ref msg);
2480 protected virtual bool ProcessMnemonic(char charCode) {
2485 protected void RaiseDragEvent(object key, DragEventArgs e) {
2489 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
2493 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
2497 protected void RaisePaintEvent(object key, PaintEventArgs e) {
2501 protected void RecreateHandle() {
2502 IEnumerator child = child_controls.GetEnumerator();
2506 if (IsHandleCreated) {
2512 while (child.MoveNext()) {
2513 ((Control)child.Current).RecreateHandle();
2519 is_recreating = false;
2522 protected void ResetMouseEventArgs() {
2526 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
2527 if (right_to_left == RightToLeft.No) {
2532 case ContentAlignment.TopLeft: {
2533 return ContentAlignment.TopRight;
2536 case ContentAlignment.TopRight: {
2537 return ContentAlignment.TopLeft;
2540 case ContentAlignment.MiddleLeft: {
2541 return ContentAlignment.MiddleRight;
2544 case ContentAlignment.MiddleRight: {
2545 return ContentAlignment.MiddleLeft;
2548 case ContentAlignment.BottomLeft: {
2549 return ContentAlignment.BottomRight;
2552 case ContentAlignment.BottomRight: {
2553 return ContentAlignment.BottomLeft;
2557 // if it's center it doesn't change
2563 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
2564 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
2568 if (align == HorizontalAlignment.Left) {
2569 return HorizontalAlignment.Right;
2572 // align must be HorizontalAlignment.Right
2573 return HorizontalAlignment.Left;
2576 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
2577 if (right_to_left == RightToLeft.No) {
2581 if (align == LeftRightAlignment.Left) {
2582 return LeftRightAlignment.Right;
2585 // align must be LeftRightAlignment.Right;
2586 return LeftRightAlignment.Left;
2589 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
2590 return RtlTranslateAlignment(align);
2593 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
2594 return RtlTranslateAlignment(align);
2597 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
2598 return RtlTranslateAlignment(align);
2601 protected virtual void ScaleCore(float dx, float dy) {
2602 throw new NotImplementedException();
2605 protected virtual void Select(bool directed, bool forward) {
2610 // Select this control
2614 if (parent == null) {
2618 index = parent.child_controls.IndexOf(this);
2625 if ((index+1) < parent.child_controls.Count) {
2634 index = parent.child_controls.Count-1;
2637 result = Select(parent.child_controls[index]);
2638 } while (!result && parent.child_controls[index] != this);
2641 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
2642 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
2643 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
2647 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
2651 if ((specified & BoundsSpecified.Width)!= BoundsSpecified.Width) {
2655 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
2659 if (IsHandleCreated) {
2660 XplatUI.SetWindowPos(Handle, x, y, width, height);
2662 UpdateBounds(x, y, width, height);
2665 protected virtual void SetClientSizeCore(int x, int y) {
2666 // Calculate the actual window size from the client size (it usually stays the same or grows)
2667 Rectangle ClientRect;
2668 Rectangle WindowRect;
2671 ClientRect = new Rectangle(0, 0, x, y);
2672 cp = this.CreateParams;
2674 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, false, out WindowRect)==false) {
2678 this.client_size = new Size(x, y);
2679 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
2682 protected void SetStyle(ControlStyles flag, bool value) {
2684 control_style |= flag;
2686 control_style &= ~flag;
2690 protected virtual void SetVisibleCore(bool value) {
2691 if (value!=is_visible) {
2693 XplatUI.SetVisible(Handle, value);
2694 OnVisibleChanged(EventArgs.Empty);
2696 if (dc_mem != null) {
2701 if (bmp_mem != null) {
2706 this.CreateBuffers(bounds.Width, bounds.Height);
2709 // FIXME - deal with focus
2711 if (parent != null) {
2712 parent.PerformLayout(this, "visible");
2714 PerformLayout(this, "visible");
2719 protected void UpdateBounds() {
2727 if (!IsHandleCreated) {
2731 XplatUI.GetWindowPos(this.Handle, out x, out y, out width, out height, out client_width, out client_height);
2732 UpdateBounds(x, y, width, height, client_width, client_height);
2735 protected void UpdateBounds(int x, int y, int width, int height) {
2736 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
2738 bool resized = false;
2740 int client_x_diff = this.bounds.Width-this.client_size.Width;
2741 int client_y_diff = this.bounds.Height-this.client_size.Height;
2743 // Needed to generate required notifications
2744 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
2748 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
2755 bounds.Height=height;
2757 // Update client rectangle as well
2758 if (this.layout_suspended==0) {
2759 prev_size.Width=client_size.Width;
2760 prev_size.Height=client_size.Height;
2763 client_size.Width=width-client_x_diff;
2764 client_size.Height=height-client_y_diff;
2767 OnLocationChanged(EventArgs.Empty);
2771 OnSizeChanged(EventArgs.Empty);
2775 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
2776 UpdateBounds(x, y, width, height);
2778 this.client_size.Width=clientWidth;
2779 this.client_size.Height=clientHeight;
2783 protected virtual void WndProc(ref Message m) {
2784 EventArgs e = new EventArgs();
2787 Console.WriteLine("Received message {0}", m);
2790 switch((Msg)m.Msg) {
2791 case Msg.WM_WINDOWPOSCHANGED: {
2794 if (GetStyle(ControlStyles.ResizeRedraw)) {
2801 case Msg.WM_PAINT: {
2802 PaintEventArgs paint_event;
2804 paint_event = XplatUI.PaintEventStart(Handle);
2805 OnPaint(paint_event);
2806 XplatUI.PaintEventEnd(Handle);
2811 case Msg.WM_ERASEBKGND:{
2812 if (GetStyle (ControlStyles.UserPaint)){
2813 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
2814 PaintEventArgs eraseEventArgs = new PaintEventArgs (Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
2815 OnPaintBackground (eraseEventArgs);
2817 m.Result = (IntPtr)1;
2819 m.Result = IntPtr.Zero;
2826 case Msg.WM_LBUTTONUP: {
2827 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
2829 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2831 if (mouse_clicks > 1) {
2837 case Msg.WM_LBUTTONDOWN: {
2838 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
2839 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2845 case Msg.WM_LBUTTONDBLCLK: {
2847 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
2848 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2853 case Msg.WM_MBUTTONUP: {
2854 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
2856 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2858 if (mouse_clicks > 1) {
2864 case Msg.WM_MBUTTONDOWN: {
2865 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
2866 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2872 case Msg.WM_MBUTTONDBLCLK: {
2874 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
2875 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2880 case Msg.WM_RBUTTONUP: {
2881 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
2883 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2885 if (mouse_clicks > 1) {
2891 case Msg.WM_RBUTTONDOWN: {
2892 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
2893 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2899 case Msg.WM_RBUTTONDBLCLK: {
2901 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
2902 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2907 case Msg.WM_MOUSEWHEEL: {
2909 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
2910 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2911 HighOrder(m.WParam.ToInt32())));
2916 case Msg.WM_MOUSEMOVE: {
2917 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
2919 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
2924 case Msg.WM_MOUSE_ENTER: {
2929 OnMouseEnter(EventArgs.Empty);
2933 case Msg.WM_MOUSE_LEAVE: {
2935 OnMouseLeave(EventArgs.Empty);
2939 case Msg.WM_MOUSEHOVER: {
2940 OnMouseHover(EventArgs.Empty);
2944 case Msg.WM_KEYDOWN: {
2945 if (!ProcessKeyMessage(ref m)) {
2952 case Msg.WM_KEYUP: {
2953 if (!ProcessKeyMessage(ref m)) {
2961 if (!ProcessKeyMessage(ref m)) {
2970 case Msg.WM_WINDOWPOSCHANGED: throw new NotImplementedException(); break;
2971 case Msg.WM_SYSCOLORCHANGE: throw new NotImplementedException(); break;
2983 #endregion // Public Instance Methods
2985 #region OnXXX methods
2986 protected virtual void OnBackColorChanged(EventArgs e) {
2987 if (BackColorChanged!=null) BackColorChanged(this, e);
2988 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
2991 protected virtual void OnBackgroundImageChanged(EventArgs e) {
2992 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
2993 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
2996 protected virtual void OnBindingContextChanged(EventArgs e) {
2997 if (BindingContextChanged!=null) BindingContextChanged(this, e);
2998 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3001 protected virtual void OnCausesValidationChanged(EventArgs e) {
3002 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3005 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3006 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3009 protected virtual void OnClick(EventArgs e) {
3010 if (Click!=null) Click(this, e);
3013 protected virtual void OnContextMenuChanged(EventArgs e) {
3014 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3017 protected virtual void OnControlAdded(ControlEventArgs e) {
3018 if (ControlAdded!=null) ControlAdded(this, e);
3021 protected virtual void OnControlRemoved(ControlEventArgs e) {
3022 if (ControlRemoved!=null) ControlRemoved(this, e);
3025 protected virtual void OnCreateControl() {
3029 protected virtual void OnCursorChanged(EventArgs e) {
3030 if (CursorChanged!=null) CursorChanged(this, e);
3033 protected virtual void OnDockChanged(EventArgs e) {
3034 if (DockChanged!=null) DockChanged(this, e);
3037 protected virtual void OnDoubleClick(EventArgs e) {
3038 if (DoubleClick!=null) DoubleClick(this, e);
3041 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3042 if (DragDrop!=null) DragDrop(this, drgevent);
3045 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3046 if (DragEnter!=null) DragEnter(this, drgevent);
3049 protected virtual void OnDragLeave(EventArgs e) {
3050 if (DragLeave!=null) DragLeave(this, e);
3053 protected virtual void OnDragOver(DragEventArgs drgevent) {
3054 if (DragOver!=null) DragOver(this, drgevent);
3057 protected virtual void OnEnabledChanged(EventArgs e) {
3058 if (EnabledChanged!=null) EnabledChanged(this, e);
3059 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3062 protected virtual void OnEnter(EventArgs e) {
3063 if (Enter!=null) Enter(this, e);
3066 protected virtual void OnFontChanged(EventArgs e) {
3067 if (FontChanged!=null) FontChanged(this, e);
3070 protected virtual void OnForeColorChanged(EventArgs e) {
3071 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3072 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3075 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3076 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3079 protected virtual void OnGotFocus(EventArgs e) {
3080 if (GotFocus!=null) GotFocus(this, e);
3083 protected virtual void OnHandleCreated(EventArgs e) {
3084 if (HandleCreated!=null) HandleCreated(this, e);
3087 protected virtual void OnHandleDestroyed(EventArgs e) {
3088 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3091 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3092 if (HelpRequested!=null) HelpRequested(this, hevent);
3095 protected virtual void OnImeModeChanged(EventArgs e) {
3096 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3099 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3100 if (Invalidated!=null) Invalidated(this, e);
3103 protected virtual void OnKeyDown(KeyEventArgs e) {
3104 if (KeyDown!=null) KeyDown(this, e);
3107 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3108 if (KeyPress!=null) KeyPress(this, e);
3111 protected virtual void OnKeyUp(KeyEventArgs e) {
3112 if (KeyUp!=null) KeyUp(this, e);
3115 protected virtual void OnLayout(LayoutEventArgs levent) {
3116 if (Layout!=null) Layout(this, levent);
3119 protected virtual void OnLeave(EventArgs e) {
3120 if (Leave!=null) Leave(this, e);
3123 protected virtual void OnLocationChanged(EventArgs e) {
3124 if (LocationChanged!=null) LocationChanged(this, e);
3127 protected virtual void OnLostFocus(EventArgs e) {
3128 if (LostFocus!=null) LostFocus(this, e);
3131 protected virtual void OnMouseDown(MouseEventArgs e) {
3132 if (MouseDown!=null) MouseDown(this, e);
3135 protected virtual void OnMouseEnter(EventArgs e) {
3136 if (MouseEnter!=null) MouseEnter(this, e);
3139 protected virtual void OnMouseHover(EventArgs e) {
3140 if (MouseHover!=null) MouseHover(this, e);
3143 protected virtual void OnMouseLeave(EventArgs e) {
3144 if (MouseLeave!=null) MouseLeave(this, e);
3147 protected virtual void OnMouseMove(MouseEventArgs e) {
3148 if (MouseMove!=null) MouseMove(this, e);
3151 protected virtual void OnMouseUp(MouseEventArgs e) {
3152 if (MouseUp!=null) MouseUp(this, e);
3155 protected virtual void OnMouseWheel(MouseEventArgs e) {
3156 if (MouseWheel!=null) MouseWheel(this, e);
3159 protected virtual void OnMove(EventArgs e) {
3160 if (Move!=null) Move(this, e);
3163 protected virtual void OnNotifyMessage(Message m) {
3167 protected virtual void OnPaint(PaintEventArgs e) {
3168 if (Paint!=null) Paint(this, e);
3171 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3175 protected virtual void OnParentBackColorChanged(EventArgs e) {
3176 if (background_color.IsEmpty && background_image==null) {
3178 OnBackColorChanged(e);
3182 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3183 if (background_color.IsEmpty && background_image==null) {
3185 OnBackgroundImageChanged(e);
3189 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3190 if (binding_context==null) {
3191 binding_context=Parent.binding_context;
3192 OnBindingContextChanged(e);
3196 protected virtual void OnParentChanged(EventArgs e) {
3197 if (ParentChanged!=null) ParentChanged(this, e);
3200 protected virtual void OnParentEnabledChanged(EventArgs e) {
3201 if ((is_enabled && !Parent.is_enabled) || (!is_enabled && Parent.is_enabled)) {
3204 EnabledChanged(this, e);
3208 protected virtual void OnParentFontChanged(EventArgs e) {
3215 protected virtual void OnParentForeColorChanged(EventArgs e) {
3216 if (foreground_color.IsEmpty) {
3218 OnForeColorChanged(e);
3222 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
3223 if (right_to_left==RightToLeft.Inherit) {
3225 OnRightToLeftChanged(e);
3229 protected virtual void OnParentVisibleChanged(EventArgs e) {
3230 if (is_visible!=Parent.is_visible) {
3233 OnVisibleChanged(e);
3237 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
3238 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
3241 protected virtual void OnResize(EventArgs e) {
3242 if (Resize!=null) Resize(this, e);
3244 PerformLayout(this, "bounds");
3246 if (parent != null) {
3247 parent.PerformLayout();
3251 protected virtual void OnRightToLeftChanged(EventArgs e) {
3252 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
3253 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
3256 protected virtual void OnSizeChanged(EventArgs e) {
3257 InvalidateBuffers ();
3259 if (SizeChanged!=null) SizeChanged(this, e);
3262 protected virtual void OnStyleChanged(EventArgs e) {
3263 if (StyleChanged!=null) StyleChanged(this, e);
3266 protected virtual void OnSystemColorsChanged(EventArgs e) {
3267 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
3270 protected virtual void OnTabIndexChanged(EventArgs e) {
3271 if (TabIndexChanged!=null) TabIndexChanged(this, e);
3274 protected virtual void OnTabStopChanged(EventArgs e) {
3275 if (TabStopChanged!=null) TabStopChanged(this, e);
3278 protected virtual void OnTextChanged(EventArgs e) {
3279 if (TextChanged!=null) TextChanged(this, e);
3282 protected virtual void OnValidated(EventArgs e) {
3283 if (Validated!=null) Validated(this, e);
3286 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
3287 if (Validating!=null) Validating(this, e);
3290 protected virtual void OnVisibleChanged(EventArgs e) {
3297 if (bmp_mem!=null) {
3303 if (!this.IsHandleCreated) {
3304 this.CreateHandle();
3310 if (VisibleChanged!=null) VisibleChanged(this, e);
3312 // We need to tell our kids
3313 for (int i=0; i<child_controls.Count; i++) {
3314 child_controls[i].OnParentVisibleChanged(e);
3317 #endregion // OnXXX methods
3320 public event EventHandler BackColorChanged;
3321 public event EventHandler BackgroundImageChanged;
3322 public event EventHandler BindingContextChanged;
3323 public event EventHandler CausesValidationChanged;
3324 public event UICuesEventHandler ChangeUICues;
3325 public event EventHandler Click;
3326 public event EventHandler ContextMenuChanged;
3327 public event ControlEventHandler ControlAdded;
3328 public event ControlEventHandler ControlRemoved;
3329 public event EventHandler CursorChanged;
3330 public event EventHandler DockChanged;
3331 public event EventHandler DoubleClick;
3332 public event DragEventHandler DragDrop;
3333 public event DragEventHandler DragEnter;
3334 public event EventHandler DragLeave;
3335 public event DragEventHandler DragOver;
3336 public event EventHandler EnabledChanged;
3337 public event EventHandler Enter;
3338 public event EventHandler FontChanged;
3339 public event EventHandler ForeColorChanged;
3340 public event GiveFeedbackEventHandler GiveFeedback;
3341 public event EventHandler GotFocus;
3342 public event EventHandler HandleCreated;
3343 public event EventHandler HandleDestroyed;
3344 public event HelpEventHandler HelpRequested;
3345 public event EventHandler ImeModeChanged;
3346 public event InvalidateEventHandler Invalidated;
3347 public event KeyEventHandler KeyDown;
3348 public event KeyPressEventHandler KeyPress;
3349 public event KeyEventHandler KeyUp;
3350 public event LayoutEventHandler Layout;
3351 public event EventHandler Leave;
3352 public event EventHandler LocationChanged;
3353 public event EventHandler LostFocus;
3354 public event MouseEventHandler MouseDown;
3355 public event EventHandler MouseEnter;
3356 public event EventHandler MouseHover;
3357 public event EventHandler MouseLeave;
3358 public event MouseEventHandler MouseMove;
3359 public event MouseEventHandler MouseUp;
3360 public event MouseEventHandler MouseWheel;
3361 public event EventHandler Move;
3362 public event PaintEventHandler Paint;
3363 public event EventHandler ParentChanged;
3364 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
3365 public event QueryContinueDragEventHandler QueryContinueDrag;
3366 public event EventHandler Resize;
3367 public event EventHandler RightToLeftChanged;
3368 public event EventHandler SizeChanged;
3369 public event EventHandler StyleChanged;
3370 public event EventHandler SystemColorsChanged;
3371 public event EventHandler TabIndexChanged;
3372 public event EventHandler TabStopChanged;
3373 public event EventHandler TextChanged;
3374 public event EventHandler Validated;
3375 public event CancelEventHandler Validating;
3376 public event EventHandler VisibleChanged;
3377 #endregion // Events