Allow creating wxGraphicsContext from cairo_t object (wxMSW).

Input void* parameter of wxCairoRenderer::CreateContextFromNativeContext can represent either DC handle or pointer to cairo_t object. It can be checked if it is a real HDC or not and proper wxCairoContext ctor can be invoked.

Closes #16991.
This commit is contained in:
Gilbert Pelletier
2016-03-14 20:53:18 +01:00
committed by Artur Wieczorek
parent c3a2994931
commit 46df3a1794

View File

@@ -1908,6 +1908,9 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, HDC handle )
wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context )
: wxGraphicsContext(renderer)
{
#ifdef __WXMSW__
m_mswSurface = NULL;
#endif // __WXMSW__
Init( context );
m_width =
m_height = 0;
@@ -2536,7 +2539,11 @@ wxGraphicsContext * wxCairoRenderer::CreateContextFromNativeContext( void * cont
{
ENSURE_LOADED_OR_RETURN(NULL);
#ifdef __WXMSW__
if (::GetObjectType((HGDIOBJ)context) == OBJ_DC)
{
return new wxCairoContext(this, (HDC)context);
}
return new wxCairoContext(this, (cairo_t*)context);
#else
return new wxCairoContext(this,(cairo_t*)context);
#endif