From 566b7f7bbf7b48072d6f93e6bff90ac9cea78071 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Wed, 8 Feb 2006 14:00:34 +0000 Subject: [PATCH] added wxCHANGE_HDC_MAP_MODE to avoid #ifdef __WXWINCE__ everywhere git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@37385 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/msw/private.h | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/include/wx/msw/private.h b/include/wx/msw/private.h index 4fdca8a4d7..30aebc2836 100644 --- a/include/wx/msw/private.h +++ b/include/wx/msw/private.h @@ -519,6 +519,41 @@ private: 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 { -- 2.45.2