diff --git a/eeschema/CMakeLists.txt b/eeschema/CMakeLists.txt index d58fe5ba5e..d59a61e47f 100644 --- a/eeschema/CMakeLists.txt +++ b/eeschema/CMakeLists.txt @@ -318,8 +318,8 @@ set( EESCHEMA_IMPORT_GFX ) set( EESCHEMA_PRINTING - printing/dialog_print_using_printer.cpp - printing/dialog_print_using_printer_base.cpp + printing/dialog_print.cpp + printing/dialog_print_base.cpp printing/sch_printout.cpp ) diff --git a/eeschema/invoke_sch_dialog.h b/eeschema/invoke_sch_dialog.h index c90e2a83f8..23e8667a50 100644 --- a/eeschema/invoke_sch_dialog.h +++ b/eeschema/invoke_sch_dialog.h @@ -61,10 +61,6 @@ class SCH_EDIT_FRAME; int InvokeDialogRescueEach( wxWindow* aParent, RESCUER& aRescuer, SCH_SHEET_PATH* aCurrentSheet, EDA_DRAW_PANEL_GAL::GAL_TYPE aGalBackEndType, bool aAskShowAgain ); -/// Create and show DIALOG_PRINT_USING_PRINTER and return whatever -/// DIALOG_PRINT_USING_PRINTER::ShowModal() returns. -int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller ); - /// Create and show DIALOG_BOM and return whatever /// DIALOG_BOM::ShowModal() returns. int InvokeDialogCreateBOM( SCH_EDIT_FRAME* aCaller ); diff --git a/eeschema/printing/dialog_print_using_printer.cpp b/eeschema/printing/dialog_print.cpp similarity index 86% rename from eeschema/printing/dialog_print_using_printer.cpp rename to eeschema/printing/dialog_print.cpp index 15c12b7157..e8184ac49b 100644 --- a/eeschema/printing/dialog_print_using_printer.cpp +++ b/eeschema/printing/dialog_print.cpp @@ -26,47 +26,15 @@ #include #include #include -#include #include #include #include -#include -#include -#include -#include "dialog_print_using_printer_base.h" -#include #include #include - -#include - +#include "dialog_print.h" #include "sch_printout.h" -class DIALOG_PRINT_USING_PRINTER : public DIALOG_PRINT_USING_PRINTER_BASE -{ -public: - DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent ); - ~DIALOG_PRINT_USING_PRINTER() override; - -protected: - void OnOutputChoice( wxCommandEvent& event ) override; - void OnUseColorThemeChecked( wxCommandEvent& event ) override; - -private: - bool TransferDataToWindow() override; - bool TransferDataFromWindow() override; - - void OnPageSetup( wxCommandEvent& event ) override; - void OnPrintPreview( wxCommandEvent& event ) override; - - void SavePrintOptions(); - - SCH_EDIT_FRAME* m_parent; - bool m_useCairo; -}; - - /** * Custom schematic print preview frame. * This derived preview frame remembers its size and position during a session @@ -77,7 +45,7 @@ public: SCH_PREVIEW_FRAME( wxPrintPreview* aPreview, wxWindow* aParent, const wxString& aTitle, const wxPoint& aPos = wxDefaultPosition, const wxSize& aSize = wxDefaultSize ) : - wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize ) + wxPreviewFrame( aPreview, aParent, aTitle, aPos, aSize ) { } @@ -116,9 +84,9 @@ wxPoint SCH_PREVIEW_FRAME::s_pos; wxSize SCH_PREVIEW_FRAME::s_size; -DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent ) : - DIALOG_PRINT_USING_PRINTER_BASE( aParent ), - m_parent( aParent ) +DIALOG_PRINT::DIALOG_PRINT( SCH_EDIT_FRAME* aParent ) : + DIALOG_PRINT_BASE( aParent ), + m_parent( aParent ) { wxASSERT( aParent ); m_useCairo = ADVANCED_CFG::GetCfg().m_EnableEeschemaPrintCairo; @@ -144,13 +112,13 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent } -DIALOG_PRINT_USING_PRINTER::~DIALOG_PRINT_USING_PRINTER() +DIALOG_PRINT::~DIALOG_PRINT() { SavePrintOptions(); } -bool DIALOG_PRINT_USING_PRINTER::TransferDataToWindow() +bool DIALOG_PRINT::TransferDataToWindow() { EESCHEMA_SETTINGS* cfg = m_parent->eeconfig(); @@ -197,11 +165,15 @@ bool DIALOG_PRINT_USING_PRINTER::TransferDataToWindow() if( pageInfo.IsCustom() ) { if( pageInfo.IsPortrait() ) + { pageSetupDialogData.SetPaperSize( wxSize( EDA_UNIT_UTILS::Mils2mm( pageInfo.GetWidthMils() ), EDA_UNIT_UTILS::Mils2mm( pageInfo.GetHeightMils() ) ) ); + } else + { pageSetupDialogData.SetPaperSize( wxSize( EDA_UNIT_UTILS::Mils2mm( pageInfo.GetHeightMils() ), EDA_UNIT_UTILS::Mils2mm( pageInfo.GetWidthMils() ) ) ); + } } pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); @@ -212,13 +184,13 @@ bool DIALOG_PRINT_USING_PRINTER::TransferDataToWindow() } -void DIALOG_PRINT_USING_PRINTER::OnUseColorThemeChecked( wxCommandEvent& event ) +void DIALOG_PRINT::OnUseColorThemeChecked( wxCommandEvent& event ) { m_colorTheme->Enable( m_checkUseColorTheme->GetValue() ); } -void DIALOG_PRINT_USING_PRINTER::OnOutputChoice( wxCommandEvent& event ) +void DIALOG_PRINT::OnOutputChoice( wxCommandEvent& event ) { long sel = event.GetSelection(); m_checkBackgroundColor->Enable( sel == 0 ); @@ -230,7 +202,7 @@ void DIALOG_PRINT_USING_PRINTER::OnOutputChoice( wxCommandEvent& event ) } -void DIALOG_PRINT_USING_PRINTER::SavePrintOptions() +void DIALOG_PRINT::SavePrintOptions() { EESCHEMA_SETTINGS* cfg = m_parent->eeconfig(); @@ -252,7 +224,7 @@ void DIALOG_PRINT_USING_PRINTER::SavePrintOptions() } -void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) +void DIALOG_PRINT::OnPageSetup( wxCommandEvent& event ) { wxPageSetupDialog pageSetupDialog( this, &m_parent->GetPageSetupData() ); pageSetupDialog.ShowModal(); @@ -261,7 +233,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) } -void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) +void DIALOG_PRINT::OnPrintPreview( wxCommandEvent& event ) { SavePrintOptions(); @@ -300,7 +272,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) } -bool DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow() +bool DIALOG_PRINT::TransferDataFromWindow() { if( Pgm().m_Printing ) { @@ -400,11 +372,3 @@ bool DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow() return true; } - - -int InvokeDialogPrintUsingPrinter( SCH_EDIT_FRAME* aCaller ) -{ - DIALOG_PRINT_USING_PRINTER dlg( aCaller ); - - return dlg.ShowModal(); -} diff --git a/eeschema/printing/dialog_print.h b/eeschema/printing/dialog_print.h new file mode 100644 index 0000000000..3f6e6d40a9 --- /dev/null +++ b/eeschema/printing/dialog_print.h @@ -0,0 +1,53 @@ +/* + * This program source code file is part of KiCad, a free EDA CAD application. + * + * Copyright The KiCad Developers, see AUTHORS.txt for contributors. + * + * This program is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by the + * Free Software Foundation, either version 3 of the License, or (at your + * option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program. If not, see . + */ + +#pragma once + +#include "dialog_print_base.h" + + +class SCH_EDIT_FRAME; +class SCH_SCREEN; + + +class DIALOG_PRINT : public DIALOG_PRINT_BASE +{ +public: + DIALOG_PRINT( SCH_EDIT_FRAME* aParent ); + ~DIALOG_PRINT() override; + +protected: + void OnOutputChoice( wxCommandEvent& event ) override; + void OnUseColorThemeChecked( wxCommandEvent& event ) override; + +private: + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + + void OnPageSetup( wxCommandEvent& event ) override; + void OnPrintPreview( wxCommandEvent& event ) override; + + void SavePrintOptions(); + +private: + SCH_EDIT_FRAME* m_parent; + bool m_useCairo; +}; + + diff --git a/eeschema/printing/dialog_print_using_printer_base.cpp b/eeschema/printing/dialog_print_base.cpp similarity index 79% rename from eeschema/printing/dialog_print_using_printer_base.cpp rename to eeschema/printing/dialog_print_base.cpp index f2415e2cba..8007317f54 100644 --- a/eeschema/printing/dialog_print_using_printer_base.cpp +++ b/eeschema/printing/dialog_print_base.cpp @@ -5,11 +5,11 @@ // PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// -#include "dialog_print_using_printer_base.h" +#include "dialog_print_base.h" /////////////////////////////////////////////////////////////////////////// -DIALOG_PRINT_USING_PRINTER_BASE::DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) +DIALOG_PRINT_BASE::DIALOG_PRINT_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : DIALOG_SHIM( parent, id, title, pos, size, style ) { this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); @@ -96,20 +96,20 @@ DIALOG_PRINT_USING_PRINTER_BASE::DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* pare bMainSizer->Fit( this ); // Connect Events - this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) ); - m_colorPrint->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnOutputChoice ), NULL, this ); - m_checkUseColorTheme->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnUseColorThemeChecked ), NULL, this ); - m_buttonPageSetup->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this ); - m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_BASE::OnCloseWindow ) ); + m_colorPrint->Connect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PRINT_BASE::OnOutputChoice ), NULL, this ); + m_checkUseColorTheme->Connect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PRINT_BASE::OnUseColorThemeChecked ), NULL, this ); + m_buttonPageSetup->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_BASE::OnPageSetup ), NULL, this ); + m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_BASE::OnPrintPreview ), NULL, this ); } -DIALOG_PRINT_USING_PRINTER_BASE::~DIALOG_PRINT_USING_PRINTER_BASE() +DIALOG_PRINT_BASE::~DIALOG_PRINT_BASE() { // Disconnect Events - this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) ); - m_colorPrint->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnOutputChoice ), NULL, this ); - m_checkUseColorTheme->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnUseColorThemeChecked ), NULL, this ); - m_buttonPageSetup->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this ); - m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_BASE::OnCloseWindow ) ); + m_colorPrint->Disconnect( wxEVT_COMMAND_CHOICE_SELECTED, wxCommandEventHandler( DIALOG_PRINT_BASE::OnOutputChoice ), NULL, this ); + m_checkUseColorTheme->Disconnect( wxEVT_COMMAND_CHECKBOX_CLICKED, wxCommandEventHandler( DIALOG_PRINT_BASE::OnUseColorThemeChecked ), NULL, this ); + m_buttonPageSetup->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_BASE::OnPageSetup ), NULL, this ); + m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_BASE::OnPrintPreview ), NULL, this ); } diff --git a/eeschema/printing/dialog_print_using_printer_base.fbp b/eeschema/printing/dialog_print_base.fbp similarity index 99% rename from eeschema/printing/dialog_print_using_printer_base.fbp rename to eeschema/printing/dialog_print_base.fbp index 22181e5761..a50dac2906 100644 --- a/eeschema/printing/dialog_print_using_printer_base.fbp +++ b/eeschema/printing/dialog_print_base.fbp @@ -13,12 +13,12 @@ 1 res UTF-8 - dialog_print_using_printer_base + dialog_print_base 1000 1 1 UI - dialog_print_schematic + dialog_print . 0 source_name @@ -48,7 +48,7 @@ wxID_ANY -1,-1 - DIALOG_PRINT_USING_PRINTER_BASE + DIALOG_PRINT_BASE -1,-1 wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER diff --git a/eeschema/printing/dialog_print_using_printer_base.h b/eeschema/printing/dialog_print_base.h similarity index 82% rename from eeschema/printing/dialog_print_using_printer_base.h rename to eeschema/printing/dialog_print_base.h index 1bb07c2344..45e83e1e56 100644 --- a/eeschema/printing/dialog_print_using_printer_base.h +++ b/eeschema/printing/dialog_print_base.h @@ -29,9 +29,9 @@ /////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////// -/// Class DIALOG_PRINT_USING_PRINTER_BASE +/// Class DIALOG_PRINT_BASE /////////////////////////////////////////////////////////////////////////////// -class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM +class DIALOG_PRINT_BASE : public DIALOG_SHIM { private: @@ -58,9 +58,9 @@ class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM public: - DIALOG_PRINT_USING_PRINTER_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 ); + 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 ); - ~DIALOG_PRINT_USING_PRINTER_BASE(); + ~DIALOG_PRINT_BASE(); }; diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 3e2fdcd0d1..aa4d6030d8 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -78,7 +79,7 @@ #include #include #include -#include "sch_edit_table_tool.h" +#include #ifdef KICAD_IPC_API #include @@ -295,7 +296,10 @@ int SCH_EDITOR_CONTROL::RemapSymbols( const TOOL_EVENT& aEvent ) int SCH_EDITOR_CONTROL::Print( const TOOL_EVENT& aEvent ) { - InvokeDialogPrintUsingPrinter( m_frame ); + DIALOG_PRINT dlg( m_frame ); + + dlg.ShowModal(); + return 0; }