diff --git a/common/widgets/bitmap_button.cpp b/common/widgets/bitmap_button.cpp index de7e0282ce..7ca136e07a 100644 --- a/common/widgets/bitmap_button.cpp +++ b/common/widgets/bitmap_button.cpp @@ -92,16 +92,17 @@ void BITMAP_BUTTON::SetPadding( int aPadding ) } -void BITMAP_BUTTON::SetBitmap( const wxBitmap& aBmp ) +void BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp ) { m_normalBitmap = aBmp; - m_unadjustedMinSize = aBmp.GetSize(); + m_unadjustedMinSize = aBmp.GetPreferredBitmapSizeFor( this ); - SetMinSize( wxSize( aBmp.GetWidth() + ( m_padding * 2 ), aBmp.GetHeight() + ( m_padding * 2 ) ) ); + SetMinSize( wxSize( m_unadjustedMinSize.GetWidth() + ( m_padding * 2 ), + m_unadjustedMinSize.GetHeight() + ( m_padding * 2 ) ) ); } -void BITMAP_BUTTON::SetDisabledBitmap( const wxBitmap& aBmp ) +void BITMAP_BUTTON::SetDisabledBitmap( const wxBitmapBundle& aBmp ) { m_disabledBitmap = aBmp; } @@ -272,11 +273,11 @@ void BITMAP_BUTTON::OnPaint( wxPaintEvent& aEvent ) } } - const wxBitmap& bmp = hasFlag( wxCONTROL_DISABLED ) ? m_disabledBitmap : m_normalBitmap; + const wxBitmapBundle& bmp = hasFlag( wxCONTROL_DISABLED ) ? m_disabledBitmap : m_normalBitmap; // Draw the bitmap with the upper-left corner offset by the padding if( bmp.IsOk() ) - dc.DrawBitmap( bmp, m_padding, m_padding, true ); + dc.DrawBitmap( bmp.GetBitmapFor( this ), m_padding, m_padding, true ); // Draw the badge if( m_showBadge ) diff --git a/common/widgets/std_bitmap_button.cpp b/common/widgets/std_bitmap_button.cpp index 3b5a7b1020..7ddf6c797e 100644 --- a/common/widgets/std_bitmap_button.cpp +++ b/common/widgets/std_bitmap_button.cpp @@ -73,11 +73,12 @@ void STD_BITMAP_BUTTON::onThemeChanged( wxSysColourChangedEvent &aEvent ) } -void STD_BITMAP_BUTTON::SetBitmap( const wxBitmap& aBmp ) +void STD_BITMAP_BUTTON::SetBitmap( const wxBitmapBundle& aBmp ) { m_bitmap = aBmp; + wxSize size = aBmp.GetPreferredBitmapSizeFor( this ); - SetMinSize( wxSize( m_bitmap.GetWidth() + 8, m_bitmap.GetHeight() + 8 ) ); + SetMinSize( wxSize( size.GetWidth() + 8, size.GetHeight() + 8 ) ); } @@ -205,14 +206,21 @@ void STD_BITMAP_BUTTON::OnPaint( wxPaintEvent& WXUNUSED( aEvent ) ) if( m_bitmap.IsOk() ) { - r1.x = ( size.GetWidth() - m_bitmap.GetWidth() ) / 2; + wxSize bmpSize = m_bitmap.GetPreferredBitmapSizeFor( this ); + + r1.x = ( size.GetWidth() - bmpSize.GetWidth() ) / 2; if( r1.x < 0 ) r1.x = 0; - r1.y += ( size.GetHeight() - m_bitmap.GetHeight() ) / 2; + r1.y += ( size.GetHeight() - bmpSize.GetHeight() ) / 2; - dc.DrawBitmap( m_bIsEnable ? m_bitmap : m_bitmap.ConvertToDisabled(), r1.x, r1.y, true ); + wxBitmap bm = m_bitmap.GetBitmapFor( this ); + + if( !m_bIsEnable ) + bm.ConvertToDisabled(); + + dc.DrawBitmap( bm, r1.x, r1.y, true ); } } diff --git a/include/widgets/bitmap_button.h b/include/widgets/bitmap_button.h index 498eee2a21..cbf83c061b 100644 --- a/include/widgets/bitmap_button.h +++ b/include/widgets/bitmap_button.h @@ -25,7 +25,7 @@ #ifndef BITMAP_BUTTON_H_ #define BITMAP_BUTTON_H_ -#include +#include #include #include @@ -63,14 +63,14 @@ public: * * @param aBmp is the enabled bitmap. */ - void SetBitmap( const wxBitmap& aBmp ); + void SetBitmap( const wxBitmapBundle& aBmp ); /** * Set the bitmap shown when the button is disabled. * * @param aBmp is the disabled bitmap. */ - void SetDisabledBitmap( const wxBitmap& aBmp ); + void SetDisabledBitmap( const wxBitmapBundle& aBmp ); /** * Enable the button. @@ -142,8 +142,8 @@ protected: } private: - wxBitmap m_normalBitmap; - wxBitmap m_disabledBitmap; + wxBitmapBundle m_normalBitmap; + wxBitmapBundle m_disabledBitmap; bool m_isRadioButton; bool m_showBadge; diff --git a/include/widgets/std_bitmap_button.h b/include/widgets/std_bitmap_button.h index c49eae79af..666e21f7e9 100644 --- a/include/widgets/std_bitmap_button.h +++ b/include/widgets/std_bitmap_button.h @@ -25,7 +25,7 @@ #ifndef STD_BITMAP_BUTTON_H #define STD_BITMAP_BUTTON_H -#include +#include #include class wxButton; @@ -51,7 +51,7 @@ public: ~STD_BITMAP_BUTTON(); - void SetBitmap( const wxBitmap& aBmp ); + void SetBitmap( const wxBitmapBundle& aBmp ); bool Enable( bool aEnable = true ) override; protected: @@ -66,7 +66,7 @@ protected: private: int m_stateButton = 0; bool m_bIsEnable = true; - wxBitmap m_bitmap; + wxBitmapBundle m_bitmap; }; #endif /*STD_BITMAP_BUTTON_H*/