]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/tbar95.cpp
Applied patch [ 1310251 ] Fixed a pixel depth bug converting wxImageb to wxBitmap
[wxWidgets.git] / src / msw / tbar95.cpp
index 754543b9329671da41bb2608d9d81ca36ef8fac6..174a4630ee9ea1e85712d77f136d3778101cfff0 100644 (file)
@@ -509,6 +509,12 @@ bool wxToolBar::DoDeleteTool(size_t pos, wxToolBarToolBase *tool)
 
 void wxToolBar::CreateDisabledImageList()
 {
+    if (m_disabledImgList != NULL)
+    {
+        delete m_disabledImgList;
+        m_disabledImgList = NULL;
+    }
+
     // as we can't use disabled image list with older versions of comctl32.dll,
     // don't even bother creating it
     if ( wxTheApp->GetComCtl32Version() >= 470 )
@@ -528,14 +534,12 @@ void wxToolBar::CreateDisabledImageList()
                                             bmpDisabled.GetMask() != NULL,
                                             GetToolsCount()
                                         );
-                return;
+                break;
             }
         }
 
         // we don't have any disabled bitmaps
     }
-
-    m_disabledImgList = NULL;
 }
 
 bool wxToolBar::Realize()
@@ -550,21 +554,18 @@ bool wxToolBar::Realize()
     const bool isVertical = HasFlag(wxTB_VERTICAL);
 
     bool doRemap, doRemapBg, doTransparent;
-#ifdef __WXWINCE__
-    doRemapBg = false;
-    doRemap = false;
-    doTransparent = false;
-#else
-    if (wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 2)
+    doRemapBg = doRemap = doTransparent = false;
+
+#ifndef __WXWINCE__
+    int remapValue = (-1);
+    if (wxSystemOptions::HasOption(wxT("msw.remap")))
+        remapValue = wxSystemOptions::GetOptionInt(wxT("msw.remap"));
+
+    doTransparent = (remapValue == 2);
+    if (!doTransparent)
     {
-        doRemapBg = doRemap = false;
-        doTransparent = true;
-    }
-    else
-    {   doRemap = !wxSystemOptions::HasOption(wxT("msw.remap"))
-            || wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 1;
+        doRemap = (remapValue != 0);
         doRemapBg = !doRemap;
-        doTransparent = false;
     }
 #endif
 
@@ -607,6 +608,7 @@ bool wxToolBar::Realize()
         wxMemoryDC dcAllButtons;
         wxBitmap bitmap(totalBitmapWidth, totalBitmapHeight);
         dcAllButtons.SelectObject(bitmap);
+
 #ifdef __WXWINCE__
         dcAllButtons.SetBackground(wxBrush(wxColour(192,192,192)));
 #else
@@ -631,8 +633,6 @@ bool wxToolBar::Realize()
                 totalBitmapWidth, totalBitmapHeight);
 
             dcAllButtons.SelectObject(bitmap);
-
-
         }
 #endif // !__WXWINCE__
 
@@ -679,17 +679,20 @@ bool wxToolBar::Realize()
                         wxImage imgGreyed;
                         wxCreateGreyedImage(bmp.ConvertToImage(), imgGreyed);
 
-                        // we need to have light grey background colour for
-                        // MapBitmap() to work correctly
-                        for ( int y = 0; y < h; y++ )
+                        if (doRemap)
                         {
-                            for ( int x = 0; x < w; x++ )
+                            // we need to have light grey background colour for
+                            // MapBitmap() to work correctly
+                            for ( int y = 0; y < h; y++ )
                             {
-                                if ( imgGreyed.IsTransparent(x, y) )
-                                    imgGreyed.SetRGB(x, y,
-                                                     wxLIGHT_GREY->Red(),
-                                                     wxLIGHT_GREY->Green(),
-                                                     wxLIGHT_GREY->Blue());
+                                for ( int x = 0; x < w; x++ )
+                                {
+                                    if ( imgGreyed.IsTransparent(x, y) )
+                                        imgGreyed.SetRGB(x, y,
+                                                         wxLIGHT_GREY->Red(),
+                                                         wxLIGHT_GREY->Green(),
+                                                         wxLIGHT_GREY->Blue());
+                                }
                             }
                         }
 
@@ -697,7 +700,10 @@ bool wxToolBar::Realize()
                     }
 #endif // wxUSE_IMAGE
 
-                    MapBitmap(bmpDisabled.GetHBITMAP(), w, h);
+                    if (doRemap)
+                    {
+                        MapBitmap(bmpDisabled.GetHBITMAP(), w, h);
+                    }
 
                     m_disabledImgList->Add(bmpDisabled);
                 }
@@ -720,8 +726,6 @@ bool wxToolBar::Realize()
             // Map to system colours
             hBitmap = (HBITMAP)MapBitmap((WXHBITMAP) hBitmap,
                 totalBitmapWidth, totalBitmapHeight);
-
-
         }
 
         bool addBitmap = true;
@@ -816,7 +820,6 @@ bool wxToolBar::Realize()
             continue;
         }
 
-
         TBBUTTON& button = buttons[i];
 
         wxZeroMemory(button);