28#include <wx/radiobut.h>
29#include <wx/scrolwin.h>
30#include <wx/stattext.h>
35 std::vector<std::reference_wrapper<RC_ITEM>> aItems,
36 std::map<int, SEVERITY>& aSeverities,
38 wxPanel( aParentWindow ),
39 m_severities( aSeverities ),
41 m_pinMapSpecialCase( aPinMapSpecialCase )
43 wxString severities[] = {
_(
"Error" ),
_(
"Warning" ),
_(
"Ignore" ) };
44 int severityCount =
sizeof( severities ) /
sizeof( wxString );
46 wxBoxSizer* panelSizer =
new wxBoxSizer( wxVERTICAL );
47 wxScrolledWindow* scrollWin =
new wxScrolledWindow(
this, wxID_ANY,
48 wxDefaultPosition, wxDefaultSize,
49 wxTAB_TRAVERSAL | wxVSCROLL );
50 bool firstLine =
true;
52 scrollWin->SetScrollRate( 0, 5 );
54 wxBoxSizer* scrollWinSizer =
new wxBoxSizer( wxVERTICAL );
55 scrollWin->SetSizer( scrollWinSizer );
57 wxFlexGridSizer* gridSizer =
new wxFlexGridSizer( 0, 2, 0, 5 );
58 gridSizer->SetFlexibleDirection( wxBOTH );
59 gridSizer->SetVGap( 5 );
63 int errorCode = item.GetErrorCode();
64 wxString msg = item.GetErrorText();
71 wxStaticText* heading =
new wxStaticText( scrollWin, wxID_ANY, msg );
72 wxFont headingFont = heading->GetFont();
74 heading->SetFont( headingFont.Bold() );
78 gridSizer->AddSpacer( 5 );
79 gridSizer->AddSpacer( 5 );
82 gridSizer->Add( heading, 0, wxALIGN_BOTTOM | wxALL | wxEXPAND, 4 );
83 gridSizer->AddSpacer( 0 );
85 else if( !msg.IsEmpty() )
87 wxStaticText* errorLabel =
new wxStaticText( scrollWin, wxID_ANY, msg + wxT(
":" ) );
88 gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 15 );
92 wxPanel* radioPanel =
new wxPanel( scrollWin );
93 wxBoxSizer* radioSizer =
new wxBoxSizer( wxHORIZONTAL );
95 for(
int i = 0; i < severityCount; ++i )
97 m_buttonMap[ errorCode ][i] =
new wxRadioButton( radioPanel,
98 baseID + errorCode * 10 + i,
100 wxDefaultPosition, wxDefaultSize,
101 i == 0 ? wxRB_GROUP : 0 );
103 wxRIGHT | wxALIGN_CENTER_VERTICAL, 30 );
106 radioPanel->SetSizer( radioSizer );
107 radioPanel->Layout();
108 gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL );
117 wxString pinMapSeverities[] = {
_(
"From Pin Conflicts Map" ), wxT(
"" ),
_(
"Ignore" ) };
121 wxStaticText* errorLabel =
new wxStaticText( scrollWin, wxID_ANY, msg + wxT(
":" ) );
122 gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 15 );
124 wxPanel* radioPanel =
new wxPanel( scrollWin );
125 wxBoxSizer* radioSizer =
new wxBoxSizer( wxHORIZONTAL );
127 for(
size_t i = 0; i < 3; ++i )
129 if( pinMapSeverities[i] == wxT(
"" ) )
131 wxStaticText* spacer =
new wxStaticText( radioPanel, wxID_ANY, wxT(
"" ) );
132 radioSizer->Add( spacer, 0, wxRIGHT | wxEXPAND, 17 );
136 m_buttonMap[ errorCode ][i] =
new wxRadioButton( radioPanel,
137 baseID + errorCode * 10 + i,
139 wxDefaultPosition, wxDefaultSize,
140 i == 0 ? wxRB_GROUP : 0 );
141 radioSizer->Add(
m_buttonMap[ errorCode ][i], 0, wxEXPAND );
145 radioPanel->SetSizer( radioSizer );
146 radioPanel->Layout();
147 gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL );
150 scrollWinSizer->Add( gridSizer, 1, wxEXPAND | wxALL, 5 );
151 panelSizer->Add( scrollWin, 1, wxEXPAND, 0 );
154 [
this]( wxIdleEvent& aEvent )
158 wxWindow* dialog = wxGetTopLevelParent(
this );
159 wxWindow* topLevelFocus = wxGetTopLevelParent( wxWindow::FindFocus() );
161 if( topLevelFocus == dialog )
166 SetSizer( panelSizer );
168 panelSizer->Fit(
this );
178 if(
IsOK( m_parent,
_(
"The violation severities have been changed outside the Setup dialog.\n"
179 "Do you wish to reload them?" ) ) )
190 int errorCode = item.GetErrorCode();
192 wxRadioButton* button =
nullptr;
194 switch( aSettings[ errorCode ] )
203 button->SetValue(
true );
209 int newSeverity = aSettings[ pinMapCode ];
223 int errorCode = item.GetErrorCode();
257 int errorCode = item.GetErrorCode();
284 else if(
m_buttonMap[ pinMapCode ][2]->GetValue() )
void ImportSettingsFrom(std::map< int, SEVERITY > &aSettings)
std::map< int, SEVERITY > & m_severities
bool TransferDataToWindow() override
RC_ITEM * m_pinMapSpecialCase
For ERC settings; a pointer to ERC_ITEM::pinTableConflict.
bool TransferDataFromWindow() override
PANEL_SETUP_SEVERITIES(wxWindow *aParentWindow, std::vector< std::reference_wrapper< RC_ITEM > > aItems, std::map< int, SEVERITY > &aSeverities, RC_ITEM *aPinMapSpecialCase=nullptr)
Creates the severities setup panel.
std::map< int, wxRadioButton *[4]> m_buttonMap
std::map< int, SEVERITY > m_lastLoaded
std::vector< std::reference_wrapper< RC_ITEM > > m_items
A list of item templates (to get descriptive text and error codes from)
A holder for a rule check item, DRC in Pcbnew or ERC in Eeschema.
wxString GetErrorText() const
bool IsOK(wxWindow *aParent, const wxString &aMessage)
Display a yes/no dialog with aMessage and returns the user response.
This file is part of the common library.
Functions to provide common constants and other functions to assist in making a consistent UI.