[wx-dev] tree control & drawing

Vadim Zeitlin vadim at wxwindows.org
Tue Oct 3 04:48:56 PDT 2006


On Tue, 03 Oct 2006 13:38:13 +0200 Robert Roebling wrote:

RR> >      virtual void SetHighlightImage(const wxImage &);
RR> >      virtual void SetUnfocusedHighlightImage(const wxImage &);
RR> 
RR> We'd generally use wxBitmap or wxIcon for such an interface.

 wxBitmap -- wxIcon should be used if we need a mask but I don't think this
is the case here. OTOH I admit that even after I looked at the screenshot I
still don't understand why do we need a bitmap here at all: don't you just
draw a colour gradient? And if so, why not use the appropriate wxDC method?

RR> > One of the things is that has become apparent to me that it is 
RR> > impossible to write a subclass or hook into any events to make it 
RR> > possible to override drawing behaviour in the base-class.
...
RR> I'd say virtual methods are more appropriate here, but keep in mind
RR> that the wxTreeCtrl under Windows is the native control and it
RR> probably cannot be custmoized like that.

 Exactly. While I won't say that the design of the generic wxTreeCtrl is
ideal, you should take into account that it's not really simple to improve
it because as soon as you make this PaintItem() virtual method part of
public class interface you'll also need to implement it for Win32 (which is
definitely possible but someone still needs to do it) and, in the future,
for Mac OS native data browser based implementation too.

 Regards,
VZ





More information about the wx-dev mailing list