Merge branch 'gc-from-unknown-dc'
Add wxGraphicsRenderer::CreateContextFromUnknownDC(). See https://github.com/wxWidgets/wxWidgets/pull/1213
This commit is contained in:
@@ -876,6 +876,8 @@ public:
|
||||
#endif
|
||||
#endif
|
||||
|
||||
wxGraphicsContext* CreateContextFromUnknownDC(const wxDC& dc);
|
||||
|
||||
virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) = 0;
|
||||
|
||||
virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) = 0;
|
||||
|
@@ -456,6 +456,8 @@ public:
|
||||
with wxDC and doesn't known its exact type. Use Create() instead if
|
||||
you know that the DC is e.g. wxWindowDC.
|
||||
|
||||
@see wxGraphicsRenderer::CreateContextFromUnknownDC()
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
static wxGraphicsContext* CreateFromUnknownDC(wxDC& dc);
|
||||
@@ -1341,6 +1343,24 @@ public:
|
||||
*/
|
||||
virtual wxGraphicsContext* CreateContext(const wxEnhMetaFileDC& metaFileDC) = 0;
|
||||
|
||||
/**
|
||||
Creates a wxGraphicsContext from a DC of unknown specific type.
|
||||
|
||||
Creates a wxGraphicsContext if @a dc is a supported type (i.e. has a
|
||||
corresponding CreateContext() method, e.g. wxWindowDC or wxMemoryDC).
|
||||
Returns @NULL if the DC is unsupported.
|
||||
|
||||
This method is only useful as a helper in generic code that operates
|
||||
with wxDC and doesn't known its exact type. Use the appropriate
|
||||
CreateContext() overload instead if you know that the DC is e.g.
|
||||
wxWindowDC.
|
||||
|
||||
@see wxGraphicsContext::CreateFromUnknownDC()
|
||||
|
||||
@since 3.1.3
|
||||
*/
|
||||
static wxGraphicsContext* CreateContextFromUnknownDC(wxDC& dc);
|
||||
|
||||
/**
|
||||
Creates a wxGraphicsContext associated with a wxImage.
|
||||
|
||||
|
@@ -989,45 +989,7 @@ wxGraphicsBitmap wxGraphicsContext::CreateSubBitmap( const wxGraphicsBitmap &bmp
|
||||
|
||||
wxGraphicsContext* wxGraphicsContext::CreateFromUnknownDC(const wxDC& dc)
|
||||
{
|
||||
#ifndef wxNO_RTTI
|
||||
if ( const wxWindowDC *windc = dynamic_cast<const wxWindowDC*>(&dc) )
|
||||
return Create(*windc);
|
||||
|
||||
if ( const wxMemoryDC *memdc = dynamic_cast<const wxMemoryDC*>(&dc) )
|
||||
return Create(*memdc);
|
||||
|
||||
#if wxUSE_PRINTING_ARCHITECTURE
|
||||
if ( const wxPrinterDC *printdc = dynamic_cast<const wxPrinterDC*>(&dc) )
|
||||
return Create(*printdc);
|
||||
#endif
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#if wxUSE_ENH_METAFILE
|
||||
if ( const wxEnhMetaFileDC *mfdc = dynamic_cast<const wxEnhMetaFileDC*>(&dc) )
|
||||
return Create(*mfdc);
|
||||
#endif
|
||||
#endif
|
||||
#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;
|
||||
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromUnknownDC(dc);
|
||||
}
|
||||
|
||||
wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
|
||||
@@ -1070,4 +1032,27 @@ wxGraphicsContext* wxGraphicsContext::Create()
|
||||
|
||||
wxIMPLEMENT_ABSTRACT_CLASS(wxGraphicsRenderer, wxObject);
|
||||
|
||||
wxGraphicsContext* wxGraphicsRenderer::CreateContextFromUnknownDC(const wxDC& dc)
|
||||
{
|
||||
if ( const wxWindowDC *windc = wxDynamicCast(&dc, wxWindowDC) )
|
||||
return CreateContext(*windc);
|
||||
|
||||
if ( const wxMemoryDC *memdc = wxDynamicCast(&dc, wxMemoryDC) )
|
||||
return CreateContext(*memdc);
|
||||
|
||||
#if wxUSE_PRINTING_ARCHITECTURE
|
||||
if ( const wxPrinterDC *printdc = wxDynamicCast(&dc, wxPrinterDC) )
|
||||
return CreateContext(*printdc);
|
||||
#endif
|
||||
|
||||
#ifdef __WXMSW__
|
||||
#if wxUSE_ENH_METAFILE
|
||||
if ( const wxEnhMetaFileDC *mfdc = wxDynamicCast(&dc, wxEnhMetaFileDC) )
|
||||
return CreateContext(*mfdc);
|
||||
#endif
|
||||
#endif
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
#endif // wxUSE_GRAPHICS_CONTEXT
|
||||
|
Reference in New Issue
Block a user