KiCad PCB EDA Suite
Loading...
Searching...
No Matches
fp_text_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 FPT_UPRIGHT, // keep text upright when viewed from bottom or right of board
51
52 FPT_COUNT // keep as last
53};
54
55
56class FP_TEXT_GRID_TABLE : public wxGridTableBase, public std::vector<PCB_FIELD>
57{
58public:
61
62 int GetNumberRows() override { return (int) size(); }
63 int GetNumberCols() override { return FPT_COUNT; }
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 row, int col, wxGridCellAttr::wxAttrKind kind ) 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_footprintAttr;
104 wxGridCellAttr* m_urlAttr;
105
106 std::unique_ptr<NUMERIC_EVALUATOR> m_eval;
107 std::map< std::pair<int, int>, wxString > m_evalOriginal;
108};
109
110
111#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:84
A text control validator used for validating the text allowed in fields.
Definition: validators.h:221
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) override
void SetValueAsLong(int aRow, int aCol, long aValue) override
wxGridCellAttr * m_boolColAttr
FIELD_VALIDATOR m_urlValidator
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxString GetValue(int aRow, int aCol) override
wxString GetColLabelValue(int aCol) override
int GetNumberRows() override
PCB_BASE_FRAME * m_frame
wxGridCellAttr * m_footprintAttr
void onUnitsChanged(wxCommandEvent &aEvent)
wxGridCellAttr * m_readOnlyAttr
bool GetValueAsBool(int aRow, int aCol) override
long GetValueAsLong(int aRow, int aCol) override
void SetValueAsBool(int aRow, int aCol, bool aValue) override
wxGridCellAttr * m_orientationColAttr
DIALOG_SHIM * m_dialog
wxGridCellAttr * m_layerColAttr
int GetNumberCols() override
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
wxGridCellAttr * m_urlAttr
wxGridCellAttr * m_valueAttr
FIELD_VALIDATOR m_valueValidator
wxGridCellAttr * m_referenceAttr
FIELD_VALIDATOR m_nonUrlValidator
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
std::map< std::pair< int, int >, wxString > m_evalOriginal
FIELD_VALIDATOR m_referenceValidator
bool IsEmptyCell(int row, int col) override
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
FIELD_VALIDATOR m_fieldNameValidator
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
FP_TEXT_COL_ORDER
@ FPT_ORIENTATION
@ FPT_YOFFSET
@ FPT_KNOCKOUT
@ FPT_UPRIGHT
@ FPT_ITALIC
@ FPT_LAYER
@ FPT_WIDTH
@ FPT_COUNT
@ FPT_SHOWN
@ FPT_HEIGHT
@ FPT_VALUE
@ FPT_XOFFSET
@ FPT_THICKNESS
@ FPT_NAME
Custom text control validator definitions.