X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/92c32bbee7cde97f465a5632734d63f050f5d550..33820d94285c0004acce756e7d10d9698e6387d1:/src/msw/renderer.cpp?ds=sidebyside diff --git a/src/msw/renderer.cpp b/src/msw/renderer.cpp index c8f46f0274..2408a16dd8 100644 --- a/src/msw/renderer.cpp +++ b/src/msw/renderer.cpp @@ -162,11 +162,33 @@ private: #define DFCS_HOT 0x1000 #endif +// ---------------------------------------------------------------------------- +// methods common to wxRendererMSW and wxRendererXP +// ---------------------------------------------------------------------------- + +class wxRendererMSWBase : public wxDelegateRendererNative +{ +public: + wxRendererMSWBase() { } + wxRendererMSWBase(wxRendererNative& rendererNative) + : wxDelegateRendererNative(rendererNative) { } + + void DrawFocusRect(wxWindow * win, + wxDC& dc, + const wxRect& rect, + int flags = 0); + + void DrawItemSelectionRect(wxWindow *win, + wxDC& dc, + const wxRect& rect, + int flags = 0); +}; + // ---------------------------------------------------------------------------- // wxRendererMSW: wxRendererNative implementation for "old" Win32 systems // ---------------------------------------------------------------------------- -class WXDLLEXPORT wxRendererMSW : public wxDelegateRendererNative +class wxRendererMSW : public wxRendererMSWBase { public: wxRendererMSW() { } @@ -188,11 +210,6 @@ public: const wxRect& rect, int flags = 0); - virtual void DrawFocusRect(wxWindow* win, - wxDC& dc, - const wxRect& rect, - int flags = 0); - virtual void DrawChoice(wxWindow* win, wxDC& dc, const wxRect& rect, @@ -208,12 +225,12 @@ public: const wxRect& rect, int flags=0); - virtual void DrawRadioButton(wxWindow* win, + virtual void DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect, int flags=0); - virtual wxSize GetCheckBoxSize() const; + virtual wxSize GetCheckBoxSize(wxWindow *win); virtual int GetHeaderButtonHeight(wxWindow *win); @@ -227,10 +244,10 @@ private: #if wxUSE_UXTHEME -class WXDLLEXPORT wxRendererXP : public wxDelegateRendererNative +class wxRendererXP : public wxRendererMSWBase { public: - wxRendererXP() : wxDelegateRendererNative(wxRendererMSW::Get()) { } + wxRendererXP() : wxRendererMSWBase(wxRendererMSW::Get()) { } static wxRendererNative& Get(); @@ -269,12 +286,6 @@ public: const wxRect& rect, int flags = 0); - virtual void DrawItemSelectionRect(wxWindow *win, - wxDC& dc, - const wxRect& rect, - int flags = 0 ); - - virtual wxSplitterRenderParams GetSplitterParams(const wxWindow *win); private: wxDECLARE_NO_COPY_CLASS(wxRendererXP); @@ -282,6 +293,53 @@ private: #endif // wxUSE_UXTHEME + +// ============================================================================ +// wxRendererMSWBase implementation +// ============================================================================ + +void wxRendererMSWBase::DrawFocusRect(wxWindow * WXUNUSED(win), + wxDC& dc, + const wxRect& rect, + int WXUNUSED(flags)) +{ + RECT rc; + wxCopyRectToRECT(rect, rc); + + ::DrawFocusRect(GraphicsHDC(&dc), &rc); +} + +void wxRendererMSWBase::DrawItemSelectionRect(wxWindow *win, + wxDC& dc, + const wxRect& rect, + int flags) +{ + wxBrush brush; + if ( flags & wxCONTROL_SELECTED ) + { + if ( flags & wxCONTROL_FOCUSED ) + { + brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); + } + else // !focused + { + brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); + } + } + else // !selected + { + brush = *wxTRANSPARENT_BRUSH; + } + + dc.SetBrush(brush); + dc.SetPen(*wxTRANSPARENT_PEN); + dc.DrawRectangle( rect ); + + if ((flags & wxCONTROL_FOCUSED) && (flags & wxCONTROL_CURRENT)) + DrawFocusRect( win, dc, rect, flags ); +} + + // ============================================================================ // wxRendererNative and wxRendererMSW implementation // ============================================================================ @@ -377,18 +435,7 @@ wxRendererMSW::DrawPushButton(wxWindow * WXUNUSED(win), ::DrawFrameControl(GraphicsHDC(&dc), &rc, DFC_BUTTON, style); } -void wxRendererMSW::DrawFocusRect(wxWindow * WXUNUSED(win), - wxDC& dc, - const wxRect& rect, - int WXUNUSED(flags)) -{ - RECT rc; - wxCopyRectToRECT(rect, rc); - - ::DrawFocusRect(GraphicsHDC(&dc), &rc); -} - -wxSize wxRendererMSW::GetCheckBoxSize() const +wxSize wxRendererMSW::GetCheckBoxSize(wxWindow * WXUNUSED(win)) { return wxSize(::GetSystemMetrics(SM_CXMENUCHECK), ::GetSystemMetrics(SM_CYMENUCHECK)); @@ -480,7 +527,7 @@ void wxRendererMSW::DrawChoice(wxWindow* win, wxDC& dc, // Draw a themed radio button -void wxRendererMSW::DrawRadioButton(wxWindow* win, wxDC& dc, const wxRect& rect, int flags) +void wxRendererMSW::DrawRadioBitmap(wxWindow* win, wxDC& dc, const wxRect& rect, int flags) { #if wxUSE_UXTHEME wxUxThemeHandle hTheme(win, L"BUTTON"); @@ -740,38 +787,6 @@ wxRendererXP::DrawPushButton(wxWindow * win, ); } -void -wxRendererXP::DrawItemSelectionRect(wxWindow *win, - wxDC& dc, - const wxRect& rect, - int flags) -{ - wxBrush brush; - if ( flags & wxCONTROL_SELECTED ) - { - if ( flags & wxCONTROL_FOCUSED ) - { - brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_HIGHLIGHT)); - } - else // !focused - { - brush = wxBrush(wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE)); - } - } - else // !selected - { - brush = *wxTRANSPARENT_BRUSH; - } - - dc.SetBrush(brush); - dc.SetPen(*wxTRANSPARENT_PEN); - dc.DrawRectangle( rect ); - - if ((flags & wxCONTROL_FOCUSED) && (flags & wxCONTROL_CURRENT)) - DrawFocusRect( win, dc, rect, flags ); -} - - // ---------------------------------------------------------------------------- // splitter drawing