Implement getting/releasing HDC in Cairo wxGraphicsContext (wxMSW)

This commit is contained in:
Artur Wieczorek
2021-06-27 23:56:24 +02:00
parent dd7bcbd9eb
commit a3988c8db6
3 changed files with 20 additions and 13 deletions

View File

@@ -306,9 +306,6 @@ public:
it changes them, so it is safe to assume that the same pen, brush and colours it changes them, so it is safe to assume that the same pen, brush and colours
that were active before the call to this function are still in effect after it. that were active before the call to this function are still in effect after it.
@note Under wxMSW drawing on wxGCDC is possible only if it's associated with
GDI+ or Direct2D wxGraphicsContext.
@library{wxcore} @library{wxcore}
@category{gdi} @category{gdi}
*/ */

View File

@@ -184,7 +184,9 @@
m( cairo_get_font_options, \ m( cairo_get_font_options, \
(cairo_t* cr, cairo_font_options_t* options), (cr, options) ) \ (cairo_t* cr, cairo_font_options_t* options), (cr, options) ) \
m( cairo_user_to_device_distance, \ m( cairo_user_to_device_distance, \
(cairo_t* cr, double *dx, double* dy), (cr, dx, dy) ) (cairo_t* cr, double *dx, double* dy), (cr, dx, dy) ) \
m( cairo_surface_mark_dirty, \
(cairo_surface_t* surface), (surface))
#ifdef __WXMAC__ #ifdef __WXMAC__
#define wxCAIRO_PLATFORM_METHODS(m) \ #define wxCAIRO_PLATFORM_METHODS(m) \

View File

@@ -513,15 +513,8 @@ public:
virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const wxOVERRIDE; virtual void GetPartialTextExtents(const wxString& text, wxArrayDouble& widths) const wxOVERRIDE;
#ifdef __WXMSW__ #ifdef __WXMSW__
virtual WXHDC GetNativeHDC() wxOVERRIDE virtual WXHDC GetNativeHDC() wxOVERRIDE;
{ virtual void ReleaseNativeHDC(WXHDC WXUNUSED(hdc)) wxOVERRIDE;
wxFAIL_MSG("Can't get HDC from Cairo context");
return NULL;
};
virtual void ReleaseNativeHDC(WXHDC WXUNUSED(hdc)) wxOVERRIDE
{
wxFAIL_MSG("Can't release HDC for Cairo context");
};
#endif #endif
protected: protected:
@@ -3086,6 +3079,21 @@ void wxCairoContext::EndLayer()
cairo_paint_with_alpha(m_context, double(opacity)); cairo_paint_with_alpha(m_context, double(opacity));
} }
#ifdef __WXMSW__
WXHDC wxCairoContext::GetNativeHDC()
{
wxCHECK_MSG(m_mswSurface, NULL, "Can't get HDC from Cairo context");
cairo_surface_flush(m_mswSurface);
return cairo_win32_surface_get_dc(m_mswSurface);
};
void wxCairoContext::ReleaseNativeHDC(WXHDC WXUNUSED(hdc))
{
wxCHECK_RET(m_mswSurface, "Can't release HDC for Cairo context");
cairo_surface_mark_dirty(m_mswSurface);
};
#endif // __WXMSW__
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
// wxCairoRenderer declaration // wxCairoRenderer declaration
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------