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." );
317 alias->ClearMembers();
324 wxStringTokenizer tok(
name,
" " );
326 if( tok.CountTokens() > 1 )
332 while( tok.HasMoreTokens() )
333 alias->AddMember( tok.GetNextToken() );
362 wxString membersLabel;
374 for(
const wxString& member : alias->Members() )
397 int colSize = std::max(
grid->GetClientSize().x,
grid->GetVisibleWidth( 0 ) );
399 if(
grid->GetColSize( 0 ) != colSize )
400 grid->SetColSize( 0, colSize );
422 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
444 wxGridCellEditor* cellEditor =
m_aliasesGrid->GetCellEditor( row, 0 );
446 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
447 aliasName = txt->GetValue();
449 cellEditor->DecRef();
474 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[ row ];
475 alias->SetName( aliasName );
488 std::vector<std::pair<wxString, std::vector<wxString>>> aliasList( aAliases.begin(),
491 std::sort( aliasList.begin(), aliasList.end(),
492 [](
const std::pair<wxString, std::vector<wxString>>& a,
493 const std::pair<wxString, std::vector<wxString>>& b )
495 return a.first.CmpNoCase( b.first ) < 0;
498 for(
const auto& alias : aliasList )
500 std::shared_ptr<BUS_ALIAS> entry = std::make_shared<BUS_ALIAS>();
502 entry->SetName( alias.first );
503 entry->SetMembers( alias.second );
513 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
525 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[aAliasIndex];
527 alias->ClearMembers();
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)