]> git.saurik.com Git - wxWidgets.git/commitdiff
added AutoHPEN, AutoHBRUSH, AutoHBITMAP; refactored CompatibleBitmap into the last...
authorVadim Zeitlin <vadim@wxwidgets.org>
Sun, 22 May 2005 13:59:45 +0000 (13:59 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Sun, 22 May 2005 13:59:45 +0000 (13:59 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34245 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/private.h

index be6d9305ad336b3a36ea3be24ed151d31044dd7b..f015082b7e37a9bf7605a0a93a3b4ef2da4fb75a 100644 (file)
@@ -440,16 +440,53 @@ private:
     HGDIOBJ m_gdiobj;
 };
 
-// a class for temporary bitmaps
-class CompatibleBitmap : private AutoGDIObject
+// TODO: all this asks for using a AutoHandler<T, CreateFunc> template...
+
+// a class for temporary pens
+class AutoHBRUSH : private AutoGDIObject
+{
+public:
+    AutoHBRUSH(COLORREF col)
+        : AutoGDIObject(::CreateSolidBrush(col)) { }
+
+    operator HBRUSH() const { return (HBRUSH)GetObject(); }
+};
+
+// a class for temporary pens
+class AutoHPEN : private AutoGDIObject
+{
+public:
+    AutoHPEN(COLORREF col)
+        : AutoGDIObject(::CreatePen(PS_SOLID, 0, col)) { }
+
+    operator HPEN() const { return (HPEN)GetObject(); }
+};
+
+// classes for temporary bitmaps
+class AutoHBITMAP : private AutoGDIObject
+{
+public:
+    AutoHBITMAP(HBITMAP hbmp) : AutoGDIObject(hbmp) { }
+
+    operator HBITMAP() const { return (HBITMAP)GetObject(); }
+};
+
+class CompatibleBitmap : public AutoHBITMAP
 {
 public:
     CompatibleBitmap(HDC hdc, int w, int h)
-        : AutoGDIObject(::CreateCompatibleBitmap(hdc, w, h))
+        : AutoHBITMAP(::CreateCompatibleBitmap(hdc, w, h))
     {
     }
+};
 
-    operator HBITMAP() const { return (HBITMAP)GetObject(); }
+class MonoBitmap : public AutoHBITMAP
+{
+public:
+    MonoBitmap(int w, int h)
+        : AutoHBITMAP(::CreateBitmap(w, h, 1, 1, 0))
+    {
+    }
 };
 
 // class automatically destroys the region object