]> git.saurik.com Git - wxWidgets.git/blobdiff - src/gtk/nonownedwnd.cpp
Add doc for wxGraphicsContext.Create(), which is a lightweight context with no target...
[wxWidgets.git] / src / gtk / nonownedwnd.cpp
index 95e4288a857bc3f4cc833e3c5069b5e66681f82d..e558b5298404167deae92ea9476bc5d6f155b808 100644 (file)
@@ -3,7 +3,7 @@
 // Purpose:     wxGTK implementation of wxNonOwnedWindow.
 // Author:      Vadim Zeitlin
 // Created:     2011-10-12
 // Purpose:     wxGTK implementation of wxNonOwnedWindow.
 // Author:      Vadim Zeitlin
 // Created:     2011-10-12
-// RCS-ID:      $Id: wxhead.cpp,v 1.11 2010-04-22 12:44:51 zeitlin Exp $
+// RCS-ID:      $Id$
 // Copyright:   (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 // Copyright:   (c) 2011 Vadim Zeitlin <vadim@wxwidgets.org>
 // Licence:     wxWindows licence
 ///////////////////////////////////////////////////////////////////////////////
 #endif
 
 #ifndef WX_PRECOMP
 #endif
 
 #ifndef WX_PRECOMP
+    #include "wx/nonownedwnd.h"
     #include "wx/dcclient.h"
     #include "wx/dcmemory.h"
     #include "wx/dcclient.h"
     #include "wx/dcmemory.h"
-    #include "wx/nonownedwnd.h"
     #include "wx/region.h"
 #endif // WX_PRECOMP
 
     #include "wx/region.h"
 #endif // WX_PRECOMP
 
-#include "wx/gtk/private.h"
-
-#include <gdk/gdk.h>
-
 #include "wx/graphics.h"
 
 #include "wx/graphics.h"
 
+#include <gtk/gtk.h>
+#include "wx/gtk/private/gtk2-compat.h"
+
 // ----------------------------------------------------------------------------
 // wxNonOwnedWindowShapeImpl: base class for region and path-based classes.
 // ----------------------------------------------------------------------------
 // ----------------------------------------------------------------------------
 // wxNonOwnedWindowShapeImpl: base class for region and path-based classes.
 // ----------------------------------------------------------------------------
@@ -96,7 +95,7 @@ public:
 private:
     virtual bool DoSetShape(GdkWindow* window)
     {
 private:
     virtual bool DoSetShape(GdkWindow* window)
     {
-        gdk_window_shape_combine_mask(window, NULL, 0, 0);
+        gdk_window_shape_combine_region(window, NULL, 0, 0);
 
         return true;
     }
 
         return true;
     }
@@ -176,7 +175,11 @@ private:
         dc.SetBackground(*wxBLACK);
         dc.Clear();
 
         dc.SetBackground(*wxBLACK);
         dc.Clear();
 
+#ifdef __WXGTK3__
+        wxGraphicsContext* context = dc.GetGraphicsContext();
+#else
         wxScopedPtr<wxGraphicsContext> context(wxGraphicsContext::Create(dc));
         wxScopedPtr<wxGraphicsContext> context(wxGraphicsContext::Create(dc));
+#endif
         context->SetBrush(*wxWHITE);
         context->FillPath(path);
 
         context->SetBrush(*wxWHITE);
         context->FillPath(path);
 
@@ -185,11 +188,16 @@ private:
 
     virtual bool DoSetShape(GdkWindow *window)
     {
 
     virtual bool DoSetShape(GdkWindow *window)
     {
-        GdkBitmap* bitmap = m_mask.GetBitmap();
-        if ( !bitmap )
+        if (!m_mask)
             return false;
 
             return false;
 
-        gdk_window_shape_combine_mask(window, bitmap, 0, 0);
+#ifdef __WXGTK3__
+        cairo_region_t* region = gdk_cairo_region_create_from_surface(m_mask);
+        gdk_window_shape_combine_region(window, region, 0, 0);
+        cairo_region_destroy(region);
+#else
+        gdk_window_shape_combine_mask(window, m_mask, 0, 0);
+#endif
 
         return true;
     }
 
         return true;
     }
@@ -200,7 +208,11 @@ private:
         event.Skip();
 
         wxPaintDC dc(m_win);
         event.Skip();
 
         wxPaintDC dc(m_win);
+#ifdef __WXGTK3__
+        wxGraphicsContext* context = dc.GetGraphicsContext();
+#else
         wxScopedPtr<wxGraphicsContext> context(wxGraphicsContext::Create(dc));
         wxScopedPtr<wxGraphicsContext> context(wxGraphicsContext::Create(dc));
+#endif
         context->SetPen(wxPen(*wxLIGHT_GREY, 2));
         context->StrokePath(m_path);
     }
         context->SetPen(wxPen(*wxLIGHT_GREY, 2));
         context->StrokePath(m_path);
     }