From 771ebfa9a95fef46c316c9cbfb643f623525f7e1 Mon Sep 17 00:00:00 2001 From: Dimitri Schoolwerth Date: Mon, 1 Feb 2021 22:56:36 +0100 Subject: [PATCH] Add wxDataViewCtrl debug option to display render bounds For debugging convenience define DEBUG_RENDER_EXTENTS to draw a red rectangle around a custom rendered cell's full rectangle, and a green rect for the extent of the item appearing inside it. Custom renderers ordinarily should not draw outside of the green rect. A notable exception is drawn text, particularly multi-line ones. --- src/common/datavcmn.cpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/src/common/datavcmn.cpp b/src/common/datavcmn.cpp index 2c6fbe11d1..715bfc08cc 100644 --- a/src/common/datavcmn.cpp +++ b/src/common/datavcmn.cpp @@ -32,6 +32,10 @@ #include "wx/access.h" #endif // wxUSE_ACCESSIBILITY +// Uncomment this line to, for custom renderers, visually show the extent +// of both a cell and its item. +//#define DEBUG_RENDER_EXTENTS + const char wxDataViewCtrlNameStr[] = "dataviewCtrl"; namespace @@ -1035,6 +1039,20 @@ wxDataViewCustomRendererBase::WXCallRender(wxRect rectCell, wxDC *dc, int state) if ( m_attr.HasFont() ) changeFont.Set(m_attr.GetEffectiveFont(dc->GetFont())); +#ifdef DEBUG_RENDER_EXTENTS + { + + wxDCBrushChanger changeBrush(*dc, *wxTRANSPARENT_BRUSH); + wxDCPenChanger changePen(*dc, *wxRED); + + dc->DrawRectangle(rectCell); + + dc->SetPen(*wxGREEN); + dc->DrawRectangle(rectItem); + + } +#endif + Render(rectItem, dc, state); }