]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/graphicc.cpp
avoiding potential mismatch between true and expected state of wxGraphicsContext...
[wxWidgets.git] / src / generic / graphicc.cpp
index ec4830837f729f51c7001688fe4c544f3143ab6b..cf9a017ad13b8ee9b773c098b9655318cf5afcea 100644 (file)
@@ -71,6 +71,10 @@ using namespace std;
 #include <cairo.h>
 #ifdef __WXMSW__
 #include <cairo-win32.h>
+// Notice that the order is important: cairo-win32.h includes windows.h which
+// pollutes the global name space with macros so include our own header which
+// #undefines them after it.
+#include "wx/msw/private.h"
 #endif
 
 #ifdef __WXGTK__
@@ -79,13 +83,6 @@ using namespace std;
 #include "wx/gtk/dc.h"
 #endif
 
-#ifdef __WXMSW__
-#include <cairo-win32.h>
-// We must do this as cairo-win32.h includes windows.h which pollutes the
-// global name space with macros.
-#include "wx/msw/winundef.h"
-#endif
-
 #ifdef __WXMAC__
 #include "wx/osx/private.h"
 #include <cairo-quartz.h>
@@ -400,6 +397,7 @@ public:
     virtual void Clip( const wxRegion &region );
 #ifdef __WXMSW__
     cairo_surface_t* m_mswSurface;
+    WindowHDC m_mswWindowHDC;
 #endif
 
     // clips drawings to the rect
@@ -1744,7 +1742,10 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, cairo_t *context )
 }
 
 wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window)
-: wxGraphicsContext(renderer)
+    : wxGraphicsContext(renderer)
+#ifdef __WXMSW__
+    , m_mswWindowHDC(GetHwndOf(window))
+#endif
 {
     m_enableOffset = true;    
 #ifdef __WXGTK__
@@ -1768,7 +1769,7 @@ wxCairoContext::wxCairoContext( wxGraphicsRenderer* renderer, wxWindow *window)
 #endif
 
 #ifdef __WXMSW__
-    m_mswSurface = cairo_win32_surface_create((HDC)window->GetHandle());
+    m_mswSurface = cairo_win32_surface_create((HDC)m_mswWindowHDC);
     Init(cairo_create(m_mswSurface));
 #endif