Add wxGraphicsContext::CreateFromUnknownDC()
A convenience helper for writing generic code that may operate on different kinds of DCs, all supported by wxGraphicsContext, but without knowing its specific type.
This commit is contained in:
parent
6615c06d31
commit
7833c65c2a
@ -70,6 +70,7 @@ enum wxCompositionMode
|
|||||||
wxCOMPOSITION_ADD /* R = S + D */
|
wxCOMPOSITION_ADD /* R = S + D */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class WXDLLIMPEXP_FWD_CORE wxDC;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxWindowDC;
|
class WXDLLIMPEXP_FWD_CORE wxWindowDC;
|
||||||
class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
|
class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
|
||||||
#if wxUSE_PRINTING_ARCHITECTURE
|
#if wxUSE_PRINTING_ARCHITECTURE
|
||||||
@ -437,6 +438,11 @@ public:
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef wxNO_RTTI
|
||||||
|
// Create a context from a DC of unknown type, if supported, returns NULL otherwise
|
||||||
|
static wxGraphicsContext* CreateFromUnknownDC(const wxDC& dc);
|
||||||
|
#endif
|
||||||
|
|
||||||
static wxGraphicsContext* CreateFromNative( void * context );
|
static wxGraphicsContext* CreateFromNative( void * context );
|
||||||
|
|
||||||
static wxGraphicsContext* CreateFromNativeWindow( void * window );
|
static wxGraphicsContext* CreateFromNativeWindow( void * window );
|
||||||
|
@ -438,6 +438,21 @@ public:
|
|||||||
*/
|
*/
|
||||||
static wxGraphicsContext* Create(const wxEnhMetaFileDC& metaFileDC);
|
static wxGraphicsContext* Create(const wxEnhMetaFileDC& metaFileDC);
|
||||||
|
|
||||||
|
/**
|
||||||
|
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 Create() 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 Create() instead if
|
||||||
|
you know that the DC is e.g. wxWindowDC.
|
||||||
|
|
||||||
|
@since 3.1.1
|
||||||
|
*/
|
||||||
|
static wxGraphicsContext* CreateFromUnknownDC(wxDC& dc);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Creates a wxGraphicsContext associated with a wxImage.
|
Creates a wxGraphicsContext associated with a wxImage.
|
||||||
|
|
||||||
|
@ -22,12 +22,18 @@
|
|||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include "wx/icon.h"
|
#include "wx/icon.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
#include "wx/dcclient.h"
|
||||||
#include "wx/dcmemory.h"
|
#include "wx/dcmemory.h"
|
||||||
|
#include "wx/dcprint.h"
|
||||||
#include "wx/math.h"
|
#include "wx/math.h"
|
||||||
#include "wx/region.h"
|
#include "wx/region.h"
|
||||||
#include "wx/log.h"
|
#include "wx/log.h"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef __WXMSW__
|
||||||
|
#include "wx/msw/enhmeta.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
#include "wx/private/graphics.h"
|
#include "wx/private/graphics.h"
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
@ -920,6 +926,31 @@ wxGraphicsBitmap wxGraphicsContext::CreateSubBitmap( const wxGraphicsBitmap &bmp
|
|||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifndef wxNO_RTTI
|
||||||
|
wxGraphicsContext* wxGraphicsContext::CreateFromUnknownDC(const wxDC& dc)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
|
wxGraphicsContext* wxGraphicsContext::CreateFromNative( void * context )
|
||||||
{
|
{
|
||||||
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeContext(context);
|
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeContext(context);
|
||||||
|
Loading…
Reference in New Issue
Block a user