28#include <wx/printdlg.h>
44 const wxString& aTitle,
const wxPoint& aPos = wxDefaultPosition,
45 const wxSize& aSize = wxDefaultSize ) :
46 wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
50 bool Show(
bool show )
override
58 ret = wxPreviewFrame::Show( show );
67 s_pos = GetPosition();
69 ret = wxPreviewFrame::Show( show );
88 m_settings( aSettings )
96 { wxID_APPLY,
_(
"Print Preview" ) },
97 { wxID_CANCEL,
_(
"Close" ) } } );
99#if defined(__WXMAC__) or defined(__WXGTK__)
164 "value.\nIt will be clamped to %f." ),
172 "value.\nIt will be clamped to %f." ),
179 wxFAIL_MSG( wxT(
"No scale option selected." ) );
186 wxASSERT( aValue >= 0.0 );
192 else if( aValue == 1.0 )
212 if( !wxDialog::TransferDataToWindow() )
229 pageSetupDialog.ShowModal();
231 (*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
232 (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
248 wxString title =
_(
"Print Preview" );
249 wxPrintPreview* preview =
252 preview->SetZoom( 100 );
259 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
267 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
273 frame->SetMinSize( wxSize( 650, 500 ) );
274 frame->SetSize( (m_parent->GetSize() * 3) / 4 );
283 if(
Pgm().m_Printing )
285 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
301 wxPrinter printer( &printDialogData );
302 auto printout = std::unique_ptr<wxPrintout>(
createPrintout(
_(
"Print" ) ) );
307 if( !printer.Print(
this, printout.get(),
true ) )
309 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
314 *
s_PrintData = printer.GetPrintDialogData().GetPrintData();
326 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
352 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.