From 090a8353e58270a7f4cc7ff2d082b2f77f3600e0 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Tue, 16 Dec 2014 20:16:20 +0000 Subject: [PATCH] Move wxRendererMSW::DrawTextCtrl() implementation to wxRendererGeneric. This ensures that wxRendererGeneric::DrawGauge() is actually usable as otherwise calling it always resulted in an assertion failure because it used DrawTextCtrl() which was not implemented in wxRendererGeneric. So this fixes using DrawGauge() in non-MSW ports which was added by r77023 (see #16406) but apparently never worked. Also remove wxRendererMSW::DrawGauge() as it's exactly the same as the version inherited from wxRendererGeneric. Closes #16725. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@78278 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- src/generic/renderg.cpp | 24 +++++++++++++++--- src/msw/renderer.cpp | 55 ----------------------------------------- 2 files changed, 20 insertions(+), 59 deletions(-) diff --git a/src/generic/renderg.cpp b/src/generic/renderg.cpp index e1b8f588e6..a865311c21 100644 --- a/src/generic/renderg.cpp +++ b/src/generic/renderg.cpp @@ -777,10 +777,21 @@ void wxRendererGeneric::DrawRadioBitmap(wxWindow* WXUNUSED(win), wxDC& WXUNUSED( wxFAIL_MSG("UNIMPLEMENTED: wxRendererGeneric::DrawRadioBitmap"); } -void wxRendererGeneric::DrawTextCtrl(wxWindow* WXUNUSED(win), wxDC& WXUNUSED(dc), - const wxRect& WXUNUSED(rect), int WXUNUSED(flags)) +void wxRendererGeneric::DrawTextCtrl(wxWindow* WXUNUSED(win), + wxDC& dc, + const wxRect& rect, + int WXUNUSED(flags)) { - wxFAIL_MSG("UNIMPLEMENTED: wxRendererGeneric::DrawTextCtrl"); + wxColour fill; + wxColour bdr; + { + fill = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); + bdr = *wxBLACK; + } + + dc.SetPen(bdr); + dc.SetBrush(fill); + dc.DrawRectangle(rect); } #ifdef wxHAS_DRAW_TITLE_BAR_BITMAP @@ -800,7 +811,12 @@ void wxRendererGeneric::DrawTitleBarBitmap(wxWindow * WXUNUSED(win), #endif // wxHAS_DRAW_TITLE_BAR_BITMAP -void wxRendererGeneric::DrawGauge(wxWindow* win, wxDC& dc, const wxRect& rect, int value, int max, int WXUNUSED(flags)) +void wxRendererGeneric::DrawGauge(wxWindow* win, + wxDC& dc, + const wxRect& rect, + int value, + int max, + int WXUNUSED(flags)) { // Use same background as text controls. DrawTextCtrl(win, dc, rect); diff --git a/src/msw/renderer.cpp b/src/msw/renderer.cpp index e0b46a35d5..19ce59ff75 100644 --- a/src/msw/renderer.cpp +++ b/src/msw/renderer.cpp @@ -153,11 +153,6 @@ public: wxDC& dc, const wxRect& rect, int flags = 0) = 0; - - virtual void DrawTextCtrl(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0) = 0; }; // ---------------------------------------------------------------------------- @@ -189,11 +184,6 @@ public: const wxRect& rect, int flags = 0); - virtual void DrawTextCtrl(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0); - virtual void DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect, @@ -208,13 +198,6 @@ public: wxTitleBarButton button, int flags = 0); - virtual void DrawGauge(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int value, - int max, - int flags = 0); - virtual wxSize GetCheckBoxSize(wxWindow *win); virtual int GetHeaderButtonHeight(wxWindow *win); @@ -597,44 +580,6 @@ int wxRendererMSW::GetHeaderButtonMargin(wxWindow *WXUNUSED(win)) return 10; } -// Uses the theme to draw the border and fill for something like a wxTextCtrl -void wxRendererMSW::DrawTextCtrl(wxWindow* WXUNUSED(win), - wxDC& dc, - const wxRect& rect, - int WXUNUSED(flags)) -{ - wxColour fill; - wxColour bdr; - { - fill = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOW); - bdr = *wxBLACK; - } - - dc.SetPen(bdr); - dc.SetBrush(fill); - dc.DrawRectangle(rect); -} - -void wxRendererMSW::DrawGauge(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int value, - int max, - int WXUNUSED(flags)) -{ - // Use text ctrl back as background - DrawTextCtrl(win, dc, rect); - - // Calc progress bar size - wxRect progRect(rect); - progRect.Deflate(2); - progRect.width = wxMulDivInt32(progRect.width, value, max); - - dc.SetBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); - dc.SetPen(*wxTRANSPARENT_PEN); - dc.DrawRectangle(progRect); -} - // ============================================================================ // wxRendererXP implementation // ============================================================================