move generic part of AdjustSize() and status bar methods to the base class

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41328 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2006-09-20 17:24:29 +00:00
parent c2c4d939f3
commit 1cd9779fce
4 changed files with 71 additions and 78 deletions

View File

@ -132,6 +132,10 @@ public:
virtual bool AreScrollbarsInsideBorder() const;
virtual void AdjustSize(wxSize *size, const wxWindow *window);
virtual wxCoord GetListboxItemHeight(wxCoord fontHeight);
#if wxUSE_SCROLLBAR
virtual wxRect GetScrollbarRect(const wxScrollBar *scrollbar,
wxScrollBar::Element elem,
@ -147,6 +151,17 @@ public:
virtual int PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord);
#endif // wxUSE_SCROLLBAR
#if wxUSE_STATUSBAR
virtual void DrawStatusField(wxDC& dc,
const wxRect& rect,
const wxString& label,
int flags = 0, int style = 0);
virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const;
#endif // wxUSE_STATUSBAR
virtual wxCoord GetCheckItemMargin() const { return 0; }
protected:
// various constants
enum ArrowDirection

View File

@ -441,11 +441,24 @@ wxRect wxStdRenderer::GetBorderDimensions(wxBorder border) const
return rect;
}
void wxStdRenderer::AdjustSize(wxSize *size, const wxWindow *window)
{
// take into account the border width
wxRect rectBorder = GetBorderDimensions(window->GetBorder());
size->x += rectBorder.x + rectBorder.width;
size->y += rectBorder.y + rectBorder.height;
}
bool wxStdRenderer::AreScrollbarsInsideBorder() const
{
return false;
}
wxCoord wxStdRenderer::GetListboxItemHeight(wxCoord fontHeight)
{
return fontHeight + 2;
}
void wxStdRenderer::DrawTextBorder(wxDC& dc,
wxBorder border,
const wxRect& rect,
@ -1047,3 +1060,37 @@ int wxStdRenderer::PixelToScrollbar(const wxScrollBar *scrollbar, wxCoord coord)
#endif // wxUSE_SCROLLBAR
// ----------------------------------------------------------------------------
// status bar
// ----------------------------------------------------------------------------
#if wxUSE_STATUSBAR
wxSize wxStdRenderer::GetStatusBarBorders(wxCoord *borderBetweenFields) const
{
if ( borderBetweenFields )
*borderBetweenFields = 2;
return wxSize(2, 2);
}
void wxStdRenderer::DrawStatusField(wxDC& dc,
const wxRect& rect,
const wxString& label,
int flags,
int style)
{
wxRect rectIn;
if ( style == wxSB_RAISED )
DrawBorder(dc, wxBORDER_RAISED, rect, flags, &rectIn);
else if ( style != wxSB_FLAT )
DrawBorder(dc, wxBORDER_STATIC, rect, flags, &rectIn);
rectIn.Deflate(GetStatusBarBorders(NULL));
wxDCClipper clipper(dc, rectIn);
DrawLabel(dc, label, rectIn, flags, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
}
#endif // wxUSE_STATUSBAR

View File

@ -115,8 +115,6 @@ public:
wxOrientation orient,
const wxRect& rect,
int flags = 0);
virtual void DrawScrollCorner(wxDC& dc,
const wxRect& rect);
#if wxUSE_TOOLBAR
virtual void DrawToolBarButton(wxDC& dc,
@ -188,13 +186,6 @@ public:
const wxMenuGeometryInfo& geomInfo);
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
virtual void DrawStatusField(wxDC& dc,
const wxRect& rect,
const wxString& label,
int flags = 0, int style = 0);
#endif // wxUSE_STATUSBAR
virtual void DrawFrameTitleBar(wxDC& dc,
const wxRect& rect,
const wxString& title,
@ -244,8 +235,6 @@ public:
int thumbPos = -1) const;
#endif // wxUSE_SCROLLBAR
virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
{ return fontHeight + 2; }
virtual wxSize GetCheckBitmapSize() const
{ return wxSize(10, 10); }
virtual wxSize GetRadioBitmapSize() const
@ -289,10 +278,6 @@ public:
const wxMenu& menu) const;
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const;
#endif // wxUSE_STATUSBAR
// helpers for "wxBitmap wxColourScheme::Get()"
void DrawCheckBitmap(wxDC& dc, const wxRect& rect);
void DrawUncheckBitmap(wxDC& dc, const wxRect& rect, bool isPressed);
@ -1895,27 +1880,6 @@ wxMenuGeometryInfo *wxGTKRenderer::GetMenuGeometry(wxWindow *win,
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
// ----------------------------------------------------------------------------
// status bar
// ----------------------------------------------------------------------------
wxSize
wxGTKRenderer::GetStatusBarBorders(wxCoord * WXUNUSED(borderBetweenFields)) const
{
return wxSize(0,0);
}
void wxGTKRenderer::DrawStatusField(wxDC& WXUNUSED(dc),
const wxRect& WXUNUSED(rect),
const wxString& WXUNUSED(label),
int WXUNUSED(flags), int WXUNUSED(style))
{
}
#endif // wxUSE_STATUSBAR
// ----------------------------------------------------------------------------
// combobox
// ----------------------------------------------------------------------------
@ -2309,11 +2273,6 @@ void wxGTKRenderer::DrawScrollbarShaft(wxDC& dc,
DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, SCROLLBAR), rectBar);
}
void wxGTKRenderer::DrawScrollCorner(wxDC& dc, const wxRect& rect)
{
DrawSolidRect(dc, wxSCHEME_COLOUR(m_scheme, CONTROL), rect);
}
#if wxUSE_SCROLLBAR
wxRect wxGTKRenderer::GetScrollbarRect(const wxScrollBar *scrollbar,
wxScrollBar::Element elem,
@ -2382,9 +2341,7 @@ void wxGTKRenderer::AdjustSize(wxSize *size, const wxWindow *window)
#endif // wxUSE_SCROLLBAR
{
// take into account the border width
wxRect rectBorder = GetBorderDimensions(window->GetBorder());
size->x += rectBorder.x + rectBorder.width;
size->y += rectBorder.y + rectBorder.height;
wxStdRenderer::AdjustSize(size, window);
}
}

View File

@ -258,8 +258,6 @@ public:
virtual wxSize GetScrollbarArrowSize() const
{ return m_sizeScrollbarArrow; }
virtual wxCoord GetListboxItemHeight(wxCoord fontHeight)
{ return fontHeight + 2; }
virtual wxSize GetCheckBitmapSize() const
{ return wxSize(13, 13); }
virtual wxSize GetRadioBitmapSize() const
@ -306,10 +304,6 @@ public:
const wxMenu& menu) const;
#endif // wxUSE_MENUS
#if wxUSE_STATUSBAR
virtual wxSize GetStatusBarBorders(wxCoord *borderBetweenFields) const;
#endif // wxUSE_STATUSBAR
protected:
// overridden wxStdRenderer methods
virtual void DrawFrameWithLabel(wxDC& dc,
@ -2615,25 +2609,15 @@ wxMenuGeometryInfo *wxWin32Renderer::GetMenuGeometry(wxWindow *win,
// status bar
// ----------------------------------------------------------------------------
static const wxCoord STATBAR_BORDER_X = 2;
static const wxCoord STATBAR_BORDER_Y = 2;
wxSize wxWin32Renderer::GetStatusBarBorders(wxCoord *borderBetweenFields) const
{
if ( borderBetweenFields )
*borderBetweenFields = 2;
return wxSize(STATBAR_BORDER_X, STATBAR_BORDER_Y);
}
void wxWin32Renderer::DrawStatusField(wxDC& dc,
const wxRect& rect,
const wxString& label,
int flags, int style /*=0*/)
int flags,
int style)
{
wxRect rectIn;
if ( flags & wxCONTROL_ISDEFAULT )
if ( flags & wxCONTROL_SIZEGRIP )
{
// draw the size grip: it is a normal rect except that in the lower
// right corner we have several bands which may be used for dragging
@ -2688,19 +2672,12 @@ void wxWin32Renderer::DrawStatusField(wxDC& dc,
rectIn.Deflate(1);
rectIn.width -= STATUSBAR_GRIP_SIZE;
}
else // normal pane
{
if (style == wxSB_RAISED)
DrawBorder(dc, wxBORDER_RAISED, rect, flags, &rectIn);
else if (style != wxSB_FLAT)
DrawBorder(dc, wxBORDER_STATIC, rect, flags, &rectIn);
// this will prevent the standard version from drawing any borders
style = wxSB_FLAT;
}
rectIn.Deflate(STATBAR_BORDER_X, STATBAR_BORDER_Y);
wxDCClipper clipper(dc, rectIn);
DrawLabel(dc, label, rectIn, flags, wxALIGN_LEFT | wxALIGN_CENTRE_VERTICAL);
DrawStatusField(dc, rect, label, flags, style);
}
#endif // wxUSE_STATUSBAR
@ -3599,10 +3576,7 @@ void wxWin32Renderer::AdjustSize(wxSize *size, const wxWindow *window)
}
#endif // wxUSE_BUTTON || wxUSE_TOGGLEBTN
// take into account the border width
wxRect rectBorder = GetBorderDimensions(window->GetBorder());
size->x += rectBorder.x + rectBorder.width;
size->y += rectBorder.y + rectBorder.height;
wxStdRenderer::AdjustSize(size, window);
}
// ============================================================================