From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Fri, 2 Apr 2010 19:30:41 +0000 (+0000)
Subject: Allow using wxGraphicsContext with MinGW if gdiplus.h is available.
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/cde23b64b5194f0d71cf16c85ea33d28419c815f?ds=sidebyside

Allow using wxGraphicsContext with MinGW if gdiplus.h is available.

MinGW doesn't include gdiplus.h but it can be installed independently by the
user. Allow to use it if it's available:

- Include windows.h when checking for it in configure as this is apparently
  needed for its compilation.
- Don't reset wxUSE_GRAPHICS_CONTEXT to 0 for non-Microsoft compilers, instead
  just define it as 0 by default for them, allowing the user to simply change
  the definition in wx/msw/setup.h.

Closes #11892.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63832 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/configure b/configure
index fb880bc182..f6228878d7 100755
--- a/configure
+++ b/configure
@@ -47506,6 +47506,7 @@ _ACEOF
 cat confdefs.h >>conftest.$ac_ext
 cat >>conftest.$ac_ext <<_ACEOF
 /* end confdefs.h.  */
+#include <window.h>
 #include <gdiplus.h>
 int
 main ()
diff --git a/configure.in b/configure.in
index e3b0d891b4..e6bf454aef 100644
--- a/configure.in
+++ b/configure.in
@@ -7444,7 +7444,8 @@ if test "$wxUSE_GRAPHICS_CONTEXT" = "yes"; then
                 dnl GDI+ DLL dynamically anyhow during run-time
                 AC_LANG_PUSH(C++)
                 AC_TRY_COMPILE(
-                    [#include <gdiplus.h>],
+                    [#include <windows.h>
+                     #include <gdiplus.h>],
                     [
                         using namespace Gdiplus;
                     ],
diff --git a/include/wx/motif/setup0.h b/include/wx/motif/setup0.h
index 22177951f1..2d21d12393 100644
--- a/include/wx/motif/setup0.h
+++ b/include/wx/motif/setup0.h
@@ -661,11 +661,17 @@
 // still do need to distribute it yourself for an application using
 // wxGraphicsContext to be runnable on pre-XP systems.
 //
-// Default is 1 if the compiler has gdiplus.h (currently only MSVC 7+ under
-// Windows is known to).
+// Default is 1 except if you're using a non-Microsoft compiler under Windows
+// as only MSVC7+ is known to ship with gdiplus.h. 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.
 //
 // Recommended setting: 1
-#define wxUSE_GRAPHICS_CONTEXT 1
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 1
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 // ----------------------------------------------------------------------------
 // Individual GUI controls
diff --git a/include/wx/msw/chkconf.h b/include/wx/msw/chkconf.h
index 51aede9543..eabc05bdf6 100644
--- a/include/wx/msw/chkconf.h
+++ b/include/wx/msw/chkconf.h
@@ -239,15 +239,6 @@
    Compiler-specific checks.
  */
 
-// Only MSVC 7+ has gdiplus.h, add exceptions for other compilers here if they
-// can support it too (but notice that Borland currently dies in
-// src/msw/gdiplus.cpp with "macro expansion too long" error even if the header
-// is available)
-#if !wxCHECK_VISUALC_VERSION(7)
-    #undef wxUSE_GRAPHICS_CONTEXT
-    #define wxUSE_GRAPHICS_CONTEXT 0
-#endif
-
 // Borland
 #ifdef __BORLANDC__
 
diff --git a/include/wx/msw/setup0.h b/include/wx/msw/setup0.h
index 0391162f33..e28a11d271 100644
--- a/include/wx/msw/setup0.h
+++ b/include/wx/msw/setup0.h
@@ -661,11 +661,17 @@
 // still do need to distribute it yourself for an application using
 // wxGraphicsContext to be runnable on pre-XP systems.
 //
-// Default is 1 if the compiler has gdiplus.h (currently only MSVC 7+ under
-// Windows is known to).
+// Default is 1 except if you're using a non-Microsoft compiler under Windows
+// as only MSVC7+ is known to ship with gdiplus.h. 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.
 //
 // Recommended setting: 1
-#define wxUSE_GRAPHICS_CONTEXT 1
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 1
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 // ----------------------------------------------------------------------------
 // Individual GUI controls
diff --git a/include/wx/msw/wince/setup.h b/include/wx/msw/wince/setup.h
index 615d2fa542..b63ddda90c 100644
--- a/include/wx/msw/wince/setup.h
+++ b/include/wx/msw/wince/setup.h
@@ -661,11 +661,17 @@
 // still do need to distribute it yourself for an application using
 // wxGraphicsContext to be runnable on pre-XP systems.
 //
-// Default is 1 if the compiler has gdiplus.h (currently only MSVC 7+ under
-// Windows is known to).
+// Default is 1 except if you're using a non-Microsoft compiler under Windows
+// as only MSVC7+ is known to ship with gdiplus.h. 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.
 //
 // Recommended setting: 1
-#define wxUSE_GRAPHICS_CONTEXT 1
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 1
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 // ----------------------------------------------------------------------------
 // Individual GUI controls
diff --git a/include/wx/os2/setup0.h b/include/wx/os2/setup0.h
index b3d9ee1af8..40186f83bb 100644
--- a/include/wx/os2/setup0.h
+++ b/include/wx/os2/setup0.h
@@ -661,11 +661,17 @@
 // still do need to distribute it yourself for an application using
 // wxGraphicsContext to be runnable on pre-XP systems.
 //
-// Default is 1 if the compiler has gdiplus.h (currently only MSVC 7+ under
-// Windows is known to).
+// Default is 1 except if you're using a non-Microsoft compiler under Windows
+// as only MSVC7+ is known to ship with gdiplus.h. 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.
 //
 // Recommended setting: 1
-#define wxUSE_GRAPHICS_CONTEXT 1
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 1
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 // ----------------------------------------------------------------------------
 // Individual GUI controls
diff --git a/include/wx/osx/setup0.h b/include/wx/osx/setup0.h
index 53c43ce100..b044bbfa6a 100644
--- a/include/wx/osx/setup0.h
+++ b/include/wx/osx/setup0.h
@@ -662,11 +662,17 @@
 // still do need to distribute it yourself for an application using
 // wxGraphicsContext to be runnable on pre-XP systems.
 //
-// Default is 1 if the compiler has gdiplus.h (currently only MSVC 7+ under
-// Windows is known to).
+// Default is 1 except if you're using a non-Microsoft compiler under Windows
+// as only MSVC7+ is known to ship with gdiplus.h. 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.
 //
 // Recommended setting: 1
-#define wxUSE_GRAPHICS_CONTEXT 1
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 1
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 // ----------------------------------------------------------------------------
 // Individual GUI controls
diff --git a/include/wx/palmos/setup0.h b/include/wx/palmos/setup0.h
index 5a235c70e1..3f2f2e10cd 100644
--- a/include/wx/palmos/setup0.h
+++ b/include/wx/palmos/setup0.h
@@ -661,11 +661,17 @@
 // still do need to distribute it yourself for an application using
 // wxGraphicsContext to be runnable on pre-XP systems.
 //
-// Default is 1 if the compiler has gdiplus.h (currently only MSVC 7+ under
-// Windows is known to).
+// Default is 1 except if you're using a non-Microsoft compiler under Windows
+// as only MSVC7+ is known to ship with gdiplus.h. 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.
 //
 // Recommended setting: 1
-#define wxUSE_GRAPHICS_CONTEXT 1
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 1
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 // ----------------------------------------------------------------------------
 // Individual GUI controls
diff --git a/include/wx/setup_inc.h b/include/wx/setup_inc.h
index fbeb660e29..39b22a1219 100644
--- a/include/wx/setup_inc.h
+++ b/include/wx/setup_inc.h
@@ -657,11 +657,17 @@
 // still do need to distribute it yourself for an application using
 // wxGraphicsContext to be runnable on pre-XP systems.
 //
-// Default is 1 if the compiler has gdiplus.h (currently only MSVC 7+ under
-// Windows is known to).
+// Default is 1 except if you're using a non-Microsoft compiler under Windows
+// as only MSVC7+ is known to ship with gdiplus.h. 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.
 //
 // Recommended setting: 1
-#define wxUSE_GRAPHICS_CONTEXT 1
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 1
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 // ----------------------------------------------------------------------------
 // Individual GUI controls
diff --git a/include/wx/univ/setup0.h b/include/wx/univ/setup0.h
index de3c88b727..425ce4c0c4 100644
--- a/include/wx/univ/setup0.h
+++ b/include/wx/univ/setup0.h
@@ -660,11 +660,17 @@
 // still do need to distribute it yourself for an application using
 // wxGraphicsContext to be runnable on pre-XP systems.
 //
-// Default is 1 if the compiler has gdiplus.h (currently only MSVC 7+ under
-// Windows is known to).
+// Default is 1 except if you're using a non-Microsoft compiler under Windows
+// as only MSVC7+ is known to ship with gdiplus.h. 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.
 //
 // Recommended setting: 1
-#define wxUSE_GRAPHICS_CONTEXT 1
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 1
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 // ----------------------------------------------------------------------------
 // Individual GUI controls
diff --git a/setup.h.in b/setup.h.in
index 9ce60367b4..0519dabb7d 100644
--- a/setup.h.in
+++ b/setup.h.in
@@ -323,7 +323,11 @@
 #define wxUSE_STC 0
 
 
-#define wxUSE_GRAPHICS_CONTEXT 0
+#if !defined(__WXMSW__) || wxCHECK_VISUALC_VERSION(7)
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#else
+    #define wxUSE_GRAPHICS_CONTEXT 0
+#endif
 
 
 #define wxUSE_CONTROLS     0