Add API to create wxGraphicsContext from win32 HDC
Add wxGraphicsContext::CreateFromNativeHDC() and wxGraphicsRenderer:: CreateContextFromNativeHDC() to allow creation not only from native renderer object, but also from HDC, which is something universally supported by win32 implementations.
This commit is contained in:
parent
e99abe513a
commit
e71be91ebe
@ -445,6 +445,10 @@ public:
|
||||
|
||||
static wxGraphicsContext* CreateFromNativeWindow( void * window );
|
||||
|
||||
#ifdef __WXMSW__
|
||||
static wxGraphicsContext* CreateFromNativeHDC(WXHDC dc);
|
||||
#endif
|
||||
|
||||
static wxGraphicsContext* Create( wxWindow* window );
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
@ -830,6 +834,10 @@ public:
|
||||
|
||||
virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) = 0;
|
||||
|
||||
#ifdef __WXMSW__
|
||||
virtual wxGraphicsContext * CreateContextFromNativeHDC(WXHDC dc) = 0;
|
||||
#endif
|
||||
|
||||
virtual wxGraphicsContext * CreateContext( wxWindow* window ) = 0;
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
|
@ -482,6 +482,15 @@ public:
|
||||
*/
|
||||
static wxGraphicsContext* CreateFromNativeWindow(void* window);
|
||||
|
||||
/**
|
||||
Creates a wxGraphicsContext from a native DC handle. Windows only.
|
||||
|
||||
@see wxGraphicsRenderer::CreateContextFromNativeHDC()
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
static wxGraphicsContext* CreateFromNativeHDC(WXHDC dc);
|
||||
|
||||
/**
|
||||
Create a lightweight context that can be used only for measuring text.
|
||||
*/
|
||||
@ -1321,6 +1330,13 @@ public:
|
||||
*/
|
||||
virtual wxGraphicsContext* CreateContextFromNativeWindow(void* window) = 0;
|
||||
|
||||
/**
|
||||
Creates a wxGraphicsContext from a native DC handle. Windows only.
|
||||
|
||||
@since 3.1.1
|
||||
*/
|
||||
static wxGraphicsContext* CreateContextFromNativeHDC(WXHDC dc);
|
||||
|
||||
/**
|
||||
Creates a wxGraphicsContext that can be used for measuring texts only.
|
||||
No drawing commands are allowed.
|
||||
|
@ -961,6 +961,13 @@ wxGraphicsContext* wxGraphicsContext::CreateFromNativeWindow( void * window )
|
||||
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeWindow(window);
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxGraphicsContext* wxGraphicsContext::CreateFromNativeHDC(WXHDC dc)
|
||||
{
|
||||
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeHDC(dc);
|
||||
}
|
||||
#endif
|
||||
|
||||
wxGraphicsContext* wxGraphicsContext::Create( wxWindow* window )
|
||||
{
|
||||
return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext(window);
|
||||
|
@ -2823,6 +2823,11 @@ public :
|
||||
virtual wxGraphicsContext * CreateContextFromNativeContext( void * context ) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) wxOVERRIDE;
|
||||
|
||||
#ifdef __WXMSW__
|
||||
virtual wxGraphicsContext * CreateContextFromNativeHDC(WXHDC dc) wxOVERRIDE;
|
||||
#endif
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
virtual wxGraphicsContext * CreateContextFromImage(wxImage& image) wxOVERRIDE;
|
||||
#endif // wxUSE_IMAGE
|
||||
@ -2961,6 +2966,14 @@ wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeWindow( void * windo
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __WXMSW__
|
||||
wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeHDC(WXHDC dc)
|
||||
{
|
||||
ENSURE_LOADED_OR_RETURN(NULL);
|
||||
return new wxCairoContext(this, (HDC)dc);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
wxGraphicsContext * wxCairoRenderer::CreateContextFromImage(wxImage& image)
|
||||
{
|
||||
|
@ -553,6 +553,8 @@ public :
|
||||
|
||||
virtual wxGraphicsContext * CreateContextFromNativeWindow( void * window ) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsContext * CreateContextFromNativeHDC(WXHDC dc) wxOVERRIDE;
|
||||
|
||||
virtual wxGraphicsContext * CreateContext( wxWindow* window ) wxOVERRIDE;
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
@ -2409,6 +2411,12 @@ wxGraphicsContext * wxGDIPlusRenderer::CreateContextFromNativeWindow( void * win
|
||||
return new wxGDIPlusContext(this,(HWND) window);
|
||||
}
|
||||
|
||||
wxGraphicsContext * wxGDIPlusRenderer::CreateContextFromNativeHDC(WXHDC dc)
|
||||
{
|
||||
ENSURE_LOADED_OR_RETURN(NULL);
|
||||
return new wxGDIPlusContext(this, new Graphics((HDC)dc));
|
||||
}
|
||||
|
||||
wxGraphicsContext * wxGDIPlusRenderer::CreateContext( wxWindow* window )
|
||||
{
|
||||
ENSURE_LOADED_OR_RETURN(NULL);
|
||||
|
@ -4346,6 +4346,8 @@ public :
|
||||
|
||||
wxGraphicsContext* CreateContextFromNativeWindow(void* window) wxOVERRIDE;
|
||||
|
||||
wxGraphicsContext * CreateContextFromNativeHDC(WXHDC dc) wxOVERRIDE;
|
||||
|
||||
wxGraphicsContext* CreateContext(wxWindow* window) wxOVERRIDE;
|
||||
|
||||
#if wxUSE_IMAGE
|
||||
@ -4486,6 +4488,11 @@ wxGraphicsContext* wxD2DRenderer::CreateContextFromNativeWindow(void* window)
|
||||
return new wxD2DContext(this, m_direct2dFactory, (HWND)window);
|
||||
}
|
||||
|
||||
wxGraphicsContext* wxD2DRenderer::CreateContextFromNativeHDC(WXHDC dc)
|
||||
{
|
||||
return new wxD2DContext(this, m_direct2dFactory, (HDC)dc, wxSize(0, 0));
|
||||
}
|
||||
|
||||
wxGraphicsContext* wxD2DRenderer::CreateContext(wxWindow* window)
|
||||
{
|
||||
return new wxD2DContext(this, m_direct2dFactory, (HWND)window->GetHWND());
|
||||
|
Loading…
Reference in New Issue
Block a user