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
This commit is contained in:
Václav Slavík
2006-09-29 11:45:26 +00:00
parent ab00f409f4
commit 283c797c5c
4 changed files with 49 additions and 12 deletions

View File

@@ -481,8 +481,14 @@ public:
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
// get the borders around the status bar fields (x and y fields of the // get the borders around the status bar fields (x and y fields of the
// return value) and also, optionally, the border between the fields // return value)
virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const = 0; 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 #endif // wxUSE_STATUSBAR
// get client area rectangle of top level window (i.e. subtract // get client area rectangle of top level window (i.e. subtract
@@ -856,9 +862,14 @@ public:
#endif // wxUSE_MENUS #endif // wxUSE_MENUS
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const virtual wxSize GetStatusBarBorders() const
{ return m_renderer->GetStatusBarBorders(borderBetweenFields); } { return m_renderer->GetStatusBarBorders(); }
virtual wxCoord GetStatusBarBorderBetweenFields() const
{ return m_renderer->GetStatusBarBorderBetweenFields(); }
virtual wxSize GetStatusBarFieldMargins() const
{ return m_renderer->GetStatusBarFieldMargins(); }
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR
virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const virtual wxRect GetFrameClientArea(const wxRect& rect, int flags) const
{ return m_renderer->GetFrameClientArea(rect, flags); } { return m_renderer->GetFrameClientArea(rect, flags); }
virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const virtual wxSize GetFrameTotalSize(const wxSize& clientSize, int flags) const

View File

@@ -157,7 +157,11 @@ public:
const wxString& label, const wxString& label,
int flags = 0, int style = 0); 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 #endif // wxUSE_STATUSBAR
virtual wxCoord GetCheckItemMargin() const { return 0; } virtual wxCoord GetCheckItemMargin() const { return 0; }

View File

@@ -86,7 +86,8 @@ wxRect wxStatusBarUniv::GetTotalFieldRect(wxCoord *borderBetweenFields)
// no, don't do this - the borders are meant to be inside this rect // no, don't do this - the borders are meant to be inside this rect
// wxSize sizeBorders = // wxSize sizeBorders =
m_renderer->GetStatusBarBorders(borderBetweenFields); if ( borderBetweenFields )
*borderBetweenFields = m_renderer->GetStatusBarBorderBetweenFields();
//rect.Deflate(sizeBorders.x, sizeBorders.y); //rect.Deflate(sizeBorders.x, sizeBorders.y);
// recalc the field widths if needed // recalc the field widths if needed
@@ -311,12 +312,14 @@ void wxStatusBarUniv::SetMinHeight(int WXUNUSED(height))
int wxStatusBarUniv::GetBorderX() const int wxStatusBarUniv::GetBorderX() const
{ {
return m_renderer->GetStatusBarBorders(NULL).x; return m_renderer->GetStatusBarBorders().x +
m_renderer->GetStatusBarFieldMargins().x;
} }
int wxStatusBarUniv::GetBorderY() const int wxStatusBarUniv::GetBorderY() const
{ {
return m_renderer->GetStatusBarBorders(NULL).y; return m_renderer->GetStatusBarBorders().y +
m_renderer->GetStatusBarFieldMargins().y;
} }
#endif // wxUSE_STATUSBAR #endif // wxUSE_STATUSBAR

View File

@@ -1092,11 +1092,30 @@ int wxStdRenderer::PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord)
#if wxUSE_STATUSBAR #if wxUSE_STATUSBAR
wxSize wxStdRenderer::GetStatusBarBorders(wxCoord *borderBetweenFields) const wxSize wxStdRenderer::GetStatusBarBorders() const
{ {
if ( borderBetweenFields ) // Rendered border may be different depending on field's style, we use
*borderBetweenFields = 2; // 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); return wxSize(2, 2);
} }
@@ -1113,7 +1132,7 @@ void wxStdRenderer::DrawStatusField(wxDC& dc,
else if ( style != wxSB_FLAT ) else if ( style != wxSB_FLAT )
DrawBorder(dc, wxBORDER_STATIC, rect, flags, &rectIn); DrawBorder(dc, wxBORDER_STATIC, rect, flags, &rectIn);
rectIn.Deflate(GetStatusBarBorders(NULL)); rectIn.Deflate(GetStatusBarFieldMargins());
wxDCClipper clipper(dc, rectIn); wxDCClipper clipper(dc, rectIn);
DrawLabel(dc, label, rectIn, flags, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL); DrawLabel(dc, label, rectIn, flags, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);