diff --git a/common/dialogs/dialog_page_settings.cpp b/common/dialogs/dialog_page_settings.cpp index 7ab002480b..9886bd070b 100644 --- a/common/dialogs/dialog_page_settings.cpp +++ b/common/dialogs/dialog_page_settings.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -125,8 +126,7 @@ void DIALOG_PAGES_SETTINGS::initDialog() } // initialize the page layout descr filename - m_plDescrFileName = BASE_SCREEN::m_PageLayoutDescrFileName; - m_filePicker->SetPath( m_plDescrFileName ); + SetWksFileName( BASE_SCREEN::m_PageLayoutDescrFileName ); #ifdef EESCHEMA @@ -401,13 +401,13 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings() { bool retSuccess = false; - m_plDescrFileName = m_filePicker->GetPath(); + wxString fileName = GetWksFileName(); - if( m_plDescrFileName != BASE_SCREEN::m_PageLayoutDescrFileName ) + if( fileName != BASE_SCREEN::m_PageLayoutDescrFileName ) { - if( !m_plDescrFileName.IsEmpty() ) + if( !fileName.IsEmpty() ) { - wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( m_plDescrFileName ); + wxString fullFileName = WORKSHEET_LAYOUT::MakeFullFileName( fileName ); if( !wxFileExists( fullFileName ) ) { wxString msg; @@ -418,26 +418,9 @@ bool DIALOG_PAGES_SETTINGS::SavePageSettings() } } - // Try to remove the path, if the path is the current working dir, - // or the dir of kicad.pro (template) - wxString shortFileName = WORKSHEET_LAYOUT::MakeShortFileName( m_plDescrFileName ); - wxFileName fn = shortFileName; - - // For Win/Linux/macOS compatibility, a relative path is a good idea - if( fn.IsAbsolute() ) - { - fn.MakeRelativeTo( wxGetCwd() ); - wxString msg; - msg.Printf( _( "The page layout descr filename has changed\n" - "Do you want to use the relative path:\n%s"), - fn.GetFullPath().GetData() ); - if( IsOK( this, msg ) ) - shortFileName = fn.GetFullPath(); - } - - BASE_SCREEN::m_PageLayoutDescrFileName = shortFileName; + BASE_SCREEN::m_PageLayoutDescrFileName = fileName; WORKSHEET_LAYOUT& pglayout = WORKSHEET_LAYOUT::GetTheInstance(); - pglayout.SetPageLayout( shortFileName ); + pglayout.SetPageLayout( fileName ); m_localPrjConfigChanged = true; } @@ -793,7 +776,35 @@ void DIALOG_PAGES_SETTINGS::GetCustomSizeMilsFromDialog() } // Called on .kicad_wks file description selection change -void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxFileDirPickerEvent& event ) +void DIALOG_PAGES_SETTINGS::OnWksFileSelection( wxCommandEvent& event ) { - // Currently: Nothing to do. + // Display a file picker dialog + wxFileDialog fileDialog( this, _( "Select Page Layout Descr File" ), + wxGetCwd(), GetWksFileName(), + PageLayoutDescrFileWildcard, + wxFD_DEFAULT_STYLE | wxFD_FILE_MUST_EXIST ); + + if( fileDialog.ShowModal() != wxID_OK ) + return; + + wxString fileName = fileDialog.GetPath(); + + // Try to remove the path, if the path is the current working dir, + // or the dir of kicad.pro (template) + wxString shortFileName = WORKSHEET_LAYOUT::MakeShortFileName( fileName ); + wxFileName fn = shortFileName; + + // For Win/Linux/macOS compatibility, a relative path is a good idea + if( fn.IsAbsolute() && fileName != GetWksFileName() ) + { + fn.MakeRelativeTo( wxGetCwd() ); + wxString msg; + msg.Printf( _( "The page layout descr filename has changed\n" + "Do you want to use the relative path:\n%s"), + fn.GetFullPath().GetData() ); + if( IsOK( this, msg ) ) + shortFileName = fn.GetFullPath(); + } + + SetWksFileName( shortFileName ); } diff --git a/common/dialogs/dialog_page_settings.h b/common/dialogs/dialog_page_settings.h index cdb2c02297..073606346c 100644 --- a/common/dialogs/dialog_page_settings.h +++ b/common/dialogs/dialog_page_settings.h @@ -45,9 +45,6 @@ private: PAGE_INFO m_pageInfo; /// Temporary page info. bool m_customFmt; /// true if the page selection is custom TITLE_BLOCK m_tb; /// Temporary title block (basic inscriptions). - wxString m_plDescrFileName; /// Temporary BASE_SCREEN::m_PageLayoutDescrFileName copy - - public: DIALOG_PAGES_SETTINGS( EDA_DRAW_FRAME* parent ); @@ -55,24 +52,23 @@ public: const wxString GetWksFileName() { - return m_filePicker->GetPath(); + return m_textCtrlFilePicker->GetValue(); } void SetWksFileName(const wxString& aFilename ) { - m_filePicker->SetPath( aFilename ); + m_textCtrlFilePicker->SetValue( aFilename ); } void EnableWksFileNamePicker( bool aEnable ) { - m_filePicker->Enable( aEnable ); + m_textCtrlFilePicker->Enable( aEnable ); + m_buttonBrowse->Enable( aEnable ); } private: void initDialog(); // Initialisation of member variables -// void OnCloseWindow( wxCloseEvent& event ); - // event handler for wxID_OK void OnOkClick( wxCommandEvent& event ); @@ -99,7 +95,7 @@ private: void OnDateApplyClick( wxCommandEvent& event ); // .kicad_wks file description selection - void OnWksFileSelection( wxFileDirPickerEvent& event ); + void OnWksFileSelection( wxCommandEvent& event ); // Save in the current title block the new page settings // return true if changes are made, or false if not diff --git a/common/dialogs/dialog_page_settings_base.cpp b/common/dialogs/dialog_page_settings_base.cpp index 28865814ec..0f99290cb1 100644 --- a/common/dialogs/dialog_page_settings_base.cpp +++ b/common/dialogs/dialog_page_settings_base.cpp @@ -350,8 +350,11 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind wxBoxSizer* bSizerfileSelection; bSizerfileSelection = new wxBoxSizer( wxHORIZONTAL ); - m_filePicker = new wxFilePickerCtrl( this, wxID_ANY, wxEmptyString, _("Select a file"), wxT("*.kicad_wks"), wxDefaultPosition, wxDefaultSize, wxFLP_OPEN|wxFLP_USE_TEXTCTRL ); - bSizerfileSelection->Add( m_filePicker, 1, wxBOTTOM|wxRIGHT|wxLEFT, 5 ); + m_textCtrlFilePicker = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 ); + bSizerfileSelection->Add( m_textCtrlFilePicker, 1, wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL, 5 ); + + m_buttonBrowse = new wxButton( this, wxID_ANY, _("Browse"), wxDefaultPosition, wxDefaultSize, wxBU_EXACTFIT ); + bSizerfileSelection->Add( m_buttonBrowse, 0, wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT, 5 ); bSizerFilename->Add( bSizerfileSelection, 1, wxEXPAND, 5 ); @@ -393,7 +396,7 @@ DIALOG_PAGES_SETTINGS_BASE::DIALOG_PAGES_SETTINGS_BASE( wxWindow* parent, wxWind m_TextComment2->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnComment2TextUpdated ), NULL, this ); m_TextComment3->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnComment3TextUpdated ), NULL, this ); m_TextComment4->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnComment4TextUpdated ), NULL, this ); - m_filePicker->Connect( wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnWksFileSelection ), NULL, this ); + m_buttonBrowse->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnWksFileSelection ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCancelClick ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnOkClick ), NULL, this ); } @@ -415,7 +418,7 @@ DIALOG_PAGES_SETTINGS_BASE::~DIALOG_PAGES_SETTINGS_BASE() m_TextComment2->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnComment2TextUpdated ), NULL, this ); m_TextComment3->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnComment3TextUpdated ), NULL, this ); m_TextComment4->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnComment4TextUpdated ), NULL, this ); - m_filePicker->Disconnect( wxEVT_COMMAND_FILEPICKER_CHANGED, wxFileDirPickerEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnWksFileSelection ), NULL, this ); + m_buttonBrowse->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnWksFileSelection ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnCancelClick ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PAGES_SETTINGS_BASE::OnOkClick ), NULL, this ); diff --git a/common/dialogs/dialog_page_settings_base.fbp b/common/dialogs/dialog_page_settings_base.fbp index 90b35d6158..ce60f5331c 100644 --- a/common/dialogs/dialog_page_settings_base.fbp +++ b/common/dialogs/dialog_page_settings_base.fbp @@ -4235,9 +4235,9 @@ none 5 - wxBOTTOM|wxRIGHT|wxLEFT + wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL 1 - + 1 1 1 @@ -4268,12 +4268,12 @@ 0 - Select a file + 0 1 - m_filePicker + m_textCtrlFilePicker 1 @@ -4283,7 +4283,7 @@ Resizable 1 - wxFLP_OPEN|wxFLP_USE_TEXTCTRL + 0 @@ -4292,14 +4292,104 @@ wxDefaultValidator - *.kicad_wks - OnWksFileSelection + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Browse + + 0 + + + 0 + + 1 + m_buttonBrowse + 1 + + + protected + 1 + + Resizable + 1 + + wxBU_EXACTFIT + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnWksFileSelection + + + diff --git a/common/dialogs/dialog_page_settings_base.h b/common/dialogs/dialog_page_settings_base.h index 689f553d37..9ba85e6a18 100644 --- a/common/dialogs/dialog_page_settings_base.h +++ b/common/dialogs/dialog_page_settings_base.h @@ -33,7 +33,6 @@ class DIALOG_SHIM; #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -113,7 +112,8 @@ class DIALOG_PAGES_SETTINGS_BASE : public DIALOG_SHIM wxTextCtrl* m_TextComment4; wxCheckBox* m_Comment4Export; wxStaticText* m_staticTextfilename; - wxFilePickerCtrl* m_filePicker; + wxTextCtrl* m_textCtrlFilePicker; + wxButton* m_buttonBrowse; wxStdDialogButtonSizer* m_sdbSizer1; wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1Cancel; @@ -133,7 +133,7 @@ class DIALOG_PAGES_SETTINGS_BASE : public DIALOG_SHIM virtual void OnComment2TextUpdated( wxCommandEvent& event ) { event.Skip(); } virtual void OnComment3TextUpdated( wxCommandEvent& event ) { event.Skip(); } virtual void OnComment4TextUpdated( wxCommandEvent& event ) { event.Skip(); } - virtual void OnWksFileSelection( wxFileDirPickerEvent& event ) { event.Skip(); } + virtual void OnWksFileSelection( wxCommandEvent& event ) { event.Skip(); } virtual void OnCancelClick( wxCommandEvent& event ) { event.Skip(); } virtual void OnOkClick( wxCommandEvent& event ) { event.Skip(); }