KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_drc_group_header.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <https://www.gnu.org/licenses/>.
18 */
19
21
22
23PANEL_DRC_GROUP_HEADER::PANEL_DRC_GROUP_HEADER( wxWindow* aParent, const std::vector<DRC_RULE_ROW>& aRows ) :
25 m_rows( aRows )
26{
27 wxASSERT( m_dataGrid->GetNumberCols() == 3 );
28
29 int rows = m_dataGrid->GetNumberRows();
30
31 if( rows )
32 m_dataGrid->DeleteRows( 0, rows );
33
34 m_dataGrid->AppendRows( m_rows.size() );
35
36 for( size_t i = 0; i < m_rows.size(); ++i )
37 {
38 m_dataGrid->SetCellValue( i, 0, m_rows[i].m_ruleType );
39 m_dataGrid->SetCellValue( i, 1, m_rows[i].m_ruleName );
40 m_dataGrid->SetCellValue( i, 2, m_rows[i].m_comment );
41 }
42
43 // Disable horizontal scroll bar
44 m_dataGrid->EnableScrolling( false, true );
45}
46
47
51
52
54{
55 return true;
56}
57
58
63
64void PANEL_DRC_GROUP_HEADER::OnSize( wxSizeEvent& event )
65{
66 wxSize clientSize = GetClientSize();
67 int availableWidth = clientSize.GetWidth() - wxSystemSettings::GetMetric( wxSYS_VSCROLL_X );
68 int availableHeight = clientSize.GetHeight() - wxSystemSettings::GetMetric( wxSYS_HSCROLL_Y );
69
70 m_dataGrid->SetSize( wxSize( availableWidth, availableHeight ) );
71 double total_column_width = m_dataGrid->GetColSize( 0 ) + m_dataGrid->GetColSize( 1 ) + m_dataGrid->GetColSize( 2 );
72 double col0_width_ratio = m_dataGrid->GetColSize( 0 ) / total_column_width;
73 double col1_width_ratio = m_dataGrid->GetColSize( 1 ) / total_column_width;
74 int col0_size = static_cast<int>( availableWidth * col0_width_ratio );
75 int col1_size = static_cast<int>( availableWidth * col1_width_ratio );
76 int col2_size = availableWidth - col0_size - col1_size;
77
78 m_dataGrid->SetColSize( 0, col0_size );
79 m_dataGrid->SetColSize( 1, col1_size );
80 m_dataGrid->SetColSize( 2, col2_size );
81
82 // Refresh the grid to apply the new sizes.
83 m_dataGrid->ForceRefresh();
84
85 event.Skip(); // Allow further processing of the event.
86}
87
88void PANEL_DRC_GROUP_HEADER::OnGridSize( wxGridSizeEvent& event )
89{
90 wxSizeEvent evt( m_dataGrid->GetSize() );
91 OnSize( evt );
92}
PANEL_DRC_GROUP_HEADER_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)
void OnSize(wxSizeEvent &event) override
void OnGridSize(wxGridSizeEvent &event) override
PANEL_DRC_GROUP_HEADER(wxWindow *aParent, const std::vector< DRC_RULE_ROW > &aRows)
std::vector< DRC_RULE_ROW > m_rows