Allow configuring showing printing dialog in wxHtmlEasyPrinting
Add wxHtmlEasyPrinting::SetPromptMode() to allow suppressing the "prompt" shown by wxPrinter::Print() when it's called from this class code. Closes https://github.com/wxWidgets/wxWidgets/pull/838
This commit is contained in:
@@ -88,6 +88,7 @@ All (GUI):
|
||||
- Fix bug with missing items in overflowing AUI toolbar (Maarten Bent).
|
||||
- Revert to left-aligning wxSpinCtrl contents by default.
|
||||
- Make wxRibbonButtonBar buttons more customizable (Max Maisel).
|
||||
- Add wxHtmlEasyPrinting::SetPromptMode() (pavel-t).
|
||||
|
||||
wxGTK:
|
||||
|
||||
|
@@ -273,6 +273,16 @@ public:
|
||||
void SetName(const wxString& name) { m_Name = name; }
|
||||
// set the printout name
|
||||
|
||||
// Controls showing the dialog when printing: by default, always shown.
|
||||
enum PromptMode
|
||||
{
|
||||
Prompt_Never,
|
||||
Prompt_Once,
|
||||
Prompt_Always
|
||||
};
|
||||
|
||||
void SetPromptMode(PromptMode promptMode) { m_promptMode = promptMode; }
|
||||
|
||||
protected:
|
||||
virtual wxHtmlPrintout *CreatePrintout();
|
||||
virtual bool DoPreview(wxHtmlPrintout *printout1, wxHtmlPrintout *printout2);
|
||||
@@ -296,6 +306,8 @@ private:
|
||||
wxString m_Headers[2], m_Footers[2];
|
||||
wxWindow *m_ParentWindow;
|
||||
|
||||
PromptMode m_promptMode;
|
||||
|
||||
wxDECLARE_NO_COPY_CLASS(wxHtmlEasyPrinting);
|
||||
};
|
||||
|
||||
|
@@ -340,6 +340,32 @@ public:
|
||||
*/
|
||||
void SetParentWindow(wxWindow* window);
|
||||
|
||||
/**
|
||||
Controls when the print dialog should be shown.
|
||||
|
||||
@see SetPromptMode()
|
||||
|
||||
@since 3.1.2
|
||||
*/
|
||||
enum PromptMode
|
||||
{
|
||||
Prompt_Never, //!< Do not show the print dialog.
|
||||
Prompt_Once, //!< Show the print dialog only the first time.
|
||||
Prompt_Always //!< Show the print dialog every time (default value).
|
||||
};
|
||||
|
||||
/**
|
||||
Enable or disable showing the dialog before printing.
|
||||
|
||||
The prompt mode determines the value of the @c prompt parameter passed
|
||||
to wxPrinter::Print() when it is called by this class.
|
||||
|
||||
Default prompt mode value is Prompt_Always.
|
||||
|
||||
@since 3.1.2
|
||||
*/
|
||||
void SetPromptMode(PromptMode promptMode);
|
||||
|
||||
private:
|
||||
/**
|
||||
Check whether the document fits into the page area.
|
||||
|
@@ -619,6 +619,8 @@ wxHtmlEasyPrinting::wxHtmlEasyPrinting(const wxString& name, wxWindow *parentWin
|
||||
m_PageSetupData->SetMarginBottomRight(wxPoint(25, 25));
|
||||
|
||||
SetStandardFonts(DEFAULT_PRINT_FONT_SIZE);
|
||||
|
||||
m_promptMode = Prompt_Always;
|
||||
}
|
||||
|
||||
|
||||
@@ -709,7 +711,13 @@ bool wxHtmlEasyPrinting::DoPrint(wxHtmlPrintout *printout)
|
||||
wxPrintDialogData printDialogData(*GetPrintData());
|
||||
wxPrinter printer(&printDialogData);
|
||||
|
||||
if (!printer.Print(m_ParentWindow, printout, true))
|
||||
const bool prompt = m_promptMode != Prompt_Never;
|
||||
if (m_promptMode == Prompt_Once)
|
||||
{
|
||||
m_promptMode = Prompt_Never;
|
||||
}
|
||||
|
||||
if (!printer.Print(m_ParentWindow, printout, prompt))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
Reference in New Issue
Block a user