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__)
165 " Clamped to %f" ),
scale ) );
173 " Clamped to %f" ),
scale ) );
179 wxCHECK(
false, 1.0 );
185 wxASSERT( aValue >= 0.0 );
191 else if( aValue == 1.0 )
211 if( !wxDialog::TransferDataToWindow() )
228 pageSetupDialog.ShowModal();
230 (*s_PrintData) = pageSetupDialog.GetPageSetupDialogData().GetPrintData();
231 (*s_pageSetupData) = pageSetupDialog.GetPageSetupDialogData();
247 wxString title =
_(
"Print Preview" );
248 wxPrintPreview* preview =
251 preview->SetZoom( 100 );
258 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
266 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
272 frame->SetMinSize( wxSize( 650, 500 ) );
273 frame->SetSize( (m_parent->GetSize() * 3) / 4 );
282 if(
Pgm().m_Printing )
284 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
300 wxPrinter printer( &printDialogData );
301 auto printout = std::unique_ptr<wxPrintout>(
createPrintout(
_(
"Print" ) ) );
303 Pgm().m_Printing =
true;
306 if( !printer.Print(
this, printout.get(),
true ) )
308 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
313 *
s_PrintData = printer.GetPrintDialogData().GetPrintData();
317 Pgm().m_Printing =
false;
325 wxPostEvent(
this, wxCommandEvent( wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL ) );
351 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
int GetHeightMils() const
wxPaperSize GetPaperId() const
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
int Mils2mm(double aVal)
Convert mils to mm.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
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.