Fix setting size of wxGenericStaticBitmap
We must call SetInitialSize() in Create() in order to take the size argument passed to ctor/Create() into account -- it was completely ignored previously. But calling SetBitmap() must not change the initial size, as it can also be done later, so just change the current size there instead (which is consistent with wxMSW version and original behaviour, so keep it like this, even though it's not totally clear if all ports do it). Remove the now unused wxGenericStaticBitmap::GetBitmapSize().
This commit is contained in:
@@ -38,7 +38,8 @@ public:
|
|||||||
virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE
|
virtual void SetBitmap(const wxBitmap& bitmap) wxOVERRIDE
|
||||||
{
|
{
|
||||||
m_bitmap = bitmap;
|
m_bitmap = bitmap;
|
||||||
SetInitialSize(GetBitmapSize());
|
InvalidateBestSize();
|
||||||
|
SetSize(GetBestSize());
|
||||||
Refresh();
|
Refresh();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -53,12 +54,6 @@ public:
|
|||||||
virtual ScaleMode GetScaleMode() const wxOVERRIDE { return m_scaleMode; }
|
virtual ScaleMode GetScaleMode() const wxOVERRIDE { return m_scaleMode; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxSize GetBitmapSize()
|
|
||||||
{
|
|
||||||
return m_bitmap.IsOk() ? m_bitmap.GetScaledSize()
|
|
||||||
: wxSize(16, 16); // this is completely arbitrary
|
|
||||||
}
|
|
||||||
|
|
||||||
void OnPaint(wxPaintEvent& event);
|
void OnPaint(wxPaintEvent& event);
|
||||||
|
|
||||||
wxBitmap m_bitmap;
|
wxBitmap m_bitmap;
|
||||||
|
@@ -34,7 +34,13 @@ bool wxGenericStaticBitmap::Create(wxWindow *parent, wxWindowID id,
|
|||||||
wxDefaultValidator, name))
|
wxDefaultValidator, name))
|
||||||
return false;
|
return false;
|
||||||
m_scaleMode = Scale_None;
|
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);
|
Bind(wxEVT_PAINT, &wxGenericStaticBitmap::OnPaint, this);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user