// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
-// Copyright (c) 2004-2005 Novell, Inc.
+// Copyright (c) 2004-2006 Novell, Inc.
//
// Authors:
// Peter Bartok pbartok@novell.com
// John Sohn jsohn@columbus.rr.com
//
-// COMPLETE
+#undef DebugRecreate
+#undef DebugFocus
using System;
using System.ComponentModel;
using System.Collections;
using System.Diagnostics;
using System.Drawing;
+using System.Drawing.Drawing2D;
using System.Reflection;
using System.Runtime.InteropServices;
+using System.Security;
using System.Threading;
-
namespace System.Windows.Forms
{
- [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design)]
+#if NET_2_0
+ [ComVisible(true)]
+ [ClassInterface (ClassInterfaceType.AutoDispatch)]
+#endif
+ [Designer("System.Windows.Forms.Design.ControlDesigner, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.IDesigner")]
[DefaultProperty("Text")]
[DefaultEvent("Click")]
[DesignerSerializer("System.Windows.Forms.Design.ControlCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
[ToolboxItemFilter("System.Windows.Forms")]
public class Control : Component, ISynchronizeInvoke, IWin32Window
- {
+#if NET_2_0
+ , IBindableComponent, IDropTarget
+#endif
+ {
#region Local Variables
// Basic
internal Rectangle bounds; // bounding rectangle for control (client area + decorations)
+ Rectangle explicit_bounds; // explicitly set bounds
internal object creator_thread; // thread that created the control
- internal ControlNativeWindow window; // object for native window handle
- internal string name; // for object naming
+ internal ControlNativeWindow window; // object for native window handle
+ string name; // for object naming
// State
- private bool create_handled; // true if OnCreateControl has been sent
- internal bool has_focus; // true if control has focus
- internal bool is_visible; // true if control is visible
- internal bool is_entered; // is the mouse inside the control?
- internal bool is_enabled; // true if control is enabled (usable/not grayed out)
- internal bool is_selected; // true if control is selected
- internal bool is_accessible; // true if the control is visible to accessibility applications
- internal bool is_captured; // tracks if the control has captured the mouse
+ bool is_created; // true if OnCreateControl has been sent
+ internal bool has_focus; // true if control has focus
+ internal bool is_visible; // true if control is visible
+ internal bool is_entered; // is the mouse inside the control?
+ internal bool is_enabled; // true if control is enabled (usable/not grayed out)
+ bool is_accessible; // true if the control is visible to accessibility applications
+ bool is_captured; // tracks if the control has captured the mouse
internal bool is_toplevel; // tracks if the control is a toplevel window
- internal bool is_recreating; // tracks if the handle for the control is being recreated
- internal bool causes_validation; // tracks if validation is executed on changes
- internal int tab_index; // position in tab order of siblings
- internal bool tab_stop = true; // is the control a tab stop?
- internal bool is_disposed; // has the window already been disposed?
- internal Size client_size; // size of the client area (window excluding decorations)
- internal Rectangle client_rect; // rectangle with the client area (window excluding decorations)
- internal ControlStyles control_style; // rather win32-specific, style bits for control
- internal ImeMode ime_mode = ImeMode.Inherit;
- internal bool layout_pending; // true if our parent needs to re-layout us
- internal object control_tag; // object that contains data about our control
+ bool is_recreating; // tracks if the handle for the control is being recreated
+ bool causes_validation; // tracks if validation is executed on changes
+ bool is_focusing; // tracks if Focus has been called on the control and has not yet finished
+ bool container_selected; // true if Select() or Focus() is called on a container, to prevent child controls from raising their GotFocus event
+ int tab_index; // position in tab order of siblings
+ bool tab_stop; // is the control a tab stop?
+ bool is_disposed; // has the window already been disposed?
+ Size client_size; // size of the client area (window excluding decorations)
+ Rectangle client_rect; // rectangle with the client area (window excluding decorations)
+ ControlStyles control_style; // rather win32-specific, style bits for control
+ ImeMode ime_mode;
+ object control_tag; // object that contains data about our control
internal int mouse_clicks; // Counter for mouse clicks
- internal Cursor cursor; // Cursor for the window
+ Cursor cursor; // Cursor for the window
+ internal bool allow_drop; // true if the control accepts droping objects on it
+ Region clip_region; // User-specified clip region for the window
// Visuals
internal Color foreground_color; // foreground color for control
internal Color background_color; // background color for control
- internal Image background_image; // background image for control
+ Image background_image; // background image for control
internal Font font; // font for control
- internal string text; // window/title text for control
- internal BorderStyle border_style; // Border style of control
+ string text; // window/title text for control
+ internal BorderStyle border_style; // Border style of control
// Layout
- internal AnchorStyles anchor_style; // anchoring requirements for our control
- internal DockStyle dock_style; // docking requirements for our control (supercedes anchoring)
- internal SizeF size_ratio; // size ratio of our control to it's parent; required for anchoring
- internal Size prev_size; // previous size of the control; required for anchoring
-
- // to be categorized...
- static internal ArrayList controls = new ArrayList(); // All of the application's controls, in a flat list
- internal ControlCollection child_controls; // our children
- internal Control parent; // our parent control
- internal AccessibleObject accessibility_object; // object that contains accessibility information about our control
- internal BindingContext binding_context; // TODO
- internal RightToLeft right_to_left; // drawing direction for control
- internal int layout_suspended;
- internal bool double_buffering;
- internal ContextMenu context_menu; // Context menu associated with the control
+ internal enum LayoutType {
+ Anchor,
+ Dock
+ }
+ Layout.LayoutEngine layout_engine;
+ int layout_suspended;
+ bool layout_pending; // true if our parent needs to re-layout us
+ internal AnchorStyles anchor_style; // anchoring requirements for our control
+ internal DockStyle dock_style; // docking requirements for our control
+ LayoutType layout_type;
- private Graphics dc_mem; // Graphics context for double buffering
- private Bitmap bmp_mem; // Bitmap for double buffering control
+ // Please leave the next 2 as internal until DefaultLayout (2.0) is rewritten
+ internal int dist_right; // distance to the right border of the parent
+ internal int dist_bottom; // distance to the bottom border of the parent
- private ControlBindingsCollection data_bindings;
+ // to be categorized...
+ ControlCollection child_controls; // our children
+ Control parent; // our parent control
+ AccessibleObject accessibility_object; // object that contains accessibility information about our control
+ BindingContext binding_context;
+ RightToLeft right_to_left; // drawing direction for control
+ ContextMenu context_menu; // Context menu associated with the control
+
+ // double buffering
+ DoubleBuffer backbuffer;
+
+ // to implement DeviceContext without depending on double buffering
+ Bitmap bmp;
+ Graphics bmp_g;
+
+ ControlBindingsCollection data_bindings;
+
+#if NET_2_0
+ internal bool use_compatible_text_rendering;
+ static bool verify_thread_handle;
+ Padding padding;
+ ImageLayout backgroundimage_layout;
+ Size maximum_size;
+ Size minimum_size;
+ Size preferred_size;
+ Padding margin;
+ private ContextMenuStrip context_menu_strip;
+#endif
#endregion // Local Variables
ControlNativeWindow window;
window = (ControlNativeWindow)window_collection[hWnd];
+ if (window != null) {
+ return window.owner;
+ }
+
+ return null;
+ }
+
+ static internal Control ControlFromChildHandle (IntPtr handle) {
+ ControlNativeWindow window;
- return window.owner;
+ Hwnd hwnd = Hwnd.ObjectFromHandle (handle);
+ while (hwnd != null) {
+ window = (ControlNativeWindow)window_collection[hwnd.Handle];
+ if (window != null) {
+ return window.owner;
+ }
+ hwnd = hwnd.Parent;
+ }
+
+ return null;
}
protected override void WndProc(ref Message m) {
#region Public Classes
[ComVisible(true)]
- public class ControlAccessibleObject : AccessibleObject {
- #region ControlAccessibleObject Local Variables
- private Control owner;
- #endregion // ControlAccessibleObject Local Variables
+ public class ControlAccessibleObject : AccessibleObject {
+ Control owner;
#region ControlAccessibleObject Constructors
- public ControlAccessibleObject(Control ownerControl) {
+ public ControlAccessibleObject(Control ownerControl)
+ : base (ownerControl)
+ {
this.owner = ownerControl;
}
#endregion // ControlAccessibleObject Constructors
}
}
+ public override AccessibleObject Parent {
+ get {
+ return base.Parent;
+ }
+ }
+
+
public override AccessibleRole Role {
get {
return base.Role;
#endregion // ControlAccessibleObject Public Instance Methods
}
+ private class DoubleBuffer : IDisposable
+ {
+ public Region InvalidRegion;
+ private Stack real_graphics;
+ private object back_buffer;
+ private Control parent;
+ private bool pending_disposal;
+
+ public DoubleBuffer (Control parent)
+ {
+ this.parent = parent;
+ real_graphics = new Stack ();
+ int width = parent.Width;
+ int height = parent.Height;
+
+ if (width < 1) width = 1;
+ if (height < 1) height = 1;
+
+ XplatUI.CreateOffscreenDrawable (parent.Handle, width, height, out back_buffer);
+ Invalidate ();
+ }
+
+ public void Blit (PaintEventArgs pe)
+ {
+ Graphics buffered_graphics;
+ buffered_graphics = XplatUI.GetOffscreenGraphics (back_buffer);
+ XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
+ buffered_graphics.Dispose ();
+ }
+
+ public void Start (PaintEventArgs pe)
+ {
+ // We need to get the graphics for every paint.
+ real_graphics.Push(pe.SetGraphics (XplatUI.GetOffscreenGraphics (back_buffer)));
+ }
+
+ public void End (PaintEventArgs pe)
+ {
+ Graphics buffered_graphics;
+ buffered_graphics = pe.SetGraphics ((Graphics) real_graphics.Pop ());
+
+ if (pending_disposal)
+ Dispose ();
+ else {
+ XplatUI.BlitFromOffscreen (parent.Handle, pe.Graphics, back_buffer, buffered_graphics, pe.ClipRectangle);
+ InvalidRegion.Exclude (pe.ClipRectangle);
+ }
+ buffered_graphics.Dispose ();
+ }
+
+ public void Invalidate ()
+ {
+ if (InvalidRegion != null)
+ InvalidRegion.Dispose ();
+ InvalidRegion = new Region (parent.ClientRectangle);
+ }
+
+ public void Dispose ()
+ {
+ if (real_graphics.Count > 0) {
+ pending_disposal = true;
+ return;
+ }
+
+ XplatUI.DestroyOffscreenDrawable (back_buffer);
+
+ if (InvalidRegion != null)
+ InvalidRegion.Dispose ();
+ InvalidRegion = null;
+ back_buffer = null;
+ GC.SuppressFinalize (this);
+ }
+
+ #region IDisposable Members
+ void IDisposable.Dispose ()
+ {
+ Dispose ();
+ }
+ #endregion
+
+ ~DoubleBuffer ()
+ {
+ Dispose ();
+ }
+ }
+
+ [ListBindable (false)]
+#if NET_2_0
+ [ComVisible (false)]
+ public class ControlCollection : Layout.ArrangedElementCollection, IList, ICollection, ICloneable, IEnumerable {
+#else
[DesignerSerializer("System.Windows.Forms.Design.ControlCollectionCodeDomSerializer, " + Consts.AssemblySystem_Design, "System.ComponentModel.Design.Serialization.CodeDomSerializer, " + Consts.AssemblySystem_Design)]
- [ListBindable(false)]
public class ControlCollection : IList, ICollection, ICloneable, IEnumerable {
+#endif
#region ControlCollection Local Variables
- internal ArrayList list;
- internal Control owner;
+#if !NET_2_0
+ ArrayList list;
+#endif
+ ArrayList impl_list;
+ Control[] all_controls;
+ Control owner;
#endregion // ControlCollection Local Variables
#region ControlCollection Public Constructor
public ControlCollection(Control owner) {
this.owner=owner;
+#if !NET_2_0
this.list=new ArrayList();
+#endif
}
#endregion
#region ControlCollection Public Instance Properties
+ int ICollection.Count {
+ get { return Count; }
+ }
+
+
+#if !NET_2_0
public int Count {
- get {
- return list.Count;
- }
+ get { return list.Count; }
}
+#endif
- public bool IsReadOnly {
+#if NET_2_0
+ bool IList.IsReadOnly
+#else
+ public bool IsReadOnly
+#endif
+ {
get {
return list.IsReadOnly;
}
}
+#if NET_2_0
+ public Control Owner { get { return this.owner; } }
+
+ public virtual Control this[string key] {
+ get {
+ int index = IndexOfKey (key);
+
+ if (index >= 0)
+ return this[index];
+
+ return null;
+ }
+ }
+
+ new
+#endif
public virtual Control this[int index] {
get {
if (index < 0 || index >= list.Count) {
}
return (Control)list[index];
}
+
+
}
#endregion // ControlCollection Public Instance Properties
- #region ControlCollection Private Instance Methods
+ #region ControlCollection Instance Methods
public virtual void Add (Control value)
{
+ if (value == null)
+ return;
- for (int i = 0; i < list.Count; i++) {
- if (list [i] == value) {
- // Do we need to do anything here?
- return;
- }
+ if (Contains (value)) {
+ owner.PerformLayout();
+ return;
}
if (value.tab_index == -1) {
value.tab_index = use;
}
+ if (value.parent != null) {
+ value.parent.Controls.Remove(value);
+ }
+
+ all_controls = null;
list.Add (value);
- value.Parent = owner;
- owner.UpdateZOrder();
+
+ value.ChangeParent(owner);
+
+ value.InitLayout();
+
+ owner.UpdateChildrenZOrder();
+ owner.PerformLayout(value, "Parent");
owner.OnControlAdded(new ControlEventArgs(value));
}
+ internal void AddToList (Control c)
+ {
+ all_controls = null;
+ list.Add (c);
+ }
+
+ internal virtual void AddImplicit (Control control)
+ {
+ if (impl_list == null)
+ impl_list = new ArrayList ();
+
+ if (AllContains (control))
+ return;
+
+ all_controls = null;
+ impl_list.Add (control);
+
+ control.ChangeParent (owner);
+ control.InitLayout ();
+ owner.UpdateChildrenZOrder ();
+ owner.PerformLayout (control, "Parent");
+ owner.OnControlAdded (new ControlEventArgs (control));
+ }
+#if NET_2_0
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+#endif
public virtual void AddRange (Control[] controls)
{
if (controls == null)
}
}
+ internal virtual void AddRangeImplicit (Control [] controls)
+ {
+ if (controls == null)
+ throw new ArgumentNullException ("controls");
+
+ owner.SuspendLayout ();
+
+ try {
+ for (int i = 0; i < controls.Length; i++)
+ AddImplicit (controls [i]);
+ } finally {
+ owner.ResumeLayout ();
+ }
+ }
+
+#if NET_2_0
+ new
+#endif
public virtual void Clear ()
{
- owner.SuspendLayout();
- for (int i = 0; i < list.Count; i++) {
- owner.OnControlRemoved(new ControlEventArgs((Control)list[i]));
+ all_controls = null;
+
+ // MS sends remove events in reverse order
+ while (list.Count > 0) {
+ Remove((Control)list[list.Count - 1]);
+ }
+ }
+
+ internal virtual void ClearImplicit ()
+ {
+ if (impl_list == null)
+ return;
+ all_controls = null;
+ impl_list.Clear ();
+ }
+
+ public bool Contains (Control value)
+ {
+ for (int i = list.Count; i > 0; ) {
+ i--;
+
+ if (list [i] == value) {
+ // Do we need to do anything here?
+ return true;
+ }
+ }
+ return false;
+ }
+
+ internal bool ImplicitContains (Control value)
+ {
+ if (impl_list == null)
+ return false;
+
+ for (int i = impl_list.Count; i > 0; ) {
+ i--;
+
+ if (impl_list [i] == value) {
+ // Do we need to do anything here?
+ return true;
+ }
}
- list.Clear();
- owner.ResumeLayout();
+ return false;
}
- public virtual bool Contains (Control value)
+ internal bool AllContains (Control value)
{
- return list.Contains (value);
+ return Contains (value) || ImplicitContains (value);
}
+#if NET_2_0
+ public virtual bool ContainsKey (string key)
+ {
+ return IndexOfKey (key) >= 0;
+ }
+#endif
+
+ void ICollection.CopyTo (Array array, int index)
+ {
+ CopyTo (array, index);
+ }
+
+#if !NET_2_0
public void CopyTo (Array array, int index)
{
list.CopyTo(array, index);
}
- public override bool Equals(object other) {
+ public override bool Equals (object other)
+ {
if (other is ControlCollection && (((ControlCollection)other).owner==this.owner)) {
return(true);
} else {
return(false);
}
}
+#endif
+
+#if NET_2_0
+ // LAMESPEC: MSDN says AE, MS implementation throws ANE
+ public Control[] Find (string key, bool searchAllChildren)
+ {
+ if (string.IsNullOrEmpty (key))
+ throw new ArgumentNullException ("key");
+
+ ArrayList al = new ArrayList ();
+
+ foreach (Control c in list) {
+ if (c.Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
+ al.Add (c);
+
+ if (searchAllChildren)
+ al.AddRange (c.Controls.Find (key, true));
+ }
+
+ return (Control[])al.ToArray (typeof (Control));
+ }
+#endif
public int GetChildIndex(Control child) {
return GetChildIndex(child, false);
}
- public int GetChildIndex(Control child, bool throwException) {
+#if NET_2_0
+ public virtual int
+#else
+ public int
+#endif
+ GetChildIndex(Control child, bool throwException) {
int index;
index=list.IndexOf(child);
return index;
}
- public IEnumerator GetEnumerator() {
+#if NET_2_0
+ public override IEnumerator
+#else
+ public IEnumerator
+#endif
+ GetEnumerator ()
+ {
return list.GetEnumerator();
}
- public override int GetHashCode() {
+ internal IEnumerator GetAllEnumerator ()
+ {
+ Control [] res = GetAllControls ();
+ return res.GetEnumerator ();
+ }
+
+ internal Control [] GetAllControls ()
+ {
+ if (all_controls != null)
+ return all_controls;
+
+ if (impl_list == null) {
+ all_controls = (Control []) list.ToArray (typeof (Control));
+ return all_controls;
+ }
+
+ all_controls = new Control [list.Count + impl_list.Count];
+ impl_list.CopyTo (all_controls);
+ list.CopyTo (all_controls, impl_list.Count);
+
+ return all_controls;
+ }
+
+#if !NET_2_0
+ public override int GetHashCode()
+ {
return base.GetHashCode();
}
+#endif
- public int IndexOf(Control control) {
+ public int IndexOf(Control control)
+ {
return list.IndexOf(control);
}
- public virtual void Remove(Control value) {
+#if NET_2_0
+ public virtual int IndexOfKey (string key)
+ {
+ if (string.IsNullOrEmpty (key))
+ return -1;
+
+ for (int i = 0; i < list.Count; i++)
+ if (((Control)list[i]).Name.Equals (key, StringComparison.CurrentCultureIgnoreCase))
+ return i;
+
+ return -1;
+ }
+#endif
+
+ public virtual void Remove(Control value)
+ {
+ if (value == null)
+ return;
+
+ owner.PerformLayout(value, "Parent");
owner.OnControlRemoved(new ControlEventArgs(value));
+
+ all_controls = null;
list.Remove(value);
- owner.UpdateZOrder();
+
+ value.ChangeParent(null);
+
+ owner.UpdateChildrenZOrder();
}
- public void RemoveAt(int index) {
- if (index<0 || index>=list.Count) {
- throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
+ internal virtual void RemoveImplicit (Control control)
+ {
+ if (impl_list != null) {
+ all_controls = null;
+ owner.PerformLayout (control, "Parent");
+ owner.OnControlRemoved (new ControlEventArgs (control));
+ impl_list.Remove (control);
}
+ control.ChangeParent (null);
+ owner.UpdateChildrenZOrder ();
+ }
- owner.OnControlRemoved(new ControlEventArgs((Control)list[index]));
- list.RemoveAt(index);
- owner.UpdateZOrder();
+#if NET_2_0
+ new
+#endif
+ public void RemoveAt(int index)
+ {
+ if (index < 0 || index >= list.Count) {
+ throw new ArgumentOutOfRangeException("index", index, "ControlCollection does not have that many controls");
+ }
+ Remove ((Control)list[index]);
}
- public void SetChildIndex(Control child, int newIndex) {
+#if NET_2_0
+ public virtual void RemoveByKey (string key)
+ {
+ int index = IndexOfKey (key);
+
+ if (index >= 0)
+ RemoveAt (index);
+ }
+
+ public virtual void
+#else
+ public void
+#endif
+ SetChildIndex(Control child, int newIndex)
+ {
+ if (child == null)
+ throw new ArgumentNullException ("child");
+
int old_index;
old_index=list.IndexOf(child);
return;
}
- RemoveAt(old_index);
+ all_controls = null;
+ list.RemoveAt(old_index);
if (newIndex>list.Count) {
list.Add(child);
} else {
list.Insert(newIndex, child);
}
- owner.UpdateZOrder();
+ child.UpdateZOrder();
+ owner.PerformLayout();
}
#endregion // ControlCollection Private Instance Methods
throw new ArgumentException("Object of type Control required", "value");
}
- list[index]=(Control)value;
+ all_controls = null;
+ Control ctrl = (Control) value;
+ list[index]= ctrl;
+
+ ctrl.ChangeParent(owner);
+
+ ctrl.InitLayout();
+
+ owner.UpdateChildrenZOrder();
+ owner.PerformLayout(ctrl, "Parent");
}
}
}
}
- bool IList.IsReadOnly {
- get {
- return list.IsReadOnly;
- }
- }
-
bool ICollection.IsSynchronized {
get {
return list.IsSynchronized;
if (!(value is Control)) {
throw new ArgumentException("Object of type Control required", "value");
}
+ all_controls = null;
list.Insert(index, value);
}
if (!(value is Control)) {
throw new ArgumentException("Object of type Control required", "value");
}
+ all_controls = null;
list.Remove(value);
}
- void ICollection.CopyTo(Array array, int index) {
- if (list.Count>0) {
- list.CopyTo(array, index);
- }
- }
-
Object ICloneable.Clone() {
ControlCollection clone = new ControlCollection(this.owner);
clone.list=(ArrayList)list.Clone(); // FIXME: Do we need this?
#endregion // ControlCollection Class
#region Public Constructors
- public Control() {
- creator_thread = Thread.CurrentThread;
-
- prev_size = Size.Empty;
+ public Control()
+ {
+ layout_type = LayoutType.Anchor;
anchor_style = AnchorStyles.Top | AnchorStyles.Left;
- create_handled = false;
+ is_created = false;
is_visible = true;
is_captured = false;
is_disposed = false;
is_toplevel = false;
causes_validation = true;
has_focus = false;
- layout_suspended = 0;
- double_buffering = true;
+ layout_suspended = 0;
mouse_clicks = 1;
tab_index = -1;
cursor = null;
right_to_left = RightToLeft.Inherit;
+ border_style = BorderStyle.None;
+ background_color = Color.Empty;
+ dist_right = 0;
+ dist_bottom = 0;
+ tab_stop = true;
+ ime_mode = ImeMode.Inherit;
+
+#if NET_2_0
+ backgroundimage_layout = ImageLayout.Tile;
+ use_compatible_text_rendering = Application.use_compatible_text_rendering;
+ padding = new Padding(0);
+ maximum_size = new Size();
+ minimum_size = new Size();
+ preferred_size = this.DefaultSize;
+ margin = this.DefaultMargin;
+#endif
- control_style = ControlStyles.Selectable | ControlStyles.StandardClick | ControlStyles.StandardDoubleClick;
+ control_style = ControlStyles.UserPaint | ControlStyles.AllPaintingInWmPaint |
+ ControlStyles.Selectable | ControlStyles.StandardClick |
+ ControlStyles.StandardDoubleClick;
+#if NET_2_0
+ control_style |= ControlStyles.UseTextForAccessibility;
+#endif
parent = null;
background_image = null;
text = string.Empty;
- name = string.Empty;
+ name = string.Empty;
+ window = new ControlNativeWindow(this);
child_controls = CreateControlsInstance();
client_size = new Size(DefaultSize.Width, DefaultSize.Height);
client_rect = new Rectangle(0, 0, DefaultSize.Width, DefaultSize.Height);
- XplatUI.CalculateWindowRect(IntPtr.Zero, ref client_rect, CreateParams.Style, CreateParams.ExStyle, IntPtr.Zero, out bounds);
+ bounds.Size = SizeFromClientSize (client_size);
+
if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) == 0) {
bounds.X=-1;
bounds.Y=-1;
bounds.Y=top;
bounds.Width=width;
bounds.Height=height;
- SetBoundsCore(left, top, width, height, BoundsSpecified.All);
+ SetBounds(left, top, width, height, BoundsSpecified.All);
Text=text;
}
bounds.Y=top;
bounds.Width=width;
bounds.Height=height;
- SetBoundsCore(left, top, width, height, BoundsSpecified.All);
+ SetBounds(left, top, width, height, BoundsSpecified.All);
Text=text;
}
+ private delegate void RemoveDelegate(object c);
+
protected override void Dispose(bool disposing) {
- is_disposed = true;
- if (dc_mem!=null) {
- dc_mem.Dispose();
- dc_mem=null;
- }
+ if (!is_disposed && disposing) {
+ Capture = false;
- if (bmp_mem!=null) {
- bmp_mem.Dispose();
- bmp_mem=null;
- }
+ DisposeBackBuffer ();
+
+ if (bmp != null) {
+ bmp.Dispose ();
+ bmp = null;
+ }
+ if (bmp_g != null) {
+ bmp_g.Dispose ();
+ bmp_g = null;
+ }
+
+ if (this.InvokeRequired) {
+ if (Application.MessageLoop) {
+ this.BeginInvokeInternal(new MethodInvoker(DestroyHandle), null, true);
+ }
+ } else {
+ DestroyHandle();
+ }
+
+ if (parent != null) {
+ parent.Controls.Remove(this);
+ }
- DestroyHandle();
- controls.Remove(this);
+ Control [] children = child_controls.GetAllControls ();
+ for (int i=0; i<children.Length; i++) {
+ children[i].parent = null; // Need to set to null or our child will try and remove from ourselves and crash
+ children[i].Dispose();
+ }
+ }
+ is_disposed = true;
+ is_visible = false;
+ base.Dispose(disposing);
}
#endregion // Public Constructors
#region Internal Properties
+ internal bool VisibleInternal {
+ get { return is_visible; }
+ }
+
+ internal LayoutType ControlLayoutType {
+ get { return layout_type; }
+ }
+
internal BorderStyle InternalBorderStyle {
get {
return border_style;
}
set {
+ if (!Enum.IsDefined (typeof (BorderStyle), value))
+ throw new InvalidEnumArgumentException (string.Format("Enum argument value '{0}' is not valid for BorderStyle", value));
+
if (border_style != value) {
border_style = value;
- XplatUI.SetBorderStyle(window.Handle, border_style);
+ if (IsHandleCreated) {
+ XplatUI.SetBorderStyle (window.Handle, (FormBorderStyle)border_style);
+ RecreateHandle ();
+ Refresh ();
+ }
}
}
}
#endregion // Internal Properties
#region Private & Internal Methods
- internal static IAsyncResult BeginInvokeInternal (Delegate method, object [] args) {
- AsyncMethodResult result = new AsyncMethodResult ();
- AsyncMethodData data = new AsyncMethodData ();
-
- data.Method = method;
- data.Args = args;
- data.Result = new WeakReference (result);
-
- XplatUI.SendAsyncMethod (data);
- return result;
+
+#if NET_2_0
+ void IDropTarget.OnDragDrop (DragEventArgs e)
+ {
+ OnDragDrop (e);
}
-
- internal Graphics DeviceContext {
- get {
- if (dc_mem==null) {
- CreateBuffers(this.Width, this.Height);
- }
- return dc_mem;
- }
+
+ void IDropTarget.OnDragEnter (DragEventArgs e)
+ {
+ OnDragEnter (e);
+ }
+
+ void IDropTarget.OnDragLeave (EventArgs e)
+ {
+ OnDragLeave (e);
}
- internal Bitmap ImageBuffer {
- get {
- if (bmp_mem==null) {
- CreateBuffers(this.Width, this.Height);
- }
- return bmp_mem;
- }
+ void IDropTarget.OnDragOver (DragEventArgs e)
+ {
+ OnDragOver (e);
}
+#endif
- internal void CreateBuffers (int width, int height) {
- if (double_buffering == false)
- return;
+ internal IAsyncResult BeginInvokeInternal (Delegate method, object [] args, bool disposing) {
+ AsyncMethodResult result;
+ AsyncMethodData data;
- if (dc_mem != null) {
- dc_mem.Dispose ();
+ if (!disposing) {
+ Control p = this;
+ do {
+ if (!p.IsHandleCreated) {
+ throw new InvalidOperationException("Cannot call Invoke or InvokeAsync on a control until the window handle is created");
+ }
+ p = p.parent;
+ } while (p != null);
}
- if (bmp_mem != null)
- bmp_mem.Dispose ();
- if (width < 1) {
- width = 1;
- }
+ result = new AsyncMethodResult ();
+ data = new AsyncMethodData ();
+
+ data.Handle = window.Handle;
+ data.Method = method;
+ data.Args = args;
+ data.Result = result;
- if (height < 1) {
- height = 1;
+#if NET_2_0
+ if (!ExecutionContext.IsFlowSuppressed ()) {
+ data.Context = ExecutionContext.Capture ();
+ }
+#else
+#if !MWF_ON_MSRUNTIME
+ if (SecurityManager.SecurityEnabled) {
+ data.Stack = CompressedStack.GetCompressedStack ();
}
+#endif
+#endif
- bmp_mem = new Bitmap (width, height, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
- dc_mem = Graphics.FromImage (bmp_mem);
+ XplatUI.SendAsyncMethod (data);
+ return result;
}
- internal void InvalidateBuffers ()
+
+ internal void PointToClient (ref int x, ref int y)
{
- if (double_buffering == false)
- return;
+ XplatUI.ScreenToClient (Handle, ref x, ref y);
+ }
+
+ internal void PointToScreen (ref int x, ref int y)
+ {
+ XplatUI.ClientToScreen (Handle, ref x, ref y);
+ }
- if (dc_mem != null) {
- dc_mem.Dispose ();
+ internal bool IsRecreating {
+ get {
+ return is_recreating;
}
- if (bmp_mem != null)
- bmp_mem.Dispose ();
+ }
- dc_mem = null;
- bmp_mem = null;
+ internal Graphics DeviceContext {
+ get {
+ if (bmp_g == null) {
+ bmp = new Bitmap(1, 1, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
+ bmp_g = Graphics.FromImage (bmp);
+ }
+ return bmp_g;
+ }
+ }
+
+ private void InvalidateBackBuffer ()
+ {
+ if (backbuffer != null)
+ backbuffer.Invalidate ();
+ }
+
+ private DoubleBuffer GetBackBuffer ()
+ {
+ if (backbuffer == null)
+ backbuffer = new DoubleBuffer (this);
+ return backbuffer;
+ }
+
+ private void DisposeBackBuffer ()
+ {
+ if (backbuffer != null) {
+ backbuffer.Dispose ();
+ backbuffer = null;
+ }
}
internal static void SetChildColor(Control parent) {
for (int i=0; i < parent.child_controls.Count; i++) {
child=parent.child_controls[i];
- if (child.IsHandleCreated) {
- XplatUI.SetWindowBackground(child.window.Handle, child.BackColor);
- }
if (child.child_controls.Count>0) {
SetChildColor(child);
}
}
-
}
internal bool Select(Control control) {
- Control parent;
IContainerControl container;
if (control == null) {
return false;
}
- parent = control.parent;
-
- if (((control.control_style & ControlStyles.Selectable) !=0) && (parent != null)) {
- while (parent != null) {
- if (!parent.Visible || !parent.is_enabled) {
- return false;
- }
- parent = parent.parent;
- }
- }
-
- control.is_selected = true;
-
- XplatUI.SetFocus(control.window.Handle);
container = GetContainerControl();
- if (container != null) {
+ if (container != null && (Control)container != control) {
container.ActiveControl = control;
}
+ if (control.IsHandleCreated) {
+ XplatUI.SetFocus(control.window.Handle);
+ }
return true;
}
+ internal void SelectChild (Control control)
+ {
+ if (control.IsHandleCreated)
+ XplatUI.SetFocus (control.window.Handle);
+ }
+
internal virtual void DoDefaultAction() {
// Only here to be overriden by our actual controls; this is needed by the accessibility class
}
+ internal static IntPtr MakeParam (int low, int high){
+ return new IntPtr (high << 16 | low & 0xffff);
+ }
+
internal static int LowOrder (int param) {
- return (param & 0xffff);
+ return ((int)(short)(param & 0xffff));
}
internal static int HighOrder (int param) {
- return (param >> 16);
+ return ((int)(short)(param >> 16));
+ }
+
+ // This method exists so controls overriding OnPaintBackground can have default background painting done
+ internal virtual void PaintControlBackground (PaintEventArgs pevent)
+ {
+ if (GetStyle(ControlStyles.SupportsTransparentBackColor) && (BackColor.A != 0xff)) {
+ if (parent != null) {
+ PaintEventArgs parent_pe;
+ GraphicsState state;
+
+ parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
+
+ state = parent_pe.Graphics.Save();
+ parent_pe.Graphics.TranslateTransform(-Left, -Top);
+ parent.OnPaintBackground(parent_pe);
+ parent_pe.Graphics.Restore(state);
+
+ state = parent_pe.Graphics.Save();
+ parent_pe.Graphics.TranslateTransform(-Left, -Top);
+ parent.OnPaint(parent_pe);
+ parent_pe.Graphics.Restore(state);
+ parent_pe.SetGraphics(null);
+ }
+ }
+
+ if ((clip_region != null) && (XplatUI.UserClipWontExposeParent)) {
+ if (parent != null) {
+ PaintEventArgs parent_pe;
+ Region region;
+ GraphicsState state;
+ Hwnd hwnd;
+
+ hwnd = Hwnd.ObjectFromHandle(Handle);
+
+ if (hwnd != null) {
+ parent_pe = new PaintEventArgs(pevent.Graphics, new Rectangle(pevent.ClipRectangle.X + Left, pevent.ClipRectangle.Y + Top, pevent.ClipRectangle.Width, pevent.ClipRectangle.Height));
+
+ region = new Region ();
+ region.MakeEmpty();
+ region.Union(ClientRectangle);
+
+ foreach (Rectangle r in hwnd.ClipRectangles) {
+ region.Union (r);
+ }
+
+ state = parent_pe.Graphics.Save();
+ parent_pe.Graphics.Clip = region;
+
+ parent_pe.Graphics.TranslateTransform(-Left, -Top);
+ parent.OnPaintBackground(parent_pe);
+ parent_pe.Graphics.Restore(state);
+
+ state = parent_pe.Graphics.Save();
+ parent_pe.Graphics.Clip = region;
+
+ parent_pe.Graphics.TranslateTransform(-Left, -Top);
+ parent.OnPaint(parent_pe);
+ parent_pe.Graphics.Restore(state);
+ parent_pe.SetGraphics(null);
+
+ region.Intersect(clip_region);
+ pevent.Graphics.Clip = region;
+ }
+ }
+ }
+
+ if (background_image == null) {
+ pevent.Graphics.FillRectangle(ThemeEngine.Current.ResPool.GetSolidBrush(BackColor), new Rectangle(pevent.ClipRectangle.X - 1, pevent.ClipRectangle.Y - 1, pevent.ClipRectangle.Width + 2, pevent.ClipRectangle.Height + 2));
+ return;
+ }
+
+ DrawBackgroundImage (pevent.Graphics);
+ }
+
+ void DrawBackgroundImage (Graphics g)
+ {
+#if NET_2_0
+ Rectangle drawing_rectangle = new Rectangle ();
+ g.FillRectangle (ThemeEngine.Current.ResPool.GetSolidBrush (BackColor), ClientRectangle);
+
+ switch (backgroundimage_layout)
+ {
+ case ImageLayout.Tile:
+ using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
+ g.FillRectangle (b, ClientRectangle);
+ }
+ return;
+ case ImageLayout.Center:
+ drawing_rectangle.Location = new Point (ClientSize.Width / 2 - background_image.Width / 2, ClientSize.Height / 2 - background_image.Height / 2);
+ drawing_rectangle.Size = background_image.Size;
+ break;
+ case ImageLayout.None:
+ drawing_rectangle.Location = Point.Empty;
+ drawing_rectangle.Size = background_image.Size;
+ break;
+ case ImageLayout.Stretch:
+ drawing_rectangle = ClientRectangle;
+ break;
+ case ImageLayout.Zoom:
+ drawing_rectangle = ClientRectangle;
+ if ((float)background_image.Width / (float)background_image.Height < (float)drawing_rectangle.Width / (float) drawing_rectangle.Height) {
+ drawing_rectangle.Width = (int) (background_image.Width * ((float)drawing_rectangle.Height / (float)background_image.Height));
+ drawing_rectangle.X = (ClientRectangle.Width - drawing_rectangle.Width) / 2;
+ } else {
+ drawing_rectangle.Height = (int) (background_image.Height * ((float)drawing_rectangle.Width / (float)background_image.Width));
+ drawing_rectangle.Y = (ClientRectangle.Height - drawing_rectangle.Height) / 2;
+ }
+ break;
+ default:
+ return;
+ }
+
+ g.DrawImage (background_image, drawing_rectangle);
+
+#else
+ using (TextureBrush b = new TextureBrush (background_image, WrapMode.Tile)) {
+ g.FillRectangle (b, ClientRectangle);
+ }
+#endif
+ }
+
+ internal virtual void DndEnter (DragEventArgs e)
+ {
+ try {
+ OnDragEnter (e);
+ } catch { }
+ }
+
+ internal virtual void DndOver (DragEventArgs e)
+ {
+ try {
+ OnDragOver (e);
+ } catch { }
+ }
+
+ internal virtual void DndDrop (DragEventArgs e)
+ {
+ try {
+ OnDragDrop (e);
+ } catch (Exception exc) {
+ Console.Error.WriteLine ("MWF: Exception while dropping:");
+ Console.Error.WriteLine (exc);
+ }
+ }
+
+ internal virtual void DndLeave (EventArgs e)
+ {
+ try {
+ OnDragLeave (e);
+ } catch { }
+ }
+
+ internal virtual void DndFeedback(GiveFeedbackEventArgs e)
+ {
+ try {
+ OnGiveFeedback(e);
+ } catch { }
+ }
+
+ internal virtual void DndContinueDrag(QueryContinueDragEventArgs e)
+ {
+ try {
+ OnQueryContinueDrag(e);
+ } catch { }
}
internal static MouseButtons FromParamToMouseButtons (int param) {
buttons |= MouseButtons.Middle;
if ((param & (int) MsgButtons.MK_RBUTTON) != 0)
- buttons |= MouseButtons.Right;
+ buttons |= MouseButtons.Right;
return buttons;
}
+ internal void FireEnter ()
+ {
+ OnEnter (EventArgs.Empty);
+ }
+
+ internal void FireLeave ()
+ {
+ OnLeave (EventArgs.Empty);
+ }
+
+ internal void FireValidating (CancelEventArgs ce)
+ {
+ OnValidating (ce);
+ }
+
+ internal void FireValidated ()
+ {
+ OnValidated (EventArgs.Empty);
+ }
+
internal virtual bool ProcessControlMnemonic(char charCode) {
return ProcessMnemonic(charCode);
}
index = -1;
}
- for (int i = 0; i < end; i++) {
+ for (int i = 0, pos = -1; i < end; i++) {
+ if (start == container.child_controls[i]) {
+ pos = i;
+ continue;
+ }
+
if (found == null) {
- if (container.child_controls[i].tab_index > index) {
+ if (container.child_controls[i].tab_index > index || (pos > -1 && pos < i && container.child_controls[i].tab_index == index)) {
found = container.child_controls[i];
}
} else if (found.tab_index > container.child_controls[i].tab_index) {
private static Control FindControlForward(Control container, Control start) {
Control found;
- Control p;
found = null;
- if (start != null) {
- if ((start is IContainerControl) || start.GetStyle(ControlStyles.ContainerControl)) {
- found = FindControlForward(start, null);
- if (found != null) {
- return found;
- }
- }
+ if (start == null) {
+ return FindFlatForward(container, start);
+ }
- p = start.parent;
- while (p != container) {
- found = FindFlatForward(p, start);
+ if (start.child_controls != null && start.child_controls.Count > 0 &&
+ (start == container || !((start is IContainerControl) && start.GetStyle(ControlStyles.ContainerControl)))) {
+ return FindControlForward(start, null);
+ }
+ else {
+ while (start != container) {
+ found = FindFlatForward(start.parent, start);
if (found != null) {
return found;
}
- start = p;
- p = p.parent;
+ start = start.parent;
}
}
- return FindFlatForward(container, start);
+ return null;
}
private static Control FindFlatBackward(Control container, Control start) {
index++;
}
- for (int i = 0; i < end; i++) {
- if (found == null) {
- if (container.child_controls[i].tab_index < index) {
- found = container.child_controls[i];
- }
- } else if (found.tab_index < container.child_controls[i].tab_index) {
- if (container.child_controls[i].tab_index < index) {
+ bool hit = false;
+
+ for (int i = end - 1; i >= 0; i--) {
+ if (start == container.child_controls[i]) {
+ hit = true;
+ continue;
+ }
+
+ if (found == null || found.tab_index < container.child_controls[i].tab_index) {
+ if (container.child_controls[i].tab_index < index || (hit && container.child_controls[i].tab_index == index))
found = container.child_controls[i];
- }
+
}
}
return found;
}
private static Control FindControlBackward(Control container, Control start) {
+
+ Control found = null;
+
+ if (start == null) {
+ found = FindFlatBackward(container, start);
+ }
+ else if (start != container) {
+ if (start.parent != null) {
+ found = FindFlatBackward(start.parent, start);
+
+ if (found == null) {
+ if (start.parent != container)
+ return start.parent;
+ return null;
+ }
+ }
+ }
+
+ if (found == null || start.parent == null)
+ found = start;
+
+ while (found != null && (found == container || (!((found is IContainerControl) && found.GetStyle(ControlStyles.ContainerControl))) &&
+ found.child_controls != null && found.child_controls.Count > 0)) {
+// while (ctl.child_controls != null && ctl.child_controls.Count > 0 &&
+// (ctl == this || (!((ctl is IContainerControl) && ctl.GetStyle(ControlStyles.ContainerControl))))) {
+ found = FindFlatBackward(found, null);
+ }
+
+ return found;
+
+/*
Control found;
found = null;
if (start != null) {
found = FindFlatBackward(start.parent, start);
- if (found == null && start.parent != container) {
- return start.parent;
+ if (found == null) {
+ if (start.parent != container) {
+ return start.parent;
+ }
}
}
if (found == null) {
found = FindFlatBackward(container, start);
}
- while ((found != null) && ((found is IContainerControl) || found.GetStyle(ControlStyles.ContainerControl))) {
- found = FindControlBackward(found, null);
- if (found != null) {
- return found;
+ if (container != start) {
+ while ((found != null) && (!found.Contains(start)) && found.child_controls != null && found.child_controls.Count > 0 && !(found is IContainerControl)) {// || found.GetStyle(ControlStyles.ContainerControl))) {
+ found = FindControlBackward(found, null);
+ if (found != null) {
+ return found;
+ }
}
}
-
return found;
+*/
}
- private void HandleClick(int clicks) {
+ internal virtual void HandleClick(int clicks, MouseEventArgs me) {
if (GetStyle(ControlStyles.StandardClick)) {
- if (clicks > 1) {
- if (GetStyle(ControlStyles.StandardDoubleClick)) {
- OnDoubleClick(EventArgs.Empty);
- } else {
- OnClick(EventArgs.Empty);
- }
+ if ((clicks > 1) && GetStyle(ControlStyles.StandardDoubleClick)) {
+#if !NET_2_0
+ OnDoubleClick(EventArgs.Empty);
} else {
OnClick(EventArgs.Empty);
+#else
+ OnDoubleClick(me);
+ } else {
+ OnClick(me);
+#endif
}
}
}
+
+ internal void CaptureWithConfine (Control ConfineWindow)
+ {
+ if (this.IsHandleCreated && !is_captured) {
+ is_captured = true;
+ XplatUI.GrabWindow (this.window.Handle, ConfineWindow.Handle);
+ }
+ }
private void CheckDataBindings ()
{
}
}
+ private void ChangeParent(Control new_parent) {
+ bool pre_enabled;
+ bool pre_visible;
+ Font pre_font;
+ Color pre_fore_color;
+ Color pre_back_color;
+ RightToLeft pre_rtl;
+
+ // These properties are inherited from our parent
+ // Get them pre parent-change and then send events
+ // if they are changed after we have our new parent
+ pre_enabled = Enabled;
+ pre_visible = Visible;
+ pre_font = Font;
+ pre_fore_color = ForeColor;
+ pre_back_color = BackColor;
+ pre_rtl = RightToLeft;
+ // MS doesn't seem to send a CursorChangedEvent
+
+ parent = new_parent;
+
+ if (IsHandleCreated)
+ XplatUI.SetParent(Handle,
+ (new_parent == null || !new_parent.IsHandleCreated) ? IntPtr.Zero : new_parent.Handle);
+
+ OnParentChanged(EventArgs.Empty);
+
+ if (pre_enabled != Enabled) {
+ OnEnabledChanged(EventArgs.Empty);
+ }
+
+ if (pre_visible != Visible) {
+ OnVisibleChanged(EventArgs.Empty);
+ }
+
+ if (pre_font != Font) {
+ OnFontChanged(EventArgs.Empty);
+ }
+
+ if (pre_fore_color != ForeColor) {
+ OnForeColorChanged(EventArgs.Empty);
+ }
+
+ if (pre_back_color != BackColor) {
+ OnBackColorChanged(EventArgs.Empty);
+ }
+
+ if (pre_rtl != RightToLeft) {
+ // MS sneaks a OnCreateControl and OnHandleCreated in here, I guess
+ // because when RTL changes they have to recreate the win32 control
+ // We don't really need that (until someone runs into compatibility issues)
+ OnRightToLeftChanged(EventArgs.Empty);
+ }
+
+ if ((new_parent != null) && new_parent.Created && is_visible && !Created) {
+ CreateControl();
+ }
+
+ if ((binding_context == null) && Created) {
+ OnBindingContextChanged(EventArgs.Empty);
+ }
+ }
+
+ private void UpdateDistances() {
+ if (parent != null) {
+ if (bounds.Width > 0)
+ dist_right = parent.ClientSize.Width - bounds.X - bounds.Width;
+ if (bounds.Height > 0)
+ dist_bottom = parent.ClientSize.Height - bounds.Y - bounds.Height;
+ }
+ }
+
+ private bool UseDoubleBuffering {
+ get {
+ if (!ThemeEngine.Current.DoubleBufferingSupported)
+ return false;
+
+#if NET_2_0
+ if (DoubleBuffered)
+ return true;
+#endif
+ return (control_style & ControlStyles.DoubleBuffer) != 0;
+ }
+ }
#endregion // Private & Internal Methods
#region Public Static Properties
return Cursor.Position;
}
}
+
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Browsable (false)]
+ [MonoTODO]
+ public static bool CheckForIllegalCrossThreadCalls
+ {
+ get {
+ return verify_thread_handle;
+ }
+
+ set {
+ verify_thread_handle = value;
+ }
+ }
+#endif
#endregion // Public Static Properties
#region Public Instance Properties
[Localizable(true)]
[DefaultValue(null)]
+ [MWFCategory("Accessibility")]
public string AccessibleDescription {
get {
return AccessibilityObject.description;
[Localizable(true)]
[DefaultValue(null)]
+ [MWFCategory("Accessibility")]
public string AccessibleName {
get {
return AccessibilityObject.Name;
}
[DefaultValue(AccessibleRole.Default)]
+ [MWFDescription("Role of the control"), MWFCategory("Accessibility")]
public AccessibleRole AccessibleRole {
get {
return AccessibilityObject.role;
}
[DefaultValue(false)]
+ [MWFCategory("Behavior")]
public virtual bool AllowDrop {
get {
- return XplatUI.State.DropTarget;
+ return allow_drop;
}
set {
- #if later
- XplatUI.State.DropTarget=value;
- #endif
+ if (allow_drop == value)
+ return;
+ allow_drop = value;
+ if (IsHandleCreated) {
+ UpdateStyles();
+ XplatUI.SetAllowDrop (Handle, value);
+ }
}
}
[Localizable(true)]
[RefreshProperties(RefreshProperties.Repaint)]
- [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
+ [DefaultValue(AnchorStyles.Top | AnchorStyles.Left)]
+ [MWFCategory("Layout")]
public virtual AnchorStyles Anchor {
get {
return anchor_style;
}
set {
+ layout_type = LayoutType.Anchor;
+
anchor_style=value;
- if (parent != null) {
- parent.PerformLayout(this, "Parent");
+ UpdateDistances ();
+
+ if (parent != null)
+ parent.PerformLayout(this, "Anchor");
+ }
+ }
+
+#if NET_2_0
+ // XXX: Implement me!
+ bool auto_size;
+
+ [RefreshProperties (RefreshProperties.All)]
+ [Localizable (true)]
+ [DesignerSerializationVisibility (DesignerSerializationVisibility.Hidden)]
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [DefaultValue (false)]
+ [MonoTODO("This method currently does nothing")]
+ public virtual bool AutoSize {
+ get { return auto_size; }
+ set {
+ if (this.auto_size != value) {
+ auto_size = value;
+ OnAutoSizeChanged (EventArgs.Empty);
+ }
+ }
+ }
+
+#if NET_2_0
+ [AmbientValue ("{Width=0, Height=0}")]
+#else
+ [AmbientValue (typeof(Size), "0, 0")]
+#endif
+ public virtual Size MaximumSize {
+ get {
+ return maximum_size;
+ }
+ set {
+ maximum_size = value;
+ }
+ }
+
+ public virtual Size MinimumSize {
+ get {
+ return minimum_size;
+ }
+ set {
+ if (minimum_size != value) {
+ minimum_size = value;
+ PerformLayout ();
}
}
}
+#endif // NET_2_0
[DispId(-501)]
+ [MWFCategory("Appearance")]
public virtual Color BackColor {
get {
if (background_color.IsEmpty) {
if (parent!=null) {
- return parent.BackColor;
+ Color pcolor = parent.BackColor;
+ if (pcolor.A == 0xff || GetStyle(ControlStyles.SupportsTransparentBackColor))
+ return pcolor;
}
return DefaultBackColor;
}
}
set {
- background_color=value;
- if (this.IsHandleCreated) {
- XplatUI.SetWindowBackground(this.window.Handle, value);
+ if (!value.IsEmpty && (value.A != 0xff) && !GetStyle(ControlStyles.SupportsTransparentBackColor)) {
+ throw new ArgumentException("Transparent background colors are not supported on this control");
+ }
+
+ if (background_color != value) {
+ background_color=value;
+ SetChildColor(this);
+ OnBackColorChanged(EventArgs.Empty);
+ Invalidate();
}
- SetChildColor(this);
- OnBackColorChanged(EventArgs.Empty);
- Invalidate();
}
}
[Localizable(true)]
[DefaultValue(null)]
+ [MWFCategory("Appearance")]
public virtual Image BackgroundImage {
get {
return background_image;
if (background_image!=value) {
background_image=value;
OnBackgroundImageChanged(EventArgs.Empty);
+ Invalidate ();
}
}
}
+#if NET_2_0
+ [DefaultValue (ImageLayout.Tile)]
+ [Localizable (true)]
+ public virtual ImageLayout BackgroundImageLayout {
+ get {
+ return backgroundimage_layout;
+ }
+ set {
+ if (Array.IndexOf (Enum.GetValues (typeof (ImageLayout)), value) == -1)
+ throw new InvalidEnumArgumentException ("value", (int) value, typeof(ImageLayout));
+
+ if (value != backgroundimage_layout) {
+ backgroundimage_layout = value;
+ Invalidate ();
+ OnBackgroundImageLayoutChanged (EventArgs.Empty);
+ }
+
+ }
+ }
+#endif
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
}
set {
- SetBoundsCore(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
+ SetBounds(value.Left, value.Top, value.Width, value.Height, BoundsSpecified.All);
}
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool CanFocus {
get {
- if (Visible && is_enabled && GetStyle(ControlStyles.Selectable)) {
+ if (IsHandleCreated && Visible && Enabled) {
return true;
}
return false;
get {
Control parent;
- if (!GetStyle(ControlStyles.Selectable) || this.parent == null) {
+ if (!GetStyle(ControlStyles.Selectable)) {
return false;
}
- parent = this.parent;
+ parent = this;
while (parent != null) {
if (!parent.is_visible || !parent.is_enabled) {
return false;
}
}
+ internal virtual bool InternalCapture {
+ get {
+ return Capture;
+ }
+
+ set {
+ Capture = value;
+ }
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
}
set {
- if (this.IsHandleCreated) {
- if (value && !is_captured) {
+ if (this.IsHandleCreated && value != is_captured) {
+ if (value) {
is_captured = true;
XplatUI.GrabWindow(this.window.Handle, IntPtr.Zero);
- } else if (!value && is_captured) {
+ } else {
XplatUI.UngrabWindow(this.window.Handle);
is_captured = false;
}
}
[DefaultValue(true)]
+ [MWFCategory("Focus")]
public bool CausesValidation {
get {
return this.causes_validation;
set {
this.SetClientSizeCore(value.Width, value.Height);
+#if NET_2_0
+ this.OnClientSizeChanged (EventArgs.Empty);
+#endif
}
}
}
}
+ internal bool ContainerSelected {
+ get { return container_selected; }
+ set { container_selected = value; }
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool ContainsFocus {
get {
- if (this.Focused) {
- return true;
- }
+ IntPtr focused_window;
- for (int i=0; i < child_controls.Count; i++) {
- if (child_controls[i].ContainsFocus) {
+ focused_window = XplatUI.GetFocus();
+ if (IsHandleCreated) {
+ if (focused_window == Handle) {
return true;
}
+
+ for (int i=0; i < child_controls.Count; i++) {
+ if (child_controls[i].ContainsFocus) {
+ return true;
+ }
+ }
}
return false;
}
}
-
+#if NET_2_0
+ [Browsable (false)]
+#endif
[DefaultValue(null)]
+ [MWFCategory("Behavior")]
public virtual ContextMenu ContextMenu {
get {
- return context_menu;
+ return GetContextMenuInternal ();
}
set {
}
}
+ internal virtual ContextMenu GetContextMenuInternal ()
+ {
+ return context_menu;
+ }
+
+#if NET_2_0
+ [DefaultValue (null)]
+ public virtual ContextMenuStrip ContextMenuStrip {
+ get { return this.context_menu_strip; }
+ set {
+ if (this.context_menu_strip != value) {
+ this.context_menu_strip = value;
+ OnContextMenuStripChanged (EventArgs.Empty);
+ }
+ }
+ }
+#endif
+
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
public ControlCollection Controls {
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool Created {
get {
- if (!this.is_disposed && (this.window.Handle != IntPtr.Zero)) {
- return true;
- }
- return false;
+ return (!is_disposed && is_created);
}
}
[AmbientValue(null)]
+ [MWFCategory("Appearance")]
public virtual Cursor Cursor {
get {
if (cursor != null) {
set {
if (cursor != value) {
- Point pt;
+ Point pt;
cursor = value;
- pt = Cursor.Position;
- if (bounds.Contains(pt)) {
- if (GetChildAtPoint(pt) == null) {
- if (cursor != null) {
- XplatUI.SetCursor(window.Handle, cursor.handle);
- } else {
- if (parent != null) {
- XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
+ if (IsHandleCreated) {
+ pt = Cursor.Position;
+
+ if (bounds.Contains(pt) || Capture) {
+ if (GetChildAtPoint(pt) == null) {
+ if (cursor != null) {
+ XplatUI.SetCursor(window.Handle, cursor.handle);
} else {
- XplatUI.SetCursor(window.Handle, Cursors.def.handle);
+ if (parent != null) {
+ XplatUI.SetCursor(window.Handle, parent.Cursor.handle);
+ } else {
+ XplatUI.SetCursor(window.Handle, Cursors.Default.handle);
+ }
}
}
}
}
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- [Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)]
+ [ParenthesizePropertyName(true)]
+ [RefreshProperties(RefreshProperties.All)]
+ [MWFCategory("Data")]
public ControlBindingsCollection DataBindings {
get {
if (data_bindings == null)
[Localizable(true)]
[RefreshProperties(RefreshProperties.Repaint)]
[DefaultValue(DockStyle.None)]
+ [MWFCategory("Layout")]
public virtual DockStyle Dock {
get {
return dock_style;
}
set {
+ layout_type = LayoutType.Dock;
+
if (dock_style == value) {
return;
}
+ if (!Enum.IsDefined (typeof (DockStyle), value)) {
+ throw new InvalidEnumArgumentException ("value", (int) value,
+ typeof (DockStyle));
+ }
+
dock_style = value;
+ if (dock_style == DockStyle.None) {
+ if (explicit_bounds == Rectangle.Empty)
+ Bounds = new Rectangle (new Point (0, 0), DefaultSize);
+ else
+ Bounds = explicit_bounds;
+ }
+
if (parent != null) {
- parent.PerformLayout(this, "Parent");
+ parent.PerformLayout(this, "Dock");
}
OnDockChanged(EventArgs.Empty);
}
}
+#if NET_2_0
+ protected virtual bool DoubleBuffered {
+ get {
+ return (control_style & ControlStyles.OptimizedDoubleBuffer) != 0;
+ }
+
+ set {
+ if (value == DoubleBuffered)
+ return;
+ if (value) {
+ SetStyle (ControlStyles.OptimizedDoubleBuffer | ControlStyles.AllPaintingInWmPaint, true);
+ } else {
+ SetStyle (ControlStyles.OptimizedDoubleBuffer, false);
+ }
+
+ }
+ }
+#endif
+
[DispId(-514)]
[Localizable(true)]
+ [MWFCategory("Behavior")]
public bool Enabled {
get {
- return is_enabled;
+ if (!is_enabled) {
+ return false;
+ }
+
+ if (parent != null) {
+ return parent.Enabled;
+ }
+
+ return true;
}
set {
- if (is_enabled == value) {
- return;
- }
+ if (this.is_enabled != value) {
+ bool old_value = is_enabled;
- is_enabled = value;
- Refresh();
- OnEnabledChanged (EventArgs.Empty);
+ is_enabled = value;
+ if (old_value != value && !value && this.has_focus)
+ SelectNextControl(this, true, true, true, true);
+
+ OnEnabledChanged (EventArgs.Empty);
+ }
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
- [Browsable(false)]
+ [Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public virtual bool Focused {
get {
}
[DispId(-512)]
- [AmbientValue(null)]
+ [AmbientValue(null)]
[Localizable(true)]
+ [MWFCategory("Appearance")]
public virtual Font Font {
get {
if (font != null) {
return DefaultFont;
}
+ [param:MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef=typeof(Font))]
set {
if (font != null && font.Equals (value)) {
return;
}
- font = value;
+ font = value;
Invalidate();
- OnFontChanged (EventArgs.Empty);
+ OnFontChanged (EventArgs.Empty);
+ PerformLayout ();
}
}
[DispId(-513)]
+ [MWFCategory("Appearance")]
public virtual Color ForeColor {
get {
if (foreground_color.IsEmpty) {
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public IntPtr Handle { // IWin32Window
get {
+#if NET_2_0
+ if (verify_thread_handle) {
+ if (this.InvokeRequired) {
+ throw new InvalidOperationException("Cross-thread access of handle detected. Handle access only valid on thread that created the control");
+ }
+ }
+#endif
if (!IsHandleCreated) {
CreateHandle();
}
}
set {
- SetBoundsCore(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
+ SetBounds(bounds.X, bounds.Y, bounds.Width, value, BoundsSpecified.Height);
}
}
[AmbientValue(ImeMode.Inherit)]
[Localizable(true)]
+ [MWFCategory("Behavior")]
public ImeMode ImeMode {
get {
+ if (ime_mode == ImeMode.Inherit) {
+ if (parent != null)
+ return parent.ImeMode;
+ else
+ return ImeMode.NoControl; // default value
+ }
return ime_mode;
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
- [Browsable(false)]
+ [Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool InvokeRequired { // ISynchronizeInvoke
get {
- if (creator_thread!=Thread.CurrentThread) {
+ if (creator_thread != null && creator_thread!=Thread.CurrentThread) {
return true;
}
return false;
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public bool IsHandleCreated {
get {
- if ((window!=null) && (window.Handle!=IntPtr.Zero)) {
- return true;
+ if ((window != null) && (window.Handle != IntPtr.Zero)) {
+ Hwnd hwnd = Hwnd.ObjectFromHandle (window.Handle);
+ if (hwnd != null && !hwnd.zombie)
+ return true;
}
return false;
}
}
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+#if NET_2_0
+ public virtual
+#endif
+ Layout.LayoutEngine LayoutEngine {
+ get {
+ if (layout_engine == null)
+ layout_engine = new Layout.DefaultLayout ();
+ return layout_engine;
+ }
+ }
+
[EditorBrowsable(EditorBrowsableState.Always)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
}
set {
- SetBoundsCore(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
+ SetBounds(value, bounds.Y, bounds.Width, bounds.Height, BoundsSpecified.X);
}
}
[Localizable(true)]
+ [MWFCategory("Layout")]
public Point Location {
get {
return new Point(bounds.X, bounds.Y);
}
set {
- SetBoundsCore(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
+ SetBounds(value.X, value.Y, bounds.Width, bounds.Height, BoundsSpecified.Location);
}
}
+#if NET_2_0
+ [Localizable (true)]
+ public Padding Margin {
+ get { return this.margin; }
+ set {
+ if (this.margin != value) {
+ this.margin = value;
+ OnMarginChanged (EventArgs.Empty);
+ }
+ }
+ }
+#endif
+
[Browsable(false)]
public string Name {
get {
- return this.name;
+ return name;
}
set {
- this.name=value;
+ name = value;
+ }
+ }
+
+#if NET_2_0
+ [Localizable(true)]
+ public Padding Padding {
+ get {
+ return padding;
+ }
+
+ set {
+ if (padding != value) {
+ padding = value;
+ OnPaddingChanged (EventArgs.Empty);
+ PerformLayout ();
+ }
}
}
+#endif
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
}
if (parent!=value) {
- if (parent!=null) {
+ if (value==null) {
parent.Controls.Remove(this);
+ parent = null;
+ return;
}
- parent=value;
-
- if (!parent.Controls.Contains(this)) {
- parent.Controls.Add(this);
- }
-
- XplatUI.SetParent(Handle, value.Handle);
-
- InitLayout();
-
- OnParentChanged(EventArgs.Empty);
+ value.Controls.Add(this);
}
}
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string ProductName {
get {
- return "Novell Mono MWF";
+ Type t = typeof (AssemblyProductAttribute);
+ Assembly assembly = GetType().Module.Assembly;
+ object [] attrs = assembly.GetCustomAttributes (t, false);
+ AssemblyProductAttribute a = null;
+ // On MS we get a NullRefException if product attribute is not
+ // set.
+ if (attrs != null && attrs.Length > 0)
+ a = (AssemblyProductAttribute) attrs [0];
+ return a.Product;
}
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public string ProductVersion {
get {
- return "1.1.4322.573";
+ Type t = typeof (AssemblyVersionAttribute);
+ Assembly assembly = GetType().Module.Assembly;
+ object [] attrs = assembly.GetCustomAttributes (t, false);
+ if (attrs == null || attrs.Length < 1)
+ return "1.0.0.0";
+ return ((AssemblyVersionAttribute)attrs [0]).Version;
}
}
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
public Region Region {
get {
- return new Region(this.bounds);
+ return clip_region;
}
set {
- Graphics g;
- RectangleF r;
+ if (clip_region != value) {
+ if (value != null && IsHandleCreated)
+ XplatUI.SetClipRegion(Handle, value);
- g = this.CreateGraphics();
- r = value.GetBounds(g);
-
- SetBounds((int)r.X, (int)r.Y, (int)r.Width, (int)r.Height);
-
- g.Dispose();
+ clip_region = value;
+#if NET_2_0
+ OnRegionChanged (EventArgs.Empty);
+#endif
+ }
}
}
[AmbientValue(RightToLeft.Inherit)]
[Localizable(true)]
+ [MWFCategory("Appearance")]
public virtual RightToLeft RightToLeft {
get {
+ if (right_to_left == RightToLeft.Inherit) {
+ if (parent != null)
+ return parent.RightToLeft;
+ else
+ return RightToLeft.No; // default value
+ }
return right_to_left;
}
if (value != right_to_left) {
right_to_left = value;
OnRightToLeftChanged(EventArgs.Empty);
+ PerformLayout ();
}
}
}
set {
base.Site = value;
+
+ if (value != null) {
+ AmbientProperties ap = (AmbientProperties) value.GetService (typeof (AmbientProperties));
+ if (ap != null) {
+ BackColor = ap.BackColor;
+ ForeColor = ap.ForeColor;
+ Cursor = ap.Cursor;
+ Font = ap.Font;
+ }
+ }
}
}
[Localizable(true)]
+ [MWFCategory("Layout")]
public Size Size {
get {
return new Size(Width, Height);
}
set {
- SetBoundsCore(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
+ SetBounds(bounds.X, bounds.Y, value.Width, value.Height, BoundsSpecified.Size);
}
}
[Localizable(true)]
[MergableProperty(false)]
+ [MWFCategory("Behavior")]
public int TabIndex {
get {
if (tab_index != -1) {
[DispId(-516)]
[DefaultValue(true)]
+ [MWFCategory("Behavior")]
public bool TabStop {
get {
return tab_stop;
[Bindable(true)]
[TypeConverter(typeof(StringConverter))]
[DefaultValue(null)]
+ [MWFCategory("Data")]
public object Tag {
get {
return control_tag;
[DispId(-517)]
[Localizable(true)]
[BindableAttribute(true)]
+ [MWFCategory("Appearance")]
public virtual string Text {
get {
+ // Our implementation ignores ControlStyles.CacheText - we always cache
return this.text;
}
if (text!=value) {
text=value;
- XplatUI.Text(Handle, text);
- // FIXME: Do we need a Refresh() here?
+ if (IsHandleCreated) {
+ /* we need to call .SetWindowStyle here instead of just .Text
+ because the presence/absence of Text (== "" or not) can cause
+ other window style things to appear/disappear */
+ XplatUI.SetWindowStyle(window.Handle, CreateParams);
+ XplatUI.Text(Handle, text);
+ }
OnTextChanged (EventArgs.Empty);
}
}
}
set {
- SetBoundsCore(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
+ SetBounds(bounds.X, value, bounds.Width, bounds.Height, BoundsSpecified.Y);
}
}
p = p.parent;
}
- return p;
+ return p is Form ? p : null;
}
}
[Localizable(true)]
+ [MWFCategory("Behavior")]
public bool Visible {
get {
if (!is_visible) {
}
set {
- SetBoundsCore(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
+ SetBounds(bounds.X, bounds.Y, value, bounds.Height, BoundsSpecified.Width);
}
}
get {
CreateParams create_params = new CreateParams();
- create_params.Caption = Text;
- create_params.X = Left;
- create_params.Y = Top;
- create_params.Width = Width;
- create_params.Height = Height;
+ try {
+ create_params.Caption = Text;
+ }
+ catch {
+ create_params.Caption = text;
+ }
+
+ try {
+ create_params.X = Left;
+ }
+ catch {
+ create_params.X = this.bounds.X;
+ }
+
+ try {
+ create_params.Y = Top;
+ }
+ catch {
+ create_params.Y = this.bounds.Y;
+ }
+
+ try {
+ create_params.Width = Width;
+ }
+ catch {
+ create_params.Width = this.bounds.Width;
+ }
+
+ try {
+ create_params.Height = Height;
+ }
+ catch {
+ create_params.Height = this.bounds.Height;
+ }
+
create_params.ClassName = XplatUI.DefaultClassName;
create_params.ClassStyle = 0;
create_params.ExStyle = 0;
create_params.Param = 0;
- if (parent!=null) {
+ if (allow_drop) {
+ create_params.ExStyle |= (int)WindowExStyles.WS_EX_ACCEPTFILES;
+ }
+
+ if ((parent!=null) && (parent.IsHandleCreated)) {
create_params.Parent = parent.Handle;
}
create_params.Style |= (int)WindowStyles.WS_VISIBLE;
}
+ if (!is_enabled) {
+ create_params.Style |= (int)WindowStyles.WS_DISABLED;
+ }
+
+ switch (border_style) {
+ case BorderStyle.FixedSingle:
+ create_params.Style |= (int) WindowStyles.WS_BORDER;
+ break;
+ case BorderStyle.Fixed3D:
+ create_params.ExStyle |= (int) WindowExStyles.WS_EX_CLIENTEDGE;
+ break;
+ }
+
return create_params;
}
}
+#if NET_2_0
+ protected virtual Cursor DefaultCursor { get { return Cursors.Default; } }
+#endif
+
protected virtual ImeMode DefaultImeMode {
get {
return ImeMode.Inherit;
}
}
+#if NET_2_0
+ protected virtual Padding DefaultMargin {
+ get { return new Padding (3); }
+ }
+
+ protected virtual Size DefaultMaximumSize { get { return new Size (); } }
+ protected virtual Size DefaultMinimumSize { get { return new Size (); } }
+ protected virtual Padding DefaultPadding { get { return new Padding (); } }
+#endif
+
protected virtual Size DefaultSize {
get {
- return new Size(100, 23);
+ return new Size(0, 0);
}
}
;; // Nothing to do
}
}
-
+#if NET_2_0
+ [Obsolete ()]
+#endif
protected bool RenderRightToLeft {
get {
return (this.right_to_left == RightToLeft.Yes);
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
[DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+#if NET_2_0
+ internal virtual
+#endif
protected bool ShowKeyboardCues {
get {
return true;
#region Public Static Methods
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static Control FromChildHandle(IntPtr handle) {
- IEnumerator control = Control.controls.GetEnumerator();
-
- while (control.MoveNext()) {
- if (((Control)control.Current).window.Handle == handle) {
- // Found it
- if (((Control)control.Current).Parent != null) {
- return ((Control)control.Current).Parent;
- }
- }
- }
- return null;
+ return Control.ControlNativeWindow.ControlFromChildHandle (handle);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public static Control FromHandle(IntPtr handle) {
- IEnumerator control = Control.controls.GetEnumerator();
-
- while (control.MoveNext()) {
- if (((Control)control.Current).window.Handle == handle) {
- // Found it
- return ((Control)control.Current);
- }
- }
- return null;
+ return Control.ControlNativeWindow.ControlFromHandle(handle);
}
public static bool IsMnemonic(char charCode, string text) {
- int amp;
+ int amp;
amp = text.IndexOf('&');
#region Public Instance Methods
[EditorBrowsable(EditorBrowsableState.Advanced)]
public IAsyncResult BeginInvoke(Delegate method) {
- return BeginInvokeInternal(method, null);
+ object [] prms = null;
+ if (method is EventHandler)
+ prms = new object [] { this, EventArgs.Empty };
+ return BeginInvokeInternal(method, prms, false);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
public IAsyncResult BeginInvoke (Delegate method, object[] args) {
- return BeginInvokeInternal (method, args);
+ return BeginInvokeInternal (method, args, false);
}
public void BringToFront() {
- if ((parent != null) && (parent.child_controls[0]!=this)) {
- if (parent.child_controls.Contains(this)) {
- parent.child_controls.SetChildIndex(this, 0);
- }
- }
-
- XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, true, false);
-
if (parent != null) {
+ parent.child_controls.SetChildIndex(this, 0);
parent.Refresh();
+ } else {
+ XplatUI.SetZOrder(Handle, IntPtr.Zero, false, false);
}
}
return false;
}
- public void CreateControl() {
+ public void CreateControl ()
+ {
+ if (is_disposed) {
+ throw new ObjectDisposedException(GetType().FullName.ToString());
+ }
+ if (is_created) {
+ return;
+ }
if (!IsHandleCreated) {
CreateHandle();
}
- if (!create_handled) {
- create_handled = true;
- OnCreateControl();
+ if (!is_created) {
+ is_created = true;
}
- for (int i=0; i<child_controls.Count; i++) {
- child_controls[i].CreateControl();
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i<controls.Length; i++) {
+ if (controls [i].is_visible)
+ controls [i].CreateControl ();
+ }
+
+ UpdateChildrenZOrder();
+
+ if (binding_context == null) { // seem to be sent whenever it's null?
+ OnBindingContextChanged(EventArgs.Empty);
}
+
+ OnCreateControl();
}
public Graphics CreateGraphics() {
if (!IsHandleCreated) {
- this.CreateControl();
+ this.CreateHandle();
}
return Graphics.FromHwnd(this.window.Handle);
}
- [MonoTODO("Come up with cross platform drag-drop driver interface")]
public DragDropEffects DoDragDrop(object data, DragDropEffects allowedEffects) {
- return DragDropEffects.None;
+ return XplatUI.StartDrag(this.window.Handle, data, allowedEffects);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
}
return null;
}
-
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
public bool Focus() {
- if (IsHandleCreated && !has_focus) {
- has_focus = true;
- XplatUI.SetFocus(window.Handle);
+ if (CanFocus && IsHandleCreated && !has_focus && !is_focusing) {
+ is_focusing = true;
+ Select(this);
+ is_focusing = false;
}
- return true;
+ return has_focus;
}
public Control GetChildAtPoint(Point pt) {
}
public Control GetNextControl(Control ctl, bool forward) {
- // If we're not a container we don't play
- if (!(this is IContainerControl) && !this.GetStyle(ControlStyles.ContainerControl)) {
- return null;
- }
- // If ctl is not contained by this, we start at the first child of this
if (!this.Contains(ctl)) {
- ctl = null;
+ ctl = this;
}
- // Search through our controls, starting at ctl, stepping into children as we encounter them
- // try to find the control with the tabindex closest to our own, or, if we're looking into
- // child controls, the one with the smallest tabindex
if (forward) {
- return FindControlForward(this, ctl);
+ ctl = FindControlForward(this, ctl);
+ }
+ else {
+ ctl = FindControlBackward(this, ctl);
+ }
+
+ if (ctl != this) {
+ return ctl;
}
- return FindControlBackward(this, ctl);
+ return null;
+ }
+
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public virtual Size GetPreferredSize (Size proposedSize) {
+ return preferred_size;
}
+#endif
public void Hide() {
this.Visible = false;
}
public void Invalidate(System.Drawing.Rectangle rc, bool invalidateChildren) {
- if (!IsHandleCreated || !Visible) {
+ // Win32 invalidates control including when Width and Height is equal 0
+ // or is not visible, only Paint event must be care about this.
+ if (!IsHandleCreated)
return;
- }
- NotifyInvalidate(rc);
+ if (rc.Width > 0 && rc.Height > 0) {
+
+ NotifyInvalidate(rc);
- XplatUI.Invalidate(Handle, rc, false);
+ XplatUI.Invalidate(Handle, rc, false);
- if (invalidateChildren) {
- for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
+ if (invalidateChildren) {
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i<controls.Length; i++)
+ controls [i].Invalidate ();
+ }
}
OnInvalidated(new InvalidateEventArgs(rc));
}
Invalidate(region, false);
}
- [MonoTODO("Figure out if GetRegionScans is usable")]
public void Invalidate(System.Drawing.Region region, bool invalidateChildren) {
- throw new NotImplementedException();
-
- // FIXME - should use the GetRegionScans function of the region to invalidate each area
- //if (invalidateChildren) {
- // for (int i=0; i<child_controls.Count; i++) child_controls[i].Invalidate();
- //}
+ RectangleF bounds = region.GetBounds (CreateGraphics ());
+ Invalidate (new Rectangle ((int) bounds.X, (int) bounds.Y, (int) bounds.Width, (int) bounds.Height),
+ invalidateChildren);
}
public object Invoke (Delegate method) {
- return Invoke(method, null);
+ object [] prms = null;
+ if (method is EventHandler)
+ prms = new object [] { this, EventArgs.Empty };
+
+ return Invoke(method, prms);
}
public object Invoke (Delegate method, object[] args) {
+ if (!this.InvokeRequired) {
+ return method.DynamicInvoke(args);
+ }
+
IAsyncResult result = BeginInvoke (method, args);
return EndInvoke(result);
}
+ internal object InvokeInternal (Delegate method, bool disposing) {
+ return InvokeInternal(method, null, disposing);
+ }
+
+ internal object InvokeInternal (Delegate method, object[] args, bool disposing) {
+ if (!this.InvokeRequired) {
+ return method.DynamicInvoke(args);
+ }
+
+ IAsyncResult result = BeginInvokeInternal (method, args, disposing);
+ return EndInvoke(result);
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void PerformLayout() {
PerformLayout(null, null);
}
+ internal void SetImplicitBounds (int x, int y, int width, int height)
+ {
+ Rectangle saved_bounds = explicit_bounds;
+ SetBounds (x, y, width, height);
+ explicit_bounds = saved_bounds;
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
public void PerformLayout(Control affectedControl, string affectedProperty) {
LayoutEventArgs levent = new LayoutEventArgs(affectedControl, affectedProperty);
- if (layout_suspended>0) {
+ if (layout_suspended > 0) {
layout_pending = true;
return;
}
// Perform all Dock and Anchor calculations
try {
- Control child;
- AnchorStyles anchor;
- Rectangle space;
- int diff_width;
- int diff_height;
-
- space=this.DisplayRectangle;
- if (prev_size != Size.Empty) {
- diff_width = space.Width - prev_size.Width;
- diff_height = space.Height - prev_size.Height;
- } else {
- diff_width = 0;
- diff_height = 0;
- }
-
- // Deal with docking; go through in reverse, MS docs say that lowest Z-order is closest to edge
- for (int i = child_controls.Count - 1; i >= 0; i--) {
- child=child_controls[i];
- switch (child.Dock) {
- case DockStyle.None: {
- // Do nothing
- break;
- }
-
- case DockStyle.Left: {
- child.SetBounds(space.Left, space.Y, child.Width, space.Height);
- space.X+=child.Width;
- space.Width-=child.Width;
- break;
- }
-
- case DockStyle.Top: {
- child.SetBounds(space.Left, space.Y, space.Width, child.Height);
- space.Y+=child.Height;
- space.Height-=child.Height;
- break;
- }
-
- case DockStyle.Right: {
- child.SetBounds(space.Right-child.Width, space.Y, child.Width, space.Height);
- space.Width-=child.Width;
- break;
- }
-
- case DockStyle.Bottom: {
- child.SetBounds(space.Left, space.Bottom-child.Height, space.Width, child.Height);
- space.Height-=child.Height;
- break;
- }
- }
- }
-
- for (int i = child_controls.Count - 1; i >= 0; i--) {
- child=child_controls[i];
-
- if (child.Dock == DockStyle.Fill) {
- child.SetBounds(space.Left, space.Top, space.Width, space.Height);
- space.Width=0;
- space.Height=0;
- }
- }
-
- space=this.DisplayRectangle;
-
- // Deal with anchoring
- for (int i=0; i < child_controls.Count; i++) {
- int left;
- int top;
- int width;
- int height;
-
- child=child_controls[i];
- anchor=child.Anchor;
-
- left=child.Left;
- top=child.Top;
- width=child.Width;
- height=child.Height;
-
- // If the control is docked we don't need to do anything
- if (child.Dock != DockStyle.None) {
- continue;
- }
-
- if ((anchor & AnchorStyles.Left) !=0 ) {
- if ((anchor & AnchorStyles.Right) != 0) {
- // Anchoring to left and right
- width=width+diff_width;
- } else {
- ; // nothing to do
- }
- } else if ((anchor & AnchorStyles.Right) != 0) {
- left+=diff_width;
- } else {
- left+=diff_width/2;
- }
-
- if ((anchor & AnchorStyles.Top) !=0 ) {
- if ((anchor & AnchorStyles.Bottom) != 0) {
- height+=diff_height;
- } else {
- ; // nothing to do
- }
- } else if ((anchor & AnchorStyles.Bottom) != 0) {
- top+=diff_height;
- } else {
- top+=diff_height/2;
- }
-
- // Sanity
- if (width < 0) {
- width=0;
- }
-
- if (height < 0) {
- height=0;
- }
-
- child.SetBounds(left, top, width, height);
- }
-
- // Let everyone know
OnLayout(levent);
}
}
public virtual bool PreProcessMessage(ref Message msg) {
+ return InternalPreProcessMessage (ref msg);
+ }
+
+ internal virtual bool InternalPreProcessMessage (ref Message msg) {
Keys key_data;
if ((msg.Msg == (int)Msg.WM_KEYDOWN) || (msg.Msg == (int)Msg.WM_SYSKEYDOWN)) {
- key_data = (Keys)msg.WParam.ToInt32();
+ key_data = (Keys)msg.WParam.ToInt32() | XplatUI.State.ModifierKeys;
+
if (!ProcessCmdKey(ref msg, key_data)) {
if (IsInputKey(key_data)) {
- return true;
+ return false;
}
return ProcessDialogKey(key_data);
return true;
} else if (msg.Msg == (int)Msg.WM_CHAR) {
if (IsInputChar((char)msg.WParam)) {
- return true;
+ return false;
}
+ return ProcessDialogChar((char)msg.WParam);
} else if (msg.Msg == (int)Msg.WM_SYSCHAR) {
- if (IsInputChar((char)msg.WParam)) {
- return true;
- }
return ProcessDialogChar((char)msg.WParam);
}
return false;
return new Rectangle(PointToScreen(r.Location), r.Size);
}
- public virtual void Refresh() {
- if (IsHandleCreated == true) {
+ public virtual void Refresh() {
+ if (IsHandleCreated) {
Invalidate();
XplatUI.UpdateWindow(window.Handle);
+
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i < controls.Length; i++) {
+ controls[i].Refresh();
+ }
+
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void ResetBackColor() {
- background_color = Color.Empty;
+ BackColor = Color.Empty;
}
-#if haveDataBindings
- [EditorBrowsable(EditorBrowsableState.Never)]
- [MonoTODO]
+ [EditorBrowsable(EditorBrowsableState.Never)]
public void ResetBindings() {
- // Do something
+ data_bindings.Clear();
}
-#endif
[EditorBrowsable(EditorBrowsableState.Never)]
public virtual void ResetCursor() {
- cursor = null;
+ Cursor = null;
}
[EditorBrowsable(EditorBrowsableState.Never)]
}
public virtual void ResetText() {
- text = null;
+ text = String.Empty;
}
public void ResumeLayout() {
}
public void ResumeLayout(bool performLayout) {
- layout_suspended--;
-
if (layout_suspended > 0) {
- return;
+ layout_suspended--;
}
- if (performLayout || layout_pending) {
- PerformLayout();
+ if (layout_suspended == 0) {
+ if (performLayout && layout_pending) {
+ PerformLayout();
+ }
}
}
-
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Obsolete ()]
+#endif
public void Scale(float ratio) {
ScaleCore(ratio, ratio);
}
-
+
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ [Obsolete ()]
+#endif
public void Scale(float dx, float dy) {
ScaleCore(dx, dy);
}
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ public void Scale(SizeF factor) {
+ ScaleCore(factor.Width, factor.Height);
+ }
+#endif
+
public void Select() {
- Select(false, false);
+ if (this is ContainerControl)
+ ContainerSelected = true;
+ else {
+ Control c = this.Parent;
+ while (c != null) {
+ c.ContainerSelected = false;
+ c = c.Parent;
+ }
+ }
+ Select(false, false);
}
+#if DebugFocus
+ private void printTree(Control c, string t) {
+ foreach(Control i in c.child_controls) {
+ Console.WriteLine("{2}{0}.TabIndex={1}", i, i.tab_index, t);
+ printTree(i, t+"\t");
+ }
+ }
+#endif
public bool SelectNextControl(Control ctl, bool forward, bool tabStopOnly, bool nested, bool wrap) {
Control c;
-
+
+#if DebugFocus
+ Console.WriteLine("{0}", this.FindForm());
+ printTree(this, "\t");
+#endif
+
+ if (!this.Contains(ctl) || (!nested && (ctl.parent != this))) {
+ ctl = null;
+ }
c = ctl;
do {
c = GetNextControl(c, forward);
break;
}
- if (c.CanSelect && ((c.parent == ctl.parent) || nested) && (c.tab_stop || !tabStopOnly)) {
- Select(c);
+ if (c.CanSelect && ((c.parent == this) || nested) && (c.tab_stop || !tabStopOnly)) {
+ c.Select (true, true);
return true;
}
- } while (c != ctl); // If we wrap back to ourselves we stop
+ } while (c != ctl); // If we wrap back to ourselves we stop
return false;
}
public void SendToBack() {
- if ((parent != null) && (parent.child_controls[parent.child_controls.Count-1]!=this)) {
- if (parent.child_controls.Contains(this)) {
- parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
- }
- }
-
- XplatUI.SetZOrder(this.window.Handle, IntPtr.Zero, false, true);
if (parent != null) {
- parent.Refresh();
+ parent.child_controls.SetChildIndex(this, parent.child_controls.Count);
}
}
public void SetBounds(int x, int y, int width, int height) {
- SetBoundsCore(x, y, width, height, BoundsSpecified.All);
+ SetBounds(x, y, width, height, BoundsSpecified.All);
}
public void SetBounds(int x, int y, int width, int height, BoundsSpecified specified) {
+ if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
+ x = Left;
+ }
+
+ if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
+ y = Top;
+ }
+
+ if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
+ width = Width;
+ }
+
+ if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
+ height = Height;
+ }
+
SetBoundsCore(x, y, width, height, specified);
+ if (parent != null) {
+ parent.PerformLayout(this, "Bounds");
+ }
}
- public void Show() {
- if (!IsHandleCreated) {
+ public void Show ()
+ {
+ if (!is_created) {
this.CreateControl();
}
}
public void Update() {
- XplatUI.UpdateWindow(window.Handle);
+ if (IsHandleCreated) {
+ XplatUI.UpdateWindow(window.Handle);
+ }
}
#endregion // Public Instance Methods
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void CreateHandle() {
if (IsDisposed) {
- throw new ObjectDisposedException(Name);
+ throw new ObjectDisposedException(GetType().FullName.ToString());
}
- if (IsHandleCreated) {
+ if (IsHandleCreated && !is_recreating) {
return;
}
- if (window==null) {
- window = new ControlNativeWindow(this);
- window.CreateHandle(CreateParams);
+ window.CreateHandle(CreateParams);
- // Find out where the window manager placed us
- UpdateBounds();
- UpdateStyles();
- }
+ if (window.Handle != IntPtr.Zero) {
+ creator_thread = Thread.CurrentThread;
- if (window.Handle!=IntPtr.Zero) {
- if (!controls.Contains(window.Handle)) {
- controls.Add(this);
+ XplatUI.EnableWindow(window.Handle, is_enabled);
+ XplatUI.SetVisible(window.Handle, is_visible, true);
+
+ if (clip_region != null) {
+ XplatUI.SetClipRegion(Handle, clip_region);
}
- creator_thread = Thread.CurrentThread;
+ // Set our handle with our parent
+ if ((parent != null) && (parent.IsHandleCreated)) {
+ XplatUI.SetParent(window.Handle, parent.Handle);
+ }
+
+ // Set our handle as parent for our children
+ Control [] children;
- XplatUI.SetWindowBackground(window.Handle, this.BackColor);
+ children = child_controls.GetAllControls ();
+ for (int i = 0; i < children.Length; i++ ) {
+ if (!children[i].RecreatingHandle)
+ XplatUI.SetParent(children[i].Handle, window.Handle);
+ }
+
+ UpdateStyles();
+ XplatUI.SetAllowDrop (Handle, allow_drop);
+
+ // Find out where the window manager placed us
+ if ((CreateParams.Style & (int)WindowStyles.WS_CHILD) != 0) {
+ XplatUI.SetBorderStyle(window.Handle, (FormBorderStyle)border_style);
+ }
+ UpdateBounds();
OnHandleCreated(EventArgs.Empty);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void DestroyHandle() {
if (IsHandleCreated) {
- // Destroy our children before we destroy ourselves, to prevent them from
- // being implictly (without us knowing) destroyed
- for (int i=0; i < child_controls.Count; i++) {
- child_controls[i].DestroyHandle();
- }
-
-
if (window != null) {
window.DestroyHandle();
}
- OnHandleDestroyed(EventArgs.Empty);
}
}
- protected bool GetStyle(ControlStyles flag) {
+#if NET_2_0
+ protected virtual AccessibleObject GetAccessibilityObjectById (int objectId)
+ {
+ throw new NotImplementedException ();
+ }
+#endif
+
+ protected internal bool GetStyle(ControlStyles flag) {
return (control_style & flag) != 0;
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void InitLayout() {
- if (parent != null) {
- parent.PerformLayout(this, "parent");
- }
+ UpdateDistances();
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
}
protected virtual bool IsInputChar (char charCode) {
- if (parent != null) {
- return parent.IsInputChar(charCode);
- }
-
- return false;
+ return true;
}
protected virtual bool IsInputKey (Keys keyData) {
KeyEventArgs key_event;
switch (msg.Msg) {
+ case (int)Msg.WM_SYSKEYDOWN:
case (int)Msg.WM_KEYDOWN: {
key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
OnKeyDown (key_event);
return key_event.Handled;
}
+
+ case (int)Msg.WM_SYSKEYUP:
case (int)Msg.WM_KEYUP: {
key_event = new KeyEventArgs ((Keys)msg.WParam.ToInt32 ());
OnKeyUp (key_event);
return key_event.Handled;
}
+ case (int)Msg.WM_SYSCHAR:
case (int)Msg.WM_CHAR: {
KeyPressEventArgs key_press_event;
key_press_event = new KeyPressEventArgs((char)msg.WParam);
OnKeyPress(key_press_event);
+#if NET_2_0
+ msg.WParam = (IntPtr)key_press_event.KeyChar;
+#endif
return key_press_event.Handled;
}
}
}
- return false;
+ return ProcessKeyEventArgs(ref msg);
}
protected virtual bool ProcessKeyPreview(ref Message msg) {
// MS Internal
}
+ private void SetIsRecreating ()
+ {
+ is_recreating=true;
+
+ foreach (Control c in Controls.GetAllControls()) {
+ c.SetIsRecreating ();
+ }
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected void RecreateHandle() {
- IEnumerator child = child_controls.GetEnumerator();
+#if DebugRecreate
+ Console.WriteLine("Recreating control {0}", XplatUI.Window(window.Handle));
+#endif
- is_recreating=true;
+ SetIsRecreating ();
if (IsHandleCreated) {
+#if DebugRecreate
+ Console.WriteLine(" + handle is created, destroying it.");
+#endif
DestroyHandle();
- CreateHandle();
-
- // FIXME ZOrder?
-
- while (child.MoveNext()) {
- ((Control)child.Current).RecreateHandle();
- }
+ // WM_DESTROY will CreateHandle for us
} else {
- CreateControl();
+#if DebugRecreate
+ Console.WriteLine(" + handle is not created, creating it.");
+#endif
+ if (!is_created) {
+ CreateControl();
+ } else {
+ CreateHandle();
+ }
+
+ is_recreating = false;
+#if DebugRecreate
+ Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
+#endif
}
- is_recreating = false;
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
return RtlTranslateAlignment(align);
}
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Never)]
+#else
[EditorBrowsable(EditorBrowsableState.Advanced)]
+#endif
protected virtual void ScaleCore(float dx, float dy) {
Point location;
Size size;
location = new Point((int)(Left * dx), (int)(Top * dy));
size = this.ClientSize;
-
if (!GetStyle(ControlStyles.FixedWidth)) {
size.Width = (int)(size.Width * dx);
size.Height = (int)(size.Height * dy);
}
- Location = location;
- ClientSize = size;
+ SetBounds(location.X, location.Y, size.Width, size.Height, BoundsSpecified.All);
/* Now scale our children */
- for (int i=0; i < child_controls.Count; i++) {
- child_controls[i].Scale(dx, dy);
+ Control [] controls = child_controls.GetAllControls ();
+ for (int i=0; i < controls.Length; i++) {
+ controls[i].Scale(dx, dy);
}
ResumeLayout();
}
protected virtual void Select(bool directed, bool forward) {
- int index;
- bool result;
-
- if (!directed) {
- // Select this control
- Select(this);
- return;
- }
-
- if (parent == null) {
- return;
- }
-
- // FIXME - this thing is doing the wrong stuff, needs to be similar to SelectNextControl
-
- index = parent.child_controls.IndexOf(this);
- result = false;
-
- do {
- if (forward) {
- if ((index+1) < parent.child_controls.Count) {
- index++;
- } else {
- index = 0;
- }
- } else {
- if (index>0) {
- index++;
- } else {
- index = parent.child_controls.Count-1;
- }
- }
- result = Select(parent.child_controls[index]);
- } while (!result && parent.child_controls[index] != this);
+ IContainerControl container;
+
+ container = GetContainerControl();
+ if (container != null && (Control)container != this)
+ if (!this.Parent.ContainerSelected)
+ container.ActiveControl = this;
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void SetBoundsCore(int x, int y, int width, int height, BoundsSpecified specified) {
// SetBoundsCore updates the Win32 control itself. UpdateBounds updates the controls variables and fires events, I'm guessing - pdb
- if ((specified & BoundsSpecified.X) != BoundsSpecified.X) {
- x = Left;
- }
-
- if ((specified & BoundsSpecified.Y) != BoundsSpecified.Y) {
- y = Top;
- }
-
- if ((specified & BoundsSpecified.Width) != BoundsSpecified.Width) {
- width = Width;
- }
-
- if ((specified & BoundsSpecified.Height) != BoundsSpecified.Height) {
- height = Height;
- }
-
if (IsHandleCreated) {
XplatUI.SetWindowPos(Handle, x, y, width, height);
+
+ // Win32 automatically changes negative width/height to 0.
+ // The control has already been sent a WM_WINDOWPOSCHANGED message and it has the correct
+ // data, but it'll be overwritten when we call UpdateBounds unless we get the updated
+ // size.
+ if (width < 0 || height < 0) {
+ int cw, ch, ix, iy;
+ XplatUI.GetWindowPos(Handle, this is Form, out ix, out iy, out width, out height, out cw, out ch);
+ }
}
+
UpdateBounds(x, y, width, height);
+
+ UpdateDistances();
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void SetClientSizeCore(int x, int y) {
- // Calculate the actual window size from the client size (it usually stays the same or grows)
- Rectangle ClientRect;
- Rectangle WindowRect;
- CreateParams cp;
-
- ClientRect = new Rectangle(0, 0, x, y);
- cp = this.CreateParams;
-
- if (XplatUI.CalculateWindowRect(Handle, ref ClientRect, cp.Style, cp.ExStyle, IntPtr.Zero, out WindowRect)==false) {
- return;
- }
-
- SetBoundsCore(bounds.X, bounds.Y, WindowRect.Width, WindowRect.Height, BoundsSpecified.Size);
+ Size NewSize = SizeFromClientSize (new Size (x, y));
+
+ if (NewSize != Size.Empty)
+ SetBounds (bounds.X, bounds.Y, NewSize.Width, NewSize.Height, BoundsSpecified.Size);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
- protected void SetStyle(ControlStyles flag, bool value) {
+ protected internal void SetStyle(ControlStyles flag, bool value) {
if (value) {
control_style |= flag;
} else {
control_style &= ~flag;
}
- OnStyleChanged(EventArgs.Empty);
}
protected void SetTopLevel(bool value) {
if ((GetTopLevel() != value) && (parent != null)) {
- throw new Exception();
+ throw new ArgumentException ("Cannot change toplevel style of a parented control.");
}
if (this is Form) {
}
} else {
if (Visible) {
- Visible = false;
+ Visible = false;
}
}
}
protected virtual void SetVisibleCore(bool value) {
if (value!=is_visible) {
- is_visible=value;
- XplatUI.SetVisible(Handle, value);
- // Explicitly move Toplevel windows to where we want them;
- // apparently moving unmapped toplevel windows doesn't work
- if (is_visible && (this is Form)) {
- XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
+ if (value && ((window.Handle == IntPtr.Zero) || !is_created)) {
+ CreateControl();
}
- OnVisibleChanged(EventArgs.Empty);
- if (!is_visible) {
- if (dc_mem != null) {
- dc_mem.Dispose();
- dc_mem = null;
- }
+ is_visible=value;
- if (bmp_mem != null) {
- bmp_mem.Dispose();
- bmp_mem = null;
+ if (IsHandleCreated) {
+ XplatUI.SetVisible(Handle, value, true);
+ // Explicitly move Toplevel windows to where we want them;
+ // apparently moving unmapped toplevel windows doesn't work
+ if (is_visible && (this is Form)) {
+ XplatUI.SetWindowPos(window.Handle, bounds.X, bounds.Y, bounds.Width, bounds.Height);
}
- } else {
- this.CreateBuffers(bounds.Width, bounds.Height);
-
- CreateControl();
}
- if (value == false && parent != null) {
+ OnVisibleChanged(EventArgs.Empty);
+
+ if (value == false && parent != null && Focused) {
Control container;
// Need to start at parent, GetContainerControl might return ourselves if we're a container
if (parent != null) {
parent.PerformLayout(this, "visible");
} else {
- PerformLayout(this, "visible");
+ if (is_visible)
+ PerformLayout(this, "visible");
}
}
}
-
+
+#if NET_2_0
+ protected
+#else
+ internal
+#endif
+ virtual Size SizeFromClientSize (Size clientSize)
+ {
+ Rectangle ClientRect;
+ Rectangle WindowRect;
+ CreateParams cp;
+
+ ClientRect = new Rectangle (0, 0, clientSize.Width, clientSize.Height);
+ cp = this.CreateParams;
+
+ if (XplatUI.CalculateWindowRect (ref ClientRect, cp.Style, cp.ExStyle, null, out WindowRect))
+ return new Size (WindowRect.Width, WindowRect.Height);
+
+ return Size.Empty;
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected void UpdateBounds() {
int x;
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected void UpdateBounds(int x, int y, int width, int height) {
+ CreateParams cp;
+ Rectangle rect;
+
+ // Calculate client rectangle
+ rect = new Rectangle(0, 0, 0, 0);
+ cp = CreateParams;
+
+ XplatUI.CalculateWindowRect(ref rect, cp.Style, cp.ExStyle, cp.menu, out rect);
+ UpdateBounds(x, y, width, height, width - (rect.Right - rect.Left), height - (rect.Bottom - rect.Top));
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
// UpdateBounds only seems to set our sizes and fire events but not update the GUI window to match
bool moved = false;
bool resized = false;
- int client_x_diff = this.bounds.Width-this.client_size.Width;
- int client_y_diff = this.bounds.Height-this.client_size.Height;
-
// Needed to generate required notifications
if ((this.bounds.X!=x) || (this.bounds.Y!=y)) {
moved=true;
bounds.Width=width;
bounds.Height=height;
- // Update client rectangle as well
- if (this.layout_suspended==0) {
- prev_size.Width=client_size.Width;
- prev_size.Height=client_size.Height;
- }
+ // Assume explicit bounds set. SetImplicitBounds will restore old bounds
+ explicit_bounds = bounds;
- client_size.Width=width-client_x_diff;
- client_size.Height=height-client_y_diff;
+ client_size.Width=clientWidth;
+ client_size.Height=clientHeight;
if (moved) {
OnLocationChanged(EventArgs.Empty);
if (resized) {
OnSizeChanged(EventArgs.Empty);
+#if NET_2_0
+ OnClientSizeChanged (EventArgs.Empty);
+#endif
}
}
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- protected void UpdateBounds(int x, int y, int width, int height, int clientWidth, int clientHeight) {
- UpdateBounds(x, y, width, height);
-
- this.client_size.Width=clientWidth;
- this.client_size.Height=clientHeight;
- }
-
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected void UpdateStyles() {
if (!IsHandleCreated) {
}
XplatUI.SetWindowStyle(window.Handle, CreateParams);
+ OnStyleChanged(EventArgs.Empty);
}
- [EditorBrowsable(EditorBrowsableState.Advanced)]
- protected void UpdateZOrder() {
- int children;
-#if not
- Control ctl;
+ private void UpdateZOrderOfChild(Control child) {
+ if (IsHandleCreated && child.IsHandleCreated && (child.parent == this)) {
+ int index;
- if (parent == null) {
- return;
+ index = child_controls.IndexOf(child);
+
+ if (index > 0) {
+ XplatUI.SetZOrder(child.Handle, child_controls[index - 1].Handle, false, false);
+ } else {
+ IntPtr after = AfterTopMostControl ();
+ if (after != IntPtr.Zero)
+ XplatUI.SetZOrder (child.Handle, after, false, false);
+ else
+ XplatUI.SetZOrder (child.Handle, IntPtr.Zero, true, false);
+ }
}
+ }
+
+ // Override this if there is a control that shall always remain on
+ // top of other controls (such as scrollbars). If there are several
+ // of these controls, the bottom-most should be returned.
+ internal virtual IntPtr AfterTopMostControl ()
+ {
+ return IntPtr.Zero;
+ }
- ctl = parent;
+ private void UpdateChildrenZOrder() {
+ Control [] controls;
- children = ctl.child_controls.Count;
- for (int i = 1; i < children; i++ ) {
- XplatUI.SetZOrder(ctl.child_controls[i].window.Handle, ctl.child_controls[i-1].window.Handle, false, false);
+ if (!IsHandleCreated) {
+ return;
}
-#else
- children = child_controls.Count;
- for (int i = 1; i < children; i++ ) {
- XplatUI.SetZOrder(child_controls[i].window.Handle, child_controls[i-1].window.Handle, false, false);
+
+ controls = child_controls.GetAllControls ();
+ for (int i = 1; i < controls.Length; i++ ) {
+ XplatUI.SetZOrder(controls[i].Handle, controls[i-1].Handle, false, false);
+ }
+ }
+
+ [EditorBrowsable(EditorBrowsableState.Advanced)]
+ protected void UpdateZOrder() {
+ if (parent != null) {
+ parent.UpdateZOrderOfChild(this);
}
-#endif
}
protected virtual void WndProc(ref Message m) {
#if debug
- Console.WriteLine("Control received message {0}", (Msg)m.Msg);
+ Console.WriteLine("Control {0} received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString ());
#endif
if ((this.control_style & ControlStyles.EnableNotifyMessage) != 0) {
OnNotifyMessage(m);
}
switch((Msg)m.Msg) {
- case Msg.WM_WINDOWPOSCHANGED: {
- if (Visible) {
- UpdateBounds();
- if (GetStyle(ControlStyles.ResizeRedraw)) {
- Invalidate();
- }
- }
- return;
+ case Msg.WM_DESTROY: {
+ OnHandleDestroyed(EventArgs.Empty);
+#if DebugRecreate
+ IntPtr handle = window.Handle;
+#endif
+ window.InvalidateHandle();
+
+ if (is_recreating) {
+#if DebugRecreate
+ Console.WriteLine ("Creating handle for {0:X}", handle.ToInt32());
+#endif
+ CreateHandle();
+#if DebugRecreate
+ Console.WriteLine (" + new handle = {0:X}", Handle.ToInt32());
+#endif
+ is_recreating = false;
}
+ return;
+ }
- case Msg.WM_PAINT: {
- PaintEventArgs paint_event;
+ case Msg.WM_WINDOWPOSCHANGED: {
+ if (Visible) {
+ Rectangle save_bounds = explicit_bounds;
+ UpdateBounds();
+ explicit_bounds = save_bounds;
+ if (GetStyle(ControlStyles.ResizeRedraw)) {
+ Invalidate();
+ }
+ }
+ return;
+ }
- paint_event = XplatUI.PaintEventStart(Handle);
+ // Nice description of what should happen when handling WM_PAINT
+ // can be found here: http://pluralsight.com/wiki/default.aspx/Craig/FlickerFreeControlDrawing.html
+ // and here http://msdn.microsoft.com/msdnmag/issues/06/03/WindowsFormsPerformance/
+ case Msg.WM_PAINT: {
+ PaintEventArgs paint_event;
- if ((control_style & (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) == (ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint)) {
- OnPaintBackground(paint_event);
- }
+ paint_event = XplatUI.PaintEventStart(Handle, true);
- OnPaint(paint_event);
- XplatUI.PaintEventEnd(Handle);
-
- if (!GetStyle(ControlStyles.UserPaint)) {
- DefWndProc(ref m);
- }
-
- return;
- }
-
- case Msg.WM_ERASEBKGND: {
- if (GetStyle (ControlStyles.UserPaint)) {
- if (!GetStyle(ControlStyles.AllPaintingInWmPaint)) {
- PaintEventArgs eraseEventArgs = new PaintEventArgs (m.WParam == IntPtr.Zero ? Graphics.FromHwnd (m.HWnd) :
- Graphics.FromHdc (m.WParam), new Rectangle (new Point (0,0),Size));
- OnPaintBackground (eraseEventArgs);
- }
- } else {
- XplatUI.EraseWindowBackground(m.HWnd, m.WParam);
- }
- // The DefWndProc will never have to handle this, we don't ever set hbr on the window
- m.Result = (IntPtr)1;
+ if (paint_event == null) {
return;
}
-
- case Msg.WM_LBUTTONUP: {
- HandleClick(mouse_clicks);
- OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
- mouse_clicks,
- LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
- if (mouse_clicks > 1) {
- mouse_clicks = 1;
+ DoubleBuffer current_buffer = null;
+ if (UseDoubleBuffering) {
+ current_buffer = GetBackBuffer ();
+ if (!current_buffer.InvalidRegion.IsVisible (paint_event.ClipRectangle)) {
+ // Just blit the previous image
+ current_buffer.Blit (paint_event);
+ XplatUI.PaintEventEnd (Handle, true);
+ return;
}
- return;
+ current_buffer.Start (paint_event);
}
-
- case Msg.WM_LBUTTONDOWN: {
- if (CanSelect && !is_selected) {
- Select(this);
- }
- OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
- mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
-
- return;
+
+ if (!GetStyle(ControlStyles.Opaque)) {
+ OnPaintBackground(paint_event);
}
- case Msg.WM_LBUTTONDBLCLK: {
- mouse_clicks++;
- OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
- mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
+ // Button-derived controls choose to ignore their Opaque style, give them a chance to draw their background anyways
+ OnPaintBackgroundInternal(paint_event);
- return;
+ OnPaintInternal(paint_event);
+ if (!paint_event.Handled) {
+ OnPaint(paint_event);
}
- case Msg.WM_MBUTTONUP: {
- HandleClick(mouse_clicks);
- OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
- mouse_clicks,
- LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
- if (mouse_clicks > 1) {
- mouse_clicks = 1;
- }
- return;
+ if (current_buffer != null) {
+ current_buffer.End (paint_event);
}
+
+
+ XplatUI.PaintEventEnd(Handle, true);
+
+ return;
+ }
- case Msg.WM_MBUTTONDOWN: {
- OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
- mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
-
- return;
+ case Msg.WM_ERASEBKGND: {
+ // The DefWndProc will never have to handle this, we always paint the background in managed code
+ // In theory this code would look at ControlStyles.AllPaintingInWmPaint and and call OnPaintBackground
+ // here but it just makes things more complicated...
+ m.Result = (IntPtr)1;
+ return;
+ }
+
+ case Msg.WM_LBUTTONUP: {
+ MouseEventArgs me;
+
+ me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Left,
+ mouse_clicks,
+ LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0);
+
+ HandleClick(mouse_clicks, me);
+ OnMouseUp (me);
+
+ if (InternalCapture) {
+ InternalCapture = false;
}
- case Msg.WM_MBUTTONDBLCLK: {
- mouse_clicks++;
- OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
- mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
- return;
+ if (mouse_clicks > 1) {
+ mouse_clicks = 1;
}
+ return;
+ }
+
+ case Msg.WM_LBUTTONDOWN: {
+ if (CanSelect) {
+ Select (true, true);
+ }
+ InternalCapture = true;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+
+ return;
+ }
- case Msg.WM_RBUTTONUP: {
- if (context_menu != null) {
- context_menu.Show(this, new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ())));
- }
+ case Msg.WM_LBUTTONDBLCLK: {
+ InternalCapture = true;
+ mouse_clicks++;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
- HandleClick(mouse_clicks);
- OnMouseUp (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
- mouse_clicks,
- LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
- if (mouse_clicks > 1) {
- mouse_clicks = 1;
- }
- return;
+ case Msg.WM_MBUTTONUP: {
+ MouseEventArgs me;
+
+ me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Middle,
+ mouse_clicks,
+ LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0);
+
+ HandleClick(mouse_clicks, me);
+ OnMouseUp (me);
+ if (InternalCapture) {
+ InternalCapture = false;
}
+ if (mouse_clicks > 1) {
+ mouse_clicks = 1;
+ }
+ return;
+ }
- case Msg.WM_RBUTTONDOWN: {
- OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
- mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
- return;
+ case Msg.WM_MBUTTONDOWN: {
+ InternalCapture = true;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
+
+ case Msg.WM_MBUTTONDBLCLK: {
+ InternalCapture = true;
+ mouse_clicks++;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
+
+ case Msg.WM_RBUTTONUP: {
+ MouseEventArgs me;
+ Point pt;
+
+ pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
+ pt = PointToScreen(pt);
+
+ XplatUI.SendMessage(m.HWnd, Msg.WM_CONTEXTMENU, m.HWnd, (IntPtr)(pt.X + (pt.Y << 16)));
+
+ me = new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()) | MouseButtons.Right,
+ mouse_clicks,
+ LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0);
+
+ HandleClick(mouse_clicks, me);
+ OnMouseUp (me);
+
+ if (InternalCapture) {
+ InternalCapture = false;
}
- case Msg.WM_RBUTTONDBLCLK: {
- mouse_clicks++;
- OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
- mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
- return;
+ if (mouse_clicks > 1) {
+ mouse_clicks = 1;
}
+ return;
+ }
+
+ case Msg.WM_RBUTTONDOWN: {
+ InternalCapture = true;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
- case Msg.WM_MOUSEWHEEL: {
+ case Msg.WM_RBUTTONDBLCLK: {
+ InternalCapture = true;
+ mouse_clicks++;
+ OnMouseDown (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
- OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
- mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- HighOrder(m.WParam.ToInt32())));
- return;
- }
+ case Msg.WM_CONTEXTMENU: {
+ if (context_menu != null) {
+ Point pt;
+ pt = new Point(LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()));
+
+ if (pt.X == -1 || pt.Y == -1) {
+ pt.X = (this.Width / 2) + this.Left;
+ pt.Y = (this.Height / 2) + this.Top;
+ pt = this.PointToScreen (pt);
+ }
- case Msg.WM_MOUSEMOVE: {
- OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
- mouse_clicks,
- LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
- 0));
+ context_menu.Show (this, PointToClient (pt));
return;
}
- case Msg.WM_MOUSE_ENTER: {
- if (is_entered) {
- return;
+#if NET_2_0
+ // If there isn't a regular context menu, show the Strip version
+ if (context_menu == null && context_menu_strip != null) {
+ Point pt;
+
+ pt = new Point (LowOrder ((int)m.LParam.ToInt32 ()), HighOrder ((int)m.LParam.ToInt32 ()));
+
+ if (pt.X == -1 || pt.Y == -1) {
+ pt.X = (this.Width / 2) + this.Left;
+ pt.Y = (this.Height /2) + this.Top;
+ pt = this.PointToScreen (pt);
}
- is_entered = true;
- OnMouseEnter(EventArgs.Empty);
+
+ context_menu_strip.Show (this, PointToClient (pt));
return;
}
+#endif
+ DefWndProc(ref m);
+ return;
+ }
+
+ case Msg.WM_MOUSEWHEEL: {
+ DefWndProc(ref m);
+ OnMouseWheel (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks, LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ HighOrder(m.WParam.ToInt32())));
+ return;
+ }
- case Msg.WM_MOUSE_LEAVE: {
- is_entered=false;
- OnMouseLeave(EventArgs.Empty);
- return;
- }
- case Msg.WM_MOUSEHOVER: {
- OnMouseHover(EventArgs.Empty);
+ case Msg.WM_MOUSEMOVE: {
+ OnMouseMove (new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()),
+ mouse_clicks,
+ LowOrder ((int) m.LParam.ToInt32 ()), HighOrder ((int) m.LParam.ToInt32 ()),
+ 0));
+ return;
+ }
+
+ case Msg.WM_MOUSE_ENTER: {
+ if (is_entered) {
return;
}
+ is_entered = true;
+ OnMouseEnter(EventArgs.Empty);
+ return;
+ }
- case Msg.WM_SYSKEYDOWN:
- case Msg.WM_KEYDOWN:
- case Msg.WM_SYSKEYUP:
- case Msg.WM_KEYUP:
- case Msg.WM_SYSCHAR:
- case Msg.WM_CHAR: {
- if (ProcessKeyEventArgs(ref m)) {
- return;
- }
+ case Msg.WM_MOUSE_LEAVE: {
+ is_entered=false;
+ OnMouseLeave(EventArgs.Empty);
+ return;
+ }
- if (PreProcessMessage(ref m)) {
- return;
- }
+ case Msg.WM_MOUSEHOVER: {
+ OnMouseHover(EventArgs.Empty);
+ return;
+ }
- if (ProcessKeyMessage(ref m)) {
- return;
- }
- DefWndProc (ref m);
+ case Msg.WM_SYSKEYUP: {
+ if (ProcessKeyMessage(ref m)) {
+ m.Result = IntPtr.Zero;
return;
}
- case Msg.WM_HELP: {
- Point mouse_pos;
- if (m.LParam != IntPtr.Zero) {
- HELPINFO hi;
-
- hi = new HELPINFO();
+ if ((m.WParam.ToInt32() & (int)Keys.KeyCode) == (int)Keys.Menu) {
+ Form form;
- hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
- mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
- } else {
- mouse_pos = Control.MousePosition;
+ form = FindForm();
+ if (form != null && form.ActiveMenu != null) {
+ form.ActiveMenu.ProcessCmdKey(ref m, (Keys)m.WParam.ToInt32());
}
- OnHelpRequested(new HelpEventArgs(mouse_pos));
- m.Result = (IntPtr)1;
- return;
}
- case Msg.WM_KILLFOCUS: {
- OnLeave(EventArgs.Empty);
- if (CausesValidation) {
- CancelEventArgs e;
- e = new CancelEventArgs(false);
+ DefWndProc (ref m);
+ return;
+ }
- OnValidating(e);
+ case Msg.WM_SYSKEYDOWN:
+ case Msg.WM_KEYDOWN:
+ case Msg.WM_KEYUP:
+ case Msg.WM_SYSCHAR:
+ case Msg.WM_CHAR: {
+ if (ProcessKeyMessage(ref m)) {
+ m.Result = IntPtr.Zero;
+ return;
+ }
+ DefWndProc (ref m);
+ return;
+ }
- if (e.Cancel) {
- Focus();
- return;
- }
+ case Msg.WM_HELP: {
+ Point mouse_pos;
+ if (m.LParam != IntPtr.Zero) {
+ HELPINFO hi;
- OnValidated(EventArgs.Empty);
- }
+ hi = new HELPINFO();
- this.has_focus = false;
- this.is_selected = false;
- OnLostFocus(EventArgs.Empty);
- return;
+ hi = (HELPINFO) Marshal.PtrToStructure (m.LParam, typeof (HELPINFO));
+ mouse_pos = new Point(hi.MousePos.x, hi.MousePos.y);
+ } else {
+ mouse_pos = Control.MousePosition;
}
+ OnHelpRequested(new HelpEventArgs(mouse_pos));
+ m.Result = (IntPtr)1;
+ return;
+ }
- case Msg.WM_SETFOCUS: {
- OnEnter(EventArgs.Empty);
- this.has_focus = true;
- OnGotFocus(EventArgs.Empty);
- return;
+ case Msg.WM_KILLFOCUS: {
+ this.has_focus = false;
+ OnLostFocusInternal (EventArgs.Empty);
+ return;
+ }
+
+ case Msg.WM_SETFOCUS: {
+ if (!has_focus) {
+ if (this.Parent != null && this.Parent.ContainerSelected)
+ return;
+ this.has_focus = true;
+ OnGotFocusInternal (EventArgs.Empty);
}
+ return;
+ }
+ case Msg.WM_SYSCOLORCHANGE: {
+ ThemeEngine.Current.ResetDefaults();
+ OnSystemColorsChanged(EventArgs.Empty);
+ return;
+ }
- case Msg.WM_SYSCOLORCHANGE: {
- ThemeEngine.Current.ResetDefaults();
- OnSystemColorsChanged(EventArgs.Empty);
+ case Msg.WM_SETCURSOR: {
+ if ((cursor == null) || ((HitTest)(m.LParam.ToInt32() & 0xffff) != HitTest.HTCLIENT)) {
+ DefWndProc(ref m);
return;
}
-
- case Msg.WM_SETCURSOR: {
- if (cursor == null) {
- DefWndProc(ref m);
- return;
- }
+ XplatUI.SetCursor(window.Handle, cursor.handle);
+ m.Result = (IntPtr)1;
- XplatUI.SetCursor(window.Handle, cursor.handle);
- m.Result = (IntPtr)1;
- return;
- }
+ return;
+ }
- default: {
- DefWndProc(ref m);
- return;
- }
+ default:
+ DefWndProc(ref m);
+ return;
}
}
#endregion // Public Instance Methods
#region OnXXX methods
- [EditorBrowsable(EditorBrowsableState.Advanced)]
+#if NET_2_0
+ protected virtual void OnAutoSizeChanged (EventArgs e)
+ {
+ EventHandler eh = (EventHandler)(Events[AutoSizeChangedEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+#endif
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
protected virtual void OnBackColorChanged(EventArgs e) {
- if (BackColorChanged!=null) BackColorChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [BackColorChangedEvent]);
+ if (eh != null)
+ eh (this, e);
for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackColorChanged(e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnBackgroundImageChanged(EventArgs e) {
- if (BackgroundImageChanged!=null) BackgroundImageChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [BackgroundImageChangedEvent]);
+ if (eh != null)
+ eh (this, e);
for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBackgroundImageChanged(e);
}
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected virtual void OnBackgroundImageLayoutChanged (EventArgs e)
+ {
+ EventHandler eh = (EventHandler)(Events[BackgroundImageLayoutChangedEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+#endif
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnBindingContextChanged(EventArgs e) {
CheckDataBindings ();
- if (BindingContextChanged!=null) {
- BindingContextChanged(this, e);
- }
+ EventHandler eh = (EventHandler)(Events [BindingContextChangedEvent]);
+ if (eh != null)
+ eh (this, e);
for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentBindingContextChanged(e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnCausesValidationChanged(EventArgs e) {
- if (CausesValidationChanged!=null) CausesValidationChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [CausesValidationChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnChangeUICues(UICuesEventArgs e) {
- if (ChangeUICues!=null) ChangeUICues(this, e);
+ UICuesEventHandler eh = (UICuesEventHandler)(Events [ChangeUICuesEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnClick(EventArgs e) {
- if (Click!=null) Click(this, e);
+ EventHandler eh = (EventHandler)(Events [ClickEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected virtual void OnClientSizeChanged (EventArgs e)
+ {
+ EventHandler eh = (EventHandler)(Events[ClientSizeChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
+#endif
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnContextMenuChanged(EventArgs e) {
- if (ContextMenuChanged!=null) ContextMenuChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [ContextMenuChangedEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected virtual void OnContextMenuStripChanged (EventArgs e) {
+ EventHandler eh = (EventHandler)(Events [ContextMenuStripChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
+#endif
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnControlAdded(ControlEventArgs e) {
- if (ControlAdded!=null) ControlAdded(this, e);
+ ControlEventHandler eh = (ControlEventHandler)(Events [ControlAddedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnControlRemoved(ControlEventArgs e) {
- if (ControlRemoved!=null) ControlRemoved(this, e);
+ ControlEventHandler eh = (ControlEventHandler)(Events [ControlRemovedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnCursorChanged(EventArgs e) {
- if (CursorChanged!=null) CursorChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [CursorChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnDockChanged(EventArgs e) {
- if (DockChanged!=null) DockChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [DockChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnDoubleClick(EventArgs e) {
- if (DoubleClick!=null) DoubleClick(this, e);
+ EventHandler eh = (EventHandler)(Events [DoubleClickEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnDragDrop(DragEventArgs drgevent) {
- if (DragDrop!=null) DragDrop(this, drgevent);
+ DragEventHandler eh = (DragEventHandler)(Events [DragDropEvent]);
+ if (eh != null)
+ eh (this, drgevent);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnDragEnter(DragEventArgs drgevent) {
- if (DragEnter!=null) DragEnter(this, drgevent);
+ DragEventHandler eh = (DragEventHandler)(Events [DragEnterEvent]);
+ if (eh != null)
+ eh (this, drgevent);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnDragLeave(EventArgs e) {
- if (DragLeave!=null) DragLeave(this, e);
+ EventHandler eh = (EventHandler)(Events [DragLeaveEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnDragOver(DragEventArgs drgevent) {
- if (DragOver!=null) DragOver(this, drgevent);
+ DragEventHandler eh = (DragEventHandler)(Events [DragOverEvent]);
+ if (eh != null)
+ eh (this, drgevent);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnEnabledChanged(EventArgs e) {
- if (EnabledChanged!=null) EnabledChanged(this, e);
- for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentEnabledChanged(e);
+ if (IsHandleCreated) {
+ if (this is Form) {
+ if (((Form)this).context == null) {
+ XplatUI.EnableWindow(window.Handle, Enabled);
+ }
+ } else {
+ XplatUI.EnableWindow(window.Handle, Enabled);
+ }
+ Refresh();
+ }
+
+ EventHandler eh = (EventHandler)(Events [EnabledChangedEvent]);
+ if (eh != null)
+ eh (this, e);
+
+ for (int i=0; i<child_controls.Count; i++) {
+ child_controls[i].OnParentEnabledChanged(e);
+ }
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnEnter(EventArgs e) {
- if (Enter!=null) Enter(this, e);
+ EventHandler eh = (EventHandler)(Events [EnterEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnFontChanged(EventArgs e) {
- if (FontChanged!=null) FontChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [FontChangedEvent]);
+ if (eh != null)
+ eh (this, e);
for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentFontChanged(e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnForeColorChanged(EventArgs e) {
- if (ForeColorChanged!=null) ForeColorChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [ForeColorChangedEvent]);
+ if (eh != null)
+ eh (this, e);
for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentForeColorChanged(e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnGiveFeedback(GiveFeedbackEventArgs gfbevent) {
- if (GiveFeedback!=null) GiveFeedback(this, gfbevent);
+ GiveFeedbackEventHandler eh = (GiveFeedbackEventHandler)(Events [GiveFeedbackEvent]);
+ if (eh != null)
+ eh (this, gfbevent);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnGotFocus(EventArgs e) {
- if (GotFocus!=null) GotFocus(this, e);
+ EventHandler eh = (EventHandler)(Events [GotFocusEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnHandleCreated(EventArgs e) {
- if (HandleCreated!=null) HandleCreated(this, e);
+ EventHandler eh = (EventHandler)(Events [HandleCreatedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnHandleDestroyed(EventArgs e) {
- if (HandleDestroyed!=null) HandleDestroyed(this, e);
+ EventHandler eh = (EventHandler)(Events [HandleDestroyedEvent]);
+ if (eh != null)
+ eh (this, e);
}
+ internal void RaiseHelpRequested (HelpEventArgs hevent)
+ {
+ OnHelpRequested (hevent);
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnHelpRequested(HelpEventArgs hevent) {
- if (HelpRequested!=null) HelpRequested(this, hevent);
+ HelpEventHandler eh = (HelpEventHandler)(Events [HelpRequestedEvent]);
+ if (eh != null)
+ eh (this, hevent);
}
protected virtual void OnImeModeChanged(EventArgs e) {
- if (ImeModeChanged!=null) ImeModeChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [ImeModeChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnInvalidated(InvalidateEventArgs e) {
- if (Invalidated!=null) Invalidated(this, e);
+ if (UseDoubleBuffering) {
+ // should this block be here? seems like it
+ // would be more at home in
+ // NotifyInvalidated..
+ if (e.InvalidRect == ClientRectangle) {
+ InvalidateBackBuffer ();
+ } else if (backbuffer != null){
+ // we need this Inflate call here so
+ // that the border of the rectangle is
+ // considered Visible (the
+ // invalid_region.IsVisible call) in
+ // the WM_PAINT handling below.
+ Rectangle r = Rectangle.Inflate(e.InvalidRect, 1,1);
+ backbuffer.InvalidRegion.Union (r);
+ }
+ }
+
+ InvalidateEventHandler eh = (InvalidateEventHandler)(Events [InvalidatedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
- protected virtual void OnKeyDown(KeyEventArgs e) {
- if (KeyDown!=null) KeyDown(this, e);
+ protected virtual void OnKeyDown(KeyEventArgs e) {
+ KeyEventHandler eh = (KeyEventHandler)(Events [KeyDownEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnKeyPress(KeyPressEventArgs e) {
- if (KeyPress!=null) KeyPress(this, e);
+ KeyPressEventHandler eh = (KeyPressEventHandler)(Events [KeyPressEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnKeyUp(KeyEventArgs e) {
- if (KeyUp!=null) KeyUp(this, e);
+ KeyEventHandler eh = (KeyEventHandler)(Events [KeyUpEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnLayout(LayoutEventArgs levent) {
- if (Layout!=null) Layout(this, levent);
+ LayoutEventHandler eh = (LayoutEventHandler)(Events [LayoutEvent]);
+ if (eh != null)
+ eh (this, levent);
+
+ LayoutEngine.Layout (this, levent);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnLeave(EventArgs e) {
- if (Leave!=null) Leave(this, e);
+ EventHandler eh = (EventHandler)(Events [LeaveEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnLocationChanged(EventArgs e) {
OnMove(e);
- if (LocationChanged!=null) LocationChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [LocationChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnLostFocus(EventArgs e) {
- if (LostFocus!=null) LostFocus(this, e);
+ EventHandler eh = (EventHandler)(Events [LostFocusEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+
+#if NET_2_0
+ protected virtual void OnMarginChanged (EventArgs e)
+ {
+ EventHandler eh = (EventHandler)(Events[MarginChangedEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseCaptureChanged (EventArgs e)
+ {
+ EventHandler eh = (EventHandler)(Events [MouseCaptureChangedEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseClick (MouseEventArgs e)
+ {
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseClickEvent]);
+ if (eh != null)
+ eh (this, e);
}
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected virtual void OnMouseDoubleClick (MouseEventArgs e)
+ {
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseDoubleClickEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+#endif
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMouseDown(MouseEventArgs e) {
- if (MouseDown!=null) MouseDown(this, e);
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseDownEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMouseEnter(EventArgs e) {
- if (MouseEnter!=null) MouseEnter(this, e);
+ EventHandler eh = (EventHandler)(Events [MouseEnterEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMouseHover(EventArgs e) {
- if (MouseHover!=null) MouseHover(this, e);
+ EventHandler eh = (EventHandler)(Events [MouseHoverEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMouseLeave(EventArgs e) {
- if (MouseLeave!=null) MouseLeave(this, e);
+ EventHandler eh = (EventHandler)(Events [MouseLeaveEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
- protected virtual void OnMouseMove(MouseEventArgs e) {
- if (MouseMove!=null) MouseMove(this, e);
+ protected virtual void OnMouseMove(MouseEventArgs e) {
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseMoveEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMouseUp(MouseEventArgs e) {
- if (MouseUp!=null) MouseUp(this, e);
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseUpEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMouseWheel(MouseEventArgs e) {
- if (MouseWheel!=null) MouseWheel(this, e);
+ MouseEventHandler eh = (MouseEventHandler)(Events [MouseWheelEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnMove(EventArgs e) {
- if (Move!=null) Move(this, e);
+ EventHandler eh = (EventHandler)(Events [MoveEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
// Override me!
}
+#if NET_2_0
+ protected virtual void OnPaddingChanged (EventArgs e) {
+ EventHandler eh = (EventHandler) (Events [PaddingChangedEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+#endif
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnPaint(PaintEventArgs e) {
- if (Paint!=null) Paint(this, e);
+ PaintEventHandler eh = (PaintEventHandler)(Events [PaintEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+
+ internal virtual void OnPaintBackgroundInternal(PaintEventArgs e) {
+ // Override me
+ }
+
+ internal virtual void OnPaintInternal(PaintEventArgs e) {
+ // Override me
+ }
+
+ internal virtual void OnGotFocusInternal (EventArgs e)
+ {
+ OnGotFocus (e);
+ }
+
+ internal virtual void OnLostFocusInternal (EventArgs e)
+ {
+ OnLostFocus (e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnPaintBackground(PaintEventArgs pevent) {
- // Override me!
+ PaintControlBackground (pevent);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnParentChanged(EventArgs e) {
- if (ParentChanged!=null) ParentChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [ParentChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnParentEnabledChanged(EventArgs e) {
- if (is_enabled != Parent.is_enabled) {
- is_enabled=Parent.is_enabled;
- Invalidate();
- if (EnabledChanged != null) {
- EnabledChanged(this, e);
- }
+ if (is_enabled) {
+ OnEnabledChanged(e);
}
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnQueryContinueDrag(QueryContinueDragEventArgs e) {
- if (QueryContinueDrag!=null) QueryContinueDrag(this, e);
+ QueryContinueDragEventHandler eh = (QueryContinueDragEventHandler)(Events [QueryContinueDragEvent]);
+ if (eh != null)
+ eh (this, e);
}
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+ protected virtual void OnRegionChanged (EventArgs e)
+ {
+ EventHandler eh = (EventHandler)(Events[RegionChangedEvent]);
+ if (eh != null)
+ eh (this, e);
+ }
+#endif
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnResize(EventArgs e) {
- if (Resize!=null) Resize(this, e);
+ PerformLayout(this, "Bounds");
- PerformLayout(this, "bounds");
-
- if (parent != null) {
- parent.PerformLayout();
- }
+ EventHandler eh = (EventHandler)(Events [ResizeEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnRightToLeftChanged(EventArgs e) {
- if (RightToLeftChanged!=null) RightToLeftChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [RightToLeftChangedEvent]);
+ if (eh != null)
+ eh (this, e);
for (int i=0; i<child_controls.Count; i++) child_controls[i].OnParentRightToLeftChanged(e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnSizeChanged(EventArgs e) {
- InvalidateBuffers ();
+ DisposeBackBuffer ();
OnResize(e);
- if (SizeChanged!=null) SizeChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [SizeChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnStyleChanged(EventArgs e) {
- if (StyleChanged!=null) StyleChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [StyleChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnSystemColorsChanged(EventArgs e) {
- if (SystemColorsChanged!=null) SystemColorsChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [SystemColorsChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnTabIndexChanged(EventArgs e) {
- if (TabIndexChanged!=null) TabIndexChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [TabIndexChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnTabStopChanged(EventArgs e) {
- if (TabStopChanged!=null) TabStopChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [TabStopChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnTextChanged(EventArgs e) {
- if (TextChanged!=null) TextChanged(this, e);
+ EventHandler eh = (EventHandler)(Events [TextChangedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnValidated(EventArgs e) {
- if (Validated!=null) Validated(this, e);
+ EventHandler eh = (EventHandler)(Events [ValidatedEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnValidating(System.ComponentModel.CancelEventArgs e) {
- if (Validating!=null) Validating(this, e);
+ CancelEventHandler eh = (CancelEventHandler)(Events [ValidatingEvent]);
+ if (eh != null)
+ eh (this, e);
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected virtual void OnVisibleChanged(EventArgs e) {
- if (!is_visible) {
- if (dc_mem!=null) {
- dc_mem.Dispose ();
- dc_mem=null;
- }
-
- if (bmp_mem!=null) {
- bmp_mem.Dispose();
- bmp_mem=null;
- }
- } else {
+ if ((parent != null) && !Created && Visible) {
if (!is_disposed) {
- if (!this.IsHandleCreated) {
- this.CreateControl();
- }
+ CreateControl();
PerformLayout();
}
}
-
- if (VisibleChanged!=null) VisibleChanged(this, e);
+
+ EventHandler eh = (EventHandler)(Events [VisibleChangedEvent]);
+ if (eh != null)
+ eh (this, e);
// We need to tell our kids
for (int i=0; i<child_controls.Count; i++) {
- child_controls[i].OnParentVisibleChanged(e);
+ if (child_controls[i].Visible) {
+ child_controls[i].OnParentVisibleChanged(e);
+ }
}
}
#endregion // OnXXX methods
#region Events
- public event EventHandler BackColorChanged;
- public event EventHandler BackgroundImageChanged;
- public event EventHandler BindingContextChanged;
- public event EventHandler CausesValidationChanged;
- public event UICuesEventHandler ChangeUICues;
- public event EventHandler Click;
- public event EventHandler ContextMenuChanged;
+#if NET_2_0
+ static object AutoSizeChangedEvent = new object ();
+#endif
+ static object BackColorChangedEvent = new object ();
+ static object BackgroundImageChangedEvent = new object ();
+#if NET_2_0
+ static object BackgroundImageLayoutChangedEvent = new object ();
+#endif
+ static object BindingContextChangedEvent = new object ();
+ static object CausesValidationChangedEvent = new object ();
+ static object ChangeUICuesEvent = new object ();
+ static object ClickEvent = new object ();
+#if NET_2_0
+ static object ClientSizeChangedEvent = new object ();
+#endif
+ static object ContextMenuChangedEvent = new object ();
+#if NET_2_0
+ static object ContextMenuStripChangedEvent = new object ();
+#endif
+ static object ControlAddedEvent = new object ();
+ static object ControlRemovedEvent = new object ();
+ static object CursorChangedEvent = new object ();
+ static object DockChangedEvent = new object ();
+ static object DoubleClickEvent = new object ();
+ static object DragDropEvent = new object ();
+ static object DragEnterEvent = new object ();
+ static object DragLeaveEvent = new object ();
+ static object DragOverEvent = new object ();
+ static object EnabledChangedEvent = new object ();
+ static object EnterEvent = new object ();
+ static object FontChangedEvent = new object ();
+ static object ForeColorChangedEvent = new object ();
+ static object GiveFeedbackEvent = new object ();
+ static object GotFocusEvent = new object ();
+ static object HandleCreatedEvent = new object ();
+ static object HandleDestroyedEvent = new object ();
+ static object HelpRequestedEvent = new object ();
+ static object ImeModeChangedEvent = new object ();
+ static object InvalidatedEvent = new object ();
+ static object KeyDownEvent = new object ();
+ static object KeyPressEvent = new object ();
+ static object KeyUpEvent = new object ();
+ static object LayoutEvent = new object ();
+ static object LeaveEvent = new object ();
+ static object LocationChangedEvent = new object ();
+ static object LostFocusEvent = new object ();
+#if NET_2_0
+ static object MarginChangedEvent = new object ();
+ static object MouseCaptureChangedEvent = new object ();
+ static object MouseClickEvent = new object ();
+ static object MouseDoubleClickEvent = new object ();
+#endif
+ static object MouseDownEvent = new object ();
+ static object MouseEnterEvent = new object ();
+ static object MouseHoverEvent = new object ();
+ static object MouseLeaveEvent = new object ();
+ static object MouseMoveEvent = new object ();
+ static object MouseUpEvent = new object ();
+ static object MouseWheelEvent = new object ();
+ static object MoveEvent = new object ();
+#if NET_2_0
+ static object PaddingChangedEvent = new object ();
+#endif
+ static object PaintEvent = new object ();
+ static object ParentChangedEvent = new object ();
+#if NET_2_0
+ static object PreviewKeyDownEvent = new object ();
+#endif
+ static object QueryAccessibilityHelpEvent = new object ();
+ static object QueryContinueDragEvent = new object ();
+#if NET_2_0
+ static object RegionChangedEvent = new object ();
+#endif
+ static object ResizeEvent = new object ();
+ static object RightToLeftChangedEvent = new object ();
+ static object SizeChangedEvent = new object ();
+ static object StyleChangedEvent = new object ();
+ static object SystemColorsChangedEvent = new object ();
+ static object TabIndexChangedEvent = new object ();
+ static object TabStopChangedEvent = new object ();
+ static object TextChangedEvent = new object ();
+ static object ValidatedEvent = new object ();
+ static object ValidatingEvent = new object ();
+ static object VisibleChangedEvent = new object ();
+
+#if NET_2_0
+ [Browsable (false)]
+ [EditorBrowsable (EditorBrowsableState.Never)]
+ public event EventHandler AutoSizeChanged {
+ add { Events.AddHandler (AutoSizeChangedEvent, value);}
+ remove {Events.RemoveHandler (AutoSizeChangedEvent, value);}
+ }
+#endif
+ public event EventHandler BackColorChanged {
+ add { Events.AddHandler (BackColorChangedEvent, value); }
+ remove { Events.RemoveHandler (BackColorChangedEvent, value); }
+ }
+
+ public event EventHandler BackgroundImageChanged {
+ add { Events.AddHandler (BackgroundImageChangedEvent, value); }
+ remove { Events.RemoveHandler (BackgroundImageChangedEvent, value); }
+ }
+
+#if NET_2_0
+ public event EventHandler BackgroundImageLayoutChanged {
+ add {Events.AddHandler (BackgroundImageLayoutChangedEvent, value);}
+ remove {Events.RemoveHandler (BackgroundImageLayoutChangedEvent, value);}
+ }
+#endif
+
+ public event EventHandler BindingContextChanged {
+ add { Events.AddHandler (BindingContextChangedEvent, value); }
+ remove { Events.RemoveHandler (BindingContextChangedEvent, value); }
+ }
+
+ public event EventHandler CausesValidationChanged {
+ add { Events.AddHandler (CausesValidationChangedEvent, value); }
+ remove { Events.RemoveHandler (CausesValidationChangedEvent, value); }
+ }
+
+ public event UICuesEventHandler ChangeUICues {
+ add { Events.AddHandler (ChangeUICuesEvent, value); }
+ remove { Events.RemoveHandler (ChangeUICuesEvent, value); }
+ }
+
+ public event EventHandler Click {
+ add { Events.AddHandler (ClickEvent, value); }
+ remove { Events.RemoveHandler (ClickEvent, value); }
+ }
+
+#if NET_2_0
+ public event EventHandler ClientSizeChanged {
+ add {Events.AddHandler (ClientSizeChangedEvent, value);}
+ remove {Events.RemoveHandler (ClientSizeChangedEvent, value);}
+ }
+#endif
+
+#if NET_2_0
+ [Browsable (false)]
+#endif
+ public event EventHandler ContextMenuChanged {
+ add { Events.AddHandler (ContextMenuChangedEvent, value); }
+ remove { Events.RemoveHandler (ContextMenuChangedEvent, value); }
+ }
+
+#if NET_2_0
+ public event EventHandler ContextMenuStripChanged {
+ add { Events.AddHandler (ContextMenuStripChangedEvent, value); }
+ remove { Events.RemoveHandler (ContextMenuStripChangedEvent, value);}
+ }
+#endif
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
+#if NET_2_0
+ [Browsable(true)]
+#else
[Browsable(false)]
- public event ControlEventHandler ControlAdded;
+#endif
+ public event ControlEventHandler ControlAdded {
+ add { Events.AddHandler (ControlAddedEvent, value); }
+ remove { Events.RemoveHandler (ControlAddedEvent, value); }
+ }
[EditorBrowsable(EditorBrowsableState.Advanced)]
+#if NET_2_0
+ [Browsable(true)]
+#else
[Browsable(false)]
- public event ControlEventHandler ControlRemoved;
-
- public event EventHandler CursorChanged;
- public event EventHandler DockChanged;
- public event EventHandler DoubleClick;
- public event DragEventHandler DragDrop;
- public event DragEventHandler DragEnter;
- public event EventHandler DragLeave;
- public event DragEventHandler DragOver;
- public event EventHandler EnabledChanged;
- public event EventHandler Enter;
- public event EventHandler FontChanged;
- public event EventHandler ForeColorChanged;
- public event GiveFeedbackEventHandler GiveFeedback;
+#endif
+ public event ControlEventHandler ControlRemoved {
+ add { Events.AddHandler (ControlRemovedEvent, value); }
+ remove { Events.RemoveHandler (ControlRemovedEvent, value); }
+ }
+
+ [MWFDescription("Fired when the cursor for the control has been changed"), MWFCategory("PropertyChanged")]
+ public event EventHandler CursorChanged {
+ add { Events.AddHandler (CursorChangedEvent, value); }
+ remove { Events.RemoveHandler (CursorChangedEvent, value); }
+ }
+ public event EventHandler DockChanged {
+ add { Events.AddHandler (DockChangedEvent, value); }
+ remove { Events.RemoveHandler (DockChangedEvent, value); }
+ }
+
+ public event EventHandler DoubleClick {
+ add { Events.AddHandler (DoubleClickEvent, value); }
+ remove { Events.RemoveHandler (DoubleClickEvent, value); }
+ }
+
+ public event DragEventHandler DragDrop {
+ add { Events.AddHandler (DragDropEvent, value); }
+ remove { Events.RemoveHandler (DragDropEvent, value); }
+ }
+
+ public event DragEventHandler DragEnter {
+ add { Events.AddHandler (DragEnterEvent, value); }
+ remove { Events.RemoveHandler (DragEnterEvent, value); }
+ }
+
+ public event EventHandler DragLeave {
+ add { Events.AddHandler (DragLeaveEvent, value); }
+ remove { Events.RemoveHandler (DragLeaveEvent, value); }
+ }
+
+ public event DragEventHandler DragOver {
+ add { Events.AddHandler (DragOverEvent, value); }
+ remove { Events.RemoveHandler (DragOverEvent, value); }
+ }
+
+ public event EventHandler EnabledChanged {
+ add { Events.AddHandler (EnabledChangedEvent, value); }
+ remove { Events.RemoveHandler (EnabledChangedEvent, value); }
+ }
+
+ public event EventHandler Enter {
+ add { Events.AddHandler (EnterEvent, value); }
+ remove { Events.RemoveHandler (EnterEvent, value); }
+ }
+
+ public event EventHandler FontChanged {
+ add { Events.AddHandler (FontChangedEvent, value); }
+ remove { Events.RemoveHandler (FontChangedEvent, value); }
+ }
+
+ public event EventHandler ForeColorChanged {
+ add { Events.AddHandler (ForeColorChangedEvent, value); }
+ remove { Events.RemoveHandler (ForeColorChangedEvent, value); }
+ }
+
+ public event GiveFeedbackEventHandler GiveFeedback {
+ add { Events.AddHandler (GiveFeedbackEvent, value); }
+ remove { Events.RemoveHandler (GiveFeedbackEvent, value); }
+ }
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
- public event EventHandler GotFocus;
+ public event EventHandler GotFocus {
+ add { Events.AddHandler (GotFocusEvent, value); }
+ remove { Events.RemoveHandler (GotFocusEvent, value); }
+ }
+
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
- public event EventHandler HandleCreated;
+ public event EventHandler HandleCreated {
+ add { Events.AddHandler (HandleCreatedEvent, value); }
+ remove { Events.RemoveHandler (HandleCreatedEvent, value); }
+ }
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
- public event EventHandler HandleDestroyed;
+ public event EventHandler HandleDestroyed {
+ add { Events.AddHandler (HandleDestroyedEvent, value); }
+ remove { Events.RemoveHandler (HandleDestroyedEvent, value); }
+ }
+
+ public event HelpEventHandler HelpRequested {
+ add { Events.AddHandler (HelpRequestedEvent, value); }
+ remove { Events.RemoveHandler (HelpRequestedEvent, value); }
+ }
- public event HelpEventHandler HelpRequested;
- public event EventHandler ImeModeChanged;
+ public event EventHandler ImeModeChanged {
+ add { Events.AddHandler (ImeModeChangedEvent, value); }
+ remove { Events.RemoveHandler (ImeModeChangedEvent, value); }
+ }
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
- public event InvalidateEventHandler Invalidated;
+ public event InvalidateEventHandler Invalidated {
+ add { Events.AddHandler (InvalidatedEvent, value); }
+ remove { Events.RemoveHandler (InvalidatedEvent, value); }
+ }
+
+ public event KeyEventHandler KeyDown {
+ add { Events.AddHandler (KeyDownEvent, value); }
+ remove { Events.RemoveHandler (KeyDownEvent, value); }
+ }
+
+ public event KeyPressEventHandler KeyPress {
+ add { Events.AddHandler (KeyPressEvent, value); }
+ remove { Events.RemoveHandler (KeyPressEvent, value); }
+ }
+
+ public event KeyEventHandler KeyUp {
+ add { Events.AddHandler (KeyUpEvent, value); }
+ remove { Events.RemoveHandler (KeyUpEvent, value); }
+ }
+
+ public event LayoutEventHandler Layout {
+ add { Events.AddHandler (LayoutEvent, value); }
+ remove { Events.RemoveHandler (LayoutEvent, value); }
+ }
+
+ public event EventHandler Leave {
+ add { Events.AddHandler (LeaveEvent, value); }
+ remove { Events.RemoveHandler (LeaveEvent, value); }
+ }
- public event KeyEventHandler KeyDown;
- public event KeyPressEventHandler KeyPress;
- public event KeyEventHandler KeyUp;
- public event LayoutEventHandler Layout;
- public event EventHandler Leave;
- public event EventHandler LocationChanged;
+ public event EventHandler LocationChanged {
+ add { Events.AddHandler (LocationChangedEvent, value); }
+ remove { Events.RemoveHandler (LocationChangedEvent, value); }
+ }
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
- public event EventHandler LostFocus;
+ public event EventHandler LostFocus {
+ add { Events.AddHandler (LostFocusEvent, value); }
+ remove { Events.RemoveHandler (LostFocusEvent, value); }
+ }
+
+#if NET_2_0
+ public event EventHandler MarginChanged {
+ add { Events.AddHandler (MarginChangedEvent, value); }
+ remove {Events.RemoveHandler (MarginChangedEvent, value); }
+ }
+
+ public event EventHandler MouseCaptureChanged {
+ add { Events.AddHandler (MouseCaptureChangedEvent, value); }
+ remove { Events.RemoveHandler (MouseCaptureChangedEvent, value); }
+ }
+
+ public event MouseEventHandler MouseClick
+ {
+ add { Events.AddHandler (MouseClickEvent, value); }
+ remove { Events.RemoveHandler (MouseClickEvent, value); }
+ }
+ public event MouseEventHandler MouseDoubleClick
+ {
+ add { Events.AddHandler (MouseDoubleClickEvent, value); }
+ remove { Events.RemoveHandler (MouseDoubleClickEvent, value); }
+ }
+#endif
+ public event MouseEventHandler MouseDown {
+ add { Events.AddHandler (MouseDownEvent, value); }
+ remove { Events.RemoveHandler (MouseDownEvent, value); }
+ }
+
+ public event EventHandler MouseEnter {
+ add { Events.AddHandler (MouseEnterEvent, value); }
+ remove { Events.RemoveHandler (MouseEnterEvent, value); }
+ }
+
+ public event EventHandler MouseHover {
+ add { Events.AddHandler (MouseHoverEvent, value); }
+ remove { Events.RemoveHandler (MouseHoverEvent, value); }
+ }
- public event MouseEventHandler MouseDown;
- public event EventHandler MouseEnter;
- public event EventHandler MouseHover;
- public event EventHandler MouseLeave;
- public event MouseEventHandler MouseMove;
- public event MouseEventHandler MouseUp;
+ public event EventHandler MouseLeave {
+ add { Events.AddHandler (MouseLeaveEvent, value); }
+ remove { Events.RemoveHandler (MouseLeaveEvent, value); }
+ }
+
+ public event MouseEventHandler MouseMove {
+ add { Events.AddHandler (MouseMoveEvent, value); }
+ remove { Events.RemoveHandler (MouseMoveEvent, value); }
+ }
+
+ public event MouseEventHandler MouseUp {
+ add { Events.AddHandler (MouseUpEvent, value); }
+ remove { Events.RemoveHandler (MouseUpEvent, value); }
+ }
[EditorBrowsable(EditorBrowsableState.Advanced)]
[Browsable(false)]
- public event MouseEventHandler MouseWheel;
-
- public event EventHandler Move;
- public event PaintEventHandler Paint;
- public event EventHandler ParentChanged;
- public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp;
- public event QueryContinueDragEventHandler QueryContinueDrag;
- public event EventHandler Resize;
- public event EventHandler RightToLeftChanged;
- public event EventHandler SizeChanged;
- public event EventHandler StyleChanged;
- public event EventHandler SystemColorsChanged;
- public event EventHandler TabIndexChanged;
- public event EventHandler TabStopChanged;
- public event EventHandler TextChanged;
- public event EventHandler Validated;
- public event CancelEventHandler Validating;
- public event EventHandler VisibleChanged;
+ public event MouseEventHandler MouseWheel {
+ add { Events.AddHandler (MouseWheelEvent, value); }
+ remove { Events.RemoveHandler (MouseWheelEvent, value); }
+ }
+
+ public event EventHandler Move {
+ add { Events.AddHandler (MoveEvent, value); }
+ remove { Events.RemoveHandler (MoveEvent, value); }
+ }
+#if NET_2_0
+ public event EventHandler PaddingChanged
+ {
+ add { Events.AddHandler (PaddingChangedEvent, value); }
+ remove { Events.RemoveHandler (PaddingChangedEvent, value); }
+ }
+#endif
+ public event PaintEventHandler Paint {
+ add { Events.AddHandler (PaintEvent, value); }
+ remove { Events.RemoveHandler (PaintEvent, value); }
+ }
+
+ public event EventHandler ParentChanged {
+ add { Events.AddHandler (ParentChangedEvent, value); }
+ remove { Events.RemoveHandler (ParentChangedEvent, value); }
+ }
+
+#if NET_2_0
+ public event PreviewKeyDownEventHandler PreviewKeyDown {
+ add { Events.AddHandler (PreviewKeyDownEvent, value); }
+ remove { Events.RemoveHandler (PreviewKeyDownEvent, value); }
+ }
+#endif
+
+ public event QueryAccessibilityHelpEventHandler QueryAccessibilityHelp {
+ add { Events.AddHandler (QueryAccessibilityHelpEvent, value); }
+ remove { Events.RemoveHandler (QueryAccessibilityHelpEvent, value); }
+ }
+
+ public event QueryContinueDragEventHandler QueryContinueDrag {
+ add { Events.AddHandler (QueryContinueDragEvent, value); }
+ remove { Events.RemoveHandler (QueryContinueDragEvent, value); }
+ }
+
+#if NET_2_0
+ public event EventHandler RegionChanged {
+ add { Events.AddHandler (RegionChangedEvent, value); }
+ remove { Events.RemoveHandler (RegionChangedEvent, value); }
+ }
+#endif
+
+#if NET_2_0
+ [EditorBrowsable (EditorBrowsableState.Advanced)]
+#endif
+ public event EventHandler Resize {
+ add { Events.AddHandler (ResizeEvent, value); }
+ remove { Events.RemoveHandler (ResizeEvent, value); }
+ }
+
+ public event EventHandler RightToLeftChanged {
+ add { Events.AddHandler (RightToLeftChangedEvent, value); }
+ remove { Events.RemoveHandler (RightToLeftChangedEvent, value); }
+ }
+
+ public event EventHandler SizeChanged {
+ add { Events.AddHandler (SizeChangedEvent, value); }
+ remove { Events.RemoveHandler (SizeChangedEvent, value); }
+ }
+
+ public event EventHandler StyleChanged {
+ add { Events.AddHandler (StyleChangedEvent, value); }
+ remove { Events.RemoveHandler (StyleChangedEvent, value); }
+ }
+
+ public event EventHandler SystemColorsChanged {
+ add { Events.AddHandler (SystemColorsChangedEvent, value); }
+ remove { Events.RemoveHandler (SystemColorsChangedEvent, value); }
+ }
+
+ public event EventHandler TabIndexChanged {
+ add { Events.AddHandler (TabIndexChangedEvent, value); }
+ remove { Events.RemoveHandler (TabIndexChangedEvent, value); }
+ }
+
+ public event EventHandler TabStopChanged {
+ add { Events.AddHandler (TabStopChangedEvent, value); }
+ remove { Events.RemoveHandler (TabStopChangedEvent, value); }
+ }
+
+ public event EventHandler TextChanged {
+ add { Events.AddHandler (TextChangedEvent, value); }
+ remove { Events.RemoveHandler (TextChangedEvent, value); }
+ }
+
+ public event EventHandler Validated {
+ add { Events.AddHandler (ValidatedEvent, value); }
+ remove { Events.RemoveHandler (ValidatedEvent, value); }
+ }
+
+ public event CancelEventHandler Validating {
+ add { Events.AddHandler (ValidatingEvent, value); }
+ remove { Events.RemoveHandler (ValidatingEvent, value); }
+ }
+
+ public event EventHandler VisibleChanged {
+ add { Events.AddHandler (VisibleChangedEvent, value); }
+ remove { Events.RemoveHandler (VisibleChangedEvent, value); }
+ }
+
#endregion // Events
}
}