From f4af243e5c34d412d54b41bc6d741d8342d33dc8 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 8 Dec 2017 19:42:21 +0100 Subject: [PATCH] Enable wxUSE_GRAPHICS_CONTEXT for MinGW >= 4.8 It seems that MinGW-w32 started distributing GDI+ headers since this version and MinGW-w64 might have supported them for even longer, but it's difficult to test for the MinGW distribution used in this header, as it is included before wx/msw/gccpriv.h which defines __MINGW32_TOOLCHAIN__ and __MINGW64_TOOLCHAIN__ symbols and changing this is tricky due to relative order of defining UNICODE and wxUSE_UNICODE and including MinGW headers, which can only be included once UNICODE is set properly. But while the fully correct solution is difficult, just checking for the compiler version should solve the problem in 99.99% of the cases in practice as there should be vanishingly few people using MinGW-w64 with gcc < 4.8 currently, so this simple solution is good enough. Closes #17973. --- include/wx/android/setup.h | 18 +++++++++--------- include/wx/gtk/setup0.h | 18 +++++++++--------- include/wx/motif/setup0.h | 18 +++++++++--------- include/wx/msw/setup0.h | 18 +++++++++--------- include/wx/osx/setup0.h | 18 +++++++++--------- include/wx/setup_inc.h | 18 +++++++++--------- include/wx/univ/setup0.h | 18 +++++++++--------- setup.h.in | 3 ++- 8 files changed, 65 insertions(+), 64 deletions(-) diff --git a/include/wx/android/setup.h b/include/wx/android/setup.h index 2a6aceabed..8ca861908e 100644 --- a/include/wx/android/setup.h +++ b/include/wx/android/setup.h @@ -782,18 +782,18 @@ // Enable wxGraphicsContext and related classes for a modern 2D drawing API. // -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC is known to ship with at least gdiplus.h which is required to -// compile GDI+-based implementation of wxGraphicsContext (MSVC10 and later -// versions also include d2d1.h required for Direct2D-based implementation). -// For other compilers (e.g. mingw32) you may need to install the headers (and -// just the headers) yourself. If you do, change the setting below manually. +// Default is 1 except if you're using a compiler without support for GDI+ +// under MSW, i.e. gdiplus.h and related headers (MSVC and MinGW >= 4.8 are +// known to have them). For other compilers (e.g. older mingw32) you may need +// to install the headers (and just the headers) yourself. If you do, change +// the setting below manually. // // Recommended setting: 1 if supported by the compilation environment -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER +// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION() +// here as this file is included from wx/platform.h before they're defined. +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) #define wxUSE_GRAPHICS_CONTEXT 1 #else // Disable support for other Windows compilers, enable it if your compiler diff --git a/include/wx/gtk/setup0.h b/include/wx/gtk/setup0.h index e0155cee95..df78b80ef3 100644 --- a/include/wx/gtk/setup0.h +++ b/include/wx/gtk/setup0.h @@ -783,18 +783,18 @@ // Enable wxGraphicsContext and related classes for a modern 2D drawing API. // -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC is known to ship with at least gdiplus.h which is required to -// compile GDI+-based implementation of wxGraphicsContext (MSVC10 and later -// versions also include d2d1.h required for Direct2D-based implementation). -// For other compilers (e.g. mingw32) you may need to install the headers (and -// just the headers) yourself. If you do, change the setting below manually. +// Default is 1 except if you're using a compiler without support for GDI+ +// under MSW, i.e. gdiplus.h and related headers (MSVC and MinGW >= 4.8 are +// known to have them). For other compilers (e.g. older mingw32) you may need +// to install the headers (and just the headers) yourself. If you do, change +// the setting below manually. // // Recommended setting: 1 if supported by the compilation environment -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER +// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION() +// here as this file is included from wx/platform.h before they're defined. +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) #define wxUSE_GRAPHICS_CONTEXT 1 #else // Disable support for other Windows compilers, enable it if your compiler diff --git a/include/wx/motif/setup0.h b/include/wx/motif/setup0.h index f55fc8b14c..048281ec70 100644 --- a/include/wx/motif/setup0.h +++ b/include/wx/motif/setup0.h @@ -783,18 +783,18 @@ // Enable wxGraphicsContext and related classes for a modern 2D drawing API. // -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC is known to ship with at least gdiplus.h which is required to -// compile GDI+-based implementation of wxGraphicsContext (MSVC10 and later -// versions also include d2d1.h required for Direct2D-based implementation). -// For other compilers (e.g. mingw32) you may need to install the headers (and -// just the headers) yourself. If you do, change the setting below manually. +// Default is 1 except if you're using a compiler without support for GDI+ +// under MSW, i.e. gdiplus.h and related headers (MSVC and MinGW >= 4.8 are +// known to have them). For other compilers (e.g. older mingw32) you may need +// to install the headers (and just the headers) yourself. If you do, change +// the setting below manually. // // Recommended setting: 1 if supported by the compilation environment -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER +// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION() +// here as this file is included from wx/platform.h before they're defined. +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) #define wxUSE_GRAPHICS_CONTEXT 1 #else // Disable support for other Windows compilers, enable it if your compiler diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h index 5860054d87..bd082d170c 100644 --- a/include/wx/msw/setup0.h +++ b/include/wx/msw/setup0.h @@ -783,18 +783,18 @@ // Enable wxGraphicsContext and related classes for a modern 2D drawing API. // -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC is known to ship with at least gdiplus.h which is required to -// compile GDI+-based implementation of wxGraphicsContext (MSVC10 and later -// versions also include d2d1.h required for Direct2D-based implementation). -// For other compilers (e.g. mingw32) you may need to install the headers (and -// just the headers) yourself. If you do, change the setting below manually. +// Default is 1 except if you're using a compiler without support for GDI+ +// under MSW, i.e. gdiplus.h and related headers (MSVC and MinGW >= 4.8 are +// known to have them). For other compilers (e.g. older mingw32) you may need +// to install the headers (and just the headers) yourself. If you do, change +// the setting below manually. // // Recommended setting: 1 if supported by the compilation environment -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER +// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION() +// here as this file is included from wx/platform.h before they're defined. +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) #define wxUSE_GRAPHICS_CONTEXT 1 #else // Disable support for other Windows compilers, enable it if your compiler diff --git a/include/wx/osx/setup0.h b/include/wx/osx/setup0.h index 75049f0e5e..3f6b48c69c 100644 --- a/include/wx/osx/setup0.h +++ b/include/wx/osx/setup0.h @@ -789,18 +789,18 @@ // Enable wxGraphicsContext and related classes for a modern 2D drawing API. // -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC is known to ship with at least gdiplus.h which is required to -// compile GDI+-based implementation of wxGraphicsContext (MSVC10 and later -// versions also include d2d1.h required for Direct2D-based implementation). -// For other compilers (e.g. mingw32) you may need to install the headers (and -// just the headers) yourself. If you do, change the setting below manually. +// Default is 1 except if you're using a compiler without support for GDI+ +// under MSW, i.e. gdiplus.h and related headers (MSVC and MinGW >= 4.8 are +// known to have them). For other compilers (e.g. older mingw32) you may need +// to install the headers (and just the headers) yourself. If you do, change +// the setting below manually. // // Recommended setting: 1 if supported by the compilation environment -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER +// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION() +// here as this file is included from wx/platform.h before they're defined. +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) #define wxUSE_GRAPHICS_CONTEXT 1 #else // Disable support for other Windows compilers, enable it if your compiler diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h index 9f031a8c53..a58ec282f1 100644 --- a/include/wx/setup_inc.h +++ b/include/wx/setup_inc.h @@ -779,18 +779,18 @@ // Enable wxGraphicsContext and related classes for a modern 2D drawing API. // -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC is known to ship with at least gdiplus.h which is required to -// compile GDI+-based implementation of wxGraphicsContext (MSVC10 and later -// versions also include d2d1.h required for Direct2D-based implementation). -// For other compilers (e.g. mingw32) you may need to install the headers (and -// just the headers) yourself. If you do, change the setting below manually. +// Default is 1 except if you're using a compiler without support for GDI+ +// under MSW, i.e. gdiplus.h and related headers (MSVC and MinGW >= 4.8 are +// known to have them). For other compilers (e.g. older mingw32) you may need +// to install the headers (and just the headers) yourself. If you do, change +// the setting below manually. // // Recommended setting: 1 if supported by the compilation environment -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER +// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION() +// here as this file is included from wx/platform.h before they're defined. +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) #define wxUSE_GRAPHICS_CONTEXT 1 #else // Disable support for other Windows compilers, enable it if your compiler diff --git a/include/wx/univ/setup0.h b/include/wx/univ/setup0.h index 069f9b156e..7544890848 100644 --- a/include/wx/univ/setup0.h +++ b/include/wx/univ/setup0.h @@ -782,18 +782,18 @@ // Enable wxGraphicsContext and related classes for a modern 2D drawing API. // -// Default is 1 except if you're using a non-Microsoft compiler under Windows -// as only MSVC is known to ship with at least gdiplus.h which is required to -// compile GDI+-based implementation of wxGraphicsContext (MSVC10 and later -// versions also include d2d1.h required for Direct2D-based implementation). -// For other compilers (e.g. mingw32) you may need to install the headers (and -// just the headers) yourself. If you do, change the setting below manually. +// Default is 1 except if you're using a compiler without support for GDI+ +// under MSW, i.e. gdiplus.h and related headers (MSVC and MinGW >= 4.8 are +// known to have them). For other compilers (e.g. older mingw32) you may need +// to install the headers (and just the headers) yourself. If you do, change +// the setting below manually. // // Recommended setting: 1 if supported by the compilation environment -// notice that we can't use wxCHECK_VISUALC_VERSION() here as this file is -// included from wx/platform.h before wxCHECK_VISUALC_VERSION() is defined -#ifdef _MSC_VER +// Notice that we can't use wxCHECK_VISUALC_VERSION() nor wxCHECK_GCC_VERSION() +// here as this file is included from wx/platform.h before they're defined. +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) #define wxUSE_GRAPHICS_CONTEXT 1 #else // Disable support for other Windows compilers, enable it if your compiler diff --git a/setup.h.in b/setup.h.in index b2de2783c3..8aa259f041 100644 --- a/setup.h.in +++ b/setup.h.in @@ -349,7 +349,8 @@ #endif -#ifdef _MSC_VER +#if defined(_MSC_VER) || \ + (defined(__MINGW32__) && (__GNUC__ > 4 || __GNUC_MINOR__ >= 8)) #define wxUSE_GRAPHICS_CONTEXT 0 #else #define wxUSE_GRAPHICS_CONTEXT 0