28#include <wx/printdlg.h>
47 const wxString& aTitle,
const wxPoint& aPos = wxDefaultPosition,
48 const wxSize& aSize = wxDefaultSize ) :
49 wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
53 bool Show(
bool show )
override
61 ret = wxPreviewFrame::Show( show );
70 s_pos = GetPosition();
72 ret = wxPreviewFrame::Show( show );
91 m_settings( aSettings )
102 { wxID_APPLY,
_(
"Print Preview" ) },
103 { wxID_CANCEL,
_(
"Close" ) } } );
105#if defined(__WXMAC__) or defined(__WXGTK__)
170 "value.\nIt will be clamped to %f." ),
178 "value.\nIt will be clamped to %f." ),
185 wxFAIL_MSG( wxT(
"No scale option selected." ) );
192 wxASSERT( aValue >= 0.0 );
198 else if( aValue == 1.0 )
218 if( !wxDialog::TransferDataToWindow() )
235 pageSetupDialog.ShowModal();
237 (*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
238 (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
253 wxString selectedPrinterName;
258 s_PrintData->SetPrinterName( selectedPrinterName );
261 wxString title =
_(
"Print Preview" );
262 wxPrintPreview* preview =
265 preview->SetZoom( 100 );
272 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
280 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
286 frame->SetMinSize( wxSize( 650, 500 ) );
287 frame->SetSize( ( m_parent->GetSize() * 3 ) / 4 );
296 if(
Pgm().m_Printing )
298 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
311 wxString selectedPrinterName;
316 s_PrintData->SetPrinterName( selectedPrinterName );
321 wxPrinter printer( &printDialogData );
322 auto printout = std::unique_ptr<wxPrintout>(
createPrintout(
_(
"Print" ) ) );
327 if( !printer.Print(
this, printout.get(),
true ) )
329 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
334 *
s_PrintData = printer.GetPrintDialogData().GetPrintData();
346 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
372 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
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
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 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.