wx 3.3.0, wxGrid and custom renderer problems.

42 views
Skip to first unread message

Tony Kennedy

unread,
Jul 4, 2025, 3:25:12 AMJul 4
to wx-users
Hi all,

I've got a wxGrid, and for one of the columns, I define a custom renderer. This was working fine in wx 3.1.5 and 3.2.6, but now I've updated to 3.3.0, most of the grid does not display properly if I enable the custom renderer.

Is anyone aware of any problems with this?

Thanks in advance,

Tony.

Tony Kennedy

unread,
Jul 4, 2025, 3:40:00 AMJul 4
to wx-users
Think I've found the issue. In the "Draw" function for my custom renderer, I call "dc.Clear()". This seems to clear the entire grid, not just the area to be rendered. If I comment this out, I get the rest of the grid drawing correctly, just not my cell.

void wxCustomCellRenderer::Draw(wxGrid& grid, wxGridCellAttr& attr, wxDC& dc, const wxRect& rect, int row, int col, bool isSelected)
{
    dc.Clear();

AliKet

unread,
Jul 4, 2025, 9:46:06 AMJul 4
to wx-users
Does it help if you restrict the drawing to just _ rect _? i.e.: set a clipping rectangle to _rect_ before drawing anything ?

Tony Kennedy

unread,
Jul 4, 2025, 9:56:05 AMJul 4
to wx-users
Yes, if I just draw in the rect, all works fine.

Tony.

Vadim Zeitlin

unread,
Jul 5, 2025, 5:54:01 PMJul 5
to wx-u...@googlegroups.com
On Fri, 4 Jul 2025 06:56:04 -0700 (PDT) Tony Kennedy wrote:

TK> Yes, if I just draw in the rect, all works fine.

I think you have to do this, possibly by setting the clipping rectangle
yourself, because we do want to allow the renderers to draw beyond the
current cell, at least for overflowing text.

I'm quite surprised this has changed since 3.2, however, I don't see any
differences in the relevant code...

Regards,
VZ

--
TT-Solutions: wxWidgets consultancy and technical support
https://www.tt-solutions.com/

Tony Kennedy

unread,
Jul 7, 2025, 2:55:03 AMJul 7
to wx-users
Something has definitely changed. Prior to 3.3.0, if I call "dc.Clear();" during the custom renderer "Draw" function, it only clears the cell. Now it clears the whole grid, the gridlines do still draw though. Strange.

I've got it working anyway now, and it's definitely better practice to limit drawing to the actual rect I'm supposed to draw into.

Tony.

Reply all
Reply to author
Forward
0 new messages