]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/dcbase.cpp
non-pch build fix for wxUSE_DISPLAY==0
[wxWidgets.git] / src / common / dcbase.cpp
index a6e495af411513c3ce188dc9e3e7c97cec29a1a3..be5eeb9578f5f7e0b66cb84861f80257f31c099a 100644 (file)
@@ -28,7 +28,9 @@
 #include "wx/dcclient.h"
 #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"
@@ -334,6 +336,12 @@ wxImplDC* wxNativeDCFactory::CreateScreenDC( wxScreenDC *owner )
 #endif
 }
 
+wxImplDC *wxNativeDCFactory::CreatePrinterDC( wxPrinterDC *owner, const wxPrintData &data )
+{
+    wxPrintFactory *factory = wxPrintFactory::GetFactory();
+    return factory->CreatePrinterImplDC( owner, data );
+}
+
 //-----------------------------------------------------------------------------
 // wxWindowDC
 //-----------------------------------------------------------------------------
@@ -402,50 +410,22 @@ void wxMemoryDC::SelectObject(wxBitmap& bmp)
     if (bmp.IsOk())
         bmp.UnShare();
 
-#ifdef __WXGTK__
-    wxGTKMemoryImplDC *mem_pimpl = wxDynamicCast( m_pimpl, wxGTKMemoryImplDC );
-#else
-    // TODO
-#endif
-    if (mem_pimpl)
-        mem_pimpl->DoSelect(bmp);
+    GetImpl()->DoSelect(bmp);
 }
 
 void wxMemoryDC::SelectObjectAsSource(const wxBitmap& bmp)
 {
-#ifdef __WXGTK__
-    wxGTKMemoryImplDC *mem_pimpl = wxDynamicCast( m_pimpl, wxGTKMemoryImplDC );
-#else
-    // TODO
-#endif
-    mem_pimpl->DoSelect(bmp);
+    GetImpl()->DoSelect(bmp);
 }
 
 const wxBitmap& wxMemoryDC::GetSelectedBitmap() const
 {
-#ifdef __WXGTK__
-    wxGTKMemoryImplDC *mem_pimpl = wxDynamicCast( m_pimpl, wxGTKMemoryImplDC );
-#else
-    // TODO
-#endif
-    if (mem_pimpl)
-        return mem_pimpl->DoGetSelectedBitmap();
-
-    return wxNullBitmap;    
+    return GetImpl()->GetSelectedBitmap();
 }
 
 wxBitmap& wxMemoryDC::GetSelectedBitmap()
 {
-#ifdef __WXGTK__
-    wxGTKMemoryImplDC *mem_pimpl = wxDynamicCast( m_pimpl, wxGTKMemoryImplDC );
-#else
-    // TODO
-#endif
-    
-    if (mem_pimpl)
-        return mem_pimpl->DoGetSelectedBitmap();
-   
-    return wxNullBitmap;    
+    return GetImpl()->GetSelectedBitmap();
 }
 
     
@@ -479,6 +459,39 @@ wxScreenDC::wxScreenDC()
     m_pimpl = factory->CreateScreenDC( this );
 }
 
+//-----------------------------------------------------------------------------
+// wxPrinterDC
+//-----------------------------------------------------------------------------
+
+IMPLEMENT_DYNAMIC_CLASS(wxPrinterDC, wxDC)
+
+wxPrinterDC::wxPrinterDC()
+{
+    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()
+{
+}
+
+wxRect wxPrinterDC::GetPaperRect()
+{
+    return GetImpl()->GetPaperRect();
+}
+
+int wxPrinterDC::GetResolution()
+{
+    return GetImpl()->GetResolution();
+}
+
+
 //-----------------------------------------------------------------------------
 // wxImplDC
 //-----------------------------------------------------------------------------
@@ -733,9 +746,9 @@ void wxImplDC::GetMultiLineTextExtent(const wxString& text,
             heightTextTotal = 0, heightLineDefault = 0, heightLine = 0;
 
     wxString curLine;
-    for ( const wxChar *pc = text; ; pc++ )
+    for ( wxString::const_iterator pc = text.begin(); ; ++pc )
     {
-        if ( *pc == _T('\n') || *pc == _T('\0') )
+        if ( pc == text.end() || *pc == _T('\n') )
         {
             if ( curLine.empty() )
             {
@@ -766,14 +779,13 @@ void wxImplDC::GetMultiLineTextExtent(const wxString& text,
                 heightTextTotal += heightLine;
             }
 
-            if ( *pc == _T('\n') )
+            if ( pc == text.end() )
             {
-               curLine.clear();
+               break;
             }
-            else
+            else // '\n'
             {
-               // the end of string
-               break;
+               curLine.clear();
             }
         }
         else
@@ -1062,6 +1074,7 @@ static bool wx_spline_add_point(double x, double y)
 
 static void wx_spline_draw_point_array(wxDC *dc)
 {
+    dc->DrawLines(&wx_spline_point_list, 0, 0 );
     wxPointList::compatibility_iterator node = wx_spline_point_list.GetFirst();
     while (node)
     {
@@ -1841,7 +1854,7 @@ void wxDCBase::DrawLines(const wxList *list, wxCoord xoffset, wxCoord yoffset )
     wxPoint *points = new wxPoint[n];
 
     unsigned int i = 0;
-    wxNode *node;
+    wxObjectList::compatibility_iterator node;
     for ( node = list->GetFirst(); node; node = node->GetNext(), i++ )
     {
         wxPoint *point = (wxPoint*) node->GetData();
@@ -1887,7 +1900,7 @@ void wxDCBase::DrawPolygon(const wxList *list,
     wxPoint *points = new wxPoint[n];
 
     unsigned int i = 0;
-    wxNode *node;
+    wxObjectList::compatibility_iterator node;
     for ( node = list->GetFirst(); node; node = node->GetNext(), i++ )
     {
         wxPoint *point = (wxPoint*) node->GetData();
@@ -2101,7 +2114,7 @@ static void wx_spline_draw_point_array(wxDCBase *dc)
 void wxDCBase::DrawSpline(const wxList *points)
 {
     wxPointList list;
-    wxNode *node = points->GetFirst();
+    wxObjectList::compatibility_iterator node = points->GetFirst();
     while (node)
     {
         list.Append( (wxPoint*) node->GetData() );