28#include <wx/radiobut.h>
29#include <wx/scrolwin.h>
31#include <wx/stattext.h>
36 std::vector<std::reference_wrapper<RC_ITEM>> aItems,
37 std::map<int, SEVERITY>& aSeverities,
39 wxPanel( aParentWindow ),
40 m_severities( aSeverities ),
42 m_pinMapSpecialCase( aPinMapSpecialCase )
44 wxString severities[] = {
_(
"Error" ),
_(
"Warning" ),
_(
"Ignore" ) };
45 int severityCount =
sizeof( severities ) /
sizeof( wxString );
47 wxBoxSizer* panelSizer =
new wxBoxSizer( wxVERTICAL );
48 wxScrolledWindow* scrollWin =
new wxScrolledWindow(
this, wxID_ANY,
49 wxDefaultPosition, wxDefaultSize,
50 wxTAB_TRAVERSAL | wxVSCROLL );
51 bool firstLine =
true;
53 scrollWin->SetScrollRate( 0, 5 );
55 wxBoxSizer* scrollWinSizer =
new wxBoxSizer( wxVERTICAL );
56 scrollWin->SetSizer( scrollWinSizer );
58 wxFlexGridSizer* gridSizer =
new wxFlexGridSizer( 0, 2, 0, 5 );
59 gridSizer->SetFlexibleDirection( wxBOTH );
60 gridSizer->SetVGap( 5 );
64 int errorCode = item.GetErrorCode();
65 wxString msg = item.GetErrorText();
72 wxStaticText* heading =
new wxStaticText( scrollWin, wxID_ANY, msg );
73 wxFont headingFont = heading->GetFont();
75 heading->SetFont( headingFont.Bold() );
79 gridSizer->AddSpacer( 5 );
80 gridSizer->AddSpacer( 5 );
83 gridSizer->Add( heading, 0, wxALIGN_BOTTOM | wxALL | wxEXPAND, 4 );
84 gridSizer->AddSpacer( 0 );
86 else if( !msg.IsEmpty() )
88 wxStaticText* errorLabel =
new wxStaticText( scrollWin, wxID_ANY, msg + wxT(
":" ) );
89 gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxLEFT, 15 );
93 wxPanel* radioPanel =
new wxPanel( scrollWin );
94 wxBoxSizer* radioSizer =
new wxBoxSizer( wxHORIZONTAL );
96 for(
int i = 0; i < severityCount; ++i )
98 m_buttonMap[ errorCode ][i] =
new wxRadioButton( radioPanel,
99 baseID + errorCode * 10 + i,
101 wxDefaultPosition, wxDefaultSize,
102 i == 0 ? wxRB_GROUP : 0 );
104 wxRIGHT | wxALIGN_CENTER_VERTICAL, 30 );
107 radioPanel->SetSizer( radioSizer );
108 radioPanel->Layout();
109 gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL );
118 wxString pinMapSeverities[] = {
_(
"From Pin Conflicts Map" ), wxT(
"" ),
_(
"Ignore" ) };
122 wxStaticText* errorLabel =
new wxStaticText( scrollWin, wxID_ANY, msg + wxT(
":" ) );
123 gridSizer->Add( errorLabel, 0, wxALIGN_CENTER_VERTICAL | wxALL | wxEXPAND, 15 );
125 wxPanel* radioPanel =
new wxPanel( scrollWin );
126 wxBoxSizer* radioSizer =
new wxBoxSizer( wxHORIZONTAL );
128 for(
size_t i = 0; i < 3; ++i )
130 if( pinMapSeverities[i] == wxT(
"" ) )
132 wxStaticText* spacer =
new wxStaticText( radioPanel, wxID_ANY, wxT(
"" ) );
133 radioSizer->Add( spacer, 0, wxRIGHT | wxEXPAND, 17 );
137 m_buttonMap[ errorCode ][i] =
new wxRadioButton( radioPanel,
138 baseID + errorCode * 10 + i,
140 wxDefaultPosition, wxDefaultSize,
141 i == 0 ? wxRB_GROUP : 0 );
142 radioSizer->Add(
m_buttonMap[ errorCode ][i], 0, wxEXPAND );
146 radioPanel->SetSizer( radioSizer );
147 radioPanel->Layout();
148 gridSizer->Add( radioPanel, 0, wxALIGN_CENTER_VERTICAL );
151 scrollWinSizer->Add( gridSizer, 1, wxEXPAND | wxALL, 5 );
152 panelSizer->Add( scrollWin, 1, wxEXPAND, 0 );
155 [
this]( wxIdleEvent& aEvent )
159 wxWindow* dialog = wxGetTopLevelParent(
this );
160 wxWindow* topLevelFocus = wxGetTopLevelParent( wxWindow::FindFocus() );
162 if( topLevelFocus == dialog )
167 SetSizer( panelSizer );
169 panelSizer->Fit(
this );
179 if(
IsOK( m_parent,
_(
"The violation severities have been changed outside the Setup dialog.\n"
180 "Do you wish to reload them?" ) ) )
191 int errorCode = item.GetErrorCode();
193 wxRadioButton* button =
nullptr;
195 switch( aSettings[ errorCode ] )
204 button->SetValue(
true );
210 int newSeverity = aSettings[ pinMapCode ];
224 int errorCode = item.GetErrorCode();
258 int errorCode = item.GetErrorCode();
285 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.