diff --git a/src/osx/cocoa/nonownedwnd.mm b/src/osx/cocoa/nonownedwnd.mm index b21d2d2e14..a1084ccc15 100644 --- a/src/osx/cocoa/nonownedwnd.mm +++ b/src/osx/cocoa/nonownedwnd.mm @@ -769,12 +769,6 @@ long style, long extraStyle, const wxString& WXUNUSED(name) ) [m_macWindow setDelegate:controller]; [controller addObservers:m_macWindow]; - - if ( ( style & wxFRAME_SHAPED) ) - { - [m_macWindow setOpaque:NO]; - [m_macWindow setAlphaValue:1.0]; - } if ( !(style & wxFRAME_TOOL_WINDOW) ) [m_macWindow setHidesOnDeactivate:NO]; diff --git a/src/osx/cocoa/window.mm b/src/osx/cocoa/window.mm index eaddbc7cad..b32f5aef66 100644 --- a/src/osx/cocoa/window.mm +++ b/src/osx/cocoa/window.mm @@ -3136,7 +3136,14 @@ void wxWidgetCocoaImpl::SetBackgroundColour( const wxColour &col ) if ( [targetView respondsToSelector:@selector(setBackgroundColor:) ] ) { - [targetView setBackgroundColor: col.OSXGetNSColor()]; + wxWindow* peer = GetWXPeer(); + if ( peer->GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT ) + { + wxTopLevelWindow* toplevel = wxDynamicCast(peer,wxTopLevelWindow); + + if ( toplevel == NULL || toplevel->GetShape().IsEmpty() ) + [targetView setBackgroundColor: col.OSXGetNSColor()]; + } } } @@ -3147,6 +3154,8 @@ bool wxWidgetCocoaImpl::SetBackgroundStyle( wxBackgroundStyle style ) if ( [m_osxView respondsToSelector:@selector(setOpaque:) ] ) { [m_osxView setOpaque: opaque]; + if ( style == wxBG_STYLE_TRANSPARENT ) + [m_osxView setBackgroundColor:[NSColor clearColor]]; } return true ; diff --git a/src/osx/nonownedwnd_osx.cpp b/src/osx/nonownedwnd_osx.cpp index d43a4eba65..cbc20eda73 100644 --- a/src/osx/nonownedwnd_osx.cpp +++ b/src/osx/nonownedwnd_osx.cpp @@ -254,17 +254,13 @@ wxPoint wxNonOwnedWindow::GetClientAreaOrigin() const bool wxNonOwnedWindow::SetBackgroundColour(const wxColour& c ) { + if ( !wxWindow::SetBackgroundColour(c) && m_hasBgCol ) + return false ; + // only set the native background color if the toplevel window's // background is not supposed to be transparent, otherwise the // transparency is lost - if( GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT || - (GetWindowStyle() & wxFRAME_SHAPED) ) - return false; - - if ( !wxWindow::SetBackgroundColour(c) && m_hasBgCol ) - return false ; - - if ( GetBackgroundStyle() != wxBG_STYLE_CUSTOM ) + if ( GetBackgroundStyle() != wxBG_STYLE_PAINT && GetBackgroundStyle() != wxBG_STYLE_TRANSPARENT) { if ( m_nowpeer ) return m_nowpeer->SetBackgroundColour(c); @@ -522,6 +518,10 @@ bool wxNonOwnedWindow::DoSetRegionShape(const wxRegion& region) { m_shape = region; + // set the native content view to transparency, this is an implementation detail + // no reflected in the wx BackgroundStyle + GetPeer()->SetBackgroundStyle(wxBG_STYLE_TRANSPARENT); + return m_nowpeer->SetShape(region); }