From 595a9493070ae0491dae7f16bc734a141458c5de Mon Sep 17 00:00:00 2001 From: Robin Dunn Date: Wed, 7 Apr 2004 21:48:24 +0000 Subject: [PATCH] wxStatusBarGeneric::DoGetBestSize git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@26658 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/generic/statusbr.h | 2 ++ src/generic/statusbr.cpp | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+) diff --git a/include/wx/generic/statusbr.h b/include/wx/generic/statusbr.h index 364c1b3d0b..5fc9df0a92 100644 --- a/include/wx/generic/statusbr.h +++ b/include/wx/generic/statusbr.h @@ -119,6 +119,8 @@ protected: wxPen m_mediumShadowPen; wxPen m_hilightPen; + virtual wxSize DoGetBestSize() const; + private: DECLARE_EVENT_TABLE() DECLARE_DYNAMIC_CLASS_NO_COPY(wxStatusBarGeneric) diff --git a/src/generic/statusbr.cpp b/src/generic/statusbr.cpp index 55eb58cc4f..c12bce49e7 100644 --- a/src/generic/statusbr.cpp +++ b/src/generic/statusbr.cpp @@ -109,6 +109,24 @@ bool wxStatusBarGeneric::Create(wxWindow *parent, return TRUE; } + +wxSize wxStatusBarGeneric::DoGetBestSize() const +{ + int width, height; + + // best width is the width of the parent + GetParent()->GetClientSize(&width, NULL); + + // best height is as calculated above in Create + wxClientDC dc((wxWindow*)this); + dc.SetFont(GetFont()); + wxCoord y; + dc.GetTextExtent(_T("X"), NULL, &y ); + height = (int)( (11*y)/10 + 2*GetBorderY()); + + return wxSize(width, height); +} + void wxStatusBarGeneric::SetFieldsCount(int number, const int *widths) { wxASSERT_MSG( number >= 0, _T("negative number of fields in wxStatusBar?") ); -- 2.45.2