23#include <wx/tokenzr.h>
32#include <wx/clipbrd.h>
57 [
this]( wxCommandEvent& aEvent )
63 [
this]( wxCommandEvent& aEvent )
108 const auto& projectAliases =
m_frame->Prj().GetProjectFile().m_BusAliases;
110 std::vector<std::pair<wxString, std::vector<wxString>>> aliasList( projectAliases.begin(),
111 projectAliases.end() );
113 std::sort( aliasList.begin(), aliasList.end(),
114 [](
const std::pair<wxString, std::vector<wxString>>& a,
115 const std::pair<wxString, std::vector<wxString>>& b )
117 return a.first.CmpNoCase( b.first ) < 0;
120 for(
const auto& alias : aliasList )
122 std::shared_ptr<BUS_ALIAS> entry = std::make_shared<BUS_ALIAS>();
124 entry->SetName( alias.first );
125 entry->SetMembers( alias.second );
135 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
173 [&]() -> std::pair<int, int>
176 m_aliases.push_back( std::make_shared<BUS_ALIAS>() );
185 if( ( row > 0 ) && (
m_lastAlias == ( row - 1 ) ) )
217 [&]() -> std::pair<int, int>
230 bool clipboardHasText =
false;
232 if( wxTheClipboard->Open() )
234 if( wxTheClipboard->IsSupported( wxDF_TEXT )
235 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
237 clipboardHasText =
true;
240 wxTheClipboard->Close();
243 if( clipboardHasText )
260 alias->ClearMembers();
270 int row =
event.GetRow();
274 wxString
name =
event.GetString();
278 if( ii == event.GetRow() )
283 m_errorMsg = wxString::Format(
_(
"Alias name '%s' already in use." ),
name );
299 int row =
event.GetRow();
303 wxString
name =
event.GetString();
307 m_errorMsg =
_(
"Member net/alias name cannot be empty." );
336 wxString membersLabel;
348 for(
const wxString& member : alias->Members() )
371 int colSize = std::max(
grid->GetClientSize().x,
grid->GetVisibleWidth( 0 ) );
373 if(
grid->GetColSize( 0 ) != colSize )
374 grid->SetColSize( 0, colSize );
396 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
418 wxGridCellEditor* cellEditor =
m_aliasesGrid->GetCellEditor( row, 0 );
420 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
421 aliasName = txt->GetValue();
423 cellEditor->DecRef();
448 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[ row ];
449 alias->SetName( aliasName );
462 std::vector<std::pair<wxString, std::vector<wxString>>> aliasList( aAliases.begin(),
465 std::sort( aliasList.begin(), aliasList.end(),
466 [](
const std::pair<wxString, std::vector<wxString>>& a,
467 const std::pair<wxString, std::vector<wxString>>& b )
469 return a.first.CmpNoCase( b.first ) < 0;
472 for(
const auto& alias : aliasList )
474 std::shared_ptr<BUS_ALIAS> entry = std::make_shared<BUS_ALIAS>();
476 entry->SetName( alias.first );
477 entry->SetMembers( alias.second );
487 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
499 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[aAliasIndex];
501 alias->ClearMembers();
506 wxStringTokenizer tok( cellValue,
" " );
508 if( tok.CountTokens() > 1 )
514 while( tok.HasMoreTokens() )
515 alias->AddMember( tok.GetNextToken() );
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)