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
This commit is contained in:
Vadim Zeitlin
2006-02-08 14:00:34 +00:00
parent 0699a648f6
commit 566b7f7bbf

View File

@@ -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
{