Hi all.
I’m dynamically generating images for certain cells in a wxListCtrl, and have run into a problem: on Windows XP (but not Mac, or Vista) when the row is selected the image … sorta warps. So its like when windows goes to “inverse” the image (I’m assuming), something strange is happening.
Basically, the contents of the cell might contain “0”, which I then map to the text I want (say, “New”), which has a certain background color. If this combination is new, I generate a new bitmap and store it… otherwise I return the previously generated index.
Attached is a cut of the screenshot-- the selected cell looks… weird. Warped. Darker as one would expect, but all stretched out and faded. I don’t know how to explain it properly
If anything obvious jumps out, cool. If not I can try to distill this down to a runnable sample, I’m just hoping its a glaringly obvious error because its a fairly massive and complex subclass.
Really, in an ideal world, I’d almost just prefer that image to just always look the same-- selected row or not. That’s how it behaves on the mac. If there’s an easier solution that makes that happen, that’d be great.
Thanks in advance!
···
def __getStatusImage(self, status):
if status in ActiveResourceList.StatusImageMap:
return ActiveResourceList.StatusImageMap[status]
text = self._StatusTextMapping[status]
fgColor = wx.NamedColour(“BLACK”)
bgColor = self._StatusBackgroundMapping[status]
bitmap = wx.EmptyBitmap(self.IMAGE_WIDTH,16)
dc = wx.MemoryDC(bitmap)
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.Clear()
dc.SetPen(wx.Pen(bgColor))
dc.SetBrush(wx.Brush(bgColor))
dc.DrawRectangle(0, 0, 100, 16)
dc.SetPen(wx.WHITE_PEN)
dc.SetBrush(wx.TRANSPARENT_BRUSH)
dc.SetTextForeground(wx.WHITE)
dc.SetBackgroundMode(wx.TRANSPARENT)
before = text
x = 0
y = 0
for ch in text:
try:
dc.DrawText(ch, x, y)
w, h = dc.GetTextExtent(ch)
x = x + w
if x > 100 - 5:
break
except:
pass
dc = None
del dc
index = ActiveResourceList.ResourceImages.Add(
bitmap
)
ActiveResourceList.StatusImageMap[status] = index
return index