+ Setup();
+}
+
+wxMemoryDCImpl::wxMemoryDCImpl(wxMemoryDC* owner, wxDC*)
+ : base_type(owner)
+{
+ m_ok = false;
+}
+
+wxBitmap wxMemoryDCImpl::DoGetAsBitmap(const wxRect* subrect) const
+{
+ return subrect ? m_bitmap.GetSubBitmap(*subrect) : m_bitmap;
+}
+
+void wxMemoryDCImpl::DoSelect(const wxBitmap& bitmap)
+{
+ m_bitmap = bitmap;
+ Setup();
+}
+
+const wxBitmap& wxMemoryDCImpl::GetSelectedBitmap() const
+{
+ return m_bitmap;
+}
+
+wxBitmap& wxMemoryDCImpl::GetSelectedBitmap()
+{
+ return m_bitmap;
+}
+
+void wxMemoryDCImpl::Setup()
+{
+ wxGraphicsContext* gc = NULL;
+ m_ok = m_bitmap.IsOk();
+ if (m_ok)
+ {
+ m_width = m_bitmap.GetWidth();
+ m_height = m_bitmap.GetHeight();
+ cairo_t* cr = m_bitmap.CairoCreate();
+ gc = wxGraphicsContext::CreateFromNative(cr);
+ }
+ SetGraphicsContext(gc);
+}
+//-----------------------------------------------------------------------------
+
+wxGTKCairoDC::wxGTKCairoDC(cairo_t* cr)
+ : base_type(new wxGTKCairoDCImpl(this, 0))
+{
+ cairo_reference(cr);
+ SetGraphicsContext(wxGraphicsContext::CreateFromNative(cr));
+}
+
+#else
+
+#include "wx/gtk/dc.h"
+
+//-----------------------------------------------------------------------------
+// wxGTKDCImpl
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_ABSTRACT_CLASS(wxGTKDCImpl, wxDCImpl)
+
+wxGTKDCImpl::wxGTKDCImpl( wxDC *owner )
+ : wxDCImpl( owner )
+{
+ m_ok = FALSE;
+
+ m_pen = *wxBLACK_PEN;
+ m_font = *wxNORMAL_FONT;
+ m_brush = *wxWHITE_BRUSH;
+}
+
+wxGTKDCImpl::~wxGTKDCImpl()
+{
+}
+
+void wxGTKDCImpl::DoSetClippingRegion( wxCoord x, wxCoord y, wxCoord width, wxCoord height )
+{
+ m_clipping = TRUE;
+ m_clipX1 = x;
+ m_clipY1 = y;
+ m_clipX2 = x + width;
+ m_clipY2 = y + height;
+}
+
+// ---------------------------------------------------------------------------
+// get DC capabilities
+// ---------------------------------------------------------------------------
+
+void wxGTKDCImpl::DoGetSizeMM( int* width, int* height ) const
+{
+ int w = 0;
+ int h = 0;
+ GetOwner()->GetSize( &w, &h );
+ if (width) *width = int( double(w) / (m_userScaleX*m_mm_to_pix_x) );
+ if (height) *height = int( double(h) / (m_userScaleY*m_mm_to_pix_y) );
+}
+
+// Resolution in pixels per logical inch
+wxSize wxGTKDCImpl::GetPPI() const
+{
+ // TODO (should probably be pure virtual)
+ return wxSize(0, 0);