diff --git a/include/wx/graphics.h b/include/wx/graphics.h index bcdcdb00eb..6bb970a9c9 100644 --- a/include/wx/graphics.h +++ b/include/wx/graphics.h @@ -870,6 +870,10 @@ public: // create a subimage from a native image representation virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) = 0; + virtual wxString GetName() const = 0; + virtual void + GetVersion(int* major, int* minor = NULL, int* micro = NULL) const = 0; + private: wxDECLARE_NO_COPY_CLASS(wxGraphicsRenderer); DECLARE_ABSTRACT_CLASS(wxGraphicsRenderer) diff --git a/interface/wx/graphics.h b/interface/wx/graphics.h index 8e2113bea6..74d8ff3be7 100644 --- a/interface/wx/graphics.h +++ b/interface/wx/graphics.h @@ -1211,6 +1211,34 @@ public: wxDouble x, wxDouble y, wxDouble w, wxDouble h) = 0; + /** + Returns the name of the technology used by the renderer. + + Currently this function returns "gdiplus" for Windows GDI+ implementation, + "cairo" for Cairo implementation and "cg" for OS X CoreGraphics + implementation. + + Note: the string returned by this method is not user-readable and is + expected to be used internally by the program only. + + @since 3.1.0 + */ + virtual wxString GetName() const = 0; + + /** + Returns the version major, minor and micro/build of the technology used + by the renderer. + + Currently this function returns the OS major and minor versions in + the parameters with the matching names and sets @a micro to 0 for + the GDI+ and CoreGraphics engines which are considered to be parts of + their respective OS. + + For Cairo, this is the major,minor,micro version of the Cairo library + which is returned. + */ + virtual void GetVersion(int* major, int* minor = NULL, int* micro=NULL) const = 0; + /** Returns the default renderer on this platform. On OS X this is the Core Graphics (a.k.a. Quartz 2D) renderer, on MSW the GDIPlus renderer, and diff --git a/src/generic/graphicc.cpp b/src/generic/graphicc.cpp index e43ec60cde..b2de5585f6 100644 --- a/src/generic/graphicc.cpp +++ b/src/generic/graphicc.cpp @@ -2398,6 +2398,9 @@ public : // create a subimage from a native image representation virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); + virtual wxString GetName() const wxOVERRIDE; + virtual void GetVersion(int *major, int *minor, int *micro) const wxOVERRIDE; + DECLARE_DYNAMIC_CLASS_NO_COPY(wxCairoRenderer) } ; @@ -2651,6 +2654,20 @@ wxCairoRenderer::CreateSubBitmap(const wxGraphicsBitmap& WXUNUSED(bitmap), return p; } +wxString wxCairoRenderer::GetName() const +{ + return "cairo"; +} + +void wxCairoRenderer::GetVersion(int *major, int *minor, int *micro) const +{ + int dummy; + sscanf(cairo_version_string(), "%d.%d.%d", + major ? major : &dummy, + minor ? minor : &dummy, + micro ? micro : &dummy); +} + wxGraphicsRenderer* wxGraphicsRenderer::GetCairoRenderer() { return &gs_cairoGraphicsRenderer; diff --git a/src/msw/graphics.cpp b/src/msw/graphics.cpp index 3a4865dd19..ee3c83f235 100644 --- a/src/msw/graphics.cpp +++ b/src/msw/graphics.cpp @@ -587,6 +587,9 @@ public : // create a subimage from a native image representation virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ); + virtual wxString GetName() const wxOVERRIDE; + virtual void GetVersion(int *major, int *minor, int *micro) const wxOVERRIDE; + protected : bool EnsureIsLoaded(); void Load(); @@ -2295,6 +2298,21 @@ wxGraphicsBitmap wxGDIPlusRenderer::CreateSubBitmap( const wxGraphicsBitmap &bit return wxNullGraphicsBitmap; } +wxString wxGDIPlusRenderer::GetName() const +{ + return "gdiplus"; +} + +void wxGDIPlusRenderer::GetVersion(int *major, int *minor, int *micro) const +{ + if ( major ) + *major = wxPlatformInfo::Get().GetOSMajorVersion(); + if ( minor ) + *minor = wxPlatformInfo::Get().GetOSMinorVersion(); + if ( micro ) + *micro = 0; +} + // Shutdown GDI+ at app exit, before possible dll unload class wxGDIPlusRendererModule : public wxModule { diff --git a/src/osx/carbon/graphics.cpp b/src/osx/carbon/graphics.cpp index 7ff9c32d54..fabb331e74 100644 --- a/src/osx/carbon/graphics.cpp +++ b/src/osx/carbon/graphics.cpp @@ -2654,6 +2654,10 @@ public : // create a native bitmap representation virtual wxGraphicsBitmap CreateSubBitmap( const wxGraphicsBitmap &bitmap, wxDouble x, wxDouble y, wxDouble w, wxDouble h ) wxOVERRIDE ; + + virtual wxString GetName() const wxOVERRIDE; + virtual void GetVersion(int *major, int *minor, int *micro) const wxOVERRIDE; + private : DECLARE_DYNAMIC_CLASS_NO_COPY(wxMacCoreGraphicsRenderer) } ; @@ -2875,6 +2879,21 @@ wxGraphicsBitmap wxMacCoreGraphicsRenderer::CreateSubBitmap( const wxGraphicsBit return wxNullGraphicsBitmap; } +wxString wxMacCoreGraphicsRenderer::GetName() const +{ + return "cg"; +} + +void wxMacCoreGraphicsRenderer::GetVersion(int *major, int *minor, int *micro) const +{ + if ( major ) + *major = wxPlatformInfo::Get().GetOSMajorVersion(); + if ( minor ) + *minor = wxPlatformInfo::Get().GetOSMinorVersion(); + if ( micro ) + *micro = 0; +} + wxGraphicsBrush wxMacCoreGraphicsRenderer::CreateLinearGradientBrush(wxDouble x1, wxDouble y1, wxDouble x2, wxDouble y2,