diff --git a/include/wx/generic/statbmpg.h b/include/wx/generic/statbmpg.h index bb49ba93bc..0ca3ff2e44 100644 --- a/include/wx/generic/statbmpg.h +++ b/include/wx/generic/statbmpg.h @@ -38,7 +38,8 @@ public: virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE { m_bitmap = bitmap; - SetInitialSize(GetBitmapSize()); + InvalidateBestSize(); + SetSize(GetBestSize()); Refresh(); } @@ -53,12 +54,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/generic/statbmpg.cpp b/src/generic/statbmpg.cpp index 26404a5529..115796b357 100644 --- a/src/generic/statbmpg.cpp +++ b/src/generic/statbmpg.cpp @@ -34,7 +34,13 @@ bool wxGenericStaticBitmap::Create(wxWindow *parent, wxWindowID id, wxDefaultValidator, name)) return false; m_scaleMode = Scale_None; - SetBitmap(bitmap); + + // Don't call SetBitmap() here, as it changes the size and refreshes the + // window unnecessarily, when we don't need either of these side effects + // here. + m_bitmap = bitmap; + SetInitialSize(size); + Bind(wxEVT_PAINT, &wxGenericStaticBitmap::OnPaint, this); return true; }