Permalink
Browse files

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.
  • Loading branch information...
1 parent e5b5049 commit 0649b0d028abeb0a8ea82c55ec3e19825356c278 @a-wi a-wi committed Jan 11, 2017
Showing with 1 addition and 19 deletions.
  1. +1 −19 samples/printing/printing.cpp
@@ -217,25 +217,7 @@ void MyApp::Draw(wxDC&dc)
dc.DrawBitmap( m_bitmap, 10, 10 );
#if wxUSE_GRAPHICS_CONTEXT
- wxGraphicsContext *gc = NULL;
-
- 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
+ wxGraphicsContext *gc = wxGraphicsContext::CreateFromUnknownDC(dc);
if (gc)
{

0 comments on commit 0649b0d

Please sign in to comment.