Use wxGraphicsContext::CreateFromUnknownDC in the printing sample
Creating graphics context for the various flavors of wxDC can be simplified by using this newly introduced API.
This commit is contained in:
@@ -217,25 +217,7 @@ void MyApp::Draw(wxDC&dc)
|
|||||||
dc.DrawBitmap( m_bitmap, 10, 10 );
|
dc.DrawBitmap( m_bitmap, 10, 10 );
|
||||||
|
|
||||||
#if wxUSE_GRAPHICS_CONTEXT
|
#if wxUSE_GRAPHICS_CONTEXT
|
||||||
wxGraphicsContext *gc = NULL;
|
wxGraphicsContext *gc = wxGraphicsContext::CreateFromUnknownDC(dc);
|
||||||
|
|
||||||
wxPrinterDC *printer_dc = wxDynamicCast( &dc, wxPrinterDC );
|
|
||||||
if (printer_dc)
|
|
||||||
gc = wxGraphicsContext::Create( *printer_dc );
|
|
||||||
|
|
||||||
wxWindowDC *window_dc = wxDynamicCast( &dc, wxWindowDC );
|
|
||||||
if (window_dc)
|
|
||||||
gc = wxGraphicsContext::Create( *window_dc );
|
|
||||||
|
|
||||||
wxMemoryDC *memory_dc = wxDynamicCast( &dc, wxMemoryDC );
|
|
||||||
if (memory_dc)
|
|
||||||
gc = wxGraphicsContext::Create( *memory_dc );
|
|
||||||
|
|
||||||
#ifdef __WXMSW__
|
|
||||||
wxEnhMetaFileDC *emf_dc = wxDynamicCast( &dc, wxEnhMetaFileDC );
|
|
||||||
if (emf_dc)
|
|
||||||
gc = wxGraphicsContext::Create( *emf_dc );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
if (gc)
|
if (gc)
|
||||||
{
|
{
|
||||||
|
Reference in New Issue
Block a user