28#include <wx/printdlg.h>
49 const wxPoint& aPos = wxDefaultPosition,
const wxSize& aSize = wxDefaultSize ) :
50 wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
54 bool Show(
bool show )
override
62 ret = wxPreviewFrame::Show( show );
71 s_pos = GetPosition();
73 ret = wxPreviewFrame::Show( show );
91 m_settings( aSettings )
97 { wxID_APPLY,
_(
"Print Preview" ) },
98 { wxID_CANCEL,
_(
"Close" ) } } );
100#if defined(__WXMAC__) or defined(__WXGTK__)
153 "It will be clamped to %f." ),
scale ) );
160 "It will be clamped to %f." ),
scale ) );
166 wxFAIL_MSG( wxT(
"No scale option selected." ) );
173 wxASSERT( aValue >= 0.0 );
179 else if( aValue == 1.0 )
199 if( !wxDialog::TransferDataToWindow() )
213 pageSetupDialog.ShowModal();
215 (*s_printData ) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
216 (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
231 wxString selectedPrinterName;
236 s_printData->SetPrinterName( selectedPrinterName );
239 wxString title =
_(
"Print Preview" );
242 preview->SetZoom( 100 );
249 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
257 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
263 frame->SetMinSize( wxSize( 650, 500 ) );
264 frame->SetSize( ( m_parent->GetSize() * 3 ) / 4 );
273 if(
Pgm().m_Printing )
275 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
288 wxString selectedPrinterName;
293 s_printData->SetPrinterName( selectedPrinterName );
298 wxPrinter printer( &printDialogData );
299 auto printout = std::unique_ptr<wxPrintout>(
createPrintout(
_(
"Print" ) ) );
304 if( !printer.Print(
this, printout.get(),
true ) )
306 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
311 *
s_printData = printer.GetPrintDialogData().GetPrintData();
323 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
349 DisplayError(
this,
_(
"An error occurred initializing the printer information." ) );
Class DIALOG_PRINT_GENERIC_BASE.
wxTextCtrl * m_scaleCustomText
wxButton * m_sdbSizer1Apply
wxCheckBox * m_titleBlock
wxRadioButton * m_scaleFit
wxRadioButton * m_scaleCustom
PANEL_PRINTER_LIST * m_panelPrinters
DIALOG_PRINT_GENERIC(EDA_DRAW_FRAME *aParent, PRINTOUT_SETTINGS *aSettings)
void onClose(wxCloseEvent &event) override
void setScaleValue(double aValue)
Select a corresponding scale radio button and update custom scale value if needed.
void onSetCustomScale(wxCommandEvent &event) override
static wxPrintData * s_printData
void onCancelButtonClick(wxCommandEvent &aEvent) override
virtual wxPrintout * createPrintout(const wxString &aTitle)=0
Create a printout with a requested title.
bool TransferDataToWindow() override
void onPageSetup(wxCommandEvent &event) override
double getScaleValue()
Return scale value selected in the dialog.
virtual void saveSettings()
void onPrintButtonClick(wxCommandEvent &event) override
void ForcePrintBorder(bool aValue)
Set 'print border and title block' to a requested value and hides the corresponding checkbox.
static wxPageSetupDialogData * s_pageSetupData
void onPrintPreview(wxCommandEvent &event) override
PRINTOUT_SETTINGS * m_settings
void SetupStandardButtons(std::map< int, wxString > aLabels={})
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
The base class for create windows for drawing purpose.
Custom print preview frame.
bool Show(bool show) override
KI_PREVIEW_FRAME(wxPrintPreview *aPreview, wxWindow *aParent, const wxString &aTitle, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize)
Describe the page size and margins of a paper page on which to eventually print or plot.
wxPrintOrientation GetWxOrientation() const
double GetHeightMils() const
wxPaperSize GetPaperId() const
double GetWidthMils() const
wxString GetSelectedPrinterName()
bool AsPrintersAvailable()
bool m_Printing
wxWidgets on MSW tends to crash if you spool up more than one print job at a time.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational message box with aMessage.
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
static constexpr double MAX_SCALE
static constexpr double MIN_SCALE
KICOMMON_API int Mils2mm(double aVal)
Convert mils to mm.
PGM_BASE & Pgm()
The global program "get" accessor.
Handle the parameters used to print a board drawing.
bool m_titleBlock
Print frame and title block.
bool m_blackWhite
Print in B&W or Color.
int m_pageCount
Number of pages to print.
const PAGE_INFO & m_pageInfo
double m_scale
Printing scale.