33#include <wx/printdlg.h>
34#include <wx/filename.h>
55 wxPreviewFrame( aPreview, aParent, aTitle )
59 bool Show(
bool show )
override
67 ret = wxPreviewFrame::Show( show );
76 s_pos = GetPosition();
78 ret = wxPreviewFrame::Show( show );
104 { wxID_APPLY,
_(
"Print Preview" ) },
105 { wxID_CANCEL,
_(
"Close" ) } } );
111#if defined(__WXGTK__)
118#if defined( _MSC_VER )
158 int minwidth = width;
162 for(
COLOR_SETTINGS* settings :
Pgm().GetSettingsManager().GetColorSettingsList() )
164 int pos =
m_colorTheme->Append( settings->GetName(),
static_cast<void*
>( settings ) );
166 if( settings->GetFilename() == target )
169 m_colorTheme->GetTextExtent( settings->GetName(), &width, &height );
170 minwidth = std::max( minwidth, width );
173 m_colorTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
179 wxPageSetupDialogData& pageSetupDialogData =
m_parent->GetPageSetupData();
181 pageSetupDialogData.SetPaperId( pageInfo.
GetPaperId() );
197 pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
213 long sel =
event.GetSelection();
246 wxPageSetupDialog pageSetupDialog(
this, &
m_parent->GetPageSetupData() );
247 pageSetupDialog.ShowModal();
249 m_parent->GetPageSetupData() = pageSetupDialog.GetPageSetupDialogData();
256 wxPrintData& prn_data =
m_parent->GetPageSetupData().GetPrintData();
258 wxString selectedPrinterName;
263 prn_data.SetPrinterName( selectedPrinterName );
266 wxString title =
_(
"Preview" );
270 preview->SetZoom( 100 );
277 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
285 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
291 frame->SetMinSize( wxSize( 650, 500 ) );
292 frame->SetSize( (
m_parent->GetSize() * 3) / 4 );
301 if(
Pgm().m_Printing )
303 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
329 wxFileName tmp = wxFileName::CreateTempFileName( wxS(
"eeschema_print" ) );
330 wxRemoveFile( tmp.GetFullPath() );
331 tmp.SetExt( wxS(
"pdf" ) );
353 int sheet_count =
m_parent->Schematic().Root().CountSheets();
355 wxPrintData& data =
m_parent->GetPageSetupData().GetPrintData();
357#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 2, 3 )
367 wxPaperSize paperId = data.GetPaperId();
369 bool havePaperType =
false;
372 std::set<wxPaperSize> letterSizes =
378 wxPAPER_LETTER_TRANSVERSE,
379 wxPAPER_LETTER_ROTATED
382 std::set<wxPaperSize> legalSizes =
388 std::set<wxPaperSize> a4Sizes =
393 wxPAPER_A4_TRANSVERSE,
398 if( letterSizes.count( paperId ) )
401 havePaperType =
true;
403 else if( legalSizes.count( paperId ) )
406 havePaperType =
true;
408 else if( a4Sizes.count( paperId ) )
411 havePaperType =
true;
416 PAGE_INFO pageInfo( paperType, data.GetOrientation() == wxPORTRAIT );
430 data.SetPaperId( wxPAPER_NONE );
434 wxString selectedPrinterName;
439 data.SetPrinterName( selectedPrinterName );
441 wxPrintDialogData printDialogData( data );
442 printDialogData.SetMaxPage( sheet_count );
444 if( sheet_count > 1 )
445 printDialogData.EnablePageNumbers(
true );
447 wxPrinter printer( &printDialogData );
452 if( !printer.Print(
this, &printout,
true ) )
454 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
455 DisplayError(
this,
_(
"An error occurred attempting to print the schematic." ) );
459 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.
SCH_PREVIEW_FRAME(wxPrintPreview *aPreview, wxWindow *aParent, const wxString &aTitle)
bool Show(bool show) override
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.
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.