45 for folder in BitmapFolders: |
45 for folder in BitmapFolders: |
46 bmp_path = os.path.join(folder, bmp_name + ".png") |
46 bmp_path = os.path.join(folder, bmp_name + ".png") |
47 if os.path.isfile(bmp_path): |
47 if os.path.isfile(bmp_path): |
48 return wx.Bitmap(bmp_path) |
48 return wx.Bitmap(bmp_path) |
49 return None |
49 return None |
50 |
50 |
51 def GetBitmap(bmp_name1, bmp_name2=None, size=None): |
51 def GetBitmap(bmp_name1, bmp_name2=None, size=None): |
52 bmp = BitmapLibrary.get((bmp_name1, bmp_name2, size)) |
52 bmp = BitmapLibrary.get((bmp_name1, bmp_name2, size)) |
53 if bmp is not None: |
53 if bmp is not None: |
54 return bmp |
54 return bmp |
55 |
55 |
56 if bmp_name2 is None: |
56 if bmp_name2 is None: |
57 bmp = SearchBitmap(bmp_name1) |
57 bmp = SearchBitmap(bmp_name1) |
58 else: |
58 else: |
59 # Bitmap with two icon |
59 # Bitmap with two icon |
60 bmp1 = SearchBitmap(bmp_name1) |
60 bmp1 = SearchBitmap(bmp_name1) |
61 bmp2 = SearchBitmap(bmp_name2) |
61 bmp2 = SearchBitmap(bmp_name2) |
62 |
62 |
63 if bmp1 is not None and bmp2 is not None: |
63 if bmp1 is not None and bmp2 is not None: |
64 # Calculate bitmap size |
64 # Calculate bitmap size |
65 width = bmp1.GetWidth() + bmp2.GetWidth() - 1 |
65 width = bmp1.GetWidth() + bmp2.GetWidth() - 1 |
66 height = max(bmp1.GetHeight(), bmp2.GetHeight()) |
66 height = max(bmp1.GetHeight(), bmp2.GetHeight()) |
67 |
67 |
68 # Create bitmap with both icons |
68 # Create bitmap with both icons |
69 bmp = wx.EmptyBitmap(width, height) |
69 bmp = wx.EmptyBitmap(width, height) |
70 dc = wx.MemoryDC() |
70 dc = wx.MemoryDC() |
71 dc.SelectObject(bmp) |
71 dc.SelectObject(bmp) |
72 dc.Clear() |
72 dc.Clear() |
73 dc.DrawBitmap(bmp1, 0, 0) |
73 dc.DrawBitmap(bmp1, 0, 0) |
74 dc.DrawBitmap(bmp2, bmp1.GetWidth() - 1, 0) |
74 dc.DrawBitmap(bmp2, bmp1.GetWidth() - 1, 0) |
75 dc.Destroy() |
75 dc.Destroy() |
76 |
76 |
77 elif bmp1 is not None: |
77 elif bmp1 is not None: |
78 bmp = bmp1 |
78 bmp = bmp1 |
79 elif bmp2 is not None: |
79 elif bmp2 is not None: |
80 bmp = bmp2 |
80 bmp = bmp2 |
81 |
81 |
82 if bmp is not None: |
82 if bmp is not None: |
83 BitmapLibrary[(bmp_name1, bmp_name2, size)] = bmp |
83 BitmapLibrary[(bmp_name1, bmp_name2, size)] = bmp |
84 |
84 |
85 return bmp |
85 return bmp |