From 148d83b59f6b0ad0d436305bdcb5c83489b19694 Mon Sep 17 00:00:00 2001 From: Julian Smart Date: Sun, 18 Mar 2012 23:25:39 +0000 Subject: [PATCH] Added a parameter to PrintBuffer and PrintFile to allow silent or prompted printing. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@70939 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/richtext/richtextprint.h | 6 +++--- interface/wx/richtext/richtextprint.h | 8 +++++--- src/richtext/richtextprint.cpp | 12 ++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/include/wx/richtext/richtextprint.h b/include/wx/richtext/richtextprint.h index cba26f9091..8ca2e80bb3 100644 --- a/include/wx/richtext/richtextprint.h +++ b/include/wx/richtext/richtextprint.h @@ -169,8 +169,8 @@ public: bool PreviewBuffer(const wxRichTextBuffer& buffer); /// Print the file or buffer - bool PrintFile(const wxString& richTextFile); - bool PrintBuffer(const wxRichTextBuffer& buffer); + bool PrintFile(const wxString& richTextFile, bool showPrintDialog = true); + bool PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog = true); /// Shows page setup dialog void PageSetup(); @@ -226,7 +226,7 @@ public: protected: virtual wxRichTextPrintout *CreatePrintout(); virtual bool DoPreview(wxRichTextPrintout *printout1, wxRichTextPrintout *printout2); - virtual bool DoPrint(wxRichTextPrintout *printout); + virtual bool DoPrint(wxRichTextPrintout *printout, bool showPrintDialog); private: wxPrintData* m_printData; diff --git a/interface/wx/richtext/richtextprint.h b/interface/wx/richtext/richtextprint.h index 9a6c185c8c..5a756e5028 100644 --- a/interface/wx/richtext/richtextprint.h +++ b/interface/wx/richtext/richtextprint.h @@ -341,14 +341,16 @@ public: /** Prints the given buffer. The function takes its own copy of @a buffer. + @showPrintDialog can be @true to show the print dialog, or @false to print quietly. */ - bool PrintBuffer(const wxRichTextBuffer& buffer); + bool PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog = true); /** Prints the given file. @a richTextFile can be a text file or XML file, - or other file depending on the available file handlers. + or other file depending on the available file handlers. @showPrintDialog + can be @true to show the print dialog, or @false to print quietly. */ - bool PrintFile(const wxString& richTextFile); + bool PrintFile(const wxString& richTextFile, bool showPrintDialog = true); /** A convenience function to set the footer text. diff --git a/src/richtext/richtextprint.cpp b/src/richtext/richtextprint.cpp index b491ac947b..cc4714cdd3 100644 --- a/src/richtext/richtextprint.cpp +++ b/src/richtext/richtextprint.cpp @@ -537,7 +537,7 @@ bool wxRichTextPrinting::PreviewBuffer(const wxRichTextBuffer& buffer) return DoPreview(p1, p2); } -bool wxRichTextPrinting::PrintFile(const wxString& richTextFile) +bool wxRichTextPrinting::PrintFile(const wxString& richTextFile, bool showPrintDialog) { SetRichTextBufferPrinting(new wxRichTextBuffer); @@ -550,19 +550,19 @@ bool wxRichTextPrinting::PrintFile(const wxString& richTextFile) wxRichTextPrintout *p = CreatePrintout(); p->SetRichTextBuffer(m_richTextBufferPrinting); - bool ret = DoPrint(p); + bool ret = DoPrint(p, showPrintDialog); delete p; return ret; } -bool wxRichTextPrinting::PrintBuffer(const wxRichTextBuffer& buffer) +bool wxRichTextPrinting::PrintBuffer(const wxRichTextBuffer& buffer, bool showPrintDialog) { SetRichTextBufferPrinting(new wxRichTextBuffer(buffer)); wxRichTextPrintout *p = CreatePrintout(); p->SetRichTextBuffer(m_richTextBufferPrinting); - bool ret = DoPrint(p); + bool ret = DoPrint(p, showPrintDialog); delete p; return ret; } @@ -587,12 +587,12 @@ bool wxRichTextPrinting::DoPreview(wxRichTextPrintout *printout1, wxRichTextPrin return true; } -bool wxRichTextPrinting::DoPrint(wxRichTextPrintout *printout) +bool wxRichTextPrinting::DoPrint(wxRichTextPrintout *printout, bool showPrintDialog) { wxPrintDialogData printDialogData(*GetPrintData()); wxPrinter printer(&printDialogData); - if (!printer.Print(m_parentWindow, printout, true)) + if (!printer.Print(m_parentWindow, printout, showPrintDialog)) { return false; }