]> git.saurik.com Git - wxWidgets.git/commitdiff
support for alpha channel in toolbars (patch 949843)
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Jul 2004 12:59:32 +0000 (12:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 25 Jul 2004 12:59:32 +0000 (12:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@28466 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

docs/changes.txt
docs/latex/wx/toolbar.tex
src/msw/tbar95.cpp

index 3a5d5ca425e58735570bdea890095bd015124d39..46db979514fa1e721d071504b2c4d7c4569bee1d 100644 (file)
@@ -252,6 +252,7 @@ wxMSW:
 
 - fixed UNC paths handling in wxFileSystem (Daniel Nash)
 - set wxKeyEvent::m_uniChar in Unicode build
+- support for alpha channel in toolbar bitmaps (Jurgen Doornik)
 
 wxWinCE:
 
index 94f6b18bade0c5c40f46c411c66de0e41b367796..9555daa36ec5d87b2fc1ec83361151e8b0fcb3d7 100644 (file)
@@ -51,6 +51,20 @@ before creating the toolbar:
   wxSystemOptions::SetOption(wxT("msw.remap"), 0);
 \end{verbatim}
 
+If you wish to use 32-bit images (which include an alpha channel for transparency)
+use:
+
+\begin{verbatim}
+  wxSystemOptions::SetOption(wxT("msw.remap"), 2);
+\end{verbatim}
+
+then colour remapping is switched of, and a transparent background used. But only
+use this option under Windows XP with true colour:
+
+\begin{verbatim}
+  (wxTheApp->GetComCtl32Version() >= 600 && ::wxDisplayDepth() >= 32)
+\end{verbatim}
+
 \wxheading{Window styles}
 
 \twocolwidtha{5cm}
index de0cc3ffaa02dc0f4ca9b7b488edbeb6a4b92b45..83fcc8a1e6c8818684fe2ab79ad44252ffe20872 100644 (file)
@@ -481,6 +481,19 @@ bool wxToolBar::Realize()
 
     const bool isVertical = HasFlag(wxTB_VERTICAL);
 
+    bool doRemap, doRemapBg, doTransparent;
+    if (wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 2)
+    {
+        doRemapBg = doRemap = false;
+        doTransparent = true;       
+    }
+    else
+    {   doRemap = !wxSystemOptions::HasOption(wxT("msw.remap"))
+            || wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 1;
+        doRemapBg = !doRemap;
+        doTransparent = false;
+    }
+
     // delete all old buttons, if any
     for ( size_t pos = 0; pos < m_nButtons; pos++ )
     {
@@ -520,6 +533,9 @@ bool wxToolBar::Realize()
         wxMemoryDC dcAllButtons;
         wxBitmap bitmap(totalBitmapWidth, totalBitmapHeight);
         dcAllButtons.SelectObject(bitmap);
+        if (doTransparent)
+            dcAllButtons.SetBackground(*wxTRANSPARENT_BRUSH);
+        else
         dcAllButtons.SetBackground(*wxLIGHT_GREY_BRUSH);
         dcAllButtons.Clear();
 
@@ -544,7 +560,7 @@ bool wxToolBar::Realize()
         MemoryHDC memoryDC2;
 #endif // USE_BITMAP_MASKS/!USE_BITMAP_MASKS
 
-        if (wxSystemOptions::HasOption(wxT("msw.remap")) && wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 0)
+        if (doRemapBg)
         {
 #if USE_BITMAP_MASKS
             dcAllButtons.SelectObject(wxNullBitmap);
@@ -610,7 +626,7 @@ bool wxToolBar::Realize()
         bitmap.SetHBITMAP(0);
 #endif // USE_BITMAP_MASKS/!USE_BITMAP_MASKS
 
-        if (!wxSystemOptions::HasOption(wxT("msw.remap")) || wxSystemOptions::GetOptionInt(wxT("msw.remap")) == 1)
+        if (doRemap)
         {
             // Map to system colours
             hBitmap = (HBITMAP)MapBitmap((WXHBITMAP) hBitmap,