X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/1f83c63111596f19a2247e1d1be0eb96b8dc5ddc..65391c8ffcb388cd31f610776654f50aed97cbee:/src/osx/cocoa/nonownedwnd.mm diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index 6e617f9bfd..d17540c296 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -88,6 +88,7 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector wxNonOwnedWindowCocoaImpl* impl; } +- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen; - (void)setImplementation: (wxNonOwnedWindowCocoaImpl *) theImplementation; - (wxNonOwnedWindowCocoaImpl*) implementation; - (void)noResponderFor: (SEL) selector; @@ -95,6 +96,13 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector @implementation wxNSWindow +// The default implementation always moves the window back onto the screen, +// even when the programmer explicitly wants to hide it. +- (NSRect)constrainFrameRect:(NSRect)frameRect toScreen:(NSScreen *)screen +{ + return frameRect; +} + - (void)setImplementation: (wxNonOwnedWindowCocoaImpl *) theImplementation { impl = theImplementation; @@ -124,6 +132,14 @@ typedef void (*wxOSX_NoResponderHandlerPtr)(NSView* self, SEL _cmd, SEL selector } } +// We need this for borderless windows, i.e. shaped windows or windows without +// a title bar. For more info, see: +// http://lists.apple.com/archives/cocoa-dev/2008/May/msg02091.html +- (BOOL)canBecomeKeyWindow +{ + return YES; +} + @end @interface wxNSPanel : NSPanel @@ -441,6 +457,7 @@ long style, long extraStyle, const wxString& WXUNUSED(name) ) NSRect r = wxToNSRect( NULL, wxRect( pos, size) ); [m_macWindow setImplementation:this]; + r = [NSWindow contentRectForFrameRect:r styleMask:windowstyle]; [m_macWindow initWithContentRect:r styleMask:windowstyle @@ -471,26 +488,34 @@ void wxNonOwnedWindowCocoaImpl::Lower() [m_macWindow orderWindow:NSWindowBelow relativeTo:0]; } +void wxNonOwnedWindowCocoaImpl::ShowWithoutActivating() +{ + [m_macWindow orderFront:nil]; + [[m_macWindow contentView] setNeedsDisplay: YES]; +} + bool wxNonOwnedWindowCocoaImpl::Show(bool show) { if ( show ) { wxNonOwnedWindow* wxpeer = GetWXPeer(); if (wxpeer && !(wxpeer->GetWindowStyle() & wxFRAME_TOOL_WINDOW)) - [m_macWindow makeKeyAndOrderFront:nil]; + [m_macWindow makeKeyAndOrderFront:nil]; else [m_macWindow orderFront:nil]; - - [[m_macWindow contentView] setNeedsDisplay:YES]; + [[m_macWindow contentView] setNeedsDisplay: YES]; } else [m_macWindow orderOut:nil]; return true; } -bool wxNonOwnedWindowCocoaImpl::ShowWithEffect(bool show, wxShowEffect WXUNUSED(effect), unsigned WXUNUSED(timeout)) +bool wxNonOwnedWindowCocoaImpl::ShowWithEffect(bool show, + wxShowEffect effect, + unsigned timeout) { - return Show(show); + return wxWidgetCocoaImpl:: + ShowViewOrWindowWithEffect(m_wxPeer, show, effect, timeout); } void wxNonOwnedWindowCocoaImpl::Update() @@ -526,8 +551,29 @@ void wxNonOwnedWindowCocoaImpl::SetExtraStyle( long exStyle ) } } -bool wxNonOwnedWindowCocoaImpl::SetBackgroundStyle(wxBackgroundStyle WXUNUSED(style)) +void wxNonOwnedWindowCocoaImpl::SetWindowStyleFlag( long style ) { + if (m_macWindow) + { + CGWindowLevel level = kCGNormalWindowLevel; + + if (style & wxSTAY_ON_TOP) + level = kCGUtilityWindowLevel; + else if (( style & wxFRAME_FLOAT_ON_PARENT ) || ( style & wxFRAME_TOOL_WINDOW )) + level = kCGFloatingWindowLevel; + + [m_macWindow setLevel: level]; + } +} + +bool wxNonOwnedWindowCocoaImpl::SetBackgroundStyle(wxBackgroundStyle style) +{ + if ( style == wxBG_STYLE_TRANSPARENT ) + { + [m_macWindow setOpaque:NO]; + [m_macWindow setBackgroundColor:[NSColor clearColor]]; + } + return true; } @@ -570,7 +616,10 @@ void wxNonOwnedWindowCocoaImpl::GetContentArea( int& left, int &top, int &width, bool wxNonOwnedWindowCocoaImpl::SetShape(const wxRegion& WXUNUSED(region)) { - return false; + [m_macWindow setOpaque:NO]; + [m_macWindow setBackgroundColor:[NSColor clearColor]]; + + return true; } void wxNonOwnedWindowCocoaImpl::SetTitle( const wxString& title, wxFontEncoding encoding ) @@ -673,6 +722,11 @@ void wxNonOwnedWindowCocoaImpl::WindowToScreen( int *x, int *y ) *y = p.y; } +bool wxNonOwnedWindowCocoaImpl::IsActive() +{ + return [m_macWindow isKeyWindow]; +} + wxNonOwnedWindowImpl* wxNonOwnedWindowImpl::CreateNonOwnedWindow( wxNonOwnedWindow* wxpeer, wxWindow* parent, const wxPoint& pos, const wxSize& size, long style, long extraStyle, const wxString& name ) {