Bug with TabsImageList wrong image size definition fixed
authorlaurent
Tue, 01 Sep 2009 10:30:48 +0200
changeset 401 d3f086b0da30
parent 400 12b55d82d363
child 402 281fd35e7a7b
Bug with TabsImageList wrong image size definition fixed
PLCOpenEditor.py
--- a/PLCOpenEditor.py	Thu Aug 27 18:29:46 2009 +0200
+++ b/PLCOpenEditor.py	Tue Sep 01 10:30:48 2009 +0200
@@ -283,6 +283,7 @@
             self.ShowErrorMessage(_("\"%s\" is used by one or more POUs. It can't be removed!")%name)
     return DeleteElementFunction
 
+
 #-------------------------------------------------------------------------------
 #                            PLCOpenEditor Main Class
 #-------------------------------------------------------------------------------
@@ -545,7 +546,7 @@
                   pos=wx.Point(0, 0), size=wx.Size(0, 0),
                   style=wx.TR_HAS_BUTTONS|wx.TR_SINGLE|wx.SUNKEN_BORDER)
         
-        self.TabsImageList = wx.ImageList(16, 31)
+        self.TabsImageList = wx.ImageList(31, 16)
         self.TabsImageListIndexes = {}
         
         if self.Debug:
@@ -892,28 +893,30 @@
                 return index
         if icon2_name is None:
             # Bitmap with only one icon
-            tmp_bitmap = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name))
+            bitmap = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name))
         else:
             # Bitmap with two icon
             icon1 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon1_name))
             icon2 = wx.Bitmap(os.path.join(CWD, 'Images', '%s.png'%icon2_name))
+            
             # Calculate bitmap size
             width = icon1.GetWidth() + icon2.GetWidth() - 1
             height = max(icon1.GetHeight(), icon2.GetHeight())
             # Create bitmap with both icons
-            tmp_bitmap = wx.EmptyBitmap(width, height)
+            bitmap = wx.EmptyBitmap(width, height)
             dc = wx.MemoryDC()
-            dc.SelectObject(tmp_bitmap)
+            dc.SelectObject(bitmap)
             dc.Clear()
             dc.DrawBitmap(icon1, 0, 0)
             dc.DrawBitmap(icon2, icon1.GetWidth() - 1, 0)
-        if wx.Platform != '__WXMSW__':
+            dc.Destroy()
+            
             # Store bitmap in ImageList
-            index = self.TabsImageList.Add(tmp_bitmap)
+            index = self.TabsImageList.Add(bitmap)
             # Save bitmap index in ImageList in dictionary
             self.TabsImageListIndexes[(icon1_name, icon2_name)] = index
         if USE_AUI:
-            return tmp_bitmap
+            return bitmap
         else:
             return index