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_text.h>
30
31
32class PCB_BASE_FRAME;
33
35{
44 FPT_UPRIGHT, // keep text upright when viewed from bottom or right of board
48
49 FPT_COUNT // keep as last
50};
51
52
53class FP_TEXT_GRID_TABLE : public wxGridTableBase, public std::vector<PCB_TEXT>
54{
55public:
58
59 int GetNumberRows() override { return (int) size(); }
60 int GetNumberCols() override { return FPT_COUNT; }
61
62 wxString GetColLabelValue( int aCol ) override;
63 wxString GetRowLabelValue( int aRow ) override;
64
65 bool IsEmptyCell( int row, int col ) override
66 {
67 return false; // don't allow adjacent cell overflow, even if we are actually empty
68 }
69
70 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
71 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
72 wxGridCellAttr* GetAttr( int row, int col, wxGridCellAttr::wxAttrKind kind ) override;
73
74 wxString GetValue( int aRow, int aCol ) override;
75 bool GetValueAsBool( int aRow, int aCol ) override;
76 long GetValueAsLong( int aRow, int aCol ) override;
77
78 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
79 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
80 void SetValueAsLong( int aRow, int aCol, long aValue ) override;
81
82protected:
83 void onUnitsChanged( wxCommandEvent& aEvent );
84
85private:
87
88 wxGridCellAttr* m_readOnlyAttr;
89 wxGridCellAttr* m_boolColAttr;
90 wxGridCellAttr* m_orientationColAttr;
91 wxGridCellAttr* m_layerColAttr;
92
93 std::unique_ptr<NUMERIC_EVALUATOR> m_eval;
94 std::map< std::pair<int, int>, wxString > m_evalOriginal;
95};
96
97
98#endif // FP_TEXT_GRID_TABLE_H
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) override
void SetValueAsLong(int aRow, int aCol, long aValue) override
wxGridCellAttr * m_boolColAttr
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
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
wxGridCellAttr * m_layerColAttr
int GetNumberCols() override
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
wxString GetRowLabelValue(int aRow) override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
std::map< std::pair< int, int >, wxString > m_evalOriginal
bool IsEmptyCell(int row, int col) override
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
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_XOFFSET
@ FPT_TEXT
@ FPT_THICKNESS