Fix setting size of wxStaticBitmap in wxOSX too

This is the same change as was done in the previous commit for
wxGenericStaticBitmap, see that commit message for more details.
This commit is contained in:
Vadim Zeitlin
2021-10-21 18:45:19 +01:00
parent eba93fb5e7
commit dc1c2c91b3
2 changed files with 8 additions and 9 deletions

View File

@@ -35,12 +35,6 @@ public:
virtual ScaleMode GetScaleMode() const wxOVERRIDE { return m_scaleMode; }
private:
wxSize GetBitmapSize()
{
return m_bitmap.IsOk() ? m_bitmap.GetScaledSize()
: wxSize(16, 16); // this is completely arbitrary
}
void OnPaint(wxPaintEvent& event);
wxBitmap m_bitmap;

View File

@@ -47,7 +47,12 @@ bool wxStaticBitmap::Create(wxWindow *parent,
MacPostControlCreate( pos, size );
SetBitmap(bitmap);
// Don't call SetBitmap() here, as we don't need to change the size nor
// refresh the window here.
m_bitmap = bitmap;
GetPeer()->SetBitmap(bitmap);
SetInitialSize(size);
return true;
}
@@ -56,10 +61,10 @@ bool wxStaticBitmap::Create(wxWindow *parent,
void wxStaticBitmap::SetBitmap(const wxBitmap& bitmap)
{
m_bitmap = bitmap;
SetInitialSize(GetBitmapSize());
GetPeer()->SetBitmap(bitmap);
InvalidateBestSize();
SetSize(GetBestSize());
Refresh();
}