Replaced GraphicsHDC from src/msw/renderer.cpp with wxDC::GetTempHDC().

wxDC::GetTempHDC() method provides a convenient and safe way to retrieve HDC
from a wxDC object, whether it is using GDI or GDI+. It is implemented using
(MSW-specific) virtual functions in wxDC and so doesn't need ugly hacks like
wxDynamicCast which were used in src/msw/renderer.cpp to achieve the same
effect.

Also, we now use GetTempHDC() consistently in all wxMSW rendering methods as
the old GraphicsHDC was only used in some of them meaning that many methods
didn't work at all with wxGCDC.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@62294 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2009-10-05 22:56:58 +00:00
parent 6c9aaf7d0c
commit 942d5e2d72
4 changed files with 87 additions and 62 deletions

View File

@@ -40,6 +40,7 @@
#include "wx/private/graphics.h"
#include "wx/msw/wrapgdip.h"
#include "wx/msw/dc.h"
#include "wx/dcgraph.h"
#include "wx/stack.h"
@@ -1850,4 +1851,32 @@ private:
IMPLEMENT_DYNAMIC_CLASS(wxGDIPlusRendererModule, wxModule)
// ----------------------------------------------------------------------------
// wxMSW-specific parts of wxGCDC
// ----------------------------------------------------------------------------
WXHDC wxGCDC::AcquireHDC()
{
wxGraphicsContext * const gc = GetGraphicsContext();
if ( !gc )
return NULL;
Graphics * const g = static_cast<Graphics *>(gc->GetNativeContext());
return g ? g->GetHDC() : NULL;
}
void wxGCDC::ReleaseHDC(WXHDC hdc)
{
if ( !hdc )
return;
wxGraphicsContext * const gc = GetGraphicsContext();
wxCHECK_RET( gc, "can't release HDC because there is no wxGraphicsContext" );
Graphics * const g = static_cast<Graphics *>(gc->GetNativeContext());
wxCHECK_RET( g, "can't release HDC because there is no Graphics" );
g->ReleaseHDC((HDC)hdc);
}
#endif // wxUSE_GRAPHICS_CONTEXT