+#ifdef __WXGTK3__
+ #include "wx/gtk/dc.h"
+#elif defined __WXGTK20__
+ #include "wx/gtk/dcclient.h"
+ #include "wx/gtk/dcmemory.h"
+ #include "wx/gtk/dcscreen.h"
+#elif defined(__WXGTK__)
+ #include "wx/gtk1/dcclient.h"
+ #include "wx/gtk1/dcmemory.h"
+ #include "wx/gtk1/dcscreen.h"
+#endif
+
+#ifdef __WXMAC__
+ #include "wx/osx/dcclient.h"
+ #include "wx/osx/dcmemory.h"
+ #include "wx/osx/dcscreen.h"
+#endif
+
+#ifdef __WXPM__
+ #include "wx/os2/dcclient.h"
+ #include "wx/os2/dcmemory.h"
+ #include "wx/os2/dcscreen.h"
+#endif
+
+#ifdef __WXCOCOA__
+ #include "wx/cocoa/dcclient.h"
+ #include "wx/cocoa/dcmemory.h"
+ #include "wx/cocoa/dcscreen.h"
+#endif
+
+#ifdef __WXMOTIF__
+ #include "wx/motif/dcclient.h"
+ #include "wx/motif/dcmemory.h"
+ #include "wx/motif/dcscreen.h"
+#endif
+
+#ifdef __WXX11__
+ #include "wx/x11/dcclient.h"
+ #include "wx/x11/dcmemory.h"
+ #include "wx/x11/dcscreen.h"
+#endif
+
+#ifdef __WXDFB__
+ #include "wx/dfb/dcclient.h"
+ #include "wx/dfb/dcmemory.h"
+ #include "wx/dfb/dcscreen.h"
+#endif
+
+//----------------------------------------------------------------------------
+// wxDCFactory
+//----------------------------------------------------------------------------
+
+wxDCFactory *wxDCFactory::m_factory = NULL;
+
+void wxDCFactory::Set(wxDCFactory *factory)
+{
+ delete m_factory;
+
+ m_factory = factory;
+}
+
+wxDCFactory *wxDCFactory::Get()
+{
+ if ( !m_factory )
+ m_factory = new wxNativeDCFactory;
+
+ return m_factory;
+}
+
+class wxDCFactoryCleanupModule : public wxModule
+{
+public:
+ virtual bool OnInit() { return true; }
+ virtual void OnExit() { wxDCFactory::Set(NULL); }
+
+private:
+ DECLARE_DYNAMIC_CLASS(wxDCFactoryCleanupModule)
+};
+
+IMPLEMENT_DYNAMIC_CLASS(wxDCFactoryCleanupModule, wxModule)
+
+//-----------------------------------------------------------------------------
+// wxNativeDCFactory
+//-----------------------------------------------------------------------------
+
+wxDCImpl* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner, wxWindow *window )
+{
+ wxDCImpl * const impl = new wxWindowDCImpl( owner, window );
+ impl->InheritAttributes(window);
+ return impl;
+}
+
+wxDCImpl* wxNativeDCFactory::CreateClientDC( wxClientDC *owner, wxWindow *window )
+{
+ wxDCImpl * const impl = new wxClientDCImpl( owner, window );
+ impl->InheritAttributes(window);
+ return impl;
+}
+
+wxDCImpl* wxNativeDCFactory::CreatePaintDC( wxPaintDC *owner, wxWindow *window )
+{
+ wxDCImpl * const impl = new wxPaintDCImpl( owner, window );
+ impl->InheritAttributes(window);
+ return impl;
+}
+
+wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner )
+{
+ return new wxMemoryDCImpl( owner );
+}
+
+wxDCImpl* wxNativeDCFactory::CreateMemoryDC(wxMemoryDC *owner, wxBitmap& bitmap)
+{
+ // the bitmap may be modified when it's selected into a memory DC so make
+ // sure changing this bitmap doesn't affect any other shallow copies of it
+ // (see wxMemoryDC::SelectObject())
+ //
+ // notice that we don't provide any ctor equivalent to SelectObjectAsSource
+ // method because this should be rarely needed and easy to work around by
+ // using the default ctor and calling SelectObjectAsSource itself
+ if ( bitmap.IsOk() )
+ bitmap.UnShare();
+
+ return new wxMemoryDCImpl(owner, bitmap);
+}
+
+wxDCImpl* wxNativeDCFactory::CreateMemoryDC( wxMemoryDC *owner, wxDC *dc )
+{
+ return new wxMemoryDCImpl( owner, dc );
+}
+
+wxDCImpl* wxNativeDCFactory::CreateScreenDC( wxScreenDC *owner )
+{
+ return new wxScreenDCImpl( owner );
+}
+
+#if wxUSE_PRINTING_ARCHITECTURE
+wxDCImpl *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data )
+{
+ wxPrintFactory *factory = wxPrintFactory::GetFactory();
+ return factory->CreatePrinterDCImpl( owner, data );
+}
+#endif
+
+//-----------------------------------------------------------------------------
+// wxWindowDC
+//-----------------------------------------------------------------------------