Commit 6e102489 authored by jean-pierre charras's avatar jean-pierre charras

Replace the wxFilePickedCtrl in Option Page dialog by an usual wxButton +...

Replace the wxFilePickedCtrl in Option Page dialog by an usual wxButton + wxTextCtrl, because under wxWdgets 2.8.12 the look and the behavior is very different between Windows and Linux.
parents 1293c026 5817c99a
......@@ -36,6 +36,7 @@
#include <wxstruct.h>
#include <worksheet_shape_builder.h>
#include <class_base_screen.h>
#include <wildcards_and_files_ext.h>
#include <wx/valgen.h>
#include <wx/tokenzr.h>
......@@ -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 );
}
......@@ -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
......
......@@ -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 );
......
......@@ -33,7 +33,6 @@ class DIALOG_SHIM;
#include <wx/datectrl.h>
#include <wx/dateevt.h>
#include <wx/checkbox.h>
#include <wx/filepicker.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
......@@ -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(); }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment