KiCad PCB EDA Suite
Loading...
Searching...
No Matches
lib_table_grid.h
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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#pragma once
21
22#include <kicommon.h>
24#include <wx/grid.h>
25
28
43
48class KICOMMON_API LIB_TABLE_GRID : public wxGridTableBase
49{
51
52public:
53 LIB_TABLE_GRID( const LIBRARY_TABLE& aTableToEdit, LIBRARY_MANAGER_ADAPTER* aAdapter = nullptr ) :
54 m_table( aTableToEdit ),
55 m_adapter( aAdapter )
56 {}
57
58 //-----<wxGridTableBase overloads>-------------------------------------------
59
60 int GetNumberRows() override { return (int) size(); }
61
62 int GetNumberCols() override { return COL_COUNT; }
63
64 wxString GetValue( int aRow, int aCol ) override;
65
66 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
67
68 bool GetValueAsBool( int aRow, int aCol ) override;
69
70 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
71
72 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
73
74 bool IsEmptyCell( int aRow, int aCol ) override
75 {
76 return !GetValue( aRow, aCol );
77 }
78
79 bool InsertRows( size_t aPos = 0, size_t aNumRows = 1 ) override;
80
81 bool AppendRows( size_t aNumRows = 1 ) override;
82
83 bool DeleteRows( size_t aPos, size_t aNumRows ) override;
84
85 wxString GetColLabelValue( int aCol ) override;
86
87 bool ContainsNickname( const wxString& aNickname );
88
89 LIBRARY_TABLE_ROW& At( size_t aIndex )
90 {
91 return at( aIndex );
92 }
93
95
97
98protected:
99 virtual LIBRARY_TABLE_ROW& at( size_t aIndex );
100
101 virtual size_t size() const;
102
103 virtual LIBRARY_TABLE_ROW makeNewRow();
104
105 virtual LIBRARY_TABLE_ROWS_ITER begin();
106
107 virtual LIBRARY_TABLE_ROWS_ITER insert( LIBRARY_TABLE_ROWS_ITER aIterator, const LIBRARY_TABLE_ROW& aRow );
108
109 virtual void push_back( const LIBRARY_TABLE_ROW& aRow );
110
112
113protected:
116
119};
The interface used by the classes that actually can load IO plugins for the different parts of KiCad ...
LIBRARY_TABLE m_table
Working copy of a table.
LIBRARY_TABLE & Table()
LIB_TABLE_GRID(const LIBRARY_TABLE &aTableToEdit, LIBRARY_MANAGER_ADAPTER *aAdapter=nullptr)
bool IsEmptyCell(int aRow, int aCol) override
friend class LIB_TABLE_GRID_TRICKS
wxString GetValue(int aRow, int aCol) override
LIBRARY_MANAGER_ADAPTER * m_adapter
Handle to the adapter for the type of table this grid represents (may be null)
LIBRARY_MANAGER_ADAPTER * Adapter() const
virtual size_t size() const
LIBRARY_TABLE_ROW & At(size_t aIndex)
int GetNumberCols() override
int GetNumberRows() override
virtual LIBRARY_TABLE_ROW & at(size_t aIndex)
#define KICOMMON_API
Definition kicommon.h:28
@ COL_DESCR
@ COL_NICKNAME
@ COL_OPTIONS
@ COL_STATUS
@ COL_COUNT
@ COL_ENABLED
@ COL_URI
std::vector< LIBRARY_TABLE_ROW >::iterator LIBRARY_TABLE_ROWS_ITER