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 owner;
120 public ControlNativeWindow(Control control) : base() {
125 public Control Owner {
131 static internal Control ControlFromHandle(IntPtr hWnd) {
132 ControlNativeWindow window;
134 window = (ControlNativeWindow)window_collection[hWnd];
139 protected override void WndProc(ref Message m) {
140 owner.WndProc(ref m);
145 #region Public Classes
146 public class ControlAccessibleObject : AccessibleObject {
147 #region ControlAccessibleObject Local Variables
148 private Control owner;
149 #endregion // ControlAccessibleObject Local Variables
151 #region ControlAccessibleObject Constructors
152 public ControlAccessibleObject(Control ownerControl) {
153 this.owner = ownerControl;
155 #endregion // ControlAccessibleObject Constructors
157 #region ControlAccessibleObject Public Instance Properties
158 public override string DefaultAction {
160 return base.DefaultAction;
164 public override string Description {
166 return base.Description;
170 public IntPtr Handle {
176 // We don't want to let them set it
180 public override string Help {
186 public override string KeyboardShortcut {
188 return base.KeyboardShortcut;
192 public override string Name {
202 public Control Owner {
208 public override AccessibleRole Role {
213 #endregion // ControlAccessibleObject Public Instance Properties
215 #region ControlAccessibleObject Public Instance Methods
216 public override int GetHelpTopic(out string FileName) {
217 return base.GetHelpTopic (out FileName);
220 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
221 public void NotifyClients(AccessibleEvents accEvent) {
222 throw new NotImplementedException();
225 [MonoTODO("Implement this and tie it into Control.AccessibilityNotifyClients")]
226 public void NotifyClients(AccessibleEvents accEvent, int childID) {
227 throw new NotImplementedException();
230 public override string ToString() {
231 return "ControlAccessibleObject: Owner = " + owner.ToString() + ", Text: " + owner.text;
234 #endregion // ControlAccessibleObject Public Instance Methods
237 public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
238 #region ControlCollection Local Variables
239 internal ArrayList list;
240 internal Control owner;
241 #endregion // ControlCollection Local Variables
243 #region ControlCollection Public Constructor
244 public ControlCollection(Control owner) {
246 this.list=new ArrayList();
250 #region ControlCollection Public Instance Properties
257 public bool IsReadOnly {
259 return list.IsReadOnly;
263 public virtual Control this[int index] {
265 if (index < 0 || index >= list.Count) {
266 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
268 return (Control)list[index];
271 #endregion // ControlCollection Public Instance Properties
273 #region ControlCollection Private Instance Methods
274 public virtual void Add (Control value)
277 for (int i = 0; i < list.Count; i++) {
278 if (list [i] == value) {
279 // Do we need to do anything here?
284 if (value.tab_index == -1) {
290 end = owner.child_controls.Count;
291 for (int i = 0; i < end; i++) {
292 index = owner.child_controls[i].tab_index;
297 value.tab_index = use;
301 value.Parent = owner;
302 owner.UpdateZOrder();
303 owner.OnControlAdded(new ControlEventArgs(value));
306 public virtual void AddRange (Control[] controls)
308 if (controls == null)
309 throw new ArgumentNullException ("controls");
311 owner.SuspendLayout ();
314 for (int i = 0; i < controls.Length; i++)
317 owner.ResumeLayout ();
321 public virtual void Clear ()
323 owner.SuspendLayout();
324 for (int i = 0; i < list.Count; i++) {
325 owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
328 owner.ResumeLayout();
331 public virtual bool Contains (Control value)
333 return list.Contains (value);
336 public void CopyTo (Array array, int index)
338 list.CopyTo(array, index);
341 public override bool Equals(object other) {
342 if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
349 public int GetChildIndex(Control child) {
350 return GetChildIndex(child, false);
353 public int GetChildIndex(Control child, bool throwException) {
356 index=list.IndexOf(child);
358 if (index==-1 && throwException) {
359 throw new ArgumentException("Not a child control", "child");
364 public IEnumerator GetEnumerator() {
365 return list.GetEnumerator();
368 public override int GetHashCode() {
369 return base.GetHashCode();
372 public int IndexOf(Control control) {
373 return list.IndexOf(control);
376 public virtual void Remove(Control value) {
377 owner.OnControlRemoved(new ControlEventArgs(value));
379 owner.UpdateZOrder();
382 public void RemoveAt(int index) {
383 if (index<0 || index>=list.Count) {
384 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
387 owner.OnControlRemoved(new ControlEventArgs((Control)list[index]));
388 list.RemoveAt(index);
389 owner.UpdateZOrder();
392 public void SetChildIndex(Control child, int newIndex) {
395 old_index=list.IndexOf(child);
397 throw new ArgumentException("Not a child control", "child");
400 if (old_index==newIndex) {
406 if (newIndex>list.Count) {
409 list.Insert(newIndex, child);
411 owner.UpdateZOrder();
413 #endregion // ControlCollection Private Instance Methods
415 #region ControlCollection Interface Properties
416 object IList.this[int index] {
418 if (index<0 || index>=list.Count) {
419 throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
425 if (!(value is Control)) {
426 throw new ArgumentException("Object of type Control required", "value");
429 list[index]=(Control)value;
433 bool IList.IsFixedSize {
439 bool IList.IsReadOnly {
441 return list.IsReadOnly;
445 bool ICollection.IsSynchronized {
447 return list.IsSynchronized;
451 object ICollection.SyncRoot {
453 return list.SyncRoot;
456 #endregion // ControlCollection Interface Properties
458 #region ControlCollection Interface Methods
459 int IList.Add(object value) {
461 throw new ArgumentNullException("value", "Cannot add null controls");
464 if (!(value is Control)) {
465 throw new ArgumentException("Object of type Control required", "value");
468 return list.Add(value);
471 bool IList.Contains(object value) {
472 if (!(value is Control)) {
473 throw new ArgumentException("Object of type Control required", "value");
476 return this.Contains((Control) value);
479 int IList.IndexOf(object value) {
480 if (!(value is Control)) {
481 throw new ArgumentException("Object of type Control required", "value");
484 return this.IndexOf((Control) value);
487 void IList.Insert(int index, object value) {
488 if (!(value is Control)) {
489 throw new ArgumentException("Object of type Control required", "value");
491 list.Insert(index, value);
494 void IList.Remove(object value) {
495 if (!(value is Control)) {
496 throw new ArgumentException("Object of type Control required", "value");
501 void ICollection.CopyTo(Array array, int index) {
503 list.CopyTo(array, index);
507 Object ICloneable.Clone() {
508 ControlCollection clone = new ControlCollection(this.owner);
509 clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
512 #endregion // ControlCollection Interface Methods
514 #endregion // ControlCollection Class
516 #region Public Constructors
518 creator_thread = Thread.CurrentThread;
520 prev_size = Size.Empty;
521 anchor_style = AnchorStyles.Top | AnchorStyles.Left;
528 layout_pending = false;
530 causes_validation = true;
532 layout_suspended = 0;
533 double_buffering = true;
537 right_to_left = RightToLeft.Inherit;
539 control_style = ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick;
542 background_image = null;
546 child_controls = CreateControlsInstance();
547 client_size = new Size(DefaultSize.Width, DefaultSize.Height);
548 client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
549 XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, false, out bounds);
550 if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
556 public Control(Control parent, string text) : this() {
561 public Control(Control parent, string text, int left, int top, int width, int height) : this() {
566 bounds.Height=height;
567 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
571 public Control(string text) : this() {
575 public Control(string text, int left, int top, int width, int height) : this() {
579 bounds.Height=height;
580 SetBoundsCore(left, top, width, height, BoundsSpecified.All);
584 protected override void Dispose(bool disposing) {
597 OnHandleDestroyed(EventArgs.Empty);
598 controls.Remove(this);
600 #endregion // Public Constructors
602 #region Internal Properties
603 #endregion // Internal Properties
605 #region Private & Internal Methods
606 internal static IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
607 AsyncMethodResult result = new AsyncMethodResult ();
608 AsyncMethodData data = new AsyncMethodData ();
610 data.Method = method;
612 data.Result = new WeakReference (result);
614 XplatUI.SendAsyncMethod (data);
618 internal Graphics DeviceContext {
621 CreateBuffers(this.Width, this.Height);
627 internal Bitmap ImageBuffer {
630 CreateBuffers(this.Width, this.Height);
636 internal void CreateBuffers (int width, int height) {
637 if (double_buffering == false)
653 bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
654 dc_mem = Graphics.FromImage (bmp_mem);
657 internal void InvalidateBuffers ()
659 if (double_buffering == false)
671 internal static void SetChildColor(Control parent) {
674 for (int i=0; i < parent.child_controls.Count; i++) {
675 child=parent.child_controls[i];
676 if (child.IsHandleCreated) {
677 XplatUI.SetWindowBackground(child.window.Handle, child.BackColor);
679 if (child.child_controls.Count>0) {
680 SetChildColor(child);
686 internal bool Select(Control control) {
688 IContainerControl container;
690 if (control == null) {
694 parent = control.parent;
696 if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
697 while (parent != null) {
698 if (!parent.is_visible || !parent.is_enabled) {
701 parent = parent.parent;
705 control.is_selected = true;
707 XplatUI.SetFocus(control.window.Handle);
708 container = GetContainerControl();
709 if (container != null) {
710 container.ActiveControl = control;
716 private Control FindTabStop(Control control, bool forward) {
717 if (control == null) {
725 internal virtual void DoDefaultAction() {
726 // Only here to be overriden by our actual controls; this is needed by the accessibility class
729 internal static int LowOrder (int param) {
730 return (param & 0xffff);
733 internal static int HighOrder (int param) {
734 return (param >> 16);
737 internal static MouseButtons FromParamToMouseButtons (int param) {
738 MouseButtons buttons = MouseButtons.None;
740 if ((param & (int) MsgButtons.MK_LBUTTON) != 0)
741 buttons |= MouseButtons.Left;
743 if ((param & (int) MsgButtons.MK_MBUTTON) != 0)
744 buttons |= MouseButtons.Middle;
746 if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
747 buttons |= MouseButtons.Right;
753 private static Control FindFlatForward(Control container, Control start) {
759 end = container.child_controls.Count;
762 index = start.tab_index;
767 for (int i = 0; i < end; i++) {
769 if (container.child_controls[i].tab_index > index) {
770 found = container.child_controls[i];
772 } else if (found.tab_index > container.child_controls[i].tab_index) {
773 if (container.child_controls[i].tab_index > index) {
774 found = container.child_controls[i];
781 private static Control FindControlForward(Control container, Control start) {
788 if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
789 found = FindControlForward(start, null);
796 while (p != container) {
797 found = FindFlatForward(p, start);
805 return FindFlatForward(container, start);
808 private static Control FindFlatBackward(Control container, Control start) {
814 end = container.child_controls.Count;
817 index = start.tab_index;
819 // FIXME: Possible speed-up: Keep the highest taborder index in the container
821 for (int i = 0; i < end; i++) {
822 if (container.child_controls[i].tab_index > index) {
823 index = container.child_controls[i].tab_index;
829 for (int i = 0; i < end; i++) {
831 if (container.child_controls[i].tab_index < index) {
832 found = container.child_controls[i];
834 } else if (found.tab_index < container.child_controls[i].tab_index) {
835 if (container.child_controls[i].tab_index < index) {
836 found = container.child_controls[i];
843 private static Control FindControlBackward(Control container, Control start) {
849 found = FindFlatBackward(start.parent, start);
850 if (found == null && start.parent != container) {
855 found = FindFlatBackward(container, start);
858 while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
859 found = FindControlBackward(found, null);
868 private void HandleClick(int clicks) {
869 if (GetStyle(ControlStyles.StandardClick)) {
871 if (GetStyle(ControlStyles.StandardDoubleClick)) {
872 OnDoubleClick(EventArgs.Empty);
874 OnClick(EventArgs.Empty);
877 OnClick(EventArgs.Empty);
881 #endregion // Private & Internal Methods
883 #region Public Static Properties
884 public static Color DefaultBackColor {
886 return ThemeEngine.Current.DefaultControlBackColor;
890 public static Font DefaultFont {
892 return ThemeEngine.Current.DefaultFont;
896 public static Color DefaultForeColor {
898 return ThemeEngine.Current.DefaultControlForeColor;
902 public static Keys ModifierKeys {
904 return XplatUI.State.ModifierKeys;
908 public static MouseButtons MouseButtons {
910 return XplatUI.State.MouseButtons;
914 public static Point MousePosition {
916 return Cursor.Position;
919 #endregion // Public Static Properties
921 #region Public Instance Properties
922 [EditorBrowsable(EditorBrowsableState.Advanced)]
924 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
925 public AccessibleObject AccessibilityObject {
927 if (accessibility_object==null) {
928 accessibility_object=CreateAccessibilityInstance();
930 return accessibility_object;
934 [EditorBrowsable(EditorBrowsableState.Advanced)]
936 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
937 public string AccessibleDefaultActionDescription {
939 return AccessibilityObject.default_action;
943 AccessibilityObject.default_action=value;
949 public string AccessibleDescription {
951 return AccessibilityObject.description;
955 AccessibilityObject.description=value;
961 public string AccessibleName {
963 return AccessibilityObject.Name;
967 AccessibilityObject.Name=value;
972 public AccessibleRole AccessibleRole {
974 return AccessibilityObject.role;
978 AccessibilityObject.role=value;
982 [DefaultValue(false)]
983 public virtual bool AllowDrop {
985 return XplatUI.State.DropTarget;
989 XplatUI.State.DropTarget=value;
994 [RefreshProperties(RefreshProperties.Repaint)]
995 [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
996 public virtual AnchorStyles Anchor {
1004 if (parent != null) {
1005 parent.PerformLayout(this, "Parent");
1011 public virtual Color BackColor {
1013 if (background_color.IsEmpty) {
1015 return parent.BackColor;
1017 return DefaultBackColor;
1019 return background_color;
1023 background_color=value;
1024 if (this.IsHandleCreated) {
1025 XplatUI.SetWindowBackground(this.window.Handle, value);
1027 SetChildColor(this);
1028 OnBackColorChanged(EventArgs.Empty);
1034 [DefaultValue(null)]
1035 public virtual Image BackgroundImage {
1037 return background_image;
1041 if (background_image!=value) {
1042 background_image=value;
1043 OnBackgroundImageChanged(EventArgs.Empty);
1048 [EditorBrowsable(EditorBrowsableState.Advanced)]
1050 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1051 public virtual BindingContext BindingContext {
1053 return binding_context;
1057 if (binding_context != value) {
1058 binding_context = value;
1059 OnBindingContextChanged(EventArgs.Empty);
1064 [EditorBrowsable(EditorBrowsableState.Advanced)]
1066 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1069 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1070 return ((Form)this).form_parent_window.Bottom;
1073 return bounds.Y+bounds.Height;
1077 [EditorBrowsable(EditorBrowsableState.Advanced)]
1079 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1080 public Rectangle Bounds {
1086 SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
1090 [EditorBrowsable(EditorBrowsableState.Advanced)]
1092 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1093 public bool CanFocus {
1095 if (is_visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
1102 [EditorBrowsable(EditorBrowsableState.Advanced)]
1104 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1105 public bool CanSelect {
1109 if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
1113 parent = this.parent;
1114 while (parent != null) {
1115 if (!parent.is_visible || !parent.is_enabled) {
1119 parent = parent.parent;
1125 [EditorBrowsable(EditorBrowsableState.Advanced)]
1127 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1128 public bool Capture {
1130 return this.is_captured;
1134 if (this.IsHandleCreated) {
1135 if (value && !is_captured) {
1137 XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
1138 } else if (!value && is_captured) {
1139 XplatUI.ReleaseWindow(this.window.Handle);
1140 is_captured = false;
1146 [DefaultValue(true)]
1147 public bool CausesValidation {
1149 return this.causes_validation;
1153 if (this.causes_validation != value) {
1154 causes_validation = value;
1155 OnCausesValidationChanged(EventArgs.Empty);
1160 [EditorBrowsable(EditorBrowsableState.Advanced)]
1162 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1163 public Rectangle ClientRectangle {
1165 client_rect.Width = client_size.Width;
1166 client_rect.Height = client_size.Height;
1171 [EditorBrowsable(EditorBrowsableState.Advanced)]
1173 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1174 public Size ClientSize {
1177 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1178 return ((Form)this).form_parent_window.ClientSize;
1186 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1187 ((Form)this).form_parent_window.ClientSize = value;
1191 this.SetClientSizeCore(value.Width, value.Height);
1195 [EditorBrowsable(EditorBrowsableState.Advanced)]
1197 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1198 [DescriptionAttribute("ControlCompanyNameDescr")]
1199 public String CompanyName {
1201 return "Mono Project, Novell, Inc.";
1205 [EditorBrowsable(EditorBrowsableState.Advanced)]
1207 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1208 public bool ContainsFocus {
1214 for (int i=0; i < child_controls.Count; i++) {
1215 if (child_controls[i].ContainsFocus) {
1223 [DefaultValue(null)]
1224 public virtual ContextMenu ContextMenu {
1226 return context_menu;
1230 if (context_menu != value) {
1231 context_menu = value;
1232 OnContextMenuChanged(EventArgs.Empty);
1238 [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
1239 public ControlCollection Controls {
1241 return this.child_controls;
1245 [EditorBrowsable(EditorBrowsableState.Advanced)]
1247 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1248 public bool Created {
1250 if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
1257 [AmbientValue(null)]
1258 public virtual Cursor Cursor {
1260 if (cursor != null) {
1264 if (parent != null) {
1265 return parent.Cursor;
1268 return Cursors.Default;
1272 if (cursor != value) {
1277 pt = Cursor.Position;
1278 if (bounds.Contains(pt)) {
1279 if (GetChildAtPoint(pt) == null) {
1280 if (cursor != null) {
1281 XplatUI.SetCursor(window.Handle, cursor.handle);
1283 if (parent != null) {
1284 XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
1286 XplatUI.SetCursor(window.Handle, Cursors.def.handle);
1292 OnCursorChanged(EventArgs.Empty);
1297 #if haveDataBindings
1298 [EditorBrowsable(EditorBrowsableState.Advanced)]
1300 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1301 public ControlBindingsCollection DataBindings {
1303 throw new NotImplementedException();
1308 [EditorBrowsable(EditorBrowsableState.Advanced)]
1310 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1311 public virtual Rectangle DisplayRectangle {
1313 return ClientRectangle;
1317 [EditorBrowsable(EditorBrowsableState.Advanced)]
1319 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1320 public bool Disposing {
1327 [RefreshProperties(RefreshProperties.Repaint)]
1328 [DefaultValue(DockStyle.None)]
1329 public virtual DockStyle Dock {
1335 if (dock_style == value) {
1341 if (parent != null) {
1342 parent.PerformLayout(this, "Parent");
1345 OnDockChanged(EventArgs.Empty);
1351 public bool Enabled {
1357 if (is_enabled == value) {
1363 OnEnabledChanged (EventArgs.Empty);
1367 [EditorBrowsable(EditorBrowsableState.Advanced)]
1369 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1370 public virtual bool Focused {
1372 return this.has_focus;
1377 [AmbientValue(null)]
1379 public virtual Font Font {
1385 if (Parent != null && Parent.Font != null) {
1393 if (font == value) {
1399 OnFontChanged (EventArgs.Empty);
1404 public virtual Color ForeColor {
1406 if (foreground_color.IsEmpty) {
1408 return parent.ForeColor;
1410 return DefaultForeColor;
1412 return foreground_color;
1416 if (foreground_color != value) {
1417 foreground_color=value;
1419 OnForeColorChanged(EventArgs.Empty);
1426 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1427 public IntPtr Handle { // IWin32Window
1429 if (!IsHandleCreated) {
1432 return window.Handle;
1436 [EditorBrowsable(EditorBrowsableState.Advanced)]
1438 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1439 public bool HasChildren {
1441 if (this.child_controls.Count>0) {
1448 [EditorBrowsable(EditorBrowsableState.Always)]
1450 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1453 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1454 return ((Form)this).form_parent_window.Height;
1456 return this.bounds.Height;
1460 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1461 ((Form)this).form_parent_window.Height = value;
1465 SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
1469 [AmbientValue(ImeMode.Inherit)]
1471 public ImeMode ImeMode {
1477 if (ime_mode != value) {
1480 OnImeModeChanged(EventArgs.Empty);
1485 [EditorBrowsable(EditorBrowsableState.Advanced)]
1487 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1488 public bool InvokeRequired { // ISynchronizeInvoke
1490 if (creator_thread!=Thread.CurrentThread) {
1497 [EditorBrowsable(EditorBrowsableState.Advanced)]
1499 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1500 public bool IsAccessible {
1502 return is_accessible;
1506 is_accessible = value;
1510 [EditorBrowsable(EditorBrowsableState.Advanced)]
1512 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1513 public bool IsDisposed {
1515 return this.is_disposed;
1519 [EditorBrowsable(EditorBrowsableState.Advanced)]
1521 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1522 public bool IsHandleCreated {
1524 if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
1532 [EditorBrowsable(EditorBrowsableState.Always)]
1534 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1537 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1538 return ((Form)this).form_parent_window.Left;
1541 return this.bounds.X;
1545 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1546 ((Form)this).form_parent_window.Left = value;
1550 SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
1555 public Point Location {
1557 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1558 return ((Form)this).form_parent_window.Location;
1560 return new Point(bounds.X, bounds.Y);
1564 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1565 ((Form)this).form_parent_window.Location = value;
1569 SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
1574 public string Name {
1585 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1586 public Control Parent {
1592 if (value == this) {
1593 throw new ArgumentException("A circular control reference has been made. A control cannot be owned or parented to itself.");
1596 if (parent!=value) {
1598 parent.Controls.Remove(this);
1603 if (!parent.Controls.Contains(this)) {
1604 parent.Controls.Add(this);
1607 XplatUI.SetParent(Handle, value.Handle);
1611 OnParentChanged(EventArgs.Empty);
1616 [EditorBrowsable(EditorBrowsableState.Advanced)]
1618 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1619 public string ProductName {
1621 return "Novell Mono MWF";
1625 [EditorBrowsable(EditorBrowsableState.Advanced)]
1627 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1628 public string ProductVersion {
1630 return "1.1.4322.573";
1634 [EditorBrowsable(EditorBrowsableState.Advanced)]
1636 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1637 public bool RecreatingHandle {
1639 return is_recreating;
1643 [EditorBrowsable(EditorBrowsableState.Advanced)]
1645 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1646 public Region Region {
1648 return new Region(this.bounds);
1655 g = this.CreateGraphics();
1656 r = value.GetBounds(g);
1658 SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
1664 [EditorBrowsable(EditorBrowsableState.Advanced)]
1666 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1669 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1670 return ((Form)this).form_parent_window.Right;
1673 return this.bounds.X+this.bounds.Width;
1677 [AmbientValue(RightToLeft.Inherit)]
1679 public virtual RightToLeft RightToLeft {
1681 return right_to_left;
1685 if (value != right_to_left) {
1686 right_to_left = value;
1687 OnRightToLeftChanged(EventArgs.Empty);
1692 [EditorBrowsable(EditorBrowsableState.Advanced)]
1693 public override ISite Site {
1706 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1707 return ((Form)this).form_parent_window.Size;
1709 return new Size(Width, Height);
1713 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1714 ((Form)this).form_parent_window.Size = value;
1717 SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
1722 [MergableProperty(false)]
1723 public int TabIndex {
1725 if (tab_index != -1) {
1732 if (tab_index != value) {
1734 OnTabIndexChanged(EventArgs.Empty);
1740 [DefaultValue(true)]
1741 public bool TabStop {
1747 if (tab_stop != value) {
1749 OnTabStopChanged(EventArgs.Empty);
1754 [Localizable(false)]
1756 [TypeConverter(typeof(StringConverter))]
1757 [DefaultValue(null)]
1764 control_tag = value;
1770 [BindableAttribute(true)]
1771 public virtual string Text {
1777 if (value == null) {
1778 value = String.Empty;
1783 XplatUI.Text(Handle, text);
1784 // FIXME: Do we need a Refresh() here?
1785 OnTextChanged (EventArgs.Empty);
1790 [EditorBrowsable(EditorBrowsableState.Advanced)]
1792 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1795 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1796 return ((Form)this).form_parent_window.Top;
1798 return this.bounds.Y;
1802 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1803 ((Form)this).form_parent_window.Top = value;
1807 SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
1811 [EditorBrowsable(EditorBrowsableState.Advanced)]
1813 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1814 public Control TopLevelControl {
1818 while (p.parent != null) {
1827 public bool Visible {
1829 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1830 return ((Form)this).form_parent_window.Visible;
1840 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1841 ((Form)this).form_parent_window.Visible = value;
1845 SetVisibleCore(value);
1849 [EditorBrowsable(EditorBrowsableState.Always)]
1851 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1854 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1855 return ((Form)this).form_parent_window.Width;
1857 return this.bounds.Width;
1861 if ((this is Form) && (((Form)this).form_parent_window != null)) {
1862 ((Form)this).form_parent_window.Width = value;
1866 SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
1870 [EditorBrowsable(EditorBrowsableState.Never)]
1872 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1873 public IWindowTarget WindowTarget {
1882 #endregion // Public Instance Properties
1884 #region Protected Instance Properties
1885 protected virtual CreateParams CreateParams {
1887 CreateParams create_params = new CreateParams();
1889 create_params.Caption = Text;
1890 create_params.X = Left;
1891 create_params.Y = Top;
1892 create_params.Width = Width;
1893 create_params.Height = Height;
1895 create_params.ClassName = XplatUI.DefaultClassName;
1896 create_params.ClassStyle = 0;
1897 create_params.ExStyle = 0;
1898 create_params.Param = 0;
1901 create_params.Parent = parent.Handle;
1904 create_params.Style = (int)WindowStyles.WS_CHILD | (int)WindowStyles.WS_CLIPCHILDREN | (int)WindowStyles.WS_CLIPSIBLINGS;
1907 create_params.Style |= (int)WindowStyles.WS_VISIBLE;
1910 return create_params;
1914 protected virtual ImeMode DefaultImeMode {
1916 return ImeMode.Inherit;
1920 protected virtual Size DefaultSize {
1922 return new Size(100, 23);
1926 protected int FontHeight {
1936 protected bool RenderRightToLeft {
1938 return (this.right_to_left == RightToLeft.Yes);
1942 protected bool ResizeRedraw {
1944 return GetStyle(ControlStyles.ResizeRedraw);
1948 SetStyle(ControlStyles.ResizeRedraw, value);
1952 [EditorBrowsable(EditorBrowsableState.Advanced)]
1954 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1955 protected virtual bool ShowFocusCues {
1961 [EditorBrowsable(EditorBrowsableState.Advanced)]
1963 [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
1964 protected bool ShowKeyboardCues {
1969 #endregion // Protected Instance Properties
1971 #region Public Static Methods
1972 [EditorBrowsable(EditorBrowsableState.Advanced)]
1973 public static Control FromChildHandle(IntPtr handle) {
1974 IEnumerator control = Control.controls.GetEnumerator();
1976 while (control.MoveNext()) {
1977 if (((Control)control.Current).window.Handle == handle) {
1979 if (((Control)control.Current).Parent != null) {
1980 return ((Control)control.Current).Parent;
1987 [EditorBrowsable(EditorBrowsableState.Advanced)]
1988 public static Control FromHandle(IntPtr handle) {
1989 IEnumerator control = Control.controls.GetEnumerator();
1991 while (control.MoveNext()) {
1992 if (((Control)control.Current).window.Handle == handle) {
1994 return ((Control)control.Current);
2000 public static bool IsMnemonic(char charCode, string text) {
2003 amp = text.IndexOf('&');
2006 if (amp + 1 < text.Length) {
2007 if (text[amp + 1] != '&') {
2008 if (Char.ToUpper(charCode) == Char.ToUpper(text.ToCharArray(amp + 1, 1)[0])) {
2018 #region Protected Static Methods
2019 [EditorBrowsable(EditorBrowsableState.Advanced)]
2020 protected static bool ReflectMessage(IntPtr hWnd, ref Message m) {
2023 c = Control.FromHandle(hWnd);
2033 #region Public Instance Methods
2034 [EditorBrowsable(EditorBrowsableState.Advanced)]
2035 public IAsyncResult BeginInvoke(Delegate method) {
2036 return BeginInvokeInternal(method, null);
2039 [EditorBrowsable(EditorBrowsableState.Advanced)]
2040 public IAsyncResult BeginInvoke (Delegate method, object[] args) {
2041 return BeginInvokeInternal (method, args);
2044 public void BringToFront() {
2045 if ((parent != null) && (parent.child_controls[0]!=this)) {
2046 if (parent.child_controls.Contains(this)) {
2047 parent.child_controls.SetChildIndex(this, 0);
2051 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
2053 if (parent != null) {
2058 public bool Contains(Control ctl) {
2059 while (ctl != null) {
2068 public void CreateControl() {
2070 if (!IsHandleCreated)
2073 for (int i=0; i<child_controls.Count; i++) {
2074 child_controls[i].CreateControl();
2079 public Graphics CreateGraphics() {
2080 if (!IsHandleCreated) {
2081 this.CreateHandle();
2083 return Graphics.FromHwnd(this.window.Handle);
2086 [MonoTODO("Come up with cross platform drag-drop driver interface")]
2087 public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
2088 return DragDropEffects.None;
2091 [EditorBrowsable(EditorBrowsableState.Advanced)]
2092 public object EndInvoke (IAsyncResult async_result) {
2093 AsyncMethodResult result = (AsyncMethodResult) async_result;
2094 return result.EndInvoke ();
2097 public Form FindForm() {
2110 public bool Focus() {
2111 if (IsHandleCreated && !has_focus) {
2112 XplatUI.SetFocus(window.Handle);
2118 public Control GetChildAtPoint(Point pt) {
2119 // Microsoft's version of this function doesn't seem to work, so I can't check
2120 // if we only consider children or also grandchildren, etc.
2121 // I'm gonna say 'children only'
2122 for (int i=0; i<child_controls.Count; i++) {
2123 if (child_controls[i].Bounds.Contains(pt)) {
2124 return child_controls[i];
2130 public IContainerControl GetContainerControl() {
2131 Control current = this;
2133 while (current!=null) {
2134 if ((current is IContainerControl) && ((current.control_style & ControlStyles.ContainerControl)!=0)) {
2135 return (IContainerControl)current;
2137 current = current.parent;
2142 public Control GetNextControl(Control ctl, bool forward) {
2143 // If we're not a container we don't play
2144 if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
2148 // If ctl is not contained by this, we start at the first child of this
2149 if (!this.Contains(ctl)) {
2153 // Search through our controls, starting at ctl, stepping into children as we encounter them
2154 // try to find the control with the tabindex closest to our own, or, if we're looking into
2155 // child controls, the one with the smallest tabindex
2157 return FindControlForward(this, ctl);
2159 return FindControlBackward(this, ctl);
2162 public void Hide() {
2163 this.Visible = false;
2166 public void Invalidate() {
2167 Invalidate(ClientRectangle, false);
2170 public void Invalidate(bool invalidateChildren) {
2171 Invalidate(ClientRectangle, invalidateChildren);
2174 public void Invalidate(System.Drawing.Rectangle rc) {
2175 Invalidate(rc, false);
2178 public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
2179 if (!IsHandleCreated || !Visible) {
2183 NotifyInvalidate(rc);
2185 XplatUI.Invalidate(Handle, rc, !GetStyle (ControlStyles.AllPaintingInWmPaint));
2187 if (invalidateChildren) {
2188 for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2190 OnInvalidated(new InvalidateEventArgs(rc));
2193 public void Invalidate(System.Drawing.Region region) {
2194 Invalidate(region, false);
2197 [MonoTODO("Figure out if GetRegionScans is usable")]
2198 public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
2199 throw new NotImplementedException();
2201 // FIXME - should use the GetRegionScans function of the region to invalidate each area
2202 //if (invalidateChildren) {
2203 // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
2207 public object Invoke (Delegate method) {
2208 return Invoke(method, null);
2211 public object Invoke (Delegate method, object[] args) {
2212 IAsyncResult result = BeginInvoke (method, args);
2213 return EndInvoke(result);
2216 [EditorBrowsable(EditorBrowsableState.Advanced)]
2217 public void PerformLayout() {
2218 PerformLayout(null, null);
2221 [EditorBrowsable(EditorBrowsableState.Advanced)]
2222 public void PerformLayout(Control affectedControl, string affectedProperty) {
2223 LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
2225 if (layout_suspended>0) {
2226 layout_pending = true;
2230 layout_pending = false;
2232 // Prevent us from getting messed up
2235 // Perform all Dock and Anchor calculations
2238 AnchorStyles anchor;
2243 space=this.DisplayRectangle;
2244 if (prev_size != Size.Empty) {
2245 diff_width = space.Width - prev_size.Width;
2246 diff_height = space.Height - prev_size.Height;
2252 // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
2253 for (int i = child_controls.Count - 1; i >= 0; i--) {
2254 child=child_controls[i];
2255 switch (child.Dock) {
2256 case DockStyle.None: {
2261 case DockStyle.Left: {
2262 child.SetBounds(space.Left, space.Y, child.Width, space.Height);
2263 space.X+=child.Width;
2264 space.Width-=child.Width;
2268 case DockStyle.Top: {
2269 child.SetBounds(space.Left, space.Y, space.Width, child.Height);
2270 space.Y+=child.Height;
2271 space.Height-=child.Height;
2275 case DockStyle.Right: {
2276 child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
2277 space.Width-=child.Width;
2281 case DockStyle.Bottom: {
2282 child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
2283 space.Height-=child.Height;
2287 case DockStyle.Fill: {
2288 child.SetBounds(space.Left, space.Top, space.Width, space.Height);
2296 space=this.DisplayRectangle;
2298 // Deal with anchoring
2299 for (int i=0; i < child_controls.Count; i++) {
2305 child=child_controls[i];
2306 anchor=child.Anchor;
2311 height=child.Height;
2313 // If the control is docked we don't need to do anything
2314 if (child.Dock != DockStyle.None) {
2318 if ((anchor & AnchorStyles.Left) !=0 ) {
2319 if ((anchor & AnchorStyles.Right) != 0) {
2320 // Anchoring to left and right
2321 width=width+diff_width;
2325 } else if ((anchor & AnchorStyles.Right) != 0) {
2331 if ((anchor & AnchorStyles.Top) !=0 ) {
2332 if ((anchor & AnchorStyles.Bottom) != 0) {
2333 height+=diff_height;
2337 } else if ((anchor & AnchorStyles.Bottom) != 0) {
2352 child.SetBounds(left, top, width, height);
2355 // Let everyone know
2359 // Need to make sure we decremend layout_suspended
2365 public Point PointToClient (Point p) {
2369 XplatUI.ScreenToClient (Handle, ref x, ref y);
2371 return new Point (x, y);
2374 public Point PointToScreen(Point p) {
2378 XplatUI.ClientToScreen(Handle, ref x, ref y);
2380 return new Point(x, y);
2383 public virtual bool PreProcessMessage(ref Message msg) {
2386 if (msg.Msg == (int)Msg.WM_KEYDOWN) {
2387 key_data = (Keys)msg.WParam.ToInt32();
2388 if (!ProcessCmdKey(ref msg, key_data)) {
2389 if (IsInputKey(key_data)) {
2393 return ProcessDialogKey(key_data);
2397 } else if (msg.Msg == (int)Msg.WM_CHAR) {
2398 if (IsInputChar((char)msg.WParam)) {
2402 return ProcessDialogChar((char)msg.WParam);
2408 public Rectangle RectangleToClient(Rectangle r) {
2409 return new Rectangle(PointToClient(r.Location), r.Size);
2412 public Rectangle RectangleToScreen(Rectangle r) {
2413 return new Rectangle(PointToScreen(r.Location), r.Size);
2416 public virtual void Refresh() {
2417 if (IsHandleCreated == true) {
2419 XplatUI.UpdateWindow(window.Handle);
2423 [EditorBrowsable(EditorBrowsableState.Never)]
2424 public virtual void ResetBackColor() {
2425 background_color = Color.Empty;
2428 #if haveDataBindings
2429 [EditorBrowsable(EditorBrowsableState.Never)]
2431 public void ResetBindings() {
2436 [EditorBrowsable(EditorBrowsableState.Never)]
2437 public virtual void ResetCursor() {
2441 [EditorBrowsable(EditorBrowsableState.Never)]
2442 public virtual void ResetFont() {
2446 [EditorBrowsable(EditorBrowsableState.Never)]
2447 public virtual void ResetForeColor() {
2448 foreground_color = Color.Empty;
2451 [EditorBrowsable(EditorBrowsableState.Never)]
2452 public void ResetImeMode() {
2453 ime_mode = DefaultImeMode;
2456 [EditorBrowsable(EditorBrowsableState.Never)]
2457 public virtual void ResetRightToLeft() {
2458 right_to_left = RightToLeft.Inherit;
2461 public virtual void ResetText() {
2465 public void ResumeLayout() {
2466 ResumeLayout (true);
2469 public void ResumeLayout(bool performLayout) {
2472 if (layout_suspended > 0) {
2476 if (performLayout || layout_pending) {
2481 public void Scale(float ratio) {
2482 ScaleCore(ratio, ratio);
2485 public void Scale(float dx, float dy) {
2489 public void Select() {
2490 Select(false, false);
2493 public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
2498 c = GetNextControl(c, forward);
2507 if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
2511 } while (c != ctl); // If we wrap back to ourselves we stop
2516 public void SendToBack() {
2517 if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
2518 if (parent.child_controls.Contains(this)) {
2519 parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
2523 XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
2524 if (parent != null) {
2529 public void SetBounds(int x, int y, int width, int height) {
2530 SetBoundsCore(x, y, width, height, BoundsSpecified.All);
2533 public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
2534 SetBoundsCore(x, y, width, height, specified);
2537 public void Show() {
2538 if (!IsHandleCreated) {
2539 this.CreateHandle();
2545 public void SuspendLayout() {
2549 public void Update() {
2550 XplatUI.UpdateWindow(window.Handle);
2552 #endregion // Public Instance Methods
2554 #region Protected Instance Methods
2555 [EditorBrowsable(EditorBrowsableState.Advanced)]
2556 [MonoTODO("Implement this and tie it into Control.ControlAccessibleObject.NotifyClients")]
2557 protected void AccessibilityNotifyClients(AccessibleEvents accEvent, int childID) {
2558 throw new NotImplementedException();
2561 [EditorBrowsable(EditorBrowsableState.Advanced)]
2562 protected virtual AccessibleObject CreateAccessibilityInstance() {
2563 return new Control.ControlAccessibleObject(this);
2566 [EditorBrowsable(EditorBrowsableState.Advanced)]
2567 protected virtual ControlCollection CreateControlsInstance() {
2568 return new ControlCollection(this);
2571 [EditorBrowsable(EditorBrowsableState.Advanced)]
2572 protected virtual void CreateHandle() {
2574 throw new ObjectDisposedException(Name);
2577 if (IsHandleCreated) {
2582 window = new ControlNativeWindow(this);
2583 window.CreateHandle(CreateParams);
2587 if (window.Handle!=IntPtr.Zero) {
2588 if (!controls.Contains(window.Handle)) {
2592 creator_thread = Thread.CurrentThread;
2594 XplatUI.SetWindowBackground(window.Handle, this.BackColor);
2596 OnHandleCreated(EventArgs.Empty);
2600 [EditorBrowsable(EditorBrowsableState.Advanced)]
2601 protected virtual void DefWndProc(ref Message m) {
2602 window.DefWndProc(ref m);
2605 [EditorBrowsable(EditorBrowsableState.Advanced)]
2606 protected virtual void DestroyHandle() {
2607 if (IsHandleCreated) {
2608 if (Handle != IntPtr.Zero) {
2609 controls.Remove(Handle);
2612 if (window != null) {
2613 window.DestroyHandle();
2618 protected bool GetStyle(ControlStyles flag) {
2619 return (control_style & flag) != 0;
2622 protected bool GetTopLevel() {
2626 [EditorBrowsable(EditorBrowsableState.Advanced)]
2627 protected virtual void InitLayout() {
2628 if (parent != null) {
2629 parent.PerformLayout(this, "parent");
2633 [EditorBrowsable(EditorBrowsableState.Advanced)]
2634 protected void InvokeGotFocus(Control toInvoke, EventArgs e) {
2635 toInvoke.OnGotFocus(e);
2638 [EditorBrowsable(EditorBrowsableState.Advanced)]
2639 protected void InvokeLostFocus(Control toInvoke, EventArgs e) {
2640 toInvoke.OnLostFocus(e);
2643 [EditorBrowsable(EditorBrowsableState.Advanced)]
2644 protected void InvokeOnClick(Control toInvoke, EventArgs e) {
2645 toInvoke.OnClick(e);
2648 protected void InvokePaint(Control toInvoke, PaintEventArgs e) {
2649 toInvoke.OnPaint(e);
2652 protected void InvokePaintBackground(Control toInvoke, PaintEventArgs e) {
2653 toInvoke.OnPaintBackground(e);
2656 protected virtual bool IsInputChar (char charCode) {
2657 if (parent != null) {
2658 return parent.IsInputChar(charCode);
2664 protected virtual bool IsInputKey (Keys keyData) {
2665 // Doc says this one calls IsInputChar; not sure what to do with that
2669 [EditorBrowsable(EditorBrowsableState.Advanced)]
2670 protected virtual void NotifyInvalidate(Rectangle invalidatedArea) {
2674 protected virtual bool ProcessCmdKey(ref Message msg, Keys keyData) {
2675 if ((context_menu != null) && context_menu.ProcessCmdKey(ref msg, keyData)) {
2679 if (parent != null) {
2680 return parent.ProcessCmdKey(ref msg, keyData);
2686 protected virtual bool ProcessDialogChar(char charCode) {
2687 if (parent != null) {
2688 return parent.ProcessDialogChar (charCode);
2694 protected virtual bool ProcessDialogKey (Keys keyData) {
2695 if (parent != null) {
2696 return parent.ProcessDialogKey (keyData);
2702 protected virtual bool ProcessKeyEventArgs (ref Message msg)
2704 KeyEventArgs key_event;
2706 PreProcessMessage(ref msg);
2709 case (int)Msg.WM_KEYDOWN: {
2710 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2711 OnKeyDown (key_event);
2712 return key_event.Handled;
2714 case (int)Msg.WM_KEYUP: {
2715 key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
2716 OnKeyUp (key_event);
2717 return key_event.Handled;
2720 case (int)Msg.WM_CHAR: {
2721 KeyPressEventArgs key_press_event;
2723 key_press_event = new KeyPressEventArgs((char)msg.WParam);
2724 OnKeyPress(key_press_event);
2725 return key_press_event.Handled;
2736 protected internal virtual bool ProcessKeyMessage(ref Message msg) {
2737 if (parent != null) {
2738 if (parent.ProcessKeyPreview(ref msg)) {
2743 return ProcessKeyEventArgs(ref msg);
2746 protected virtual bool ProcessKeyPreview(ref Message msg) {
2747 if (parent != null) {
2748 return parent.ProcessKeyPreview(ref msg);
2754 protected virtual bool ProcessMnemonic(char charCode) {
2759 [EditorBrowsable(EditorBrowsableState.Advanced)]
2760 protected void RaiseDragEvent(object key, DragEventArgs e) {
2764 [EditorBrowsable(EditorBrowsableState.Advanced)]
2765 protected void RaiseKeyEvent(object key, KeyEventArgs e) {
2769 [EditorBrowsable(EditorBrowsableState.Advanced)]
2770 protected void RaiseMouseEvent(object key, MouseEventArgs e) {
2774 [EditorBrowsable(EditorBrowsableState.Advanced)]
2775 protected void RaisePaintEvent(object key, PaintEventArgs e) {
2779 [EditorBrowsable(EditorBrowsableState.Advanced)]
2780 protected void RecreateHandle() {
2781 IEnumerator child = child_controls.GetEnumerator();
2785 if (IsHandleCreated) {
2791 while (child.MoveNext()) {
2792 ((Control)child.Current).RecreateHandle();
2798 is_recreating = false;
2801 [EditorBrowsable(EditorBrowsableState.Advanced)]
2802 protected void ResetMouseEventArgs() {
2806 [EditorBrowsable(EditorBrowsableState.Advanced)]
2807 protected ContentAlignment RtlTranslateAlignment(ContentAlignment align) {
2808 if (right_to_left == RightToLeft.No) {
2813 case ContentAlignment.TopLeft: {
2814 return ContentAlignment.TopRight;
2817 case ContentAlignment.TopRight: {
2818 return ContentAlignment.TopLeft;
2821 case ContentAlignment.MiddleLeft: {
2822 return ContentAlignment.MiddleRight;
2825 case ContentAlignment.MiddleRight: {
2826 return ContentAlignment.MiddleLeft;
2829 case ContentAlignment.BottomLeft: {
2830 return ContentAlignment.BottomRight;
2833 case ContentAlignment.BottomRight: {
2834 return ContentAlignment.BottomLeft;
2838 // if it's center it doesn't change
2844 [EditorBrowsable(EditorBrowsableState.Advanced)]
2845 protected HorizontalAlignment RtlTranslateAlignment(HorizontalAlignment align) {
2846 if ((right_to_left == RightToLeft.No) || (align == HorizontalAlignment.Center)) {
2850 if (align == HorizontalAlignment.Left) {
2851 return HorizontalAlignment.Right;
2854 // align must be HorizontalAlignment.Right
2855 return HorizontalAlignment.Left;
2858 [EditorBrowsable(EditorBrowsableState.Advanced)]
2859 protected LeftRightAlignment RtlTranslateAlignment(LeftRightAlignment align) {
2860 if (right_to_left == RightToLeft.No) {
2864 if (align == LeftRightAlignment.Left) {
2865 return LeftRightAlignment.Right;
2868 // align must be LeftRightAlignment.Right;
2869 return LeftRightAlignment.Left;
2872 [EditorBrowsable(EditorBrowsableState.Advanced)]
2873 protected ContentAlignment RtlTranslateContent(ContentAlignment align) {
2874 return RtlTranslateAlignment(align);
2877 [EditorBrowsable(EditorBrowsableState.Advanced)]
2878 protected HorizontalAlignment RtlTranslateHorizontal(HorizontalAlignment align) {
2879 return RtlTranslateAlignment(align);
2882 [EditorBrowsable(EditorBrowsableState.Advanced)]
2883 protected LeftRightAlignment RtlTranslateLeftRight(LeftRightAlignment align) {
2884 return RtlTranslateAlignment(align);
2887 [EditorBrowsable(EditorBrowsableState.Advanced)]
2888 protected virtual void ScaleCore(float dx, float dy) {
2894 location = new Point((int)(Left * dx), (int)(Top * dy));
2895 size = this.ClientSize;
2898 if (!GetStyle(ControlStyles.FixedWidth)) {
2899 size.Width = (int)(size.Width * dx);
2902 if (!GetStyle(ControlStyles.FixedHeight)) {
2903 size.Height = (int)(size.Height * dy);
2906 Location = location;
2909 /* Now scale our children */
2910 for (int i=0; i < child_controls.Count; i++) {
2911 child_controls[i].Scale(dx, dy);
2917 protected virtual void Select(bool directed, bool forward) {
2922 // Select this control
2927 if (parent == null) {
2931 index = parent.child_controls.IndexOf(this);
2936 if ((index+1) < parent.child_controls.Count) {
2945 index = parent.child_controls.Count-1;
2948 result = Select(parent.child_controls[index]);
2949 } while (!result && parent.child_controls[index] != this);
2952 [EditorBrowsable(EditorBrowsableState.Advanced)]
2953 protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
2954 // SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
2955 if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
2959 if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
2963 if ((specified & BoundsSpecified.Width)!= BoundsSpecified.Width) {
2967 if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
2971 if (IsHandleCreated) {
2972 XplatUI.SetWindowPos(Handle, x, y, width, height);
2974 UpdateBounds(x, y, width, height);
2977 [EditorBrowsable(EditorBrowsableState.Advanced)]
2978 protected virtual void SetClientSizeCore(int x, int y) {
2979 // Calculate the actual window size from the client size (it usually stays the same or grows)
2980 Rectangle ClientRect;
2981 Rectangle WindowRect;
2984 ClientRect = new Rectangle(0, 0, x, y);
2985 cp = this.CreateParams;
2987 if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, false, out WindowRect)==false) {
2991 SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
2994 [EditorBrowsable(EditorBrowsableState.Advanced)]
2995 protected void SetStyle(ControlStyles flag, bool value) {
2997 control_style |= flag;
2999 control_style &= ~flag;
3003 protected void SetTopLevel(bool value) {
3004 if ((GetTopLevel() != value) && (parent != null)) {
3005 throw new Exception();
3009 if (value == true) {
3019 is_toplevel = value;
3022 protected virtual void SetVisibleCore(bool value) {
3023 if (value!=is_visible) {
3025 XplatUI.SetVisible(Handle, value);
3026 OnVisibleChanged(EventArgs.Empty);
3028 if (dc_mem != null) {
3033 if (bmp_mem != null) {
3038 this.CreateBuffers(bounds.Width, bounds.Height);
3041 // FIXME - deal with focus
3043 if (parent != null) {
3044 parent.PerformLayout(this, "visible");
3046 PerformLayout(this, "visible");
3051 [EditorBrowsable(EditorBrowsableState.Advanced)]
3052 protected void UpdateBounds() {
3060 if (!IsHandleCreated) {
3064 XplatUI.GetWindowPos(this.Handle, out x, out y, out width, out height, out client_width, out client_height);
3065 UpdateBounds(x, y, width, height, client_width, client_height);
3068 [EditorBrowsable(EditorBrowsableState.Advanced)]
3069 protected void UpdateBounds(int x, int y, int width, int height) {
3070 // UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
3072 bool resized = false;
3074 int client_x_diff = this.bounds.Width-this.client_size.Width;
3075 int client_y_diff = this.bounds.Height-this.client_size.Height;
3077 // Needed to generate required notifications
3078 if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
3082 if ((this.Bounds.Width!=width) || (this.Bounds.Height!=height)) {
3089 bounds.Height=height;
3091 // Update client rectangle as well
3092 if (this.layout_suspended==0) {
3093 prev_size.Width=client_size.Width;
3094 prev_size.Height=client_size.Height;
3097 client_size.Width=width-client_x_diff;
3098 client_size.Height=height-client_y_diff;
3101 OnLocationChanged(EventArgs.Empty);
3105 OnSizeChanged(EventArgs.Empty);
3109 [EditorBrowsable(EditorBrowsableState.Advanced)]
3110 protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
3111 UpdateBounds(x, y, width, height);
3113 this.client_size.Width=clientWidth;
3114 this.client_size.Height=clientHeight;
3117 [EditorBrowsable(EditorBrowsableState.Advanced)]
3118 protected void UpdateStyles() {
3119 if (!IsHandleCreated) {
3123 if ( !(this is Form) && !(this is Form.FormParentWindow)) {
3124 XplatUI.SetWindowStyle(window.Handle, CreateParams);
3127 XplatUI.SetWindowStyle(((Form)this).form_parent_window.window.Handle, ((Form)this).CreateFormParams);
3129 XplatUI.SetWindowStyle(((Form.FormParentWindow)this).window.Handle, ((Form.FormParentWindow)this).owner.CreateFormParams);
3134 protected void UpdateZOrder() {
3139 if (parent == null) {
3145 children = ctl.child_controls.Count;
3146 for (int i = 1; i < children; i++ ) {
3147 XplatUI.SetZOrder(ctl.child_controls[i].window.Handle, ctl.child_controls[i-1].window.Handle, false, false);
3150 children = child_controls.Count;
3151 for (int i = 1; i < children; i++ ) {
3152 XplatUI.SetZOrder(child_controls[i].window.Handle, child_controls[i-1].window.Handle, false, false);
3157 protected virtual void WndProc(ref Message m) {
3159 Console.WriteLine("Received message {0}", m);
3161 if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
3165 switch((Msg)m.Msg) {
3166 case Msg.WM_WINDOWPOSCHANGED: {
3169 if (GetStyle(ControlStyles.ResizeRedraw)) {
3176 case Msg.WM_PAINT: {
3177 PaintEventArgs paint_event;
3179 paint_event = XplatUI.PaintEventStart(Handle);
3180 OnPaint(paint_event);
3181 XplatUI.PaintEventEnd(Handle);
3186 case Msg.WM_ERASEBKGND: {
3187 if (GetStyle (ControlStyles.UserPaint)) {
3188 if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
3189 PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
3190 Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
3191 OnPaintBackground (eraseEventArgs);
3193 m.Result = (IntPtr)1;
3195 m.Result = IntPtr.Zero;
3202 case Msg.WM_LBUTTONUP: {
3203 HandleClick(mouse_clicks);
3204 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
3206 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3208 if (mouse_clicks > 1) {
3214 case Msg.WM_LBUTTONDOWN: {
3215 if (CanSelect && !is_selected) {
3218 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3219 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3225 case Msg.WM_LBUTTONDBLCLK: {
3227 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3228 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3234 case Msg.WM_MBUTTONUP: {
3235 HandleClick(mouse_clicks);
3236 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
3238 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3240 if (mouse_clicks > 1) {
3246 case Msg.WM_MBUTTONDOWN: {
3247 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3248 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3254 case Msg.WM_MBUTTONDBLCLK: {
3256 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3257 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3262 case Msg.WM_RBUTTONUP: {
3263 HandleClick(mouse_clicks);
3264 OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
3266 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3268 if (mouse_clicks > 1) {
3274 case Msg.WM_RBUTTONDOWN: {
3275 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3276 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3281 case Msg.WM_RBUTTONDBLCLK: {
3283 OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3284 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3289 case Msg.WM_MOUSEWHEEL: {
3291 OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3292 mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3293 HighOrder(m.WParam.ToInt32())));
3298 case Msg.WM_MOUSEMOVE: {
3299 OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
3301 LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
3306 case Msg.WM_MOUSE_ENTER: {
3311 OnMouseEnter(EventArgs.Empty);
3315 case Msg.WM_MOUSE_LEAVE: {
3317 OnMouseLeave(EventArgs.Empty);
3321 case Msg.WM_MOUSEHOVER: {
3322 OnMouseHover(EventArgs.Empty);
3326 case Msg.WM_KEYDOWN: {
3327 if (!ProcessKeyMessage(ref m)) {
3333 case Msg.WM_KEYUP: {
3334 if (!ProcessKeyMessage(ref m)) {
3341 if (!ProcessKeyMessage(ref m)) {
3349 if (m.LParam != IntPtr.Zero) {
3352 hi = new HELPINFO();
3354 hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
3355 mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
3357 mouse_pos = Control.MousePosition;
3359 OnHelpRequested(new HelpEventArgs(mouse_pos));
3360 m.Result = (IntPtr)1;
3364 case Msg.WM_KILLFOCUS: {
3365 OnLeave(EventArgs.Empty);
3366 if (CausesValidation) {
3368 e = new CancelEventArgs(false);
3377 OnValidated(EventArgs.Empty);
3380 this.has_focus = false;
3381 this.is_selected = false;
3382 OnLostFocus(EventArgs.Empty);
3386 case Msg.WM_SETFOCUS: {
3387 OnEnter(EventArgs.Empty);
3388 this.has_focus = true;
3389 OnGotFocus(EventArgs.Empty);
3394 case Msg.WM_SYSCOLORCHANGE: {
3395 ThemeEngine.Current.ResetDefaults();
3396 OnSystemColorsChanged(EventArgs.Empty);
3401 case Msg.WM_SETCURSOR: {
3402 if (cursor == null) {
3407 XplatUI.SetCursor(window.Handle, cursor.handle);
3408 m.Result = (IntPtr)1;
3417 #endregion // Public Instance Methods
3419 #region OnXXX methods
3420 [EditorBrowsable(EditorBrowsableState.Advanced)]
3421 protected virtual void OnBackColorChanged(EventArgs e) {
3422 if (BackColorChanged!=null) BackColorChanged(this, e);
3423 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
3426 [EditorBrowsable(EditorBrowsableState.Advanced)]
3427 protected virtual void OnBackgroundImageChanged(EventArgs e) {
3428 if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
3429 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
3432 [EditorBrowsable(EditorBrowsableState.Advanced)]
3433 protected virtual void OnBindingContextChanged(EventArgs e) {
3434 if (BindingContextChanged!=null) BindingContextChanged(this, e);
3435 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
3438 [EditorBrowsable(EditorBrowsableState.Advanced)]
3439 protected virtual void OnCausesValidationChanged(EventArgs e) {
3440 if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
3443 [EditorBrowsable(EditorBrowsableState.Advanced)]
3444 protected virtual void OnChangeUICues(UICuesEventArgs e) {
3445 if (ChangeUICues!=null) ChangeUICues(this, e);
3448 [EditorBrowsable(EditorBrowsableState.Advanced)]
3449 protected virtual void OnClick(EventArgs e) {
3450 if (Click!=null) Click(this, e);
3453 [EditorBrowsable(EditorBrowsableState.Advanced)]
3454 protected virtual void OnContextMenuChanged(EventArgs e) {
3455 if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
3458 [EditorBrowsable(EditorBrowsableState.Advanced)]
3459 protected virtual void OnControlAdded(ControlEventArgs e) {
3460 if (ControlAdded!=null) ControlAdded(this, e);
3463 [EditorBrowsable(EditorBrowsableState.Advanced)]
3464 protected virtual void OnControlRemoved(ControlEventArgs e) {
3465 if (ControlRemoved!=null) ControlRemoved(this, e);
3468 [EditorBrowsable(EditorBrowsableState.Advanced)]
3469 protected virtual void OnCreateControl() {
3473 [EditorBrowsable(EditorBrowsableState.Advanced)]
3474 protected virtual void OnCursorChanged(EventArgs e) {
3475 if (CursorChanged!=null) CursorChanged(this, e);
3478 [EditorBrowsable(EditorBrowsableState.Advanced)]
3479 protected virtual void OnDockChanged(EventArgs e) {
3480 if (DockChanged!=null) DockChanged(this, e);
3483 [EditorBrowsable(EditorBrowsableState.Advanced)]
3484 protected virtual void OnDoubleClick(EventArgs e) {
3485 if (DoubleClick!=null) DoubleClick(this, e);
3488 [EditorBrowsable(EditorBrowsableState.Advanced)]
3489 protected virtual void OnDragDrop(DragEventArgs drgevent) {
3490 if (DragDrop!=null) DragDrop(this, drgevent);
3493 [EditorBrowsable(EditorBrowsableState.Advanced)]
3494 protected virtual void OnDragEnter(DragEventArgs drgevent) {
3495 if (DragEnter!=null) DragEnter(this, drgevent);
3498 [EditorBrowsable(EditorBrowsableState.Advanced)]
3499 protected virtual void OnDragLeave(EventArgs e) {
3500 if (DragLeave!=null) DragLeave(this, e);
3503 [EditorBrowsable(EditorBrowsableState.Advanced)]
3504 protected virtual void OnDragOver(DragEventArgs drgevent) {
3505 if (DragOver!=null) DragOver(this, drgevent);
3508 [EditorBrowsable(EditorBrowsableState.Advanced)]
3509 protected virtual void OnEnabledChanged(EventArgs e) {
3510 if (EnabledChanged!=null) EnabledChanged(this, e);
3511 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
3514 [EditorBrowsable(EditorBrowsableState.Advanced)]
3515 protected virtual void OnEnter(EventArgs e) {
3516 if (Enter!=null) Enter(this, e);
3519 [EditorBrowsable(EditorBrowsableState.Advanced)]
3520 protected virtual void OnFontChanged(EventArgs e) {
3521 if (FontChanged!=null) FontChanged(this, e);
3522 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
3525 [EditorBrowsable(EditorBrowsableState.Advanced)]
3526 protected virtual void OnForeColorChanged(EventArgs e) {
3527 if (ForeColorChanged!=null) ForeColorChanged(this, e);
3528 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
3531 [EditorBrowsable(EditorBrowsableState.Advanced)]
3532 protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
3533 if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
3536 [EditorBrowsable(EditorBrowsableState.Advanced)]
3537 protected virtual void OnGotFocus(EventArgs e) {
3538 if (GotFocus!=null) GotFocus(this, e);
3541 [EditorBrowsable(EditorBrowsableState.Advanced)]
3542 protected virtual void OnHandleCreated(EventArgs e) {
3543 if (HandleCreated!=null) HandleCreated(this, e);
3546 [EditorBrowsable(EditorBrowsableState.Advanced)]
3547 protected virtual void OnHandleDestroyed(EventArgs e) {
3548 if (HandleDestroyed!=null) HandleDestroyed(this, e);
3551 [EditorBrowsable(EditorBrowsableState.Advanced)]
3552 protected virtual void OnHelpRequested(HelpEventArgs hevent) {
3553 if (HelpRequested!=null) HelpRequested(this, hevent);
3556 protected virtual void OnImeModeChanged(EventArgs e) {
3557 if (ImeModeChanged!=null) ImeModeChanged(this, e);
3560 [EditorBrowsable(EditorBrowsableState.Advanced)]
3561 protected virtual void OnInvalidated(InvalidateEventArgs e) {
3562 if (Invalidated!=null) Invalidated(this, e);
3565 [EditorBrowsable(EditorBrowsableState.Advanced)]
3566 protected virtual void OnKeyDown(KeyEventArgs e) {
3567 if (KeyDown!=null) KeyDown(this, e);
3570 [EditorBrowsable(EditorBrowsableState.Advanced)]
3571 protected virtual void OnKeyPress(KeyPressEventArgs e) {
3572 if (KeyPress!=null) KeyPress(this, e);
3575 [EditorBrowsable(EditorBrowsableState.Advanced)]
3576 protected virtual void OnKeyUp(KeyEventArgs e) {
3577 if (KeyUp!=null) KeyUp(this, e);
3580 [EditorBrowsable(EditorBrowsableState.Advanced)]
3581 protected virtual void OnLayout(LayoutEventArgs levent) {
3582 if (Layout!=null) Layout(this, levent);
3585 [EditorBrowsable(EditorBrowsableState.Advanced)]
3586 protected virtual void OnLeave(EventArgs e) {
3587 if (Leave!=null) Leave(this, e);
3590 [EditorBrowsable(EditorBrowsableState.Advanced)]
3591 protected virtual void OnLocationChanged(EventArgs e) {
3593 if (LocationChanged!=null) LocationChanged(this, e);
3596 [EditorBrowsable(EditorBrowsableState.Advanced)]
3597 protected virtual void OnLostFocus(EventArgs e) {
3598 if (LostFocus!=null) LostFocus(this, e);
3601 [EditorBrowsable(EditorBrowsableState.Advanced)]
3602 protected virtual void OnMouseDown(MouseEventArgs e) {
3603 if (MouseDown!=null) MouseDown(this, e);
3606 [EditorBrowsable(EditorBrowsableState.Advanced)]
3607 protected virtual void OnMouseEnter(EventArgs e) {
3608 if (MouseEnter!=null) MouseEnter(this, e);
3611 [EditorBrowsable(EditorBrowsableState.Advanced)]
3612 protected virtual void OnMouseHover(EventArgs e) {
3613 if (MouseHover!=null) MouseHover(this, e);
3616 [EditorBrowsable(EditorBrowsableState.Advanced)]
3617 protected virtual void OnMouseLeave(EventArgs e) {
3618 if (MouseLeave!=null) MouseLeave(this, e);
3621 [EditorBrowsable(EditorBrowsableState.Advanced)]
3622 protected virtual void OnMouseMove(MouseEventArgs e) {
3623 if (MouseMove!=null) MouseMove(this, e);
3626 [EditorBrowsable(EditorBrowsableState.Advanced)]
3627 protected virtual void OnMouseUp(MouseEventArgs e) {
3628 if (MouseUp!=null) MouseUp(this, e);
3631 [EditorBrowsable(EditorBrowsableState.Advanced)]
3632 protected virtual void OnMouseWheel(MouseEventArgs e) {
3633 if (MouseWheel!=null) MouseWheel(this, e);
3636 [EditorBrowsable(EditorBrowsableState.Advanced)]
3637 protected virtual void OnMove(EventArgs e) {
3638 if (Move!=null) Move(this, e);
3641 [EditorBrowsable(EditorBrowsableState.Advanced)]
3642 protected virtual void OnNotifyMessage(Message m) {
3646 [EditorBrowsable(EditorBrowsableState.Advanced)]
3647 protected virtual void OnPaint(PaintEventArgs e) {
3648 if (Paint!=null) Paint(this, e);
3651 [EditorBrowsable(EditorBrowsableState.Advanced)]
3652 protected virtual void OnPaintBackground(PaintEventArgs pevent) {
3656 [EditorBrowsable(EditorBrowsableState.Advanced)]
3657 protected virtual void OnParentBackColorChanged(EventArgs e) {
3658 if (background_color.IsEmpty && background_image==null) {
3660 OnBackColorChanged(e);
3664 [EditorBrowsable(EditorBrowsableState.Advanced)]
3665 protected virtual void OnParentBackgroundImageChanged(EventArgs e) {
3666 if (background_color.IsEmpty && background_image==null) {
3668 OnBackgroundImageChanged(e);
3672 [EditorBrowsable(EditorBrowsableState.Advanced)]
3673 protected virtual void OnParentBindingContextChanged(EventArgs e) {
3674 if (binding_context==null) {
3675 binding_context=Parent.binding_context;
3676 OnBindingContextChanged(e);
3680 [EditorBrowsable(EditorBrowsableState.Advanced)]
3681 protected virtual void OnParentChanged(EventArgs e) {
3682 if (ParentChanged!=null) ParentChanged(this, e);
3685 [EditorBrowsable(EditorBrowsableState.Advanced)]
3686 protected virtual void OnParentEnabledChanged(EventArgs e) {
3687 if (is_enabled != Parent.is_enabled) {
3688 is_enabled=Parent.is_enabled;
3690 if (EnabledChanged != null) {
3691 EnabledChanged(this, e);
3696 [EditorBrowsable(EditorBrowsableState.Advanced)]
3697 protected virtual void OnParentFontChanged(EventArgs e) {
3704 [EditorBrowsable(EditorBrowsableState.Advanced)]
3705 protected virtual void OnParentForeColorChanged(EventArgs e) {
3706 if (foreground_color.IsEmpty) {
3708 OnForeColorChanged(e);
3712 [EditorBrowsable(EditorBrowsableState.Advanced)]
3713 protected virtual void OnParentRightToLeftChanged(EventArgs e) {
3714 if (right_to_left==RightToLeft.Inherit) {
3716 OnRightToLeftChanged(e);
3720 [EditorBrowsable(EditorBrowsableState.Advanced)]
3721 protected virtual void OnParentVisibleChanged(EventArgs e) {
3722 if (is_visible!=Parent.is_visible) {
3725 OnVisibleChanged(e);
3729 [EditorBrowsable(EditorBrowsableState.Advanced)]
3730 protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
3731 if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
3734 [EditorBrowsable(EditorBrowsableState.Advanced)]
3735 protected virtual void OnResize(EventArgs e) {
3736 if (Resize!=null) Resize(this, e);
3738 PerformLayout(this, "bounds");
3740 if (parent != null) {
3741 parent.PerformLayout();
3745 [EditorBrowsable(EditorBrowsableState.Advanced)]
3746 protected virtual void OnRightToLeftChanged(EventArgs e) {
3747 if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
3748 for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
3751 [EditorBrowsable(EditorBrowsableState.Advanced)]
3752 protected virtual void OnSizeChanged(EventArgs e) {
3753 InvalidateBuffers ();
3755 if (SizeChanged!=null) SizeChanged(this, e);
3758 [EditorBrowsable(EditorBrowsableState.Advanced)]
3759 protected virtual void OnStyleChanged(EventArgs e) {
3760 if (StyleChanged!=null) StyleChanged(this, e);
3763 [EditorBrowsable(EditorBrowsableState.Advanced)]
3764 protected virtual void OnSystemColorsChanged(EventArgs e) {
3765 if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
3768 [EditorBrowsable(EditorBrowsableState.Advanced)]
3769 protected virtual void OnTabIndexChanged(EventArgs e) {
3770 if (TabIndexChanged!=null) TabIndexChanged(this, e);
3773 [EditorBrowsable(EditorBrowsableState.Advanced)]
3774 protected virtual void OnTabStopChanged(EventArgs e) {
3775 if (TabStopChanged!=null) TabStopChanged(this, e);
3778 [EditorBrowsable(EditorBrowsableState.Advanced)]
3779 protected virtual void OnTextChanged(EventArgs e) {
3780 if (TextChanged!=null) TextChanged(this, e);
3783 [EditorBrowsable(EditorBrowsableState.Advanced)]
3784 protected virtual void OnValidated(EventArgs e) {
3785 if (Validated!=null) Validated(this, e);
3788 [EditorBrowsable(EditorBrowsableState.Advanced)]
3789 protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
3790 if (Validating!=null) Validating(this, e);
3793 [EditorBrowsable(EditorBrowsableState.Advanced)]
3794 protected virtual void OnVisibleChanged(EventArgs e) {
3801 if (bmp_mem!=null) {
3807 if (!this.IsHandleCreated) {
3808 this.CreateHandle();
3814 if (VisibleChanged!=null) VisibleChanged(this, e);
3816 // We need to tell our kids
3817 for (int i=0; i<child_controls.Count; i++) {
3818 child_controls[i].OnParentVisibleChanged(e);
3821 #endregion // OnXXX methods
3824 public event EventHandler BackColorChanged;
3825 public event EventHandler BackgroundImageChanged;
3826 public event EventHandler BindingContextChanged;
3827 public event EventHandler CausesValidationChanged;
3828 public event UICuesEventHandler ChangeUICues;
3829 public event EventHandler Click;
3830 public event EventHandler ContextMenuChanged;
3832 [EditorBrowsable(EditorBrowsableState.Advanced)]
3834 public event ControlEventHandler ControlAdded;
3836 [EditorBrowsable(EditorBrowsableState.Advanced)]
3838 public event ControlEventHandler ControlRemoved;
3840 public event EventHandler CursorChanged;
3841 public event EventHandler DockChanged;
3842 public event EventHandler DoubleClick;
3843 public event DragEventHandler DragDrop;
3844 public event DragEventHandler DragEnter;
3845 public event EventHandler DragLeave;
3846 public event DragEventHandler DragOver;
3847 public event EventHandler EnabledChanged;
3848 public event EventHandler Enter;
3849 public event EventHandler FontChanged;
3850 public event EventHandler ForeColorChanged;
3851 public event GiveFeedbackEventHandler GiveFeedback;
3853 [EditorBrowsable(EditorBrowsableState.Advanced)]
3855 public event EventHandler GotFocus;
3857 [EditorBrowsable(EditorBrowsableState.Advanced)]
3859 public event EventHandler HandleCreated;
3861 [EditorBrowsable(EditorBrowsableState.Advanced)]
3863 public event EventHandler HandleDestroyed;
3865 public event HelpEventHandler HelpRequested;
3866 public event EventHandler ImeModeChanged;
3868 [EditorBrowsable(EditorBrowsableState.Advanced)]
3870 public event InvalidateEventHandler Invalidated;
3872 public event KeyEventHandler KeyDown;
3873 public event KeyPressEventHandler KeyPress;
3874 public event KeyEventHandler KeyUp;
3875 public event LayoutEventHandler Layout;
3876 public event EventHandler Leave;
3877 public event EventHandler LocationChanged;
3879 [EditorBrowsable(EditorBrowsableState.Advanced)]
3881 public event EventHandler LostFocus;
3883 public event MouseEventHandler MouseDown;
3884 public event EventHandler MouseEnter;
3885 public event EventHandler MouseHover;
3886 public event EventHandler MouseLeave;
3887 public event MouseEventHandler MouseMove;
3888 public event MouseEventHandler MouseUp;
3890 [EditorBrowsable(EditorBrowsableState.Advanced)]
3892 public event MouseEventHandler MouseWheel;
3894 public event EventHandler Move;
3895 public event PaintEventHandler Paint;
3896 public event EventHandler ParentChanged;
3897 public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
3898 public event QueryContinueDragEventHandler QueryContinueDrag;
3899 public event EventHandler Resize;
3900 public event EventHandler RightToLeftChanged;
3901 public event EventHandler SizeChanged;
3902 public event EventHandler StyleChanged;
3903 public event EventHandler SystemColorsChanged;
3904 public event EventHandler TabIndexChanged;
3905 public event EventHandler TabStopChanged;
3906 public event EventHandler TextChanged;
3907 public event EventHandler Validated;
3908 public event CancelEventHandler Validating;
3909 public event EventHandler VisibleChanged;
3910 #endregion // Events