]> git.saurik.com Git - wxWidgets.git/blobdiff - src/common/prntbase.cpp
get rid of several dozen of warnings when using g++ >= 4.2 about string literals...
[wxWidgets.git] / src / common / prntbase.cpp
index 112f818218391c69017265aa23bc196437999155..16bea8a4a63354f39164a4faacad92f299758544 100644 (file)
 
 #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
 #include "wx/msw/printdlg.h"
+#include "wx/msw/dcprint.h"
 #elif defined(__WXMAC__)
-#include "wx/mac/printdlg.h"
-#include "wx/mac/private/print.h"
+#include "wx/osx/printdlg.h"
+#include "wx/osx/private/print.h"
+#include "wx/osx/dcprint.h"
+#elif defined(__WXPM__)
+#include "wx/os2/dcprint.h"
+#include "wx/generic/prntdlgg.h"
 #else
 #include "wx/generic/prntdlgg.h"
 #include "wx/dcps.h"
@@ -205,34 +210,15 @@ wxDialog *wxNativePrintFactory::CreatePrintSetupDialog( wxWindow *parent,
 #endif
 }
 
-#if wxUSE_NEW_DC
-
-wxImplDC* wxNativePrintFactory::CreatePrinterImplDC( wxPrinterDC *owner, const wxPrintData& data )
+wxDCImpl* wxNativePrintFactory::CreatePrinterDCImpl( wxPrinterDC *owner, const wxPrintData& data )
 {
-#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
-    return new wxWindowsPrinterDCImpl( owner, data );
-#elif defined(__WXMAC__)
-    return new wxMacPrinterDCImpl( owner, data );
+#if defined(__WXGTK__) || defined(__WXMOTIF__) || defined(__WXUNIVERSAL__)
+    return new wxPostScriptDCImpl( owner, data );
 #else
-    return new wxPostScriptImplDC( owner, data );
+    return new wxPrinterDCImpl( owner, data );
 #endif
 }
 
-#else
-
-wxDC* wxNativePrintFactory::CreatePrinterDC( const wxPrintData& data )
-{
-#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
-    return new wxPrinterDC(data);
-#elif defined(__WXMAC__)
-    return new wxPrinterDC(data);
-#else
-    return new wxPostScriptDC(data);
-#endif
-}
-
-#endif
-
 bool wxNativePrintFactory::HasOwnPrintToFile()
 {
     // Only relevant for PostScript and here the
@@ -822,6 +808,7 @@ IMPLEMENT_CLASS(wxPreviewCanvas, wxWindow)
 BEGIN_EVENT_TABLE(wxPreviewCanvas, wxScrolledWindow)
     EVT_PAINT(wxPreviewCanvas::OnPaint)
     EVT_CHAR(wxPreviewCanvas::OnChar)
+    EVT_IDLE(wxPreviewCanvas::OnIdle)
     EVT_SYS_COLOUR_CHANGED(wxPreviewCanvas::OnSysColourChanged)
 #if wxUSE_MOUSEWHEEL
     EVT_MOUSEWHEEL(wxPreviewCanvas::OnMouseWheel)
@@ -873,6 +860,16 @@ void wxPreviewCanvas::OnPaint(wxPaintEvent& WXUNUSED(event))
     }
 }
 
+void wxPreviewCanvas::OnIdle(wxIdleEvent& event)
+{
+    if ( m_printPreview )
+    {
+        if ( m_printPreview->UpdatePageRendering() )
+            Refresh();
+    }
+    event.Skip();
+}
+
 // Responds to colour changes, and passes event on to children.
 void wxPreviewCanvas::OnSysColourChanged(wxSysColourChangedEvent& event)
 {
@@ -1286,7 +1283,9 @@ void wxPreviewFrame::OnCloseWindow(wxCloseEvent& WXUNUSED(event))
         m_printPreview->SetCanvas(NULL);
         m_printPreview->SetFrame(NULL);
     }
-    delete m_printPreview;
+
+    m_previewCanvas->SetPreview(NULL);
+    wxDELETE(m_printPreview);
 
     Destroy();
 }
@@ -1410,8 +1409,6 @@ bool wxPrintPreviewBase::SetCurrentPage(int pageNum)
     {
         AdjustScrollbars(m_previewCanvas);
 
-        if (!RenderPage(pageNum))
-            return false;
         m_previewCanvas->Refresh();
         m_previewCanvas->SetFocus();
     }
@@ -1468,13 +1465,21 @@ void wxPrintPreviewBase::CalcRects(wxPreviewCanvas *canvas, wxRect& pageRect, wx
 }
 
 
+bool wxPrintPreviewBase::UpdatePageRendering()
+{
+    if ( m_previewBitmap )
+        return false;
+
+    if ( !RenderPage(m_currentPage) )
+        return false;
+
+    return true;
+}
+
 bool wxPrintPreviewBase::PaintPage(wxPreviewCanvas *canvas, wxDC& dc)
 {
     DrawBlankPage(canvas, dc);
 
-    if (!m_previewBitmap)
-        if (!RenderPage(m_currentPage))
-            return false;
     if (!m_previewBitmap)
         return false;
     if (!canvas)
@@ -1630,7 +1635,6 @@ void wxPrintPreviewBase::SetZoom(int percent)
     if (m_previewCanvas)
     {
         AdjustScrollbars(m_previewCanvas);
-        RenderPage(m_currentPage);
         ((wxScrolledWindow *) m_previewCanvas)->Scroll(0, 0);
         m_previewCanvas->ClearBackground();
         m_previewCanvas->Refresh();
@@ -1738,6 +1742,11 @@ bool wxPrintPreview::PaintPage(wxPreviewCanvas *canvas, wxDC& dc)
     return m_pimpl->PaintPage( canvas, dc );
 }
 
+bool wxPrintPreview::UpdatePageRendering()
+{
+    return m_pimpl->UpdatePageRendering();
+}
+
 bool wxPrintPreview::DrawBlankPage(wxPreviewCanvas *canvas, wxDC& dc)
 {
     return m_pimpl->DrawBlankPage( canvas, dc );