Implemented cached imagelist in marketbrowser

This commit is contained in:
HomeWorld
2010-10-05 21:28:12 +03:00
parent 334db896ca
commit aab6797212
2 changed files with 17 additions and 20 deletions

View File

@@ -21,14 +21,19 @@ import wx
import bitmapLoader
class CachingImageList(wx.ImageList):
def __init__(self):
def __init__(self, width, height):
wx.ImageList.__init__(self, width, height)
self.map = {}
def Add(self, *loaderArgs):
id = self.map.get(loaderArgs)
if id is None:
key = "".join(loaderArgs)
if key not in self.map:
bitmap = bitmapLoader.getBitmap(*loaderArgs)
id = wx.ImageList.Add(bitmap)
self.map[loaderArgs] = id
if bitmap is None:
return -1
id = wx.ImageList.Add(self,bitmap)
self.map[key] = id
else:
id = self.map[key]
return id