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:
@@ -90,10 +90,15 @@ void wxAnyButton::QtCreate(wxWindow *parent)
|
||||
m_qtPushButton->setAutoDefault(false);
|
||||
}
|
||||
|
||||
void wxAnyButton::QtSetBitmap( const wxBitmap &bitmap )
|
||||
void wxAnyButton::QtSetBitmap( const wxBitmapBundle &bitmapBundle )
|
||||
{
|
||||
wxCHECK_RET(m_qtPushButton, "Invalid button.");
|
||||
|
||||
if ( !bitmapBundle.IsOk() )
|
||||
return;
|
||||
|
||||
wxBitmap bitmap = bitmapBundle.GetBitmap(bitmapBundle.GetDefaultSize()*GetDPIScaleFactor());
|
||||
|
||||
// load the bitmap and resize the button:
|
||||
QPixmap *pixmap = bitmap.GetHandle();
|
||||
if ( pixmap != NULL )
|
||||
@@ -117,10 +122,10 @@ QWidget *wxAnyButton::GetHandle() const
|
||||
|
||||
wxBitmap wxAnyButton::DoGetBitmap(State state) const
|
||||
{
|
||||
return state < State_Max ? m_bitmaps[state] : wxNullBitmap;
|
||||
return state < State_Max ? m_bitmaps[state].GetBitmap(wxDefaultSize) : wxNullBitmap;
|
||||
}
|
||||
|
||||
void wxAnyButton::DoSetBitmap(const wxBitmap& bitmap, State which)
|
||||
void wxAnyButton::DoSetBitmap(const wxBitmapBundle& bitmap, State which)
|
||||
{
|
||||
wxCHECK_RET(which < State_Max, "Invalid state");
|
||||
|
||||
@@ -166,7 +171,7 @@ void wxAnyButton::QtUpdateState()
|
||||
State state = QtGetCurrentState();
|
||||
|
||||
// Update the bitmap
|
||||
const wxBitmap& bmp = m_bitmaps[state];
|
||||
const wxBitmapBundle& bmp = m_bitmaps[state];
|
||||
QtSetBitmap(bmp.IsOk() ? bmp : m_bitmaps[State_Normal]);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user