]> git.saurik.com Git - wxWidgets.git/blobdiff - src/motif/utils.cpp
Fix for the fact that unmapped but managed widgets
[wxWidgets.git] / src / motif / utils.cpp
index b9ddd16c515b743df59b7a90edc7cb39c58c8d4f..56c48759cb6e4714a7e0145949b772487a6a918d 100644 (file)
@@ -25,7 +25,8 @@
 #include "wx/app.h"
 #include "wx/msgdlg.h"
 #include "wx/cursor.h"
-#include "wx/window.h" // for wxTopLevelWindows
+#include "wx/dcmemory.h"
+#include "wx/bitmap.h"
 
 #include <ctype.h>
 #include <stdarg.h>
@@ -1235,3 +1236,30 @@ XmString wxStringToXmString( const char* str )
 {
     return XmStringCreateLtoR((char *)str, XmSTRING_DEFAULT_CHARSET);
 }
+
+// ----------------------------------------------------------------------------
+// wxBitmap utility functions
+// ----------------------------------------------------------------------------
+
+// Creates a bitmap with transparent areas drawn in
+// the given colour.
+wxBitmap wxCreateMaskedBitmap(const wxBitmap& bitmap, wxColour& colour)
+{
+    wxBitmap newBitmap(bitmap.GetWidth(),
+                       bitmap.GetHeight(),
+                       bitmap.GetDepth());
+    wxMemoryDC destDC;
+    wxMemoryDC srcDC;
+
+    srcDC.SelectObject(bitmap);
+    destDC.SelectObject(newBitmap);
+
+    wxBrush brush(colour, wxSOLID);
+    // destDC.SetOptimization(FALSE);
+    destDC.SetBackground(brush);
+    destDC.Clear();
+    destDC.Blit(0, 0, bitmap.GetWidth(), bitmap.GetHeight(),
+                &srcDC, 0, 0, wxCOPY, TRUE);
+
+    return newBitmap;
+}