29#include <wx/printdlg.h>
30#include <wx/filename.h>
51 wxPreviewFrame( aPreview, aParent, aTitle )
55 bool Show(
bool show )
override
63 ret = wxPreviewFrame::Show( show );
72 s_pos = GetPosition();
74 ret = wxPreviewFrame::Show( show );
100 { wxID_APPLY,
_(
"Print Preview" ) },
101 { wxID_CANCEL,
_(
"Close" ) } } );
107#if defined(__WXGTK__)
114#if defined( _MSC_VER )
154 int minwidth = width;
158 for(
COLOR_SETTINGS* settings :
Pgm().GetSettingsManager().GetColorSettingsList() )
160 int pos =
m_colorTheme->Append( settings->GetName(),
static_cast<void*
>( settings ) );
162 if( settings->GetFilename() == target )
165 m_colorTheme->GetTextExtent( settings->GetName(), &width, &height );
166 minwidth = std::max( minwidth, width );
169 m_colorTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
175 wxPageSetupDialogData& pageSetupDialogData =
m_parent->GetPageSetupData();
177 pageSetupDialogData.SetPaperId( pageInfo.
GetPaperId() );
193 pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
209 long sel =
event.GetSelection();
242 wxPageSetupDialog pageSetupDialog(
this, &
m_parent->GetPageSetupData() );
243 pageSetupDialog.ShowModal();
245 m_parent->GetPageSetupData() = pageSetupDialog.GetPageSetupDialogData();
252 wxPrintData& prn_data =
m_parent->GetPageSetupData().GetPrintData();
254 wxString selectedPrinterName;
259 prn_data.SetPrinterName( selectedPrinterName );
262 wxString title =
_(
"Preview" );
266 preview->SetZoom( 100 );
273 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
281 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
287 frame->SetMinSize( wxSize( 650, 500 ) );
288 frame->SetSize( (
m_parent->GetSize() * 3) / 4 );
297 if(
Pgm().m_Printing )
299 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
325 wxFileName tmp = wxFileName::CreateTempFileName( wxS(
"eeschema_print" ) );
326 wxRemoveFile( tmp.GetFullPath() );
327 tmp.SetExt( wxS(
"pdf" ) );
349 int sheet_count =
m_parent->Schematic().Root().CountSheets();
351 wxPrintData& data =
m_parent->GetPageSetupData().GetPrintData();
353#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 2, 3 )
363 wxPaperSize paperId = data.GetPaperId();
365 bool havePaperType =
false;
368 std::set<wxPaperSize> letterSizes =
374 wxPAPER_LETTER_TRANSVERSE,
375 wxPAPER_LETTER_ROTATED
378 std::set<wxPaperSize> legalSizes =
384 std::set<wxPaperSize> a4Sizes =
389 wxPAPER_A4_TRANSVERSE,
394 if( letterSizes.count( paperId ) )
397 havePaperType =
true;
399 else if( legalSizes.count( paperId ) )
402 havePaperType =
true;
404 else if( a4Sizes.count( paperId ) )
407 havePaperType =
true;
412 PAGE_INFO pageInfo( paperType, data.GetOrientation() == wxPORTRAIT );
426 data.SetPaperId( wxPAPER_NONE );
430 wxString selectedPrinterName;
435 data.SetPrinterName( selectedPrinterName );
437 wxPrintDialogData printDialogData( data );
438 printDialogData.SetMaxPage( sheet_count );
440 if( sheet_count > 1 )
441 printDialogData.EnablePageNumbers(
true );
443 wxPrinter printer( &printDialogData );
448 if( !printer.Print(
this, &printout,
true ) )
450 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
451 DisplayError(
this,
_(
"An error occurred attempting to print the schematic." ) );
455 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.