tree control & drawing
Alan Shouls
alan at softpress.com
Tue Oct 3 03:16:32 PDT 2006
Hi,
I am working on the tree control under OSX and currently looking at
the highlight. I have added support for bitmap highlights so it is
possible to have a gradient highlight that you get in the left had
column of Finder windows and many Apple applications. To do this I
have added some new methods to the tree control
virtual void SetHighlightImage(const wxImage &);
virtual void SetUnfocusedHighlightImage(const wxImage &);
There is some tom-foolery to cache a correctly scaled bitmap within
in the tree control (wxImage and wxBitmap make it easy). The results
don't look bad (heres a screeny)
http://users.softpress.com/alan/Resources/treetest1.png
One of the things is that has become apparent to me that it is
impossible to write a subclass or hook into any events to make it
possible to override drawing behaviour in the base-class.
The drawing of an individual item is achieved through 'PaintItem'.
This method is not virtual and there are no events that I can hook
into. For me the only way to work with it is to modify the
'wxGenericTreeCtrl' its self. To my mind the code could easily be
split across a few methods that could themselves be virtual. What I
am thinking is that painting an item could be done though
PaintItemBackground
PaintItemHighlight
PaintItemContents
Or something like this. Obviously it would be possible to create a
set of events etc. to do the same, Generally when working with a
framework I would make some sub-class that encapsulated whatever
modifications to the appearance / behaviour that I needed and the
process of incorporating some of this into the framework its self is
a fight for another day. This is not really possible with the tree
control with wx.
I believe that moves are afoot to base the tree control on the
databrowser so it may not be the case that making modifications to
the treecontrol on wx are appropriate - so these questions may be a
little academic. If on the other hand it does not get there I would
like to be able to have something that I can offer to the wx
community.
Best regards
Alan Shouls
More information about the wx-dev
mailing list