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.
This commit is contained in:
Dimitri Schoolwerth
2021-02-01 22:56:36 +01:00
parent ebec1ff9f6
commit 771ebfa9a9

View File

@@ -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);
}