39#include <wx/printdlg.h>
75 wxASSERT( aParent !=
nullptr );
80 bool HasPage(
int page )
override;
82 void GetPageInfo(
int* minPage,
int* maxPage,
int* selPageFrom,
int* selPageTo )
override;
98 const wxString& aTitle,
const wxPoint& aPos = wxDefaultPosition,
99 const wxSize& aSize = wxDefaultSize ) :
100 wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
104 bool Show(
bool show )
override
112 ret = wxPreviewFrame::Show( show );
121 s_pos = GetPosition();
123 ret = wxPreviewFrame::Show( show );
146 { wxID_APPLY,
_(
"Print Preview" ) },
147 { wxID_CANCEL,
_(
"Close" ) } } );
185 int minwidth = width;
191 int pos =
m_colorTheme->Append( settings->GetName(),
static_cast<void*
>( settings ) );
193 if( settings->GetFilename() == target )
196 m_colorTheme->GetTextExtent( settings->GetName(), &width, &height );
197 minwidth = std::max( minwidth, width );
200 m_colorTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
208 pageSetupDialogData.SetPaperId( pageInfo.
GetPaperId() );
220 pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
236 long sel =
event.GetSelection();
271 pageSetupDialog.ShowModal();
282 wxString title =
_(
"Preview" );
287 preview->SetZoom( 100 );
294 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
302 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
308 frame->SetMinSize( wxSize( 650, 500 ) );
309 frame->SetSize( (
m_parent->GetSize() * 3) / 4 );
318 if(
Pgm().m_Printing )
320 DisplayError(
this,
_(
"Previous print job not yet complete." ) );
329 printDialogData.SetMaxPage( sheet_count );
331 if( sheet_count > 1 )
332 printDialogData.EnablePageNumbers(
true );
334 wxPrinter printer( &printDialogData );
337 Pgm().m_Printing =
true;
339 if( !printer.Print(
this, &printout,
true ) )
341 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
342 DisplayError(
this,
_(
"An error occurred attempting to print the schematic." ) );
350 Pgm().m_Printing =
false;
360 wxCHECK_MSG( page >= 1 && page <= (
int)sheetList.size(),
false,
361 wxT(
"Cannot print invalid page number." ) );
363 wxCHECK_MSG( sheetList[ page - 1].LastScreen() !=
nullptr,
false,
364 wxT(
"Cannot print page with NULL screen." ) );
367 msg.Printf(
_(
"Print page %d" ), page );
387 *minPage = *selPageFrom = 1;
400 if( !wxPrintout::OnBeginDocument( startPage, endPage ) )
437 FitThisSizeToPaper( pageSizeIU );
439 fitRect = GetLogicalPaperRect();
444 int xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
445 int yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
449 if( dc->CanUseTransformMatrix() )
451 wxAffineMatrix2D matrix;
454 if( ( fitRect.width > fitRect.height ) != ( pageSizeIU.x > pageSizeIU.y ) )
458 matrix.Translate( 0, -pageSizeIU.y );
461 std::swap( pageSizeIU.x, pageSizeIU.y );
462 FitThisSizeToPaper( pageSizeIU );
463 fitRect = GetLogicalPaperRect();
465 xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
466 yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
470 std::swap( xoffset, yoffset );
474 matrix.Translate( xoffset, yoffset );
475 dc->SetTransformMatrix( matrix );
479 SetLogicalOrigin( 0, 0 );
481 OffsetLogicalOrigin( xoffset, yoffset );
484 dc->SetLogicalFunction( wxCOPY );
502 GRSFilledRect( dc, fitRect.GetX(), fitRect.GetY(), fitRect.GetRight(), fitRect.GetBottom(), 0,
531 aScreen->
Print( &renderSettings );
546 return dlg.ShowModal();
constexpr EDA_IU_SCALE schIUScale
wxString m_ColorTheme
Active color theme name.
VECTOR2I m_DrawOrg
offsets for drawing the circuit on the screen
VECTOR2I m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
Color settings are a bit different than most of the settings objects in that there can be more than o...
COLOR4D GetColor(int aLayer) const
Class DIALOG_PRINT_USING_PRINTER_BASE.
wxCheckBox * m_checkReference
wxButton * m_sdbSizer1Apply
wxCheckBox * m_checkBackgroundColor
wxCheckBox * m_checkUseColorTheme
void OnPrintPreview(wxCommandEvent &event) override
DIALOG_PRINT_USING_PRINTER(SCH_EDIT_FRAME *aParent)
void OnUseColorThemeChecked(wxCommandEvent &event) override
bool TransferDataToWindow() override
~DIALOG_PRINT_USING_PRINTER() override
bool TransferDataFromWindow() override
void OnPageSetup(wxCommandEvent &event) override
SCH_EDIT_FRAME * m_parent
void OnOutputChoice(wxCommandEvent &event) 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...
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
virtual void SetDrawBgColor(const COLOR4D &aColor)
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, const std::map< wxString, wxString > *aProperties, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
wxString GetFilename() const
A color representation with 4 components: red, green, blue, alpha.
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
void SetDefaultFont(const wxString &aFont)
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
void SetPrintDC(wxDC *aDC)
void SetIsPrinting(bool isPrinting)
Store schematic specific render settings.
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
void LoadColors(const COLOR_SETTINGS *aSettings) override
Describe the page size and margins of a paper page on which to eventually print or plot.
wxPrintOrientation GetWxOrientation() const
const VECTOR2I GetSizeIU(double aIUScale) const
Gets the page size in internal units.
int GetHeightMils() const
wxPaperSize GetPaperId() const
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
const std::map< wxString, wxString > * GetProperties()
EESCHEMA_SETTINGS * eeconfig() const
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
COLOR_SETTINGS * GetColorSettings(bool aForceRefresh=false) const override
Returns a pointer to the active color theme settings.
COLOR4D GetDrawBgColor() const override
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
wxPageSetupDialogData & GetPageSetupData()
SCH_SHEET_PATH & GetCurrentSheet() const
SCHEMATIC & Schematic() const
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
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.
bool HasPage(int page) override
bool OnPrintPage(int page) override
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) override
SCH_PRINTOUT(SCH_EDIT_FRAME *aParent, const wxString &aTitle)
SCH_EDIT_FRAME * m_parent
void PrintPage(SCH_SCREEN *aScreen)
bool OnBeginDocument(int startPage, int endPage) override
const PAGE_INFO & GetPageSettings() const
void Print(const RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
const wxString & GetFileName() const
SCHEMATIC * Schematic() const
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
void UpdateAllScreenReferences() const
Update all the symbol references for this sheet path.
SCH_SCREEN * LastScreen()
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
This file is part of the common library.
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
void GRForceBlackPen(bool flagforce)
void GRResetPenAndBrush(wxDC *DC)
void GRSFilledRect(wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
@ LAYER_DRAWINGSHEET
drawingsheet frame and titleblock
@ LAYER_SCHEMATIC_DRAWINGSHEET
@ LAYER_SCHEMATIC_BACKGROUND
int Mils2mm(double aVal)
Convert mils to mm.
SETTINGS_MANAGER * GetSettingsManager()
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
std::vector< FAB_LAYER_COLOR > dummy
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.
wxSize ToWxSize(const VECTOR2I &aSize)