29#include <wx/printdlg.h>
50 const wxPoint& aPos = wxDefaultPosition,
const wxSize& aSize = wxDefaultSize ) :
51 wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
55 bool Show(
bool show )
override
63 ret = wxPreviewFrame::Show( show );
72 s_pos = GetPosition();
74 ret = wxPreviewFrame::Show( show );
98 { wxID_APPLY,
_(
"Print Preview" ) },
99 { wxID_CANCEL,
_(
"Close" ) } } );
101#if defined(__WXMAC__) or defined(__WXGTK__)
154 "It will be clamped to %f." ),
scale ) );
161 "It will be clamped to %f." ),
scale ) );
167 wxFAIL_MSG( wxT(
"No scale option selected." ) );
174 wxASSERT( aValue >= 0.0 );
180 else if( aValue == 1.0 )
200 if( !wxDialog::TransferDataToWindow() )
214 pageSetupDialog.ShowModal();
216 (*s_printData ) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
217 (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
232 wxString selectedPrinterName;
237 s_printData->SetPrinterName( selectedPrinterName );
240 wxString title =
_(
"Print Preview" );
243 preview->SetZoom( 100 );
250 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
258 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
264 frame->SetMinSize( wxSize( 650, 500 ) );
265 frame->SetSize( ( m_parent->GetSize() * 3 ) / 4 );
274 if(
Pgm().m_Printing )
276 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
289 wxString selectedPrinterName;
294 s_printData->SetPrinterName( selectedPrinterName );
297 printDialogData.SetMaxPage(
m_settings->m_pageCount );
299 wxPrinter printer( &printDialogData );
300 auto printout = std::unique_ptr<wxPrintout>(
createPrintout(
_(
"Print" ) ) );
305 if( !printer.Print(
this, printout.get(),
true ) )
307 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
312 *
s_printData = printer.GetPrintDialogData().GetPrintData();
325 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
351 DisplayError(
this,
_(
"An error occurred initializing the printer information." ) );
wxTextCtrl * m_scaleCustomText
wxButton * m_sdbSizer1Apply
DIALOG_PRINT_GENERIC_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Print"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
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
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 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.