]> git.saurik.com Git - wxWidgets.git/blobdiff - src/msw/bmpbuttn.cpp
added wxLog::Suspend/Resume and wxYield() uses them now so that it won't flush
[wxWidgets.git] / src / msw / bmpbuttn.cpp
index ad9eecda975bca463a7b71ade7377f8ff9b1c1b3..4eb6795442050f5075905861c0f7980117cb4fd7 100644 (file)
 
 #ifndef WX_PRECOMP
     #include "wx/bmpbuttn.h"
+    #include "wx/log.h"
 #endif
 
 #include "wx/msw/private.h"
 
-#if !USE_SHARED_LIBRARY
 IMPLEMENT_DYNAMIC_CLASS(wxBitmapButton, wxButton)
-#endif
 
 #define BUTTON_HEIGHT_FACTOR (EDIT_CONTROL_FACTOR * 1.1)
 
@@ -40,7 +39,10 @@ bool wxBitmapButton::Create(wxWindow *parent, wxWindowID id, const wxBitmap& bit
 {
   m_buttonBitmap = bitmap;
   SetName(name);
+
+#if wxUSE_VALIDATORS
   SetValidator(validator);
+#endif // wxUSE_VALIDATORS
 
   parent->AddChild(this);
 
@@ -173,21 +175,40 @@ bool wxBitmapButton::MSWOnDraw(WXDRAWITEMSTRUCT *item)
     }
 
     BOOL ok;
+
+    // no MaskBlt() under Win16
+#ifdef __WIN32__
     wxMask *mask = bitmap->GetMask();
     if ( mask )
     {
         // the fg ROP is applied for the pixels of the mask bitmap which are 1
         // (for a wxMask this means that this is a non transparent pixel), the
         // bg ROP is applied for all the others
+
+        HBRUSH hbrBackground =
+            ::CreateSolidBrush(wxColourToRGB(GetBackgroundColour()));
+        HBRUSH hbrOld = (HBRUSH)::SelectObject(hDC, hbrBackground);
+
         ok = ::MaskBlt(
                        hDC, x1, y1, wBmp, hBmp,                 // dst
                        memDC, 0, 0,                             // src
                        (HBITMAP)mask->GetMaskBitmap(), 0, 0,    // mask
                        MAKEROP4(SRCCOPY,                        // fg ROP
-                                SRCPAINT)                       // bg ROP
+                                PATCOPY)                        // bg ROP
                       );
+
+        ::SelectObject(hDC, hbrOld);
+        ::DeleteObject(hbrBackground);
     }
     else
+    {
+        // this will make the check below fail and BitBlt() will be used if
+        // MaskBlt() is not supported (for example, under Win95)
+        ok = FALSE;
+    }
+
+    if ( !ok )
+#endif // Win32
     {
         ok = ::BitBlt(hDC, x1, y1, wBmp, hBmp,  // dst
                       memDC, 0, 0,              // src