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 (C) 2018-2023 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, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
24#ifndef FP_TEXT_GRID_TABLE_H
25#define FP_TEXT_GRID_TABLE_H
26
27#include <wx/grid.h>
28#include <grid_tricks.h>
29#include <pcb_field.h>
30#include <validators.h>
31#include <dialog_shim.h>
32
33
34class PCB_BASE_FRAME;
35
37{
47 PFC_UPRIGHT, // keep text upright when viewed from bottom or right of board
52
53 PFC_COUNT // keep as last
54};
55
56
57class PCB_FIELDS_GRID_TABLE : public WX_GRID_TABLE_BASE, public std::vector<PCB_FIELD>
58{
59public:
62
63 int GetNumberRows() override { return (int) size(); }
64 int GetNumberCols() override { return PFC_COUNT; }
65
66 wxString GetColLabelValue( int aCol ) override;
67
68 bool IsEmptyCell( int row, int col ) override
69 {
70 return false; // don't allow adjacent cell overflow, even if we are actually empty
71 }
72
73 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
74 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
75 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override;
76
77 wxString GetValue( int aRow, int aCol ) override;
78 bool GetValueAsBool( int aRow, int aCol ) override;
79 long GetValueAsLong( int aRow, int aCol ) override;
80
81 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
82 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
83 void SetValueAsLong( int aRow, int aCol, long aValue ) override;
84
85protected:
86 void onUnitsChanged( wxCommandEvent& aEvent );
87
88private:
91
97
98 wxGridCellAttr* m_readOnlyAttr;
99 wxGridCellAttr* m_boolColAttr;
100 wxGridCellAttr* m_orientationColAttr;
101 wxGridCellAttr* m_layerColAttr;
102 wxGridCellAttr* m_referenceAttr;
103 wxGridCellAttr* m_valueAttr;
104 wxGridCellAttr* m_footprintAttr;
105 wxGridCellAttr* m_urlAttr;
106
107 std::unique_ptr<NUMERIC_EVALUATOR> m_eval;
108 std::map< std::pair<int, int>, wxString > m_evalOriginal;
109};
110
111
112#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:88
A text control validator used for validating the text allowed in fields.
Definition: validators.h:221
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
wxGridCellAttr * m_referenceAttr
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
long GetValueAsLong(int aRow, int aCol) override
wxGridCellAttr * m_readOnlyAttr
FIELD_VALIDATOR m_urlValidator
FIELD_VALIDATOR m_valueValidator
wxGridCellAttr * m_footprintAttr
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_boolColAttr
wxGridCellAttr * m_layerColAttr
wxGridCellAttr * m_orientationColAttr
void SetValueAsLong(int aRow, int aCol, long aValue) override
PCB_FIELDS_COL_ORDER
@ PFC_XOFFSET
@ PFC_KNOCKOUT
@ PFC_ITALIC
@ PFC_HEIGHT
@ PFC_THICKNESS
@ PFC_MIRRORED
@ PFC_ORIENTATION
@ PFC_UPRIGHT
@ PFC_YOFFSET
Custom text control validator definitions.