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
37 using System.ComponentModel;
38 using System.ComponentModel.Design;
39 using System.Collections;
40 using System.Diagnostics;
41 using System.Threading;
42 using System.Runtime.InteropServices;
43 using System.ComponentModel.Design.Serialization;
46 namespace System.Windows.Forms
48 [Designer("System.Windows.Forms.Design.ContolDesigner, System.Design")]
49 [DefaultProperty("Text")]
50 [DefaultEvent("Click")]
51 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, System.Design", "System.ComponentModel.Design.Serialization.CodeDomSerializer, System.Design")]
52 [ToolboxItemFilter("System.Windows.Forms")]
53 public class Control : Component, ISynchronizeInvoke, IWin32Window
55 #region Local Variables
58 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
59 internal object creator_thread; // thread that created the control
60 internal ControlNativeWindow window; // object for native window handle
61 internal string name; // for object naming
64 internal bool has_focus; // true if control has focus
65 internal bool is_visible; // true if control is visible
66 internal bool is_entered; // is the mouse inside the control?
67 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
68 internal bool is_selected; // true if control is selected
69 internal bool is_accessible; // true if the control is visible to accessibility applications
70 internal bool is_captured; // tracks if the control has captured the mouse
71 internal bool is_toplevel; // tracks if the control is a toplevel window
72 internal bool is_recreating; // tracks if the handle for the control is being recreated
73 internal bool causes_validation; // tracks if validation is executed on changes
74 internal int tab_index; // position in tab order of siblings
75 internal bool tab_stop = true; // is the control a tab stop?
76 internal bool is_disposed; // has the window already been disposed?
77 internal Size client_size; // size of the client area (window excluding decorations)
78 internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
79 internal ControlStyles control_style; // rather win32-specific, style bits for control
80 internal ImeMode ime_mode = ImeMode.Inherit;
81 internal bool layout_pending; // true if our parent needs to re-layout us
82 internal object control_tag; // object that contains data about our control
83 internal int mouse_clicks; // Counter for mouse clicks
84 internal Cursor cursor; // Cursor for the window
87 internal Color foreground_color; // foreground color for control
88 internal Color background_color; // background color for control
89 internal Image background_image; // background image for control
90 internal Font font; // font for control
91 internal string text; // window/title text for control
94 internal AnchorStyles anchor_style; // anchoring requirements for our control
95 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
96 internal SizeF size_ratio; // size ratio of our control to it's parent; required for anchoring
97 internal Size prev_size; // previous size of the control; required for anchoring
99 // to be categorized...
100 static internal ArrayList controls = new ArrayList(); // All of the applications controls, in a flat list
101 internal ControlCollection child_controls; // our children
102 internal Control parent; // our parent control
103 internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
104 internal BindingContext binding_context; // TODO
105 internal RightToLeft right_to_left; // drawing direction for control
106 internal int layout_suspended;
107 internal bool double_buffering;
108 internal ContextMenu context_menu; // Context menu associated with the control
110 private Graphics dc_mem; // Graphics context for double buffering
111 private Bitmap bmp_mem; // Bitmap for double buffering control
113 #endregion // Local Variables
115 #region Private Classes
116 // This helper class allows us to dispatch messages to Control.WndProc
117 internal class ControlNativeWindow : NativeWindow {
118 private Control control;
120 public ControlNativeWindow(Control control) : base() {
121 this.control=control;
124 static internal Control ControlFromHandle(IntPtr hWnd) {
125 ControlNativeWindow window;
127 window = (ControlNativeWindow)window_collection[hWnd];
129 return window.control;
132 protected override void WndProc(ref Message m) {
133 control.WndProc(ref m);
138 #region Public Classes
139 public class ControlAccessibleObject : AccessibleObject {
140 #region ControlAccessibleObject Local Variables
141 private Control owner;
142 #endregion // ControlAccessibleObject Local Variables
144 #region ControlAccessibleObject Constructors
145 public ControlAccessibleObject(Control ownerControl) {
146 this.owner = ownerControl;
148 #endregion // ControlAccessibleObject Constructors
150 #region ControlAccessibleObject Public Instance Properties
151 public override string DefaultAction {
153 return base.DefaultAction;
157 public override string Description {
159 return base.Description;
163 public IntPtr Handle {
169 // We don't want to let them set it
173 public override string Help {
179 public override string KeyboardShortcut {
181 return base.KeyboardShortcut;
185 public override string Name {
195 public Control Owner {
201 public override AccessibleRole Role {
206 #endregion // ControlAccessibleObject Public Instance Properties
208 #region ControlAccessibleObject Public Instance Methods
209 public override int GetHelpTopic(out string FileName) {
210 return base.GetHelpTopic (out FileName);
213 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
214 public void NotifyClients(AccessibleEvents accEvent) {
215 throw new NotImplementedException();
218 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
219 public void NotifyClients(AccessibleEvents accEvent, int childID) {
220 throw new NotImplementedException();
223 public override string ToString() {
224 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
227 #endregion // ControlAccessibleObject Public Instance Methods
230 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
231 #region ControlCollection Local Variables
232 internal ArrayList list;
233 internal Control owner;
234 #endregion // ControlCollection Local Variables
236 #region ControlCollection Public Constructor
237 public ControlCollection(Control owner) {
239 this.list=new ArrayList();
243 #region ControlCollection Public Instance Properties
250 public bool IsReadOnly {
252 return list.IsReadOnly;
256 public virtual Control this[int index] {
258 if (index < 0 || index >= list.Count) {
259 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
261 return (Control)list[index];
264 #endregion // ControlCollection Public Instance Properties
266 #region ControlCollection Private Instance Methods
267 public virtual void Add (Control value)
270 for (int i = 0; i < list.Count; i++) {
271 if (list [i] == value) {
272 // Do we need to do anything here?
277 if (value.tab_index == -1) {
283 end = owner.child_controls.Count;
284 for (int i = 0; i < end; i++) {
285 index = owner.child_controls[i].tab_index;
290 value.tab_index = use;
294 value.Parent = owner;
295 owner.UpdateZOrder();
296 owner.OnControlAdded(new ControlEventArgs(value));
299 public virtual void AddRange (Control[] controls)
301 if (controls == null)
302 throw new ArgumentNullException ("controls");
304 owner.SuspendLayout ();
307 for (int i = 0; i < controls.Length; i++)
310 owner.ResumeLayout ();
314 public virtual void Clear ()
316 owner.SuspendLayout();
317 for (int i = 0; i < list.Count; i++) {
318 owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
321 owner.ResumeLayout();
324 public virtual bool Contains (Control value)
326 return list.Contains (value);
329 public void CopyTo (Array array, int index)
331 list.CopyTo(array, index);
334 public override bool Equals(object other) {
335 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
342 public int GetChildIndex(Control child) {
343 return GetChildIndex(child, false);
346 public int GetChildIndex(Control child, bool throwException) {
349 index=list.IndexOf(child);
351 if (index==-1 && throwException) {
352 throw new ArgumentException("Not a child control", "child");
357 public IEnumerator GetEnumerator() {
358 return list.GetEnumerator();
361 public override int GetHashCode() {
362 return base.GetHashCode();
365 public int IndexOf(Control control) {
366 return list.IndexOf(control);
369 public virtual void Remove(Control value) {
370 owner.OnControlRemoved(new ControlEventArgs(value));
372 owner.UpdateZOrder();
375 public void RemoveAt(int index) {
376 if (index<0 || index>=list.Count) {
377 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
380 owner.OnControlRemoved(new ControlEventArgs((Control)list[index]));
381 list.RemoveAt(index);
382 owner.UpdateZOrder();
385 public void SetChildIndex(Control child, int newIndex) {
388 old_index=list.IndexOf(child);
390 throw new ArgumentException("Not a child control", "child");
393 if (old_index==newIndex) {
399 if (newIndex>list.Count) {
402 list.Insert(newIndex, child);
404 owner.UpdateZOrder();
406 #endregion // ControlCollection Private Instance Methods
408 #region ControlCollection Interface Properties
409 object IList.this[int index] {
411 if (index<0 || index>=list.Count) {
412 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
418 if (!(value is Control)) {
419 throw new ArgumentException("Object of type Control required", "value");
422 list[index]=(Control)value;
426 bool IList.IsFixedSize {
432 bool IList.IsReadOnly {
434 return list.IsReadOnly;
438 bool ICollection.IsSynchronized {
440 return list.IsSynchronized;
444 object ICollection.SyncRoot {
446 return list.SyncRoot;
449 #endregion // ControlCollection Interface Properties
451 #region ControlCollection Interface Methods
452 int IList.Add(object value) {
454 throw new ArgumentNullException("value", "Cannot add null controls");
457 if (!(value is Control)) {
458 throw new ArgumentException("Object of type Control required", "value");
461 return list.Add(value);
464 bool IList.Contains(object value) {
465 if (!(value is Control)) {
466 throw new ArgumentException("Object of type Control required", "value");
469 return this.Contains((Control) value);
472 int IList.IndexOf(object value) {
473 if (!(value is Control)) {
474 throw new ArgumentException("Object of type Control required", "value");
477 return this.IndexOf((Control) value);
480 void IList.Insert(int index, object value) {
481 if (!(value is Control)) {
482 throw new ArgumentException("Object of type Control required", "value");
484 list.Insert(index, value);
487 void IList.Remove(object value) {
488 if (!(value is Control)) {
489 throw new ArgumentException("Object of type Control required", "value");
494 void ICollection.CopyTo(Array array, int index) {
496 list.CopyTo(array, index);
500 Object ICloneable.Clone() {
501 ControlCollection clone = new ControlCollection(this.owner);
502 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
505 #endregion // ControlCollection Interface Methods
507 #endregion // ControlCollection Class
509 #region Public Constructors
511 creator_thread = Thread.CurrentThread;
513 prev_size = Size.Empty;
514 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
521 layout_pending = false;
523 causes_validation = true;
525 layout_suspended = 0;
526 double_buffering = true;
530 right_to_left = RightToLeft.Inherit;
532 control_style = ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick;
535 background_image = null;
539 child_controls = CreateControlsInstance();
540 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
541 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
542 XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, false, out bounds);
543 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
549 public Control(Control parent, string text) : this() {
554 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
559 bounds.Height=height;
560 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
564 public Control(string text) : this() {
568 public Control(string text, int left, int top, int width, int height) : this() {
572 bounds.Height=height;
573 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
577 protected override void Dispose(bool disposing) {
590 OnHandleDestroyed(EventArgs.Empty);
591 controls.Remove(this);
593 #endregion // Public Constructors
595 #region Internal Properties
596 #endregion // Internal Properties
598 #region Private & Internal Methods
599 internal static IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
600 AsyncMethodResult result = new AsyncMethodResult ();
601 AsyncMethodData data = new AsyncMethodData ();
603 data.Method = method;
605 data.Result = new WeakReference (result);
607 XplatUI.SendAsyncMethod (data);
611 internal Graphics DeviceContext {
614 CreateBuffers(this.Width, this.Height);
620 internal Bitmap ImageBuffer {
623 CreateBuffers(this.Width, this.Height);
629 internal void CreateBuffers (int width, int height) {
630 if (double_buffering == false)
646 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
647 dc_mem = Graphics.FromImage (bmp_mem);
650 internal void InvalidateBuffers ()
652 if (double_buffering == false)
664 internal static void SetChildColor(Control parent) {
667 for (int i=0; i < parent.child_controls.Count; i++) {
668 child=parent.child_controls[i];
669 if (child.IsHandleCreated) {
670 XplatUI.SetWindowBackground(child.window.Handle, child.BackColor);
672 if (child.child_controls.Count>0) {
673 SetChildColor(child);
679 internal bool Select(Control control) {
681 IContainerControl container;
683 if (control == null) {
687 parent = control.parent;
689 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
690 while (parent != null) {
691 if (!parent.is_visible || !parent.is_enabled) {
694 parent = parent.parent;
698 control.is_selected = true;
700 XplatUI.SetFocus(control.window.Handle);
701 container = GetContainerControl();
702 if (container != null) {
703 container.ActiveControl = control;
709 private Control FindTabStop(Control control, bool forward) {
710 if (control == null) {
718 internal virtual void DoDefaultAction() {
719 // Only here to be overriden by our actual controls; this is needed by the accessibility class
722 internal static int LowOrder (int param) {
723 return (param & 0xffff);
726 internal static int HighOrder (int param) {
727 return (param >> 16);
730 internal static MouseButtons FromParamToMouseButtons (int param) {
731 MouseButtons buttons = MouseButtons.None;
733 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
734 buttons |= MouseButtons.Left;
736 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
737 buttons |= MouseButtons.Middle;
739 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
740 buttons |= MouseButtons.Right;
746 private static Control FindFlatForward(Control container, Control start) {
752 end = container.child_controls.Count;
755 index = start.tab_index;
760 for (int i = 0; i < end; i++) {
762 if (container.child_controls[i].tab_index > index) {
763 found = container.child_controls[i];
765 } else if (found.tab_index > container.child_controls[i].tab_index) {
766 if (container.child_controls[i].tab_index > index) {
767 found = container.child_controls[i];
774 private static Control FindControlForward(Control container, Control start) {
781 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
782 found = FindControlForward(start, null);
789 while (p != container) {
790 found = FindFlatForward(p, start);
798 return FindFlatForward(container, start);
801 private static Control FindFlatBackward(Control container, Control start) {
807 end = container.child_controls.Count;
810 index = start.tab_index;
812 // FIXME: Possible speed-up: Keep the highest taborder index in the container
814 for (int i = 0; i < end; i++) {
815 if (container.child_controls[i].tab_index > index) {
816 index = container.child_controls[i].tab_index;
822 for (int i = 0; i < end; i++) {
824 if (container.child_controls[i].tab_index < index) {
825 found = container.child_controls[i];
827 } else if (found.tab_index < container.child_controls[i].tab_index) {
828 if (container.child_controls[i].tab_index < index) {
829 found = container.child_controls[i];
836 private static Control FindControlBackward(Control container, Control start) {
842 found = FindFlatBackward(start.parent, start);
843 if (found == null && start.parent != container) {
848 found = FindFlatBackward(container, start);
851 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
852 found = FindControlBackward(found, null);
861 private void HandleClick(int clicks) {
862 if (GetStyle(ControlStyles.StandardClick)) {
864 if (GetStyle(ControlStyles.StandardDoubleClick)) {
865 OnDoubleClick(EventArgs.Empty);
867 OnClick(EventArgs.Empty);
870 OnClick(EventArgs.Empty);
874 #endregion // Private & Internal Methods
876 #region Public Static Properties
877 public static Color DefaultBackColor {
879 return ThemeEngine.Current.DefaultControlBackColor;
883 public static Font DefaultFont {
885 return ThemeEngine.Current.DefaultFont;
889 public static Color DefaultForeColor {
891 return ThemeEngine.Current.DefaultControlForeColor;
895 public static Keys ModifierKeys {
897 return XplatUI.State.ModifierKeys;
901 public static MouseButtons MouseButtons {
903 return XplatUI.State.MouseButtons;
907 public static Point MousePosition {
909 return Cursor.Position;
912 #endregion // Public Static Properties
914 #region Public Instance Properties
915 [EditorBrowsable(EditorBrowsableState.Advanced)]
917 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
918 public AccessibleObject AccessibilityObject {
920 if (accessibility_object==null) {
921 accessibility_object=CreateAccessibilityInstance();
923 return accessibility_object;
927 [EditorBrowsable(EditorBrowsableState.Advanced)]
929 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
930 public string AccessibleDefaultActionDescription {
932 return AccessibilityObject.default_action;
936 AccessibilityObject.default_action=value;
942 public string AccessibleDescription {
944 return AccessibilityObject.description;
948 AccessibilityObject.description=value;
954 public string AccessibleName {
956 return AccessibilityObject.Name;
960 AccessibilityObject.Name=value;
965 public AccessibleRole AccessibleRole {
967 return AccessibilityObject.role;
971 AccessibilityObject.role=value;
975 [DefaultValue(false)]
976 public virtual bool AllowDrop {
978 return XplatUI.State.DropTarget;
982 XplatUI.State.DropTarget=value;
987 [RefreshProperties(RefreshProperties.Repaint)]
988 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
989 public virtual AnchorStyles Anchor {
997 if (parent != null) {
998 parent.PerformLayout(this, "Parent");
1004 public virtual Color BackColor {
1006 if (background_color.IsEmpty) {
1008 return parent.BackColor;
1010 return DefaultBackColor;
1012 return background_color;
1016 background_color=value;
1017 if (this.IsHandleCreated) {
1018 XplatUI.SetWindowBackground(this.window.Handle, value);
1020 SetChildColor(this);
1021 OnBackColorChanged(EventArgs.Empty);
1027 [DefaultValue(null)]
1028 public virtual Image BackgroundImage {
1030 return background_image;
1034 if (background_image!=value) {
1035 background_image=value;
1036 OnBackgroundImageChanged(EventArgs.Empty);
1041 [EditorBrowsable(EditorBrowsableState.Advanced)]
1043 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1044 public virtual BindingContext BindingContext {
1046 return binding_context;
1050 if (binding_context != value) {
1051 binding_context = value;
1052 OnBindingContextChanged(EventArgs.Empty);
1057 [EditorBrowsable(EditorBrowsableState.Advanced)]
1059 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1062 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1063 return ((Form)this).form_parent_window.Bottom;
1066 return bounds.Y+bounds.Height;
1070 [EditorBrowsable(EditorBrowsableState.Advanced)]
1072 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1073 public Rectangle Bounds {
1079 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1083 [EditorBrowsable(EditorBrowsableState.Advanced)]
1085 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1086 public bool CanFocus {
1088 if (is_visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1095 [EditorBrowsable(EditorBrowsableState.Advanced)]
1097 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1098 public bool CanSelect {
1102 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1106 parent = this.parent;
1107 while (parent != null) {
1108 if (!parent.is_visible || !parent.is_enabled) {
1112 parent = parent.parent;
1118 [EditorBrowsable(EditorBrowsableState.Advanced)]
1120 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1121 public bool Capture {
1123 return this.is_captured;
1127 if (this.IsHandleCreated) {
1128 if (value && !is_captured) {
1130 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1131 } else if (!value && is_captured) {
1132 XplatUI.ReleaseWindow(this.window.Handle);
1133 is_captured = false;
1139 [DefaultValue(true)]
1140 public bool CausesValidation {
1142 return this.causes_validation;
1146 if (this.causes_validation != value) {
1147 causes_validation = value;
1148 OnCausesValidationChanged(EventArgs.Empty);
1153 [EditorBrowsable(EditorBrowsableState.Advanced)]
1155 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1156 public Rectangle ClientRectangle {
1158 client_rect.Width = client_size.Width;
1159 client_rect.Height = client_size.Height;
1164 [EditorBrowsable(EditorBrowsableState.Advanced)]
1166 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1167 public Size ClientSize {
1170 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1171 return ((Form)this).form_parent_window.ClientSize;
1179 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1180 ((Form)this).form_parent_window.ClientSize = value;
1184 this.SetClientSizeCore(value.Width, value.Height);
1188 [EditorBrowsable(EditorBrowsableState.Advanced)]
1190 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1191 [DescriptionAttribute("ControlCompanyNameDescr")]
1192 public String CompanyName {
1194 return "Mono Project, Novell, Inc.";
1198 [EditorBrowsable(EditorBrowsableState.Advanced)]
1200 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1201 public bool ContainsFocus {
1207 for (int i=0; i < child_controls.Count; i++) {
1208 if (child_controls[i].ContainsFocus) {
1216 [DefaultValue(null)]
1217 public virtual ContextMenu ContextMenu {
1219 return context_menu;
1223 if (context_menu != value) {
1224 context_menu = value;
1225 OnContextMenuChanged(EventArgs.Empty);
1231 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1232 public ControlCollection Controls {
1234 return this.child_controls;
1238 [EditorBrowsable(EditorBrowsableState.Advanced)]
1240 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1241 public bool Created {
1243 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1250 [AmbientValue(null)]
1251 public virtual Cursor Cursor {
1253 if (cursor != null) {
1257 if (parent != null) {
1258 return parent.Cursor;
1261 return Cursors.Default;
1265 if (cursor != value) {
1270 pt = Cursor.Position;
1271 if (bounds.Contains(pt)) {
1272 if (GetChildAtPoint(pt) == null) {
1273 if (cursor != null) {
1274 XplatUI.SetCursor(window.Handle, cursor.handle);
1276 if (parent != null) {
1277 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1279 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1285 OnCursorChanged(EventArgs.Empty);
1290 #if haveDataBindings
1291 [EditorBrowsable(EditorBrowsableState.Advanced)]
1293 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1294 public ControlBindingsCollection DataBindings {
1296 throw new NotImplementedException();
1301 [EditorBrowsable(EditorBrowsableState.Advanced)]
1303 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1304 public virtual Rectangle DisplayRectangle {
1306 return ClientRectangle;
1310 [EditorBrowsable(EditorBrowsableState.Advanced)]
1312 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1313 public bool Disposing {
1320 [RefreshProperties(RefreshProperties.Repaint)]
1321 [DefaultValue(DockStyle.None)]
1322 public virtual DockStyle Dock {
1328 if (dock_style == value) {
1334 if (parent != null) {
1335 parent.PerformLayout(this, "Parent");
1338 OnDockChanged(EventArgs.Empty);
1344 public bool Enabled {
1350 if (is_enabled == value) {
1356 OnEnabledChanged (EventArgs.Empty);
1360 [EditorBrowsable(EditorBrowsableState.Advanced)]
1362 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1363 public virtual bool Focused {
1365 return this.has_focus;
1370 [AmbientValue(null)]
1372 public virtual Font Font {
1378 if (Parent != null && Parent.Font != null) {
1386 if (font == value) {
1392 OnFontChanged (EventArgs.Empty);
1397 public virtual Color ForeColor {
1399 if (foreground_color.IsEmpty) {
1401 return parent.ForeColor;
1403 return DefaultForeColor;
1405 return foreground_color;
1409 if (foreground_color != value) {
1410 foreground_color=value;
1412 OnForeColorChanged(EventArgs.Empty);
1419 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1420 public IntPtr Handle { // IWin32Window
1422 if (!IsHandleCreated) {
1425 return window.Handle;
1429 [EditorBrowsable(EditorBrowsableState.Advanced)]
1431 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1432 public bool HasChildren {
1434 if (this.child_controls.Count>0) {
1441 [EditorBrowsable(EditorBrowsableState.Always)]
1443 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1446 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1447 return ((Form)this).form_parent_window.Height;
1449 return this.bounds.Height;
1453 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1454 ((Form)this).form_parent_window.Height = value;
1458 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1462 [AmbientValue(ImeMode.Inherit)]
1464 public ImeMode ImeMode {
1470 if (ime_mode != value) {
1473 OnImeModeChanged(EventArgs.Empty);
1478 [EditorBrowsable(EditorBrowsableState.Advanced)]
1480 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1481 public bool InvokeRequired { // ISynchronizeInvoke
1483 if (creator_thread!=Thread.CurrentThread) {
1490 [EditorBrowsable(EditorBrowsableState.Advanced)]
1492 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1493 public bool IsAccessible {
1495 return is_accessible;
1499 is_accessible = value;
1503 [EditorBrowsable(EditorBrowsableState.Advanced)]
1505 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1506 public bool IsDisposed {
1508 return this.is_disposed;
1512 [EditorBrowsable(EditorBrowsableState.Advanced)]
1514 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1515 public bool IsHandleCreated {
1517 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1525 [EditorBrowsable(EditorBrowsableState.Always)]
1527 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1530 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1531 return ((Form)this).form_parent_window.Left;
1534 return this.bounds.X;
1538 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1539 ((Form)this).form_parent_window.Left = value;
1543 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1548 public Point Location {
1550 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1551 return ((Form)this).form_parent_window.Location;
1553 return new Point(bounds.X, bounds.Y);
1557 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1558 ((Form)this).form_parent_window.Location = value;
1562 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1567 public string Name {
1578 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1579 public Control Parent {
1585 if (value == this) {
1586 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1589 if (parent!=value) {
1591 parent.Controls.Remove(this);
1596 if (!parent.Controls.Contains(this)) {
1597 parent.Controls.Add(this);
1600 XplatUI.SetParent(Handle, value.Handle);
1604 OnParentChanged(EventArgs.Empty);
1609 [EditorBrowsable(EditorBrowsableState.Advanced)]
1611 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1612 public string ProductName {
1614 return "Novell Mono MWF";
1618 [EditorBrowsable(EditorBrowsableState.Advanced)]
1620 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1621 public string ProductVersion {
1623 return "1.1.4322.573";
1627 [EditorBrowsable(EditorBrowsableState.Advanced)]
1629 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1630 public bool RecreatingHandle {
1632 return is_recreating;
1636 [EditorBrowsable(EditorBrowsableState.Advanced)]
1638 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1639 public Region Region {
1641 return new Region(this.bounds);
1648 g = this.CreateGraphics();
1649 r = value.GetBounds(g);
1651 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1657 [EditorBrowsable(EditorBrowsableState.Advanced)]
1659 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1662 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1663 return ((Form)this).form_parent_window.Right;
1666 return this.bounds.X+this.bounds.Width;
1670 [AmbientValue(RightToLeft.Inherit)]
1672 public virtual RightToLeft RightToLeft {
1674 return right_to_left;
1678 if (value != right_to_left) {
1679 right_to_left = value;
1680 OnRightToLeftChanged(EventArgs.Empty);
1685 [EditorBrowsable(EditorBrowsableState.Advanced)]
1686 public override ISite Site {
1699 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1700 return ((Form)this).form_parent_window.Size;
1702 return new Size(Width, Height);
1706 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1707 ((Form)this).form_parent_window.Size = value;
1710 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1715 [MergableProperty(false)]
1716 public int TabIndex {
1718 if (tab_index != -1) {
1725 if (tab_index != value) {
1727 OnTabIndexChanged(EventArgs.Empty);
1733 [DefaultValue(true)]
1734 public bool TabStop {
1740 if (tab_stop != value) {
1742 OnTabStopChanged(EventArgs.Empty);
1747 [Localizable(false)]
1749 [TypeConverter(typeof(StringConverter))]
1750 [DefaultValue(null)]
1757 control_tag = value;
1763 [BindableAttribute(true)]
1764 public virtual string Text {
1770 if (value == null) {
1771 value = String.Empty;
1776 XplatUI.Text(Handle, text);
1777 // FIXME: Do we need a Refresh() here?
1778 OnTextChanged (EventArgs.Empty);
1783 [EditorBrowsable(EditorBrowsableState.Advanced)]
1785 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1788 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1789 return ((Form)this).form_parent_window.Top;
1791 return this.bounds.Y;
1795 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1796 ((Form)this).form_parent_window.Top = value;
1800 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
1804 [EditorBrowsable(EditorBrowsableState.Advanced)]
1806 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1807 public Control TopLevelControl {
1811 while (p.parent != null) {
1820 public bool Visible {
1822 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1823 return ((Form)this).form_parent_window.Visible;
1833 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1834 ((Form)this).form_parent_window.Visible = value;
1838 SetVisibleCore(value);
1842 [EditorBrowsable(EditorBrowsableState.Always)]
1844 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1847 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1848 return ((Form)this).form_parent_window.Width;
1850 return this.bounds.Width;
1854 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1855 ((Form)this).form_parent_window.Width = value;
1859 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
1863 [EditorBrowsable(EditorBrowsableState.Never)]
1865 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1866 public IWindowTarget WindowTarget {
1875 #endregion // Public Instance Properties
1877 #region Protected Instance Properties
1878 protected virtual CreateParams CreateParams {
1880 CreateParams create_params = new CreateParams();
1882 create_params.Caption = Text;
1883 create_params.X = Left;
1884 create_params.Y = Top;
1885 create_params.Width = Width;
1886 create_params.Height = Height;
1888 create_params.ClassName = XplatUI.DefaultClassName;
1889 create_params.ClassStyle = 0;
1890 create_params.ExStyle = 0;
1891 create_params.Param = 0;
1894 create_params.Parent = parent.Handle;
1897 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
1900 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
1903 return create_params;
1907 protected virtual ImeMode DefaultImeMode {
1909 return ImeMode.Inherit;
1913 protected virtual Size DefaultSize {
1915 return new Size(100, 23);
1919 protected int FontHeight {
1929 protected bool RenderRightToLeft {
1931 return (this.right_to_left == RightToLeft.Yes);
1935 protected bool ResizeRedraw {
1937 return GetStyle(ControlStyles.ResizeRedraw);
1941 SetStyle(ControlStyles.ResizeRedraw, value);
1945 [EditorBrowsable(EditorBrowsableState.Advanced)]
1947 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1948 protected virtual bool ShowFocusCues {
1954 [EditorBrowsable(EditorBrowsableState.Advanced)]
1956 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1957 protected bool ShowKeyboardCues {
1962 #endregion // Protected Instance Properties
1964 #region Public Static Methods
1965 [EditorBrowsable(EditorBrowsableState.Advanced)]
1966 public static Control FromChildHandle(IntPtr handle) {
1967 IEnumerator control = Control.controls.GetEnumerator();
1969 while (control.MoveNext()) {
1970 if (((Control)control.Current).window.Handle == handle) {
1972 if (((Control)control.Current).Parent != null) {
1973 return ((Control)control.Current).Parent;
1980 [EditorBrowsable(EditorBrowsableState.Advanced)]
1981 public static Control FromHandle(IntPtr handle) {
1982 IEnumerator control = Control.controls.GetEnumerator();
1984 while (control.MoveNext()) {
1985 if (((Control)control.Current).window.Handle == handle) {
1987 return ((Control)control.Current);
1993 public static bool IsMnemonic(char charCode, string text) {
1996 amp = text.IndexOf('&');
1999 if (amp + 1 < text.Length) {
2000 if (text[amp + 1] != '&') {
2001 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2011 #region Protected Static Methods
2012 [EditorBrowsable(EditorBrowsableState.Advanced)]
2013 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2016 c = Control.FromHandle(hWnd);
2026 #region Public Instance Methods
2027 [EditorBrowsable(EditorBrowsableState.Advanced)]
2028 public IAsyncResult BeginInvoke(Delegate method) {
2029 return BeginInvokeInternal(method, null);
2032 [EditorBrowsable(EditorBrowsableState.Advanced)]
2033 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2034 return BeginInvokeInternal (method, args);
2037 public void BringToFront() {
2038 if ((parent != null) && (parent.child_controls[0]!=this)) {
2039 if (parent.child_controls.Contains(this)) {
2040 parent.child_controls.SetChildIndex(this, 0);
2044 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
2046 if (parent != null) {
2051 public bool Contains(Control ctl) {
2052 while (ctl != null) {
2061 public void CreateControl() {
2063 if (!IsHandleCreated)
2066 for (int i=0; i<child_controls.Count; i++) {
2067 child_controls[i].CreateControl();
2072 public Graphics CreateGraphics() {
2073 if (!IsHandleCreated) {
2074 this.CreateHandle();
2076 return Graphics.FromHwnd(this.window.Handle);
2079 [MonoTODO("Come up with cross platform drag-drop driver interface")]
2080 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2081 return DragDropEffects.None;
2084 [EditorBrowsable(EditorBrowsableState.Advanced)]
2085 public object EndInvoke (IAsyncResult async_result) {
2086 AsyncMethodResult result = (AsyncMethodResult) async_result;
2087 return result.EndInvoke ();
2090 public Form FindForm() {
2103 public bool Focus() {
2104 if (IsHandleCreated && !has_focus) {
2105 XplatUI.SetFocus(window.Handle);
2111 public Control GetChildAtPoint(Point pt) {
2112 // Microsoft's version of this function doesn't seem to work, so I can't check
2113 // if we only consider children or also grandchildren, etc.
2114 // I'm gonna say 'children only'
2115 for (int i=0; i<child_controls.Count; i++) {
2116 if (child_controls[i].Bounds.Contains(pt)) {
2117 return child_controls[i];
2123 public IContainerControl GetContainerControl() {
2124 Control current = this;
2126 while (current!=null) {
2127 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2128 return (IContainerControl)current;
2130 current = current.parent;
2135 public Control GetNextControl(Control ctl, bool forward) {
2136 // If we're not a container we don't play
2137 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2141 // If ctl is not contained by this, we start at the first child of this
2142 if (!this.Contains(ctl)) {
2146 // Search through our controls, starting at ctl, stepping into children as we encounter them
2147 // try to find the control with the tabindex closest to our own, or, if we're looking into
2148 // child controls, the one with the smallest tabindex
2150 return FindControlForward(this, ctl);
2152 return FindControlBackward(this, ctl);
2155 public void Hide() {
2156 this.Visible = false;
2159 public void Invalidate() {
2160 Invalidate(ClientRectangle, false);
2163 public void Invalidate(bool invalidateChildren) {
2164 Invalidate(ClientRectangle, invalidateChildren);
2167 public void Invalidate(System.Drawing.Rectangle rc) {
2168 Invalidate(rc, false);
2171 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2172 if (!IsHandleCreated || !Visible) {
2176 NotifyInvalidate(rc);
2178 XplatUI.Invalidate(Handle, rc, !GetStyle (ControlStyles.AllPaintingInWmPaint));
2180 if (invalidateChildren) {
2181 for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2183 OnInvalidated(new InvalidateEventArgs(rc));
2186 public void Invalidate(System.Drawing.Region region) {
2187 Invalidate(region, false);
2190 [MonoTODO("Figure out if GetRegionScans is usable")]
2191 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2192 throw new NotImplementedException();
2194 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2195 //if (invalidateChildren) {
2196 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2200 public object Invoke (Delegate method) {
2201 return Invoke(method, null);
2204 public object Invoke (Delegate method, object[] args) {
2205 IAsyncResult result = BeginInvoke (method, args);
2206 return EndInvoke(result);
2209 [EditorBrowsable(EditorBrowsableState.Advanced)]
2210 public void PerformLayout() {
2211 PerformLayout(null, null);
2214 [EditorBrowsable(EditorBrowsableState.Advanced)]
2215 public void PerformLayout(Control affectedControl, string affectedProperty) {
2216 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2218 if (layout_suspended>0) {
2219 layout_pending = true;
2223 layout_pending = false;
2225 // Prevent us from getting messed up
2228 // Perform all Dock and Anchor calculations
2231 AnchorStyles anchor;
2236 space=this.DisplayRectangle;
2237 if (prev_size != Size.Empty) {
2238 diff_width = space.Width - prev_size.Width;
2239 diff_height = space.Height - prev_size.Height;
2245 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2246 for (int i = child_controls.Count - 1; i >= 0; i--) {
2247 child=child_controls[i];
2248 switch (child.Dock) {
2249 case DockStyle.None: {
2254 case DockStyle.Left: {
2255 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2256 space.X+=child.Width;
2257 space.Width-=child.Width;
2261 case DockStyle.Top: {
2262 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2263 space.Y+=child.Height;
2264 space.Height-=child.Height;
2268 case DockStyle.Right: {
2269 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2270 space.Width-=child.Width;
2274 case DockStyle.Bottom: {
2275 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2276 space.Height-=child.Height;
2280 case DockStyle.Fill: {
2281 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2289 space=this.DisplayRectangle;
2291 // Deal with anchoring
2292 for (int i=0; i < child_controls.Count; i++) {
2298 child=child_controls[i];
2299 anchor=child.Anchor;
2304 height=child.Height;
2306 // If the control is docked we don't need to do anything
2307 if (child.Dock != DockStyle.None) {
2311 if ((anchor & AnchorStyles.Left) !=0 ) {
2312 if ((anchor & AnchorStyles.Right) != 0) {
2313 // Anchoring to left and right
2314 width=width+diff_width;
2318 } else if ((anchor & AnchorStyles.Right) != 0) {
2324 if ((anchor & AnchorStyles.Top) !=0 ) {
2325 if ((anchor & AnchorStyles.Bottom) != 0) {
2326 height+=diff_height;
2330 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2345 child.SetBounds(left, top, width, height);
2348 // Let everyone know
2352 // Need to make sure we decremend layout_suspended
2358 public Point PointToClient (Point p) {
2362 XplatUI.ScreenToClient (Handle, ref x, ref y);
2364 return new Point (x, y);
2367 public Point PointToScreen(Point p) {
2371 XplatUI.ClientToScreen(Handle, ref x, ref y);
2373 return new Point(x, y);
2376 public virtual bool PreProcessMessage(ref Message msg) {
2379 if (msg.Msg == (int)Msg.WM_KEYDOWN) {
2380 key_data = (Keys)msg.WParam.ToInt32();
2381 if (!ProcessCmdKey(ref msg, key_data)) {
2382 if (IsInputKey(key_data)) {
2386 return ProcessDialogKey(key_data);
2390 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2391 if (IsInputChar((char)msg.WParam)) {
2395 return ProcessDialogChar((char)msg.WParam);
2401 public Rectangle RectangleToClient(Rectangle r) {
2402 return new Rectangle(PointToClient(r.Location), r.Size);
2405 public Rectangle RectangleToScreen(Rectangle r) {
2406 return new Rectangle(PointToScreen(r.Location), r.Size);
2409 public virtual void Refresh() {
2410 if (IsHandleCreated == true) {
2411 XplatUI.RefreshWindow(window.Handle);
2415 [EditorBrowsable(EditorBrowsableState.Never)]
2416 public virtual void ResetBackColor() {
2417 background_color = Color.Empty;
2420 #if haveDataBindings
2421 [EditorBrowsable(EditorBrowsableState.Never)]
2423 public void ResetBindings() {
2428 [EditorBrowsable(EditorBrowsableState.Never)]
2429 public virtual void ResetCursor() {
2433 [EditorBrowsable(EditorBrowsableState.Never)]
2434 public virtual void ResetFont() {
2438 [EditorBrowsable(EditorBrowsableState.Never)]
2439 public virtual void ResetForeColor() {
2440 foreground_color = Color.Empty;
2443 [EditorBrowsable(EditorBrowsableState.Never)]
2444 public void ResetImeMode() {
2445 ime_mode = DefaultImeMode;
2448 [EditorBrowsable(EditorBrowsableState.Never)]
2449 public virtual void ResetRightToLeft() {
2450 right_to_left = RightToLeft.Inherit;
2453 public virtual void ResetText() {
2457 public void ResumeLayout() {
2458 ResumeLayout (true);
2461 public void ResumeLayout(bool performLayout) {
2464 if (layout_suspended > 0) {
2468 if (performLayout || layout_pending) {
2473 public void Scale(float ratio) {
2474 ScaleCore(ratio, ratio);
2477 public void Scale(float dx, float dy) {
2481 public void Select() {
2482 Select(false, false);
2485 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2490 c = GetNextControl(c, forward);
2499 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
2503 } while (c != ctl); // If we wrap back to ourselves we stop
2508 public void SendToBack() {
2509 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2510 if (parent.child_controls.Contains(this)) {
2511 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2515 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2516 if (parent != null) {
2521 public void SetBounds(int x, int y, int width, int height) {
2522 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2525 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2526 SetBoundsCore(x, y, width, height, specified);
2529 public void Show() {
2530 if (!IsHandleCreated) {
2531 this.CreateHandle();
2537 public void SuspendLayout() {
2541 public void Update() {
2542 XplatUI.UpdateWindow(window.Handle);
2544 #endregion // Public Instance Methods
2546 #region Protected Instance Methods
2547 [EditorBrowsable(EditorBrowsableState.Advanced)]
2548 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2549 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2550 throw new NotImplementedException();
2553 [EditorBrowsable(EditorBrowsableState.Advanced)]
2554 protected virtual AccessibleObject CreateAccessibilityInstance() {
2555 return new Control.ControlAccessibleObject(this);
2558 [EditorBrowsable(EditorBrowsableState.Advanced)]
2559 protected virtual ControlCollection CreateControlsInstance() {
2560 return new ControlCollection(this);
2563 [EditorBrowsable(EditorBrowsableState.Advanced)]
2564 protected virtual void CreateHandle() {
2566 throw new ObjectDisposedException(Name);
2569 if (IsHandleCreated) {
2574 window = new ControlNativeWindow(this);
2575 window.CreateHandle(CreateParams);
2578 if (window.Handle!=IntPtr.Zero) {
2579 if (!controls.Contains(window.Handle)) {
2583 creator_thread = Thread.CurrentThread;
2585 XplatUI.SetWindowBackground(window.Handle, this.BackColor);
2587 OnHandleCreated(EventArgs.Empty);
2591 [EditorBrowsable(EditorBrowsableState.Advanced)]
2592 protected virtual void DefWndProc(ref Message m) {
2593 window.DefWndProc(ref m);
2596 [EditorBrowsable(EditorBrowsableState.Advanced)]
2597 protected virtual void DestroyHandle() {
2598 if (IsHandleCreated) {
2599 if (Handle != IntPtr.Zero) {
2600 controls.Remove(Handle);
2603 if (window != null) {
2604 window.DestroyHandle();
2609 protected bool GetStyle(ControlStyles flag) {
2610 return (control_style & flag) != 0;
2613 protected bool GetTopLevel() {
2617 [EditorBrowsable(EditorBrowsableState.Advanced)]
2618 protected virtual void InitLayout() {
2619 if (parent != null) {
2620 parent.PerformLayout(this, "parent");
2624 [EditorBrowsable(EditorBrowsableState.Advanced)]
2625 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2626 toInvoke.OnGotFocus(e);
2629 [EditorBrowsable(EditorBrowsableState.Advanced)]
2630 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2631 toInvoke.OnLostFocus(e);
2634 [EditorBrowsable(EditorBrowsableState.Advanced)]
2635 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2636 toInvoke.OnClick(e);
2639 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2640 toInvoke.OnPaint(e);
2643 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2644 toInvoke.OnPaintBackground(e);
2647 protected virtual bool IsInputChar (char charCode) {
2648 if (parent != null) {
2649 return parent.IsInputChar(charCode);
2655 protected virtual bool IsInputKey (Keys keyData) {
2656 // Doc says this one calls IsInputChar; not sure what to do with that
2660 [EditorBrowsable(EditorBrowsableState.Advanced)]
2661 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2665 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2666 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2670 if (parent != null) {
2671 return parent.ProcessCmdKey(ref msg, keyData);
2677 protected virtual bool ProcessDialogChar(char charCode) {
2678 if (parent != null) {
2679 return parent.ProcessDialogChar (charCode);
2685 protected virtual bool ProcessDialogKey (Keys keyData) {
2686 if (parent != null) {
2687 return parent.ProcessDialogKey (keyData);
2693 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2695 KeyEventArgs key_event;
2697 PreProcessMessage(ref msg);
2700 case (int)Msg.WM_KEYDOWN: {
2701 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2702 OnKeyDown (key_event);
2703 return key_event.Handled;
2705 case (int)Msg.WM_KEYUP: {
2706 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2707 OnKeyUp (key_event);
2708 return key_event.Handled;
2711 case (int)Msg.WM_CHAR: {
2712 KeyPressEventArgs key_press_event;
2714 key_press_event = new KeyPressEventArgs((char)msg.WParam);
2715 OnKeyPress(key_press_event);
2716 return key_press_event.Handled;
2727 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
2728 if (parent != null) {
2729 if (parent.ProcessKeyPreview(ref msg)) {
2734 return ProcessKeyEventArgs(ref msg);
2737 protected virtual bool ProcessKeyPreview(ref Message msg) {
2738 if (parent != null) {
2739 return parent.ProcessKeyPreview(ref msg);
2745 protected virtual bool ProcessMnemonic(char charCode) {
2750 [EditorBrowsable(EditorBrowsableState.Advanced)]
2751 protected void RaiseDragEvent(object key, DragEventArgs e) {
2755 [EditorBrowsable(EditorBrowsableState.Advanced)]
2756 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
2760 [EditorBrowsable(EditorBrowsableState.Advanced)]
2761 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
2765 [EditorBrowsable(EditorBrowsableState.Advanced)]
2766 protected void RaisePaintEvent(object key, PaintEventArgs e) {
2770 [EditorBrowsable(EditorBrowsableState.Advanced)]
2771 protected void RecreateHandle() {
2772 IEnumerator child = child_controls.GetEnumerator();
2776 if (IsHandleCreated) {
2782 while (child.MoveNext()) {
2783 ((Control)child.Current).RecreateHandle();
2789 is_recreating = false;
2792 [EditorBrowsable(EditorBrowsableState.Advanced)]
2793 protected void ResetMouseEventArgs() {
2797 [EditorBrowsable(EditorBrowsableState.Advanced)]
2798 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
2799 if (right_to_left == RightToLeft.No) {
2804 case ContentAlignment.TopLeft: {
2805 return ContentAlignment.TopRight;
2808 case ContentAlignment.TopRight: {
2809 return ContentAlignment.TopLeft;
2812 case ContentAlignment.MiddleLeft: {
2813 return ContentAlignment.MiddleRight;
2816 case ContentAlignment.MiddleRight: {
2817 return ContentAlignment.MiddleLeft;
2820 case ContentAlignment.BottomLeft: {
2821 return ContentAlignment.BottomRight;
2824 case ContentAlignment.BottomRight: {
2825 return ContentAlignment.BottomLeft;
2829 // if it's center it doesn't change
2835 [EditorBrowsable(EditorBrowsableState.Advanced)]
2836 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
2837 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
2841 if (align == HorizontalAlignment.Left) {
2842 return HorizontalAlignment.Right;
2845 // align must be HorizontalAlignment.Right
2846 return HorizontalAlignment.Left;
2849 [EditorBrowsable(EditorBrowsableState.Advanced)]
2850 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
2851 if (right_to_left == RightToLeft.No) {
2855 if (align == LeftRightAlignment.Left) {
2856 return LeftRightAlignment.Right;
2859 // align must be LeftRightAlignment.Right;
2860 return LeftRightAlignment.Left;
2863 [EditorBrowsable(EditorBrowsableState.Advanced)]
2864 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
2865 return RtlTranslateAlignment(align);
2868 [EditorBrowsable(EditorBrowsableState.Advanced)]
2869 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
2870 return RtlTranslateAlignment(align);
2873 [EditorBrowsable(EditorBrowsableState.Advanced)]
2874 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
2875 return RtlTranslateAlignment(align);
2878 [EditorBrowsable(EditorBrowsableState.Advanced)]
2879 protected virtual void ScaleCore(float dx, float dy) {
2885 location = new Point((int)(Left * dx), (int)(Top * dy));
2886 size = this.ClientSize;
2889 if (!GetStyle(ControlStyles.FixedWidth)) {
2890 size.Width = (int)(size.Width * dx);
2893 if (!GetStyle(ControlStyles.FixedHeight)) {
2894 size.Height = (int)(size.Height * dy);
2897 Location = location;
2900 /* Now scale our children */
2901 for (int i=0; i < child_controls.Count; i++) {
2902 child_controls[i].Scale(dx, dy);
2908 protected virtual void Select(bool directed, bool forward) {
2913 // Select this control
2918 if (parent == null) {
2922 index = parent.child_controls.IndexOf(this);
2927 if ((index+1) < parent.child_controls.Count) {
2936 index = parent.child_controls.Count-1;
2939 result = Select(parent.child_controls[index]);
2940 } while (!result && parent.child_controls[index] != this);
2943 [EditorBrowsable(EditorBrowsableState.Advanced)]
2944 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
2945 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
2946 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
2950 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
2954 if ((specified & BoundsSpecified.Width)!= BoundsSpecified.Width) {
2958 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
2962 if (IsHandleCreated) {
2963 XplatUI.SetWindowPos(Handle, x, y, width, height);
2965 UpdateBounds(x, y, width, height);
2968 [EditorBrowsable(EditorBrowsableState.Advanced)]
2969 protected virtual void SetClientSizeCore(int x, int y) {
2970 // Calculate the actual window size from the client size (it usually stays the same or grows)
2971 Rectangle ClientRect;
2972 Rectangle WindowRect;
2975 ClientRect = new Rectangle(0, 0, x, y);
2976 cp = this.CreateParams;
2978 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, false, out WindowRect)==false) {
2982 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
2985 [EditorBrowsable(EditorBrowsableState.Advanced)]
2986 protected void SetStyle(ControlStyles flag, bool value) {
2988 control_style |= flag;
2990 control_style &= ~flag;
2994 protected void SetTopLevel(bool value) {
2995 if ((GetTopLevel() != value) && (parent != null)) {
2996 throw new Exception();
3000 if (value == true) {
3010 is_toplevel = value;
3013 protected virtual void SetVisibleCore(bool value) {
3014 if (value!=is_visible) {
3016 XplatUI.SetVisible(Handle, value);
3017 OnVisibleChanged(EventArgs.Empty);
3019 if (dc_mem != null) {
3024 if (bmp_mem != null) {
3029 this.CreateBuffers(bounds.Width, bounds.Height);
3032 // FIXME - deal with focus
3034 if (parent != null) {
3035 parent.PerformLayout(this, "visible");
3037 PerformLayout(this, "visible");
3042 [EditorBrowsable(EditorBrowsableState.Advanced)]
3043 protected void UpdateBounds() {
3051 if (!IsHandleCreated) {
3055 XplatUI.GetWindowPos(this.Handle, out x, out y, out width, out height, out client_width, out client_height);
3056 UpdateBounds(x, y, width, height, client_width, client_height);
3059 [EditorBrowsable(EditorBrowsableState.Advanced)]
3060 protected void UpdateBounds(int x, int y, int width, int height) {
3061 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3063 bool resized = false;
3065 int client_x_diff = this.bounds.Width-this.client_size.Width;
3066 int client_y_diff = this.bounds.Height-this.client_size.Height;
3068 // Needed to generate required notifications
3069 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3073 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3080 bounds.Height=height;
3082 // Update client rectangle as well
3083 if (this.layout_suspended==0) {
3084 prev_size.Width=client_size.Width;
3085 prev_size.Height=client_size.Height;
3088 client_size.Width=width-client_x_diff;
3089 client_size.Height=height-client_y_diff;
3092 OnLocationChanged(EventArgs.Empty);
3096 OnSizeChanged(EventArgs.Empty);
3100 [EditorBrowsable(EditorBrowsableState.Advanced)]
3101 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3102 UpdateBounds(x, y, width, height);
3104 this.client_size.Width=clientWidth;
3105 this.client_size.Height=clientHeight;
3108 [EditorBrowsable(EditorBrowsableState.Advanced)]
3109 protected void UpdateStyles() {
3110 if (!IsHandleCreated) {
3114 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3117 protected void UpdateZOrder() {
3122 if (parent == null) {
3128 children = ctl.child_controls.Count;
3129 for (int i = 1; i < children; i++ ) {
3130 XplatUI.SetZOrder(ctl.child_controls[i].window.Handle, ctl.child_controls[i-1].window.Handle, false, false);
3133 children = child_controls.Count;
3134 for (int i = 1; i < children; i++ ) {
3135 XplatUI.SetZOrder(child_controls[i].window.Handle, child_controls[i-1].window.Handle, false, false);
3140 protected virtual void WndProc(ref Message m) {
3142 Console.WriteLine("Received message {0}", m);
3144 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3148 switch((Msg)m.Msg) {
3149 case Msg.WM_WINDOWPOSCHANGED: {
3152 if (GetStyle(ControlStyles.ResizeRedraw)) {
3159 case Msg.WM_PAINT: {
3160 PaintEventArgs paint_event;
3162 paint_event = XplatUI.PaintEventStart(Handle);
3163 OnPaint(paint_event);
3164 XplatUI.PaintEventEnd(Handle);
3169 case Msg.WM_ERASEBKGND: {
3170 if (GetStyle (ControlStyles.UserPaint)) {
3171 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3172 PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
3173 Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
3174 OnPaintBackground (eraseEventArgs);
3176 m.Result = (IntPtr)1;
3178 m.Result = IntPtr.Zero;
3185 case Msg.WM_LBUTTONUP: {
3186 HandleClick(mouse_clicks);
3187 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3189 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3191 if (mouse_clicks > 1) {
3197 case Msg.WM_LBUTTONDOWN: {
3198 if (CanSelect && !is_selected) {
3201 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3202 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3208 case Msg.WM_LBUTTONDBLCLK: {
3210 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3211 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3217 case Msg.WM_MBUTTONUP: {
3218 HandleClick(mouse_clicks);
3219 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3221 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3223 if (mouse_clicks > 1) {
3229 case Msg.WM_MBUTTONDOWN: {
3230 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3231 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3237 case Msg.WM_MBUTTONDBLCLK: {
3239 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3240 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3245 case Msg.WM_RBUTTONUP: {
3246 HandleClick(mouse_clicks);
3247 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3249 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3251 if (mouse_clicks > 1) {
3257 case Msg.WM_RBUTTONDOWN: {
3258 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3259 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3264 case Msg.WM_RBUTTONDBLCLK: {
3266 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3267 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3272 case Msg.WM_MOUSEWHEEL: {
3274 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3275 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3276 HighOrder(m.WParam.ToInt32())));
3281 case Msg.WM_MOUSEMOVE: {
3282 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3284 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3289 case Msg.WM_MOUSE_ENTER: {
3294 OnMouseEnter(EventArgs.Empty);
3298 case Msg.WM_MOUSE_LEAVE: {
3300 OnMouseLeave(EventArgs.Empty);
3304 case Msg.WM_MOUSEHOVER: {
3305 OnMouseHover(EventArgs.Empty);
3309 case Msg.WM_KEYDOWN: {
3310 if (!ProcessKeyMessage(ref m)) {
3316 case Msg.WM_KEYUP: {
3317 if (!ProcessKeyMessage(ref m)) {
3324 if (!ProcessKeyMessage(ref m)) {
3332 if (m.LParam != IntPtr.Zero) {
3335 hi = new HELPINFO();
3337 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3338 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3340 mouse_pos = Control.MousePosition;
3342 OnHelpRequested(new HelpEventArgs(mouse_pos));
3343 m.Result = (IntPtr)1;
3347 case Msg.WM_KILLFOCUS: {
3348 OnLeave(EventArgs.Empty);
3349 if (CausesValidation) {
3351 e = new CancelEventArgs(false);
3360 OnValidated(EventArgs.Empty);
3363 this.has_focus = false;
3364 this.is_selected = false;
3365 OnLostFocus(EventArgs.Empty);
3369 case Msg.WM_SETFOCUS: {
3370 OnEnter(EventArgs.Empty);
3371 this.has_focus = true;
3372 OnGotFocus(EventArgs.Empty);
3377 case Msg.WM_SYSCOLORCHANGE: {
3378 ThemeEngine.Current.ResetDefaults();
3379 OnSystemColorsChanged(EventArgs.Empty);
3384 case Msg.WM_SETCURSOR: {
3385 if (cursor == null) {
3390 XplatUI.SetCursor(window.Handle, cursor.handle);
3391 m.Result = (IntPtr)1;
3400 #endregion // Public Instance Methods
3402 #region OnXXX methods
3403 [EditorBrowsable(EditorBrowsableState.Advanced)]
3404 protected virtual void OnBackColorChanged(EventArgs e) {
3405 if (BackColorChanged!=null) BackColorChanged(this, e);
3406 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3409 [EditorBrowsable(EditorBrowsableState.Advanced)]
3410 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3411 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3412 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3415 [EditorBrowsable(EditorBrowsableState.Advanced)]
3416 protected virtual void OnBindingContextChanged(EventArgs e) {
3417 if (BindingContextChanged!=null) BindingContextChanged(this, e);
3418 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3421 [EditorBrowsable(EditorBrowsableState.Advanced)]
3422 protected virtual void OnCausesValidationChanged(EventArgs e) {
3423 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3426 [EditorBrowsable(EditorBrowsableState.Advanced)]
3427 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3428 if (ChangeUICues!=null) ChangeUICues(this, e);
3431 [EditorBrowsable(EditorBrowsableState.Advanced)]
3432 protected virtual void OnClick(EventArgs e) {
3433 if (Click!=null) Click(this, e);
3436 [EditorBrowsable(EditorBrowsableState.Advanced)]
3437 protected virtual void OnContextMenuChanged(EventArgs e) {
3438 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3441 [EditorBrowsable(EditorBrowsableState.Advanced)]
3442 protected virtual void OnControlAdded(ControlEventArgs e) {
3443 if (ControlAdded!=null) ControlAdded(this, e);
3446 [EditorBrowsable(EditorBrowsableState.Advanced)]
3447 protected virtual void OnControlRemoved(ControlEventArgs e) {
3448 if (ControlRemoved!=null) ControlRemoved(this, e);
3451 [EditorBrowsable(EditorBrowsableState.Advanced)]
3452 protected virtual void OnCreateControl() {
3456 [EditorBrowsable(EditorBrowsableState.Advanced)]
3457 protected virtual void OnCursorChanged(EventArgs e) {
3458 if (CursorChanged!=null) CursorChanged(this, e);
3461 [EditorBrowsable(EditorBrowsableState.Advanced)]
3462 protected virtual void OnDockChanged(EventArgs e) {
3463 if (DockChanged!=null) DockChanged(this, e);
3466 [EditorBrowsable(EditorBrowsableState.Advanced)]
3467 protected virtual void OnDoubleClick(EventArgs e) {
3468 if (DoubleClick!=null) DoubleClick(this, e);
3471 [EditorBrowsable(EditorBrowsableState.Advanced)]
3472 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3473 if (DragDrop!=null) DragDrop(this, drgevent);
3476 [EditorBrowsable(EditorBrowsableState.Advanced)]
3477 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3478 if (DragEnter!=null) DragEnter(this, drgevent);
3481 [EditorBrowsable(EditorBrowsableState.Advanced)]
3482 protected virtual void OnDragLeave(EventArgs e) {
3483 if (DragLeave!=null) DragLeave(this, e);
3486 [EditorBrowsable(EditorBrowsableState.Advanced)]
3487 protected virtual void OnDragOver(DragEventArgs drgevent) {
3488 if (DragOver!=null) DragOver(this, drgevent);
3491 [EditorBrowsable(EditorBrowsableState.Advanced)]
3492 protected virtual void OnEnabledChanged(EventArgs e) {
3493 if (EnabledChanged!=null) EnabledChanged(this, e);
3494 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3497 [EditorBrowsable(EditorBrowsableState.Advanced)]
3498 protected virtual void OnEnter(EventArgs e) {
3499 if (Enter!=null) Enter(this, e);
3502 [EditorBrowsable(EditorBrowsableState.Advanced)]
3503 protected virtual void OnFontChanged(EventArgs e) {
3504 if (FontChanged!=null) FontChanged(this, e);
3505 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3508 [EditorBrowsable(EditorBrowsableState.Advanced)]
3509 protected virtual void OnForeColorChanged(EventArgs e) {
3510 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3511 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3514 [EditorBrowsable(EditorBrowsableState.Advanced)]
3515 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3516 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3519 [EditorBrowsable(EditorBrowsableState.Advanced)]
3520 protected virtual void OnGotFocus(EventArgs e) {
3521 if (GotFocus!=null) GotFocus(this, e);
3524 [EditorBrowsable(EditorBrowsableState.Advanced)]
3525 protected virtual void OnHandleCreated(EventArgs e) {
3526 if (HandleCreated!=null) HandleCreated(this, e);
3529 [EditorBrowsable(EditorBrowsableState.Advanced)]
3530 protected virtual void OnHandleDestroyed(EventArgs e) {
3531 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3534 [EditorBrowsable(EditorBrowsableState.Advanced)]
3535 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3536 if (HelpRequested!=null) HelpRequested(this, hevent);
3539 protected virtual void OnImeModeChanged(EventArgs e) {
3540 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3543 [EditorBrowsable(EditorBrowsableState.Advanced)]
3544 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3545 if (Invalidated!=null) Invalidated(this, e);
3548 [EditorBrowsable(EditorBrowsableState.Advanced)]
3549 protected virtual void OnKeyDown(KeyEventArgs e) {
3550 if (KeyDown!=null) KeyDown(this, e);
3553 [EditorBrowsable(EditorBrowsableState.Advanced)]
3554 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3555 if (KeyPress!=null) KeyPress(this, e);
3558 [EditorBrowsable(EditorBrowsableState.Advanced)]
3559 protected virtual void OnKeyUp(KeyEventArgs e) {
3560 if (KeyUp!=null) KeyUp(this, e);
3563 [EditorBrowsable(EditorBrowsableState.Advanced)]
3564 protected virtual void OnLayout(LayoutEventArgs levent) {
3565 if (Layout!=null) Layout(this, levent);
3568 [EditorBrowsable(EditorBrowsableState.Advanced)]
3569 protected virtual void OnLeave(EventArgs e) {
3570 if (Leave!=null) Leave(this, e);
3573 [EditorBrowsable(EditorBrowsableState.Advanced)]
3574 protected virtual void OnLocationChanged(EventArgs e) {
3576 if (LocationChanged!=null) LocationChanged(this, e);
3579 [EditorBrowsable(EditorBrowsableState.Advanced)]
3580 protected virtual void OnLostFocus(EventArgs e) {
3581 if (LostFocus!=null) LostFocus(this, e);
3584 [EditorBrowsable(EditorBrowsableState.Advanced)]
3585 protected virtual void OnMouseDown(MouseEventArgs e) {
3586 if (MouseDown!=null) MouseDown(this, e);
3589 [EditorBrowsable(EditorBrowsableState.Advanced)]
3590 protected virtual void OnMouseEnter(EventArgs e) {
3591 if (MouseEnter!=null) MouseEnter(this, e);
3594 [EditorBrowsable(EditorBrowsableState.Advanced)]
3595 protected virtual void OnMouseHover(EventArgs e) {
3596 if (MouseHover!=null) MouseHover(this, e);
3599 [EditorBrowsable(EditorBrowsableState.Advanced)]
3600 protected virtual void OnMouseLeave(EventArgs e) {
3601 if (MouseLeave!=null) MouseLeave(this, e);
3604 [EditorBrowsable(EditorBrowsableState.Advanced)]
3605 protected virtual void OnMouseMove(MouseEventArgs e) {
3606 if (MouseMove!=null) MouseMove(this, e);
3609 [EditorBrowsable(EditorBrowsableState.Advanced)]
3610 protected virtual void OnMouseUp(MouseEventArgs e) {
3611 if (MouseUp!=null) MouseUp(this, e);
3614 [EditorBrowsable(EditorBrowsableState.Advanced)]
3615 protected virtual void OnMouseWheel(MouseEventArgs e) {
3616 if (MouseWheel!=null) MouseWheel(this, e);
3619 [EditorBrowsable(EditorBrowsableState.Advanced)]
3620 protected virtual void OnMove(EventArgs e) {
3621 if (Move!=null) Move(this, e);
3624 [EditorBrowsable(EditorBrowsableState.Advanced)]
3625 protected virtual void OnNotifyMessage(Message m) {
3629 [EditorBrowsable(EditorBrowsableState.Advanced)]
3630 protected virtual void OnPaint(PaintEventArgs e) {
3631 if (Paint!=null) Paint(this, e);
3634 [EditorBrowsable(EditorBrowsableState.Advanced)]
3635 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3639 [EditorBrowsable(EditorBrowsableState.Advanced)]
3640 protected virtual void OnParentBackColorChanged(EventArgs e) {
3641 if (background_color.IsEmpty && background_image==null) {
3643 OnBackColorChanged(e);
3647 [EditorBrowsable(EditorBrowsableState.Advanced)]
3648 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3649 if (background_color.IsEmpty && background_image==null) {
3651 OnBackgroundImageChanged(e);
3655 [EditorBrowsable(EditorBrowsableState.Advanced)]
3656 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3657 if (binding_context==null) {
3658 binding_context=Parent.binding_context;
3659 OnBindingContextChanged(e);
3663 [EditorBrowsable(EditorBrowsableState.Advanced)]
3664 protected virtual void OnParentChanged(EventArgs e) {
3665 if (ParentChanged!=null) ParentChanged(this, e);
3668 [EditorBrowsable(EditorBrowsableState.Advanced)]
3669 protected virtual void OnParentEnabledChanged(EventArgs e) {
3670 if (is_enabled != Parent.is_enabled) {
3671 is_enabled=Parent.is_enabled;
3673 if (EnabledChanged != null) {
3674 EnabledChanged(this, e);
3679 [EditorBrowsable(EditorBrowsableState.Advanced)]
3680 protected virtual void OnParentFontChanged(EventArgs e) {
3687 [EditorBrowsable(EditorBrowsableState.Advanced)]
3688 protected virtual void OnParentForeColorChanged(EventArgs e) {
3689 if (foreground_color.IsEmpty) {
3691 OnForeColorChanged(e);
3695 [EditorBrowsable(EditorBrowsableState.Advanced)]
3696 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
3697 if (right_to_left==RightToLeft.Inherit) {
3699 OnRightToLeftChanged(e);
3703 [EditorBrowsable(EditorBrowsableState.Advanced)]
3704 protected virtual void OnParentVisibleChanged(EventArgs e) {
3705 if (is_visible!=Parent.is_visible) {
3708 OnVisibleChanged(e);
3712 [EditorBrowsable(EditorBrowsableState.Advanced)]
3713 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
3714 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
3717 [EditorBrowsable(EditorBrowsableState.Advanced)]
3718 protected virtual void OnResize(EventArgs e) {
3719 if (Resize!=null) Resize(this, e);
3721 PerformLayout(this, "bounds");
3723 if (parent != null) {
3724 parent.PerformLayout();
3728 [EditorBrowsable(EditorBrowsableState.Advanced)]
3729 protected virtual void OnRightToLeftChanged(EventArgs e) {
3730 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
3731 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
3734 [EditorBrowsable(EditorBrowsableState.Advanced)]
3735 protected virtual void OnSizeChanged(EventArgs e) {
3736 InvalidateBuffers ();
3738 if (SizeChanged!=null) SizeChanged(this, e);
3741 [EditorBrowsable(EditorBrowsableState.Advanced)]
3742 protected virtual void OnStyleChanged(EventArgs e) {
3743 if (StyleChanged!=null) StyleChanged(this, e);
3746 [EditorBrowsable(EditorBrowsableState.Advanced)]
3747 protected virtual void OnSystemColorsChanged(EventArgs e) {
3748 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
3751 [EditorBrowsable(EditorBrowsableState.Advanced)]
3752 protected virtual void OnTabIndexChanged(EventArgs e) {
3753 if (TabIndexChanged!=null) TabIndexChanged(this, e);
3756 [EditorBrowsable(EditorBrowsableState.Advanced)]
3757 protected virtual void OnTabStopChanged(EventArgs e) {
3758 if (TabStopChanged!=null) TabStopChanged(this, e);
3761 [EditorBrowsable(EditorBrowsableState.Advanced)]
3762 protected virtual void OnTextChanged(EventArgs e) {
3763 if (TextChanged!=null) TextChanged(this, e);
3766 [EditorBrowsable(EditorBrowsableState.Advanced)]
3767 protected virtual void OnValidated(EventArgs e) {
3768 if (Validated!=null) Validated(this, e);
3771 [EditorBrowsable(EditorBrowsableState.Advanced)]
3772 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
3773 if (Validating!=null) Validating(this, e);
3776 [EditorBrowsable(EditorBrowsableState.Advanced)]
3777 protected virtual void OnVisibleChanged(EventArgs e) {
3784 if (bmp_mem!=null) {
3790 if (!this.IsHandleCreated) {
3791 this.CreateHandle();
3797 if (VisibleChanged!=null) VisibleChanged(this, e);
3799 // We need to tell our kids
3800 for (int i=0; i<child_controls.Count; i++) {
3801 child_controls[i].OnParentVisibleChanged(e);
3804 #endregion // OnXXX methods
3807 public event EventHandler BackColorChanged;
3808 public event EventHandler BackgroundImageChanged;
3809 public event EventHandler BindingContextChanged;
3810 public event EventHandler CausesValidationChanged;
3811 public event UICuesEventHandler ChangeUICues;
3812 public event EventHandler Click;
3813 public event EventHandler ContextMenuChanged;
3815 [EditorBrowsable(EditorBrowsableState.Advanced)]
3817 public event ControlEventHandler ControlAdded;
3819 [EditorBrowsable(EditorBrowsableState.Advanced)]
3821 public event ControlEventHandler ControlRemoved;
3823 public event EventHandler CursorChanged;
3824 public event EventHandler DockChanged;
3825 public event EventHandler DoubleClick;
3826 public event DragEventHandler DragDrop;
3827 public event DragEventHandler DragEnter;
3828 public event EventHandler DragLeave;
3829 public event DragEventHandler DragOver;
3830 public event EventHandler EnabledChanged;
3831 public event EventHandler Enter;
3832 public event EventHandler FontChanged;
3833 public event EventHandler ForeColorChanged;
3834 public event GiveFeedbackEventHandler GiveFeedback;
3836 [EditorBrowsable(EditorBrowsableState.Advanced)]
3838 public event EventHandler GotFocus;
3840 [EditorBrowsable(EditorBrowsableState.Advanced)]
3842 public event EventHandler HandleCreated;
3844 [EditorBrowsable(EditorBrowsableState.Advanced)]
3846 public event EventHandler HandleDestroyed;
3848 public event HelpEventHandler HelpRequested;
3849 public event EventHandler ImeModeChanged;
3851 [EditorBrowsable(EditorBrowsableState.Advanced)]
3853 public event InvalidateEventHandler Invalidated;
3855 public event KeyEventHandler KeyDown;
3856 public event KeyPressEventHandler KeyPress;
3857 public event KeyEventHandler KeyUp;
3858 public event LayoutEventHandler Layout;
3859 public event EventHandler Leave;
3860 public event EventHandler LocationChanged;
3862 [EditorBrowsable(EditorBrowsableState.Advanced)]
3864 public event EventHandler LostFocus;
3866 public event MouseEventHandler MouseDown;
3867 public event EventHandler MouseEnter;
3868 public event EventHandler MouseHover;
3869 public event EventHandler MouseLeave;
3870 public event MouseEventHandler MouseMove;
3871 public event MouseEventHandler MouseUp;
3873 [EditorBrowsable(EditorBrowsableState.Advanced)]
3875 public event MouseEventHandler MouseWheel;
3877 public event EventHandler Move;
3878 public event PaintEventHandler Paint;
3879 public event EventHandler ParentChanged;
3880 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
3881 public event QueryContinueDragEventHandler QueryContinueDrag;
3882 public event EventHandler Resize;
3883 public event EventHandler RightToLeftChanged;
3884 public event EventHandler SizeChanged;
3885 public event EventHandler StyleChanged;
3886 public event EventHandler SystemColorsChanged;
3887 public event EventHandler TabIndexChanged;
3888 public event EventHandler TabStopChanged;
3889 public event EventHandler TextChanged;
3890 public event EventHandler Validated;
3891 public event CancelEventHandler Validating;
3892 public event EventHandler VisibleChanged;
3893 #endregion // Events