33#include <wx/printdlg.h>
34#include <wx/filename.h>
55 const wxString& aTitle,
const wxPoint& aPos = wxDefaultPosition,
56 const wxSize& aSize = wxDefaultSize ) :
57 wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
61 bool Show(
bool show )
override
69 ret = wxPreviewFrame::Show( show );
78 s_pos = GetPosition();
80 ret = wxPreviewFrame::Show( show );
106 { wxID_APPLY,
_(
"Print Preview" ) },
107 { wxID_CANCEL,
_(
"Close" ) } } );
113#if defined(__WXGTK__)
120#if defined( _MSC_VER )
160 int minwidth = width;
166 int pos =
m_colorTheme->Append( settings->GetName(),
static_cast<void*
>( settings ) );
168 if( settings->GetFilename() == target )
171 m_colorTheme->GetTextExtent( settings->GetName(), &width, &height );
172 minwidth = std::max( minwidth, width );
175 m_colorTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
181 wxPageSetupDialogData& pageSetupDialogData =
m_parent->GetPageSetupData();
183 pageSetupDialogData.SetPaperId( pageInfo.
GetPaperId() );
199 pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
215 long sel =
event.GetSelection();
249 wxPageSetupDialog pageSetupDialog(
this, &
m_parent->GetPageSetupData() );
250 pageSetupDialog.ShowModal();
252 m_parent->GetPageSetupData() = pageSetupDialog.GetPageSetupDialogData();
259 wxPrintData& prn_data =
m_parent->GetPageSetupData().GetPrintData();
261 wxString selectedPrinterName;
266 prn_data.SetPrinterName( selectedPrinterName );
269 wxString title =
_(
"Preview" );
273 preview->SetZoom( 100 );
280 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
288 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
294 frame->SetMinSize( wxSize( 650, 500 ) );
295 frame->SetSize( (
m_parent->GetSize() * 3) / 4 );
304 if(
Pgm().m_Printing )
306 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
333 wxFileName tmp = wxFileName::CreateTempFileName( wxS(
"eeschema_print" ) );
334 wxRemoveFile( tmp.GetFullPath() );
335 tmp.SetExt( wxS(
"pdf" ) );
357 int sheet_count =
m_parent->Schematic().Root().CountSheets();
359 wxPrintData& data =
m_parent->GetPageSetupData().GetPrintData();
361#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 2, 3 )
371 wxPaperSize paperId = data.GetPaperId();
372 const wxChar* paperType =
nullptr;
375 std::set<wxPaperSize> letterSizes = {
380 wxPAPER_LETTER_TRANSVERSE,
381 wxPAPER_LETTER_ROTATED
384 std::set<wxPaperSize> legalSizes = {
389 std::set<wxPaperSize> a4Sizes = {
393 wxPAPER_A4_TRANSVERSE,
398 if( letterSizes.count( paperId ) )
399 paperType = PAGE_INFO::USLetter;
400 else if( legalSizes.count( paperId ) )
401 paperType = PAGE_INFO::USLegal;
402 else if( a4Sizes.count( paperId ) )
403 paperType = PAGE_INFO::A4;
407 PAGE_INFO pageInfo( paperType, data.GetOrientation() == wxPORTRAIT );
417 data.SetPaperId( wxPAPER_NONE );
421 wxString selectedPrinterName;
425 data.SetPrinterName( selectedPrinterName );
427 wxPrintDialogData printDialogData( data );
428 printDialogData.SetMaxPage( sheet_count );
430 if( sheet_count > 1 )
431 printDialogData.EnablePageNumbers(
true );
433 wxPrinter printer( &printDialogData );
438 if( !printer.Print(
this, &printout,
true ) )
440 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
441 DisplayError(
this,
_(
"An error occurred attempting to print the schematic." ) );
445 m_parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData();
static const ADVANCED_CFG & GetCfg()
Get the singleton instance's config, which is shared by all consumers.
wxString m_ColorTheme
Active color theme name.
Color settings are a bit different than most of the settings objects in that there can be more than o...
wxCheckBox * m_checkBackgroundColor
DIALOG_PRINT_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)
wxButton * m_sdbSizerApply
PANEL_PRINTER_LIST * m_panelPrinters
wxCheckBox * m_checkUseColorTheme
wxCheckBox * m_checkReference
void OnPrintPreview(wxCommandEvent &event) override
void OnPageSetup(wxCommandEvent &event) override
void OnOutputChoice(wxCommandEvent &event) override
bool TransferDataFromWindow() override
SCH_EDIT_FRAME * m_parent
DIALOG_PRINT(SCH_EDIT_FRAME *aParent)
void OnUseColorThemeChecked(wxCommandEvent &event) override
bool TransferDataToWindow() override
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...
wxString GetFilename() const
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.
Schematic editor (Eeschema) main window.
Schematic plotting class.
void Plot(PLOT_FORMAT aPlotFormat, const SCH_PLOT_OPTS &aPlotOpts, SCH_RENDER_SETTINGS *aRenderSettings, REPORTER *aReporter=nullptr)
Perform the plotting of the schematic using the given aPlotFormat and a\ aPlotSettings.
wxString GetLastOutputFilePath() const
Get the last output file path, this is mainly intended for PDFs with the open after plot GUI option.
Custom schematic print preview frame.
bool Show(bool show) override
SCH_PREVIEW_FRAME(wxPrintPreview *aPreview, wxWindow *aParent, const wxString &aTitle, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize)
Custom print out for printing schematics.
void LoadColors(const COLOR_SETTINGS *aSettings) override
void DisplayError(wxWindow *aParent, const wxString &aText)
Display an error or warning message box with aMessage.
This file is part of the common library.
KICOMMON_API int Mils2mm(double aVal)
Convert mils to mm.
SETTINGS_MANAGER * GetSettingsManager()
PGM_BASE & Pgm()
The global program "get" accessor.
COLOR_SETTINGS * GetColorSettings(const wxString &aName)
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
bool monochrome
Whether or not to print in monochrome.
bool background
Whether or not to print background color.
wxString color_theme
Color theme to use for printing.
bool title_block
Whether or not to print title block.
bool use_theme
If false, display color theme will be used.
bool m_useBackgroundColor
wxString result
Test unit parsing edge cases and error handling.