29#include <wx/printdlg.h>
30#include <wx/filename.h>
53 wxPreviewFrame( aPreview, aParent, aTitle )
57 bool Show(
bool show )
override
65 ret = wxPreviewFrame::Show( show );
74 s_pos = GetPosition();
76 ret = wxPreviewFrame::Show( show );
102 { wxID_APPLY,
_(
"Print Preview" ) },
103 { wxID_CANCEL,
_(
"Close" ) } } );
109#if defined(__WXGTK__)
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." ) );
314 int sheet_count =
m_parent->Schematic().Root().CountSheets();
316 wxPrintData& data =
m_parent->GetPageSetupData().GetPrintData();
318#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 2, 3 )
328 wxPaperSize paperId = data.GetPaperId();
330 bool havePaperType =
false;
333 std::set<wxPaperSize> letterSizes =
339 wxPAPER_LETTER_TRANSVERSE,
340 wxPAPER_LETTER_ROTATED
343 std::set<wxPaperSize> legalSizes =
349 std::set<wxPaperSize> a4Sizes =
354 wxPAPER_A4_TRANSVERSE,
359 if( letterSizes.count( paperId ) )
362 havePaperType =
true;
364 else if( legalSizes.count( paperId ) )
367 havePaperType =
true;
369 else if( a4Sizes.count( paperId ) )
372 havePaperType =
true;
377 PAGE_INFO pageInfo( paperType, data.GetOrientation() == wxPORTRAIT );
391 data.SetPaperId( wxPAPER_NONE );
395 wxString selectedPrinterName;
400 data.SetPrinterName( selectedPrinterName );
402 wxPrintDialogData printDialogData( data );
403 printDialogData.SetMaxPage( sheet_count );
405 if( sheet_count > 1 )
406 printDialogData.EnablePageNumbers(
true );
408 wxPrinter printer( &printDialogData );
413 if( !printer.Print(
this, &printout,
true ) )
415 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
416 DisplayError(
this,
_(
"An error occurred attempting to print the schematic." ) );
420 m_parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData();
453 wxString jobName = wxFileName(
m_parent->Schematic().GetFileName() ).GetName();
455 if( !tmpDir.
MakeDirectory( wxS(
"eeschema_print" ), wxS_IRUSR | wxS_IWUSR | wxS_IXUSR ) )
457 DisplayError(
this,
_(
"Failed to create a temporary folder for printing." ) );
461 wxFileName tmp( tmpDir.
Path(), jobName.IsEmpty() ? wxString( wxS(
"schematic" ) ) : jobName, wxS(
"pdf" ) );
469 auto sheetIt = std::find( sheets.begin(), sheets.end(),
m_parent->GetCurrentSheet() );
470 int currentPage = sheetIt == sheets.end() ? 0 :
static_cast<int>( sheetIt - sheets.begin() ) + 1;
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...
wxButton * m_buttonPageSetup
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.
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
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void SortByHierarchicalPageNumbers(bool aUpdateVirtualPageNums=true)
This works like SortByPageNumbers, but it sorts the sheets first by their hierarchical depth and then...
void BuildSheetList(SCH_SHEET *aSheet, bool aCheckIntegrity)
Build the list of sheets and their sheet path from aSheet.
A temporary file or directory that is removed when the object goes out of scope.
bool MakeDirectory(const wxString &aPrefix, int aPermissions=wxS_DIR_DEFAULT)
Create an empty directory with a unique name after aPrefix.
const wxString & Path() const
A wrapper for reporting to a wxString object.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
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
IbisParser parser & reporter
wxString result
Test unit parsing edge cases and error handling.