X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/488194403efc0093d6ae3c6e0c5731b854258805..928e79b665fc9ad569655ced3168195b39bd04b6:/src/common/dcbase.cpp diff --git a/src/common/dcbase.cpp b/src/common/dcbase.cpp index 07353fba74..e48e874e07 100644 --- a/src/common/dcbase.cpp +++ b/src/common/dcbase.cpp @@ -29,35 +29,41 @@ #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 __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 //---------------------------------------------------------------------------- @@ -66,33 +72,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 ); } @@ -136,42 +153,34 @@ 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 //----------------------------------------------------------------------------- -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 ); } //----------------------------------------------------------------------------- @@ -181,21 +190,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) @@ -224,21 +230,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 ); } //----------------------------------------------------------------------------- @@ -248,31 +249,25 @@ 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 ); } //----------------------------------------------------------------------------- // wxPrinterDC //----------------------------------------------------------------------------- +#if wxUSE_PRINTING_ARCHITECTURE + 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)) { } @@ -286,6 +281,7 @@ int wxPrinterDC::GetResolution() return GetImpl()->GetResolution(); } +#endif // wxUSE_PRINTING_ARCHITECTURE //----------------------------------------------------------------------------- // wxDCImpl @@ -329,7 +325,7 @@ wxDCImpl::wxDCImpl( wxDC *owner ) (double)wxGetDisplaySizeMM().GetWidth(); m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() / (double)wxGetDisplaySizeMM().GetHeight(); - + ResetBoundingBox(); ResetClipping(); } @@ -1284,7 +1280,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); @@ -1294,7 +1290,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); @@ -1302,9 +1298,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); @@ -1312,6 +1308,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