Invoking super().Draw in GridCellRenderer

Hello Robin and all. Happy holidays!

I have a fairly technical question. In summary: Is it possible to invoke super().Draw in a custom GridCellRenderer?

Longer discussion:

From: https://docs.wxwidgets.org/trunk/classwx_grid_cell_renderer.html#a1848512422742bbbf9dec1b173bfc752 we remark that Draw is pure virtual but has a default implementation that prepares the display context.

I was thinking of invoking super().Draw(...) as part of my own renderer’s Draw method but this does not work raising an exception to the effect that Draw is virtual.

I was looking at https://github.com/wxWidgets/Phoenix/blob/c422227c1d9c62fd71d6cf8c2081dc7b2dcb7519/etg/grid.py#L253-L275 to see if there was something obvious (to me) that I could change. To that effect I looked at the SIP docs at https://www.riverbankcomputing.com/static/Docs/sip/ and I noticed we can use virtualCatcherCode to provide a default python implementation, and remark that you use it in some parts of the code, but I do not think this was what we want in this case, is it?.

What do you think? Is there something we can do to allow invoking the default implementation of Draw in a custom GridCellRenderer?

Evidently this is not a big thing as one can just reimplement the default implementation https://github.com/wxWidgets/wxWidgets/blob/23c78057428339437b07a2cb4a6cb0dfe30b2885/src/generic/gridctrl.cpp#L38-L70 in python trivially.

Thank you. Best regards,

Jorge

In C++ a pure virtual with an implementation is not a common thing. (Personally I would call it an oxymoron…) Since SIP can’t tell if there is an implementation or not, it has to assume that the pure virtual really is a pure virtual with no implementation.

I can easily override this in the etg/grid.py, and so far it seems to be working okay. Once I ensure that compilers on the other platforms are still happy then I’ll commit the change.

Thank you, Robin. I look forward to see what the solution looks like and learn something.

With the ETG framework used for converting from Doxygen XML to SIP code it is simply a matter of turning off the pure virtual flag for that method.

1 Like