Commit 59782e2f authored by charras's avatar charras

Enhancements in Pcbnew libraries config dialog

parent ecab9f8b
......@@ -138,19 +138,19 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonUpClick( wxCommandEvent& event )
m_ListLibr->GetSelections(selections);
if ( selections.GetCount() <= 0 ) // No selection.
return;
if( selections[0] == 0 ) // The first lib is selected. cannot move up it
return;
wxArrayString libnames = m_ListLibr->GetStrings();
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1]);
}
m_ListLibr->Set(libnames);
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
......@@ -177,7 +177,7 @@ void DIALOG_EESCHEMA_CONFIG::OnButtonDownClick( wxCommandEvent& event )
return;
wxArrayString libnames = m_ListLibr->GetStrings();
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
int jj = selections[ii];
......@@ -294,10 +294,10 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
m_ListLibr->GetSelections(selections);
ii = selections.GetCount();
if( ii <= 0 && event.GetId() != ID_ADD_LIB )
ii = 0;
else
if( ii > 0 )
ii = selections[0];
else
ii = 0;
wxString libpath;
libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
......
......@@ -23,7 +23,7 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
m_ListLibr->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Eeschema.\nThe order of this list is important:\nEeschema searchs for a given component using this list order priority.") );
m_ListLibr->SetMinSize( wxSize( 400,250 ) );
sbLibsChoiceSizer->Add( m_ListLibr, 1, wxALL|wxEXPAND, 5 );
sbLibsChoiceSizer->Add( m_ListLibr, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
......@@ -60,7 +60,7 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
m_listUserPaths->SetToolTip( _("Additional paths used in this project. The priority is highter than default Kicad paths.") );
m_listUserPaths->SetMinSize( wxSize( 400,90 ) );
sbSizer4->Add( m_listUserPaths, 1, wxALL|wxEXPAND, 5 );
sbSizer4->Add( m_listUserPaths, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bUserPathsButtonsSizer;
bUserPathsButtonsSizer = new wxBoxSizer( wxVERTICAL );
......@@ -76,7 +76,7 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
sbSizer4->Add( bUserPathsButtonsSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
bMainSizer->Add( sbSizer4, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbSizer4, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbLibPathSizer;
sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Current search path list") ), wxVERTICAL );
......@@ -87,10 +87,10 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
sbLibPathSizer->Add( m_DefaultLibraryPathslistBox, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbLibPathSizer, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbLibPathSizer, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticline3 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline3, 0, wxEXPAND | wxALL, 5 );
bMainSizer->Add( m_staticline3, 0, wxEXPAND|wxRIGHT|wxLEFT, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
......
......@@ -89,7 +89,7 @@
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxListBox" expanded="1">
<property name="bg"></property>
......@@ -414,7 +414,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
......@@ -426,7 +426,7 @@
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxListBox" expanded="1">
<property name="bg"></property>
......@@ -647,7 +647,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
......@@ -713,7 +713,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND | wxALL</property>
<property name="flag">wxEXPAND|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticLine" expanded="1">
<property name="bg"></property>
......
......@@ -141,6 +141,71 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnCloseWindow( wxCloseEvent& event )
}
/********************************************************************/
void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonUpClick( wxCommandEvent& event )
/********************************************************************/
{
wxArrayInt selections;
m_ListLibr->GetSelections(selections);
if ( selections.GetCount() <= 0 ) // No selection.
return;
if( selections[0] == 0 ) // The first lib is selected. cannot move up it
return;
wxArrayString libnames = m_ListLibr->GetStrings();
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj-1]);
}
m_ListLibr->Set(libnames);
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
m_ListLibr->SetSelection(jj-1);
}
m_LibListChanged = TRUE;
}
/*********************************************************************/
void DIALOG_PCBNEW_CONFIG_LIBS::OnButtonDownClick( wxCommandEvent& event )
/*********************************************************************/
{
wxArrayInt selections;
m_ListLibr->GetSelections(selections);
if ( selections.GetCount() <= 0 ) // No selection.
return;
// The last lib is selected. cannot move down it
if( selections.Last() == (int)(m_ListLibr->GetCount()-1) )
return;
wxArrayString libnames = m_ListLibr->GetStrings();
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
int jj = selections[ii];
EXCHG( libnames[jj], libnames[jj+1]);
}
m_ListLibr->Set(libnames);
// Reselect previously selected names
for( size_t ii = 0; ii < selections.GetCount(); ii++ )
{
int jj = selections[ii];
m_ListLibr->SetSelection(jj+1);
}
m_LibListChanged = TRUE;
}
/*********************************************************************/
void DIALOG_PCBNEW_CONFIG_LIBS::OnRemoveLibClick( wxCommandEvent& event )
......@@ -149,14 +214,14 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnRemoveLibClick( wxCommandEvent& event )
* The real list (g_LibName_List) is not changed, so the change can be canceled
*/
{
int ii;
ii = m_ListLibr->GetSelection();
if( ii < 0 )
return;
wxArrayInt selections;
m_ListLibr->Delete(ii);
m_LibListChanged = TRUE;
m_ListLibr->GetSelections(selections);
for( int ii = selections.GetCount()-1; ii >= 0; ii-- )
{
m_ListLibr->Delete(selections[ii] );
m_LibListChanged = TRUE;
}
}
......@@ -170,12 +235,17 @@ void DIALOG_PCBNEW_CONFIG_LIBS::OnAddOrInsertLibClick( wxCommandEvent& event )
* The real list (g_LibName_List) is not changed, so the change can be canceled
*/
{
int ii;
int ii = 0;
wxString libfilename;
wxFileName fn;
ii = m_ListLibr->GetSelection();
if( ii == wxNOT_FOUND )
wxArrayInt selections;
m_ListLibr->GetSelections(selections);
ii = selections.GetCount();
if( ii > 0 )
ii = selections[0];
else
ii = 0;
wxString libpath;
......
......@@ -31,6 +31,8 @@ private:
void OnCancelClick( wxCommandEvent& event );
void OnRemoveUserPath( wxCommandEvent& event );
void OnBrowseModDocFile( wxCommandEvent& event );
void OnButtonUpClick( wxCommandEvent& event );
void OnButtonDownClick( wxCommandEvent& event );
public:
......
......@@ -24,11 +24,11 @@ DIALOG_PCBNEW_CONFIG_LIBS_FBP::DIALOG_PCBNEW_CONFIG_LIBS_FBP( wxWindow* parent,
sbLibsChoiceSizer->Add( bLibsButtonsSizer, 0, wxALIGN_CENTER_HORIZONTAL, 5 );
m_ListLibr = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListLibr = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE );
m_ListLibr->SetToolTip( _("List of active library files.\nOnly library files in this list are loaded by Pcbnew.\nThe order of this list is important:\nPcbnew searchs for a given footprint using this list order priority.") );
m_ListLibr->SetMinSize( wxSize( 400,90 ) );
sbLibsChoiceSizer->Add( m_ListLibr, 1, wxALL|wxEXPAND, 5 );
sbLibsChoiceSizer->Add( m_ListLibr, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bRightSizer;
bRightSizer = new wxBoxSizer( wxVERTICAL );
......@@ -36,7 +36,7 @@ DIALOG_PCBNEW_CONFIG_LIBS_FBP::DIALOG_PCBNEW_CONFIG_LIBS_FBP( wxWindow* parent,
m_buttonAddLib = new wxButton( this, ID_ADD_LIB, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonAddLib->SetToolTip( _("Add a new library after the selected library, and load it") );
bRightSizer->Add( m_buttonAddLib, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5 );
bRightSizer->Add( m_buttonAddLib, 0, wxALIGN_CENTER_HORIZONTAL|wxRIGHT|wxLEFT, 5 );
m_buttonIns = new wxButton( this, wxID_ANY, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonIns->SetToolTip( _("Add a new library before the selected library, and load it") );
......@@ -48,20 +48,26 @@ DIALOG_PCBNEW_CONFIG_LIBS_FBP::DIALOG_PCBNEW_CONFIG_LIBS_FBP( wxWindow* parent,
bRightSizer->Add( m_buttonRemoveLib, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
sbLibsChoiceSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
m_buttonUp = new wxButton( this, wxID_ANY, _("Up"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonUp, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( sbLibsChoiceSizer, 1, wxALL|wxEXPAND, 5 );
m_buttonDown = new wxButton( this, wxID_ANY, _("Down"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonDown, 0, wxALL, 5 );
sbLibsChoiceSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
bMainSizer->Add( sbLibsChoiceSizer, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbModulesDocSizer;
sbModulesDocSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Footprint documentation file") ), wxHORIZONTAL );
m_TextHelpModulesFileName = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
sbModulesDocSizer->Add( m_TextHelpModulesFileName, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
sbModulesDocSizer->Add( m_TextHelpModulesFileName, 1, wxALIGN_CENTER_VERTICAL|wxRIGHT|wxLEFT, 5 );
m_buttonModDoc = new wxButton( this, wxID_BROWSE_MOD_DOC, _("Browse"), wxDefaultPosition, wxDefaultSize, 0 );
sbModulesDocSizer->Add( m_buttonModDoc, 0, wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 10 );
bMainSizer->Add( sbModulesDocSizer, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbModulesDocSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbSizer4;
sbSizer4 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("User defined search paths") ), wxHORIZONTAL );
......@@ -73,7 +79,7 @@ DIALOG_PCBNEW_CONFIG_LIBS_FBP::DIALOG_PCBNEW_CONFIG_LIBS_FBP( wxWindow* parent,
m_listUserPaths = new wxListBox( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0, NULL, 0 );
m_listUserPaths->SetToolTip( _("Additional paths used in this project. The priority is highter than default Kicad paths.") );
bUserListSizer->Add( m_listUserPaths, 1, wxALL|wxEXPAND, 5 );
bUserListSizer->Add( m_listUserPaths, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
sbSizer4->Add( bUserListSizer, 1, wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
......@@ -91,7 +97,7 @@ DIALOG_PCBNEW_CONFIG_LIBS_FBP::DIALOG_PCBNEW_CONFIG_LIBS_FBP( wxWindow* parent,
sbSizer4->Add( bUserPathsButtonsSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbSizer4, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbSizer4, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
wxStaticBoxSizer* sbLibPathSizer;
sbLibPathSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Current search path list") ), wxVERTICAL );
......@@ -107,10 +113,10 @@ DIALOG_PCBNEW_CONFIG_LIBS_FBP::DIALOG_PCBNEW_CONFIG_LIBS_FBP( wxWindow* parent,
sbLibPathSizer->Add( m_DefaultLibraryPathslistBox, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbLibPathSizer, 0, wxALL|wxEXPAND, 5 );
bMainSizer->Add( sbLibPathSizer, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_staticline1 = new wxStaticLine( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLI_HORIZONTAL );
bMainSizer->Add( m_staticline1, 0, wxEXPAND | wxALL, 5 );
bMainSizer->Add( m_staticline1, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_sdbSizer1 = new wxStdDialogButtonSizer();
m_sdbSizer1OK = new wxButton( this, wxID_OK );
......@@ -131,6 +137,8 @@ DIALOG_PCBNEW_CONFIG_LIBS_FBP::DIALOG_PCBNEW_CONFIG_LIBS_FBP( wxWindow* parent,
m_buttonAddLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonIns->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnRemoveLibClick ), NULL, this );
m_buttonUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnButtonUpClick ), NULL, this );
m_buttonDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnButtonDownClick ), NULL, this );
m_buttonModDoc->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnBrowseModDocFile ), NULL, this );
m_buttonAddPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonInsPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertPath ), NULL, this );
......@@ -146,6 +154,8 @@ DIALOG_PCBNEW_CONFIG_LIBS_FBP::~DIALOG_PCBNEW_CONFIG_LIBS_FBP()
m_buttonAddLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonIns->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnRemoveLibClick ), NULL, this );
m_buttonUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnButtonUpClick ), NULL, this );
m_buttonDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnButtonDownClick ), NULL, this );
m_buttonModDoc->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnBrowseModDocFile ), NULL, this );
m_buttonAddPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonInsPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_PCBNEW_CONFIG_LIBS_FBP::OnAddOrInsertPath ), NULL, this );
......
......@@ -47,6 +47,8 @@ class DIALOG_PCBNEW_CONFIG_LIBS_FBP : public wxDialog
wxButton* m_buttonAddLib;
wxButton* m_buttonIns;
wxButton* m_buttonRemoveLib;
wxButton* m_buttonUp;
wxButton* m_buttonDown;
wxTextCtrl* m_TextHelpModulesFileName;
wxButton* m_buttonModDoc;
wxListBox* m_listUserPaths;
......@@ -63,6 +65,8 @@ class DIALOG_PCBNEW_CONFIG_LIBS_FBP : public wxDialog
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); }
virtual void OnAddOrInsertLibClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveLibClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonUpClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnButtonDownClick( wxCommandEvent& event ){ event.Skip(); }
virtual void OnBrowseModDocFile( wxCommandEvent& event ){ event.Skip(); }
virtual void OnAddOrInsertPath( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveUserPath( 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