KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_fields_grid_table.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
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
20#ifndef FP_TEXT_GRID_TABLE_H
21#define FP_TEXT_GRID_TABLE_H
22
23#include <wx/grid.h>
24#include <grid_tricks.h>
25#include <pcb_field.h>
26#include <validators.h>
27#include <dialog_shim.h>
28
29
30class PCB_BASE_FRAME;
31
51
52
53class PCB_FIELDS_GRID_TABLE : public WX_GRID_TABLE_BASE, public std::vector<PCB_FIELD>
54{
55public:
57 std::vector<EMBEDDED_FILES*> aFilesStack );
59
60 int GetNumberRows() override { return (int) size(); }
61 int GetNumberCols() override { return PFC_COUNT; }
62
63 int GetMandatoryRowCount() const;
64
65 wxString GetColLabelValue( int aCol ) override;
66
67 bool IsEmptyCell( int row, int col ) override
68 {
69 return false; // don't allow adjacent cell overflow, even if we are actually empty
70 }
71
72 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
73 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
74 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override;
75
76 wxString GetValue( int aRow, int aCol ) override;
77 bool GetValueAsBool( int aRow, int aCol ) override;
78 long GetValueAsLong( int aRow, int aCol ) override;
79
80 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
81 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
82 void SetValueAsLong( int aRow, int aCol, long aValue ) override;
83
84protected:
85 void onUnitsChanged( wxCommandEvent& aEvent );
86
87private:
90
96
97 wxGridCellAttr* m_readOnlyAttr;
98 wxGridCellAttr* m_boolColAttr;
99 wxGridCellAttr* m_orientationColAttr;
100 wxGridCellAttr* m_layerColAttr;
101 wxGridCellAttr* m_referenceAttr;
102 wxGridCellAttr* m_valueAttr;
103 wxGridCellAttr* m_urlAttr;
104
105 std::unique_ptr<NUMERIC_EVALUATOR> m_eval;
106 std::map< std::pair<int, int>, wxString > m_evalOriginal;
107};
108
109
110#endif // FP_TEXT_GRID_TABLE_H
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition dialog_shim.h:65
A text control validator used for validating the text allowed in fields.
Definition validators.h:138
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
void onUnitsChanged(wxCommandEvent &aEvent)
void SetValue(int aRow, int aCol, const wxString &aValue) override
bool GetValueAsBool(int aRow, int aCol) override
wxString GetColLabelValue(int aCol) override
bool IsEmptyCell(int row, int col) override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
std::map< std::pair< int, int >, wxString > m_evalOriginal
FIELD_VALIDATOR m_nonUrlValidator
PCB_FIELDS_GRID_TABLE(PCB_BASE_FRAME *aFrame, DIALOG_SHIM *aDialog, std::vector< EMBEDDED_FILES * > aFilesStack)
long GetValueAsLong(int aRow, int aCol) override
wxGridCellAttr * m_readOnlyAttr
wxString GetValue(int aRow, int aCol) override
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
void SetValueAsBool(int aRow, int aCol, bool aValue) override
FIELD_VALIDATOR m_referenceValidator
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
FIELD_VALIDATOR m_fieldNameValidator
wxGridCellAttr * m_orientationColAttr
void SetValueAsLong(int aRow, int aCol, long aValue) override
PCB_FIELDS_COL_ORDER
@ PFC_THICKNESS
@ PFC_ORIENTATION
Custom text control validator definitions.