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-2005 Novell, Inc.
23 // Peter Bartok pbartok@novell.com
25 // Partially based on work by:
26 // Aleksey Ryabchuk ryabchuk@yahoo.com
27 // Alexandre Pigolkine pigolkine@gmx.de
28 // Dennis Hayes dennish@raytek.com
29 // Jaak Simm jaaksimm@firm.ee
30 // John Sohn jsohn@columbus.rr.com
36 using System.ComponentModel;
37 using System.ComponentModel.Design;
38 using System.ComponentModel.Design.Serialization;
39 using System.Collections;
40 using System.Diagnostics;
42 using System.Reflection;
43 using System.Runtime.InteropServices;
44 using System.Threading;
47 namespace System.Windows.Forms
49 [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design)]
50 [DefaultProperty("Text")]
51 [DefaultEvent("Click")]
52 [DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
53 [ToolboxItemFilter("System.Windows.Forms")]
54 public class Control : Component, ISynchronizeInvoke, IWin32Window
56 #region Local Variables
59 internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
60 internal object creator_thread; // thread that created the control
61 internal ControlNativeWindow window; // object for native window handle
62 internal string name; // for object naming
65 internal bool has_focus; // true if control has focus
66 internal bool is_visible; // true if control is visible
67 internal bool is_entered; // is the mouse inside the control?
68 internal bool is_enabled; // true if control is enabled (usable/not grayed out)
69 internal bool is_selected; // true if control is selected
70 internal bool is_accessible; // true if the control is visible to accessibility applications
71 internal bool is_captured; // tracks if the control has captured the mouse
72 internal bool is_toplevel; // tracks if the control is a toplevel window
73 internal bool is_recreating; // tracks if the handle for the control is being recreated
74 internal bool causes_validation; // tracks if validation is executed on changes
75 internal int tab_index; // position in tab order of siblings
76 internal bool tab_stop = true; // is the control a tab stop?
77 internal bool is_disposed; // has the window already been disposed?
78 internal Size client_size; // size of the client area (window excluding decorations)
79 internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
80 internal ControlStyles control_style; // rather win32-specific, style bits for control
81 internal ImeMode ime_mode = ImeMode.Inherit;
82 internal bool layout_pending; // true if our parent needs to re-layout us
83 internal object control_tag; // object that contains data about our control
84 internal int mouse_clicks; // Counter for mouse clicks
85 internal Cursor cursor; // Cursor for the window
88 internal Color foreground_color; // foreground color for control
89 internal Color background_color; // background color for control
90 internal Image background_image; // background image for control
91 internal Font font; // font for control
92 internal string text; // window/title text for control
93 internal BorderStyle border_style; // Border style of control
96 internal AnchorStyles anchor_style; // anchoring requirements for our control
97 internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
98 internal SizeF size_ratio; // size ratio of our control to it's parent; required for anchoring
99 internal Size prev_size; // previous size of the control; required for anchoring
101 // to be categorized...
102 static internal ArrayList controls = new ArrayList(); // All of the applications controls, in a flat list
103 internal ControlCollection child_controls; // our children
104 internal Control parent; // our parent control
105 internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
106 internal BindingContext binding_context; // TODO
107 internal RightToLeft right_to_left; // drawing direction for control
108 internal int layout_suspended;
109 internal bool double_buffering;
110 internal ContextMenu context_menu; // Context menu associated with the control
112 private Graphics dc_mem; // Graphics context for double buffering
113 private Bitmap bmp_mem; // Bitmap for double buffering control
115 #endregion // Local Variables
117 #region Private Classes
118 // This helper class allows us to dispatch messages to Control.WndProc
119 internal class ControlNativeWindow : NativeWindow {
120 private Control owner;
122 public ControlNativeWindow(Control control) : base() {
127 public Control Owner {
133 static internal Control ControlFromHandle(IntPtr hWnd) {
134 ControlNativeWindow window;
136 window = (ControlNativeWindow)window_collection[hWnd];
141 protected override void WndProc(ref Message m) {
142 owner.WndProc(ref m);
147 #region Public Classes
149 public class ControlAccessibleObject : AccessibleObject {
150 #region ControlAccessibleObject Local Variables
151 private Control owner;
152 #endregion // ControlAccessibleObject Local Variables
154 #region ControlAccessibleObject Constructors
155 public ControlAccessibleObject(Control ownerControl) {
156 this.owner = ownerControl;
158 #endregion // ControlAccessibleObject Constructors
160 #region ControlAccessibleObject Public Instance Properties
161 public override string DefaultAction {
163 return base.DefaultAction;
167 public override string Description {
169 return base.Description;
173 public IntPtr Handle {
179 // We don't want to let them set it
183 public override string Help {
189 public override string KeyboardShortcut {
191 return base.KeyboardShortcut;
195 public override string Name {
205 public Control Owner {
211 public override AccessibleRole Role {
216 #endregion // ControlAccessibleObject Public Instance Properties
218 #region ControlAccessibleObject Public Instance Methods
219 public override int GetHelpTopic(out string FileName) {
220 return base.GetHelpTopic (out FileName);
223 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
224 public void NotifyClients(AccessibleEvents accEvent) {
225 throw new NotImplementedException();
228 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
229 public void NotifyClients(AccessibleEvents accEvent, int childID) {
230 throw new NotImplementedException();
233 public override string ToString() {
234 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
237 #endregion // ControlAccessibleObject Public Instance Methods
240 [DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
241 [ListBindable(false)]
242 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
243 #region ControlCollection Local Variables
244 internal ArrayList list;
245 internal Control owner;
246 #endregion // ControlCollection Local Variables
248 #region ControlCollection Public Constructor
249 public ControlCollection(Control owner) {
251 this.list=new ArrayList();
255 #region ControlCollection Public Instance Properties
262 public bool IsReadOnly {
264 return list.IsReadOnly;
268 public virtual Control this[int index] {
270 if (index < 0 || index >= list.Count) {
271 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
273 return (Control)list[index];
276 #endregion // ControlCollection Public Instance Properties
278 #region ControlCollection Private Instance Methods
279 public virtual void Add (Control value)
282 for (int i = 0; i < list.Count; i++) {
283 if (list [i] == value) {
284 // Do we need to do anything here?
289 if (value.tab_index == -1) {
295 end = owner.child_controls.Count;
296 for (int i = 0; i < end; i++) {
297 index = owner.child_controls[i].tab_index;
302 value.tab_index = use;
306 value.Parent = owner;
307 owner.UpdateZOrder();
308 owner.OnControlAdded(new ControlEventArgs(value));
311 public virtual void AddRange (Control[] controls)
313 if (controls == null)
314 throw new ArgumentNullException ("controls");
316 owner.SuspendLayout ();
319 for (int i = 0; i < controls.Length; i++)
322 owner.ResumeLayout ();
326 public virtual void Clear ()
328 owner.SuspendLayout();
329 for (int i = 0; i < list.Count; i++) {
330 owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
333 owner.ResumeLayout();
336 public virtual bool Contains (Control value)
338 return list.Contains (value);
341 public void CopyTo (Array array, int index)
343 list.CopyTo(array, index);
346 public override bool Equals(object other) {
347 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
354 public int GetChildIndex(Control child) {
355 return GetChildIndex(child, false);
358 public int GetChildIndex(Control child, bool throwException) {
361 index=list.IndexOf(child);
363 if (index==-1 && throwException) {
364 throw new ArgumentException("Not a child control", "child");
369 public IEnumerator GetEnumerator() {
370 return list.GetEnumerator();
373 public override int GetHashCode() {
374 return base.GetHashCode();
377 public int IndexOf(Control control) {
378 return list.IndexOf(control);
381 public virtual void Remove(Control value) {
382 owner.OnControlRemoved(new ControlEventArgs(value));
384 owner.UpdateZOrder();
387 public void RemoveAt(int index) {
388 if (index<0 || index>=list.Count) {
389 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
392 owner.OnControlRemoved(new ControlEventArgs((Control)list[index]));
393 list.RemoveAt(index);
394 owner.UpdateZOrder();
397 public void SetChildIndex(Control child, int newIndex) {
400 old_index=list.IndexOf(child);
402 throw new ArgumentException("Not a child control", "child");
405 if (old_index==newIndex) {
411 if (newIndex>list.Count) {
414 list.Insert(newIndex, child);
416 owner.UpdateZOrder();
418 #endregion // ControlCollection Private Instance Methods
420 #region ControlCollection Interface Properties
421 object IList.this[int index] {
423 if (index<0 || index>=list.Count) {
424 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
430 if (!(value is Control)) {
431 throw new ArgumentException("Object of type Control required", "value");
434 list[index]=(Control)value;
438 bool IList.IsFixedSize {
444 bool IList.IsReadOnly {
446 return list.IsReadOnly;
450 bool ICollection.IsSynchronized {
452 return list.IsSynchronized;
456 object ICollection.SyncRoot {
458 return list.SyncRoot;
461 #endregion // ControlCollection Interface Properties
463 #region ControlCollection Interface Methods
464 int IList.Add(object value) {
466 throw new ArgumentNullException("value", "Cannot add null controls");
469 if (!(value is Control)) {
470 throw new ArgumentException("Object of type Control required", "value");
473 return list.Add(value);
476 bool IList.Contains(object value) {
477 if (!(value is Control)) {
478 throw new ArgumentException("Object of type Control required", "value");
481 return this.Contains((Control) value);
484 int IList.IndexOf(object value) {
485 if (!(value is Control)) {
486 throw new ArgumentException("Object of type Control required", "value");
489 return this.IndexOf((Control) value);
492 void IList.Insert(int index, object value) {
493 if (!(value is Control)) {
494 throw new ArgumentException("Object of type Control required", "value");
496 list.Insert(index, value);
499 void IList.Remove(object value) {
500 if (!(value is Control)) {
501 throw new ArgumentException("Object of type Control required", "value");
506 void ICollection.CopyTo(Array array, int index) {
508 list.CopyTo(array, index);
512 Object ICloneable.Clone() {
513 ControlCollection clone = new ControlCollection(this.owner);
514 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
517 #endregion // ControlCollection Interface Methods
519 #endregion // ControlCollection Class
521 #region Public Constructors
523 creator_thread = Thread.CurrentThread;
525 prev_size = Size.Empty;
526 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
533 layout_pending = false;
535 causes_validation = true;
537 layout_suspended = 0;
538 double_buffering = true;
542 right_to_left = RightToLeft.Inherit;
544 control_style = ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick;
547 background_image = null;
551 child_controls = CreateControlsInstance();
552 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
553 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
554 XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, CreateParams.ExStyle, IntPtr.Zero, out bounds);
555 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
561 public Control(Control parent, string text) : this() {
566 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
571 bounds.Height=height;
572 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
576 public Control(string text) : this() {
580 public Control(string text, int left, int top, int width, int height) : this() {
584 bounds.Height=height;
585 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
589 protected override void Dispose(bool disposing) {
602 OnHandleDestroyed(EventArgs.Empty);
603 controls.Remove(this);
605 #endregion // Public Constructors
607 #region Internal Properties
608 internal BorderStyle InternalBorderStyle {
614 if (border_style != value) {
615 border_style = value;
617 XplatUI.SetBorderStyle(window.Handle, border_style);
621 #endregion // Internal Properties
623 #region Private & Internal Methods
624 internal static IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
625 AsyncMethodResult result = new AsyncMethodResult ();
626 AsyncMethodData data = new AsyncMethodData ();
628 data.Method = method;
630 data.Result = new WeakReference (result);
632 XplatUI.SendAsyncMethod (data);
636 internal Graphics DeviceContext {
639 CreateBuffers(this.Width, this.Height);
645 internal Bitmap ImageBuffer {
648 CreateBuffers(this.Width, this.Height);
654 internal void CreateBuffers (int width, int height) {
655 if (double_buffering == false)
658 if (dc_mem != null) {
672 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
673 dc_mem = Graphics.FromImage (bmp_mem);
676 internal void InvalidateBuffers ()
678 if (double_buffering == false)
681 if (dc_mem != null) {
691 internal static void SetChildColor(Control parent) {
694 for (int i=0; i < parent.child_controls.Count; i++) {
695 child=parent.child_controls[i];
696 if (child.IsHandleCreated) {
697 XplatUI.SetWindowBackground(child.window.Handle, child.BackColor);
699 if (child.child_controls.Count>0) {
700 SetChildColor(child);
706 internal bool Select(Control control) {
708 IContainerControl container;
710 if (control == null) {
714 parent = control.parent;
716 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
717 while (parent != null) {
718 if (!parent.is_visible || !parent.is_enabled) {
721 parent = parent.parent;
725 control.is_selected = true;
727 XplatUI.SetFocus(control.window.Handle);
728 container = GetContainerControl();
729 if (container != null) {
730 container.ActiveControl = control;
735 internal virtual void DoDefaultAction() {
736 // Only here to be overriden by our actual controls; this is needed by the accessibility class
739 internal static int LowOrder (int param) {
740 return (param & 0xffff);
743 internal static int HighOrder (int param) {
744 return (param >> 16);
747 internal static MouseButtons FromParamToMouseButtons (int param) {
748 MouseButtons buttons = MouseButtons.None;
750 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
751 buttons |= MouseButtons.Left;
753 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
754 buttons |= MouseButtons.Middle;
756 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
757 buttons |= MouseButtons.Right;
763 internal virtual bool ProcessControlMnemonic(char charCode) {
764 return ProcessMnemonic(charCode);
767 private static Control FindFlatForward(Control container, Control start) {
773 end = container.child_controls.Count;
776 index = start.tab_index;
781 for (int i = 0; i < end; i++) {
783 if (container.child_controls[i].tab_index > index) {
784 found = container.child_controls[i];
786 } else if (found.tab_index > container.child_controls[i].tab_index) {
787 if (container.child_controls[i].tab_index > index) {
788 found = container.child_controls[i];
795 private static Control FindControlForward(Control container, Control start) {
802 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
803 found = FindControlForward(start, null);
810 while (p != container) {
811 found = FindFlatForward(p, start);
819 return FindFlatForward(container, start);
822 private static Control FindFlatBackward(Control container, Control start) {
828 end = container.child_controls.Count;
831 index = start.tab_index;
833 // FIXME: Possible speed-up: Keep the highest taborder index in the container
835 for (int i = 0; i < end; i++) {
836 if (container.child_controls[i].tab_index > index) {
837 index = container.child_controls[i].tab_index;
843 for (int i = 0; i < end; i++) {
845 if (container.child_controls[i].tab_index < index) {
846 found = container.child_controls[i];
848 } else if (found.tab_index < container.child_controls[i].tab_index) {
849 if (container.child_controls[i].tab_index < index) {
850 found = container.child_controls[i];
857 private static Control FindControlBackward(Control container, Control start) {
863 found = FindFlatBackward(start.parent, start);
864 if (found == null && start.parent != container) {
869 found = FindFlatBackward(container, start);
872 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
873 found = FindControlBackward(found, null);
882 private void HandleClick(int clicks) {
883 if (GetStyle(ControlStyles.StandardClick)) {
885 if (GetStyle(ControlStyles.StandardDoubleClick)) {
886 OnDoubleClick(EventArgs.Empty);
888 OnClick(EventArgs.Empty);
891 OnClick(EventArgs.Empty);
895 #endregion // Private & Internal Methods
897 #region Public Static Properties
898 public static Color DefaultBackColor {
900 return ThemeEngine.Current.DefaultControlBackColor;
904 public static Font DefaultFont {
906 return ThemeEngine.Current.DefaultFont;
910 public static Color DefaultForeColor {
912 return ThemeEngine.Current.DefaultControlForeColor;
916 public static Keys ModifierKeys {
918 return XplatUI.State.ModifierKeys;
922 public static MouseButtons MouseButtons {
924 return XplatUI.State.MouseButtons;
928 public static Point MousePosition {
930 return Cursor.Position;
933 #endregion // Public Static Properties
935 #region Public Instance Properties
936 [EditorBrowsable(EditorBrowsableState.Advanced)]
938 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
939 public AccessibleObject AccessibilityObject {
941 if (accessibility_object==null) {
942 accessibility_object=CreateAccessibilityInstance();
944 return accessibility_object;
948 [EditorBrowsable(EditorBrowsableState.Advanced)]
950 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
951 public string AccessibleDefaultActionDescription {
953 return AccessibilityObject.default_action;
957 AccessibilityObject.default_action=value;
963 public string AccessibleDescription {
965 return AccessibilityObject.description;
969 AccessibilityObject.description=value;
975 public string AccessibleName {
977 return AccessibilityObject.Name;
981 AccessibilityObject.Name=value;
985 [DefaultValue(AccessibleRole.Default)]
986 public AccessibleRole AccessibleRole {
988 return AccessibilityObject.role;
992 AccessibilityObject.role=value;
996 [DefaultValue(false)]
997 public virtual bool AllowDrop {
999 return XplatUI.State.DropTarget;
1003 XplatUI.State.DropTarget=value;
1008 [RefreshProperties(RefreshProperties.Repaint)]
1009 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
1010 public virtual AnchorStyles Anchor {
1012 return anchor_style;
1018 if (parent != null) {
1019 parent.PerformLayout(this, "Parent");
1025 public virtual Color BackColor {
1027 if (background_color.IsEmpty) {
1029 return parent.BackColor;
1031 return DefaultBackColor;
1033 return background_color;
1037 background_color=value;
1038 if (this.IsHandleCreated) {
1039 XplatUI.SetWindowBackground(this.window.Handle, value);
1041 SetChildColor(this);
1042 OnBackColorChanged(EventArgs.Empty);
1048 [DefaultValue(null)]
1049 public virtual Image BackgroundImage {
1051 return background_image;
1055 if (background_image!=value) {
1056 background_image=value;
1057 OnBackgroundImageChanged(EventArgs.Empty);
1062 [EditorBrowsable(EditorBrowsableState.Advanced)]
1064 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1065 public virtual BindingContext BindingContext {
1067 return binding_context;
1071 if (binding_context != value) {
1072 binding_context = value;
1073 OnBindingContextChanged(EventArgs.Empty);
1078 [EditorBrowsable(EditorBrowsableState.Advanced)]
1080 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1083 return bounds.Y+bounds.Height;
1087 [EditorBrowsable(EditorBrowsableState.Advanced)]
1089 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1090 public Rectangle Bounds {
1096 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1100 [EditorBrowsable(EditorBrowsableState.Advanced)]
1102 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1103 public bool CanFocus {
1105 if (is_visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1112 [EditorBrowsable(EditorBrowsableState.Advanced)]
1114 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1115 public bool CanSelect {
1119 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1123 parent = this.parent;
1124 while (parent != null) {
1125 if (!parent.is_visible || !parent.is_enabled) {
1129 parent = parent.parent;
1135 [EditorBrowsable(EditorBrowsableState.Advanced)]
1137 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1138 public bool Capture {
1140 return this.is_captured;
1144 if (this.IsHandleCreated) {
1145 if (value && !is_captured) {
1147 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1148 } else if (!value && is_captured) {
1149 XplatUI.UngrabWindow(this.window.Handle);
1150 is_captured = false;
1156 [DefaultValue(true)]
1157 public bool CausesValidation {
1159 return this.causes_validation;
1163 if (this.causes_validation != value) {
1164 causes_validation = value;
1165 OnCausesValidationChanged(EventArgs.Empty);
1170 [EditorBrowsable(EditorBrowsableState.Advanced)]
1172 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1173 public Rectangle ClientRectangle {
1175 client_rect.Width = client_size.Width;
1176 client_rect.Height = client_size.Height;
1181 [EditorBrowsable(EditorBrowsableState.Advanced)]
1183 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1184 public Size ClientSize {
1187 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1188 return ((Form)this).form_parent_window.ClientSize;
1196 this.SetClientSizeCore(value.Width, value.Height);
1200 [EditorBrowsable(EditorBrowsableState.Advanced)]
1202 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1203 [DescriptionAttribute("ControlCompanyNameDescr")]
1204 public String CompanyName {
1206 return "Mono Project, Novell, Inc.";
1210 [EditorBrowsable(EditorBrowsableState.Advanced)]
1212 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1213 public bool ContainsFocus {
1219 for (int i=0; i < child_controls.Count; i++) {
1220 if (child_controls[i].ContainsFocus) {
1228 [DefaultValue(null)]
1229 public virtual ContextMenu ContextMenu {
1231 return context_menu;
1235 if (context_menu != value) {
1236 context_menu = value;
1237 OnContextMenuChanged(EventArgs.Empty);
1243 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1244 public ControlCollection Controls {
1246 return this.child_controls;
1250 [EditorBrowsable(EditorBrowsableState.Advanced)]
1252 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1253 public bool Created {
1255 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1262 [AmbientValue(null)]
1263 public virtual Cursor Cursor {
1265 if (cursor != null) {
1269 if (parent != null) {
1270 return parent.Cursor;
1273 return Cursors.Default;
1277 if (cursor != value) {
1282 pt = Cursor.Position;
1283 if (bounds.Contains(pt)) {
1284 if (GetChildAtPoint(pt) == null) {
1285 if (cursor != null) {
1286 XplatUI.SetCursor(window.Handle, cursor.handle);
1288 if (parent != null) {
1289 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1291 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1297 OnCursorChanged(EventArgs.Empty);
1302 #if haveDataBindings
1303 [EditorBrowsable(EditorBrowsableState.Advanced)]
1305 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1306 public ControlBindingsCollection DataBindings {
1308 throw new NotImplementedException();
1313 [EditorBrowsable(EditorBrowsableState.Advanced)]
1315 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1316 public virtual Rectangle DisplayRectangle {
1318 return ClientRectangle;
1322 [EditorBrowsable(EditorBrowsableState.Advanced)]
1324 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1325 public bool Disposing {
1332 [RefreshProperties(RefreshProperties.Repaint)]
1333 [DefaultValue(DockStyle.None)]
1334 public virtual DockStyle Dock {
1340 if (dock_style == value) {
1346 if (parent != null) {
1347 parent.PerformLayout(this, "Parent");
1350 OnDockChanged(EventArgs.Empty);
1356 public bool Enabled {
1362 if (is_enabled == value) {
1368 OnEnabledChanged (EventArgs.Empty);
1372 [EditorBrowsable(EditorBrowsableState.Advanced)]
1374 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1375 public virtual bool Focused {
1377 return this.has_focus;
1382 [AmbientValue(null)]
1384 public virtual Font Font {
1390 if (Parent != null && Parent.Font != null) {
1398 if (font == value) {
1404 OnFontChanged (EventArgs.Empty);
1409 public virtual Color ForeColor {
1411 if (foreground_color.IsEmpty) {
1413 return parent.ForeColor;
1415 return DefaultForeColor;
1417 return foreground_color;
1421 if (foreground_color != value) {
1422 foreground_color=value;
1424 OnForeColorChanged(EventArgs.Empty);
1431 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1432 public IntPtr Handle { // IWin32Window
1434 if (!IsHandleCreated) {
1437 return window.Handle;
1441 [EditorBrowsable(EditorBrowsableState.Advanced)]
1443 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1444 public bool HasChildren {
1446 if (this.child_controls.Count>0) {
1453 [EditorBrowsable(EditorBrowsableState.Always)]
1455 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1458 return this.bounds.Height;
1462 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1466 [AmbientValue(ImeMode.Inherit)]
1468 public ImeMode ImeMode {
1474 if (ime_mode != value) {
1477 OnImeModeChanged(EventArgs.Empty);
1482 [EditorBrowsable(EditorBrowsableState.Advanced)]
1484 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1485 public bool InvokeRequired { // ISynchronizeInvoke
1487 if (creator_thread!=Thread.CurrentThread) {
1494 [EditorBrowsable(EditorBrowsableState.Advanced)]
1496 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1497 public bool IsAccessible {
1499 return is_accessible;
1503 is_accessible = value;
1507 [EditorBrowsable(EditorBrowsableState.Advanced)]
1509 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1510 public bool IsDisposed {
1512 return this.is_disposed;
1516 [EditorBrowsable(EditorBrowsableState.Advanced)]
1518 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1519 public bool IsHandleCreated {
1521 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1529 [EditorBrowsable(EditorBrowsableState.Always)]
1531 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1534 return this.bounds.X;
1538 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1543 public Point Location {
1545 return new Point(bounds.X, bounds.Y);
1549 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1554 public string Name {
1565 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1566 public Control Parent {
1572 if (value == this) {
1573 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1576 if (parent!=value) {
1578 parent.Controls.Remove(this);
1583 if (!parent.Controls.Contains(this)) {
1584 parent.Controls.Add(this);
1587 XplatUI.SetParent(Handle, value.Handle);
1591 OnParentChanged(EventArgs.Empty);
1596 [EditorBrowsable(EditorBrowsableState.Advanced)]
1598 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1599 public string ProductName {
1601 return "Novell Mono MWF";
1605 [EditorBrowsable(EditorBrowsableState.Advanced)]
1607 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1608 public string ProductVersion {
1610 return "1.1.4322.573";
1614 [EditorBrowsable(EditorBrowsableState.Advanced)]
1616 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1617 public bool RecreatingHandle {
1619 return is_recreating;
1623 [EditorBrowsable(EditorBrowsableState.Advanced)]
1625 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1626 public Region Region {
1628 return new Region(this.bounds);
1635 g = this.CreateGraphics();
1636 r = value.GetBounds(g);
1638 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1644 [EditorBrowsable(EditorBrowsableState.Advanced)]
1646 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1649 return this.bounds.X+this.bounds.Width;
1653 [AmbientValue(RightToLeft.Inherit)]
1655 public virtual RightToLeft RightToLeft {
1657 return right_to_left;
1661 if (value != right_to_left) {
1662 right_to_left = value;
1663 OnRightToLeftChanged(EventArgs.Empty);
1668 [EditorBrowsable(EditorBrowsableState.Advanced)]
1669 public override ISite Site {
1682 return new Size(Width, Height);
1686 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1691 [MergableProperty(false)]
1692 public int TabIndex {
1694 if (tab_index != -1) {
1701 if (tab_index != value) {
1703 OnTabIndexChanged(EventArgs.Empty);
1709 [DefaultValue(true)]
1710 public bool TabStop {
1716 if (tab_stop != value) {
1718 OnTabStopChanged(EventArgs.Empty);
1723 [Localizable(false)]
1725 [TypeConverter(typeof(StringConverter))]
1726 [DefaultValue(null)]
1733 control_tag = value;
1739 [BindableAttribute(true)]
1740 public virtual string Text {
1746 if (value == null) {
1747 value = String.Empty;
1752 XplatUI.Text(Handle, text);
1753 // FIXME: Do we need a Refresh() here?
1754 OnTextChanged (EventArgs.Empty);
1759 [EditorBrowsable(EditorBrowsableState.Always)]
1761 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1764 return this.bounds.Y;
1768 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
1772 [EditorBrowsable(EditorBrowsableState.Advanced)]
1774 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1775 public Control TopLevelControl {
1779 while (p.parent != null) {
1788 public bool Visible {
1798 SetVisibleCore(value);
1802 [EditorBrowsable(EditorBrowsableState.Always)]
1804 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1807 return this.bounds.Width;
1811 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
1815 [EditorBrowsable(EditorBrowsableState.Never)]
1817 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1818 public IWindowTarget WindowTarget {
1827 #endregion // Public Instance Properties
1829 #region Protected Instance Properties
1830 protected virtual CreateParams CreateParams {
1832 CreateParams create_params = new CreateParams();
1834 create_params.Caption = Text;
1835 create_params.X = Left;
1836 create_params.Y = Top;
1837 create_params.Width = Width;
1838 create_params.Height = Height;
1840 create_params.ClassName = XplatUI.DefaultClassName;
1841 create_params.ClassStyle = 0;
1842 create_params.ExStyle = 0;
1843 create_params.Param = 0;
1846 create_params.Parent = parent.Handle;
1849 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
1852 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
1855 return create_params;
1859 protected virtual ImeMode DefaultImeMode {
1861 return ImeMode.Inherit;
1865 protected virtual Size DefaultSize {
1867 return new Size(100, 23);
1871 protected int FontHeight {
1881 protected bool RenderRightToLeft {
1883 return (this.right_to_left == RightToLeft.Yes);
1887 protected bool ResizeRedraw {
1889 return GetStyle(ControlStyles.ResizeRedraw);
1893 SetStyle(ControlStyles.ResizeRedraw, value);
1897 [EditorBrowsable(EditorBrowsableState.Advanced)]
1899 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1900 protected virtual bool ShowFocusCues {
1906 [EditorBrowsable(EditorBrowsableState.Advanced)]
1908 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1909 protected bool ShowKeyboardCues {
1914 #endregion // Protected Instance Properties
1916 #region Public Static Methods
1917 [EditorBrowsable(EditorBrowsableState.Advanced)]
1918 public static Control FromChildHandle(IntPtr handle) {
1919 IEnumerator control = Control.controls.GetEnumerator();
1921 while (control.MoveNext()) {
1922 if (((Control)control.Current).window.Handle == handle) {
1924 if (((Control)control.Current).Parent != null) {
1925 return ((Control)control.Current).Parent;
1932 [EditorBrowsable(EditorBrowsableState.Advanced)]
1933 public static Control FromHandle(IntPtr handle) {
1934 IEnumerator control = Control.controls.GetEnumerator();
1936 while (control.MoveNext()) {
1937 if (((Control)control.Current).window.Handle == handle) {
1939 return ((Control)control.Current);
1945 public static bool IsMnemonic(char charCode, string text) {
1948 amp = text.IndexOf('&');
1951 if (amp + 1 < text.Length) {
1952 if (text[amp + 1] != '&') {
1953 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
1963 #region Protected Static Methods
1964 [EditorBrowsable(EditorBrowsableState.Advanced)]
1965 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
1968 c = Control.FromHandle(hWnd);
1978 #region Public Instance Methods
1979 [EditorBrowsable(EditorBrowsableState.Advanced)]
1980 public IAsyncResult BeginInvoke(Delegate method) {
1981 return BeginInvokeInternal(method, null);
1984 [EditorBrowsable(EditorBrowsableState.Advanced)]
1985 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
1986 return BeginInvokeInternal (method, args);
1989 public void BringToFront() {
1990 if ((parent != null) && (parent.child_controls[0]!=this)) {
1991 if (parent.child_controls.Contains(this)) {
1992 parent.child_controls.SetChildIndex(this, 0);
1996 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
1998 if (parent != null) {
2003 public bool Contains(Control ctl) {
2004 while (ctl != null) {
2013 public void CreateControl() {
2015 if (!IsHandleCreated)
2018 for (int i=0; i<child_controls.Count; i++) {
2019 child_controls[i].CreateControl();
2024 public Graphics CreateGraphics() {
2025 if (!IsHandleCreated) {
2026 this.CreateHandle();
2028 return Graphics.FromHwnd(this.window.Handle);
2031 [MonoTODO("Come up with cross platform drag-drop driver interface")]
2032 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2033 return DragDropEffects.None;
2036 [EditorBrowsable(EditorBrowsableState.Advanced)]
2037 public object EndInvoke (IAsyncResult async_result) {
2038 AsyncMethodResult result = (AsyncMethodResult) async_result;
2039 return result.EndInvoke ();
2042 public Form FindForm() {
2055 public bool Focus() {
2056 if (IsHandleCreated && !has_focus) {
2057 XplatUI.SetFocus(window.Handle);
2063 public Control GetChildAtPoint(Point pt) {
2064 // Microsoft's version of this function doesn't seem to work, so I can't check
2065 // if we only consider children or also grandchildren, etc.
2066 // I'm gonna say 'children only'
2067 for (int i=0; i<child_controls.Count; i++) {
2068 if (child_controls[i].Bounds.Contains(pt)) {
2069 return child_controls[i];
2075 public IContainerControl GetContainerControl() {
2076 Control current = this;
2078 while (current!=null) {
2079 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2080 return (IContainerControl)current;
2082 current = current.parent;
2087 public Control GetNextControl(Control ctl, bool forward) {
2088 // If we're not a container we don't play
2089 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2093 // If ctl is not contained by this, we start at the first child of this
2094 if (!this.Contains(ctl)) {
2098 // Search through our controls, starting at ctl, stepping into children as we encounter them
2099 // try to find the control with the tabindex closest to our own, or, if we're looking into
2100 // child controls, the one with the smallest tabindex
2102 return FindControlForward(this, ctl);
2104 return FindControlBackward(this, ctl);
2107 public void Hide() {
2108 this.Visible = false;
2111 public void Invalidate() {
2112 Invalidate(ClientRectangle, false);
2115 public void Invalidate(bool invalidateChildren) {
2116 Invalidate(ClientRectangle, invalidateChildren);
2119 public void Invalidate(System.Drawing.Rectangle rc) {
2120 Invalidate(rc, false);
2123 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2124 if (!IsHandleCreated || !Visible) {
2128 NotifyInvalidate(rc);
2130 XplatUI.Invalidate(Handle, rc, !GetStyle (ControlStyles.AllPaintingInWmPaint));
2132 if (invalidateChildren) {
2133 for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2135 OnInvalidated(new InvalidateEventArgs(rc));
2138 public void Invalidate(System.Drawing.Region region) {
2139 Invalidate(region, false);
2142 [MonoTODO("Figure out if GetRegionScans is usable")]
2143 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2144 throw new NotImplementedException();
2146 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2147 //if (invalidateChildren) {
2148 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2152 public object Invoke (Delegate method) {
2153 return Invoke(method, null);
2156 public object Invoke (Delegate method, object[] args) {
2157 IAsyncResult result = BeginInvoke (method, args);
2158 return EndInvoke(result);
2161 [EditorBrowsable(EditorBrowsableState.Advanced)]
2162 public void PerformLayout() {
2163 PerformLayout(null, null);
2166 [EditorBrowsable(EditorBrowsableState.Advanced)]
2167 public void PerformLayout(Control affectedControl, string affectedProperty) {
2168 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2170 if (layout_suspended>0) {
2171 layout_pending = true;
2175 layout_pending = false;
2177 // Prevent us from getting messed up
2180 // Perform all Dock and Anchor calculations
2183 AnchorStyles anchor;
2188 space=this.DisplayRectangle;
2189 if (prev_size != Size.Empty) {
2190 diff_width = space.Width - prev_size.Width;
2191 diff_height = space.Height - prev_size.Height;
2197 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2198 for (int i = child_controls.Count - 1; i >= 0; i--) {
2199 child=child_controls[i];
2200 switch (child.Dock) {
2201 case DockStyle.None: {
2206 case DockStyle.Left: {
2207 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2208 space.X+=child.Width;
2209 space.Width-=child.Width;
2213 case DockStyle.Top: {
2214 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2215 space.Y+=child.Height;
2216 space.Height-=child.Height;
2220 case DockStyle.Right: {
2221 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2222 space.Width-=child.Width;
2226 case DockStyle.Bottom: {
2227 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2228 space.Height-=child.Height;
2234 for (int i = child_controls.Count - 1; i >= 0; i--) {
2235 child=child_controls[i];
2237 if (child.Dock == DockStyle.Fill) {
2238 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2244 space=this.DisplayRectangle;
2246 // Deal with anchoring
2247 for (int i=0; i < child_controls.Count; i++) {
2253 child=child_controls[i];
2254 anchor=child.Anchor;
2259 height=child.Height;
2261 // If the control is docked we don't need to do anything
2262 if (child.Dock != DockStyle.None) {
2266 if ((anchor & AnchorStyles.Left) !=0 ) {
2267 if ((anchor & AnchorStyles.Right) != 0) {
2268 // Anchoring to left and right
2269 width=width+diff_width;
2273 } else if ((anchor & AnchorStyles.Right) != 0) {
2279 if ((anchor & AnchorStyles.Top) !=0 ) {
2280 if ((anchor & AnchorStyles.Bottom) != 0) {
2281 height+=diff_height;
2285 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2300 child.SetBounds(left, top, width, height);
2303 // Let everyone know
2307 // Need to make sure we decremend layout_suspended
2313 public Point PointToClient (Point p) {
2317 XplatUI.ScreenToClient (Handle, ref x, ref y);
2319 return new Point (x, y);
2322 public Point PointToScreen(Point p) {
2326 XplatUI.ClientToScreen(Handle, ref x, ref y);
2328 return new Point(x, y);
2331 public virtual bool PreProcessMessage(ref Message msg) {
2334 if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
2335 key_data = (Keys)msg.WParam.ToInt32();
2336 if (!ProcessCmdKey(ref msg, key_data)) {
2337 if (IsInputKey(key_data)) {
2341 return ProcessDialogKey(key_data);
2345 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2346 if (IsInputChar((char)msg.WParam)) {
2349 } else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
2350 if (IsInputChar((char)msg.WParam)) {
2353 return ProcessDialogChar((char)msg.WParam);
2358 public Rectangle RectangleToClient(Rectangle r) {
2359 return new Rectangle(PointToClient(r.Location), r.Size);
2362 public Rectangle RectangleToScreen(Rectangle r) {
2363 return new Rectangle(PointToScreen(r.Location), r.Size);
2366 public virtual void Refresh() {
2367 if (IsHandleCreated == true) {
2369 XplatUI.UpdateWindow(window.Handle);
2373 [EditorBrowsable(EditorBrowsableState.Never)]
2374 public virtual void ResetBackColor() {
2375 background_color = Color.Empty;
2378 #if haveDataBindings
2379 [EditorBrowsable(EditorBrowsableState.Never)]
2381 public void ResetBindings() {
2386 [EditorBrowsable(EditorBrowsableState.Never)]
2387 public virtual void ResetCursor() {
2391 [EditorBrowsable(EditorBrowsableState.Never)]
2392 public virtual void ResetFont() {
2396 [EditorBrowsable(EditorBrowsableState.Never)]
2397 public virtual void ResetForeColor() {
2398 foreground_color = Color.Empty;
2401 [EditorBrowsable(EditorBrowsableState.Never)]
2402 public void ResetImeMode() {
2403 ime_mode = DefaultImeMode;
2406 [EditorBrowsable(EditorBrowsableState.Never)]
2407 public virtual void ResetRightToLeft() {
2408 right_to_left = RightToLeft.Inherit;
2411 public virtual void ResetText() {
2415 public void ResumeLayout() {
2416 ResumeLayout (true);
2419 public void ResumeLayout(bool performLayout) {
2422 if (layout_suspended > 0) {
2426 if (performLayout || layout_pending) {
2431 public void Scale(float ratio) {
2432 ScaleCore(ratio, ratio);
2435 public void Scale(float dx, float dy) {
2439 public void Select() {
2440 Select(false, false);
2443 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2448 c = GetNextControl(c, forward);
2457 if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
2461 } while (c != ctl); // If we wrap back to ourselves we stop
2466 public void SendToBack() {
2467 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2468 if (parent.child_controls.Contains(this)) {
2469 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2473 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2474 if (parent != null) {
2479 public void SetBounds(int x, int y, int width, int height) {
2480 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2483 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2484 SetBoundsCore(x, y, width, height, specified);
2487 public void Show() {
2488 if (!IsHandleCreated) {
2489 this.CreateHandle();
2495 public void SuspendLayout() {
2499 public void Update() {
2500 XplatUI.UpdateWindow(window.Handle);
2502 #endregion // Public Instance Methods
2504 #region Protected Instance Methods
2505 [EditorBrowsable(EditorBrowsableState.Advanced)]
2506 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2507 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2508 throw new NotImplementedException();
2511 [EditorBrowsable(EditorBrowsableState.Advanced)]
2512 protected virtual AccessibleObject CreateAccessibilityInstance() {
2513 return new Control.ControlAccessibleObject(this);
2516 [EditorBrowsable(EditorBrowsableState.Advanced)]
2517 protected virtual ControlCollection CreateControlsInstance() {
2518 return new ControlCollection(this);
2521 [EditorBrowsable(EditorBrowsableState.Advanced)]
2522 protected virtual void CreateHandle() {
2524 throw new ObjectDisposedException(Name);
2527 if (IsHandleCreated) {
2532 window = new ControlNativeWindow(this);
2533 window.CreateHandle(CreateParams);
2535 // Find out where the window manager placed us
2540 if (window.Handle!=IntPtr.Zero) {
2541 if (!controls.Contains(window.Handle)) {
2545 creator_thread = Thread.CurrentThread;
2547 XplatUI.SetWindowBackground(window.Handle, this.BackColor);
2549 OnHandleCreated(EventArgs.Empty);
2553 [EditorBrowsable(EditorBrowsableState.Advanced)]
2554 protected virtual void DefWndProc(ref Message m) {
2555 window.DefWndProc(ref m);
2558 [EditorBrowsable(EditorBrowsableState.Advanced)]
2559 protected virtual void DestroyHandle() {
2560 if (IsHandleCreated) {
2561 if (Handle != IntPtr.Zero) {
2562 controls.Remove(Handle);
2565 if (window != null) {
2566 window.DestroyHandle();
2571 protected bool GetStyle(ControlStyles flag) {
2572 return (control_style & flag) != 0;
2575 protected bool GetTopLevel() {
2579 [EditorBrowsable(EditorBrowsableState.Advanced)]
2580 protected virtual void InitLayout() {
2581 if (parent != null) {
2582 parent.PerformLayout(this, "parent");
2586 [EditorBrowsable(EditorBrowsableState.Advanced)]
2587 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2588 toInvoke.OnGotFocus(e);
2591 [EditorBrowsable(EditorBrowsableState.Advanced)]
2592 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2593 toInvoke.OnLostFocus(e);
2596 [EditorBrowsable(EditorBrowsableState.Advanced)]
2597 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2598 toInvoke.OnClick(e);
2601 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2602 toInvoke.OnPaint(e);
2605 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2606 toInvoke.OnPaintBackground(e);
2609 protected virtual bool IsInputChar (char charCode) {
2610 if (parent != null) {
2611 return parent.IsInputChar(charCode);
2617 protected virtual bool IsInputKey (Keys keyData) {
2618 // Doc says this one calls IsInputChar; not sure what to do with that
2622 [EditorBrowsable(EditorBrowsableState.Advanced)]
2623 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2627 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2628 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2632 if (parent != null) {
2633 return parent.ProcessCmdKey(ref msg, keyData);
2639 protected virtual bool ProcessDialogChar(char charCode) {
2640 if (parent != null) {
2641 return parent.ProcessDialogChar (charCode);
2647 protected virtual bool ProcessDialogKey (Keys keyData) {
2648 if (parent != null) {
2649 return parent.ProcessDialogKey (keyData);
2655 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2657 KeyEventArgs key_event;
2660 case (int)Msg.WM_KEYDOWN: {
2661 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2662 OnKeyDown (key_event);
2663 return key_event.Handled;
2665 case (int)Msg.WM_KEYUP: {
2666 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2667 OnKeyUp (key_event);
2668 return key_event.Handled;
2671 case (int)Msg.WM_CHAR: {
2672 KeyPressEventArgs key_press_event;
2674 key_press_event = new KeyPressEventArgs((char)msg.WParam);
2675 OnKeyPress(key_press_event);
2676 return key_press_event.Handled;
2687 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
2688 if (parent != null) {
2689 if (parent.ProcessKeyPreview(ref msg)) {
2697 protected virtual bool ProcessKeyPreview(ref Message msg) {
2698 if (parent != null) {
2699 return parent.ProcessKeyPreview(ref msg);
2705 protected virtual bool ProcessMnemonic(char charCode) {
2710 [EditorBrowsable(EditorBrowsableState.Advanced)]
2711 protected void RaiseDragEvent(object key, DragEventArgs e) {
2715 [EditorBrowsable(EditorBrowsableState.Advanced)]
2716 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
2720 [EditorBrowsable(EditorBrowsableState.Advanced)]
2721 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
2725 [EditorBrowsable(EditorBrowsableState.Advanced)]
2726 protected void RaisePaintEvent(object key, PaintEventArgs e) {
2730 [EditorBrowsable(EditorBrowsableState.Advanced)]
2731 protected void RecreateHandle() {
2732 IEnumerator child = child_controls.GetEnumerator();
2736 if (IsHandleCreated) {
2742 while (child.MoveNext()) {
2743 ((Control)child.Current).RecreateHandle();
2749 is_recreating = false;
2752 [EditorBrowsable(EditorBrowsableState.Advanced)]
2753 protected void ResetMouseEventArgs() {
2757 [EditorBrowsable(EditorBrowsableState.Advanced)]
2758 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
2759 if (right_to_left == RightToLeft.No) {
2764 case ContentAlignment.TopLeft: {
2765 return ContentAlignment.TopRight;
2768 case ContentAlignment.TopRight: {
2769 return ContentAlignment.TopLeft;
2772 case ContentAlignment.MiddleLeft: {
2773 return ContentAlignment.MiddleRight;
2776 case ContentAlignment.MiddleRight: {
2777 return ContentAlignment.MiddleLeft;
2780 case ContentAlignment.BottomLeft: {
2781 return ContentAlignment.BottomRight;
2784 case ContentAlignment.BottomRight: {
2785 return ContentAlignment.BottomLeft;
2789 // if it's center it doesn't change
2795 [EditorBrowsable(EditorBrowsableState.Advanced)]
2796 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
2797 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
2801 if (align == HorizontalAlignment.Left) {
2802 return HorizontalAlignment.Right;
2805 // align must be HorizontalAlignment.Right
2806 return HorizontalAlignment.Left;
2809 [EditorBrowsable(EditorBrowsableState.Advanced)]
2810 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
2811 if (right_to_left == RightToLeft.No) {
2815 if (align == LeftRightAlignment.Left) {
2816 return LeftRightAlignment.Right;
2819 // align must be LeftRightAlignment.Right;
2820 return LeftRightAlignment.Left;
2823 [EditorBrowsable(EditorBrowsableState.Advanced)]
2824 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
2825 return RtlTranslateAlignment(align);
2828 [EditorBrowsable(EditorBrowsableState.Advanced)]
2829 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
2830 return RtlTranslateAlignment(align);
2833 [EditorBrowsable(EditorBrowsableState.Advanced)]
2834 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
2835 return RtlTranslateAlignment(align);
2838 [EditorBrowsable(EditorBrowsableState.Advanced)]
2839 protected virtual void ScaleCore(float dx, float dy) {
2845 location = new Point((int)(Left * dx), (int)(Top * dy));
2846 size = this.ClientSize;
2849 if (!GetStyle(ControlStyles.FixedWidth)) {
2850 size.Width = (int)(size.Width * dx);
2853 if (!GetStyle(ControlStyles.FixedHeight)) {
2854 size.Height = (int)(size.Height * dy);
2857 Location = location;
2860 /* Now scale our children */
2861 for (int i=0; i < child_controls.Count; i++) {
2862 child_controls[i].Scale(dx, dy);
2868 protected virtual void Select(bool directed, bool forward) {
2873 // Select this control
2878 if (parent == null) {
2882 // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
2884 index = parent.child_controls.IndexOf(this);
2889 if ((index+1) < parent.child_controls.Count) {
2898 index = parent.child_controls.Count-1;
2901 result = Select(parent.child_controls[index]);
2902 } while (!result && parent.child_controls[index] != this);
2905 [EditorBrowsable(EditorBrowsableState.Advanced)]
2906 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
2907 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
2908 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
2912 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
2916 if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
2920 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
2924 if (IsHandleCreated) {
2925 XplatUI.SetWindowPos(Handle, x, y, width, height);
2927 UpdateBounds(x, y, width, height);
2930 [EditorBrowsable(EditorBrowsableState.Advanced)]
2931 protected virtual void SetClientSizeCore(int x, int y) {
2932 // Calculate the actual window size from the client size (it usually stays the same or grows)
2933 Rectangle ClientRect;
2934 Rectangle WindowRect;
2937 ClientRect = new Rectangle(0, 0, x, y);
2938 cp = this.CreateParams;
2940 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
2944 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
2947 [EditorBrowsable(EditorBrowsableState.Advanced)]
2948 protected void SetStyle(ControlStyles flag, bool value) {
2950 control_style |= flag;
2952 control_style &= ~flag;
2956 protected void SetTopLevel(bool value) {
2957 if ((GetTopLevel() != value) && (parent != null)) {
2958 throw new Exception();
2962 if (value == true) {
2972 is_toplevel = value;
2975 protected virtual void SetVisibleCore(bool value) {
2976 if (value!=is_visible) {
2978 XplatUI.SetVisible(Handle, value);
2979 // Explicitly move Toplevel windows to where we want them;
2980 // apparently moving unmapped toplevel windows doesn't work
2981 if (is_visible && (this is Form)) {
2982 XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
2984 OnVisibleChanged(EventArgs.Empty);
2987 if (dc_mem != null) {
2992 if (bmp_mem != null) {
2997 this.CreateBuffers(bounds.Width, bounds.Height);
3000 // FIXME - deal with focus
3002 if (parent != null) {
3003 parent.PerformLayout(this, "visible");
3005 PerformLayout(this, "visible");
3010 [EditorBrowsable(EditorBrowsableState.Advanced)]
3011 protected void UpdateBounds() {
3019 if (!IsHandleCreated) {
3023 XplatUI.GetWindowPos(this.Handle, this is Form, out x, out y, out width, out height, out client_width, out client_height);
3025 UpdateBounds(x, y, width, height, client_width, client_height);
3028 [EditorBrowsable(EditorBrowsableState.Advanced)]
3029 protected void UpdateBounds(int x, int y, int width, int height) {
3030 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3032 bool resized = false;
3034 int client_x_diff = this.bounds.Width-this.client_size.Width;
3035 int client_y_diff = this.bounds.Height-this.client_size.Height;
3037 // Needed to generate required notifications
3038 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3042 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3049 bounds.Height=height;
3051 // Update client rectangle as well
3052 if (this.layout_suspended==0) {
3053 prev_size.Width=client_size.Width;
3054 prev_size.Height=client_size.Height;
3057 client_size.Width=width-client_x_diff;
3058 client_size.Height=height-client_y_diff;
3061 OnLocationChanged(EventArgs.Empty);
3065 OnSizeChanged(EventArgs.Empty);
3069 [EditorBrowsable(EditorBrowsableState.Advanced)]
3070 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3071 UpdateBounds(x, y, width, height);
3073 this.client_size.Width=clientWidth;
3074 this.client_size.Height=clientHeight;
3077 [EditorBrowsable(EditorBrowsableState.Advanced)]
3078 protected void UpdateStyles() {
3079 if (!IsHandleCreated) {
3083 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3086 [EditorBrowsable(EditorBrowsableState.Advanced)]
3087 protected void UpdateZOrder() {
3092 if (parent == null) {
3098 children = ctl.child_controls.Count;
3099 for (int i = 1; i < children; i++ ) {
3100 XplatUI.SetZOrder(ctl.child_controls[i].window.Handle, ctl.child_controls[i-1].window.Handle, false, false);
3103 children = child_controls.Count;
3104 for (int i = 1; i < children; i++ ) {
3105 XplatUI.SetZOrder(child_controls[i].window.Handle, child_controls[i-1].window.Handle, false, false);
3110 protected virtual void WndProc(ref Message m) {
3112 Console.WriteLine("Control received message {0}", (Msg)m.Msg);
3114 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3118 switch((Msg)m.Msg) {
3119 case Msg.WM_WINDOWPOSCHANGED: {
3122 if (GetStyle(ControlStyles.ResizeRedraw)) {
3129 case Msg.WM_PAINT: {
3130 PaintEventArgs paint_event;
3132 paint_event = XplatUI.PaintEventStart(Handle);
3134 if (GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3135 OnPaintBackground(paint_event);
3137 OnPaint(paint_event);
3138 XplatUI.PaintEventEnd(Handle);
3143 case Msg.WM_ERASEBKGND: {
3144 if (GetStyle (ControlStyles.UserPaint)) {
3145 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3146 PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
3147 Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
3148 OnPaintBackground (eraseEventArgs);
3150 m.Result = (IntPtr)1;
3152 m.Result = IntPtr.Zero;
3159 case Msg.WM_LBUTTONUP: {
3160 HandleClick(mouse_clicks);
3161 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3163 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3165 if (mouse_clicks > 1) {
3171 case Msg.WM_LBUTTONDOWN: {
3172 if (CanSelect && !is_selected) {
3175 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3176 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3182 case Msg.WM_LBUTTONDBLCLK: {
3184 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3185 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3191 case Msg.WM_MBUTTONUP: {
3192 HandleClick(mouse_clicks);
3193 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3195 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3197 if (mouse_clicks > 1) {
3203 case Msg.WM_MBUTTONDOWN: {
3204 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3205 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3211 case Msg.WM_MBUTTONDBLCLK: {
3213 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3214 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3219 case Msg.WM_RBUTTONUP: {
3220 HandleClick(mouse_clicks);
3221 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3223 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3225 if (mouse_clicks > 1) {
3231 case Msg.WM_RBUTTONDOWN: {
3232 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3233 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3238 case Msg.WM_RBUTTONDBLCLK: {
3240 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3241 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3246 case Msg.WM_MOUSEWHEEL: {
3248 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3249 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3250 HighOrder(m.WParam.ToInt32())));
3255 case Msg.WM_MOUSEMOVE: {
3256 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3258 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3263 case Msg.WM_MOUSE_ENTER: {
3268 OnMouseEnter(EventArgs.Empty);
3272 case Msg.WM_MOUSE_LEAVE: {
3274 OnMouseLeave(EventArgs.Empty);
3278 case Msg.WM_MOUSEHOVER: {
3279 OnMouseHover(EventArgs.Empty);
3283 case Msg.WM_SYSKEYDOWN:
3284 case Msg.WM_KEYDOWN:
3285 case Msg.WM_SYSKEYUP:
3287 case Msg.WM_SYSCHAR:
3289 if (ProcessKeyEventArgs(ref m)) {
3293 if (PreProcessMessage(ref m)) {
3297 if (ProcessKeyMessage(ref m)) {
3306 if (m.LParam != IntPtr.Zero) {
3309 hi = new HELPINFO();
3311 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3312 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3314 mouse_pos = Control.MousePosition;
3316 OnHelpRequested(new HelpEventArgs(mouse_pos));
3317 m.Result = (IntPtr)1;
3321 case Msg.WM_KILLFOCUS: {
3322 OnLeave(EventArgs.Empty);
3323 if (CausesValidation) {
3325 e = new CancelEventArgs(false);
3334 OnValidated(EventArgs.Empty);
3337 this.has_focus = false;
3338 this.is_selected = false;
3339 OnLostFocus(EventArgs.Empty);
3343 case Msg.WM_SETFOCUS: {
3344 OnEnter(EventArgs.Empty);
3345 this.has_focus = true;
3346 OnGotFocus(EventArgs.Empty);
3351 case Msg.WM_SYSCOLORCHANGE: {
3352 ThemeEngine.Current.ResetDefaults();
3353 OnSystemColorsChanged(EventArgs.Empty);
3358 case Msg.WM_SETCURSOR: {
3359 if (cursor == null) {
3364 XplatUI.SetCursor(window.Handle, cursor.handle);
3365 m.Result = (IntPtr)1;
3375 #endregion // Public Instance Methods
3377 #region OnXXX methods
3378 [EditorBrowsable(EditorBrowsableState.Advanced)]
3379 protected virtual void OnBackColorChanged(EventArgs e) {
3380 if (BackColorChanged!=null) BackColorChanged(this, e);
3381 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3384 [EditorBrowsable(EditorBrowsableState.Advanced)]
3385 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3386 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3387 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3390 [EditorBrowsable(EditorBrowsableState.Advanced)]
3391 protected virtual void OnBindingContextChanged(EventArgs e) {
3392 if (BindingContextChanged!=null) BindingContextChanged(this, e);
3393 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3396 [EditorBrowsable(EditorBrowsableState.Advanced)]
3397 protected virtual void OnCausesValidationChanged(EventArgs e) {
3398 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3401 [EditorBrowsable(EditorBrowsableState.Advanced)]
3402 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3403 if (ChangeUICues!=null) ChangeUICues(this, e);
3406 [EditorBrowsable(EditorBrowsableState.Advanced)]
3407 protected virtual void OnClick(EventArgs e) {
3408 if (Click!=null) Click(this, e);
3411 [EditorBrowsable(EditorBrowsableState.Advanced)]
3412 protected virtual void OnContextMenuChanged(EventArgs e) {
3413 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3416 [EditorBrowsable(EditorBrowsableState.Advanced)]
3417 protected virtual void OnControlAdded(ControlEventArgs e) {
3418 if (ControlAdded!=null) ControlAdded(this, e);
3421 [EditorBrowsable(EditorBrowsableState.Advanced)]
3422 protected virtual void OnControlRemoved(ControlEventArgs e) {
3423 if (ControlRemoved!=null) ControlRemoved(this, e);
3426 [EditorBrowsable(EditorBrowsableState.Advanced)]
3427 protected virtual void OnCreateControl() {
3431 [EditorBrowsable(EditorBrowsableState.Advanced)]
3432 protected virtual void OnCursorChanged(EventArgs e) {
3433 if (CursorChanged!=null) CursorChanged(this, e);
3436 [EditorBrowsable(EditorBrowsableState.Advanced)]
3437 protected virtual void OnDockChanged(EventArgs e) {
3438 if (DockChanged!=null) DockChanged(this, e);
3441 [EditorBrowsable(EditorBrowsableState.Advanced)]
3442 protected virtual void OnDoubleClick(EventArgs e) {
3443 if (DoubleClick!=null) DoubleClick(this, e);
3446 [EditorBrowsable(EditorBrowsableState.Advanced)]
3447 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3448 if (DragDrop!=null) DragDrop(this, drgevent);
3451 [EditorBrowsable(EditorBrowsableState.Advanced)]
3452 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3453 if (DragEnter!=null) DragEnter(this, drgevent);
3456 [EditorBrowsable(EditorBrowsableState.Advanced)]
3457 protected virtual void OnDragLeave(EventArgs e) {
3458 if (DragLeave!=null) DragLeave(this, e);
3461 [EditorBrowsable(EditorBrowsableState.Advanced)]
3462 protected virtual void OnDragOver(DragEventArgs drgevent) {
3463 if (DragOver!=null) DragOver(this, drgevent);
3466 [EditorBrowsable(EditorBrowsableState.Advanced)]
3467 protected virtual void OnEnabledChanged(EventArgs e) {
3468 if (EnabledChanged!=null) EnabledChanged(this, e);
3469 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3472 [EditorBrowsable(EditorBrowsableState.Advanced)]
3473 protected virtual void OnEnter(EventArgs e) {
3474 if (Enter!=null) Enter(this, e);
3477 [EditorBrowsable(EditorBrowsableState.Advanced)]
3478 protected virtual void OnFontChanged(EventArgs e) {
3479 if (FontChanged!=null) FontChanged(this, e);
3480 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3483 [EditorBrowsable(EditorBrowsableState.Advanced)]
3484 protected virtual void OnForeColorChanged(EventArgs e) {
3485 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3486 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3489 [EditorBrowsable(EditorBrowsableState.Advanced)]
3490 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3491 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3494 [EditorBrowsable(EditorBrowsableState.Advanced)]
3495 protected virtual void OnGotFocus(EventArgs e) {
3496 if (GotFocus!=null) GotFocus(this, e);
3499 [EditorBrowsable(EditorBrowsableState.Advanced)]
3500 protected virtual void OnHandleCreated(EventArgs e) {
3501 if (HandleCreated!=null) HandleCreated(this, e);
3504 [EditorBrowsable(EditorBrowsableState.Advanced)]
3505 protected virtual void OnHandleDestroyed(EventArgs e) {
3506 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3509 [EditorBrowsable(EditorBrowsableState.Advanced)]
3510 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3511 if (HelpRequested!=null) HelpRequested(this, hevent);
3514 protected virtual void OnImeModeChanged(EventArgs e) {
3515 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3518 [EditorBrowsable(EditorBrowsableState.Advanced)]
3519 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3520 if (Invalidated!=null) Invalidated(this, e);
3523 [EditorBrowsable(EditorBrowsableState.Advanced)]
3524 protected virtual void OnKeyDown(KeyEventArgs e) {
3525 if (KeyDown!=null) KeyDown(this, e);
3528 [EditorBrowsable(EditorBrowsableState.Advanced)]
3529 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3530 if (KeyPress!=null) KeyPress(this, e);
3533 [EditorBrowsable(EditorBrowsableState.Advanced)]
3534 protected virtual void OnKeyUp(KeyEventArgs e) {
3535 if (KeyUp!=null) KeyUp(this, e);
3538 [EditorBrowsable(EditorBrowsableState.Advanced)]
3539 protected virtual void OnLayout(LayoutEventArgs levent) {
3540 if (Layout!=null) Layout(this, levent);
3543 [EditorBrowsable(EditorBrowsableState.Advanced)]
3544 protected virtual void OnLeave(EventArgs e) {
3545 if (Leave!=null) Leave(this, e);
3548 [EditorBrowsable(EditorBrowsableState.Advanced)]
3549 protected virtual void OnLocationChanged(EventArgs e) {
3551 if (LocationChanged!=null) LocationChanged(this, e);
3554 [EditorBrowsable(EditorBrowsableState.Advanced)]
3555 protected virtual void OnLostFocus(EventArgs e) {
3556 if (LostFocus!=null) LostFocus(this, e);
3559 [EditorBrowsable(EditorBrowsableState.Advanced)]
3560 protected virtual void OnMouseDown(MouseEventArgs e) {
3561 if (MouseDown!=null) MouseDown(this, e);
3564 [EditorBrowsable(EditorBrowsableState.Advanced)]
3565 protected virtual void OnMouseEnter(EventArgs e) {
3566 if (MouseEnter!=null) MouseEnter(this, e);
3569 [EditorBrowsable(EditorBrowsableState.Advanced)]
3570 protected virtual void OnMouseHover(EventArgs e) {
3571 if (MouseHover!=null) MouseHover(this, e);
3574 [EditorBrowsable(EditorBrowsableState.Advanced)]
3575 protected virtual void OnMouseLeave(EventArgs e) {
3576 if (MouseLeave!=null) MouseLeave(this, e);
3579 [EditorBrowsable(EditorBrowsableState.Advanced)]
3580 protected virtual void OnMouseMove(MouseEventArgs e) {
3581 if (MouseMove!=null) MouseMove(this, e);
3584 [EditorBrowsable(EditorBrowsableState.Advanced)]
3585 protected virtual void OnMouseUp(MouseEventArgs e) {
3586 if (MouseUp!=null) MouseUp(this, e);
3589 [EditorBrowsable(EditorBrowsableState.Advanced)]
3590 protected virtual void OnMouseWheel(MouseEventArgs e) {
3591 if (MouseWheel!=null) MouseWheel(this, e);
3594 [EditorBrowsable(EditorBrowsableState.Advanced)]
3595 protected virtual void OnMove(EventArgs e) {
3596 if (Move!=null) Move(this, e);
3599 [EditorBrowsable(EditorBrowsableState.Advanced)]
3600 protected virtual void OnNotifyMessage(Message m) {
3604 [EditorBrowsable(EditorBrowsableState.Advanced)]
3605 protected virtual void OnPaint(PaintEventArgs e) {
3606 if (Paint!=null) Paint(this, e);
3609 [EditorBrowsable(EditorBrowsableState.Advanced)]
3610 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3614 [EditorBrowsable(EditorBrowsableState.Advanced)]
3615 protected virtual void OnParentBackColorChanged(EventArgs e) {
3616 if (background_color.IsEmpty && background_image==null) {
3618 OnBackColorChanged(e);
3622 [EditorBrowsable(EditorBrowsableState.Advanced)]
3623 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3624 if (background_color.IsEmpty && background_image==null) {
3626 OnBackgroundImageChanged(e);
3630 [EditorBrowsable(EditorBrowsableState.Advanced)]
3631 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3632 if (binding_context==null) {
3633 binding_context=Parent.binding_context;
3634 OnBindingContextChanged(e);
3638 [EditorBrowsable(EditorBrowsableState.Advanced)]
3639 protected virtual void OnParentChanged(EventArgs e) {
3640 if (ParentChanged!=null) ParentChanged(this, e);
3643 [EditorBrowsable(EditorBrowsableState.Advanced)]
3644 protected virtual void OnParentEnabledChanged(EventArgs e) {
3645 if (is_enabled != Parent.is_enabled) {
3646 is_enabled=Parent.is_enabled;
3648 if (EnabledChanged != null) {
3649 EnabledChanged(this, e);
3654 [EditorBrowsable(EditorBrowsableState.Advanced)]
3655 protected virtual void OnParentFontChanged(EventArgs e) {
3662 [EditorBrowsable(EditorBrowsableState.Advanced)]
3663 protected virtual void OnParentForeColorChanged(EventArgs e) {
3664 if (foreground_color.IsEmpty) {
3666 OnForeColorChanged(e);
3670 [EditorBrowsable(EditorBrowsableState.Advanced)]
3671 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
3672 if (right_to_left==RightToLeft.Inherit) {
3674 OnRightToLeftChanged(e);
3678 [EditorBrowsable(EditorBrowsableState.Advanced)]
3679 protected virtual void OnParentVisibleChanged(EventArgs e) {
3680 if (is_visible!=Parent.is_visible) {
3683 OnVisibleChanged(e);
3687 [EditorBrowsable(EditorBrowsableState.Advanced)]
3688 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
3689 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
3692 [EditorBrowsable(EditorBrowsableState.Advanced)]
3693 protected virtual void OnResize(EventArgs e) {
3694 if (Resize!=null) Resize(this, e);
3696 PerformLayout(this, "bounds");
3698 if (parent != null) {
3699 parent.PerformLayout();
3703 [EditorBrowsable(EditorBrowsableState.Advanced)]
3704 protected virtual void OnRightToLeftChanged(EventArgs e) {
3705 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
3706 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
3709 [EditorBrowsable(EditorBrowsableState.Advanced)]
3710 protected virtual void OnSizeChanged(EventArgs e) {
3711 InvalidateBuffers ();
3713 if (SizeChanged!=null) SizeChanged(this, e);
3716 [EditorBrowsable(EditorBrowsableState.Advanced)]
3717 protected virtual void OnStyleChanged(EventArgs e) {
3718 if (StyleChanged!=null) StyleChanged(this, e);
3721 [EditorBrowsable(EditorBrowsableState.Advanced)]
3722 protected virtual void OnSystemColorsChanged(EventArgs e) {
3723 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
3726 [EditorBrowsable(EditorBrowsableState.Advanced)]
3727 protected virtual void OnTabIndexChanged(EventArgs e) {
3728 if (TabIndexChanged!=null) TabIndexChanged(this, e);
3731 [EditorBrowsable(EditorBrowsableState.Advanced)]
3732 protected virtual void OnTabStopChanged(EventArgs e) {
3733 if (TabStopChanged!=null) TabStopChanged(this, e);
3736 [EditorBrowsable(EditorBrowsableState.Advanced)]
3737 protected virtual void OnTextChanged(EventArgs e) {
3738 if (TextChanged!=null) TextChanged(this, e);
3741 [EditorBrowsable(EditorBrowsableState.Advanced)]
3742 protected virtual void OnValidated(EventArgs e) {
3743 if (Validated!=null) Validated(this, e);
3746 [EditorBrowsable(EditorBrowsableState.Advanced)]
3747 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
3748 if (Validating!=null) Validating(this, e);
3751 [EditorBrowsable(EditorBrowsableState.Advanced)]
3752 protected virtual void OnVisibleChanged(EventArgs e) {
3759 if (bmp_mem!=null) {
3765 if (!this.IsHandleCreated) {
3766 this.CreateHandle();
3772 if (VisibleChanged!=null) VisibleChanged(this, e);
3774 // We need to tell our kids
3775 for (int i=0; i<child_controls.Count; i++) {
3776 child_controls[i].OnParentVisibleChanged(e);
3779 #endregion // OnXXX methods
3782 public event EventHandler BackColorChanged;
3783 public event EventHandler BackgroundImageChanged;
3784 public event EventHandler BindingContextChanged;
3785 public event EventHandler CausesValidationChanged;
3786 public event UICuesEventHandler ChangeUICues;
3787 public event EventHandler Click;
3788 public event EventHandler ContextMenuChanged;
3790 [EditorBrowsable(EditorBrowsableState.Advanced)]
3792 public event ControlEventHandler ControlAdded;
3794 [EditorBrowsable(EditorBrowsableState.Advanced)]
3796 public event ControlEventHandler ControlRemoved;
3798 public event EventHandler CursorChanged;
3799 public event EventHandler DockChanged;
3800 public event EventHandler DoubleClick;
3801 public event DragEventHandler DragDrop;
3802 public event DragEventHandler DragEnter;
3803 public event EventHandler DragLeave;
3804 public event DragEventHandler DragOver;
3805 public event EventHandler EnabledChanged;
3806 public event EventHandler Enter;
3807 public event EventHandler FontChanged;
3808 public event EventHandler ForeColorChanged;
3809 public event GiveFeedbackEventHandler GiveFeedback;
3811 [EditorBrowsable(EditorBrowsableState.Advanced)]
3813 public event EventHandler GotFocus;
3815 [EditorBrowsable(EditorBrowsableState.Advanced)]
3817 public event EventHandler HandleCreated;
3819 [EditorBrowsable(EditorBrowsableState.Advanced)]
3821 public event EventHandler HandleDestroyed;
3823 public event HelpEventHandler HelpRequested;
3824 public event EventHandler ImeModeChanged;
3826 [EditorBrowsable(EditorBrowsableState.Advanced)]
3828 public event InvalidateEventHandler Invalidated;
3830 public event KeyEventHandler KeyDown;
3831 public event KeyPressEventHandler KeyPress;
3832 public event KeyEventHandler KeyUp;
3833 public event LayoutEventHandler Layout;
3834 public event EventHandler Leave;
3835 public event EventHandler LocationChanged;
3837 [EditorBrowsable(EditorBrowsableState.Advanced)]
3839 public event EventHandler LostFocus;
3841 public event MouseEventHandler MouseDown;
3842 public event EventHandler MouseEnter;
3843 public event EventHandler MouseHover;
3844 public event EventHandler MouseLeave;
3845 public event MouseEventHandler MouseMove;
3846 public event MouseEventHandler MouseUp;
3848 [EditorBrowsable(EditorBrowsableState.Advanced)]
3850 public event MouseEventHandler MouseWheel;
3852 public event EventHandler Move;
3853 public event PaintEventHandler Paint;
3854 public event EventHandler ParentChanged;
3855 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
3856 public event QueryContinueDragEventHandler QueryContinueDrag;
3857 public event EventHandler Resize;
3858 public event EventHandler RightToLeftChanged;
3859 public event EventHandler SizeChanged;
3860 public event EventHandler StyleChanged;
3861 public event EventHandler SystemColorsChanged;
3862 public event EventHandler TabIndexChanged;
3863 public event EventHandler TabStopChanged;
3864 public event EventHandler TextChanged;
3865 public event EventHandler Validated;
3866 public event CancelEventHandler Validating;
3867 public event EventHandler VisibleChanged;
3868 #endregion // Events