29#include <wx/clipbrd.h>
35 m_membersGridDirty( false ),
36 m_errorGrid( nullptr ),
54 [
this]( wxCommandEvent& aEvent )
60 [
this]( wxCommandEvent& aEvent )
98 [&](
const std::shared_ptr<BUS_ALIAS>& alias ) ->
bool
100 wxString aName = alias->GetName();
101 std::vector<wxString> aMembers = alias->Members();
103 std::sort( aMembers.begin(), aMembers.end() );
105 for(
const std::shared_ptr<BUS_ALIAS>& candidate :
m_aliases )
107 wxString bName = candidate->GetName();
108 std::vector<wxString> bMembers = candidate->Members();
110 std::sort( bMembers.begin(), bMembers.end() );
112 if( aName == bName && aMembers == bMembers )
124 for(
const std::shared_ptr<BUS_ALIAS>& alias : screen->GetBusAliases() )
126 if( !contains( alias ) )
136 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
165 screen->ClearBusAliases();
167 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
168 alias->GetParent()->AddBusAlias( alias );
180 [&]() -> std::pair<int, int>
192 if( ( row > 0 ) && (
m_lastAlias == ( row - 1 ) ) )
224 [&]() -> std::pair<int, int>
237 bool clipboardHasText =
false;
239 if( wxTheClipboard->Open() )
241 if( wxTheClipboard->IsSupported( wxDF_TEXT )
242 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
244 clipboardHasText = true;
247 wxTheClipboard->Close();
250 if( clipboardHasText )
267 alias->Members().clear();
270 alias->Members().push_back(
m_membersGrid->GetCellValue( ii, 0 ) );
277 int row =
event.GetRow();
281 wxString
name =
event.GetString();
285 if( ii == event.GetRow() )
291 m_errorMsg = wxString::Format(
_(
"Alias name '%s' already in use." ),
name );
307 int row =
event.GetRow();
311 wxString
name =
event.GetString();
315 m_errorMsg =
_(
"Member net/alias name cannot be empty." );
325 alias->Members().clear();
332 wxStringTokenizer tok(
name,
" " );
334 if( tok.CountTokens() > 1 )
340 while( tok.HasMoreTokens() )
341 alias->Members().push_back( tok.GetNextToken() );
345 alias->Members().push_back(
m_membersGrid->GetCellValue( ii, 0 ) );
354 if(
m_lastAlias >= 0 && m_lastAlias < m_aliasesGrid->GetNumberRows() )
358 wxString membersLabel;
360 if( alias->GetParent() )
362 wxFileName sheet_name( alias->GetParent()->GetFileName() );
363 source.Printf( wxS(
"(" ) + sheet_name.GetFullName() + wxS(
")" ) );
376 for(
const wxString& member : alias->Members() )
399 int colSize = std::max(
grid->GetClientSize().x,
grid->GetVisibleWidth( 0 ) );
401 if(
grid->GetColSize( 0 ) != colSize )
402 grid->SetColSize( 0, colSize );
424 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
446 wxGridCellEditor* cellEditor =
m_aliasesGrid->GetCellEditor( row, 0 );
448 if( wxTextEntry* txt =
dynamic_cast<wxTextEntry*
>( cellEditor->GetControl() ) )
449 aliasName = txt->GetValue();
451 cellEditor->DecRef();
458 else if(
m_lastAlias >= 0 && m_lastAlias < m_aliasesGrid->GetNumberRows() )
476 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[ row ];
477 alias->SetName( aliasName );
491 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
501 const std::shared_ptr<BUS_ALIAS>& alias =
m_aliases[aAliasIndex];
503 alias->Members().clear();
509 if( !memberValue.empty() )
511 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.
Class PANEL_SETUP_BUSES_BASE.
STD_BITMAP_BUTTON * m_addAlias
wxSimplebook * m_membersBook
STD_BITMAP_BUTTON * m_addMember
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 loadAliases(const SCHEMATIC &aSchematic)
void OnSizeGrid(wxSizeEvent &event) override
PANEL_SETUP_BUSES(wxWindow *aWindow, SCH_EDIT_FRAME *aFrame)
bool TransferDataToWindow() override
void ImportSettingsFrom(const SCHEMATIC &aOtherSchematic)
void updateAliasMembers(int aAliasIndex)
When rows are created programmatically by pasting values from the clipboard, the cell change event ma...
wxString m_membersLabelTemplate
void OnRemoveMember(wxCommandEvent &aEvent) override
void OnMemberGridCellChanging(wxGridEvent &event)
bool TransferDataFromWindow() override
void OnAddMember(wxCommandEvent &aEvent) override
void doReloadMembersGrid()
void OnAddAlias(wxCommandEvent &aEvent) override
Holds all the data relating to one schematic.
Schematic editor (Eeschema) main window.
SCH_SCREEN * GetScreen() const override
Return a pointer to a BASE_SCREEN or one of its derivatives.
SCHEMATIC & Schematic() const
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
void OverrideMinSize(double aXPct, double aYPct)
Grids that have column sizes automatically set to fill the available width don't want to shrink after...
void OnDeleteRows(const std::function< void(int row)> &aDeleter)
Handles a row deletion event.
void OnAddRow(const std::function< std::pair< int, int >()> &aAdder)
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
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)