28#include <wx/printdlg.h>
45 const wxString& aTitle,
const wxPoint& aPos = wxDefaultPosition,
46 const wxSize& aSize = wxDefaultSize ) :
47 wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
51 bool Show(
bool show )
override
59 ret = wxPreviewFrame::Show( show );
68 s_pos = GetPosition();
70 ret = wxPreviewFrame::Show( show );
89 m_settings( aSettings )
97 { wxID_APPLY,
_(
"Print Preview" ) },
98 { wxID_CANCEL,
_(
"Close" ) } } );
100#if defined(__WXMAC__) or defined(__WXGTK__)
165 "value.\nIt will be clamped to %f." ),
173 "value.\nIt will be clamped to %f." ),
180 wxFAIL_MSG( wxT(
"No scale option selected." ) );
187 wxASSERT( aValue >= 0.0 );
193 else if( aValue == 1.0 )
213 if( !wxDialog::TransferDataToWindow() )
230 pageSetupDialog.ShowModal();
232 (*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
233 (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
249 wxString title =
_(
"Print Preview" );
250 wxPrintPreview* preview =
253 preview->SetZoom( 100 );
260 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
268 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
274 frame->SetMinSize( wxSize( 650, 500 ) );
275 frame->SetSize( ( m_parent->GetSize() * 3 ) / 4 );
284 if(
Pgm().m_Printing )
286 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
302 wxPrinter printer( &printDialogData );
303 auto printout = std::unique_ptr<wxPrintout>(
createPrintout(
_(
"Print" ) ) );
308 if( !printer.Print(
this, printout.get(),
true ) )
310 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
315 *
s_PrintData = printer.GetPrintDialogData().GetPrintData();
327 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
353 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
APP_SETTINGS_BASE * m_config
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
virtual ~DIALOG_PRINT_GENERIC()
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
wxFloatingPointValidator< double > m_scaleValidator
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 DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
void DisplayInfoMessage(wxWindow *aParent, const wxString &aMessage, const wxString &aExtraInfo)
Display an informational 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.
virtual void Save(APP_SETTINGS_BASE *aConfig)
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
virtual void Load(APP_SETTINGS_BASE *aConfig)
double m_scale
Printing scale.