Permalink
Browse files

Make wxGraphicsContext::CreateFromUnknownDC() operational also when C…

…++ RTTI is not used

Use wxDynamicCast() to cast to the various wxDC types if wxNO_RTTI is defined.
  • Loading branch information...
1 parent 587067b commit e5b5049cc3d09477b906081a8eb92e5b429d5537 @a-wi a-wi committed Jan 11, 2017
Showing with 19 additions and 1 deletion.
  1. +19 −1 src/common/graphcmn.cpp
@@ -946,7 +946,25 @@ wxGraphicsContext* wxGraphicsContext::CreateFromUnknownDC(const wxDC& dc)
return Create(*mfdc);
#endif
#endif
-#endif // !wxNO_RTTI
+#else // wxNO_RTTI
+ if ( const wxWindowDC *windc = wxDynamicCast(&dc, wxWindowDC) )
+ return Create(*windc);
+
+ if ( const wxMemoryDC *memdc = wxDynamicCast(&dc, wxMemoryDC) )
+ return Create(*memdc);
+
+#if wxUSE_PRINTING_ARCHITECTURE
+ if ( const wxPrinterDC *printdc = wxDynamicCast(&dc, wxPrinterDC) )
+ return Create(*printdc);
+#endif
+
+#ifdef __WXMSW__
+#if wxUSE_ENH_METAFILE
+ if ( const wxEnhMetaFileDC *mfdc = wxDynamicCast(&dc, wxEnhMetaFileDC) )
+ return Create(*mfdc);
+#endif
+#endif
+#endif // !wxNO_RTTI/wxNO_RTTI
return NULL;
}

0 comments on commit e5b5049

Please sign in to comment.