]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dcbase.cpp
on HP-UX 11.11, vsscanf first parameter is not const
[wxWidgets.git] / src / common / dcbase.cpp
index 07353fba7435c1002e811eee09b99f0889521470..09b466d07aefa55bc846cf83db9b6d443b7d33a1 100644 (file)
 #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"
+#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
 
 //----------------------------------------------------------------------------
 
 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 +181,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 +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)
@@ -224,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 );
 }
 
 //-----------------------------------------------------------------------------
@@ -248,31 +277,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 +309,7 @@ int wxPrinterDC::GetResolution()
     return GetImpl()->GetResolution();
 }
 
+#endif // wxUSE_PRINTING_ARCHITECTURE
 
 //-----------------------------------------------------------------------------
 // wxDCImpl
@@ -329,7 +353,7 @@ wxDCImpl::wxDCImpl( wxDC *owner )
                     (double)wxGetDisplaySizeMM().GetWidth();
     m_mm_to_pix_y = (double)wxGetDisplaySize().GetHeight() /
                     (double)wxGetDisplaySizeMM().GetHeight();
-                    
+
     ResetBoundingBox();
     ResetClipping();
 }
@@ -1284,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);
@@ -1294,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);
@@ -1302,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);
@@ -1312,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