22 #include <wx/tokenzr.h> 30 #include <wx/button.h> 31 #include <wx/stattext.h> 32 #include <wx/valtext.h> 37 :
DIALOG_SHIM( aParent, wxID_ANY,
_(
"Bus Definitions" ),
38 wxDefaultPosition, wxDefaultSize,
39 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
42 auto sizer =
new wxBoxSizer( wxVERTICAL );
43 auto buttons =
new wxStdDialogButtonSizer();
44 wxButton* okButton =
new wxButton(
this, wxID_OK );
46 buttons->AddButton( okButton );
47 buttons->AddButton(
new wxButton(
this, wxID_CANCEL ) );
50 auto top_container =
new wxBoxSizer( wxHORIZONTAL );
51 auto left_pane =
new wxBoxSizer( wxVERTICAL );
52 auto right_pane =
new wxBoxSizer( wxVERTICAL );
55 auto lbl_aliases =
new wxStaticText(
this, wxID_ANY,
_(
"Bus Aliases" ),
56 wxDefaultPosition, wxDefaultSize,
60 wxSize( 300, 300 ), wxLC_ALIGN_LEFT |
61 wxLC_NO_HEADER | wxLC_REPORT |
65 auto lbl_alias_edit =
new wxStaticText(
this, wxID_ANY,
_(
"Alias Name" ),
66 wxDefaultPosition, wxDefaultSize,
69 m_bus_edit =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString,
70 wxDefaultPosition, wxDefaultSize, wxTE_PROCESS_ENTER );
72 auto left_button_sizer =
new wxBoxSizer( wxHORIZONTAL );
82 left_pane->Add( lbl_aliases, 0, wxEXPAND | wxALL, 5 );
84 left_pane->Add( lbl_alias_edit, 0, wxEXPAND | wxALL, 5 );
85 left_pane->Add(
m_bus_edit, 0, wxEXPAND | wxALL, 5 );
86 left_pane->Add( left_button_sizer, 0, wxEXPAND | wxALL, 5 );
89 auto lbl_signals =
new wxStaticText(
this, wxID_ANY,
_(
"Alias Members" ),
90 wxDefaultPosition, wxDefaultSize,
94 wxSize( 300, 300 ), wxLC_ALIGN_LEFT |
95 wxLC_NO_HEADER | wxLC_REPORT |
99 auto lbl_signal_edit =
new wxStaticText(
this, wxID_ANY,
_(
"Member Name" ),
100 wxDefaultPosition, wxDefaultSize,
103 m_signal_edit =
new wxTextCtrl(
this, wxID_ANY, wxEmptyString, wxDefaultPosition,
104 wxDefaultSize, wxTE_PROCESS_ENTER );
106 auto right_button_sizer =
new wxBoxSizer( wxHORIZONTAL );
116 right_pane->Add( lbl_signals, 0, wxEXPAND | wxALL, 5 );
118 right_pane->Add( lbl_signal_edit, 0, wxEXPAND | wxALL, 5 );
120 right_pane->Add( right_button_sizer, 0, wxEXPAND | wxALL, 5 );
122 top_container->Add( left_pane, 1, wxEXPAND );
123 top_container->Add( right_pane, 1, wxEXPAND );
125 sizer->Add( top_container, 1, wxEXPAND | wxALL, 5 );
126 sizer->Add( buttons, 0, wxEXPAND | wxBOTTOM, 10 );
131 wxTextValidator validator;
132 validator.SetStyle( wxFILTER_EXCLUDE_CHAR_LIST );
133 validator.SetCharExcludes(
"\r\n\t " );
138 validator.SetCharExcludes(
"\r\n\t" );
184 okButton->SetDefault();
201 std::vector< std::shared_ptr<BUS_ALIAS> > original_aliases;
204 for(
SCH_SCREEN* screen = screens.GetFirst(); screen !=
nullptr; screen = screens.GetNext() )
206 std::unordered_set<std::shared_ptr<BUS_ALIAS>> sheet_aliases = screen->GetBusAliases();
207 original_aliases.insert( original_aliases.end(), sheet_aliases.begin(),
208 sheet_aliases.end() );
211 original_aliases.erase( std::unique( original_aliases.begin(),
212 original_aliases.end() ),
213 original_aliases.end() );
218 for(
const std::shared_ptr<BUS_ALIAS>& alias : original_aliases )
237 screen->ClearBusAliases();
239 for(
const std::shared_ptr<BUS_ALIAS>& alias :
m_aliases )
240 alias->GetParent()->AddBusAlias( alias );
249 if( event.GetEventType() == wxEVT_COMMAND_LIST_ITEM_SELECTED )
251 auto alias =
m_aliases[
event.GetIndex() ];
262 auto members = alias->Members();
269 for(
unsigned i = 0; i < members.size(); i++ )
300 if( event.GetEventType() == wxEVT_COMMAND_LIST_ITEM_SELECTED )
322 if( new_name.Length() == 0 )
329 if( alias->GetName() == new_name )
340 auto alias = std::make_shared<BUS_ALIAS>();
341 alias->SetName( new_name );
344 alias->SetParent( static_cast<SCH_EDIT_FRAME*>( GetParent() )->GetScreen() );
369 wxASSERT( idx >= 0 );
389 auto evt = wxListEvent( wxEVT_COMMAND_LIST_ITEM_DESELECTED );
407 wxStringTokenizer tok( name_list,
" " );
408 while( tok.HasMoreTokens() )
410 auto name = tok.GetNextToken();
425 notAdded = notAdded.IsEmpty() ?
name : notAdded +
" " +
name;
442 wxASSERT( idx >= 0 );
447 if( new_name.Find(
" " ) != wxNOT_FOUND )
467 wxASSERT( idx >= 0 );
480 wxString
name = aAlias->GetName();
481 wxFileName sheet_name( aAlias->GetParent()->GetFileName() );
483 name += _T(
" (" ) + sheet_name.GetFullName() + _T(
")" );
bool TransferDataFromWindow() override
wxButton * m_btn_add_signal
wxListView * m_bus_list_view
wxListView * m_signal_list_view
void OnAddSignal(wxCommandEvent &aEvent)
void OnAddBus(wxCommandEvent &aEvent)
void OnRenameSignal(wxCommandEvent &aEvent)
wxButton * m_btn_rename_signal
Schematic editor (Eeschema) main window.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
void OnInitDialog(wxInitDialogEvent &aEvent)
void OnSelectBus(wxListEvent &event)
void OnRemoveSignal(wxCommandEvent &aEvent)
wxButton * m_btn_remove_bus
SCH_EDIT_FRAME * m_parent
std::unordered_set< SCH_SCREEN * > m_screens
SCHEMATIC & Schematic() const
void OnRenameBus(wxCommandEvent &aEvent)
wxButton * m_btn_remove_signal
std::vector< std::shared_ptr< BUS_ALIAS > > m_aliases
bool TransferDataToWindow() override
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
wxTextCtrl * m_signal_edit
std::shared_ptr< BUS_ALIAS > m_active_alias
wxString getAliasDisplayText(std::shared_ptr< BUS_ALIAS > aAlias)
void OnRemoveBus(wxCommandEvent &aEvent)
void InvokeDialogBusManager(SCH_EDIT_FRAME *aCaller)
Create and show DIALOG_BUS_MANAGER.
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
void OnSelectSignal(wxListEvent &event)
DIALOG_BUS_MANAGER(SCH_EDIT_FRAME *aParent)
Container class that holds multiple SCH_SCREEN objects in a hierarchy.
wxButton * m_btn_rename_bus