]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/printps.cpp
removed 2nd frame from html test sample; test sample now shows DL,DT,DD support
[wxWidgets.git] / src / generic / printps.cpp
index 389fb5c7e152b395cdf08e4c0ff5298a650f2cce..0e994766b9cb1e8daa4ff739786754f5209b0dc6 100644 (file)
 
 #include "wx/defs.h"
 
+#if wxUSE_PRINTING_ARCHITECTURE
+
 #ifndef WX_PRECOMP
     #include "wx/utils.h"
     #include "wx/dc.h"
     #include "wx/app.h"
     #include "wx/msgdlg.h"
-    #include <wx/intl.h>
+    #include "wx/intl.h"
+    #include "wx/progdlg.h"
 #endif
 
 #include "wx/generic/printps.h"
 #include "wx/dcprint.h"
 #include "wx/printdlg.h"
 #include "wx/generic/prntdlgg.h"
+#include "wx/generic/progdlgg.h"
 #include "wx/paper.h"
 
 #include <stdlib.h>
 // wxWin macros
 // ----------------------------------------------------------------------------
 
-#if !USE_SHARED_LIBRARY
     IMPLEMENT_DYNAMIC_CLASS(wxPostScriptPrinter, wxPrinterBase)
     IMPLEMENT_CLASS(wxPostScriptPrintPreview, wxPrintPreviewBase)
-#endif
 
 // ============================================================================
 // implementation
@@ -81,7 +83,12 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
         return FALSE;
 
     printout->SetIsPreview(FALSE);
-    printout->OnPreparePrinting();
+
+    // 4/9/99, JACS: this is a silly place to allow preparation, considering
+    // the DC and no parameters have been set in the printout object.
+    // Moved further down.
+
+    // printout->OnPreparePrinting();
 
     // Get some parameters from the printout, if defined
     int fromPage, toPage;
@@ -113,6 +120,7 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
     else
         m_printDialogData.EnablePageNumbers(FALSE);
 
+
     // Create a suitable device context
     wxDC *dc = (wxDC *) NULL;
     if (prompt)
@@ -165,6 +173,20 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
     // Create an abort window
     wxBeginBusyCursor();
 
+    printout->OnPreparePrinting();
+
+    int
+       pagesPerCopy = m_printDialogData.GetToPage()-m_printDialogData.GetFromPage()+1,
+       totalPages = pagesPerCopy * m_printDialogData.GetNoCopies(),
+       printedPages = 0;
+    // Open the progress bar dialog
+    wxProgressDialog *progressDialog = new wxProgressDialog (
+       printout->GetTitle(),
+       _("Printing..."),
+       totalPages,
+       parent,
+       wxPD_CAN_ABORT|wxPD_AUTO_HIDE|wxPD_APP_MODAL);
+
     printout->OnBeginPrinting();
 
     bool keepGoing = TRUE;
@@ -192,15 +214,27 @@ bool wxPostScriptPrinter::Print(wxWindow *parent, wxPrintout *printout, bool pro
             }
             else
             {
-                dc->StartPage();
-                printout->OnPrintPage(pn);
-                dc->EndPage();
+               wxString msg;
+               msg.Printf(_("Printing page %d..."), printedPages+1);
+               if(progressDialog->Update(printedPages++, msg))
+               {
+                  dc->StartPage();
+                  printout->OnPrintPage(pn);
+                  dc->EndPage();
+               }
+               else
+               {
+                  sm_abortIt = TRUE;
+                  keepGoing = FALSE;
+               }
             }
+           wxYield();
         }
         printout->OnEndDocument();
     }
 
     printout->OnEndPrinting();
+    delete progressDialog;
 
     wxEndBusyCursor();
 
@@ -321,3 +355,4 @@ void wxPostScriptPrintPreview::DetermineScaling()
     }
 }
 
+#endif