25#include <wx/tokenzr.h>
34#include <wx/clipbrd.h>
59 [
this]( wxCommandEvent& aEvent )
65 [
this]( wxCommandEvent& aEvent )
110 const auto& projectAliases =
m_frame->Prj().GetProjectFile().m_BusAliases;
112 std::vector<std::pair<wxString, std::vector<wxString>>> aliasList( projectAliases.begin(),
113 projectAliases.end() );
115 std::sort( aliasList.begin(), aliasList.end(),
116 [](
const std::pair<wxString, std::vector<wxString>>& a,
117 const std::pair<wxString, std::vector<wxString>>& b )
119 return a.first.CmpNoCase( b.first ) < 0;
122 for(
const auto& alias : aliasList )
124 std::shared_ptr<BUS_ALIAS> entry = std::make_shared<BUS_ALIAS>();
126 entry->SetName( alias.first );
127 entry->SetMembers( alias.second );
137 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
175 [&]() -> std::pair<int, int>
178 m_aliases.push_back( std::make_shared<BUS_ALIAS>() );
187 if( ( row > 0 ) && (
m_lastAlias == ( row - 1 ) ) )
219 [&]() -> std::pair<int, int>
232 bool clipboardHasText =
false;
234 if( wxTheClipboard->Open() )
236 if( wxTheClipboard->IsSupported( wxDF_TEXT )
237 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
239 clipboardHasText =
true;
242 wxTheClipboard->Close();
245 if( clipboardHasText )
262 alias->ClearMembers();
272 int row =
event.GetRow();
276 wxString
name =
event.GetString();
280 if( ii == event.GetRow() )
285 m_errorMsg = wxString::Format(
_(
"Alias name '%s' already in use." ),
name );
301 int row =
event.GetRow();
305 wxString
name =
event.GetString();
309 m_errorMsg =
_(
"Member net/alias name cannot be empty." );
340 wxString membersLabel;
351 for(
const wxString& member : alias->Members() )
374 int colSize = std::max(
grid->GetClientSize().x,
grid->GetVisibleWidth( 0 ) );
376 if(
grid->GetColSize( 0 ) != colSize )
377 grid->SetColSize( 0, colSize );
399 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
421 wxGridCellEditor* cellEditor =
m_aliasesGrid->GetCellEditor( row, 0 );
423 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
424 aliasName = txt->GetValue();
426 cellEditor->DecRef();
451 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[ row ];
452 alias->SetName( aliasName );
465 std::vector<std::pair<wxString, std::vector<wxString>>> aliasList( aAliases.begin(), aAliases.end() );
467 std::sort( aliasList.begin(), aliasList.end(),
468 [](
const std::pair<wxString, std::vector<wxString>>& a,
469 const std::pair<wxString, std::vector<wxString>>& b )
471 return a.first.CmpNoCase( b.first ) < 0;
474 for(
const auto& alias : aliasList )
476 std::shared_ptr<BUS_ALIAS> entry = std::make_shared<BUS_ALIAS>();
478 entry->SetName( alias.first );
479 entry->SetMembers( alias.second );
489 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
505 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[aAliasIndex];
507 alias->ClearMembers();
512 wxStringTokenizer tok( cellValue,
" " );
514 if( tok.CountTokens() > 1 )
520 while( tok.HasMoreTokens() )
521 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)