From 3d77ed9e9d0ef4d4ca527c438b307ce37dc1d004 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Sat, 17 Feb 2018 16:27:59 +0000 Subject: [PATCH] Replace Cancel button with Close in Generate Pos dialog Fixes: lp:1548123 * https://bugs.launchpad.net/kicad/+bug/1548123 --- ...ialog_gen_footprint_position_file_base.cpp | 79 +- ...ialog_gen_footprint_position_file_base.fbp | 831 +++++++++++------- .../dialog_gen_footprint_position_file_base.h | 19 +- pcbnew/exporters/gen_footprints_placefile.cpp | 13 +- 4 files changed, 589 insertions(+), 353 deletions(-) diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp index 45dc8ff309..46b9e65b4c 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.cpp @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #include "wx_html_report_panel.h" @@ -25,7 +25,7 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow m_staticTextDir = new wxStaticText( this, wxID_ANY, _("Output directory:"), wxDefaultPosition, wxDefaultSize, 0 ); m_staticTextDir->Wrap( -1 ); - bDirSizer->Add( m_staticTextDir, 0, wxEXPAND|wxTOP|wxLEFT, 5 ); + bDirSizer->Add( m_staticTextDir, 0, wxEXPAND, 10 ); wxBoxSizer* bSizerdirBrowse; bSizerdirBrowse = new wxBoxSizer( wxHORIZONTAL ); @@ -34,42 +34,54 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow m_outputDirectoryName->SetToolTip( _("Target directory for plot files. Can be absolute or relative to the board file location.") ); m_outputDirectoryName->SetMinSize( wxSize( 350,-1 ) ); - bSizerdirBrowse->Add( m_outputDirectoryName, 1, wxEXPAND|wxRIGHT|wxLEFT, 5 ); + bSizerdirBrowse->Add( m_outputDirectoryName, 1, wxBOTTOM|wxEXPAND|wxTOP, 4 ); - m_browseButton = new wxButton( this, wxID_ANY, _("Browse..."), wxDefaultPosition, wxDefaultSize, 0 ); - bSizerdirBrowse->Add( m_browseButton, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 ); + m_browseButton = new wxBitmapButton( this, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW ); + bSizerdirBrowse->Add( m_browseButton, 0, wxRIGHT, 1 ); bDirSizer->Add( bSizerdirBrowse, 1, wxEXPAND, 5 ); - bUpperSizer->Add( bDirSizer, 1, 0, 5 ); + bUpperSizer->Add( bDirSizer, 1, wxALL, 10 ); - m_MainSizer->Add( bUpperSizer, 0, wxEXPAND, 5 ); + m_MainSizer->Add( bUpperSizer, 0, wxEXPAND|wxLEFT|wxRIGHT, 2 ); - wxBoxSizer* bSizerOptions; - bSizerOptions = new wxBoxSizer( wxHORIZONTAL ); + wxGridBagSizer* gbSizer1; + gbSizer1 = new wxGridBagSizer( 0, 0 ); + gbSizer1->SetFlexibleDirection( wxBOTH ); + gbSizer1->SetNonFlexibleGrowMode( wxFLEX_GROWMODE_SPECIFIED ); - wxString m_rbFormatChoices[] = { _("Ascii"), _("CSV") }; + wxBoxSizer* bOptionsSizer; + bOptionsSizer = new wxBoxSizer( wxHORIZONTAL ); + + wxString m_rbFormatChoices[] = { _("ASCII"), _("CSV") }; int m_rbFormatNChoices = sizeof( m_rbFormatChoices ) / sizeof( wxString ); m_rbFormat = new wxRadioBox( this, wxID_ANY, _("Format:"), wxDefaultPosition, wxDefaultSize, m_rbFormatNChoices, m_rbFormatChoices, 1, wxRA_SPECIFY_COLS ); m_rbFormat->SetSelection( 0 ); - bSizerOptions->Add( m_rbFormat, 0, wxALL, 5 ); + m_rbFormat->SetMinSize( wxSize( 90,-1 ) ); + + bOptionsSizer->Add( m_rbFormat, 0, wxALL, 5 ); wxString m_radioBoxUnitsChoices[] = { _("Inches"), _("mm") }; int m_radioBoxUnitsNChoices = sizeof( m_radioBoxUnitsChoices ) / sizeof( wxString ); m_radioBoxUnits = new wxRadioBox( this, wxID_ANY, _("Units:"), wxDefaultPosition, wxDefaultSize, m_radioBoxUnitsNChoices, m_radioBoxUnitsChoices, 1, wxRA_SPECIFY_COLS ); m_radioBoxUnits->SetSelection( 0 ); - bSizerOptions->Add( m_radioBoxUnits, 0, wxALL|wxEXPAND, 5 ); + m_radioBoxUnits->SetMinSize( wxSize( 90,-1 ) ); - wxString m_radioBoxFilesCountChoices[] = { _("One file per side"), _("One file for board") }; + bOptionsSizer->Add( m_radioBoxUnits, 0, wxALL|wxEXPAND, 5 ); + + wxString m_radioBoxFilesCountChoices[] = { _("One file per side"), _("Single file for board") }; int m_radioBoxFilesCountNChoices = sizeof( m_radioBoxFilesCountChoices ) / sizeof( wxString ); m_radioBoxFilesCount = new wxRadioBox( this, wxID_ANY, _("Files:"), wxDefaultPosition, wxDefaultSize, m_radioBoxFilesCountNChoices, m_radioBoxFilesCountChoices, 1, wxRA_SPECIFY_COLS ); - m_radioBoxFilesCount->SetSelection( 0 ); + m_radioBoxFilesCount->SetSelection( 1 ); m_radioBoxFilesCount->SetToolTip( _("Creates 2 files: one for each board side or\nCreates only one file containing all footprints to place\n") ); - bSizerOptions->Add( m_radioBoxFilesCount, 1, wxALL, 5 ); + bOptionsSizer->Add( m_radioBoxFilesCount, 1, wxALL, 5 ); + + + gbSizer1->Add( bOptionsSizer, wxGBPosition( 0, 0 ), wxGBSpan( 1, 1 ), wxEXPAND, 5 ); wxString m_radioBoxForceSmdChoices[] = { _("With INSERT attribute set"), _("Force INSERT attribute for all SMD footprints") }; int m_radioBoxForceSmdNChoices = sizeof( m_radioBoxForceSmdChoices ) / sizeof( wxString ); @@ -77,10 +89,28 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow m_radioBoxForceSmd->SetSelection( 0 ); m_radioBoxForceSmd->SetToolTip( _("Only footprints with option INSERT are listed in placement file.\nThis option can force this option for all footprints having only SMD pads.\nWarning: this options will modify the board.") ); - bSizerOptions->Add( m_radioBoxForceSmd, 0, wxALL, 5 ); + gbSizer1->Add( m_radioBoxForceSmd, wxGBPosition( 1, 0 ), wxGBSpan( 1, 1 ), wxALL|wxEXPAND, 5 ); - m_MainSizer->Add( bSizerOptions, 0, wxEXPAND|wxTOP|wxBOTTOM, 5 ); + gbSizer1->Add( 0, 0, wxGBPosition( 0, 1 ), wxGBSpan( 2, 1 ), wxEXPAND, 5 ); + + wxBoxSizer* bButtonsSizer; + bButtonsSizer = new wxBoxSizer( wxVERTICAL ); + + bButtonsSizer->SetMinSize( wxSize( 140,-1 ) ); + m_generateButton = new wxButton( this, wxID_ANY, _("Generate File"), wxDefaultPosition, wxDefaultSize, 0 ); + bButtonsSizer->Add( m_generateButton, 0, wxALL|wxEXPAND, 5 ); + + m_closeButton = new wxButton( this, wxID_CANCEL, _("Close"), wxDefaultPosition, wxDefaultSize, 0 ); + bButtonsSizer->Add( m_closeButton, 0, wxALL|wxEXPAND|wxTOP, 5 ); + + + gbSizer1->Add( bButtonsSizer, wxGBPosition( 0, 2 ), wxGBSpan( 2, 1 ), wxEXPAND|wxLEFT|wxTOP, 25 ); + + + gbSizer1->AddGrowableCol( 1 ); + + m_MainSizer->Add( gbSizer1, 0, wxEXPAND|wxLEFT|wxRIGHT, 5 ); wxBoxSizer* bSizer7; bSizer7 = new wxBoxSizer( wxVERTICAL ); @@ -93,15 +123,6 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow m_MainSizer->Add( bSizer7, 1, wxEXPAND, 5 ); - m_sdbSizerButtons = new wxStdDialogButtonSizer(); - m_sdbSizerButtonsOK = new wxButton( this, wxID_OK ); - m_sdbSizerButtons->AddButton( m_sdbSizerButtonsOK ); - m_sdbSizerButtonsCancel = new wxButton( this, wxID_CANCEL ); - m_sdbSizerButtons->AddButton( m_sdbSizerButtonsCancel ); - m_sdbSizerButtons->Realize(); - - m_MainSizer->Add( m_sdbSizerButtons, 0, wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT, 5 ); - this->SetSizer( m_MainSizer ); this->Layout(); @@ -111,13 +132,13 @@ DIALOG_GEN_FOOTPRINT_POSITION_BASE::DIALOG_GEN_FOOTPRINT_POSITION_BASE( wxWindow // Connect Events m_browseButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); - m_sdbSizerButtonsOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::OnOKButton ), NULL, this ); + m_generateButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::OnGenerate ), NULL, this ); } DIALOG_GEN_FOOTPRINT_POSITION_BASE::~DIALOG_GEN_FOOTPRINT_POSITION_BASE() { // Disconnect Events m_browseButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::OnOutputDirectoryBrowseClicked ), NULL, this ); - m_sdbSizerButtonsOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::OnOKButton ), NULL, this ); + m_generateButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_GEN_FOOTPRINT_POSITION_BASE::OnGenerate ), NULL, this ); } diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp index 107aa41e64..da92393fb8 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.fbp @@ -94,8 +94,8 @@ wxVERTICAL protected - 5 - wxEXPAND + 2 + wxEXPAND|wxLEFT|wxRIGHT 0 @@ -103,8 +103,8 @@ wxHORIZONTAL none - 5 - + 10 + wxALL 1 @@ -112,8 +112,8 @@ wxVERTICAL none - 5 - wxEXPAND|wxTOP|wxLEFT + 10 + wxEXPAND 0 1 @@ -204,8 +204,8 @@ wxHORIZONTAL none - 5 - wxEXPAND|wxRIGHT|wxLEFT + 4 + wxBOTTOM|wxEXPAND|wxTOP 1 1 @@ -294,11 +294,11 @@ - - 5 - wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT + + 1 + wxRIGHT 0 - + 1 1 1 @@ -309,6 +309,7 @@ + 1 0 @@ -317,17 +318,20 @@ 1 0 0 + Dock 0 Left 1 1 + 0 0 + wxID_ANY - Browse... + MyButton 0 @@ -343,10 +347,11 @@ 1 Resizable + 1 - - + wxBU_AUTODRAW + ; forward_declare 0 @@ -390,287 +395,310 @@ 5 - wxEXPAND|wxTOP|wxBOTTOM + wxEXPAND|wxLEFT|wxRIGHT 0 - + + + wxBOTH + 1 + + 0 - bSizerOptions - wxHORIZONTAL + gbSizer1 + wxFLEX_GROWMODE_SPECIFIED none - + 0 + 5 - wxALL - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Ascii" "CSV" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Format: - 1 - - 0 - - - 0 + 1 + 0 + wxEXPAND + 0 + 1 + - 1 - m_rbFormat - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - + bOptionsSizer + wxHORIZONTAL + none + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "ASCII" "CSV" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Format: + 1 + + 0 + + + 0 + 90,-1 + 1 + m_rbFormat + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "Inches" "mm" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Units: + 1 + + 0 + + + 0 + 90,-1 + 1 + m_radioBoxUnits + 1 + + + protected + 1 + + Resizable + 0 + 1 + + wxRA_SPECIFY_COLS + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 1 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + "One file per side" "Single file for board" + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Files: + 1 + + 0 + + + 0 + + 1 + m_radioBoxFilesCount + 1 + + + protected + 1 + + Resizable + 1 + 1 + + wxRA_SPECIFY_COLS + + 0 + Creates 2 files: one for each board side or Creates only one file containing all footprints to place + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + 5 + 1 + 0 wxALL|wxEXPAND - 0 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "Inches" "mm" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Units: - 1 - - 0 - - - 0 - - 1 - m_radioBoxUnits - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 1 - - 1 - 1 - 1 - 1 - - - - - - - - 1 - 0 - "One file per side" "One file for board" - 1 - - 1 - 0 - Dock - 0 - Left - 1 - - 1 - - 0 - 0 - wxID_ANY - Files: - 1 - - 0 - - - 0 - - 1 - m_radioBoxFilesCount - 1 - - - protected - 1 - - Resizable - 0 - 1 - - wxRA_SPECIFY_COLS - - 0 - Creates 2 files: one for each board side or Creates only one file containing all footprints to place - - wxFILTER_NONE - wxDefaultValidator - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 5 - wxALL - 0 + 1 + 1 1 1 @@ -757,6 +785,209 @@ + + 5 + 1 + 1 + wxEXPAND + 0 + 2 + + 0 + protected + 0 + + + + 25 + 1 + 2 + wxEXPAND|wxLEFT|wxTOP + 0 + 2 + + 140,-1 + bButtonsSizer + wxVERTICAL + none + + 5 + wxALL|wxEXPAND + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Generate File + + 0 + + + 0 + + 1 + m_generateButton + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnGenerate + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL|wxEXPAND|wxTOP + 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_closeButton + 1 + + + protected + 1 + + Resizable + 1 + + + ; forward_declare + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -850,32 +1081,6 @@ - - 5 - wxEXPAND|wxTOP|wxBOTTOM|wxRIGHT - 0 - - 0 - 1 - 0 - 0 - 0 - 1 - 0 - 0 - - m_sdbSizerButtons - protected - - - - - - OnOKButton - - - - diff --git a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h index 4284d965ed..a4d5754d4e 100644 --- a/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h +++ b/pcbnew/dialogs/dialog_gen_footprint_position_file_base.h @@ -1,8 +1,8 @@ /////////////////////////////////////////////////////////////////////////// -// C++ code generated with wxFormBuilder (version Aug 4 2017) +// C++ code generated with wxFormBuilder (version Dec 30 2017) // http://www.wxformbuilder.org/ // -// PLEASE DO "NOT" EDIT THIS FILE! +// PLEASE DO *NOT* EDIT THIS FILE! /////////////////////////////////////////////////////////////////////////// #ifndef __DIALOG_GEN_FOOTPRINT_POSITION_FILE_BASE_H__ @@ -11,7 +11,6 @@ #include #include #include -class DIALOG_SHIM; class WX_HTML_REPORT_PANEL; #include "dialog_shim.h" @@ -22,9 +21,14 @@ class WX_HTML_REPORT_PANEL; #include #include #include +#include +#include +#include +#include #include #include #include +#include #include #include @@ -41,19 +45,18 @@ class DIALOG_GEN_FOOTPRINT_POSITION_BASE : public DIALOG_SHIM wxBoxSizer* m_MainSizer; wxStaticText* m_staticTextDir; wxTextCtrl* m_outputDirectoryName; - wxButton* m_browseButton; + wxBitmapButton* m_browseButton; wxRadioBox* m_rbFormat; wxRadioBox* m_radioBoxUnits; wxRadioBox* m_radioBoxFilesCount; wxRadioBox* m_radioBoxForceSmd; + wxButton* m_generateButton; + wxButton* m_closeButton; WX_HTML_REPORT_PANEL* m_messagesPanel; - wxStdDialogButtonSizer* m_sdbSizerButtons; - wxButton* m_sdbSizerButtonsOK; - wxButton* m_sdbSizerButtonsCancel; // Virtual event handlers, overide them in your derived class virtual void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) { event.Skip(); } - virtual void OnOKButton( wxCommandEvent& event ) { event.Skip(); } + virtual void OnGenerate( wxCommandEvent& event ) { event.Skip(); } public: diff --git a/pcbnew/exporters/gen_footprints_placefile.cpp b/pcbnew/exporters/gen_footprints_placefile.cpp index e44c4584b5..9c8a7f903b 100644 --- a/pcbnew/exporters/gen_footprints_placefile.cpp +++ b/pcbnew/exporters/gen_footprints_placefile.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -118,7 +119,7 @@ private: void initDialog(); void OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) override; - void OnOKButton( wxCommandEvent& event ) override; + void OnGenerate( wxCommandEvent& event ) override; bool CreateFiles(); @@ -157,6 +158,8 @@ const wxString backSideName = wxT( "bottom" ); void DIALOG_GEN_FOOTPRINT_POSITION::initDialog() { + m_browseButton->SetBitmap( KiBitmap( browse_files_xpm ) ); + m_config = Kiface().KifaceSettings(); m_config->Read( PLACEFILE_UNITS_KEY, &m_unitsOpt, 1 ); m_config->Read( PLACEFILE_OPT_KEY, &m_fileOpt, 0 ); @@ -168,7 +171,11 @@ void DIALOG_GEN_FOOTPRINT_POSITION::initDialog() m_radioBoxFilesCount->SetSelection( m_fileOpt ); m_rbFormat->SetSelection( m_fileFormat ); - m_sdbSizerButtonsOK->SetDefault(); + // Update sizes and sizers: + m_messagesPanel->MsgPanelSetMinSize( wxSize( -1, 160 ) ); + GetSizer()->SetSizeHints( this ); + + m_generateButton->SetDefault(); } void DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEvent& event ) @@ -200,7 +207,7 @@ void DIALOG_GEN_FOOTPRINT_POSITION::OnOutputDirectoryBrowseClicked( wxCommandEve m_outputDirectoryName->SetValue( dirName.GetFullPath() ); } -void DIALOG_GEN_FOOTPRINT_POSITION::OnOKButton( wxCommandEvent& event ) +void DIALOG_GEN_FOOTPRINT_POSITION::OnGenerate( wxCommandEvent& event ) { m_unitsOpt = m_radioBoxUnits->GetSelection(); m_fileOpt = m_radioBoxFilesCount->GetSelection();