X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/affd2611c569d9d8e60fa542614f6668956b16de..b16f4bfab29a541cbb24febe07983087776388cb:/src/mac/carbon/toolbar.cpp diff --git a/src/mac/carbon/toolbar.cpp b/src/mac/carbon/toolbar.cpp index 8014c63119..0ae7bed16e 100644 --- a/src/mac/carbon/toolbar.cpp +++ b/src/mac/carbon/toolbar.cpp @@ -66,6 +66,7 @@ public: void SetSize(const wxSize& size) ; void SetPosition( const wxPoint& position ) ; + wxSize GetSize() const { if ( IsControl() ) @@ -88,6 +89,7 @@ public: { return wxPoint(m_x, m_y); } + bool DoEnable( bool enable ) ; private : void Init() { @@ -159,6 +161,28 @@ DEFINE_ONE_SHOT_HANDLER_GETTER( wxMacToolBarToolEventHandler ) // wxToolBarTool // ---------------------------------------------------------------------------- +bool wxToolBarTool::DoEnable(bool enable) +{ + if ( IsControl() ) + { + GetControl()->Enable( enable ) ; + } + else if ( IsButton() ) + { +#if TARGET_API_MAC_OSX + if ( enable ) + EnableControl( m_controlHandle ) ; + else + DisableControl( m_controlHandle ) ; +#else + if ( enable ) + ActivateControl( m_controlHandle ) ; + else + DeactivateControl( m_controlHandle ) ; +#endif + } + return true ; +} void wxToolBarTool::SetSize(const wxSize& size) { if ( IsControl() ) @@ -240,8 +264,6 @@ wxToolBarTool::wxToolBarTool(wxToolBar *tbar, GetEventTypeCount(eventList), eventList, this,NULL); UMAShowControl( m_controlHandle ) ; - if ( !IsEnabled() ) - DisableControl( m_controlHandle ) ; if ( CanBeToggled() && IsToggled() ) ::SetControl32BitValue( m_controlHandle , 1 ) ; @@ -377,6 +399,7 @@ bool wxToolBar::Realize() } SetSize( maxWidth, maxHeight ); + InvalidateBestSize(); return TRUE; } @@ -442,18 +465,7 @@ void wxToolBar::DoEnableTool(wxToolBarToolBase *t, bool enable) if (!IsShown()) return ; - wxToolBarTool *tool = (wxToolBarTool *)t; - if ( tool->IsControl() ) - { - tool->GetControl()->Enable( enable ) ; - } - else if ( tool->IsButton() ) - { - if ( enable ) - UMAActivateControl( (ControlRef) tool->GetControlHandle() ) ; - else - UMADeactivateControl( (ControlRef) tool->GetControlHandle() ) ; - } + ((wxToolBarTool*)t)->DoEnable( enable ) ; } void wxToolBar::DoToggleTool(wxToolBarToolBase *t, bool toggle) @@ -473,6 +485,7 @@ bool wxToolBar::DoInsertTool(size_t WXUNUSED(pos), { // nothing special to do here - we relayout in Realize() later tool->Attach(this); + InvalidateBestSize(); return TRUE; } @@ -519,6 +532,7 @@ bool wxToolBar::DoDeleteTool(size_t WXUNUSED(pos), wxToolBarToolBase *tool) tool2->SetPosition( pt ) ; } + InvalidateBestSize(); return TRUE ; } @@ -537,8 +551,41 @@ void wxToolBar::OnPaint(wxPaintEvent& event) if ( toolbarrect.top < 0 ) toolbarrect.top = 0 ; */ - UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; + if ( !MacGetTopLevelWindow()->MacGetMetalAppearance() ) + { + UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; + } + else + { +#if TARGET_API_MAC_OSX +#if MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_2 + if ( UMAGetSystemVersion() >= 0x1030 ) + { + HIRect hiToolbarrect = CGRectMake( dc.YLOG2DEVMAC(0) , dc.XLOG2DEVMAC(0) , + dc.YLOG2DEVREL(h) , dc.XLOG2DEVREL(w) ); + CGContextRef cgContext ; + Rect bounds ; + GetPortBounds( (CGrafPtr) dc.m_macPort , &bounds ) ; + QDBeginCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ; + CGContextTranslateCTM( cgContext , 0 , bounds.bottom - bounds.top ) ; + CGContextScaleCTM( cgContext , 1 , -1 ) ; + { + HIThemeBackgroundDrawInfo drawInfo ; + drawInfo.version = 0 ; + drawInfo.state = kThemeStateActive ; + drawInfo.kind = kThemeBackgroundMetal ; + HIThemeApplyBackground( &hiToolbarrect, &drawInfo , cgContext,kHIThemeOrientationNormal) ; + } + QDEndCGContext( (CGrafPtr) dc.m_macPort , &cgContext ) ; + } + else +#endif + { + UMADrawThemePlacard( &toolbarrect , IsEnabled() ? kThemeStateActive : kThemeStateInactive) ; + } +#endif + } event.Skip() ; }