]> git.saurik.com Git - wxWidgets.git/commitdiff
added wxCHANGE_HDC_MAP_MODE to avoid #ifdef __WXWINCE__ everywhere
authorVadim Zeitlin <vadim@wxwidgets.org>
Wed, 8 Feb 2006 14:00:34 +0000 (14:00 +0000)
committerVadim Zeitlin <vadim@wxwidgets.org>
Wed, 8 Feb 2006 14:00:34 +0000 (14:00 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37385 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/msw/private.h

index 4fdca8a4d7157cc9f464b56ff3c1ed137d827563..30aebc2836e43762a6ef3000052bece8bf4422f2 100644 (file)
@@ -519,6 +519,41 @@ private:
     DECLARE_NO_COPY_CLASS(HDCClipper)
 };
 
     DECLARE_NO_COPY_CLASS(HDCClipper)
 };
 
+// set the given map mode for the life time of this object
+//
+// NB: SetMapMode() is not supported by CE so we also define a helper macro
+//     to avoid using it there
+#ifdef __WXWINCE__
+    #define wxCHANGE_HDC_MAP_MODE(hdc, mm)
+#else // !__WXWINCE__
+    class HDCMapModeChanger
+    {
+    public:
+        HDCMapModeChanger(HDC hdc, int mm)
+            : m_hdc(hdc)
+        {
+            m_modeOld = ::SetMapMode(hdc, mm);
+            if ( !m_modeOld )
+                wxLogLastError(_T("SelectClipRgn"));
+        }
+
+        ~HDCMapModeChanger()
+        {
+            if ( m_modeOld )
+                ::SetMapMode(m_hdc, m_modeOld);
+        }
+
+    private:
+        HDC m_hdc;
+        int m_modeOld;
+
+        DECLARE_NO_COPY_CLASS(HDCMapModeChanger)
+    };
+
+    #define wxCHANGE_HDC_MAP_MODE(hdc, mm) \
+        HDCMapModeChanger wxMAKE_UNIQUE_NAME(wxHDCMapModeChanger)(hdc, mm)
+#endif // __WXWINCE__/!__WXWINCE__
+
 // smart buffeer using GlobalAlloc/GlobalFree()
 class GlobalPtr
 {
 // smart buffeer using GlobalAlloc/GlobalFree()
 class GlobalPtr
 {