31#include <wx/clipbrd.h>
56 [
this]( wxCommandEvent& aEvent )
62 [
this]( wxCommandEvent& aEvent )
107 const auto& projectAliases =
m_frame->Prj().GetProjectFile().m_BusAliases;
109 std::vector<std::pair<wxString, std::vector<wxString>>> aliasList( projectAliases.begin(),
110 projectAliases.end() );
112 std::sort( aliasList.begin(), aliasList.end(),
113 [](
const std::pair<wxString, std::vector<wxString>>& a,
114 const std::pair<wxString, std::vector<wxString>>& b )
116 return a.first.CmpNoCase( b.first ) < 0;
119 for(
const auto& alias : aliasList )
121 std::shared_ptr<BUS_ALIAS> entry = std::make_shared<BUS_ALIAS>();
123 entry->SetName( alias.first );
124 entry->Members() = alias.second;
134 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
172 [&]() -> std::pair<int, int>
175 m_aliases.push_back( std::make_shared<BUS_ALIAS>() );
184 if( ( row > 0 ) && (
m_lastAlias == ( row - 1 ) ) )
216 [&]() -> std::pair<int, int>
229 bool clipboardHasText =
false;
231 if( wxTheClipboard->Open() )
233 if( wxTheClipboard->IsSupported( wxDF_TEXT )
234 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
236 clipboardHasText =
true;
239 wxTheClipboard->Close();
242 if( clipboardHasText )
259 alias->Members().clear();
262 alias->Members().push_back(
m_membersGrid->GetCellValue( ii, 0 ) );
269 int row =
event.GetRow();
273 wxString
name =
event.GetString();
277 if( ii == event.GetRow() )
282 m_errorMsg = wxString::Format(
_(
"Alias name '%s' already in use." ),
name );
298 int row =
event.GetRow();
302 wxString
name =
event.GetString();
306 m_errorMsg =
_(
"Member net/alias name cannot be empty." );
316 alias->Members().clear();
323 wxStringTokenizer tok(
name,
" " );
325 if( tok.CountTokens() > 1 )
331 while( tok.HasMoreTokens() )
332 alias->Members().push_back( tok.GetNextToken() );
336 alias->Members().push_back(
m_membersGrid->GetCellValue( ii, 0 ) );
361 wxString membersLabel;
373 for(
const wxString& member : alias->Members() )
396 int colSize = std::max(
grid->GetClientSize().x,
grid->GetVisibleWidth( 0 ) );
398 if(
grid->GetColSize( 0 ) != colSize )
399 grid->SetColSize( 0, colSize );
421 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
443 wxGridCellEditor* cellEditor =
m_aliasesGrid->GetCellEditor( row, 0 );
445 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
446 aliasName = txt->GetValue();
448 cellEditor->DecRef();
473 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[ row ];
474 alias->SetName( aliasName );
487 std::vector<std::pair<wxString, std::vector<wxString>>> aliasList( aAliases.begin(),
490 std::sort( aliasList.begin(), aliasList.end(),
491 [](
const std::pair<wxString, std::vector<wxString>>& a,
492 const std::pair<wxString, std::vector<wxString>>& b )
494 return a.first.CmpNoCase( b.first ) < 0;
497 for(
const auto& alias : aliasList )
499 std::shared_ptr<BUS_ALIAS> entry = std::make_shared<BUS_ALIAS>();
501 entry->SetName( alias.first );
502 entry->Members() = alias.second;
512 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
524 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[aAliasIndex];
526 alias->Members().clear();
532 if( !memberValue.empty() )
534 alias->Members().push_back( memberValue );
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap, int aMinHeight)
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
STD_BITMAP_BUTTON * m_addAlias
wxSimplebook * m_membersBook
STD_BITMAP_BUTTON * m_addMember
PANEL_SETUP_BUSES_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
STD_BITMAP_BUTTON * m_deleteAlias
wxStaticText * m_membersLabel
STD_BITMAP_BUTTON * m_removeMember
void OnAliasesGridCellChanging(wxGridEvent &event)
std::vector< std::shared_ptr< BUS_ALIAS > > m_aliases
void reloadMembersGridOnIdle(wxIdleEvent &aEvent)
void OnDeleteAlias(wxCommandEvent &aEvent) override
void OnUpdateUI(wxUpdateUIEvent &event) override
void OnSizeGrid(wxSizeEvent &event) override
PANEL_SETUP_BUSES(wxWindow *aWindow, SCH_EDIT_FRAME *aFrame)
bool TransferDataToWindow() override
void OnMemberGridCellChanged(wxGridEvent &event)
void updateAliasMembers(int aAliasIndex)
Keep the BUS_ALIAS member list synchronized with the values displayed in the grid.
wxString m_membersLabelTemplate
void OnRemoveMember(wxCommandEvent &aEvent) override
void OnMemberGridCellChanging(wxGridEvent &event)
bool TransferDataFromWindow() override
void OnAddMember(wxCommandEvent &aEvent) override
void ImportSettingsFrom(const std::map< wxString, std::vector< wxString > > &aAliases)
void doReloadMembersGrid()
void OnAddAlias(wxCommandEvent &aEvent) override
Schematic editor (Eeschema) main window.
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
This file is part of the common library.
KICOMMON_API wxFont GetSmallInfoFont(wxWindow *aWindow)