]> git.saurik.com Git - wxWidgets.git/commitdiff
fixed wxStatusBar size calculations so that the text is not clipped
authorVáclav Slavík <vslavik@fastmail.fm>
Fri, 29 Sep 2006 11:45:26 +0000 (11:45 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Fri, 29 Sep 2006 11:45:26 +0000 (11:45 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41503 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/univ/renderer.h
include/wx/univ/stdrend.h
src/univ/statusbr.cpp
src/univ/stdrend.cpp

index c9e33d84ca3adfab3462cd491d85839d619e74b3..330ca33843b30ee6f4032230db621e975ef08a00 100644 (file)
@@ -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
index f46b25792c846f827fda0581c0b5264524d8ae6f..5c02eea79ae64aa3ef052720242737251c6bf2ae 100644 (file)
@@ -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; }
index ccb51540e6cd6ce67f639c02897fe99d213f335b..b4846a87665657dde306ce74c6c459486769ef03 100644 (file)
@@ -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
index 54c31778833b579a1254785416fc8167c40b30a0..147fcd0639fd037adf01c7451eb8a9d376df3872 100644 (file)
@@ -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);