X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8736cc485b94318d9c5d1e4bb443f16de9b8c9b4..c17b2e31516424a77fd54b8fc192eac133269ce4:/src/mac/carbon/toplevel.cpp diff --git a/src/mac/carbon/toplevel.cpp b/src/mac/carbon/toplevel.cpp index b0930420a0..d45476496a 100644 --- a/src/mac/carbon/toplevel.cpp +++ b/src/mac/carbon/toplevel.cpp @@ -57,6 +57,9 @@ // constants // ---------------------------------------------------------------------------- +// unified title and toolbar constant - not in Tiger headers, so we duplicate it here +#define kWindowUnifiedTitleAndToolbarAttribute (1 << 7) + // trace mask for activation tracing messages static const wxChar *TRACE_ACTIVATE = _T("activation"); @@ -1248,6 +1251,13 @@ void wxTopLevelWindowMac::MacCreateRealWindow( } #endif +#if TARGET_API_MAC_OSX + if ( m_macWindow != NULL ) + { + MacSetUnifiedAppearance( true ) ; + } +#endif + // the frame window event handler InstallStandardEventHandler( GetWindowEventTarget(MAC_WXHWND(m_macWindow)) ) ; MacInstallTopLevelWindowEventHandler() ; @@ -1460,8 +1470,14 @@ void wxTopLevelWindowMac::SetExtraStyle(long exStyle) if ( m_macWindow != NULL ) { bool metal = GetExtraStyle() & wxFRAME_EX_METAL ; + if ( MacGetMetalAppearance() != metal ) + { + if ( MacGetUnifiedAppearance() ) + MacSetUnifiedAppearance( !metal ) ; + MacSetMetalAppearance( metal ) ; + } } #endif } @@ -1529,6 +1545,9 @@ void wxTopLevelWindowMac::DoGetClientSize( int *width, int *height ) const void wxTopLevelWindowMac::MacSetMetalAppearance( bool set ) { #if TARGET_API_MAC_OSX + if ( MacGetUnifiedAppearance() ) + MacSetUnifiedAppearance( false ) ; + MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes , set ? kWindowNoAttributes : kWindowMetalAttribute ) ; #endif @@ -1539,10 +1558,41 @@ bool wxTopLevelWindowMac::MacGetMetalAppearance() const #if TARGET_API_MAC_OSX return MacGetWindowAttributes() & kWindowMetalAttribute ; #else - return false ; + return false; #endif } +void wxTopLevelWindowMac::MacSetUnifiedAppearance( bool set ) +{ +#if TARGET_API_MAC_OSX + if ( UMAGetSystemVersion() >= 0x1040 ) + { + if ( MacGetMetalAppearance() ) + MacSetMetalAppearance( false ) ; + + MacChangeWindowAttributes( set ? kWindowUnifiedTitleAndToolbarAttribute : kWindowNoAttributes , + set ? kWindowNoAttributes : kWindowUnifiedTitleAndToolbarAttribute) ; + + // For some reason, Tiger uses white as the background color for this appearance, + // while most apps using it use the typical striped background. Restore that behavior + // for wx. + // TODO: Determine if we need this on Leopard as well. (should be harmless either way, + // though) + SetBackgroundColour( wxSYS_COLOUR_WINDOW ) ; + } +#endif +} + +bool wxTopLevelWindowMac::MacGetUnifiedAppearance() const +{ +#if TARGET_API_MAC_OSX + if ( UMAGetSystemVersion() >= 0x1040 ) + return MacGetWindowAttributes() & kWindowUnifiedTitleAndToolbarAttribute ; + else +#endif + return false; +} + void wxTopLevelWindowMac::MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear ) { ChangeWindowAttributes( (WindowRef)m_macWindow, attributesToSet, attributesToClear ) ;