#include "wx/dcmemory.h"
#include "wx/dcscreen.h"
#include "wx/dcprint.h"
-#include "wx/dcbuffer.h" // for IMPLEMENT_DYNAMIC_CLASS
#include "wx/prntbase.h"
#ifndef WX_PRECOMP
#include "wx/math.h"
+ #include "wx/module.h"
#endif
#ifdef __WXMSW__
-#include "wx/msw/dcclient.h"
-#include "wx/msw/dcmemory.h"
-#include "wx/msw/dcscreen.h"
+ #include "wx/msw/dcclient.h"
+ #include "wx/msw/dcmemory.h"
+ #include "wx/msw/dcscreen.h"
#endif
#ifdef __WXGTK__
-#include "wx/gtk/dcclient.h"
-#include "wx/gtk/dcmemory.h"
-#include "wx/gtk/dcscreen.h"
+ #include "wx/gtk/dcclient.h"
+ #include "wx/gtk/dcmemory.h"
+ #include "wx/gtk/dcscreen.h"
#endif
#ifdef __WXMAC__
-#include "wx/mac/dcclient.h"
-#include "wx/mac/dcmemory.h"
-#include "wx/mac/dcscreen.h"
+ #include "wx/mac/dcclient.h"
+ #include "wx/mac/dcmemory.h"
+ #include "wx/mac/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"
+ #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
+
+#ifdef __WXPALMOS__
+ #include "wx/palmos/dcclient.h"
+ #include "wx/palmos/dcmemory.h"
+ #include "wx/palmos/dcscreen.h"
#endif
//----------------------------------------------------------------------------
wxDCFactory *wxDCFactory::m_factory = NULL;
-void wxDCFactory::SetDCFactory( wxDCFactory *factory )
+void wxDCFactory::Set(wxDCFactory *factory)
{
- if (wxDCFactory::m_factory)
- delete wxDCFactory::m_factory;
+ delete m_factory;
- wxDCFactory::m_factory = factory;
+ m_factory = factory;
}
-wxDCFactory *wxDCFactory::GetFactory()
+wxDCFactory *wxDCFactory::Get()
{
- if (!wxDCFactory::m_factory)
- wxDCFactory::m_factory = new wxNativeDCFactory;
+ if ( !m_factory )
+ m_factory = new wxNativeDCFactory;
- return wxDCFactory::m_factory;
+ 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 )
-{
+{
return new wxWindowDCImpl( owner );
}
wxDCImpl* wxNativeDCFactory::CreateWindowDC( wxWindowDC *owner, wxWindow *window )
-{
+{
return new wxWindowDCImpl( owner, window );
}
// wxWindowDC
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxWindowDC, wxDC)
+IMPLEMENT_ABSTRACT_CLASS(wxWindowDC, wxDC)
-wxWindowDC::wxWindowDC()
+wxWindowDC::wxWindowDC(wxWindow *win)
+ : wxDC(wxDCFactory::Get()->CreateWindowDC(this, win))
{
}
-wxWindowDC::wxWindowDC( wxWindow *win )
-{
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreateWindowDC( this, win );
-}
-
//-----------------------------------------------------------------------------
// wxClientDC
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxClientDC, wxWindowDC)
+IMPLEMENT_ABSTRACT_CLASS(wxClientDC, wxWindowDC)
-wxClientDC::wxClientDC()
+wxClientDC::wxClientDC(wxWindow *win)
+ : wxWindowDC(wxDCFactory::Get()->CreateClientDC(this, win))
{
}
-wxClientDC::wxClientDC( wxWindow *win )
-{
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreateClientDC( this, win );
-}
-
//-----------------------------------------------------------------------------
// wxMemoryDC
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxMemoryDC, wxDC)
wxMemoryDC::wxMemoryDC()
+ : wxDC(wxDCFactory::Get()->CreateMemoryDC(this))
{
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreateMemoryDC( this );
}
-wxMemoryDC::wxMemoryDC( wxBitmap& bitmap )
+wxMemoryDC::wxMemoryDC(wxBitmap& bitmap)
+ : wxDC(wxDCFactory::Get()->CreateMemoryDC(this, bitmap))
{
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreateMemoryDC( this, bitmap );
}
-wxMemoryDC::wxMemoryDC( wxDC *dc )
+wxMemoryDC::wxMemoryDC(wxDC *dc)
+ : wxDC(wxDCFactory::Get()->CreateMemoryDC(this, dc))
{
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreateMemoryDC( this, dc );
}
void wxMemoryDC::SelectObject(wxBitmap& bmp)
return GetImpl()->GetSelectedBitmap();
}
-
+
//-----------------------------------------------------------------------------
// wxPaintDC
//-----------------------------------------------------------------------------
-IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC)
+IMPLEMENT_ABSTRACT_CLASS(wxPaintDC, wxClientDC)
-wxPaintDC::wxPaintDC()
+wxPaintDC::wxPaintDC(wxWindow *win)
+ : wxClientDC(wxDCFactory::Get()->CreatePaintDC(this, win))
{
}
-wxPaintDC::wxPaintDC( wxWindow *win )
-{
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreatePaintDC( this, win );
-}
-
//-----------------------------------------------------------------------------
// wxScreenDC
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC)
wxScreenDC::wxScreenDC()
+ : wxDC(wxDCFactory::Get()->CreateScreenDC(this))
{
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreateScreenDC( this );
}
//-----------------------------------------------------------------------------
IMPLEMENT_DYNAMIC_CLASS(wxPrinterDC, wxDC)
wxPrinterDC::wxPrinterDC()
+ : wxDC(wxDCFactory::Get()->CreatePrinterDC(this, wxPrintData()))
{
- wxPrintData data; // Does this make sense?
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreatePrinterDC( this, data );
}
-wxPrinterDC::wxPrinterDC( const wxPrintData &data )
-{
- wxDCFactory *factory = wxDCFactory::GetFactory();
- m_pimpl = factory->CreatePrinterDC( this, data );
-}
-
-wxPrinterDC::~wxPrinterDC()
+wxPrinterDC::wxPrinterDC(const wxPrintData& data)
+ : wxDC(wxDCFactory::Get()->CreatePrinterDC(this, data))
{
}
return GetImpl()->GetResolution();
}
-#endif
+#endif // wxUSE_PRINTING_ARCHITECTURE
//-----------------------------------------------------------------------------
// wxDCImpl
(double)wxGetDisplaySizeMM().GetWidth();
m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
(double)wxGetDisplaySizeMM().GetHeight();
-
+
ResetBoundingBox();
ResetClipping();
}
*externalLeading = externalLeading2;
}
-void wxDC::GetLogicalOrigin(long *x, long *y) const
+void wxDC::GetLogicalOrigin(long *x, long *y) const
{
wxCoord x2, y2;
m_pimpl->DoGetLogicalOrigin(&x2, &y2);
*y = y2;
}
-void wxDC::GetDeviceOrigin(long *x, long *y) const
+void wxDC::GetDeviceOrigin(long *x, long *y) const
{
wxCoord x2, y2;
m_pimpl->DoGetDeviceOrigin(&x2, &y2);
*x = x2;
if ( y )
*y = y2;
- }
-
-void wxDC::GetClippingBox(long *x, long *y, long *w, long *h) const
+ }
+
+void wxDC::GetClippingBox(long *x, long *y, long *w, long *h) const
{
wxCoord xx,yy,ww,hh;
m_pimpl->DoGetClippingBox(&xx, &yy, &ww, &hh);
if (y) *y = yy;
if (w) *w = ww;
if (h) *h = hh;
- }
-
+ }
+
#endif // WXWIN_COMPATIBILITY_2_8