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 private 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) {
2105 XplatUI.SetFocus(window.Handle);
2110 public Control GetChildAtPoint(Point pt) {
2111 // Microsoft's version of this function doesn't seem to work, so I can't check
2112 // if we only consider children or also grandchildren, etc.
2113 // I'm gonna say 'children only'
2114 for (int i=0; i<child_controls.Count; i++) {
2115 if (child_controls[i].Bounds.Contains(pt)) {
2116 return child_controls[i];
2122 public IContainerControl GetContainerControl() {
2123 Control current = this;
2125 while (current!=null) {
2126 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2127 return (IContainerControl)current;
2129 current = current.parent;
2134 public Control GetNextControl(Control ctl, bool forward) {
2135 // If we're not a container we don't play
2136 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2140 // If ctl is not contained by this, we start at the first child of this
2141 if (!this.Contains(ctl)) {
2145 // Search through our controls, starting at ctl, stepping into children as we encounter them
2146 // try to find the control with the tabindex closest to our own, or, if we're looking into
2147 // child controls, the one with the smallest tabindex
2149 return FindControlForward(this, ctl);
2151 return FindControlBackward(this, ctl);
2154 public void Hide() {
2155 this.Visible = false;
2158 public void Invalidate() {
2159 Invalidate(ClientRectangle, false);
2162 public void Invalidate(bool invalidateChildren) {
2163 Invalidate(ClientRectangle, invalidateChildren);
2166 public void Invalidate(System.Drawing.Rectangle rc) {
2167 Invalidate(rc, false);
2170 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2171 if (!IsHandleCreated || !Visible) {
2175 NotifyInvalidate(rc);
2177 XplatUI.Invalidate(Handle, rc, !GetStyle (ControlStyles.AllPaintingInWmPaint));
2179 if (invalidateChildren) {
2180 for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2182 OnInvalidated(new InvalidateEventArgs(rc));
2185 public void Invalidate(System.Drawing.Region region) {
2186 Invalidate(region, false);
2189 [MonoTODO("Figure out if GetRegionScans is usable")]
2190 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2191 throw new NotImplementedException();
2193 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2194 //if (invalidateChildren) {
2195 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2199 public object Invoke (Delegate method) {
2200 return Invoke(method, null);
2203 public object Invoke (Delegate method, object[] args) {
2204 IAsyncResult result = BeginInvoke (method, args);
2205 return EndInvoke(result);
2208 [EditorBrowsable(EditorBrowsableState.Advanced)]
2209 public void PerformLayout() {
2210 PerformLayout(null, null);
2213 [EditorBrowsable(EditorBrowsableState.Advanced)]
2214 public void PerformLayout(Control affectedControl, string affectedProperty) {
2215 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2217 if (layout_suspended>0) {
2218 layout_pending = true;
2222 layout_pending = false;
2224 // Prevent us from getting messed up
2227 // Perform all Dock and Anchor calculations
2230 AnchorStyles anchor;
2235 space=this.DisplayRectangle;
2236 if (prev_size != Size.Empty) {
2237 diff_width = space.Width - prev_size.Width;
2238 diff_height = space.Height - prev_size.Height;
2244 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2245 for (int i = child_controls.Count - 1; i >= 0; i--) {
2246 child=child_controls[i];
2247 switch (child.Dock) {
2248 case DockStyle.None: {
2253 case DockStyle.Left: {
2254 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2255 space.X+=child.Width;
2256 space.Width-=child.Width;
2260 case DockStyle.Top: {
2261 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2262 space.Y+=child.Height;
2263 space.Height-=child.Height;
2267 case DockStyle.Right: {
2268 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2269 space.Width-=child.Width;
2273 case DockStyle.Bottom: {
2274 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2275 space.Height-=child.Height;
2279 case DockStyle.Fill: {
2280 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2288 space=this.DisplayRectangle;
2290 // Deal with anchoring
2291 for (int i=0; i < child_controls.Count; i++) {
2297 child=child_controls[i];
2298 anchor=child.Anchor;
2303 height=child.Height;
2305 // If the control is docked we don't need to do anything
2306 if (child.Dock != DockStyle.None) {
2310 if ((anchor & AnchorStyles.Left) !=0 ) {
2311 if ((anchor & AnchorStyles.Right) != 0) {
2312 // Anchoring to left and right
2313 width=width+diff_width;
2317 } else if ((anchor & AnchorStyles.Right) != 0) {
2323 if ((anchor & AnchorStyles.Top) !=0 ) {
2324 if ((anchor & AnchorStyles.Bottom) != 0) {
2325 height+=diff_height;
2329 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2344 child.SetBounds(left, top, width, height);
2347 // Let everyone know
2351 // Need to make sure we decremend layout_suspended
2357 public Point PointToClient (Point p) {
2361 XplatUI.ScreenToClient (Handle, ref x, ref y);
2363 return new Point (x, y);
2366 public Point PointToScreen(Point p) {
2370 XplatUI.ClientToScreen(Handle, ref x, ref y);
2372 return new Point(x, y);
2375 public virtual bool PreProcessMessage(ref Message msg) {
2378 if (msg.Msg == (int)Msg.WM_KEYDOWN) {
2379 key_data = (Keys)msg.WParam.ToInt32();
2380 if (!ProcessCmdKey(ref msg, key_data)) {
2381 if (IsInputKey(key_data)) {
2385 return ProcessDialogKey(key_data);
2389 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2390 if (IsInputChar((char)msg.WParam)) {
2394 return ProcessDialogChar((char)msg.WParam);
2400 public Rectangle RectangleToClient(Rectangle r) {
2401 return new Rectangle(PointToClient(r.Location), r.Size);
2404 public Rectangle RectangleToScreen(Rectangle r) {
2405 return new Rectangle(PointToScreen(r.Location), r.Size);
2408 public virtual void Refresh() {
2409 if (IsHandleCreated == true) {
2410 XplatUI.RefreshWindow(window.Handle);
2414 [EditorBrowsable(EditorBrowsableState.Never)]
2415 public virtual void ResetBackColor() {
2416 background_color = Color.Empty;
2419 #if haveDataBindings
2420 [EditorBrowsable(EditorBrowsableState.Never)]
2422 public void ResetBindings() {
2427 [EditorBrowsable(EditorBrowsableState.Never)]
2428 public virtual void ResetCursor() {
2432 [EditorBrowsable(EditorBrowsableState.Never)]
2433 public virtual void ResetFont() {
2437 [EditorBrowsable(EditorBrowsableState.Never)]
2438 public virtual void ResetForeColor() {
2439 foreground_color = Color.Empty;
2442 [EditorBrowsable(EditorBrowsableState.Never)]
2443 public void ResetImeMode() {
2444 ime_mode = DefaultImeMode;
2447 [EditorBrowsable(EditorBrowsableState.Never)]
2448 public virtual void ResetRightToLeft() {
2449 right_to_left = RightToLeft.Inherit;
2452 public virtual void ResetText() {
2456 public void ResumeLayout() {
2457 ResumeLayout (true);
2460 public void ResumeLayout(bool performLayout) {
2463 if (layout_suspended > 0) {
2467 if (performLayout || layout_pending) {
2472 public void Scale(float ratio) {
2473 ScaleCore(ratio, ratio);
2476 public void Scale(float dx, float dy) {
2480 public void Select() {
2481 Select(false, false);
2484 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2489 c = GetNextControl(c, forward);
2498 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
2502 } while (c != ctl); // If we wrap back to ourselves we stop
2507 public void SendToBack() {
2508 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2509 if (parent.child_controls.Contains(this)) {
2510 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2514 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2515 if (parent != null) {
2520 public void SetBounds(int x, int y, int width, int height) {
2521 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2524 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2525 SetBoundsCore(x, y, width, height, specified);
2528 public void Show() {
2529 if (!IsHandleCreated) {
2530 this.CreateHandle();
2536 public void SuspendLayout() {
2540 public void Update() {
2541 XplatUI.UpdateWindow(window.Handle);
2543 #endregion // Public Instance Methods
2545 #region Protected Instance Methods
2546 [EditorBrowsable(EditorBrowsableState.Advanced)]
2547 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2548 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2549 throw new NotImplementedException();
2552 [EditorBrowsable(EditorBrowsableState.Advanced)]
2553 protected virtual AccessibleObject CreateAccessibilityInstance() {
2554 return new Control.ControlAccessibleObject(this);
2557 [EditorBrowsable(EditorBrowsableState.Advanced)]
2558 protected virtual ControlCollection CreateControlsInstance() {
2559 return new ControlCollection(this);
2562 [EditorBrowsable(EditorBrowsableState.Advanced)]
2563 protected virtual void CreateHandle() {
2565 throw new ObjectDisposedException(Name);
2568 if (IsHandleCreated) {
2573 window = new ControlNativeWindow(this);
2574 window.CreateHandle(CreateParams);
2577 if (window.Handle!=IntPtr.Zero) {
2578 if (!controls.Contains(window.Handle)) {
2582 creator_thread = Thread.CurrentThread;
2584 XplatUI.SetWindowBackground(window.Handle, this.BackColor);
2586 OnHandleCreated(EventArgs.Empty);
2590 [EditorBrowsable(EditorBrowsableState.Advanced)]
2591 protected virtual void DefWndProc(ref Message m) {
2592 window.DefWndProc(ref m);
2595 [EditorBrowsable(EditorBrowsableState.Advanced)]
2596 protected virtual void DestroyHandle() {
2597 if (IsHandleCreated) {
2598 if (Handle != IntPtr.Zero) {
2599 controls.Remove(Handle);
2602 if (window != null) {
2603 window.DestroyHandle();
2608 protected bool GetStyle(ControlStyles flag) {
2609 return (control_style & flag) != 0;
2612 protected bool GetTopLevel() {
2616 [EditorBrowsable(EditorBrowsableState.Advanced)]
2617 protected virtual void InitLayout() {
2618 if (parent != null) {
2619 parent.PerformLayout(this, "parent");
2623 [EditorBrowsable(EditorBrowsableState.Advanced)]
2624 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2625 toInvoke.OnGotFocus(e);
2628 [EditorBrowsable(EditorBrowsableState.Advanced)]
2629 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2630 toInvoke.OnLostFocus(e);
2633 [EditorBrowsable(EditorBrowsableState.Advanced)]
2634 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2635 toInvoke.OnClick(e);
2638 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2639 toInvoke.OnPaint(e);
2642 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2643 toInvoke.OnPaintBackground(e);
2646 protected virtual bool IsInputChar (char charCode) {
2647 if (parent != null) {
2648 return parent.IsInputChar(charCode);
2654 protected virtual bool IsInputKey (Keys keyData) {
2655 // Doc says this one calls IsInputChar; not sure what to do with that
2659 [EditorBrowsable(EditorBrowsableState.Advanced)]
2660 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2664 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2665 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2669 if (parent != null) {
2670 return parent.ProcessCmdKey(ref msg, keyData);
2676 protected virtual bool ProcessDialogChar(char charCode) {
2677 if (parent != null) {
2678 return parent.ProcessDialogChar (charCode);
2684 protected virtual bool ProcessDialogKey (Keys keyData) {
2685 if (parent != null) {
2686 return parent.ProcessDialogKey (keyData);
2692 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2694 KeyEventArgs key_event;
2696 PreProcessMessage(ref msg);
2699 case (int)Msg.WM_KEYDOWN: {
2700 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2701 OnKeyDown (key_event);
2702 return key_event.Handled;
2704 case (int)Msg.WM_KEYUP: {
2705 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2706 OnKeyUp (key_event);
2707 return key_event.Handled;
2710 case (int)Msg.WM_CHAR: {
2711 KeyPressEventArgs key_press_event;
2713 key_press_event = new KeyPressEventArgs((char)msg.WParam);
2714 OnKeyPress(key_press_event);
2715 return key_press_event.Handled;
2726 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
2727 if (parent != null) {
2728 if (parent.ProcessKeyPreview(ref msg)) {
2733 return ProcessKeyEventArgs(ref msg);
2736 protected virtual bool ProcessKeyPreview(ref Message msg) {
2737 if (parent != null) {
2738 return parent.ProcessKeyPreview(ref msg);
2744 protected virtual bool ProcessMnemonic(char charCode) {
2749 [EditorBrowsable(EditorBrowsableState.Advanced)]
2750 protected void RaiseDragEvent(object key, DragEventArgs e) {
2754 [EditorBrowsable(EditorBrowsableState.Advanced)]
2755 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
2759 [EditorBrowsable(EditorBrowsableState.Advanced)]
2760 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
2764 [EditorBrowsable(EditorBrowsableState.Advanced)]
2765 protected void RaisePaintEvent(object key, PaintEventArgs e) {
2769 [EditorBrowsable(EditorBrowsableState.Advanced)]
2770 protected void RecreateHandle() {
2771 IEnumerator child = child_controls.GetEnumerator();
2775 if (IsHandleCreated) {
2781 while (child.MoveNext()) {
2782 ((Control)child.Current).RecreateHandle();
2788 is_recreating = false;
2791 [EditorBrowsable(EditorBrowsableState.Advanced)]
2792 protected void ResetMouseEventArgs() {
2796 [EditorBrowsable(EditorBrowsableState.Advanced)]
2797 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
2798 if (right_to_left == RightToLeft.No) {
2803 case ContentAlignment.TopLeft: {
2804 return ContentAlignment.TopRight;
2807 case ContentAlignment.TopRight: {
2808 return ContentAlignment.TopLeft;
2811 case ContentAlignment.MiddleLeft: {
2812 return ContentAlignment.MiddleRight;
2815 case ContentAlignment.MiddleRight: {
2816 return ContentAlignment.MiddleLeft;
2819 case ContentAlignment.BottomLeft: {
2820 return ContentAlignment.BottomRight;
2823 case ContentAlignment.BottomRight: {
2824 return ContentAlignment.BottomLeft;
2828 // if it's center it doesn't change
2834 [EditorBrowsable(EditorBrowsableState.Advanced)]
2835 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
2836 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
2840 if (align == HorizontalAlignment.Left) {
2841 return HorizontalAlignment.Right;
2844 // align must be HorizontalAlignment.Right
2845 return HorizontalAlignment.Left;
2848 [EditorBrowsable(EditorBrowsableState.Advanced)]
2849 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
2850 if (right_to_left == RightToLeft.No) {
2854 if (align == LeftRightAlignment.Left) {
2855 return LeftRightAlignment.Right;
2858 // align must be LeftRightAlignment.Right;
2859 return LeftRightAlignment.Left;
2862 [EditorBrowsable(EditorBrowsableState.Advanced)]
2863 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
2864 return RtlTranslateAlignment(align);
2867 [EditorBrowsable(EditorBrowsableState.Advanced)]
2868 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
2869 return RtlTranslateAlignment(align);
2872 [EditorBrowsable(EditorBrowsableState.Advanced)]
2873 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
2874 return RtlTranslateAlignment(align);
2877 [EditorBrowsable(EditorBrowsableState.Advanced)]
2878 protected virtual void ScaleCore(float dx, float dy) {
2884 location = new Point((int)(Left * dx), (int)(Top * dy));
2885 size = this.ClientSize;
2888 if (!GetStyle(ControlStyles.FixedWidth)) {
2889 size.Width = (int)(size.Width * dx);
2892 if (!GetStyle(ControlStyles.FixedHeight)) {
2893 size.Height = (int)(size.Height * dy);
2896 Location = location;
2899 /* Now scale our children */
2900 for (int i=0; i < child_controls.Count; i++) {
2901 child_controls[i].Scale(dx, dy);
2907 protected virtual void Select(bool directed, bool forward) {
2912 // Select this control
2917 if (parent == null) {
2921 index = parent.child_controls.IndexOf(this);
2926 if ((index+1) < parent.child_controls.Count) {
2935 index = parent.child_controls.Count-1;
2938 result = Select(parent.child_controls[index]);
2939 } while (!result && parent.child_controls[index] != this);
2942 [EditorBrowsable(EditorBrowsableState.Advanced)]
2943 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
2944 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
2945 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
2949 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
2953 if ((specified & BoundsSpecified.Width)!= BoundsSpecified.Width) {
2957 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
2961 if (IsHandleCreated) {
2962 XplatUI.SetWindowPos(Handle, x, y, width, height);
2964 UpdateBounds(x, y, width, height);
2967 [EditorBrowsable(EditorBrowsableState.Advanced)]
2968 protected virtual void SetClientSizeCore(int x, int y) {
2969 // Calculate the actual window size from the client size (it usually stays the same or grows)
2970 Rectangle ClientRect;
2971 Rectangle WindowRect;
2974 ClientRect = new Rectangle(0, 0, x, y);
2975 cp = this.CreateParams;
2977 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, false, out WindowRect)==false) {
2981 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
2984 [EditorBrowsable(EditorBrowsableState.Advanced)]
2985 protected void SetStyle(ControlStyles flag, bool value) {
2987 control_style |= flag;
2989 control_style &= ~flag;
2993 protected void SetTopLevel(bool value) {
2994 if ((GetTopLevel() != value) && (parent != null)) {
2995 throw new Exception();
2999 if (value == true) {
3009 is_toplevel = value;
3012 protected virtual void SetVisibleCore(bool value) {
3013 if (value!=is_visible) {
3015 XplatUI.SetVisible(Handle, value);
3016 OnVisibleChanged(EventArgs.Empty);
3018 if (dc_mem != null) {
3023 if (bmp_mem != null) {
3028 this.CreateBuffers(bounds.Width, bounds.Height);
3031 // FIXME - deal with focus
3033 if (parent != null) {
3034 parent.PerformLayout(this, "visible");
3036 PerformLayout(this, "visible");
3041 [EditorBrowsable(EditorBrowsableState.Advanced)]
3042 protected void UpdateBounds() {
3050 if (!IsHandleCreated) {
3054 XplatUI.GetWindowPos(this.Handle, out x, out y, out width, out height, out client_width, out client_height);
3055 UpdateBounds(x, y, width, height, client_width, client_height);
3058 [EditorBrowsable(EditorBrowsableState.Advanced)]
3059 protected void UpdateBounds(int x, int y, int width, int height) {
3060 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3062 bool resized = false;
3064 int client_x_diff = this.bounds.Width-this.client_size.Width;
3065 int client_y_diff = this.bounds.Height-this.client_size.Height;
3067 // Needed to generate required notifications
3068 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3072 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3079 bounds.Height=height;
3081 // Update client rectangle as well
3082 if (this.layout_suspended==0) {
3083 prev_size.Width=client_size.Width;
3084 prev_size.Height=client_size.Height;
3087 client_size.Width=width-client_x_diff;
3088 client_size.Height=height-client_y_diff;
3091 OnLocationChanged(EventArgs.Empty);
3095 OnSizeChanged(EventArgs.Empty);
3099 [EditorBrowsable(EditorBrowsableState.Advanced)]
3100 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3101 UpdateBounds(x, y, width, height);
3103 this.client_size.Width=clientWidth;
3104 this.client_size.Height=clientHeight;
3107 [EditorBrowsable(EditorBrowsableState.Advanced)]
3108 protected void UpdateStyles() {
3109 if (!IsHandleCreated) {
3113 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3116 protected void UpdateZOrder() {
3121 if (parent == null) {
3127 children = ctl.child_controls.Count;
3128 for (int i = 1; i < children; i++ ) {
3129 XplatUI.SetZOrder(ctl.child_controls[i].window.Handle, ctl.child_controls[i-1].window.Handle, false, false);
3132 children = child_controls.Count;
3133 for (int i = 1; i < children; i++ ) {
3134 XplatUI.SetZOrder(child_controls[i].window.Handle, child_controls[i-1].window.Handle, false, false);
3139 protected virtual void WndProc(ref Message m) {
3141 Console.WriteLine("Received message {0}", m);
3143 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3147 switch((Msg)m.Msg) {
3148 case Msg.WM_WINDOWPOSCHANGED: {
3151 if (GetStyle(ControlStyles.ResizeRedraw)) {
3158 case Msg.WM_PAINT: {
3159 PaintEventArgs paint_event;
3161 paint_event = XplatUI.PaintEventStart(Handle);
3162 OnPaint(paint_event);
3163 XplatUI.PaintEventEnd(Handle);
3168 case Msg.WM_ERASEBKGND: {
3169 if (GetStyle (ControlStyles.UserPaint)) {
3170 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3171 PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
3172 Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
3173 OnPaintBackground (eraseEventArgs);
3175 m.Result = (IntPtr)1;
3177 m.Result = IntPtr.Zero;
3184 case Msg.WM_LBUTTONUP: {
3185 HandleClick(mouse_clicks);
3186 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3188 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3190 if (mouse_clicks > 1) {
3196 case Msg.WM_LBUTTONDOWN: {
3197 if (CanSelect && !is_selected) {
3200 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3201 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3207 case Msg.WM_LBUTTONDBLCLK: {
3209 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3210 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3216 case Msg.WM_MBUTTONUP: {
3217 HandleClick(mouse_clicks);
3218 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3220 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3222 if (mouse_clicks > 1) {
3228 case Msg.WM_MBUTTONDOWN: {
3229 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3230 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3236 case Msg.WM_MBUTTONDBLCLK: {
3238 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3239 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3244 case Msg.WM_RBUTTONUP: {
3245 HandleClick(mouse_clicks);
3246 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3248 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3250 if (mouse_clicks > 1) {
3256 case Msg.WM_RBUTTONDOWN: {
3257 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3258 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3263 case Msg.WM_RBUTTONDBLCLK: {
3265 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3266 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3271 case Msg.WM_MOUSEWHEEL: {
3273 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3274 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3275 HighOrder(m.WParam.ToInt32())));
3280 case Msg.WM_MOUSEMOVE: {
3281 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3283 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3288 case Msg.WM_MOUSE_ENTER: {
3293 OnMouseEnter(EventArgs.Empty);
3297 case Msg.WM_MOUSE_LEAVE: {
3299 OnMouseLeave(EventArgs.Empty);
3303 case Msg.WM_MOUSEHOVER: {
3304 OnMouseHover(EventArgs.Empty);
3308 case Msg.WM_KEYDOWN: {
3309 if (!ProcessKeyMessage(ref m)) {
3315 case Msg.WM_KEYUP: {
3316 if (!ProcessKeyMessage(ref m)) {
3323 if (!ProcessKeyMessage(ref m)) {
3331 if (m.LParam != IntPtr.Zero) {
3334 hi = new HELPINFO();
3336 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3337 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3339 mouse_pos = Control.MousePosition;
3341 OnHelpRequested(new HelpEventArgs(mouse_pos));
3342 m.Result = (IntPtr)1;
3346 case Msg.WM_KILLFOCUS: {
3347 OnLeave(EventArgs.Empty);
3348 if (CausesValidation) {
3350 e = new CancelEventArgs(false);
3359 OnValidated(EventArgs.Empty);
3362 this.has_focus = false;
3363 OnLostFocus(EventArgs.Empty);
3367 case Msg.WM_SETFOCUS: {
3368 OnEnter(EventArgs.Empty);
3369 this.has_focus = true;
3370 OnGotFocus(EventArgs.Empty);
3375 case Msg.WM_SYSCOLORCHANGE: {
3376 ThemeEngine.Current.ResetDefaults();
3377 OnSystemColorsChanged(EventArgs.Empty);
3382 case Msg.WM_SETCURSOR: {
3383 if (cursor == null) {
3388 XplatUI.SetCursor(window.Handle, cursor.handle);
3389 m.Result = (IntPtr)1;
3398 #endregion // Public Instance Methods
3400 #region OnXXX methods
3401 [EditorBrowsable(EditorBrowsableState.Advanced)]
3402 protected virtual void OnBackColorChanged(EventArgs e) {
3403 if (BackColorChanged!=null) BackColorChanged(this, e);
3404 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3407 [EditorBrowsable(EditorBrowsableState.Advanced)]
3408 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3409 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3410 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3413 [EditorBrowsable(EditorBrowsableState.Advanced)]
3414 protected virtual void OnBindingContextChanged(EventArgs e) {
3415 if (BindingContextChanged!=null) BindingContextChanged(this, e);
3416 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3419 [EditorBrowsable(EditorBrowsableState.Advanced)]
3420 protected virtual void OnCausesValidationChanged(EventArgs e) {
3421 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3424 [EditorBrowsable(EditorBrowsableState.Advanced)]
3425 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3426 if (ChangeUICues!=null) ChangeUICues(this, e);
3429 [EditorBrowsable(EditorBrowsableState.Advanced)]
3430 protected virtual void OnClick(EventArgs e) {
3431 if (Click!=null) Click(this, e);
3434 [EditorBrowsable(EditorBrowsableState.Advanced)]
3435 protected virtual void OnContextMenuChanged(EventArgs e) {
3436 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3439 [EditorBrowsable(EditorBrowsableState.Advanced)]
3440 protected virtual void OnControlAdded(ControlEventArgs e) {
3441 if (ControlAdded!=null) ControlAdded(this, e);
3444 [EditorBrowsable(EditorBrowsableState.Advanced)]
3445 protected virtual void OnControlRemoved(ControlEventArgs e) {
3446 if (ControlRemoved!=null) ControlRemoved(this, e);
3449 [EditorBrowsable(EditorBrowsableState.Advanced)]
3450 protected virtual void OnCreateControl() {
3454 [EditorBrowsable(EditorBrowsableState.Advanced)]
3455 protected virtual void OnCursorChanged(EventArgs e) {
3456 if (CursorChanged!=null) CursorChanged(this, e);
3459 [EditorBrowsable(EditorBrowsableState.Advanced)]
3460 protected virtual void OnDockChanged(EventArgs e) {
3461 if (DockChanged!=null) DockChanged(this, e);
3464 [EditorBrowsable(EditorBrowsableState.Advanced)]
3465 protected virtual void OnDoubleClick(EventArgs e) {
3466 if (DoubleClick!=null) DoubleClick(this, e);
3469 [EditorBrowsable(EditorBrowsableState.Advanced)]
3470 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3471 if (DragDrop!=null) DragDrop(this, drgevent);
3474 [EditorBrowsable(EditorBrowsableState.Advanced)]
3475 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3476 if (DragEnter!=null) DragEnter(this, drgevent);
3479 [EditorBrowsable(EditorBrowsableState.Advanced)]
3480 protected virtual void OnDragLeave(EventArgs e) {
3481 if (DragLeave!=null) DragLeave(this, e);
3484 [EditorBrowsable(EditorBrowsableState.Advanced)]
3485 protected virtual void OnDragOver(DragEventArgs drgevent) {
3486 if (DragOver!=null) DragOver(this, drgevent);
3489 [EditorBrowsable(EditorBrowsableState.Advanced)]
3490 protected virtual void OnEnabledChanged(EventArgs e) {
3491 if (EnabledChanged!=null) EnabledChanged(this, e);
3492 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3495 [EditorBrowsable(EditorBrowsableState.Advanced)]
3496 protected virtual void OnEnter(EventArgs e) {
3497 if (Enter!=null) Enter(this, e);
3500 [EditorBrowsable(EditorBrowsableState.Advanced)]
3501 protected virtual void OnFontChanged(EventArgs e) {
3502 if (FontChanged!=null) FontChanged(this, e);
3503 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3506 [EditorBrowsable(EditorBrowsableState.Advanced)]
3507 protected virtual void OnForeColorChanged(EventArgs e) {
3508 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3509 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3512 [EditorBrowsable(EditorBrowsableState.Advanced)]
3513 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3514 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3517 [EditorBrowsable(EditorBrowsableState.Advanced)]
3518 protected virtual void OnGotFocus(EventArgs e) {
3519 if (GotFocus!=null) GotFocus(this, e);
3522 [EditorBrowsable(EditorBrowsableState.Advanced)]
3523 protected virtual void OnHandleCreated(EventArgs e) {
3524 if (HandleCreated!=null) HandleCreated(this, e);
3527 [EditorBrowsable(EditorBrowsableState.Advanced)]
3528 protected virtual void OnHandleDestroyed(EventArgs e) {
3529 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3532 [EditorBrowsable(EditorBrowsableState.Advanced)]
3533 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3534 if (HelpRequested!=null) HelpRequested(this, hevent);
3537 protected virtual void OnImeModeChanged(EventArgs e) {
3538 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3541 [EditorBrowsable(EditorBrowsableState.Advanced)]
3542 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3543 if (Invalidated!=null) Invalidated(this, e);
3546 [EditorBrowsable(EditorBrowsableState.Advanced)]
3547 protected virtual void OnKeyDown(KeyEventArgs e) {
3548 if (KeyDown!=null) KeyDown(this, e);
3551 [EditorBrowsable(EditorBrowsableState.Advanced)]
3552 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3553 if (KeyPress!=null) KeyPress(this, e);
3556 [EditorBrowsable(EditorBrowsableState.Advanced)]
3557 protected virtual void OnKeyUp(KeyEventArgs e) {
3558 if (KeyUp!=null) KeyUp(this, e);
3561 [EditorBrowsable(EditorBrowsableState.Advanced)]
3562 protected virtual void OnLayout(LayoutEventArgs levent) {
3563 if (Layout!=null) Layout(this, levent);
3566 [EditorBrowsable(EditorBrowsableState.Advanced)]
3567 protected virtual void OnLeave(EventArgs e) {
3568 if (Leave!=null) Leave(this, e);
3571 [EditorBrowsable(EditorBrowsableState.Advanced)]
3572 protected virtual void OnLocationChanged(EventArgs e) {
3574 if (LocationChanged!=null) LocationChanged(this, e);
3577 [EditorBrowsable(EditorBrowsableState.Advanced)]
3578 protected virtual void OnLostFocus(EventArgs e) {
3579 if (LostFocus!=null) LostFocus(this, e);
3582 [EditorBrowsable(EditorBrowsableState.Advanced)]
3583 protected virtual void OnMouseDown(MouseEventArgs e) {
3584 if (MouseDown!=null) MouseDown(this, e);
3587 [EditorBrowsable(EditorBrowsableState.Advanced)]
3588 protected virtual void OnMouseEnter(EventArgs e) {
3589 if (MouseEnter!=null) MouseEnter(this, e);
3592 [EditorBrowsable(EditorBrowsableState.Advanced)]
3593 protected virtual void OnMouseHover(EventArgs e) {
3594 if (MouseHover!=null) MouseHover(this, e);
3597 [EditorBrowsable(EditorBrowsableState.Advanced)]
3598 protected virtual void OnMouseLeave(EventArgs e) {
3599 if (MouseLeave!=null) MouseLeave(this, e);
3602 [EditorBrowsable(EditorBrowsableState.Advanced)]
3603 protected virtual void OnMouseMove(MouseEventArgs e) {
3604 if (MouseMove!=null) MouseMove(this, e);
3607 [EditorBrowsable(EditorBrowsableState.Advanced)]
3608 protected virtual void OnMouseUp(MouseEventArgs e) {
3609 if (MouseUp!=null) MouseUp(this, e);
3612 [EditorBrowsable(EditorBrowsableState.Advanced)]
3613 protected virtual void OnMouseWheel(MouseEventArgs e) {
3614 if (MouseWheel!=null) MouseWheel(this, e);
3617 [EditorBrowsable(EditorBrowsableState.Advanced)]
3618 protected virtual void OnMove(EventArgs e) {
3619 if (Move!=null) Move(this, e);
3622 [EditorBrowsable(EditorBrowsableState.Advanced)]
3623 protected virtual void OnNotifyMessage(Message m) {
3627 [EditorBrowsable(EditorBrowsableState.Advanced)]
3628 protected virtual void OnPaint(PaintEventArgs e) {
3629 if (Paint!=null) Paint(this, e);
3632 [EditorBrowsable(EditorBrowsableState.Advanced)]
3633 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3637 [EditorBrowsable(EditorBrowsableState.Advanced)]
3638 protected virtual void OnParentBackColorChanged(EventArgs e) {
3639 if (background_color.IsEmpty && background_image==null) {
3641 OnBackColorChanged(e);
3645 [EditorBrowsable(EditorBrowsableState.Advanced)]
3646 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3647 if (background_color.IsEmpty && background_image==null) {
3649 OnBackgroundImageChanged(e);
3653 [EditorBrowsable(EditorBrowsableState.Advanced)]
3654 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3655 if (binding_context==null) {
3656 binding_context=Parent.binding_context;
3657 OnBindingContextChanged(e);
3661 [EditorBrowsable(EditorBrowsableState.Advanced)]
3662 protected virtual void OnParentChanged(EventArgs e) {
3663 if (ParentChanged!=null) ParentChanged(this, e);
3666 [EditorBrowsable(EditorBrowsableState.Advanced)]
3667 protected virtual void OnParentEnabledChanged(EventArgs e) {
3668 if (is_enabled != Parent.is_enabled) {
3669 is_enabled=Parent.is_enabled;
3671 if (EnabledChanged != null) {
3672 EnabledChanged(this, e);
3677 [EditorBrowsable(EditorBrowsableState.Advanced)]
3678 protected virtual void OnParentFontChanged(EventArgs e) {
3685 [EditorBrowsable(EditorBrowsableState.Advanced)]
3686 protected virtual void OnParentForeColorChanged(EventArgs e) {
3687 if (foreground_color.IsEmpty) {
3689 OnForeColorChanged(e);
3693 [EditorBrowsable(EditorBrowsableState.Advanced)]
3694 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
3695 if (right_to_left==RightToLeft.Inherit) {
3697 OnRightToLeftChanged(e);
3701 [EditorBrowsable(EditorBrowsableState.Advanced)]
3702 protected virtual void OnParentVisibleChanged(EventArgs e) {
3703 if (is_visible!=Parent.is_visible) {
3706 OnVisibleChanged(e);
3710 [EditorBrowsable(EditorBrowsableState.Advanced)]
3711 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
3712 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
3715 [EditorBrowsable(EditorBrowsableState.Advanced)]
3716 protected virtual void OnResize(EventArgs e) {
3717 if (Resize!=null) Resize(this, e);
3719 PerformLayout(this, "bounds");
3721 if (parent != null) {
3722 parent.PerformLayout();
3726 [EditorBrowsable(EditorBrowsableState.Advanced)]
3727 protected virtual void OnRightToLeftChanged(EventArgs e) {
3728 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
3729 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
3732 [EditorBrowsable(EditorBrowsableState.Advanced)]
3733 protected virtual void OnSizeChanged(EventArgs e) {
3734 InvalidateBuffers ();
3736 if (SizeChanged!=null) SizeChanged(this, e);
3739 [EditorBrowsable(EditorBrowsableState.Advanced)]
3740 protected virtual void OnStyleChanged(EventArgs e) {
3741 if (StyleChanged!=null) StyleChanged(this, e);
3744 [EditorBrowsable(EditorBrowsableState.Advanced)]
3745 protected virtual void OnSystemColorsChanged(EventArgs e) {
3746 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
3749 [EditorBrowsable(EditorBrowsableState.Advanced)]
3750 protected virtual void OnTabIndexChanged(EventArgs e) {
3751 if (TabIndexChanged!=null) TabIndexChanged(this, e);
3754 [EditorBrowsable(EditorBrowsableState.Advanced)]
3755 protected virtual void OnTabStopChanged(EventArgs e) {
3756 if (TabStopChanged!=null) TabStopChanged(this, e);
3759 [EditorBrowsable(EditorBrowsableState.Advanced)]
3760 protected virtual void OnTextChanged(EventArgs e) {
3761 if (TextChanged!=null) TextChanged(this, e);
3764 [EditorBrowsable(EditorBrowsableState.Advanced)]
3765 protected virtual void OnValidated(EventArgs e) {
3766 if (Validated!=null) Validated(this, e);
3769 [EditorBrowsable(EditorBrowsableState.Advanced)]
3770 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
3771 if (Validating!=null) Validating(this, e);
3774 [EditorBrowsable(EditorBrowsableState.Advanced)]
3775 protected virtual void OnVisibleChanged(EventArgs e) {
3782 if (bmp_mem!=null) {
3788 if (!this.IsHandleCreated) {
3789 this.CreateHandle();
3795 if (VisibleChanged!=null) VisibleChanged(this, e);
3797 // We need to tell our kids
3798 for (int i=0; i<child_controls.Count; i++) {
3799 child_controls[i].OnParentVisibleChanged(e);
3802 #endregion // OnXXX methods
3805 public event EventHandler BackColorChanged;
3806 public event EventHandler BackgroundImageChanged;
3807 public event EventHandler BindingContextChanged;
3808 public event EventHandler CausesValidationChanged;
3809 public event UICuesEventHandler ChangeUICues;
3810 public event EventHandler Click;
3811 public event EventHandler ContextMenuChanged;
3813 [EditorBrowsable(EditorBrowsableState.Advanced)]
3815 public event ControlEventHandler ControlAdded;
3817 [EditorBrowsable(EditorBrowsableState.Advanced)]
3819 public event ControlEventHandler ControlRemoved;
3821 public event EventHandler CursorChanged;
3822 public event EventHandler DockChanged;
3823 public event EventHandler DoubleClick;
3824 public event DragEventHandler DragDrop;
3825 public event DragEventHandler DragEnter;
3826 public event EventHandler DragLeave;
3827 public event DragEventHandler DragOver;
3828 public event EventHandler EnabledChanged;
3829 public event EventHandler Enter;
3830 public event EventHandler FontChanged;
3831 public event EventHandler ForeColorChanged;
3832 public event GiveFeedbackEventHandler GiveFeedback;
3834 [EditorBrowsable(EditorBrowsableState.Advanced)]
3836 public event EventHandler GotFocus;
3838 [EditorBrowsable(EditorBrowsableState.Advanced)]
3840 public event EventHandler HandleCreated;
3842 [EditorBrowsable(EditorBrowsableState.Advanced)]
3844 public event EventHandler HandleDestroyed;
3846 public event HelpEventHandler HelpRequested;
3847 public event EventHandler ImeModeChanged;
3849 [EditorBrowsable(EditorBrowsableState.Advanced)]
3851 public event InvalidateEventHandler Invalidated;
3853 public event KeyEventHandler KeyDown;
3854 public event KeyPressEventHandler KeyPress;
3855 public event KeyEventHandler KeyUp;
3856 public event LayoutEventHandler Layout;
3857 public event EventHandler Leave;
3858 public event EventHandler LocationChanged;
3860 [EditorBrowsable(EditorBrowsableState.Advanced)]
3862 public event EventHandler LostFocus;
3864 public event MouseEventHandler MouseDown;
3865 public event EventHandler MouseEnter;
3866 public event EventHandler MouseHover;
3867 public event EventHandler MouseLeave;
3868 public event MouseEventHandler MouseMove;
3869 public event MouseEventHandler MouseUp;
3871 [EditorBrowsable(EditorBrowsableState.Advanced)]
3873 public event MouseEventHandler MouseWheel;
3875 public event EventHandler Move;
3876 public event PaintEventHandler Paint;
3877 public event EventHandler ParentChanged;
3878 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
3879 public event QueryContinueDragEventHandler QueryContinueDrag;
3880 public event EventHandler Resize;
3881 public event EventHandler RightToLeftChanged;
3882 public event EventHandler SizeChanged;
3883 public event EventHandler StyleChanged;
3884 public event EventHandler SystemColorsChanged;
3885 public event EventHandler TabIndexChanged;
3886 public event EventHandler TabStopChanged;
3887 public event EventHandler TextChanged;
3888 public event EventHandler Validated;
3889 public event CancelEventHandler Validating;
3890 public event EventHandler VisibleChanged;
3891 #endregion // Events