KiCad PCB EDA Suite
Loading...
Searching...
No Matches
panel_bom_presets.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) 2023 Mike Williams <[email protected]>
5 * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#include <panel_bom_presets.h>
26
27#include <wx/grid.h>
28#include <widgets/wx_grid.h>
29#include <bitmaps.h>
31
32
34 PANEL_BOM_PRESETS_BASE( aWindow ), m_settings( aSettings )
35{
36 m_btnDeleteBomPreset->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
37 m_btnDeleteBomFmtPreset->SetBitmap( KiBitmapBundle( BITMAPS::small_trash ) );
38}
39
40
42{
45
46 BuildGrid();
47
48 return true;
49}
50
51
53{
56
57 return true;
58}
59
60
62{
65
66 for( const BOM_PRESET& p : m_bomPresets )
67 {
68 m_bomPresetsGrid->AppendRows( 1 );
69 m_bomPresetsGrid->SetCellValue( m_bomPresetsGrid->GetNumberRows() - 1, 0, p.name );
70 }
71
72 for( const BOM_FMT_PRESET& p : m_bomFmtPresets )
73 {
74 m_bomFmtPresetsGrid->AppendRows( 1 );
75 m_bomFmtPresetsGrid->SetCellValue( m_bomFmtPresetsGrid->GetNumberRows() - 1, 0, p.name );
76 }
77}
78
79
80void PANEL_BOM_PRESETS::OnDeleteBomPreset( wxCommandEvent& event )
81{
82 int curRow = m_bomPresetsGrid->GetGridCursorRow();
83
84 if( curRow < 0 || m_bomPresetsGrid->GetNumberRows() <= curRow )
85 return;
86
87 m_bomPresetsGrid->DeleteRows( curRow, 1 );
88 m_bomPresets.erase( m_bomPresets.begin() + curRow );
89}
90
91
92void PANEL_BOM_PRESETS::OnDeleteBomFmtPreset( wxCommandEvent& event )
93{
94 int curRow = m_bomFmtPresetsGrid->GetGridCursorRow();
95
96 if( curRow < 0 || m_bomFmtPresetsGrid->GetNumberRows() <= curRow )
97 return;
98
99 m_bomFmtPresetsGrid->DeleteRows( curRow, 1 );
100 // Erase the bom preset from the bom presets list.
101 m_bomFmtPresets.erase( m_bomFmtPresets.begin() + curRow );
102}
103
104
106{
107 m_bomPresets = aSettings.m_BomPresets;
108 BuildGrid();
109}
110
111
113{
115 BuildGrid();
116}
wxBitmapBundle KiBitmapBundle(BITMAPS aBitmap)
Definition: bitmap.cpp:110
Class PANEL_BOM_PRESETS_BASE.
STD_BITMAP_BUTTON * m_btnDeleteBomPreset
STD_BITMAP_BUTTON * m_btnDeleteBomFmtPreset
std::vector< BOM_FMT_PRESET > m_bomFmtPresets
std::vector< BOM_PRESET > m_bomPresets
void OnDeleteBomFmtPreset(wxCommandEvent &event) override
bool TransferDataFromWindow() override
bool TransferDataToWindow() override
void ImportBomFmtPresetsFrom(SCHEMATIC_SETTINGS &aSettings)
PANEL_BOM_PRESETS(wxWindow *aWindow, SCHEMATIC_SETTINGS &aSettings)
void ImportBomPresetsFrom(SCHEMATIC_SETTINGS &aSettings)
SCHEMATIC_SETTINGS & m_settings
void OnDeleteBomPreset(wxCommandEvent &event) override
These settings were stored in SCH_BASE_FRAME previously.
std::vector< BOM_PRESET > m_BomPresets
std::vector< BOM_FMT_PRESET > m_BomFmtPresets
void SetBitmap(const wxBitmapBundle &aBmp)
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
Definition: wx_grid.h:147