From 283c797c5c79a25d6998abe1ab6cc1b17260dc19 Mon Sep 17 00:00:00 2001 From: =?utf8?q?V=C3=A1clav=20Slav=C3=ADk?= Date: Fri, 29 Sep 2006 11:45:26 +0000 Subject: [PATCH] fixed wxStatusBar size calculations so that the text is not clipped git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41503 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/univ/renderer.h | 19 +++++++++++++++---- include/wx/univ/stdrend.h | 6 +++++- src/univ/statusbr.cpp | 9 ++++++--- src/univ/stdrend.cpp | 27 +++++++++++++++++++++++---- 4 files changed, 49 insertions(+), 12 deletions(-) diff --git a/include/wx/univ/renderer.h b/include/wx/univ/renderer.h index c9e33d84ca..330ca33843 100644 --- a/include/wx/univ/renderer.h +++ b/include/wx/univ/renderer.h @@ -481,8 +481,14 @@ public: #if wxUSE_STATUSBAR // get the borders around the status bar fields (x and y fields of the - // return value) and also, optionally, the border between the fields - virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const = 0; + // return value) + virtual wxSize GetStatusBarBorders() const = 0; + + // get the border between the status bar fields + virtual wxCoord GetStatusBarBorderBetweenFields() const = 0; + + // get the mergin between a field and its border + virtual wxSize GetStatusBarFieldMargins() const = 0; #endif // wxUSE_STATUSBAR // get client area rectangle of top level window (i.e. subtract @@ -856,9 +862,14 @@ public: #endif // wxUSE_MENUS #if wxUSE_STATUSBAR - virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const - { return m_renderer->GetStatusBarBorders(borderBetweenFields); } + virtual wxSize GetStatusBarBorders() const + { return m_renderer->GetStatusBarBorders(); } + virtual wxCoord GetStatusBarBorderBetweenFields() const + { return m_renderer->GetStatusBarBorderBetweenFields(); } + virtual wxSize GetStatusBarFieldMargins() const + { return m_renderer->GetStatusBarFieldMargins(); } #endif // wxUSE_STATUSBAR + virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const { return m_renderer->GetFrameClientArea(rect, flags); } virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const diff --git a/include/wx/univ/stdrend.h b/include/wx/univ/stdrend.h index f46b25792c..5c02eea79a 100644 --- a/include/wx/univ/stdrend.h +++ b/include/wx/univ/stdrend.h @@ -157,7 +157,11 @@ public: const wxString& label, int flags = 0, int style = 0); - virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const; + virtual wxSize GetStatusBarBorders() const; + + virtual wxCoord GetStatusBarBorderBetweenFields() const; + + virtual wxSize GetStatusBarFieldMargins() const; #endif // wxUSE_STATUSBAR virtual wxCoord GetCheckItemMargin() const { return 0; } diff --git a/src/univ/statusbr.cpp b/src/univ/statusbr.cpp index ccb51540e6..b4846a8766 100644 --- a/src/univ/statusbr.cpp +++ b/src/univ/statusbr.cpp @@ -86,7 +86,8 @@ wxRect wxStatusBarUniv::GetTotalFieldRect(wxCoord *borderBetweenFields) // no, don't do this - the borders are meant to be inside this rect // wxSize sizeBorders = - m_renderer->GetStatusBarBorders(borderBetweenFields); + if ( borderBetweenFields ) + *borderBetweenFields = m_renderer->GetStatusBarBorderBetweenFields(); //rect.Deflate(sizeBorders.x, sizeBorders.y); // recalc the field widths if needed @@ -311,12 +312,14 @@ void wxStatusBarUniv::SetMinHeight(int WXUNUSED(height)) int wxStatusBarUniv::GetBorderX() const { - return m_renderer->GetStatusBarBorders(NULL).x; + return m_renderer->GetStatusBarBorders().x + + m_renderer->GetStatusBarFieldMargins().x; } int wxStatusBarUniv::GetBorderY() const { - return m_renderer->GetStatusBarBorders(NULL).y; + return m_renderer->GetStatusBarBorders().y + + m_renderer->GetStatusBarFieldMargins().y; } #endif // wxUSE_STATUSBAR diff --git a/src/univ/stdrend.cpp b/src/univ/stdrend.cpp index 54c3177883..147fcd0639 100644 --- a/src/univ/stdrend.cpp +++ b/src/univ/stdrend.cpp @@ -1092,11 +1092,30 @@ int wxStdRenderer::PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord) #if wxUSE_STATUSBAR -wxSize wxStdRenderer::GetStatusBarBorders(wxCoord *borderBetweenFields) const +wxSize wxStdRenderer::GetStatusBarBorders() const { - if ( borderBetweenFields ) - *borderBetweenFields = 2; + // Rendered border may be different depending on field's style, we use + // the largest value so that any field certainly fits into the borders + // we return: + wxRect raised = GetBorderDimensions(wxBORDER_RAISED); + wxRect flat = GetBorderDimensions(wxBORDER_STATIC); + wxASSERT_MSG( raised.x == raised.width && raised.y == raised.height && + flat.x == flat.width && flat.y == flat.height, + _T("this code expects uniform borders, you must override GetStatusBarBorders") ); + + // take the larger of flat/raised values: + wxSize border(wxMax(raised.x, flat.x), wxMax(raised.y, flat.y)); + + return border; +} +wxCoord wxStdRenderer::GetStatusBarBorderBetweenFields() const +{ + return 2; +} + +wxSize wxStdRenderer::GetStatusBarFieldMargins() const +{ return wxSize(2, 2); } @@ -1113,7 +1132,7 @@ void wxStdRenderer::DrawStatusField(wxDC& dc, else if ( style != wxSB_FLAT ) DrawBorder(dc, wxBORDER_STATIC, rect, flags, &rectIn); - rectIn.Deflate(GetStatusBarBorders(NULL)); + rectIn.Deflate(GetStatusBarFieldMargins()); wxDCClipper clipper(dc, rectIn); DrawLabel(dc, label, rectIn, flags, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL); -- 2.45.2