From dc1c2c91b3e5c9689a6da6d29f001bb2c99b7490 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Thu, 21 Oct 2021 18:45:19 +0100 Subject: [PATCH] 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. --- include/wx/osx/statbmp.h | 6 ------ src/osx/statbmp_osx.cpp | 11 ++++++++--- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/include/wx/osx/statbmp.h b/include/wx/osx/statbmp.h index 51d9545a08..9075614e5c 100644 --- a/include/wx/osx/statbmp.h +++ b/include/wx/osx/statbmp.h @@ -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; diff --git a/src/osx/statbmp_osx.cpp b/src/osx/statbmp_osx.cpp index 94332a571f..3fd14dd46a 100644 --- a/src/osx/statbmp_osx.cpp +++ b/src/osx/statbmp_osx.cpp @@ -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(); }