Author: jackson
Date: 2005-12-13 14:49:02 -0500 (Tue, 13 Dec 2005)
New Revision: 54314
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
Modified:
trunk/mcs/class/Managed.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
Log:
* System.Windows.Forms.dll.sources: Add the new internal window
managers
* Form.cs: We now hook into an internal window manager instead of just
an
MDI subsystem, this is so we can have properly behaving tool windows.
* MdiClient.cs: Naming change, MdiChildContext is now WindowManager
* InternalWindowManager.cs: New internal class that acts as a
window manager for tool windows and as a base for mdi windows.
* MdiWindowManager.cs: New class that acts as a window manager for
mdi windows.
Modified: trunk/mcs/class/Managed.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2005-12-13 19:25:24 UTC
(rev 54313)
+++ trunk/mcs/class/Managed.Windows.Forms/ChangeLog 2005-12-13 19:49:02 UTC
(rev 54314)
@@ -1,3 +1,8 @@
+2005-12-13 Jackson Harper <[EMAIL PROTECTED]>
+
+ * System.Windows.Forms.dll.sources: Add the new internal window
+ managers
+
2005-12-04 Alexander Olk <[EMAIL PROTECTED]>
* System.Windows.Forms.dll.sources: Added ThemeClearlooks.cs
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-12-13 19:25:24 UTC (rev 54313)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/ChangeLog
2005-12-13 19:49:02 UTC (rev 54314)
@@ -1,3 +1,13 @@
+2005-12-13 Jackson Harper <[EMAIL PROTECTED]>
+
+ * Form.cs: We now hook into an internal window manager instead of just
an
+ MDI subsystem, this is so we can have properly behaving tool windows.
+ * MdiClient.cs: Naming change, MdiChildContext is now WindowManager
+ * InternalWindowManager.cs: New internal class that acts as a
+ window manager for tool windows and as a base for mdi windows.
+ * MdiWindowManager.cs: New class that acts as a window manager for
+ mdi windows.
+
2005-12-12 Jackson Harper <[EMAIL PROTECTED]>
* Control.cs: Updates so we match behavoir for for implicit
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
2005-12-13 19:25:24 UTC (rev 54313)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/Form.cs
2005-12-13 19:49:02 UTC (rev 54314)
@@ -63,7 +63,7 @@
private Form owner;
private Form.ControlCollection owned_forms;
private MdiClient mdi_container;
- private MdiChildContext mdi_child_context;
+ private InternalWindowManager window_manager;
private Form mdi_parent;
private bool key_preview;
private MainMenu menu;
@@ -325,18 +325,19 @@
set {
form_border_style = value;
- // MDI windows handle borders themselves
- if (!IsMdiChild) {
+ if (window_manager == null) {
if (IsHandleCreated) {
XplatUI.SetBorderStyle(window.Handle, form_border_style);
}
UpdateStyles();
+
+ if (value ==
FormBorderStyle.FixedToolWindow ||
+ value ==
FormBorderStyle.SizableToolWindow)
+ window_manager = new
InternalWindowManager (this);
} else {
- if (mdi_child_context != null &&
IsHandleCreated)
-
mdi_child_context.UpdateBorderStyle (value);
- UpdateStyles ();
+ window_manager.UpdateBorderStyle
(value);
}
- }
+ }
}
[DefaultValue(false)]
@@ -494,7 +495,7 @@
mdi_parent = value;
if (mdi_parent != null) {
- mdi_child_context = new MdiChildContext
(this,
+ window_manager = new MdiWindowManager
(this,
mdi_parent.MdiContainer);
mdi_parent.MdiContainer.Controls.Add
(this);
}
@@ -507,8 +508,8 @@
get { return mdi_container; }
}
- internal MdiChildContext MdiChildContext {
- get { return mdi_child_context; }
+ internal InternalWindowManager WindowManager {
+ get { return window_manager; }
}
[DefaultValue(null)]
@@ -538,9 +539,9 @@
public MainMenu MergedMenu {
get {
- if (!IsMdiChild || mdi_child_context == null)
+ if (!IsMdiChild || window_manager == null)
return null;
- return mdi_child_context.MergedMenu;
+ return ((MdiWindowManager)
window_manager).MergedMenu;
}
}
@@ -1438,8 +1439,7 @@
[EditorBrowsable(EditorBrowsableState.Advanced)]
protected override void WndProc(ref Message m) {
- if (IsMdiChild && mdi_child_context != null &&
- mdi_child_context.HandleMessage (ref
m)) {
+ if (window_manager != null &&
window_manager.HandleMessage (ref m)) {
return;
}
@@ -1539,6 +1539,11 @@
}
#endregion // Protected Instance Methods
+ internal void RemoveWindowManager ()
+ {
+ window_manager = null;
+ }
+
#region Events
public event EventHandler Activated;
public event EventHandler Closed;
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
2005-12-13 19:25:24 UTC (rev 54313)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/InternalWindowManager.cs
2005-12-13 19:49:02 UTC (rev 54314)
@@ -0,0 +1,654 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Jackson Harper ([EMAIL PROTECTED])
+//
+//
+
+
+using System;
+using System.Drawing;
+
+namespace System.Windows.Forms {
+
+ internal class InternalWindowManager {
+
+ private static Color titlebar_color;
+
+ private int BorderWidth = 3;
+ private Size MinTitleBarSize = new Size (115, 25);
+
+ internal Form form;
+
+ private TitleButton close_button;
+ private TitleButton maximize_button;
+ private TitleButton minimize_button;
+
+ private TitleButton [] title_buttons = new TitleButton [3];
+
+ // moving windows
+ private Point start;
+ private State state;
+ private FormPos sizing_edge;
+ private Rectangle virtual_position;
+ private Rectangle prev_virtual_position;
+ private Rectangle prev_bounds;
+ private bool maximized;
+
+ private class TitleButton {
+ public Rectangle Rectangle;
+ public ButtonState State;
+ public CaptionButton Caption;
+ public EventHandler Clicked;
+
+ public TitleButton (CaptionButton caption, EventHandler
clicked)
+ {
+ Caption = caption;
+ Clicked = clicked;
+ }
+ }
+
+ private enum State {
+ Idle,
+ Moving,
+ Sizing,
+ }
+
+ [Flags]
+ private enum FormPos {
+ None,
+
+ TitleBar = 1,
+
+ Top = 2,
+ Left = 4,
+ Right = 8,
+ Bottom = 16,
+
+ TopLeft = Top | Left,
+ TopRight = Top | Right,
+
+ BottomLeft = Bottom | Left,
+ BottomRight = Bottom | Right,
+
+ AnyEdge = Top | Left | Right | Bottom,
+ }
+
+ public InternalWindowManager (Form form)
+ {
+ titlebar_color = Color.FromArgb (255, 0, 0, 255);
+ this.form = form;
+
+ CreateButtons ();
+ }
+
+ public Form Form {
+ get { return form; }
+ }
+
+ public bool Maximized {
+ get { return maximized; }
+ }
+
+ public bool HandleMessage (ref Message m)
+ {
+ switch ((Msg)m.Msg) {
+
+
+ // The mouse handling messages are actually
+ // not WM_NC* messages except for the first
button and NCMOVEs
+ // down because we capture on the form
+
+ case Msg.WM_MOUSEMOVE:
+ return HandleMouseMove (form, ref m);
+
+ case Msg.WM_LBUTTONUP:
+ HandleLButtonUp (ref m);
+ break;
+
+ case Msg.WM_RBUTTONDOWN:
+ case Msg.WM_LBUTTONDOWN:
+ return HandleButtonDown (ref m);
+
+ case Msg.WM_NCMOUSEMOVE:
+ return HandleNCMouseMove (form, ref m);
+
+ case Msg.WM_NCLBUTTONUP:
+ return HandleNCLButtonUp (ref m);
+
+ case Msg.WM_NCLBUTTONDOWN:
+ return HandleNCLButtonDown (ref m);
+
+ case Msg.WM_MOUSE_LEAVE:
+ FormMouseLeave (ref m);
+ break;
+
+ case Msg.WM_NCPAINT:
+ PaintWindowDecorations ();
+ break;
+ }
+ return false;
+ }
+
+ public virtual void UpdateBorderStyle (FormBorderStyle
border_style)
+ {
+ XplatUI.SetBorderStyle (form.Handle, border_style);
+
+ if (ShouldRemoveWindowManager (border_style)) {
+ form.RemoveWindowManager ();
+ return;
+ }
+
+ CreateButtons ();
+ }
+
+ public virtual void PointToClient (ref int x, ref int y)
+ {
+ XplatUI.ScreenToClient (form.Handle, ref x, ref y);
+ }
+
+ public virtual void PointToScreen (ref int x, ref int y)
+ {
+ XplatUI.ClientToScreen (form.Handle, ref x, ref y);
+ }
+
+ protected virtual bool ShouldRemoveWindowManager
(FormBorderStyle style)
+ {
+ return style != FormBorderStyle.FixedToolWindow &&
style != FormBorderStyle.SizableToolWindow;
+ }
+
+ private void CreateButtons ()
+ {
+ switch (form.FormBorderStyle) {
+ case FormBorderStyle.None:
+ close_button = null;
+ minimize_button = null;
+ maximize_button = null;
+ break;
+ case FormBorderStyle.FixedSingle:
+ case FormBorderStyle.Fixed3D:
+ case FormBorderStyle.FixedDialog:
+ case FormBorderStyle.Sizable:
+ close_button = new TitleButton
(CaptionButton.Close, new EventHandler (CloseClicked));
+ minimize_button = new TitleButton
(CaptionButton.Minimize, new EventHandler (MinimizeClicked));
+ maximize_button = new TitleButton
(CaptionButton.Maximize, new EventHandler (MaximizeClicked));
+ break;
+ case FormBorderStyle.FixedToolWindow:
+ case FormBorderStyle.SizableToolWindow:
+ close_button = new TitleButton
(CaptionButton.Close, new EventHandler (CloseClicked));
+ break;
+ }
+
+ title_buttons [0] = close_button;
+ title_buttons [1] = minimize_button;
+ title_buttons [2] = maximize_button;
+ }
+
+ protected virtual bool HandleButtonDown (ref Message m)
+ {
+ form.BringToFront ();
+ return false;
+ }
+
+ protected virtual bool HandleNCLButtonDown (ref Message m)
+ {
+ form.BringToFront ();
+
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ int client_x = x;
+ int client_y = y;
+
+ PointToClient (ref client_x, ref client_y);
+ start = new Point (client_x, client_y);
+ virtual_position = form.Bounds;
+
+ form.PointToClient (ref x, ref y);
+ // Need to adjust because we are in NC land
+ y += TitleBarHeight;
+ FormPos pos = FormPosForCoords (x, y);
+
+ if (pos == FormPos.TitleBar) {
+ HandleTitleBarDown (x, y);
+ return true;
+ }
+
+ if (IsSizable) {
+ SetCursorForPos (pos);
+
+ if ((pos & FormPos.AnyEdge) == 0)
+ return false;
+
+ state = State.Sizing;
+ sizing_edge = pos;
+ form.Capture = true;
+ return true;
+ }
+
+ return false;
+ }
+
+ private void HandleTitleBarDown (int x, int y)
+ {
+ foreach (TitleButton button in title_buttons) {
+ if (button != null && button.Rectangle.Contains
(x, y)) {
+ button.State = ButtonState.Pushed;
+ return;
+ }
+ }
+
+ if (maximized)
+ return;
+
+ state = State.Moving;
+ form.Capture = true;
+ }
+
+ private bool HandleMouseMove (Form form, ref Message m)
+ {
+ switch (state) {
+ case State.Moving:
+ HandleWindowMove (m);
+ return true;
+ case State.Sizing:
+ HandleSizing (m);
+ return true;
+ }
+
+ /*
+ if (IsSizable) {
+ int x = Control.LowOrder ((int)
m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int)
m.LParam.ToInt32 ());
+ FormPos pos = FormPosForCoords (x, y);
+ Console.WriteLine ("position: " + pos);
+ SetCursorForPos (pos);
+
+ ClearVirtualPosition ();
+ state = State.Idle;
+ }
+ */
+
+ return false;
+ }
+
+ private bool HandleNCMouseMove (Form form, ref Message m)
+ {
+ if (IsSizable) {
+ int x = Control.LowOrder ((int)
m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int)
m.LParam.ToInt32 ());
+ FormPos pos = FormPosForCoords (x, y);
+
+ SetCursorForPos (pos);
+
+ ClearVirtualPosition ();
+ state = State.Idle;
+ }
+
+ return false;
+ }
+
+ private void FormMouseLeave (ref Message m)
+ {
+ form.ResetCursor ();
+ }
+
+ private void SetCursorForPos (FormPos pos)
+ {
+ switch (pos) {
+ case FormPos.TopLeft:
+ case FormPos.BottomRight:
+ form.Cursor = Cursors.SizeNWSE;
+ break;
+ case FormPos.TopRight:
+ case FormPos.BottomLeft:
+ form.Cursor = Cursors.SizeNESW;
+ break;
+ case FormPos.Top:
+ case FormPos.Bottom:
+ form.Cursor = Cursors.SizeNS;
+ break;
+ case FormPos.Left:
+ case FormPos.Right:
+ form.Cursor = Cursors.SizeWE;
+ break;
+ default:
+ form.ResetCursor ();
+ break;
+ }
+ }
+
+ protected virtual void HandleWindowMove (Message m)
+ {
+ Point move = MouseMove (m);
+
+ virtual_position.X = start.X + move.X;
+ virtual_position.Y = start.Y + move.Y;
+ virtual_position.Width = form.Width;
+ virtual_position.Height = form.Height;
+
+ DrawVirtualPosition (virtual_position);
+ }
+
+ private void HandleSizing (Message m)
+ {
+ Point move = MouseMove (m);
+ Rectangle pos = virtual_position;
+ int mw = MinTitleBarSize.Width + (BorderWidth * 2);
+ int mh = MinTitleBarSize.Height + (BorderWidth * 2);
+
+ if ((sizing_edge & FormPos.Top) != 0) {
+ int height = form.Height - move.Y;
+ if (height <= mh) {
+ move.Y += height - mh;
+ height = mh;
+ }
+ pos.Y = form.Top + move.Y;
+ pos.Height = height;
+ } else if ((sizing_edge & FormPos.Bottom) != 0) {
+ int height = form.Height + move.Y;
+ if (height <= mh)
+ move.Y -= height - mh;
+ pos.Height = form.Height + move.Y;
+ }
+
+ if ((sizing_edge & FormPos.Left) != 0) {
+ int width = form.Width - move.X;
+ if (width <= mw) {
+ move.X += width - mw;
+ width = mw;
+ }
+ pos.X = form.Left + move.X;
+ pos.Width = width;
+ } else if ((sizing_edge & FormPos.Right) != 0) {
+ int width = form.Width + move.X;
+ if (width <= mw)
+ move.X -= width - mw;
+ pos.Width = form.Width + move.X;
+ }
+
+ UpdateVP (pos);
+ }
+
+ private bool IsSizable {
+ get {
+ switch (form.FormBorderStyle) {
+ case FormBorderStyle.Sizable:
+ case FormBorderStyle.SizableToolWindow:
+ return true;
+ default:
+ return false;
+ }
+ }
+ }
+
+ private bool HasBorders {
+ get {
+ return form.FormBorderStyle !=
FormBorderStyle.None;
+ }
+ }
+
+ private bool IsToolWindow {
+ get {
+ if (form.FormBorderStyle ==
FormBorderStyle.SizableToolWindow ||
+ form.FormBorderStyle ==
FormBorderStyle.FixedToolWindow)
+ return true;
+ return false;
+ }
+ }
+
+ private int TitleBarHeight {
+ get {
+ if (IsToolWindow)
+ return 19;
+ if (form.FormBorderStyle ==
FormBorderStyle.None)
+ return 0;
+ return 26;
+ }
+ }
+
+ private void UpdateVP (Rectangle r)
+ {
+ UpdateVP (r.X, r.Y, r.Width, r.Height);
+ }
+
+ private void UpdateVP (Point loc, int w, int h)
+ {
+ UpdateVP (loc.X, loc.Y, w, h);
+ }
+
+ private void UpdateVP (int x, int y, int w, int h)
+ {
+ virtual_position.X = x;
+ virtual_position.Y = y;
+ virtual_position.Width = w;
+ virtual_position.Height = h;
+
+ DrawVirtualPosition (virtual_position);
+ }
+
+ private void HandleLButtonUp (ref Message m)
+ {
+ if (state == State.Idle)
+ return;
+
+ ClearVirtualPosition ();
+
+ form.Capture = false;
+ form.Bounds = virtual_position;
+ state = State.Idle;
+ }
+
+ private bool HandleNCLButtonUp (ref Message m)
+ {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ form.PointToClient (ref x, ref y);
+
+ // Need to adjust because we are in NC land
+ y += TitleBarHeight;
+
+ foreach (TitleButton button in title_buttons) {
+ if (button != null && button.Rectangle.Contains
(x, y)) {
+ button.Clicked (this, EventArgs.Empty);
+ return true;
+ }
+ }
+
+ return true;
+ }
+
+ private void PaintWindowDecorations ()
+ {
+ Graphics dc = XplatUI.GetMenuDC (form.Handle,
IntPtr.Zero);
+
+ if (HasBorders) {
+ Rectangle borders = new Rectangle (0, 0,
form.Width, form.Height);
+
+ ControlPaint.DrawBorder3D (dc, borders,
Border3DStyle.Raised);
+
+ if (IsSizable) {
+ borders.Inflate (-1, -1);
+ ControlPaint.DrawFocusRectangle (dc,
borders);
+ }
+ }
+
+ Color color = ThemeEngine.Current.ColorControlDark;
+
+ if (form.Focused && !maximized)
+ color = titlebar_color;
+
+ Rectangle tb = new Rectangle (BorderWidth, BorderWidth,
+ form.Width - (BorderWidth * 2),
TitleBarHeight - 1);
+
+ dc.FillRectangle
(ThemeEngine.Current.ResPool.GetSolidBrush (color), tb);
+
+ dc.DrawLine (new Pen (Color.White, 1), BorderWidth,
+ TitleBarHeight + BorderWidth,
form.Width - BorderWidth,
+ TitleBarHeight + BorderWidth);
+
+ if (!IsToolWindow) {
+ tb.X += 18; // Room for the icon and the buttons
+ tb.Width = (form.Width - 62) - tb.X;
+ }
+
+ if (form.Text != null) {
+ StringFormat format = new StringFormat ();
+ format.FormatFlags = StringFormatFlags.NoWrap;
+ format.Trimming =
StringTrimming.EllipsisCharacter;
+ format.LineAlignment = StringAlignment.Center;
+ dc.DrawString (form.Text, form.Font,
+
ThemeEngine.Current.ResPool.GetSolidBrush (Color.White),
+ tb, format);
+ }
+
+ if (!IsToolWindow && HasBorders) {
+ if (form.Icon != null) {
+ dc.DrawIcon (form.Icon, new Rectangle
(BorderWidth + 3,
+
BorderWidth + 3, 16, 16));
+ }
+
+ minimize_button.Rectangle = new Rectangle
(form.Width - 62,
+ BorderWidth + 2, 18, 22);
+
+ maximize_button.Rectangle = new Rectangle
(form.Width - 44,
+ BorderWidth + 2, 18, 22);
+
+ close_button.Rectangle = new Rectangle
(form.Width - 24,
+ BorderWidth + 2, 18, 22);
+
+ DrawTitleButton (dc, minimize_button);
+ DrawTitleButton (dc, maximize_button);
+ DrawTitleButton (dc, close_button);
+ } else if (IsToolWindow) {
+ close_button.Rectangle = new Rectangle
(form.Width - BorderWidth - 2 - 13,
+ BorderWidth + 2, 13, 13);
+ DrawTitleButton (dc, close_button);
+ }
+ }
+
+ private void DrawTitleButton (Graphics dc, TitleButton button)
+ {
+ dc.FillRectangle (SystemBrushes.Control,
button.Rectangle);
+
+ ControlPaint.DrawCaptionButton (dc, button.Rectangle,
+ button.Caption, ButtonState.Normal);
+ }
+
+ private void CloseClicked (object sender, EventArgs e)
+ {
+ form.Close ();
+ // form.Close should set visibility to false somewhere
+ // in it's closing chain but currently does not.
+ form.Visible = false;
+ }
+
+ private void MinimizeClicked (object sender, EventArgs e)
+ {
+ form.SuspendLayout ();
+ form.Width = MinTitleBarSize.Width + (BorderWidth * 2);
+ form.Height = MinTitleBarSize.Height + (BorderWidth *
2);
+ form.ResumeLayout ();
+ }
+
+ private void MaximizeClicked (object sender, EventArgs e)
+ {
+ if (maximized) {
+ form.Bounds = prev_bounds;
+ maximized = false;
+ } else {
+ prev_bounds = form.Bounds;
+ form.Bounds = form.Parent.Bounds;
+ maximized = true;
+ }
+ }
+
+ private Point MouseMove (Message m)
+ {
+ int x = Control.LowOrder ((int) m.LParam.ToInt32 ());
+ int y = Control.HighOrder ((int) m.LParam.ToInt32 ());
+
+ form.PointToScreen (ref x, ref y);
+ PointToClient (ref x, ref y);
+ int x_move = x - start.X;
+ int y_move = y - start.Y;
+
+ return new Point (x_move, y_move);
+ }
+
+ protected virtual void DrawVirtualPosition (Rectangle
virtual_position)
+ {
+ form.Bounds = virtual_position;
+ start = form.Location;
+ }
+
+ protected virtual void ClearVirtualPosition ()
+ {
+
+ }
+
+ private FormPos FormPosForCoords (int x, int y)
+ {
+ if (y < TitleBarHeight + BorderWidth) {
+
+ if (y > BorderWidth && x > BorderWidth &&
+ x < form.Width - BorderWidth)
+ return FormPos.TitleBar;
+
+ if (x < BorderWidth || (x < 20 && y <
BorderWidth))
+ return FormPos.TopLeft;
+
+ if (x > form.Width - BorderWidth ||
+ (x > form.Width - 20 && y <
BorderWidth))
+ return FormPos.TopRight;
+
+ if (y < BorderWidth)
+ return FormPos.Top;
+
+ } else if (y > form.Height - 20) {
+
+ if (x < BorderWidth ||
+ (x < 20 && y > form.Height -
BorderWidth))
+ return FormPos.BottomLeft;
+
+ if (x > form.Width - BorderWidth ||
+ (x > form.Width - 20 &&
+ y > form.Height - BorderWidth))
+ return FormPos.BottomRight;
+
+ if (y > form.Height - BorderWidth)
+ return FormPos.Bottom;
+
+
+ } else if (x < BorderWidth) {
+ return FormPos.Left;
+ } else if (x > form.Width - BorderWidth) {
+ return FormPos.Right;
+ }
+
+ return FormPos.None;
+ }
+ }
+}
+
+
Modified:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
2005-12-13 19:25:24 UTC (rev 54313)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiClient.cs
2005-12-13 19:49:02 UTC (rev 54314)
@@ -304,7 +304,7 @@
if (!child.Visible)
continue;
- if (child.MdiChildContext.Maximized)
+ if (child.WindowManager.Maximized)
child.Bounds = Bounds;
}
}
Added:
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
===================================================================
---
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
2005-12-13 19:25:24 UTC (rev 54313)
+++
trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms/MdiWindowManager.cs
2005-12-13 19:49:02 UTC (rev 54314)
@@ -0,0 +1,114 @@
+// Permission is hereby granted, free of charge, to any person obtaining
+// a copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to
+// permit persons to whom the Software is furnished to do so, subject to
+// the following conditions:
+//
+// The above copyright notice and this permission notice shall be
+// included in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
+// 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) 2005 Novell, Inc. (http://www.novell.com)
+//
+// Authors:
+// Jackson Harper ([EMAIL PROTECTED])
+//
+//
+
+
+using System;
+using System.Drawing;
+using System.Drawing.Drawing2D;
+
+namespace System.Windows.Forms {
+
+ internal class MdiWindowManager : InternalWindowManager {
+
+ private static readonly int MdiBorderStyle = 0xFFFF;
+
+ private MainMenu merged_menu;
+ private MdiClient mdi_container;
+ private Rectangle prev_virtual_position;
+
+ public MdiWindowManager (Form form, MdiClient mdi_container) :
base (form)
+ {
+ this.mdi_container = mdi_container;
+ }
+
+ public MainMenu MergedMenu {
+ get {
+ if (merged_menu == null)
+ merged_menu = CreateMergedMenu ();
+ return merged_menu;
+ }
+ }
+
+ private MainMenu CreateMergedMenu ()
+ {
+ Form parent = (Form) mdi_container.Parent;
+ MainMenu clone = (MainMenu) parent.Menu.CloneMenu ();
+ clone.MergeMenu (form.Menu);
+ clone.MenuChanged += new EventHandler
(MenuChangedHandler);
+ clone.SetForm (parent);
+ return clone;
+ }
+
+ private void MenuChangedHandler (object sender, EventArgs e)
+ {
+ CreateMergedMenu ();
+ }
+
+ public override void PointToClient (ref int x, ref int y)
+ {
+ XplatUI.ScreenToClient (mdi_container.Handle, ref x,
ref y);
+ }
+
+ public override void PointToScreen (ref int x, ref int y)
+ {
+ XplatUI.ClientToScreen (mdi_container.Handle, ref x,
ref y);
+ }
+
+ public override void UpdateBorderStyle (FormBorderStyle
border_style)
+ {
+ base.UpdateBorderStyle (border_style);
+
+ if (border_style != FormBorderStyle.None)
+ XplatUI.SetBorderStyle (form.Handle,
(FormBorderStyle) MdiBorderStyle);
+ else
+ XplatUI.SetBorderStyle (form.Handle,
FormBorderStyle.None);
+ }
+
+ protected override bool ShouldRemoveWindowManager
(FormBorderStyle style)
+ {
+ return false;
+ }
+
+ protected override void DrawVirtualPosition (Rectangle
virtual_position)
+ {
+ ClearVirtualPosition ();
+
+ if (form.Parent != null)
+ XplatUI.DrawReversibleRectangle
(form.Parent.Handle, virtual_position, 2);
+ prev_virtual_position = virtual_position;
+
+ }
+
+ protected override void ClearVirtualPosition ()
+ {
+ if (prev_virtual_position != Rectangle.Empty &&
form.Parent != null)
+ XplatUI.DrawReversibleRectangle
(form.Parent.Handle,
+ prev_virtual_position, 2);
+ prev_virtual_position = Rectangle.Empty;
+ }
+ }
+}
+
Modified: trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
===================================================================
--- trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
2005-12-13 19:25:24 UTC (rev 54313)
+++ trunk/mcs/class/Managed.Windows.Forms/System.Windows.Forms.dll.sources
2005-12-13 19:49:02 UTC (rev 54314)
@@ -292,6 +292,7 @@
System.Windows.Forms/InputLanguageChangingEventHandler.cs
System.Windows.Forms/InputLanguageCollection.cs
System.Windows.Forms/InputLanguage.cs
+System.Windows.Forms/InternalWindowManager.cs
System.Windows.Forms/InvalidateEventArgs.cs
System.Windows.Forms/InvalidateEventHandler.cs
System.Windows.Forms/IRootGridEntry.cs
@@ -334,6 +335,7 @@
System.Windows.Forms/ListViewItem.cs
System.Windows.Forms/ListViewItemConverter.cs
System.Windows.Forms/MainMenu.cs
+System.Windows.Forms/MdiWindowManager.cs
System.Windows.Forms/MdiChildContext.cs
System.Windows.Forms/MdiClient.cs
System.Windows.Forms/MdiLayout.cs
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches