From 2a9856ba340af47b9ad5a43bd512297aea4f3d87 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sun, 22 Jul 2018 23:27:59 +0100 Subject: [PATCH] Refresh eeschema print dialog. Use standard button layout and remove extraneous heading. Move to TransferDataTo/FromWindow. Close dialog after printing. Fixes: lp:1763319 * https://bugs.launchpad.net/kicad/+bug/1763319 --- .../dialogs/dialog_print_using_printer.cpp | 94 ++-- .../dialog_print_using_printer_base.cpp | 56 ++- .../dialog_print_using_printer_base.fbp | 456 +++++------------- .../dialogs/dialog_print_using_printer_base.h | 17 +- 4 files changed, 187 insertions(+), 436 deletions(-) diff --git a/eeschema/dialogs/dialog_print_using_printer.cpp b/eeschema/dialogs/dialog_print_using_printer.cpp index ec7ccd3dfe..40a73221aa 100644 --- a/eeschema/dialogs/dialog_print_using_printer.cpp +++ b/eeschema/dialogs/dialog_print_using_printer.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr - * Copyright (C) 2015-2016 KiCad Developers, see CHANGELOG.TXT for contributors. + * Copyright (C) 2015-2018 KiCad Developers, see CHANGELOG.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 @@ -38,7 +38,6 @@ #include #include -#include /** @@ -51,6 +50,7 @@ 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; SCH_EDIT_FRAME* GetParent() const { @@ -58,13 +58,12 @@ public: } private: - void OnCloseWindow( wxCloseEvent& event ) override; + bool TransferDataToWindow() override; + bool TransferDataFromWindow() override; + void OnPageSetup( wxCommandEvent& event ) override; void OnPrintPreview( wxCommandEvent& event ) override; - void OnPrintButtonClick( wxCommandEvent& event ) override; - void OnButtonCancelClick( wxCommandEvent& event ) override { Close(); } - void initDialog(); void GetPrintOptions(); }; @@ -149,18 +148,42 @@ DIALOG_PRINT_USING_PRINTER::DIALOG_PRINT_USING_PRINTER( SCH_EDIT_FRAME* aParent m_checkReference->SetValue( aParent->GetPrintSheetReference() ); m_checkMonochrome->SetValue( aParent->GetPrintMonochrome() ); - initDialog(); + + // We use a sdbSizer to get platform-dependent ordering of the action buttons, but + // that requires us to correct the button labels here. + m_sdbSizer1OK->SetLabel( _( "Print" ) ); + m_sdbSizer1Apply->SetLabel( _( "Preview" ) ); + m_sdbSizer1Cancel->SetLabel( _( "Close" ) ); + m_sdbSizer1->Layout(); #ifdef __WXMAC__ // Problems with modal on wx-2.9 - Anyway preview is standard for OSX - m_buttonPreview->Hide(); + m_sdbSizer1Apply->Hide(); #endif - GetSizer()->Fit( this ); + m_sdbSizer1OK->SetDefault(); // on linux, this is inadequate to determine + // what ENTER does. Must also SetFocus(). + m_sdbSizer1OK->SetFocus(); + + FinishDialogSettings(); } -void DIALOG_PRINT_USING_PRINTER::initDialog() +DIALOG_PRINT_USING_PRINTER::~DIALOG_PRINT_USING_PRINTER() +{ + SCH_EDIT_FRAME* parent = GetParent(); + + if( !IsIconized() ) + { + parent->SetPrintDialogPosition( GetPosition() ); + parent->SetPrintDialogSize( GetSize() ); + } + + GetPrintOptions(); +} + + +bool DIALOG_PRINT_USING_PRINTER::TransferDataToWindow() { SCH_EDIT_FRAME* parent = GetParent(); @@ -182,19 +205,7 @@ void DIALOG_PRINT_USING_PRINTER::initDialog() pageSetupDialogData.GetPrintData().SetOrientation( pageInfo.GetWxOrientation() ); - if ( GetSizer() ) - GetSizer()->SetSizeHints( this ); - - // Rely on the policy in class DIALOG_SHIM, which centers the dialog - // initially during a runtime session but gives user the ability to move it in - // that session. - // This dialog may get moved and resized in Show(), but in case this is - // the first time, center it for starters. - Center(); - - m_buttonPrint->SetDefault(); // on linux, this is inadequate to determine - // what ENTER does. Must also SetFocus(). - m_buttonPrint->SetFocus(); + return true; } @@ -207,22 +218,6 @@ void DIALOG_PRINT_USING_PRINTER::GetPrintOptions() } -void DIALOG_PRINT_USING_PRINTER::OnCloseWindow( wxCloseEvent& event ) -{ - SCH_EDIT_FRAME* parent = GetParent(); - - if( !IsIconized() ) - { - parent->SetPrintDialogPosition( GetPosition() ); - parent->SetPrintDialogSize( GetSize() ); - } - - GetPrintOptions(); - - EndDialog( wxID_CANCEL ); -} - - /* Open a dialog box for printer setup (printer options, page size ...) */ void DIALOG_PRINT_USING_PRINTER::OnPageSetup( wxCommandEvent& event ) @@ -251,12 +246,6 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) new SCH_PRINTOUT( parent, title ), &parent->GetPageSetupData().GetPrintData() ); - if( preview == NULL ) - { - DisplayError( this, _( "Print preview error!" ) ); - return; - } - preview->SetZoom( 100 ); SCH_PREVIEW_FRAME* frame = new SCH_PREVIEW_FRAME( preview, this, title ); @@ -285,7 +274,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintPreview( wxCommandEvent& event ) } -void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) +bool DIALOG_PRINT_USING_PRINTER::TransferDataFromWindow() { SCH_EDIT_FRAME* parent = GetParent(); @@ -302,7 +291,7 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) // Disable 'Print' button to prevent issuing another print // command before the previous one is finished (causes problems on Windows) - ENABLER printBtnDisable( *m_buttonPrint, false ); + m_sdbSizer1OK->Enable( false ); if( !printer.Print( this, &printout, true ) ) { @@ -314,6 +303,8 @@ void DIALOG_PRINT_USING_PRINTER::OnPrintButtonClick( wxCommandEvent& event ) { parent->GetPageSetupData() = printer.GetPrintDialogData().GetPrintData(); } + + return true; } @@ -356,14 +347,7 @@ void SCH_PRINTOUT::GetPageInfo( int* minPage, int* maxPage, int* selPageFrom, in bool SCH_PRINTOUT::HasPage( int pageNum ) { - int pageCount; - - pageCount = g_RootSheet->CountSheets(); - - if( pageCount >= pageNum ) - return true; - - return false; + return g_RootSheet->CountSheets() >= pageNum; } diff --git a/eeschema/dialogs/dialog_print_using_printer_base.cpp b/eeschema/dialogs/dialog_print_using_printer_base.cpp index 86fb423543..5d46cd78a6 100644 --- a/eeschema/dialogs/dialog_print_using_printer_base.cpp +++ b/eeschema/dialogs/dialog_print_using_printer_base.cpp @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -14,47 +14,49 @@ DIALOG_PRINT_USING_PRINTER_BASE::DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* pare this->SetSizeHints( wxSize( -1,-1 ), wxDefaultSize ); wxBoxSizer* bMainSizer; - bMainSizer = new wxBoxSizer( wxHORIZONTAL ); + bMainSizer = new wxBoxSizer( wxVERTICAL ); wxBoxSizer* bleftSizer; bleftSizer = new wxBoxSizer( wxVERTICAL ); - m_staticText1 = new wxStaticText( this, wxID_ANY, _("Print options:"), wxDefaultPosition, wxDefaultSize, 0 ); - m_staticText1->Wrap( -1 ); - m_staticText1->SetFont( wxFont( wxNORMAL_FONT->GetPointSize(), wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD, false, wxEmptyString ) ); - - bleftSizer->Add( m_staticText1, 0, wxTOP|wxRIGHT, 5 ); - m_checkReference = new wxCheckBox( this, wxID_ANY, _("Print sheet &reference and title block"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkReference->SetValue(true); m_checkReference->SetToolTip( _("Print (or not) the Frame references.") ); - bleftSizer->Add( m_checkReference, 0, wxALL, 10 ); + bleftSizer->Add( m_checkReference, 0, wxALL, 5 ); m_checkMonochrome = new wxCheckBox( this, wxID_ANY, _("Print in &black and white only"), wxDefaultPosition, wxDefaultSize, 0 ); m_checkMonochrome->SetValue(true); - bleftSizer->Add( m_checkMonochrome, 0, wxBOTTOM|wxRIGHT|wxLEFT, 10 ); + bleftSizer->Add( m_checkMonochrome, 0, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); - bMainSizer->Add( bleftSizer, 1, wxBOTTOM|wxEXPAND|wxLEFT|wxTOP, 12 ); + bMainSizer->Add( bleftSizer, 1, wxEXPAND|wxTOP|wxBOTTOM|wxLEFT, 10 ); + + m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL ); + bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 ); wxBoxSizer* bbuttonsSizer; - bbuttonsSizer = new wxBoxSizer( wxVERTICAL ); + bbuttonsSizer = new wxBoxSizer( wxHORIZONTAL ); m_buttonPageSetup = new wxButton( this, wxID_ANY, _("Page Setup"), wxDefaultPosition, wxDefaultSize, 0 ); - bbuttonsSizer->Add( m_buttonPageSetup, 0, wxALL|wxEXPAND, 5 ); - - m_buttonPreview = new wxButton( this, wxID_ANY, _("Preview"), wxDefaultPosition, wxDefaultSize, 0 ); - bbuttonsSizer->Add( m_buttonPreview, 0, wxALL|wxEXPAND, 5 ); - - m_buttonPrint = new wxButton( this, wxID_ANY, _("Print"), wxDefaultPosition, wxDefaultSize, 0 ); - bbuttonsSizer->Add( m_buttonPrint, 0, wxALL|wxEXPAND, 5 ); - - m_buttonQuit = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); - bbuttonsSizer->Add( m_buttonQuit, 0, wxALL|wxEXPAND, 5 ); + bbuttonsSizer->Add( m_buttonPageSetup, 0, wxALL|wxALIGN_CENTER_VERTICAL, 5 ); - bMainSizer->Add( bbuttonsSizer, 0, wxALL, 5 ); + bbuttonsSizer->Add( 0, 0, 1, wxEXPAND|wxRIGHT|wxLEFT, 20 ); + + m_sdbSizer1 = new wxStdDialogButtonSizer(); + m_sdbSizer1OK = new wxButton( this, wxID_OK ); + m_sdbSizer1->AddButton( m_sdbSizer1OK ); + m_sdbSizer1Apply = new wxButton( this, wxID_APPLY ); + m_sdbSizer1->AddButton( m_sdbSizer1Apply ); + m_sdbSizer1Cancel = new wxButton( this, wxID_CANCEL ); + m_sdbSizer1->AddButton( m_sdbSizer1Cancel ); + m_sdbSizer1->Realize(); + + bbuttonsSizer->Add( m_sdbSizer1, 0, 0, 5 ); + + + bMainSizer->Add( bbuttonsSizer, 0, wxALL|wxEXPAND, 5 ); this->SetSizer( bMainSizer ); @@ -64,9 +66,7 @@ DIALOG_PRINT_USING_PRINTER_BASE::DIALOG_PRINT_USING_PRINTER_BASE( wxWindow* pare // Connect Events this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) ); m_buttonPageSetup->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this ); - m_buttonPreview->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); - m_buttonPrint->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this ); - m_buttonQuit->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCancelClick ), NULL, this ); + m_sdbSizer1Apply->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); } DIALOG_PRINT_USING_PRINTER_BASE::~DIALOG_PRINT_USING_PRINTER_BASE() @@ -74,8 +74,6 @@ DIALOG_PRINT_USING_PRINTER_BASE::~DIALOG_PRINT_USING_PRINTER_BASE() // Disconnect Events this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnCloseWindow ) ); m_buttonPageSetup->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPageSetup ), NULL, this ); - m_buttonPreview->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); - m_buttonPrint->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintButtonClick ), NULL, this ); - m_buttonQuit->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnButtonCancelClick ), NULL, this ); + m_sdbSizer1Apply->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PRINT_USING_PRINTER_BASE::OnPrintPreview ), NULL, this ); } diff --git a/eeschema/dialogs/dialog_print_using_printer_base.fbp b/eeschema/dialogs/dialog_print_using_printer_base.fbp index f4e2ea798b..624cdf6dad 100644 --- a/eeschema/dialogs/dialog_print_using_printer_base.fbp +++ b/eeschema/dialogs/dialog_print_using_printer_base.fbp @@ -91,11 +91,11 @@ bMainSizer - wxHORIZONTAL + wxVERTICAL none - 12 - wxBOTTOM|wxEXPAND|wxLEFT|wxTOP + 10 + wxEXPAND|wxTOP|wxBOTTOM|wxLEFT 1 @@ -104,89 +104,6 @@ none 5 - wxTOP|wxRIGHT - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - ,90,92,-1,70,0 - 0 - 0 - wxID_ANY - Print options: - - 0 - - - 0 - - 1 - m_staticText1 - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - - - -1 - - - - - - - - - - - - - - - - - - - - - - - - - - - 10 wxALL 0 @@ -274,7 +191,7 @@ - 10 + 5 wxBOTTOM|wxRIGHT|wxLEFT 0 @@ -365,16 +282,97 @@ 5 - wxALL + wxEXPAND|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + 0 + + + 0 + + 1 + m_staticline1 + 1 + + + protected + 1 + + Resizable + 1 + + wxLI_HORIZONTAL + ; forward_declare + 0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND 0 bbuttonsSizer - wxVERTICAL + wxHORIZONTAL none 5 - wxALL|wxEXPAND + wxALL|wxALIGN_CENTER_VERTICAL 0 1 @@ -461,267 +459,39 @@ - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Preview - - 0 - - - 0 - - 1 - m_buttonPreview - 1 - - + 20 + wxEXPAND|wxRIGHT|wxLEFT + 1 + + 0 protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnPrintPreview - - - - - - - - - - - - - - - - - - - - - - - + 0 5 - wxALL|wxEXPAND + 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Print - - 0 - - - 0 + + 1 + 1 + 0 + 0 + 0 + 1 + 0 + 0 - 1 - m_buttonPrint - 1 - - + m_sdbSizer1 protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnPrintButtonClick - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - 1 - - 1 - 0 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_CANCEL - Close - - 0 - - - 0 - - 1 - m_buttonQuit - 1 - - - protected - 1 - - Resizable - 1 - - - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - OnButtonCancelClick - - - - - - - - - - - - - - - - - - - - - - - + OnPrintPreview + + + + + + + diff --git a/eeschema/dialogs/dialog_print_using_printer_base.h b/eeschema/dialogs/dialog_print_using_printer_base.h index 35bc7a7a85..62c3ac4051 100644 --- a/eeschema/dialogs/dialog_print_using_printer_base.h +++ b/eeschema/dialogs/dialog_print_using_printer_base.h @@ -1,5 +1,5 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Nov 22 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // // PLEASE DO *NOT* EDIT THIS FILE! @@ -13,13 +13,13 @@ #include #include "dialog_shim.h" #include -#include +#include #include #include #include #include -#include #include +#include #include #include @@ -33,20 +33,19 @@ class DIALOG_PRINT_USING_PRINTER_BASE : public DIALOG_SHIM private: protected: - wxStaticText* m_staticText1; wxCheckBox* m_checkReference; wxCheckBox* m_checkMonochrome; + wxStaticLine* m_staticline1; wxButton* m_buttonPageSetup; - wxButton* m_buttonPreview; - wxButton* m_buttonPrint; - wxButton* m_buttonQuit; + wxStdDialogButtonSizer* m_sdbSizer1; + wxButton* m_sdbSizer1OK; + wxButton* m_sdbSizer1Apply; + wxButton* m_sdbSizer1Cancel; // Virtual event handlers, overide them in your derived class virtual void OnCloseWindow( wxCloseEvent& event ) { event.Skip(); } virtual void OnPageSetup( wxCommandEvent& event ) { event.Skip(); } virtual void OnPrintPreview( wxCommandEvent& event ) { event.Skip(); } - virtual void OnPrintButtonClick( wxCommandEvent& event ) { event.Skip(); } - virtual void OnButtonCancelClick( wxCommandEvent& event ) { event.Skip(); } public: