Move symbol management to a standard Save As... model.

Also brings horizontal toolbar in line with Pcbnew and Eeschema.
And updates the EDA_LIST_DIALOG to current practices.

This finishes the removal of the active library concept from the
Symbol Editor (started with the new component tree in 5.0).

Fixes: lp:1740717
* https://bugs.launchpad.net/kicad/+bug/1740717
This commit is contained in:
Jeff Young 2018-07-24 22:16:59 +01:00
parent e55bb9e748
commit 822ebf6955
16 changed files with 739 additions and 826 deletions

View File

@ -16,32 +16,32 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
wxBoxSizer* bSizerMain;
bSizerMain = new wxBoxSizer( wxVERTICAL );
m_filterLabel = new wxStaticText( this, wxID_ANY, _("Filter:"), wxDefaultPosition, wxDefaultSize, 0 );
m_filterLabel->Wrap( -1 );
m_filterLabel->SetToolTip( _("Enter a string to filter items.\nOnly names containing this string will be listed") );
bSizerMain->Add( m_filterLabel, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
m_filterBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bSizerMain->Add( m_filterBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
wxBoxSizer* bMargins;
bMargins = new wxBoxSizer( wxVERTICAL );
m_listLabel = new wxStaticText( this, wxID_ANY, _("Items:"), wxDefaultPosition, wxDefaultSize, 0 );
m_listLabel->Wrap( -1 );
bSizerMain->Add( m_listLabel, 0, wxRIGHT|wxLEFT, 5 );
bMargins->Add( m_listLabel, 0, wxALL, 5 );
m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES|wxALWAYS_SHOW_SB|wxVSCROLL );
m_listBox = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_HRULES|wxLC_REPORT|wxLC_SINGLE_SEL|wxLC_VRULES|wxALWAYS_SHOW_SB|wxRAISED_BORDER|wxVSCROLL );
m_listBox->SetMinSize( wxSize( -1,200 ) );
bSizerMain->Add( m_listBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
bMargins->Add( m_listBox, 3, wxBOTTOM|wxRIGHT|wxLEFT|wxEXPAND, 5 );
m_filterBox = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, 0 );
bMargins->Add( m_filterBox, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
m_staticTextMsg = new wxStaticText( this, wxID_ANY, _("Messages:"), wxDefaultPosition, wxDefaultSize, 0 );
m_staticTextMsg->Wrap( -1 );
bSizerMain->Add( m_staticTextMsg, 0, wxRIGHT|wxLEFT, 5 );
bMargins->Add( m_staticTextMsg, 0, wxRIGHT|wxLEFT, 5 );
m_messages = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxTE_MULTILINE|wxTE_READONLY );
m_messages->SetMinSize( wxSize( -1,80 ) );
bSizerMain->Add( m_messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bMargins->Add( m_messages, 1, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bSizerMain->Add( bMargins, 1, wxEXPAND|wxTOP|wxRIGHT|wxLEFT, 5 );
m_sdbSizer = new wxStdDialogButtonSizer();
m_sdbSizerOK = new wxButton( this, wxID_OK );
@ -60,22 +60,16 @@ EDA_LIST_DIALOG_BASE::EDA_LIST_DIALOG_BASE( wxWindow* parent, wxWindowID id, con
this->Centre( wxBOTH );
// Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) );
m_filterBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this );
m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this );
m_listBox->Connect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemSelected ), NULL, this );
m_sdbSizerCancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this );
m_sdbSizerOK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this );
m_filterBox->Connect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this );
}
EDA_LIST_DIALOG_BASE::~EDA_LIST_DIALOG_BASE()
{
// Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( EDA_LIST_DIALOG_BASE::onClose ) );
m_filterBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this );
m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_ACTIVATED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemActivated ), NULL, this );
m_listBox->Disconnect( wxEVT_COMMAND_LIST_ITEM_SELECTED, wxListEventHandler( EDA_LIST_DIALOG_BASE::onListItemSelected ), NULL, this );
m_sdbSizerCancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onCancelClick ), NULL, this );
m_sdbSizerOK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::onOkClick ), NULL, this );
m_filterBox->Disconnect( wxEVT_COMMAND_TEXT_UPDATED, wxCommandEventHandler( EDA_LIST_DIALOG_BASE::textChangeInFilterBox ), NULL, this );
}

View File

@ -61,7 +61,7 @@
<event name="OnAuiPaneRestore"></event>
<event name="OnAuiRender"></event>
<event name="OnChar"></event>
<event name="OnClose">onClose</event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
@ -95,181 +95,16 @@
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxStaticText" 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_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">Filter:</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="flag">wxEXPAND|wxTOP|wxRIGHT|wxLEFT</property>
<property name="proportion">1</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_filterLabel</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"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip">Enter a string to filter items.&#x0A;Only names containing this string will be listed</property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="wrap">-1</property>
<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>
<property name="name">bMargins</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" 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_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="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></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_filterBox</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"></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="value"></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="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">textChangeInFilterBox</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">wxRIGHT|wxLEFT</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxStaticText" expanded="1">
<property name="BottomDockable">1</property>
@ -409,7 +244,7 @@
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxALWAYS_SHOW_SB|wxVSCROLL</property>
<property name="window_style">wxALWAYS_SHOW_SB|wxRAISED_BORDER|wxVSCROLL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -455,6 +290,97 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" 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_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="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></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_filterBox</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"></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="value"></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="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">textChangeInFilterBox</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">wxRIGHT|wxLEFT</property>
@ -629,6 +555,8 @@
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL|wxEXPAND</property>
@ -646,11 +574,11 @@
<property name="name">m_sdbSizer</property>
<property name="permission">protected</property>
<event name="OnApplyButtonClick"></event>
<event name="OnCancelButtonClick">onCancelClick</event>
<event name="OnCancelButtonClick"></event>
<event name="OnContextHelpButtonClick"></event>
<event name="OnHelpButtonClick"></event>
<event name="OnNoButtonClick"></event>
<event name="OnOKButtonClick">onOkClick</event>
<event name="OnOKButtonClick"></event>
<event name="OnSaveButtonClick"></event>
<event name="OnYesButtonClick"></event>
</object>

View File

@ -18,8 +18,8 @@
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/textctrl.h>
#include <wx/listctrl.h>
#include <wx/textctrl.h>
#include <wx/sizer.h>
#include <wx/button.h>
#include <wx/dialog.h>
@ -35,10 +35,9 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM
private:
protected:
wxStaticText* m_filterLabel;
wxTextCtrl* m_filterBox;
wxStaticText* m_listLabel;
wxListCtrl* m_listBox;
wxTextCtrl* m_filterBox;
wxStaticText* m_staticTextMsg;
wxTextCtrl* m_messages;
wxStdDialogButtonSizer* m_sdbSizer;
@ -46,12 +45,9 @@ class EDA_LIST_DIALOG_BASE : public DIALOG_SHIM
wxButton* m_sdbSizerCancel;
// Virtual event handlers, overide them in your derived class
virtual void onClose( wxCloseEvent& event ) = 0;
virtual void textChangeInFilterBox( wxCommandEvent& event ) = 0;
virtual void onListItemActivated( wxListEvent& event ) = 0;
virtual void onListItemSelected( wxListEvent& event ) = 0;
virtual void onCancelClick( wxCommandEvent& event ) = 0;
virtual void onOkClick( wxCommandEvent& event ) = 0;
virtual void textChangeInFilterBox( wxCommandEvent& event ) = 0;
public:

View File

@ -35,10 +35,9 @@
// wxWidgets spends *far* too long calcuating column widths (most of it, believe it or
// not, in repeatedly creating/destorying a wxDC to do the measurement in).
// Use default column widths instead. (Note that these will be scaled down proportionally
// to fit the available space when the dialog is instantiated.)
static int DEFAULT_COL_WIDTHS[] = { 400, 200 };
// not, in repeatedly creating/destroying a wxDC to do the measurement in).
// Use default column widths instead.
static int DEFAULT_COL_WIDTHS[] = { 200, 600 };
@ -48,7 +47,7 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
const wxString& aSelection,
void( *aCallBackFunction )( wxString&, void* ),
void* aCallBackFunctionData,
bool aSortList ) :
bool aSortList, bool aShowHeaders ) :
EDA_LIST_DIALOG_BASE( aParent, wxID_ANY, aTitle )
{
m_sortList = aSortList;
@ -56,15 +55,18 @@ EDA_LIST_DIALOG::EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitl
m_cb_data = aCallBackFunctionData;
m_itemsListCp = &aItemList;
m_filterBox->SetHint( _( "Filter" ) );
initDialog( aItemHeaders, aSelection );
if( !aShowHeaders )
m_listBox->SetSingleStyle( wxLC_NO_HEADER, true );
// DIALOG_SHIM needs a unique hash_key because classname is not sufficient
// because so many dialogs share this same class, with different numbers of
// columns, different column names, and column widths.
m_hash_key = TO_UTF8( aTitle );
m_filterBox->SetFocus();
m_sdbSizerOK->SetDefault();
// this line fixes an issue on Linux Ubuntu using Unity (dialog not shown),
@ -109,9 +111,9 @@ void EDA_LIST_DIALOG::initDialog( const wxArrayString& aItemHeaders, const wxStr
}
void EDA_LIST_DIALOG::SetFilterLabel( const wxString& aLabel )
void EDA_LIST_DIALOG::SetFilterHint( const wxString& aHint )
{
m_filterLabel->SetLabel( aLabel );
m_filterBox->SetHint( aHint );
}
@ -121,6 +123,12 @@ void EDA_LIST_DIALOG::SetListLabel( const wxString& aLabel )
}
void EDA_LIST_DIALOG::SetOKLabel( const wxString& aLabel )
{
m_sdbSizerOK->SetLabel( aLabel );
}
void EDA_LIST_DIALOG::textChangeInFilterBox( wxCommandEvent& event )
{
wxString filter;
@ -216,12 +224,6 @@ void EDA_LIST_DIALOG::InsertItems( const std::vector< wxArrayString >& itemList,
}
void EDA_LIST_DIALOG::onCancelClick( wxCommandEvent& event )
{
EndModal( wxID_CANCEL );
}
void EDA_LIST_DIALOG::onListItemSelected( wxListEvent& event )
{
if( m_cb_func )
@ -240,18 +242,6 @@ void EDA_LIST_DIALOG::onListItemActivated( wxListEvent& event )
}
void EDA_LIST_DIALOG::onOkClick( wxCommandEvent& event )
{
EndModal( wxID_OK );
}
void EDA_LIST_DIALOG::onClose( wxCloseEvent& event )
{
EndModal( wxID_CANCEL );
}
/* Sort alphabetically, case insensitive.
*/
static int wxCALLBACK myCompareFunction( wxIntPtr aItem1, wxIntPtr aItem2,

View File

@ -224,11 +224,9 @@ enum id_eeschema_frm
ID_LIBEDIT_IMPORT_PART,
ID_LIBEDIT_EXPORT_PART,
ID_LIBEDIT_SAVE_PART,
ID_LIBEDIT_SAVE_PART_AS,
ID_LIBEDIT_REVERT_PART,
ID_LIBEDIT_REMOVE_PART,
ID_LIBEDIT_CUT_PART,
ID_LIBEDIT_COPY_PART,
ID_LIBEDIT_PASTE_PART,
ID_LIBEDIT_DUPLICATE_PART,
/* Library editor horizontal toolbar IDs. */

View File

@ -204,10 +204,6 @@ static EDA_HOTKEY HkCreatePin( _HKI( "Create Pin" ), HK_LIBEDIT_CREATE_PIN, 'P'
static EDA_HOTKEY HkInsertPin( _HKI( "Repeat Pin" ), HK_REPEAT_LAST, WXK_INSERT );
static EDA_HOTKEY HkMoveLibItem( _HKI( "Move Library Item" ), HK_LIBEDIT_MOVE_GRAPHIC_ITEM, 'M' );
// Load/save files
static EDA_HOTKEY HkSaveAllLib( _HKI( "Save All Libraries" ), HK_SAVE_ALL_LIBS, 'S' + GR_KB_CTRL,
ID_LIBEDIT_SAVE_ALL_LIBS );
// Autoplace fields
static EDA_HOTKEY HkAutoplaceFields( _HKI( "Autoplace Fields" ), HK_AUTOPLACE_FIELDS, 'O',
ID_AUTOPLACE_FIELDS );
@ -324,7 +320,6 @@ static EDA_HOTKEY* schematic_Hotkey_List[] =
// List of hotkey descriptors for library editor
static EDA_HOTKEY* libEdit_Hotkey_List[] =
{
&HkSaveAllLib,
&HkCreatePin,
&HkInsertPin,
&HkMoveLibItem,

View File

@ -71,7 +71,6 @@ enum hotkey_id_commnand {
HK_ADD_GRAPHIC_TEXT,
HK_ADD_GRAPHIC_POLYLINE,
HK_ADD_NOCONN_FLAG,
HK_SAVE_ALL_LIBS,
HK_LEFT_CLICK,
HK_LEFT_DCLICK,
HK_LEAVE_SHEET,

View File

@ -104,12 +104,10 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
EVT_TOOL( ID_LIBEDIT_IMPORT_PART, LIB_EDIT_FRAME::OnImportPart )
EVT_TOOL( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnExportPart )
EVT_TOOL( ID_LIBEDIT_SAVE_PART, LIB_EDIT_FRAME::OnSavePart )
EVT_TOOL( ID_LIBEDIT_SAVE_PART_AS, LIB_EDIT_FRAME::OnSavePartAs )
EVT_TOOL( ID_LIBEDIT_REVERT_PART, LIB_EDIT_FRAME::OnRevertPart )
EVT_TOOL( ID_LIBEDIT_REMOVE_PART, LIB_EDIT_FRAME::OnRemovePart )
EVT_TOOL( ID_LIBEDIT_CUT_PART, LIB_EDIT_FRAME::OnCopyCutPart )
EVT_TOOL( ID_LIBEDIT_COPY_PART, LIB_EDIT_FRAME::OnCopyCutPart )
EVT_TOOL( ID_LIBEDIT_PASTE_PART, LIB_EDIT_FRAME::OnPasteDuplicatePart )
EVT_TOOL( ID_LIBEDIT_DUPLICATE_PART, LIB_EDIT_FRAME::OnPasteDuplicatePart )
EVT_TOOL( ID_LIBEDIT_DUPLICATE_PART, LIB_EDIT_FRAME::OnDuplicatePart )
// Main horizontal toolbar.
EVT_TOOL( ID_TO_LIBVIEW, LIB_EDIT_FRAME::OnOpenLibraryViewer )
@ -174,10 +172,10 @@ BEGIN_EVENT_TABLE( LIB_EDIT_FRAME, EDA_DRAW_FRAME )
// Update user interface elements.
EVT_UPDATE_UI( wxID_PASTE, LIB_EDIT_FRAME::OnUpdatePaste )
EVT_UPDATE_UI( ID_LIBEDIT_REVERT_LIBRARY, LIB_EDIT_FRAME::OnUpdateLibModified )
EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_EXPORT_PART, LIB_EDIT_FRAME::OnUpdateHavePart )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_PART, LIB_EDIT_FRAME::OnUpdatePartModified )
EVT_UPDATE_UI( ID_LIBEDIT_SAVE_PART_AS, LIB_EDIT_FRAME::OnUpdateHavePart )
EVT_UPDATE_UI( ID_LIBEDIT_REVERT_PART, LIB_EDIT_FRAME::OnUpdatePartModified )
EVT_UPDATE_UI( ID_LIBEDIT_PASTE_PART, LIB_EDIT_FRAME::OnUpdateClipboardNotEmpty )
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_CHECK_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
EVT_UPDATE_UI( ID_LIBEDIT_GET_FRAME_EDIT_PART, LIB_EDIT_FRAME::OnUpdateEditingPart )
@ -495,6 +493,14 @@ void LIB_EDIT_FRAME::OnUpdateSearchTreeTool( wxUpdateUIEvent& aEvent )
}
void LIB_EDIT_FRAME::OnUpdateHavePart( wxUpdateUIEvent& aEvent )
{
LIB_ID libId = getTargetLibId();
aEvent.Enable( libId.IsValid() );
}
void LIB_EDIT_FRAME::OnUpdateEditingPart( wxUpdateUIEvent& aEvent )
{
LIB_PART* part = GetCurPart();
@ -541,12 +547,6 @@ void LIB_EDIT_FRAME::OnUpdateLibModified( wxUpdateUIEvent& aEvent )
}
void LIB_EDIT_FRAME::OnUpdateClipboardNotEmpty( wxUpdateUIEvent& aEvent )
{
aEvent.Enable( !!m_copiedPart );
}
void LIB_EDIT_FRAME::OnUpdateUndo( wxUpdateUIEvent& event )
{
event.Enable( GetCurPart() && GetScreen() &&
@ -592,7 +592,8 @@ void LIB_EDIT_FRAME::OnUpdateSaveAll( wxUpdateUIEvent& event )
break;
}
event.SetText( modified > 1 ? _( "Save All &Libraries..." ) : _( "Save All &Libraries" ) );
event.SetText( AddHotkeyName( modified > 1 ? _( "&Save..." ) : _( "&Save All" ),
g_Libedit_Hokeys_Descr, HK_SAVE ) );
event.Enable( modified > 0 );
}

View File

@ -292,6 +292,7 @@ public:
* the remaining unsaved changes.
*/
void OnSavePart( wxCommandEvent& aEvent );
void OnSavePartAs( wxCommandEvent& aEvent );
/**
* Reverts unsaved changes in a part, restoring to the last saved state.
@ -303,8 +304,7 @@ public:
*/
void OnRemovePart( wxCommandEvent& aEvent );
void OnCopyCutPart( wxCommandEvent& aEvent );
void OnPasteDuplicatePart( wxCommandEvent& aEvent );
void OnDuplicatePart( wxCommandEvent& aEvent );
void OnSelectAlias( wxCommandEvent& event );
void OnSelectPart( wxCommandEvent& event );
@ -336,6 +336,7 @@ public:
void OnUpdateSelectTool( wxUpdateUIEvent& aEvent );
void OnUpdateEditingPart( wxUpdateUIEvent& event );
void OnUpdatePartModified( wxUpdateUIEvent& aEvent );
void OnUpdateHavePart( wxUpdateUIEvent& aEvent );
void OnUpdateLibModified( wxUpdateUIEvent& aEvent );
void OnUpdateClipboardNotEmpty( wxUpdateUIEvent& aEvent );
void OnUpdateUndo( wxUpdateUIEvent& event );
@ -786,9 +787,6 @@ private:
///> Clipboard buffer storing LIB_ITEMs
BLOCK_SELECTOR m_clipboard;
// Copy/cut/paste buffer to move parts between libraries
std::unique_ptr<LIB_PART> m_copiedPart;
DECLARE_EVENT_TABLE()
};

View File

@ -53,24 +53,15 @@
#include <cmp_tree_model_adapter.h>
#include <dialogs/dialog_lib_new_component.h>
#include <dialog_helpers.h>
void LIB_EDIT_FRAME::DisplayLibInfos()
{
wxString lib = GetCurLib();
wxString title = _( "Symbol Library Editor - " );
wxString title = _( "Symbol Library Editor" );
if( !lib.empty() && Prj().SchSymbolLibTable()->HasLibrary( lib ) )
{
wxString fileName = Prj().SchSymbolLibTable()->GetFullURI( lib );
title += lib + " (" + fileName + ")";
if( wxFileName::FileExists( fileName ) && !wxFileName::IsFileWritable( fileName ) )
title += " " + _( "[Read Only]" );
}
else
title += _( "no library selected" );
if( GetCurPart() )
title += wxT( " - " ) + GetCurPart()->GetLibId().Format();
SetTitle( title );
}
@ -374,6 +365,104 @@ void LIB_EDIT_FRAME::OnSavePart( wxCommandEvent& aEvent )
}
void LIB_EDIT_FRAME::OnSavePartAs( wxCommandEvent& aEvent )
{
LIB_ID old_lib_id = getTargetLibId();
wxString old_name = old_lib_id.GetLibItemName();
wxString old_lib = old_lib_id.GetLibNickname();
LIB_PART* part = m_libMgr->GetBufferedPart( old_name, old_lib );
if( part )
{
SYMBOL_LIB_TABLE* tbl = Prj().SchSymbolLibTable();
wxArrayString headers;
std::vector< wxArrayString > itemsToDisplay;
std::vector< wxString > libNicknames = tbl->GetLogicalLibs();
headers.Add( _( "Nickname" ) );
headers.Add( _( "Description" ) );
for( const auto& name : libNicknames )
{
wxArrayString item;
item.Add( name );
item.Add( tbl->GetDescription( name ) );
itemsToDisplay.push_back( item );
}
EDA_LIST_DIALOG dlg( this, _( "Save Symbol As" ), headers, itemsToDisplay, old_lib,
nullptr, nullptr, /* sort */ false, /* show headers */ false );
dlg.SetListLabel( _( "Save in library:" ) );
dlg.SetOKLabel( _( "Save" ) );
wxBoxSizer* bNameSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticText* label = new wxStaticText( &dlg, wxID_ANY, _( "Name:" ),
wxDefaultPosition, wxDefaultSize, 0 );
bNameSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
wxTextCtrl* nameTextCtrl = new wxTextCtrl( &dlg, wxID_ANY, old_name,
wxDefaultPosition, wxDefaultSize, 0 );
bNameSizer->Add( nameTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxSizer* mainSizer = dlg.GetSizer();
mainSizer->Prepend( bNameSizer, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
// Move nameTextCtrl to the head of the tab-order
if( dlg.GetChildren().DeleteObject( nameTextCtrl ) )
dlg.GetChildren().Insert( nameTextCtrl );
dlg.SetInitialFocus( nameTextCtrl );
dlg.Layout();
mainSizer->Fit( &dlg );
if( dlg.ShowModal() != wxID_OK )
return; // canceled by user
wxString new_lib = dlg.GetTextSelection();
if( new_lib.IsEmpty() )
{
DisplayError( NULL, _( "No library specified. Symbol could not be saved." ) );
return;
}
wxString new_name = nameTextCtrl->GetValue();
new_name.Trim( true );
new_name.Trim( false );
new_name.Replace( " ", "_" );
if( new_name.IsEmpty() )
{
DisplayError( NULL, _( "No symbol name specified. Symbol could not be saved." ) );
return;
}
// Test if there is a component with this name already.
if( m_libMgr->PartExists( new_name, new_lib ) )
{
wxString msg = wxString::Format( _( "Symbol \"%s\" already exists in library \"%s\"" ),
new_name, new_lib );
DisplayError( this, msg );
return;
}
LIB_PART new_part( *part );
new_part.SetName( new_name );
fixDuplicateAliases( &new_part, new_lib );
m_libMgr->UpdatePart( &new_part, new_lib );
m_treePane->GetCmpTree()->SelectLibId( LIB_ID( new_lib, new_part.GetName() ) );
if( isCurrentPart( old_lib_id ) )
loadPart( new_name, new_lib, m_unit );
m_libMgr->RemovePart( old_name, old_lib );
}
}
void LIB_EDIT_FRAME::OnRemovePart( wxCommandEvent& aEvent )
{
LIB_ID libId = getTargetLibId();
@ -393,30 +482,7 @@ void LIB_EDIT_FRAME::OnRemovePart( wxCommandEvent& aEvent )
}
void LIB_EDIT_FRAME::OnCopyCutPart( wxCommandEvent& aEvent )
{
int unit = 0;
auto cmpTree = m_treePane->GetCmpTree();
LIB_ID partId = cmpTree->GetSelectedLibId( &unit );
LIB_PART* part = m_libMgr->GetBufferedPart( partId.GetLibItemName(), partId.GetLibNickname() );
if( !part )
return;
LIB_ID libId = getTargetLibId();
m_copiedPart.reset( new LIB_PART( *part ) );
if( aEvent.GetId() == ID_LIBEDIT_CUT_PART )
{
if( isCurrentPart( libId ) )
emptyScreen();
m_libMgr->RemovePart( libId.GetLibItemName(), libId.GetLibNickname() );
}
}
void LIB_EDIT_FRAME::OnPasteDuplicatePart( wxCommandEvent& aEvent )
void LIB_EDIT_FRAME::OnDuplicatePart( wxCommandEvent& aEvent )
{
int unit = 0;
LIB_ID libId = m_treePane->GetCmpTree()->GetSelectedLibId( &unit );
@ -425,14 +491,7 @@ void LIB_EDIT_FRAME::OnPasteDuplicatePart( wxCommandEvent& aEvent )
if( !m_libMgr->LibraryExists( lib ) )
return;
LIB_PART* srcPart = nullptr;
if( aEvent.GetId() == ID_LIBEDIT_DUPLICATE_PART )
srcPart = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib );
else if( aEvent.GetId() == ID_LIBEDIT_PASTE_PART )
srcPart = m_copiedPart.get();
else
wxFAIL;
LIB_PART* srcPart = m_libMgr->GetBufferedPart( libId.GetLibItemName(), lib );
if( !srcPart )
return;
@ -456,7 +515,10 @@ void LIB_EDIT_FRAME::fixDuplicateAliases( LIB_PART* aPart, const wxString& aLibr
while( m_libMgr->PartExists( newName, aLibrary ) )
{
newName = wxString::Format( "%s_%d", alias->GetName(), sfx );
if( sfx == 0 )
newName = wxString::Format( "%s_copy", alias->GetName() );
else
newName = wxString::Format( "%s_copy%d", alias->GetName(), sfx );
++sfx;
}

View File

@ -38,9 +38,6 @@
#include "lib_edit_frame.h"
/**
* @brief (Re)Create the menubar for the part editor frame
*/
void LIB_EDIT_FRAME::ReCreateMenuBar()
{
// wxWidgets handles the Mac Application menu behind the scenes, but that means
@ -54,7 +51,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
// Menu File:
wxMenu* fileMenu = new wxMenu;
// Creating/loading libraries
AddMenuItem( fileMenu,
ID_LIBEDIT_NEW_LIBRARY,
_( "&New Library..." ),
@ -63,19 +59,24 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
AddMenuItem( fileMenu,
ID_LIBEDIT_ADD_LIBRARY,
_( "&Add Library..." ),
_( "Add &Library..." ),
_( "Adds a previously created library" ),
KiBitmap( add_library_xpm ) );
// Separator
AddMenuItem( fileMenu,
ID_LIBEDIT_NEW_PART,
_( "New S&ymbol..." ),
_( "Create a new empty symbol" ),
KiBitmap( new_component_xpm ) );
fileMenu->AppendSeparator();
// Save library variants
text = AddHotkeyName( _( "&Save" ), g_Libedit_Hokeys_Descr, HK_SAVE );
AddMenuItem( fileMenu,
ID_LIBEDIT_SAVE_LIBRARY,
_( "&Save Library" ),
_( "Save the current library" ),
KiBitmap( save_library_xpm ) );
ID_LIBEDIT_SAVE_ALL_LIBS,
text,
_( "Save changes" ),
KiBitmap( save_xpm ) );
AddMenuItem( fileMenu,
ID_LIBEDIT_SAVE_LIBRARY_AS,
@ -83,31 +84,40 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
_( "Save the current library to a new file" ),
KiBitmap( save_as_xpm ) );
text = AddHotkeyName( _( "Save All &Libraries" ), g_Libedit_Hokeys_Descr, HK_SAVE_ALL_LIBS );
AddMenuItem( fileMenu, ID_LIBEDIT_SAVE_ALL_LIBS, text, _( "Save all library changes" ),
KiBitmap( save_xpm ) );
AddMenuItem( fileMenu,
ID_LIBEDIT_SAVE_PART_AS,
_( "Save Symbol As..." ),
_( "Saves a copy of the current symbol" ),
KiBitmap( save_part_xpm ) );
// Separator
fileMenu->AppendSeparator();
// Export as png file
AddMenuItem( fileMenu,
ID_LIBEDIT_IMPORT_PART,
_( "&Import Symbol..." ),
_( "Import a symbol to the current library" ),
KiBitmap( import_part_xpm ) );
AddMenuItem( fileMenu,
ID_LIBEDIT_EXPORT_PART,
_( "&Export Symbol..." ),
_( "Export the current symbol" ),
KiBitmap( export_part_xpm ) );
AddMenuItem( fileMenu,
ID_LIBEDIT_GEN_PNG_FILE,
_( "Export Current View as &PNG..." ),
_( "Export PNG..." ),
_( "Create a PNG file from the current view" ),
KiBitmap( plot_xpm ) );
// Export as SVG file
AddMenuItem( fileMenu,
ID_LIBEDIT_GEN_SVG_FILE,
_( "Create S&VG File..." ),
_( "Export SVG..." ),
_( "Create a SVG file from the current symbol" ),
KiBitmap( plot_svg_xpm ) );
// Separator
fileMenu->AppendSeparator();
// Quit
AddMenuItem( fileMenu,
wxID_EXIT,
_( "&Quit" ),
@ -117,16 +127,13 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
// Edit menu
wxMenu* editMenu = new wxMenu;
// Undo
text = AddHotkeyName( _( "&Undo" ), g_Libedit_Hokeys_Descr, HK_UNDO );
AddMenuItem( editMenu,
wxID_UNDO,
text,
_( "Undo last edit" ),
KiBitmap( undo_xpm ) );
// Redo
text = AddHotkeyName( _( "&Redo" ), g_Libedit_Hokeys_Descr, HK_REDO );
AddMenuItem( editMenu,
wxID_REDO,
@ -134,6 +141,34 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
_( "Redo the last undo command" ),
KiBitmap( redo_xpm ) );
editMenu->AppendSeparator();
AddMenuItem( editMenu,
ID_LIBEDIT_GET_FRAME_EDIT_PART,
_( "&Properties..." ),
_( "Edit symbol properties" ),
KiBitmap( part_properties_xpm ) );
AddMenuItem( editMenu,
ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
_( "&Fields..." ),
_( "Edit field properties" ),
KiBitmap( edit_text_xpm ) );
editMenu->AppendSeparator();
AddMenuItem( editMenu,
ID_LIBEDIT_EDIT_PIN_BY_TABLE,
_( "Pin &Table..." ),
_( "Show pin table" ),
KiBitmap( pin_table_xpm ) );
AddMenuItem( editMenu,
ID_LIBEDIT_CHECK_PART,
_( "Electrical Rules &Checker" ),
_( "Check duplicate and off grid pins" ),
KiBitmap( erc_xpm ) );
// Menu View:
wxMenu* viewMenu = new wxMenu;
@ -180,63 +215,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
_( "Toggles the search tree visibility" ),
KiBitmap( search_tree_xpm ) );
// Menu Part:
wxMenu* partMenu = new wxMenu;
AddMenuItem( partMenu,
ID_LIBEDIT_NEW_PART,
_( "&New Symbol..." ),
_( "Create a new empty symbol" ),
KiBitmap( new_component_xpm ) );
AddMenuItem( partMenu,
ID_LIBEDIT_SAVE_PART,
_( "&Save Symbol" ),
_( "Saves the current symbol to the library" ),
KiBitmap( save_part_xpm ) );
partMenu->AppendSeparator();
AddMenuItem( partMenu,
ID_LIBEDIT_IMPORT_PART,
_( "&Import Symbol..." ),
_( "Import a symbol to the current library" ),
KiBitmap( import_part_xpm ) );
AddMenuItem( partMenu,
ID_LIBEDIT_EXPORT_PART,
_( "&Export Symbol..." ),
_( "Export the current symbol" ),
KiBitmap( export_part_xpm ) );
partMenu->AppendSeparator();
AddMenuItem( partMenu,
ID_LIBEDIT_GET_FRAME_EDIT_PART,
_( "&Properties..." ),
_( "Edit symbol properties" ),
KiBitmap( part_properties_xpm ) );
AddMenuItem( partMenu,
ID_LIBEDIT_GET_FRAME_EDIT_FIELDS,
_( "&Fields..." ),
_( "Edit field properties" ),
KiBitmap( edit_text_xpm ) );
partMenu->AppendSeparator();
AddMenuItem( partMenu,
ID_LIBEDIT_EDIT_PIN_BY_TABLE,
_( "Pi&n Table..." ),
_( "Show pin table" ),
KiBitmap( pin_table_xpm ) );
AddMenuItem( partMenu,
ID_LIBEDIT_CHECK_PART,
_( "Electrical Rules Checker" ),
_( "Check duplicate and off grid pins" ),
KiBitmap( erc_xpm ) );
// Menu Place:
wxMenu* placeMenu = new wxMenu;
@ -349,7 +327,6 @@ void LIB_EDIT_FRAME::ReCreateMenuBar()
menuBar->Append( fileMenu, _( "&File" ) );
menuBar->Append( editMenu, _( "&Edit" ) );
menuBar->Append( viewMenu, _( "&View" ) );
menuBar->Append( partMenu, _( "&Symbol" ) );
menuBar->Append( placeMenu, _( "&Place" ) );
menuBar->Append( preferencesMenu, _( "P&references" ) );
menuBar->Append( helpMenu, _( "&Help" ) );

View File

@ -116,35 +116,16 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
_( "Create a new library" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_ADD_LIBRARY, wxEmptyString,
KiScaledBitmap( add_library_xpm, this ),
KiScaledBitmap( open_library_xpm, this ),
_( "Add an existing library" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_ALL_LIBS, wxEmptyString,
KiScaledBitmap( save_library_xpm, this ),
_( "Save all libraries" ) );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_LIBEDIT_NEW_PART, wxEmptyString,
KiScaledBitmap( new_component_xpm, this ),
_( "Create new symbol" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_PART, wxEmptyString,
KiScaledBitmap( save_part_xpm, this ),
_( "Save current symbol" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_IMPORT_PART, wxEmptyString,
KiScaledBitmap( import_part_xpm, this ),
_( "Import symbol" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_EXPORT_PART, wxEmptyString,
KiScaledBitmap( export_part_xpm, this ),
_( "Export symbol" ) );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( wxID_PASTE, wxEmptyString, KiScaledBitmap( paste_xpm, this ),
_( "Paste" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_SAVE_ALL_LIBS, wxEmptyString,
KiScaledBitmap( save_xpm, this ),
_( "Save libraries" ) );
KiScaledSeparator( m_mainToolBar, this );
@ -156,21 +137,6 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString,
KiScaledBitmap( part_properties_xpm, this ),
_( "Edit symbol properties" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxEmptyString,
KiScaledBitmap( text_xpm, this ),
_( "Edit field properties" ) );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, KiScaledBitmap( erc_xpm, this ),
_( "Check duplicate and off grid pins" ) );
KiScaledSeparator( m_mainToolBar, this );
msg = AddHotkeyName( HELP_ZOOM_REDRAW, g_Libedit_Hokeys_Descr, HK_ZOOM_REDRAW, IS_COMMENT );
m_mainToolBar->AddTool( ID_ZOOM_REDRAW, wxEmptyString,
KiScaledBitmap( zoom_redraw_xpm, this ), msg );
@ -191,12 +157,13 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
KiScaledBitmap( morgan1_xpm, this ),
_( "Show as \"De Morgan\" normal symbol" ), wxITEM_CHECK );
m_mainToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
KiScaledBitmap( morgan2_xpm, this ),
_( "Show as \"De Morgan\" convert symbol" ), wxITEM_CHECK );
m_mainToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_PART, wxEmptyString,
KiScaledBitmap( part_properties_xpm, this ),
_( "Edit symbol properties" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_GET_FRAME_EDIT_FIELDS, wxEmptyString,
KiScaledBitmap( text_xpm, this ),
_( "Edit field properties" ) );
KiScaledSeparator( m_mainToolBar, this );
@ -204,6 +171,22 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
KiScaledBitmap( datasheet_xpm, this ),
_( "Show associated datasheet or document" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_TABLE, wxEmptyString,
KiScaledBitmap( pin_table_xpm, this ),
_( "Show pin table" ) );
m_mainToolBar->AddTool( ID_LIBEDIT_CHECK_PART, wxEmptyString, KiScaledBitmap( erc_xpm, this ),
_( "Check duplicate and off grid pins" ) );
KiScaledSeparator( m_mainToolBar, this );
m_mainToolBar->AddTool( ID_DE_MORGAN_NORMAL_BUTT, wxEmptyString,
KiScaledBitmap( morgan1_xpm, this ),
_( "Show as \"De Morgan\" normal symbol" ), wxITEM_CHECK );
m_mainToolBar->AddTool( ID_DE_MORGAN_CONVERT_BUTT, wxEmptyString,
KiScaledBitmap( morgan2_xpm, this ),
_( "Show as \"De Morgan\" convert symbol" ), wxITEM_CHECK );
KiScaledSeparator( m_mainToolBar, this );
m_partSelectBox = new wxComboBox( m_mainToolBar,
@ -222,16 +205,13 @@ void LIB_EDIT_FRAME::ReCreateHToolbar()
0, nullptr, wxCB_READONLY );
m_mainToolBar->AddControl( m_aliasSelectBox );
m_mainToolBar->AddSeparator();
KiScaledSeparator( m_mainToolBar, this );
msg = _( "Synchronized pin edit mode\n"
"Synchronized pin edit mode propagates to other units all pin changes except pin number modification.\n"
"Enabled by default for multiunit parts with interchangeable units." );
m_mainToolBar->AddTool( ID_LIBEDIT_SYNC_PIN_EDIT, wxEmptyString,
KiScaledBitmap( pin2pin_xpm, this ), msg, wxITEM_CHECK );
m_mainToolBar->AddTool( ID_LIBEDIT_EDIT_PIN_BY_TABLE, wxEmptyString,
KiScaledBitmap( pin_table_xpm, this ),
_( "Show pin table" ) );
// after adding the buttons to the toolbar, must call Realize() to reflect the changes
m_mainToolBar->Realize();

View File

@ -40,7 +40,7 @@ CMP_TREE_PANE::CMP_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMgr )
wxBoxSizer* boxSizer = new wxBoxSizer( wxVERTICAL );
m_tree = new COMPONENT_TREE( this, &SYMBOL_LIB_TABLE::GetGlobalLibTable(),
m_libMgr->GetAdapter(), COMPONENT_TREE::SEARCH );
boxSizer->Add( m_tree, 1, wxEXPAND | wxALL, 5 );
boxSizer->Add( m_tree, 1, wxEXPAND, 5 );
SetSizer( boxSizer ); // should remove the previous sizer according to wxWidgets docs
Layout();
@ -65,28 +65,26 @@ CMP_TREE_PANE::CMP_TREE_PANE( LIB_EDIT_FRAME* aParent, LIB_MANAGER* aLibMgr )
KiBitmap( new_component_xpm ) );
AddMenuItem( menuLibrary.get(), ID_LIBEDIT_IMPORT_PART, _( "&Import Symbol..." ),
KiBitmap( import_part_xpm ) );
AddMenuItem( menuLibrary.get(), ID_LIBEDIT_PASTE_PART, _( "Paste Symbol" ),
KiBitmap( paste_xpm ) );
std::unique_ptr<wxMenu> menuPart = std::make_unique<wxMenu>();
AddMenuItem( menuPart.get(), ID_LIBEDIT_EDIT_PART, _( "&Edit Symbol" ),
KiBitmap( edit_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_REMOVE_PART, _( "Remove Symbol" ),
KiBitmap( delete_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_EXPORT_PART, _( "E&xport Symbol..." ),
KiBitmap( export_part_xpm ) );
menuPart->AppendSeparator();
AddMenuItem( menuPart.get(), ID_LIBEDIT_SAVE_PART, _( "&Save Symbol" ),
KiBitmap( save_part_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_SAVE_PART_AS, _( "Save Symbol As..." ),
KiBitmap( save_part_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_DUPLICATE_PART, _( "Duplicate Symbol" ),
KiBitmap( duplicate_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_REMOVE_PART, _( "Delete Symbol" ),
KiBitmap( delete_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_REVERT_PART, _( "Revert Symbol" ),
KiBitmap( undo_xpm ) );
menuPart->AppendSeparator();
AddMenuItem( menuPart.get(), ID_LIBEDIT_CUT_PART, _( "Cut Symbol" ),
KiBitmap( cut_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_COPY_PART, _( "Copy Symbol" ),
KiBitmap( copy_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_DUPLICATE_PART, _( "Duplicate Symbol" ),
KiBitmap( duplicate_xpm ) );
AddMenuItem( menuPart.get(), ID_LIBEDIT_EXPORT_PART, _( "E&xport Symbol..." ),
KiBitmap( export_part_xpm ) );
// Menu displayed when nothing is selected
std::unique_ptr<wxMenu> menuNoSelection = std::make_unique<wxMenu>();

View File

@ -64,7 +64,7 @@ COMPONENT_TREE::COMPONENT_TREE( wxWindow* aParent, SYMBOL_LIB_TABLE* aSymLibTabl
0, wxALIGN_CENTER | wxALL, 5 );
#endif
search_sizer->Add( m_query_ctrl, 1, wxALL | wxEXPAND, 5 );
search_sizer->Add( m_query_ctrl, 1, wxLEFT | wxTOP | wxEXPAND, 5 );
sizer->Add( search_sizer, 0, wxEXPAND, 5 );
m_query_ctrl->Bind( wxEVT_TEXT, &COMPONENT_TREE::onQueryText, this );
@ -77,7 +77,7 @@ COMPONENT_TREE::COMPONENT_TREE( wxWindow* aParent, SYMBOL_LIB_TABLE* aSymLibTabl
new wxDataViewCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxDV_SINGLE );
m_adapter->AttachTo( m_tree_ctrl );
sizer->Add( m_tree_ctrl, 1, wxALL | wxEXPAND, 5 );
sizer->Add( m_tree_ctrl, 1, wxLEFT | wxTOP | wxEXPAND, 5 );
// Description panel
if( aWidgets & DETAILS )

View File

@ -64,6 +64,7 @@ public:
* @param aCallBackFunction = callback function to display comments
* @param aCallBackFunctionData = a pointer to pass to @a aCallBackFunction
* @param aSortList = true to sort list items by alphabetic order.
* @param aShowHeaders = true if the list should have headers.
*/
EDA_LIST_DIALOG( EDA_DRAW_FRAME* aParent, const wxString& aTitle,
const wxArrayString& aItemHeaders,
@ -71,12 +72,13 @@ public:
const wxString& aRefText,
void (* aCallBackFunction)( wxString& text, void* data ) = NULL,
void* aCallBackFunctionData = NULL,
bool aSortList = false );
bool aSortList = false, bool aShowHeaders = true );
// ~EDA_LIST_DIALOG() {}
void SetFilterLabel( const wxString& aLabel );
void SetFilterHint( const wxString& aHint );
void SetListLabel( const wxString& aLabel );
void SetOKLabel( const wxString& aLabel );
void Append( const wxArrayString& aItemStr );
void InsertItems( const std::vector<wxArrayString>& aItemList, int aPosition = 0 );
@ -91,9 +93,6 @@ public:
wxString GetTextSelection( int aColumn = 0 );
private:
void onClose( wxCloseEvent& event ) override;
void onCancelClick( wxCommandEvent& event ) override;
void onOkClick( wxCommandEvent& event ) override;
void onListItemSelected( wxListEvent& event ) override;
void onListItemActivated( wxListEvent& event ) override;
void textChangeInFilterBox(wxCommandEvent& event) override;

View File

@ -714,40 +714,38 @@ bool FOOTPRINT_EDIT_FRAME::SaveFootprintInLibrary( wxString activeLibrary, MODUL
for( unsigned i = 0; i < nicknames.size(); i++ )
{
wxArrayString item;
item.Add( nicknames[i] );
item.Add( tbl->GetDescription( nicknames[i] ) );
itemsToDisplay.push_back( item );
}
EDA_LIST_DIALOG dlg( this, FMT_SAVE_MODULE, headers, itemsToDisplay, libraryName );
dlg.SetFilterLabel( _( "Library Filter:" ) );
dlg.SetListLabel( _( "Save in Library:" ) );
EDA_LIST_DIALOG dlg( this, FMT_SAVE_MODULE, headers, itemsToDisplay, libraryName,
nullptr, nullptr, /* sort */ false, /* show headers */ false );
dlg.SetListLabel( _( "Save in library:" ) );
dlg.SetOKLabel( _( "Save" ) );
wxSizer* mainSizer = dlg.GetSizer();
wxBoxSizer* bNameSizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticLine* separator = new wxStaticLine( &dlg, wxID_ANY, wxDefaultPosition,
wxDefaultSize, wxLI_HORIZONTAL );
mainSizer->Prepend( separator, 0, wxEXPAND|wxBOTTOM|wxTOP, 10 );
wxStaticText* label = new wxStaticText( &dlg, wxID_ANY, _( "Name:" ),
wxDefaultPosition, wxDefaultSize, 0 );
bNameSizer->Add( label, 0, wxALIGN_CENTER_VERTICAL|wxTOP|wxBOTTOM|wxLEFT, 5 );
wxTextCtrl* nameTextCtrl = new wxTextCtrl( &dlg, wxID_ANY, footprintName,
wxDefaultPosition, wxDefaultSize, 0 );
mainSizer->Prepend( nameTextCtrl, 0, wxEXPAND|wxBOTTOM|wxRIGHT|wxLEFT, 5 );
bNameSizer->Add( nameTextCtrl, 1, wxALIGN_CENTER_VERTICAL|wxALL, 5 );
wxTextValidator nameValidator( wxFILTER_EXCLUDE_CHAR_LIST );
nameValidator.SetCharExcludes( MODULE::StringLibNameInvalidChars( false ) );
nameTextCtrl->SetValidator( nameValidator );
wxStaticText* label = new wxStaticText( &dlg, wxID_ANY, _( "Footprint Name:" ),
wxDefaultPosition, wxDefaultSize, 0 );
mainSizer->Prepend( label, 0, wxTOP|wxRIGHT|wxLEFT, 5 );
wxSizer* mainSizer = dlg.GetSizer();
mainSizer->Prepend( bNameSizer, 0, wxEXPAND|wxTOP|wxLEFT|wxRIGHT, 5 );
// Move nameTextCtrl to the head of the tab-order
if( dlg.GetChildren().DeleteObject( nameTextCtrl ) )
dlg.GetChildren().Insert( nameTextCtrl );
nameTextCtrl->SetFocus();
dlg.SetInitialFocus( nameTextCtrl );
dlg.Layout();
mainSizer->Fit( &dlg );