]> git.saurik.com Git - wxWidgets.git/commitdiff
Added wxDC::CreateGraphicsContext and implemented it for a few DCs
authorRobert Roebling <robert@roebling.de>
Fri, 25 Apr 2008 11:05:16 +0000 (11:05 +0000)
committerRobert Roebling <robert@roebling.de>
Fri, 25 Apr 2008 11:05:16 +0000 (11:05 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@53344 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/dc.h
include/wx/gtk/dcclient.h
include/wx/gtk/dcmemory.h
include/wx/gtk/print.h
include/wx/msw/dcclient.h
include/wx/msw/dcmemory.h
src/gtk/dcclient.cpp
src/gtk/dcmemory.cpp
src/gtk/print.cpp
src/msw/dcclient.cpp
src/msw/dcmemory.cpp

index f0fe623aa7da8ca63fc75bb2a5068e4b6d4d1c37..e500f1f49ac4d121c6087ee081106c3ebc15d28d 100644 (file)
@@ -42,6 +42,11 @@ class WXDLLIMPEXP_FWD_CORE wxMemoryDC;
 class WXDLLIMPEXP_FWD_CORE wxPrinterDC;
 class WXDLLIMPEXP_FWD_CORE wxPrintData;
 
+
+#if wxUSE_GRAPHICS_CONTEXT
+class WXDLLIMPEXP_FWD_CORE wxGraphicsContext;
+#endif
+
 //-----------------------------------------------------------------------------
 // wxDrawObject helper class
 //-----------------------------------------------------------------------------
@@ -182,6 +187,15 @@ public:
     virtual bool CanDrawBitmap() const = 0;
     virtual bool CanGetTextExtent() const = 0;
 
+    // get graphics context from 
+
+#if wxUSE_GRAPHICS_CONTEXT
+    virtual wxGraphicsContext* CreateGraphicsContext()
+    {
+        return NULL;
+    }
+#endif
+
     // query dimension, colour deps, resolution
 
     virtual void DoGetSize(int *width, int *height) const = 0;
@@ -620,6 +634,11 @@ public:
     bool IsOk() const
         { return m_pimpl && m_pimpl->IsOk(); }
 
+#if wxUSE_GRAPHICS_CONTEXT
+    wxGraphicsContext* CreateGraphicsContext()
+        { return m_pimpl->CreateGraphicsContext(); }
+#endif
+
     // query capabilities
 
     bool CanDrawBitmap() const
index 29e35429a5382665f43cd3d9a32f68a9008bc71f..9a3a13d1a4c60c336d5421a2b627937004740bcd 100644 (file)
@@ -28,6 +28,10 @@ public:
 
     virtual ~wxWindowDCImpl();
 
+#if wxUSE_GRAPHICS_CONTEXT
+    virtual wxGraphicsContext* CreateGraphicsContext();
+#endif
+
     virtual bool CanDrawBitmap() const { return true; }
     virtual bool CanGetTextExtent() const { return true; }
 
index ff470015c82cedf04f4023ad7fd2d06901131946..44296bdb6d482607d1ad26723733aab38495f1d8 100644 (file)
@@ -26,6 +26,10 @@ public:
     
     virtual ~wxMemoryDCImpl();
 
+#if wxUSE_GRAPHICS_CONTEXT
+    virtual wxGraphicsContext* CreateGraphicsContext();
+#endif
+
     // these get reimplemented for mono-bitmaps to behave
     // more like their Win32 couterparts. They now interpret
     // wxWHITE, wxWHITE_BRUSH and wxWHITE_PEN as drawing 0
index 46dde4f2b02aa5b59f8d8f2a3455581e0daf7959..5cc313bde90c80103f9826c30e780ca76c69f6f4 100644 (file)
@@ -227,6 +227,10 @@ public:
     bool Ok() const { return IsOk(); }
     bool IsOk() const;
 
+#if wxUSE_GRAPHICS_CONTEXT
+    virtual wxGraphicsContext* CreateGraphicsContext();
+#endif
+
     bool CanDrawBitmap() const { return true; }
     void Clear();
     void SetFont( const wxFont& font );
index eed5e21e594f3bc94e110b6a14642071dc8109b9..5957aa5c22855d0ead61a10533451dc22c17f7e4 100644 (file)
@@ -43,6 +43,10 @@ public:
     // Create a DC corresponding to the whole window
     wxWindowDCImpl( wxDC *owner, wxWindow *win );
 
+#if wxUSE_GRAPHICS_CONTEXT
+    virtual wxGraphicsContext* CreateGraphicsContext();
+#endif
+
     virtual void DoGetSize(int *width, int *height) const;
 
 protected:
index 5b78fead33222f744a980a452808c55f9da2a2f4..23b75e904822ce6ba231742b863b41a35820f71d 100644 (file)
@@ -22,6 +22,10 @@ public:
     wxMemoryDCImpl( wxMemoryDC *owner, wxBitmap& bitmap );
     wxMemoryDCImpl( wxMemoryDC *owner, wxDC *dc ); // Create compatible DC
 
+#if wxUSE_GRAPHICS_CONTEXT
+    virtual wxGraphicsContext* CreateGraphicsContext();
+#endif
+
     // override some base class virtuals
     virtual void DoDrawRectangle(wxCoord x, wxCoord y, wxCoord width, wxCoord height);
     virtual void DoGetSize(int* width, int* height) const;
index 5589029861b47d4044ca88e4abd6ccef02c9f517..1c4a313d5cfa028d55a625ddfa1bf95036487abf 100644 (file)
 
 #include <gdk/gdkx.h>
 
+#if wxUSE_GRAPHICS_CONTEXT
+#include "wx/graphics.h"
+#endif
+
+
 //-----------------------------------------------------------------------------
 // local defines
 //-----------------------------------------------------------------------------
@@ -365,6 +370,14 @@ wxWindowDCImpl::~wxWindowDCImpl()
         pango_font_description_free( m_fontdesc );
 }
 
+#if wxUSE_GRAPHICS_CONTEXT
+wxGraphicsContext* wxWindowDCImpl::CreateGraphicsContext()
+{
+    wxWindowDC *windowdc = (wxWindowDC*) GetOwner();
+    return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *windowdc );
+}
+#endif
+
 void wxWindowDCImpl::SetUpDC( bool isMemDC )
 {
     m_ok = true;
index 3c22ca1fc19b2e57293b8c105de6fdb9576d6c2a..d77d307dc5c3c76da744cbfb1ecd0bc61937dc94 100644 (file)
 #include <gdk/gdk.h>
 #include <gtk/gtk.h>
 
+#if wxUSE_GRAPHICS_CONTEXT
+#include "wx/graphics.h"
+#endif
+
 //-----------------------------------------------------------------------------
 // wxMemoryDCImpl
 //-----------------------------------------------------------------------------
@@ -60,6 +64,14 @@ void wxMemoryDCImpl::Init()
     m_fontdesc = pango_font_description_copy( pango_context_get_font_description( m_context ) );
 }
 
+#if wxUSE_GRAPHICS_CONTEXT
+wxGraphicsContext* wxMemoryDCImpl::CreateGraphicsContext()
+{
+    wxMemoryDC *memdc = (wxMemoryDC*) GetOwner();
+    return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *memdc );
+}
+#endif
+
 void wxMemoryDCImpl::DoSelect( const wxBitmap& bitmap )
 {
     Destroy();
index 4ac6043261851e6eba2db23bdd300fe3b0c7095d..d84ee92ffc5528bde57d3c13af60dd1780aee878 100644 (file)
 #include <gtk/gtk.h>
 #include <gtk/gtkpagesetupunixdialog.h>
 
+#if wxUSE_GRAPHICS_CONTEXT
+#include "wx/graphics.h"
+#endif
+
 #include "wx/link.h"
 wxFORCE_LINK_THIS_MODULE(gtk_print)
 
@@ -1155,6 +1159,13 @@ bool wxGtkPrinterDCImpl::IsOk() const
     return m_gpc != NULL;
 }
 
+#if wxUSE_GRAPHICS_CONTEXT
+wxGraphicsContext* wxGtkPrinterDCImpl::CreateGraphicsContext()
+{
+    return wxGraphicsRenderer::GetDefaultRenderer()->CreateContextFromNativeContext( (void*) m_cairo );
+}
+#endif
+
 bool wxGtkPrinterDCImpl::DoFloodFill(wxCoord WXUNUSED(x1),
                                wxCoord WXUNUSED(y1),
                                const wxColour& WXUNUSED(col),
index e97fe01af2b2a691b9c822bcd73d0db792bc2bb2..b965c68430e128da179f4ba62e5ae1c3dff264ac 100644 (file)
     #include "wx/window.h"
 #endif
 
+#if wxUSE_GRAPHICS_CONTEXT
+#include "wx/graphics.h"
+#endif
+
 #include "wx/msw/private.h"
 
 // ----------------------------------------------------------------------------
@@ -118,6 +122,14 @@ void wxWindowDCImpl::InitDC()
 #endif
 }
 
+#if wxUSE_GRAPHICS_CONTEXT
+wxGraphicsContext* wxWindowDCImpl::CreateGraphicsContext()
+{
+    wxWindowDC *windowdc = (wxWindowDC*) GetOwner();
+    return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *windowdc );
+}
+#endif
+
 void wxWindowDCImpl::DoGetSize(int *width, int *height) const
 {
     wxCHECK_RET( m_window, _T("wxWindowDCImpl without a window?") );
index 6869e6f4e4b2f6873ede578fd7c176a7f0ad394e..7da1ce87c5b4a4b4b5ff0c52c199edb7203bfb60 100644 (file)
     #include "wx/log.h"
 #endif
 
+#if wxUSE_GRAPHICS_CONTEXT
+#include "wx/graphics.h"
+#endif
+
 #include "wx/msw/private.h"
 
 // ----------------------------------------------------------------------------
@@ -78,6 +82,14 @@ void wxMemoryDCImpl::Init()
     }
 }
 
+#if wxUSE_GRAPHICS_CONTEXT
+wxGraphicsContext* wxMemoryDCImpl::CreateGraphicsContext()
+{
+    wxMemoryDC *memdc = (wxMemoryDC*) GetOwner();
+    return wxGraphicsRenderer::GetDefaultRenderer()->CreateContext( *memdc );
+}
+#endif
+
 bool wxMemoryDCImpl::CreateCompatible(wxDC *dc)
 {
     wxDCImpl *impl = dc ? dc->GetImpl() : NULL ;