Commit 5817c99a 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.
parent 1293c026
......@@ -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 );
......
......@@ -4235,9 +4235,9 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="flag">wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER_VERTICAL</property>
<property name="proportion">1</property>
<object class="wxFilePickerCtrl" expanded="1">
<object class="wxTextCtrl" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
......@@ -4268,12 +4268,12 @@
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="message">Select a file</property>
<property name="maxlength"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_filePicker</property>
<property name="name">m_textCtrlFilePicker</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
......@@ -4283,7 +4283,7 @@
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxFLP_OPEN|wxFLP_USE_TEXTCTRL</property>
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
......@@ -4292,14 +4292,104 @@
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="wildcard">*.kicad_wks</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnFileChanged">OnWksFileSelection</event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_VERTICAL|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Browse</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_buttonBrowse</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style">wxBU_EXACTFIT</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnWksFileSelection</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
......
......@@ -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