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." ) );
330#if defined( __WXGTK__ ) && !wxCHECK_VERSION( 3, 2, 3 )
340 wxPaperSize paperId = data.GetPaperId();
341 const wxChar* paperType =
nullptr;
344 std::set<wxPaperSize> letterSizes = {
349 wxPAPER_LETTER_TRANSVERSE,
350 wxPAPER_LETTER_ROTATED
353 std::set<wxPaperSize> legalSizes = {
358 std::set<wxPaperSize> a4Sizes = {
362 wxPAPER_A4_TRANSVERSE,
367 if( letterSizes.count( paperId ) )
369 else if( legalSizes.count( paperId ) )
371 else if( a4Sizes.count( paperId ) )
376 PAGE_INFO pageInfo( paperType, data.GetOrientation() == wxPORTRAIT );
386 data.SetPaperId( wxPAPER_NONE );
390 wxPrintDialogData printDialogData( data );
391 printDialogData.SetMaxPage( sheet_count );
393 if( sheet_count > 1 )
394 printDialogData.EnablePageNumbers(
true );
396 wxPrinter printer( &printDialogData );
399 Pgm().m_Printing =
true;
401 if( !printer.Print(
this, &printout,
true ) )
403 if( wxPrinter::GetLastError() == wxPRINTER_ERROR )
404 DisplayError(
this,
_(
"An error occurred attempting to print the schematic." ) );
412 Pgm().m_Printing =
false;
422 wxCHECK_MSG( page >= 1 && page <= (
int)sheetList.size(),
false,
423 wxT(
"Cannot print invalid page number." ) );
425 wxCHECK_MSG( sheetList[ page - 1].LastScreen() !=
nullptr,
false,
426 wxT(
"Cannot print page with NULL screen." ) );
429 msg.Printf(
_(
"Print page %d" ), page );
450 *minPage = *selPageFrom = 1;
463 if( !wxPrintout::OnBeginDocument( startPage, endPage ) )
500 FitThisSizeToPaper( pageSizeIU );
502 fitRect = GetLogicalPaperRect();
507 int xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
508 int yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
512 if( dc->CanUseTransformMatrix() )
514 wxAffineMatrix2D matrix;
517 if( ( fitRect.width > fitRect.height ) != ( pageSizeIU.x > pageSizeIU.y ) )
521 matrix.Translate( 0, -pageSizeIU.y );
524 std::swap( pageSizeIU.x, pageSizeIU.y );
525 FitThisSizeToPaper( pageSizeIU );
526 fitRect = GetLogicalPaperRect();
528 xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
529 yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
533 std::swap( xoffset, yoffset );
534 std::swap( fitRect.width, fitRect.height );
538 matrix.Translate( xoffset, yoffset );
539 dc->SetTransformMatrix( matrix );
541 fitRect.x -= xoffset;
542 fitRect.y -= yoffset;
546 SetLogicalOrigin( 0, 0 );
548 OffsetLogicalOrigin( xoffset, yoffset );
551 dc->SetLogicalFunction( wxCOPY );
564 bgColor = COLOR4D::WHITE;
569 GRSFilledRect( dc, fitRect.GetX(), fitRect.GetY(), fitRect.GetRight(), fitRect.GetBottom(), 0,
590 if( printDrawingSheet )
598 aScreen->
Print( &renderSettings );
613 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.
static const wxChar USLetter[]
static const wxChar USLegal[]
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 RecomputeIntersheetRefs()
Update the schematic's page reference map for all global labels, and refresh the labels so that they ...
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
KICOMMON_API 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)