private Size maximum_size;
private Size minimum_size;
private SizeGripStyle size_grip_style;
+ private SizeGrip size_grip;
private Rectangle maximized_bounds;
private Rectangle default_maximized_bounds;
private double opacity;
Select (ActiveControl);
}
}
+
+ private new void UpdateSizeGripVisible ()
+ {
+ // Following link explains when to show size grip:
+ // http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=138687&SiteID=1
+ // if SizeGripStyle.Auto, only shown if form is shown using ShowDialog and is sizable
+ // if SizeGripStyle.Show, only shown if form is sizable
+
+ bool show = false;
+
+ switch (size_grip_style) {
+ case SizeGripStyle.Auto:
+ show = is_modal && (form_border_style == FormBorderStyle.Sizable || form_border_style == FormBorderStyle.SizableToolWindow);
+ break;
+ case SizeGripStyle.Hide:
+ show = false;
+ break;
+ case SizeGripStyle.Show:
+ show = (form_border_style == FormBorderStyle.Sizable || form_border_style == FormBorderStyle.SizableToolWindow);
+ break;
+ }
+
+ if (!show) {
+ if (size_grip != null && size_grip.Visible)
+ size_grip.Visible = false;
+ } else {
+ if (size_grip == null) {
+ size_grip = new SizeGrip (this);
+ size_grip.Virtual = true;
+ size_grip.FillBackground = false;
+ }
+ size_grip.Visible = true;
+ }
+ }
+
#endregion // Private & Internal Methods
#region Public Classes
+#if NET_2_0
+ [ComVisible (false)]
+#endif
public new class ControlCollection : Control.ControlCollection {
Form form_owner;
}
UpdateStyles();
+
+ if (this.Visible)
+ this.Size = SizeFromClientSize (this.ClientSize);
+ else
+ XplatUI.InvalidateNC (this.Handle);
}
}
}
}
+ [EditorBrowsable (EditorBrowsableState.Never)]
[Browsable (false)]
public new Padding Margin {
get { return base.Margin; }
set { base.Size = value; }
}
- [MonoTODO("Trigger something when GripStyle is set")]
[DefaultValue(SizeGripStyle.Auto)]
[MWFCategory("Window Style")]
public SizeGripStyle SizeGripStyle {
set {
size_grip_style = value;
+ UpdateSizeGripVisible ();
}
}
#if NET_2_0
[Browsable(false)]
- [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
+ [DefaultValue (true)]
+ [DispIdAttribute (-516)]
[EditorBrowsable(EditorBrowsableState.Never)]
public new bool TabStop {
get { return base.TabStop; }
cp.Style = (int)(WindowStyles.WS_CLIPCHILDREN | WindowStyles.WS_CLIPSIBLINGS);
+ if (Parent != null) {
+ cp.Parent = Parent.Handle;
+ cp.Style |= (int) WindowStyles.WS_CHILD;
+ }
+
if (IsMdiChild) {
cp.Style |= (int)(WindowStyles.WS_CHILD | WindowStyles.WS_CAPTION);
if (Parent != null) {
}
}
}
+#if NET_2_0
+ [MonoTODO ("Implemented for Win32, needs X11 implementation")]
+ protected virtual bool ShowWithoutActivation {
+ get { return false; }
+ }
+#endif
#endregion // Protected Instance Properties
#region Public Static Methods
}
if (owner == this) {
- throw new InvalidOperationException("The 'ownerWin32' cannot be the form being shown.");
+ throw new ArgumentException ("Forms cannot own themselves or their owners.", "owner");
}
if (is_modal) {
- throw new InvalidOperationException("The form is already displayed as a modal dialog.");
+ throw new InvalidOperationException ("The form is already displayed as a modal dialog.");
}
if (Visible) {
- throw new InvalidOperationException("Already visible forms cannot be displayed as a modal dialog. Set the Visible property to 'false' prior to calling Form.ShowDialog.");
+ throw new InvalidOperationException ("Forms that are already "
+ + " visible cannot be displayed as a modal dialog. Set the"
+ + " form's visible property to false before calling"
+ + " ShowDialog.");
}
if (!Enabled) {
- throw new InvalidOperationException("Cannot display a disabled form as modal dialog.");
+ throw new InvalidOperationException ("Forms that are not enabled"
+ + " cannot be displayed as a modal dialog. Set the form's"
+ + " enabled property to true before calling ShowDialog.");
}
if (TopLevelControl != this) {
- throw new InvalidOperationException("Can only display TopLevel forms as modal dialog.");
+ throw new InvalidOperationException ("Forms that are not top level"
+ + " forms cannot be displayed as a modal dialog. Remove the"
+ + " form from any parent form before calling ShowDialog.");
}
#if broken
}
}
+ if (this.ShowWithoutActivation)
+ Hwnd.ObjectFromHandle (this.Handle).no_activate = true;
+
XplatUI.SetWindowMinMax(window.Handle, maximized_bounds, minimum_size, maximum_size);
if ((FormBorderStyle != FormBorderStyle.FixedDialog) && (icon != null)) {
XplatUI.SetIcon(window.Handle, icon);
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected override void OnPaint (PaintEventArgs pevent) {
base.OnPaint (pevent);
+
+ if (size_grip != null) {
+ size_grip.HandlePaint (this, pevent);
+ }
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected override void OnResize(EventArgs e) {
base.OnResize(e);
- if (this.IsMdiChild && ParentForm != null) {
- ParentForm.PerformLayout();
- ParentForm.Size = ParentForm.Size;
- }
}
[EditorBrowsable(EditorBrowsableState.Advanced)]
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected override void WndProc(ref Message m) {
+#if debug
+ Console.WriteLine(DateTime.Now.ToLongTimeString () + " Form {0} ({2}) received message {1}", window.Handle == IntPtr.Zero ? this.Text : XplatUI.Window(window.Handle), m.ToString (), Text);
+#endif
if (window_manager != null && window_manager.HandleMessage (ref m)) {
return;
}
// Menu drawing
- case Msg.WM_NCLBUTTONDOWN: {
+ case Msg.WM_NCHITTEST: {
+ if (XplatUI.IsEnabled (Handle) && ActiveMenu != null) {
+ int x = LowOrder ((int)m.LParam.ToInt32 ());
+ int y = HighOrder ((int)m.LParam.ToInt32 ());
+
+ XplatUI.ScreenToMenu (ActiveMenu.Wnd.window.Handle, ref x, ref y);
+
+ // If point is under menu return HTMENU, it prevents Win32 to return HTMOVE.
+ if ((x > 0) && (y > 0) && (x < ActiveMenu.Rect.Width) && (y < ActiveMenu.Rect.Height)) {
+ m.Result = new IntPtr ((int)HitTest.HTMENU);
+ return;
+ }
+ }
+
+ base.WndProc (ref m);
+ return;
+ }
+
+ case Msg.WM_NCLBUTTONDOWN: {
if (XplatUI.IsEnabled (Handle) && ActiveMenu != null) {
ActiveMenu.OnMouseDown(this, new MouseEventArgs (FromParamToMouseButtons ((int) m.WParam.ToInt32()), mouse_clicks, Control.MousePosition.X, Control.MousePosition.Y, 0));
}
base.WndProc(ref m);
return;
}
- case Msg.WM_NCLBUTTONUP: {
+
+ case Msg.WM_NCLBUTTONUP: {
if (ActiveMaximizedMdiChild != null) {
ActiveMaximizedMdiChild.HandleMenuMouseUp (ActiveMenu,
LowOrder ((int)m.LParam.ToInt32 ()),
active_tracker.OnMouseDown(new MouseEventArgs (args.Button, args.Clicks, Control.MousePosition.X, Control.MousePosition.Y, args.Delta));
return;
}
- base.WndProc(ref m);
+#if NET_2_0
+ ToolStripManager.FireAppClicked ();
+#endif
+ base.WndProc (ref m);
return;
}
}
}
- static object AutoValidateChangedEvent = new object ();
static object FormClosingEvent = new object ();
static object FormClosedEvent = new object ();
static object HelpButtonClickedEvent = new object ();
[Browsable (true)]
[EditorBrowsable (EditorBrowsableState.Always)]
- public event EventHandler AutoValidateChanged {
- add { Events.AddHandler (AutoValidateChangedEvent, value); }
- remove { Events.RemoveHandler (AutoValidateChangedEvent, value); }
+ public new event EventHandler AutoValidateChanged {
+ add { base.AutoValidateChanged += value; }
+ remove { base.AutoValidateChanged -= value; }
}
public event FormClosingEventHandler FormClosing {
remove { base.TabStopChanged -= value; }
}
-
- [EditorBrowsable (EditorBrowsableState.Always)]
protected override void OnBackgroundImageChanged (EventArgs e)
{
base.OnBackgroundImageChanged (e);
}
- [EditorBrowsable (EditorBrowsableState.Always)]
protected override void OnBackgroundImageLayoutChanged (EventArgs e)
{
base.OnBackgroundImageLayoutChanged (e);
eh (this, e);
}
- [EditorBrowsable (EditorBrowsableState.Advanced)]
protected override void OnLayout (LayoutEventArgs levent)
{
base.OnLayout (levent);