KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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-2022 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 FIELDS_GRID_TABLE_H
25#define FIELDS_GRID_TABLE_H
26
27#include <wx/grid.h>
28#include <sch_symbol.h>
29#include <grid_tricks.h>
30#include <validators.h>
31
32class SCH_BASE_FRAME;
33class DIALOG_SHIM;
34class EMBEDDED_FILES;
35class SCH_LABEL_BASE;
36
37
39{
40public:
42 std::function<void( wxCommandEvent& )> aAddHandler ) :
43 GRID_TRICKS( aGrid, std::move( aAddHandler ) ),
44 m_dlg( aDialog ),
45 m_files( aFiles )
46 {}
47
48protected:
49 void showPopupMenu( wxMenu& menu, wxGridEvent& aEvent ) override;
50 void doPopupSelection( wxCommandEvent& event ) override;
53};
54
55
57{
73
74 FDC_COUNT // keep as last
75};
76
77
78class FIELDS_GRID_TABLE : public WX_GRID_TABLE_BASE, public std::vector<SCH_FIELD>
79{
80public:
81 FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid,
82 LIB_SYMBOL* aSymbol );
83 FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
84 SCH_SYMBOL* aSymbol );
85 FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
86 SCH_SHEET* aSheet );
87 FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
88 SCH_LABEL_BASE* aLabel );
89 ~FIELDS_GRID_TABLE() override;
90
91 int GetNumberRows() override { return (int) this->size(); }
92 int GetNumberCols() override { return FDC_COUNT; }
93
94 wxString GetColLabelValue( int aCol ) override;
95
96 bool IsEmptyCell( int row, int col ) override
97 {
98 return false; // don't allow adjacent cell overflow, even if we are actually empty
99 }
100
101 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
102 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
103 wxGridCellAttr* GetAttr( int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind ) override;
104
105 wxString GetValue( int aRow, int aCol ) override;
106 bool GetValueAsBool( int aRow, int aCol ) override;
107
108 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
109 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
110
111 wxString StringFromBool( bool aValue ) const;
112 bool BoolFromString( wxString aValue ) const;
113
114protected:
115 void initGrid( WX_GRID* aGrid );
116
117 void onUnitsChanged( wxCommandEvent& aEvent );
118
119private:
126 wxString m_curdir;
127
134
135 wxGridCellAttr* m_readOnlyAttr;
136 wxGridCellAttr* m_fieldNameAttr;
137 wxGridCellAttr* m_referenceAttr;
138 wxGridCellAttr* m_valueAttr;
139 wxGridCellAttr* m_footprintAttr;
140 wxGridCellAttr* m_urlAttr;
141 wxGridCellAttr* m_nonUrlAttr;
142 wxGridCellAttr* m_filepathAttr;
143 wxGridCellAttr* m_boolAttr;
144 wxGridCellAttr* m_vAlignAttr;
145 wxGridCellAttr* m_hAlignAttr;
146 wxGridCellAttr* m_orientationAttr;
147 wxGridCellAttr* m_netclassAttr;
148 wxGridCellAttr* m_fontAttr;
149 wxGridCellAttr* m_colorAttr;
150
151 std::unique_ptr<NUMERIC_EVALUATOR> m_eval;
152 std::map< std::pair<int, int>, wxString > m_evalOriginal;
153};
154
155
156#endif // FIELDS_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
wxGridCellAttr * GetAttr(int aRow, int aCol, wxGridCellAttr::wxAttrKind aKind) override
wxString StringFromBool(bool aValue) const
bool GetValueAsBool(int aRow, int aCol) override
FIELD_VALIDATOR m_fieldNameValidator
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
void initGrid(WX_GRID *aGrid)
wxGridCellAttr * m_fieldNameAttr
int GetNumberRows() override
wxGridCellAttr * m_readOnlyAttr
FIELD_VALIDATOR m_urlValidator
SCH_BASE_FRAME * m_frame
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
wxGridCellAttr * m_colorAttr
wxGridCellAttr * m_nonUrlAttr
wxGridCellAttr * m_referenceAttr
FIELD_VALIDATOR m_referenceValidator
FIELD_VALIDATOR m_valueValidator
std::map< std::pair< int, int >, wxString > m_evalOriginal
DIALOG_SHIM * m_dialog
bool IsEmptyCell(int row, int col) override
wxGridCellAttr * m_footprintAttr
wxGridCellAttr * m_boolAttr
wxGridCellAttr * m_fontAttr
wxGridCellAttr * m_urlAttr
wxGridCellAttr * m_valueAttr
wxGridCellAttr * m_hAlignAttr
wxGridCellAttr * m_orientationAttr
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * m_vAlignAttr
wxGridCellAttr * m_filepathAttr
wxGridCellAttr * m_netclassAttr
void SetValueAsBool(int aRow, int aCol, bool aValue) override
int GetNumberCols() override
wxString GetValue(int aRow, int aCol) override
void onUnitsChanged(wxCommandEvent &aEvent)
std::unique_ptr< NUMERIC_EVALUATOR > m_eval
FIELD_VALIDATOR m_nonUrlValidator
FIELD_VALIDATOR m_filepathValidator
wxString GetColLabelValue(int aCol) override
bool BoolFromString(wxString aValue) const
FIELDS_GRID_TRICKS(WX_GRID *aGrid, DIALOG_SHIM *aDialog, EMBEDDED_FILES *aFiles, std::function< void(wxCommandEvent &)> aAddHandler)
void showPopupMenu(wxMenu &menu, wxGridEvent &aEvent) override
void doPopupSelection(wxCommandEvent &event) override
EMBEDDED_FILES * m_files
A text control validator used for validating the text allowed in fields.
Definition: validators.h:221
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
Define a library symbol object.
Definition: lib_symbol.h:78
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Schematic editor (Eeschema) main window.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
Schematic symbol object.
Definition: sch_symbol.h:104
FIELDS_DATA_COL_ORDER
@ FDC_TEXT_SIZE
@ FDC_BOLD
@ FDC_POSY
@ FDC_ITALIC
@ FDC_SHOW_NAME
@ FDC_COUNT
@ FDC_NAME
@ FDC_H_ALIGN
@ FDC_COLOR
@ FDC_SHOWN
@ FDC_ALLOW_AUTOPLACE
@ FDC_VALUE
@ FDC_POSX
@ FDC_ORIENTATION
@ FDC_V_ALIGN
@ FDC_FONT
STL namespace.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
Custom text control validator definitions.