X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/957ea55146a1dd3e29ea803936527344672a947f..0c62004afb4926ecce56883250aaf72890b2ff9d:/src/common/dcbase.cpp diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index e0b7d7a41b..09b466d07a 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -33,30 +33,65 @@ #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" +#ifdef __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/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 __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" + #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 //---------------------------------------------------------------------------- @@ -65,33 +100,44 @@ 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 ); } @@ -147,32 +193,22 @@ wxDCImpl *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *owner, const wxPrintD // 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) - -wxClientDC::wxClientDC() -{ -} +IMPLEMENT_ABSTRACT_CLASS(wxClientDC, wxWindowDC) -wxClientDC::wxClientDC( wxWindow *win ) +wxClientDC::wxClientDC(wxWindow *win) + : wxWindowDC(wxDCFactory::Get()->CreateClientDC(this, win)) { - wxDCFactory *factory = wxDCFactory::GetFactory(); - m_pimpl = factory->CreateClientDC( this, win ); } //----------------------------------------------------------------------------- @@ -182,21 +218,18 @@ wxClientDC::wxClientDC( wxWindow *win ) 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) @@ -225,21 +258,16 @@ wxBitmap& wxMemoryDC::GetSelectedBitmap() return GetImpl()->GetSelectedBitmap(); } - + //----------------------------------------------------------------------------- // wxPaintDC //----------------------------------------------------------------------------- -IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxClientDC) - -wxPaintDC::wxPaintDC() -{ -} +IMPLEMENT_ABSTRACT_CLASS(wxPaintDC, wxClientDC) -wxPaintDC::wxPaintDC( wxWindow *win ) +wxPaintDC::wxPaintDC(wxWindow *win) + : wxClientDC(wxDCFactory::Get()->CreatePaintDC(this, win)) { - wxDCFactory *factory = wxDCFactory::GetFactory(); - m_pimpl = factory->CreatePaintDC( this, win ); } //----------------------------------------------------------------------------- @@ -249,9 +277,8 @@ wxPaintDC::wxPaintDC( wxWindow *win ) IMPLEMENT_DYNAMIC_CLASS(wxScreenDC, wxWindowDC) wxScreenDC::wxScreenDC() + : wxDC(wxDCFactory::Get()->CreateScreenDC(this)) { - wxDCFactory *factory = wxDCFactory::GetFactory(); - m_pimpl = factory->CreateScreenDC( this ); } //----------------------------------------------------------------------------- @@ -263,19 +290,12 @@ wxScreenDC::wxScreenDC() 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)) { } @@ -289,7 +309,7 @@ int wxPrinterDC::GetResolution() return GetImpl()->GetResolution(); } -#endif +#endif // wxUSE_PRINTING_ARCHITECTURE //----------------------------------------------------------------------------- // wxDCImpl @@ -333,7 +353,7 @@ wxDCImpl::wxDCImpl( wxDC *owner ) (double)wxGetDisplaySizeMM().GetWidth(); m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() / (double)wxGetDisplaySizeMM().GetHeight(); - + ResetBoundingBox(); ResetClipping(); } @@ -1288,7 +1308,7 @@ void wxDC::GetTextExtent(const wxString& string, *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); @@ -1298,7 +1318,7 @@ void wxDC::GetLogicalOrigin(long *x, long *y) const *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); @@ -1306,9 +1326,9 @@ void wxDC::GetDeviceOrigin(long *x, long *y) const *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); @@ -1316,6 +1336,6 @@ void wxDC::GetClippingBox(long *x, long *y, long *w, long *h) const if (y) *y = yy; if (w) *w = ww; if (h) *h = hh; - } - + } + #endif // WXWIN_COMPATIBILITY_2_8