Commit ecab9f8b authored by charras's avatar charras

Eeschema library config dialog enhancements: multi selection of lib names and up/down command

parent 50f5eb37
......@@ -43,6 +43,8 @@ private:
void OnOkClick( wxCommandEvent& event );
void OnCancelClick( wxCommandEvent& event );
void OnRemoveUserPath( wxCommandEvent& event );
void OnButtonUpClick( wxCommandEvent& event );
void OnButtonDownClick( wxCommandEvent& event );
public:
......@@ -127,6 +129,72 @@ void DIALOG_EESCHEMA_CONFIG::Init()
}
/********************************************************************/
void DIALOG_EESCHEMA_CONFIG::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_EESCHEMA_CONFIG::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_EESCHEMA_CONFIG::OnCancelClick( wxCommandEvent& event )
/******************************************************************/
......@@ -196,14 +264,14 @@ void DIALOG_EESCHEMA_CONFIG::OnRemoveLibClick( wxCommandEvent& event )
* The real list (m_Parent->m_ComponentLibFiles) is not changed, so the change can be cancelled
*/
{
int ii;
wxArrayInt selections;
ii = m_ListLibr->GetSelection();
if( ii < 0 )
return;
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;
}
}
......@@ -222,9 +290,14 @@ void DIALOG_EESCHEMA_CONFIG::OnAddOrInsertLibClick( wxCommandEvent& event )
wxString libfilename;
wxFileName fn;
ii = m_ListLibr->GetSelection();
if( ii == wxNOT_FOUND && event.GetId() != ID_ADD_LIB )
wxArrayInt selections;
m_ListLibr->GetSelections(selections);
ii = selections.GetCount();
if( ii <= 0 && event.GetId() != ID_ADD_LIB )
ii = 0;
else
ii = selections[0];
wxString libpath;
libpath = m_DefaultLibraryPathslistBox->GetStringSelection();
......
......@@ -19,7 +19,7 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
wxStaticBoxSizer* sbLibsChoiceSizer;
sbLibsChoiceSizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Component library files") ), wxHORIZONTAL );
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 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 ) );
......@@ -31,17 +31,23 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
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|wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 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") );
bRightSizer->Add( m_buttonIns, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP, 5 );
bRightSizer->Add( m_buttonIns, 0, wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 5 );
m_buttonRemoveLib = new wxButton( this, ID_REMOVE_LIB, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
m_buttonRemoveLib->SetToolTip( _("Unload the selected library") );
bRightSizer->Add( m_buttonRemoveLib, 0, wxALL|wxALIGN_CENTER_HORIZONTAL, 5 );
bRightSizer->Add( m_buttonRemoveLib, 0, wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND, 5 );
m_buttonUp = new wxButton( this, wxID_ANY, _("Up"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonUp, 0, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_buttonDown = new wxButton( this, wxID_ANY, _("Down"), wxDefaultPosition, wxDefaultSize, 0 );
bRightSizer->Add( m_buttonDown, 0, wxALL|wxEXPAND, 5 );
sbLibsChoiceSizer->Add( bRightSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
......@@ -60,13 +66,13 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
bUserPathsButtonsSizer = new wxBoxSizer( wxVERTICAL );
m_buttonAddPath = new wxButton( this, ID_LIB_PATH_SEL, _("Add"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonAddPath, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
bUserPathsButtonsSizer->Add( m_buttonAddPath, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 5 );
m_buttonInsPath = new wxButton( this, wxID_INSERT_PATH, _("Insert"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonInsPath, 0, wxLEFT|wxRIGHT|wxTOP, 5 );
bUserPathsButtonsSizer->Add( m_buttonInsPath, 0, wxLEFT|wxRIGHT|wxTOP|wxEXPAND, 5 );
m_buttonRemovePath = new wxButton( this, wxID_REMOVE_PATH, _("Remove"), wxDefaultPosition, wxDefaultSize, 0 );
bUserPathsButtonsSizer->Add( m_buttonRemovePath, 0, wxALL, 5 );
bUserPathsButtonsSizer->Add( m_buttonRemovePath, 0, wxALL|wxEXPAND, 5 );
sbSizer4->Add( bUserPathsButtonsSizer, 0, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
......@@ -102,9 +108,13 @@ DIALOG_EESCHEMA_CONFIG_FBP::DIALOG_EESCHEMA_CONFIG_FBP( wxWindow* parent, wxWind
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCloseWindow ) );
m_ListLibr->Connect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnFilesListClick ), NULL, this );
m_ListLibr->Connect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnFilesListClick ), NULL, this );
m_buttonAddLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonIns->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveLib->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonUp->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnButtonUpClick ), NULL, this );
m_buttonDown->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnButtonDownClick ), NULL, this );
m_buttonAddPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonInsPath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonRemovePath->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveUserPath ), NULL, this );
......@@ -116,9 +126,13 @@ DIALOG_EESCHEMA_CONFIG_FBP::~DIALOG_EESCHEMA_CONFIG_FBP()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnCloseWindow ) );
m_ListLibr->Disconnect( wxEVT_COMMAND_LISTBOX_SELECTED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnFilesListClick ), NULL, this );
m_ListLibr->Disconnect( wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnFilesListClick ), NULL, this );
m_buttonAddLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonIns->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertLibClick ), NULL, this );
m_buttonRemoveLib->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveLibClick ), NULL, this );
m_buttonUp->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnButtonUpClick ), NULL, this );
m_buttonDown->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnButtonDownClick ), NULL, this );
m_buttonAddPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonInsPath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnAddOrInsertPath ), NULL, this );
m_buttonRemovePath->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_EESCHEMA_CONFIG_FBP::OnRemoveUserPath ), NULL, this );
......
......@@ -106,7 +106,7 @@
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style">wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE</property>
<property name="style">wxLB_EXTENDED|wxLB_HSCROLL|wxLB_NEEDED_SB|wxLB_SINGLE</property>
<property name="subclass"></property>
<property name="tooltip">List of active library files.&#x0A;Only library files in this list are loaded by Eeschema.&#x0A;The order of this list is important:&#x0A;Eeschema searchs for a given component using this list order priority.</property>
<property name="window_extra_style"></property>
......@@ -122,8 +122,8 @@
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnListBox"></event>
<event name="OnListBoxDClick"></event>
<event name="OnListBox">OnFilesListClick</event>
<event name="OnListBoxDClick">OnFilesListClick</event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
......@@ -150,7 +150,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
......@@ -202,7 +202,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP</property>
<property name="flag">wxALIGN_CENTER_HORIZONTAL|wxLEFT|wxRIGHT|wxTOP|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
......@@ -254,7 +254,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL</property>
<property name="flag">wxALL|wxALIGN_CENTER_HORIZONTAL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
......@@ -304,6 +304,110 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="default">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Up</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_buttonUp</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnButtonUpClick</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>
<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="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="default">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Down</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_buttonDown</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnButtonDownClick</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>
<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="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>
......@@ -383,7 +487,7 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxLEFT|wxRIGHT|wxTOP</property>
<property name="flag">wxLEFT|wxRIGHT|wxTOP|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
......@@ -435,7 +539,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxLEFT|wxRIGHT|wxTOP</property>
<property name="flag">wxLEFT|wxRIGHT|wxTOP|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
......@@ -487,7 +591,7 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="flag">wxALL|wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
......
......@@ -45,6 +45,8 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
wxButton* m_buttonAddLib;
wxButton* m_buttonIns;
wxButton* m_buttonRemoveLib;
wxButton* m_buttonUp;
wxButton* m_buttonDown;
wxListBox* m_listUserPaths;
wxButton* m_buttonAddPath;
wxButton* m_buttonInsPath;
......@@ -54,8 +56,11 @@ class DIALOG_EESCHEMA_CONFIG_FBP : public wxDialog
// Virtual event handlers, overide them in your derived class
virtual void OnCloseWindow( wxCloseEvent& event ){ event.Skip(); }
virtual void OnFilesListClick( wxCommandEvent& 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 OnAddOrInsertPath( wxCommandEvent& event ){ event.Skip(); }
virtual void OnRemoveUserPath( wxCommandEvent& event ){ event.Skip(); }
virtual void OnCancelClick( 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