Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/xwt.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'Xwt.XamMac/Xwt.Mac/WindowBackend.cs')
-rw-r--r--Xwt.XamMac/Xwt.Mac/WindowBackend.cs40
1 files changed, 36 insertions, 4 deletions
diff --git a/Xwt.XamMac/Xwt.Mac/WindowBackend.cs b/Xwt.XamMac/Xwt.Mac/WindowBackend.cs
index 350aed24..29c1762c 100644
--- a/Xwt.XamMac/Xwt.Mac/WindowBackend.cs
+++ b/Xwt.XamMac/Xwt.Mac/WindowBackend.cs
@@ -29,6 +29,7 @@
// THE SOFTWARE.
using System;
+using System.Linq;
using AppKit;
using CoreGraphics;
using Foundation;
@@ -110,11 +111,27 @@ namespace Xwt.Mac
internal void InternalShow ()
{
MakeKeyAndOrderFront (MacEngine.App);
+ if (ParentWindow != null)
+ {
+ if (!ParentWindow.ChildWindows.Contains(this))
+ ParentWindow.AddChildWindow(this, NSWindowOrderingMode.Above);
+
+ // always use NSWindow for alignment when running in guest mode and
+ // don't rely on AddChildWindow to position the window correctly
+ if (frontend.InitialLocation == WindowLocation.CenterParent && !(ParentWindow is WindowBackend))
+ {
+ var parentBounds = MacDesktopBackend.ToDesktopRect(ParentWindow.ContentRectFor(ParentWindow.Frame));
+ var bounds = ((IWindowFrameBackend)this).Bounds;
+ bounds.X = parentBounds.Center.X - (Frame.Width / 2);
+ bounds.Y = parentBounds.Center.Y - (Frame.Height / 2);
+ ((IWindowFrameBackend)this).Bounds = bounds;
+ }
+ }
}
public void Present ()
{
- MakeKeyAndOrderFront (MacEngine.App);
+ InternalShow();
}
public bool Visible {
@@ -238,6 +255,8 @@ namespace Xwt.Mac
PerformClose(this);
else
Close ();
+ if (ParentWindow != null)
+ ParentWindow.RemoveChildWindow(this);
return closePerformed;
}
@@ -378,8 +397,21 @@ namespace Xwt.Mac
void IWindowFrameBackend.SetTransientFor (IWindowFrameBackend window)
{
- // Generally, TransientFor is used to implement dialog, we reproduce the assumption here
- Level = window == null ? NSWindowLevel.Normal : NSWindowLevel.ModalPanel;
+ if (!((IWindowFrameBackend)this).ShowInTaskbar)
+ StyleMask &= ~NSWindowStyle.Miniaturizable;
+
+ var win = window as NSWindow ?? ApplicationContext.Toolkit.GetNativeWindow(window) as NSWindow;
+
+ if (ParentWindow != win) {
+ // remove from the previous parent
+ if (ParentWindow != null)
+ ParentWindow.RemoveChildWindow(this);
+
+ ParentWindow = win;
+ // A window must be visible to be added to a parent. See InternalShow().
+ if (Visible)
+ ParentWindow.AddChildWindow(this, NSWindowOrderingMode.Above);
+ }
}
bool IWindowFrameBackend.Resizable {
@@ -528,7 +560,7 @@ namespace Xwt.Mac
if (child != null) {
frame.X += (nfloat) frontend.Padding.Left;
frame.Width -= (nfloat) (frontend.Padding.HorizontalSpacing);
- frame.Y += (nfloat) frontend.Padding.Top;
+ frame.Y += (nfloat) (childView.IsFlipped ? frontend.Padding.Bottom : frontend.Padding.Top);
frame.Height -= (nfloat) (frontend.Padding.VerticalSpacing);
childView.Frame = frame;
}