X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/dbeddfb93d3479d03d8ec4c0121dfbe3bbcc422b..9b66a1d31a32e9235792261db6ff755ce26ab5c1:/src/osx/cocoa/nonownedwnd.mm diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index d17ce38b68..20a01d1834 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: src/mac/cocoa/nonownedwnd.mm +// Name: src/osx/cocoa/nonownedwnd.mm // Purpose: non owned window for cocoa // Author: DavidStefan Csomor // Modified by: @@ -10,23 +10,19 @@ ///////////////////////////////////////////////////////////////////////////// #include "wx/wxprec.h" - -#if wxOSX_USE_COCOA -#include -#else -#include +#ifndef WX_PRECOMP + #include "wx/nonownedwnd.h" + #include "wx/frame.h" #endif -#ifdef __WXMAC__ #include "wx/osx/private.h" -#endif NSRect wxToNSRect( NSView* parent, const wxRect& r ) { NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame]; int y = r.y; int x = r.x ; - if ( parent != NULL && ![ parent isFlipped ] ) + if ( parent == NULL || ![ parent isFlipped ] ) y = frame.size.height - ( r.y + r.height ); return NSMakeRect(x, y, r.width , r.height); } @@ -36,7 +32,7 @@ wxRect wxFromNSRect( NSView* parent, const NSRect& rect ) NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame]; int y = rect.origin.y; int x = rect.origin.x; - if ( parent != NULL && ![ parent isFlipped ] ) + if ( parent == NULL || ![ parent isFlipped ] ) y = frame.size.height - (rect.origin.y + rect.size.height); return wxRect( x, y, rect.size.width, rect.size.height ); } @@ -46,7 +42,7 @@ NSPoint wxToNSPoint( NSView* parent, const wxPoint& p ) NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame]; int x = p.x ; int y = p.y; - if ( parent != NULL && ![ parent isFlipped ] ) + if ( parent == NULL || ![ parent isFlipped ] ) y = frame.size.height - ( p.y ); return NSMakePoint(x, y); } @@ -56,7 +52,7 @@ wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p ) NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame]; int x = p.x; int y = p.y; - if ( parent != NULL && ![ parent isFlipped ] ) + if ( parent == NULL || ![ parent isFlipped ] ) y = frame.size.height - ( p.y ); return wxPoint( x, y); } @@ -141,10 +137,26 @@ wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p ) return NO; } -- (NSSize)windowWillResize:(NSWindow *)window +- (NSSize)windowWillResize:(NSWindow *)win toSize:(NSSize)proposedFrameSize { - // todo + NSRect frame = [win frame]; + wxRect wxframe = wxFromNSRect( NULL, frame ); + wxframe.SetWidth( proposedFrameSize.width ); + wxframe.SetHeight( proposedFrameSize.height ); + wxNSWindow* window = (wxNSWindow*) win; + wxNonOwnedWindowCocoaImpl* windowimpl = [window implementation]; + if ( windowimpl ) + { + wxNonOwnedWindow* wxpeer = windowimpl->GetWXPeer(); + if ( wxpeer ) + { + wxpeer->HandleResizing( 0, &wxframe ); + NSSize newSize = NSMakeSize(wxframe.GetWidth(), wxframe.GetHeight()); + return newSize; + } + } + return proposedFrameSize; } @@ -239,7 +251,7 @@ long style, long extraStyle, const wxString& name ) else m_macWindow = [wxNSWindow alloc]; - CGWindowLevel level = kCGNormalWindowLevelKey; + CGWindowLevel level = kCGNormalWindowLevel; if ( style & wxFRAME_TOOL_WINDOW ) {