(Port to 2.8) Add the unified style on OS X 10.4, and default to using it.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@48167 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -104,6 +104,7 @@ public:
|
||||
virtual void MacInstallTopLevelWindowEventHandler() ;
|
||||
|
||||
bool MacGetMetalAppearance() const ;
|
||||
bool MacGetUnifiedAppearance() const ;
|
||||
|
||||
void MacChangeWindowAttributes( wxUint32 attributesToSet , wxUint32 attributesToClear ) ;
|
||||
wxUint32 MacGetWindowAttributes() const ;
|
||||
@@ -141,6 +142,7 @@ private :
|
||||
// This is because the ExtraStyle flags get out of sync with the metal appearance and the metal
|
||||
// logic & checks cease to work as expected. To set the metal appearance, use SetExtraStyle.
|
||||
void MacSetMetalAppearance( bool on ) ;
|
||||
void MacSetUnifiedAppearance( bool on ) ;
|
||||
|
||||
WXEVENTHANDLERREF m_macEventHandler ;
|
||||
|
||||
|
@@ -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");
|
||||
|
||||
@@ -1257,6 +1260,13 @@ void wxTopLevelWindowMac::MacCreateRealWindow(
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( m_macWindow != NULL )
|
||||
{
|
||||
MacSetUnifiedAppearance( true ) ;
|
||||
}
|
||||
#endif
|
||||
|
||||
HIViewRef growBoxRef = 0 ;
|
||||
err = HIViewFindByID( HIViewGetRoot( (WindowRef)m_macWindow ), kHIViewWindowGrowBoxID, &growBoxRef );
|
||||
if ( err == noErr && growBoxRef != 0 )
|
||||
@@ -1474,8 +1484,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
|
||||
}
|
||||
@@ -1549,6 +1565,9 @@ void wxTopLevelWindowMac::DoCentre(int dir)
|
||||
void wxTopLevelWindowMac::MacSetMetalAppearance( bool set )
|
||||
{
|
||||
#if TARGET_API_MAC_OSX
|
||||
if ( MacGetUnifiedAppearance() )
|
||||
MacSetUnifiedAppearance( false ) ;
|
||||
|
||||
MacChangeWindowAttributes( set ? kWindowMetalAttribute : kWindowNoAttributes ,
|
||||
set ? kWindowNoAttributes : kWindowMetalAttribute ) ;
|
||||
#endif
|
||||
@@ -1559,10 +1578,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 ) ;
|
||||
|
Reference in New Issue
Block a user