Made Display class 100% flicker free on wxMSW.

This commit is contained in:
HomeWorld
2010-12-11 04:05:19 +02:00
parent 91c58ec257
commit 2bec2e38b6

View File

@@ -36,6 +36,9 @@ class Display(wx.ListCtrl):
self.Bind(wx.EVT_LIST_COL_END_DRAG, self.resizeChecker)
self.Bind(wx.EVT_LIST_COL_BEGIN_DRAG, self.resizeSkip)
if "wxMSW" in wx.PlatformInfo:
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBk)
self.mainFrame = gui.mainFrame.MainFrame.getInstance()
i = 0
@@ -68,6 +71,42 @@ class Display(wx.ListCtrl):
self.imageListBase = self.imageList.ImageCount
def OnEraseBk(self,event):
if self.GetItemCount() >0:
width, height = self.GetClientSize()
dc = event.GetDC()
dc.DestroyClippingRegion()
dc.SetClippingRegion(0, 0, width, height)
x,y,w,h = dc.GetClippingBox()
topItem = self.GetTopItem()
bottomItem = topItem + self.GetCountPerPage()
if bottomItem >= self.GetItemCount():
bottomItem = self.GetItemCount() - 1
topRect = self.GetItemRect(topItem, wx.LIST_RECT_LABEL)
bottomRect = self.GetItemRect(bottomItem, wx.LIST_RECT_BOUNDS)
items_rect = wx.Rect(topRect.left, 0, bottomRect.right - topRect.left, bottomRect.bottom )
updateRegion = wx.Region(x,y,w,h)
updateRegion.SubtractRect(items_rect)
dc.DestroyClippingRegion()
dc.SetClippingRegionAsRegion(updateRegion)
dc.SetBackground(wx.Brush(self.GetBackgroundColour(), wx.SOLID))
dc.Clear()
dc.DestroyClippingRegion()
else:
event.Skip()
def addColumn(self, i, col):
self.activeColumns.append(col)
info = wx.ListItem()
@@ -170,7 +209,6 @@ class Display(wx.ListCtrl):
self.SetItemData(item, id)
# self.Freeze()
if 'wxMSW' in wx.PlatformInfo:
for i,col in enumerate(self.activeColumns):