]> git.saurik.com Git - wxWidgets.git/commitdiff
Show progress of printing in wxMSW.
authorVáclav Slavík <vslavik@fastmail.fm>
Thu, 9 Aug 2012 15:52:15 +0000 (15:52 +0000)
committerVáclav Slavík <vslavik@fastmail.fm>
Thu, 9 Aug 2012 15:52:15 +0000 (15:52 +0000)
Add the number of the page being printed as well as the total to the
wxMSW printing progress window. Improved the layout and fixed some i18n
issues in the process.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@72308 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/prntbase.h
src/common/prntbase.cpp
src/msw/printwin.cpp

index 8ae728d004f476843ae3d8933aa1a7ba47a79516..3faa87fab6e3e4c9f249701b8bbca59547dc0c17 100644 (file)
@@ -41,6 +41,7 @@ class WXDLLIMPEXP_FWD_CORE wxPrintFactory;
 class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
 class WXDLLIMPEXP_FWD_CORE wxPrintPreview;
 class WXDLLIMPEXP_FWD_CORE wxPrintAbortDialog;
 class WXDLLIMPEXP_FWD_CORE wxPrintNativeDataBase;
 class WXDLLIMPEXP_FWD_CORE wxPrintPreview;
 class WXDLLIMPEXP_FWD_CORE wxPrintAbortDialog;
+class WXDLLIMPEXP_FWD_CORE wxStaticText;
 class wxPrintPageMaxCtrl;
 class wxPrintPageTextCtrl;
 
 class wxPrintPageMaxCtrl;
 class wxPrintPageTextCtrl;
 
@@ -740,9 +741,14 @@ public:
                        long style = wxDEFAULT_DIALOG_STYLE,
                        const wxString& name = wxT("dialog"));
 
                        long style = wxDEFAULT_DIALOG_STYLE,
                        const wxString& name = wxT("dialog"));
 
+    void SetProgress(int currentPage, int totalPages,
+                     int currentCopy, int totalCopies);
+
     void OnCancel(wxCommandEvent& event);
 
 private:
     void OnCancel(wxCommandEvent& event);
 
 private:
+    wxStaticText *m_progress;
+
     DECLARE_EVENT_TABLE()
     wxDECLARE_NO_COPY_CLASS(wxPrintAbortDialog);
 };
     DECLARE_EVENT_TABLE()
     wxDECLARE_NO_COPY_CLASS(wxPrintAbortDialog);
 };
index 02e37fb34e10391614298dfeb0d0812abd3b943d..c1467b1d837d20e8f4921e355cd81e794bb6186a 100644 (file)
@@ -518,15 +518,34 @@ wxPrintAbortDialog::wxPrintAbortDialog(wxWindow *parent,
                                        const wxString& name)
     : wxDialog(parent, wxID_ANY, _("Printing"), pos, size, style, name)
 {
                                        const wxString& name)
     : wxDialog(parent, wxID_ANY, _("Printing"), pos, size, style, name)
 {
-    wxBoxSizer *button_sizer = new wxBoxSizer(wxVERTICAL);
-    button_sizer->Add(new wxStaticText(this, wxID_ANY, _("Please wait while printing\n") + documentTitle), 0, wxALL, 10 );
-    button_sizer->Add(new wxButton(this, wxID_CANCEL, wxT("Cancel") ), 0, wxALL | wxALIGN_CENTER, 10);
-
-    SetAutoLayout(true);
-    SetSizer(button_sizer);
-
-    button_sizer->Fit(this);
-    button_sizer->SetSizeHints(this);
+    wxBoxSizer *mainSizer = new wxBoxSizer(wxVERTICAL);
+    mainSizer->Add(new wxStaticText(this, wxID_ANY, _("Please wait while printing...")),
+                   wxSizerFlags().Expand().DoubleBorder());
+
+    wxFlexGridSizer *gridSizer = new wxFlexGridSizer(2, wxSize(20, 0));
+    gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Document:")));
+    gridSizer->AddGrowableCol(1);
+    gridSizer->Add(new wxStaticText(this, wxID_ANY, documentTitle));
+    gridSizer->Add(new wxStaticText(this, wxID_ANY, _("Progress:")));
+    m_progress = new wxStaticText(this, wxID_ANY, _("Preparing"));
+    m_progress->SetMinSize(wxSize(250, -1));
+    gridSizer->Add(m_progress);
+    mainSizer->Add(gridSizer, wxSizerFlags().Expand().DoubleBorder(wxLEFT | wxRIGHT));
+
+    mainSizer->Add(CreateStdDialogButtonSizer(wxCANCEL),
+                   wxSizerFlags().Expand().DoubleBorder());
+
+    SetSizerAndFit(mainSizer);
+}
+
+void wxPrintAbortDialog::SetProgress(int currentPage, int totalPages,
+                                     int currentCopy, int totalCopies)
+{
+  wxString text;
+  text.Printf(_("Printing page %d of %d"), currentPage, totalPages);
+  if ( totalCopies > 1 )
+      text += wxString::Format(_(" (copy %d of %d)"), currentCopy, totalCopies);
+  m_progress->SetLabel(text);
 }
 
 void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
 }
 
 void wxPrintAbortDialog::OnCancel(wxCommandEvent& WXUNUSED(event))
index 3648192fc81900ccf418975f184cbe9729a7ec61..0c8a2ed6521397984245a0c38f0d57a7317d5c5f 100644 (file)
@@ -196,10 +196,8 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
         maxPageNum = m_printDialogData.GetToPage();
     }
 
         maxPageNum = m_printDialogData.GetToPage();
     }
 
-    int copyCount;
-    for ( copyCount = 1;
-          copyCount <= m_printDialogData.GetNoCopies();
-          copyCount++ )
+    const int maxCopyCount = m_printDialogData.GetNoCopies();
+    for ( int copyCount = 1; copyCount <= maxCopyCount; copyCount++ )
     {
         if ( !printout->OnBeginDocument(minPageNum, maxPageNum) )
         {
     {
         if ( !printout->OnBeginDocument(minPageNum, maxPageNum) )
         {
@@ -219,6 +217,10 @@ bool wxWindowsPrinter::Print(wxWindow *parent, wxPrintout *printout, bool prompt
               pn <= maxPageNum && printout->HasPage(pn);
               pn++ )
         {
               pn <= maxPageNum && printout->HasPage(pn);
               pn++ )
         {
+            win->SetProgress(pn - minPageNum + 1,
+                             maxPageNum - minPageNum + 1,
+                             copyCount, maxCopyCount);
+
             if ( sm_abortIt )
             {
                 sm_lastError = wxPRINTER_CANCELLED;
             if ( sm_abortIt )
             {
                 sm_lastError = wxPRINTER_CANCELLED;