Allow using wxBitmapBundle for wxButton bitmaps

Take wxBitmapBundle in wxButton::SetBitmapLabel() and related functions
in order to be able to associate several bitmaps to be used in different
resolutions with the button, instead of just a single bitmap.
This commit is contained in:
Vadim Zeitlin
2021-10-10 19:32:43 +01:00
parent 2910327ef3
commit 4e5d2d97e2
36 changed files with 223 additions and 175 deletions

View File

@@ -43,20 +43,20 @@ void wxAnyButton::SetLabel(const wxString& label)
wxBitmap wxAnyButton::DoGetBitmap(State which) const
{
return m_bitmaps[which];
return m_bitmaps[which].GetBitmap(wxDefaultSize);
}
void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
void wxAnyButton::DoSetBitmap(const wxBitmapBundle& bitmapBundle, State which)
{
m_bitmaps[which] = bitmap;
m_bitmaps[which] = bitmapBundle;
if ( which == State_Normal )
GetPeer()->SetBitmap(bitmap);
GetPeer()->SetBitmap(bitmapBundle);
else if ( which == State_Pressed )
{
wxButtonImpl* bi = dynamic_cast<wxButtonImpl*> (GetPeer());
if ( bi )
bi->SetPressedBitmap(bitmap);
bi->SetPressedBitmap(bitmapBundle);
}
InvalidateBestSize();
}
@@ -84,11 +84,11 @@ bool wxAnyButton::DoSetLabelMarkup(const wxString& markup)
void wxAnyButton::OnEnterWindow( wxMouseEvent& WXUNUSED(event))
{
if ( DoGetBitmap( State_Current ).IsOk() )
GetPeer()->SetBitmap( DoGetBitmap( State_Current ) );
GetPeer()->SetBitmap( m_bitmaps[State_Current] );
}
void wxAnyButton::OnLeaveWindow( wxMouseEvent& WXUNUSED(event))
{
if ( DoGetBitmap( State_Current ).IsOk() )
GetPeer()->SetBitmap( DoGetBitmap( State_Normal ) );
GetPeer()->SetBitmap( m_bitmaps[State_Normal] );
}