Alle lunedì 07 aprile 2008, hai scritto:
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_FOCUSEDwx.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).
This workaround looks good, many thanks. Anyway, after some testing, I
preferred a different approach. With your code the item row didn't look nice
for me (see shot 1) because I wanted the full row to be colored so I changed
your code into:
elif drawItemBackground:
dc.DrawRectangleRect(itemrect)
result in shot 2
···
--
Cordialmente
Stefano Bartaletti
Responsabile Software
G.Tosi Spa Tintoria
Skype account: stefano.bartaletti
ICQ contact : 1271960
Viale dell'Industria 61
21052 Busto Arsizio (VA)
Tel. +39 0331 34 48 11
Fax +39 0331 35 21 23