From 1cd9779fce63b081d875de7a901c8eb6120d0b8a Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 20 Sep 2006 17:24:29 +0000 Subject: [PATCH] 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 --- include/wx/univ/stdrend.h | 15 +++++++++++++ src/univ/stdrend.cpp | 47 +++++++++++++++++++++++++++++++++++++++ src/univ/themes/gtk.cpp | 45 +------------------------------------ src/univ/themes/win32.cpp | 42 +++++++--------------------------- 4 files changed, 71 insertions(+), 78 deletions(-) diff --git a/include/wx/univ/stdrend.h b/include/wx/univ/stdrend.h index 9acd6e31bf..a78452202e 100644 --- a/include/wx/univ/stdrend.h +++ b/include/wx/univ/stdrend.h @@ -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 diff --git a/src/univ/stdrend.cpp b/src/univ/stdrend.cpp index 14e2395353..488231c473 100644 --- a/src/univ/stdrend.cpp +++ b/src/univ/stdrend.cpp @@ -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 diff --git a/src/univ/themes/gtk.cpp b/src/univ/themes/gtk.cpp index 382823ee04..ef2860b0b0 100644 --- a/src/univ/themes/gtk.cpp +++ b/src/univ/themes/gtk.cpp @@ -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); } } diff --git a/src/univ/themes/win32.cpp b/src/univ/themes/win32.cpp index cca5284673..351f9f0955 100644 --- a/src/univ/themes/win32.cpp +++ b/src/univ/themes/win32.cpp @@ -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); - } - rectIn.Deflate(STATBAR_BORDER_X, STATBAR_BORDER_Y); + // this will prevent the standard version from drawing any borders + style = wxSB_FLAT; + } - 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); } // ============================================================================ -- 2.45.2