38 #include <wx/printdlg.h> 74 wxASSERT( aParent !=
nullptr );
79 bool HasPage(
int page )
override;
81 void GetPageInfo(
int* minPage,
int* maxPage,
int* selPageFrom,
int* selPageTo )
override;
97 const wxString& aTitle,
const wxPoint& aPos = wxDefaultPosition,
98 const wxSize& aSize = wxDefaultSize ) :
99 wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize )
103 bool Show(
bool show )
override 111 ret = wxPreviewFrame::Show( show );
120 s_pos = GetPosition();
122 ret = wxPreviewFrame::Show( show );
189 int minwidth = width;
195 int pos =
m_colorTheme->Append( settings->GetName(), static_cast<void*>( settings ) );
197 if( settings->GetFilename() == target )
200 m_colorTheme->GetTextExtent( settings->GetName(), &width, &height );
201 minwidth = std::max( minwidth, width );
204 m_colorTheme->SetMinSize( wxSize( minwidth + 50, -1 ) );
212 pageSetupDialogData.SetPaperId( pageInfo.
GetPaperId() );
224 pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.
GetWxOrientation() );
272 pageSetupDialog.ShowModal();
283 wxString title =
_(
"Preview" );
288 preview->SetZoom( 100 );
291 frame->SetMinSize( wxSize( 550, 350 ) );
295 frame->SetSize( (
m_parent->GetSize() * 2) / 3 );
301 frame->SetExtraStyle( frame->GetExtraStyle() | wxTOPLEVEL_EX_DIALOG );
309 frame->InitializeWithModality( wxPreviewFrame_WindowModal );
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 ) )
412 wxPoint tmp_startvisu;
432 FitThisSizeToPaper( pageSizeIU );
434 fitRect = GetLogicalPaperRect();
439 int xoffset = ( fitRect.width - pageSizeIU.x ) / 2;
440 int yoffset = ( fitRect.height - pageSizeIU.y ) / 2;
442 if( dc->CanUseTransformMatrix() )
444 wxAffineMatrix2D matrix = dc->GetTransformMatrix();
447 if( ( fitRect.width > fitRect.height ) != ( pageSizeIU.x > pageSizeIU.y ) )
450 xoffset = ( fitRect.height - pageSizeIU.x ) / 2;
451 yoffset = ( fitRect.width - pageSizeIU.y ) / 2;
454 matrix.Translate( xoffset, yoffset );
455 dc->SetTransformMatrix( matrix );
465 OffsetLogicalOrigin( xoffset, yoffset );
468 dc->SetLogicalFunction( wxCOPY );
486 GRSFilledRect(
nullptr, dc, fitRect.GetX(), fitRect.GetY(), fitRect.GetRight(),
487 fitRect.GetBottom(), 0, bgColor, bgColor );
496 renderSettings.LoadColors( theme );
509 renderSettings.SetIsPrinting(
true );
511 aScreen->
Print( &renderSettings );
526 return dlg.ShowModal();
void SetCurrentSheet(const SCH_SHEET_PATH &aSheet)
void OnMonochromeChecked(wxCommandEvent &event) override
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
A container for handling SCH_SHEET_PATH objects in a flattened hierarchy.
void GRResetPenAndBrush(wxDC *DC)
const wxString & GetFileName() const
wxCheckBox * m_checkBackgroundColor
wxPrintOrientation GetWxOrientation() const
Implementation of conversion functions that require both schematic and board internal units.
This file is part of the common library.
int GetHeightMils() const
wxString GetFilename() const
wxString color_theme
Color theme to use for printing.
wxCheckBox * m_checkUseColorTheme
bool title_block
Whether or not to print title block.
KIGFX::SCH_RENDER_SETTINGS * GetRenderSettings()
Schematic editor (Eeschema) main window.
bool TransferDataFromWindow() override
SCH_PREVIEW_FRAME(wxPrintPreview *aPreview, wxWindow *aParent, const wxString &aTitle, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize)
bool use_theme
If false, display color theme will be used.
void GetPageInfo(int *minPage, int *maxPage, int *selPageFrom, int *selPageTo) override
void UpdateAllScreenReferences()
Update all the symbol references for this sheet path.
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
const PAGE_INFO & GetPageSettings() const
wxButton * m_sdbSizer1Cancel
bool monochrome
Whether or not to print in monochrome.
wxPaperSize GetPaperId() const
wxCheckBox * m_checkMonochrome
EESCHEMA_SETTINGS * eeconfig() const
static LIB_SYMBOL * dummy()
Used to draw a dummy shape when a LIB_SYMBOL is not found in library.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCH_EDIT_FRAME * m_parent
wxPoint m_StartVisu
Coordinates in drawing units of the current view position (upper left corner of device)
void PrintPage(SCH_SCREEN *aScreen)
Custom print out for printing schematics.
int InvokeDialogPrintUsingPrinter(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_PRINT_USING_PRINTER and return whatever DIALOG_PRINT_USING_PRINTER::ShowModal(...
void SetMsgPanel(const std::vector< MSG_PANEL_ITEM > &aList)
Clear the message panel and populates it with the contents of aList.
void GRForceBlackPen(bool flagforce)
Describe the page size and margins of a paper page on which to eventually print or plot.
bool OnPrintPage(int page) override
Class DIALOG_PRINT_USING_PRINTER_BASE.
void OnUseColorThemeChecked(wxCommandEvent &event) override
SCHEMATIC & Schematic() const
wxCheckBox * m_checkReference
Custom schematic print preview frame.
SCH_PRINTOUT(SCH_EDIT_FRAME *aParent, const wxString &aTitle)
drawingsheet frame and titleblock
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
wxPageSetupDialogData & GetPageSetupData()
void PrintDrawingSheet(const RENDER_SETTINGS *aSettings, BASE_SCREEN *aScreen, double aMils2Iu, const wxString &aFilename, const wxString &aSheetLayer=wxEmptyString)
Prints the drawing-sheet (frame and title block).
COLOR4D GetDrawBgColor() const override
wxStdDialogButtonSizer * m_sdbSizer1
COLOR_SETTINGS * GetColorSettings() const override
Returns a pointer to the active color theme settings.
bool background
Whether or not to print background color.
SETTINGS_MANAGER * GetSettingsManager()
void OnPageSetup(wxCommandEvent &event) override
bool TransferDataToWindow() override
int CountSheets() const
Count the number of sheets found in "this" sheet including all of the subsheets.
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
COLOR_SETTINGS * GetColorSettings(const wxString &aName="user")
Retrieves a color settings object that applications can read colors from.
SCH_SHEET_LIST GetSheets() const override
Builds and returns an updated schematic hierarchy TODO: can this be cached?
COLOR4D GetColor(int aLayer) const
~DIALOG_PRINT_USING_PRINTER() override
bool Show(bool show) override
SCH_SCREEN * LastScreen()
void Print(const RENDER_SETTINGS *aSettings)
Print all the items in the screen to aDC.
void SetSheetNumberAndCount()
Set the m_ScreenNumber and m_NumberOfScreens members for screens.
bool OnBeginDocument(int startPage, int endPage) override
int Mils2mm(double x)
Convert mils to mm.
wxPoint m_DrawOrg
offsets for drawing the circuit on the screen
Store schematic specific render settings.
void OnPrintPreview(wxCommandEvent &event) override
wxButton * m_sdbSizer1Apply
Color settings are a bit different than most of the settings objects in that there can be more than o...
SCH_SHEET_PATH & GetCurrentSheet() const
DIALOG_PRINT_USING_PRINTER(SCH_EDIT_FRAME *aParent)
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
SCH_EDIT_FRAME * m_parent
bool HasPage(int page) override
void SetPrintDC(wxDC *aDC)
virtual void SetDrawBgColor(const COLOR4D &aColor)
void GRSFilledRect(EDA_RECT *aClipBox, wxDC *aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
wxString m_ColorTheme
Active color theme name.
A color representation with 4 components: red, green, blue, alpha.