diff --git a/pcsx2/gui/pxStaticText.cpp b/pcsx2/gui/pxStaticText.cpp index f9c1659c6a..62709890fd 100644 --- a/pcsx2/gui/pxStaticText.cpp +++ b/pcsx2/gui/pxStaticText.cpp @@ -124,6 +124,32 @@ int pxStaticText::calcPaddingHeight(int newHeight) const return (int)(newHeight * m_paddingPct_vert * 2) + (m_paddingPix_vert * 2); } +// Overloaded form wxPanel and friends. +wxSize pxStaticText::DoGetBestSize() const +{ + wxClientDC dc(const_cast(this)); + dc.SetFont(GetFontOk()); + + wxSize best; + + if (m_autowrap) + { + best = GetBestWrappedSize(dc); + //best.x = wxDefaultCoord; + } + else + { + // No autowrapping, so we can force a specific size here! + best = dc.GetMultiLineTextExtent(GetLabel()); + best.x += calcPaddingWidth(best.x); + } + + best.y += calcPaddingHeight(best.y); + + CacheBestSize(best); + return best; +} + wxSize pxStaticText::GetBestWrappedSize(const wxClientDC& dc) const { pxAssert(m_autowrap); diff --git a/pcsx2/gui/pxStaticText.h b/pcsx2/gui/pxStaticText.h index abe158c656..8aeaedb958 100644 --- a/pcsx2/gui/pxStaticText.h +++ b/pcsx2/gui/pxStaticText.h @@ -57,6 +57,7 @@ protected: bool AcceptsFocus() const { return false; } bool HasTransparentBackground() { return true; } void DoSetSize(int x, int y, int w, int h, int sizeFlags = wxSIZE_AUTO); + wxSize DoGetBestSize() const; public: pxStaticText(wxWindow* parent, const wxString& label, wxAlignment align = wxALIGN_CENTRE_HORIZONTAL);