From b19d4eb9bf0623c8d4402621b49acdece19223d8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 30 Sep 2006 18:30:00 +0000 Subject: [PATCH] draw solid focus rectangle in mono theme and don't do it at all for selected items (this required adding flags parameter to DrawFocusRect()) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@41535 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/univ/renderer.h | 8 +++++--- include/wx/univ/stdrend.h | 2 +- src/univ/stdrend.cpp | 5 +++-- src/univ/themes/gtk.cpp | 5 +++-- src/univ/themes/mono.cpp | 14 ++++++++++++++ 5 files changed, 26 insertions(+), 8 deletions(-) diff --git a/include/wx/univ/renderer.h b/include/wx/univ/renderer.h index 330ca33843..225c71b9c6 100644 --- a/include/wx/univ/renderer.h +++ b/include/wx/univ/renderer.h @@ -93,7 +93,9 @@ public: // draw the focus rectangle around the label contained in the given rect - virtual void DrawFocusRect(wxDC& dc, const wxRect& rect) = 0; + // + // only wxCONTROL_SELECTED makes sense in flags here + virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0) = 0; // draw the label inside the given rectangle with the specified alignment // and optionally emphasize the character with the given index @@ -536,8 +538,8 @@ public: const wxRect& rect, int flags) { m_renderer->DrawButtonSurface(dc, col, rect, flags); } - virtual void DrawFocusRect(wxDC& dc, const wxRect& rect) - { m_renderer->DrawFocusRect(dc, rect); } + virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0) + { m_renderer->DrawFocusRect(dc, rect, flags); } virtual void DrawLabel(wxDC& dc, const wxString& label, const wxRect& rect, diff --git a/include/wx/univ/stdrend.h b/include/wx/univ/stdrend.h index 5c02eea79a..4fe5ab07fa 100644 --- a/include/wx/univ/stdrend.h +++ b/include/wx/univ/stdrend.h @@ -38,7 +38,7 @@ public: int flags); - virtual void DrawFocusRect(wxDC& dc, const wxRect& rect); + virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0); virtual void DrawLabel(wxDC& dc, const wxString& label, const wxRect& rect, diff --git a/src/univ/stdrend.cpp b/src/univ/stdrend.cpp index 147fcd0639..255092ca44 100644 --- a/src/univ/stdrend.cpp +++ b/src/univ/stdrend.cpp @@ -184,7 +184,8 @@ void wxStdRenderer::DrawButtonSurface(wxDC& dc, // text // ---------------------------------------------------------------------------- -void wxStdRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect) +void +wxStdRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect, int WXUNUSED(flags)) { // draw the pixels manually because the "dots" in wxPen with wxDOT style // may be short traits and not really dots @@ -615,7 +616,7 @@ void wxStdRenderer::DrawItem(wxDC& dc, if ( flags & wxCONTROL_FOCUSED ) { - DrawFocusRect(dc, rect); + DrawFocusRect(dc, rect, flags); } } diff --git a/src/univ/themes/gtk.cpp b/src/univ/themes/gtk.cpp index f2ec37267c..1b66387049 100644 --- a/src/univ/themes/gtk.cpp +++ b/src/univ/themes/gtk.cpp @@ -84,7 +84,7 @@ public: wxGTKRenderer(const wxColourScheme *scheme); // wxRenderer methods - virtual void DrawFocusRect(wxDC& dc, const wxRect& rect); + virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0); virtual void DrawTextBorder(wxDC& dc, wxBorder border, const wxRect& rect, @@ -834,7 +834,8 @@ void wxGTKRenderer::DrawSunkenBorder(wxDC& dc, wxRect *rect) DrawShadedRect(dc, rect, m_penBlack, m_penLightGrey); } -void wxGTKRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect) +void +wxGTKRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect, int WXUNUSED(flags)) { dc.SetBrush(*wxTRANSPARENT_BRUSH); wxRect rectFocus = rect; diff --git a/src/univ/themes/mono.cpp b/src/univ/themes/mono.cpp index c769427651..dcba79f7b0 100644 --- a/src/univ/themes/mono.cpp +++ b/src/univ/themes/mono.cpp @@ -62,6 +62,8 @@ public: int indexAccel = -1, wxRect *rectBounds = NULL); + virtual void DrawFocusRect(wxDC& dc, const wxRect& rect, int flags = 0); + virtual void DrawButtonBorder(wxDC& dc, const wxRect& rect, int flags = 0, @@ -699,6 +701,18 @@ wxMonoRenderer::DrawVerticalLine(wxDC& dc, wxCoord x, wxCoord y1, wxCoord y2) dc.DrawLine(x, y1, x, y2 + 1); } +void wxMonoRenderer::DrawFocusRect(wxDC& dc, const wxRect& rect, int flags) +{ + // no need to draw the focus rect for selected items, it would be invisible + // anyhow + if ( !(flags & wxCONTROL_SELECTED) ) + { + dc.SetPen(m_penFg); + dc.SetBrush(*wxTRANSPARENT_BRUSH); + dc.DrawRectangle(rect); + } +} + // ---------------------------------------------------------------------------- // label // ---------------------------------------------------------------------------- -- 2.47.2