Hi Stefano,
Hello Andrea,
> Well, in theory CustomTreeCtrl should be able to do both... I have
> never used it in virtual mode, is there any chance you can send a
> small sample app that demonstrates the problem so that I (or someone
> more knowledgeable than me in wx) can try to fix the problem?You can just use latest wxDemo, go to More Windows/Controls-TreeMixin, add a
few items: with TreeCtrl and TreeListCtrl every third item has a green
background while CustomTreeCtrl items remain all white background
I have found the problem, and the workaround is quite simple. In the
wxPython version 2.8.7.1 (not the SVN one or the pre-release), around
line 4387 of CustomTreeCtrl source, there is this if condition:
if self.HasFlag(TR_FULL_ROW_HIGHLIGHT):
x = 0
w, h = self.GetClientSize()
itemrect = wx.Rect(x, item.GetY()+offset, w, total_h-offset)
if item.IsSelected():
if self._usegradients:
if self._gradientstyle == 0: # Horizontal
self.DrawHorizontalGradient(dc, itemrect,
self._hasFocus)
else: # Vertical
self.DrawVerticalGradient(dc, itemrect, self._hasFocus)
elif self._vistaselection:
self.DrawVistaRectangle(dc, itemrect, self._hasFocus)
else:
if wx.Platform in ["__WXGTK2__", "__WXMAC__"]:
flags = wx.CONTROL_SELECTED
if self._hasFocus: flags = flags | wx.CONTROL_FOCUSED
wx.RendererNative.Get().DrawItemSelectionRect(self, dc, itemrect,
flags)
else:
dc.DrawRectangleRect(itemrect)
What you should do, is to add the following lines of code:
else:
if drawItemBackground:
minusicon = wcheck + image_w - 2
itemrect = wx.Rect(item.GetX()+minusicon,
item.GetY()+offset,
item.GetWidth()-minusicon,
total_h-offset)
dc.DrawRectangleRect(itemrect)
This "else" condition is at the same level of the "if
item.IsSelected():" if condition. It works here for me. The problem
was related to the wx.TR_FULL_ROW_HIGHLIGHT, which prevented the
drawing of the item background (I don't know why, it's just a bug).
*Important*:
For wxPython developers with SVN access: I had to format my computer
at home because of various problems, is there anyone who could please
update the SVN source of CustomTreeCtrl with this modification? I can
not do it from work as our firewall is a bit too tight.
Thank you for your help.
Andrea.
"Imagination Is The Only Weapon In The War Against Reality."
http://xoomer.alice.it/infinity77/
ยทยทยท
On Mon, Apr 7, 2008 at 11:06 AM, Stefano Bartaletti wrote: