#ifndef WX_PRECOMP
#include "wx/nonownedwnd.h"
#include "wx/frame.h"
+ #include "wx/app.h"
+ #include "wx/dialog.h"
#endif
#include "wx/osx/private.h"
+NSScreen* wxOSXGetMenuScreen()
+{
+ if ( [NSScreen screens] == nil )
+ return [NSScreen mainScreen];
+ else
+ {
+ return [[NSScreen screens] objectAtIndex:0];
+ }
+}
+
NSRect wxToNSRect( NSView* parent, const wxRect& r )
{
- NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame];
+ NSRect frame = parent ? [parent bounds] : [wxOSXGetMenuScreen() frame];
int y = r.y;
int x = r.x ;
if ( parent == NULL || ![ parent isFlipped ] )
wxRect wxFromNSRect( NSView* parent, const NSRect& rect )
{
- NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame];
+ NSRect frame = parent ? [parent bounds] : [wxOSXGetMenuScreen() frame];
int y = (int)rect.origin.y;
int x = (int)rect.origin.x;
if ( parent == NULL || ![ parent isFlipped ] )
NSPoint wxToNSPoint( NSView* parent, const wxPoint& p )
{
- NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame];
+ NSRect frame = parent ? [parent bounds] : [wxOSXGetMenuScreen() frame];
int x = p.x ;
int y = p.y;
if ( parent == NULL || ![ parent isFlipped ] )
wxPoint wxFromNSPoint( NSView* parent, const NSPoint& p )
{
- NSRect frame = parent ? [parent bounds] : [[NSScreen mainScreen] frame];
+ NSRect frame = parent ? [parent bounds] : [wxOSXGetMenuScreen() frame];
int x = (int)p.x;
int y = (int)p.y;
if ( parent == NULL || ![ parent isFlipped ] )
|| selector == @selector(deleteForward:)
|| selector == @selector(insertNewline:)
|| selector == @selector(insertTab:)
+ || selector == @selector(insertBacktab:)
|| selector == @selector(keyDown:)
|| selector == @selector(keyUp:)
|| selector == @selector(scrollPageUp:)
- (void)sendEvent:(NSEvent *) event
{
if ( ![self WX_filterSendEvent: event] )
+ {
+ WXEVENTREF formerEvent = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEvent();
+ WXEVENTHANDLERCALLREF formerHandler = wxTheApp == NULL ? NULL : wxTheApp->MacGetCurrentEventHandlerCallRef();
+
+ if (wxTheApp)
+ wxTheApp->MacSetCurrentEvent(event, NULL);
+
[super sendEvent: event];
+
+ if (wxTheApp)
+ wxTheApp->MacSetCurrentEvent(formerEvent , formerHandler);
+ }
}
// The default implementation always moves the window back onto the screen,
{
}
+- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen;
- (void)noResponderFor: (SEL) selector;
- (void)sendEvent:(NSEvent *)event;
@end
@implementation wxNSPanel
+- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen
+{
+ wxNonOwnedWindowCocoaImpl* impl = (wxNonOwnedWindowCocoaImpl*) wxNonOwnedWindowImpl::FindFromWXWindow( self );
+ if (impl && impl->IsFullScreen())
+ return frameRect;
+ else
+ return [super constrainFrameRect:frameRect toScreen:screen];
+}
+
- (BOOL)canBecomeKeyWindow
{
return YES;
}
}
-void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), const wxPoint& pos, const wxSize& size,
+void wxNonOwnedWindowCocoaImpl::Create( wxWindow* parent, const wxPoint& pos, const wxSize& size,
long style, long extraStyle, const wxString& WXUNUSED(name) )
{
static wxNonOwnedWindowController* controller = NULL;
defer:NO
];
+ // If the parent is modal, windows with wxFRAME_FLOAT_ON_PARENT style need
+ // to be in kCGUtilityWindowLevel and not kCGFloatingWindowLevel to stay
+ // above the parent.
+ wxDialog * const parentDialog = wxDynamicCast(parent, wxDialog);
+ if (parentDialog && parentDialog->IsModal())
+ {
+ if (level == kCGFloatingWindowLevel)
+ {
+ level = kCGUtilityWindowLevel;
+ }
+
+ // Cocoa's modal loop does not process other windows by default, but
+ // don't call this on normal window levels so nested modal dialogs will
+ // still behave modally.
+ if (level != kCGNormalWindowLevel)
+ {
+ if ([m_macWindow isKindOfClass:[NSPanel class]])
+ {
+ [(NSPanel*)m_macWindow setWorksWhenModal:YES];
+ }
+ }
+ }
+
[m_macWindow setLevel:level];
[m_macWindow setDelegate:controller];
[m_macWindow setOpaque:NO];
[m_macWindow setAlphaValue:1.0];
}
+
+ if ( !(style & wxFRAME_TOOL_WINDOW) )
+ [m_macWindow setHidesOnDeactivate:NO];
}
void wxNonOwnedWindowCocoaImpl::Create( wxWindow* WXUNUSED(parent), WXWindow nativeWindow )
data->m_formerFrame = [m_macWindow frame];
CGDisplayCapture( kCGDirectMainDisplay );
[m_macWindow setLevel:CGShieldingWindowLevel()];
- [m_macWindow setFrame:[[NSScreen mainScreen] frame] display:YES];
+ NSRect screenframe = [[NSScreen mainScreen] frame];
+ NSRect frame = NSMakeRect (0, 0, 100, 100);
+ NSRect contentRect;
+ contentRect = [NSWindow contentRectForFrameRect: frame
+ styleMask: NSTitledWindowMask];
+ screenframe.origin.y += (frame.origin.y - contentRect.origin.y);
+ screenframe.size.height += (frame.size.height - contentRect.size.height);
+ [m_macWindow setFrame:screenframe display:YES];
}
else if ( m_macFullScreenData != NULL )
{