KiCad PCB EDA Suite
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 <base_units.h>
28#include <sch_validators.h>
29#include <wx/grid.h>
30#include <sch_symbol.h>
31#include <grid_tricks.h>
32#include <validators.h>
33
34class SCH_BASE_FRAME;
35class DIALOG_SHIM;
36class SCH_LABEL_BASE;
37
38
40{
41public:
43 GRID_TRICKS( aGrid ),
44 m_dlg( aDialog )
45 {}
46
47protected:
48 virtual void showPopupMenu( wxMenu& menu ) override;
49 virtual void doPopupSelection( wxCommandEvent& event ) override;
51};
52
53
55{
69
70 FDC_COUNT // keep as last
71};
72
73
74template <class T>
75class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector<T>
76{
77public:
78 FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid,
79 LIB_SYMBOL* aSymbol );
80 FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
81 SCH_SYMBOL* aSymbol );
82 FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
83 SCH_SHEET* aSheet );
84 FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_EDIT_FRAME* aFrame, WX_GRID* aGrid,
85 SCH_LABEL_BASE* aLabel );
87
88 int GetNumberRows() override { return (int) this->size(); }
89 int GetNumberCols() override { return FDC_COUNT; }
90
91 wxString GetColLabelValue( int aCol ) override;
92
93 bool IsEmptyCell( int row, int col ) override
94 {
95 return false; // don't allow adjacent cell overflow, even if we are actually empty
96 }
97
98 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
99 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
100 wxGridCellAttr* GetAttr( int row, int col, wxGridCellAttr::wxAttrKind kind ) override;
101
102 wxString GetValue( int aRow, int aCol ) override;
103 bool GetValueAsBool( int aRow, int aCol ) override;
104
105 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
106 void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
107
108 wxString StringFromBool( bool aValue ) const;
109 bool BoolFromString( wxString aValue ) const;
110
111protected:
112 void initGrid( WX_GRID* aGrid );
113
114 void onUnitsChanged( wxCommandEvent& aEvent );
115
116private:
124 wxString m_curdir;
125
133
134 wxGridCellAttr* m_readOnlyAttr;
135 wxGridCellAttr* m_fieldNameAttr;
136 wxGridCellAttr* m_referenceAttr;
137 wxGridCellAttr* m_valueAttr;
138 wxGridCellAttr* m_footprintAttr;
139 wxGridCellAttr* m_urlAttr;
140 wxGridCellAttr* m_nonUrlAttr;
141 wxGridCellAttr* m_filepathAttr;
142 wxGridCellAttr* m_boolAttr;
143 wxGridCellAttr* m_vAlignAttr;
144 wxGridCellAttr* m_hAlignAttr;
145 wxGridCellAttr* m_orientationAttr;
146 wxGridCellAttr* m_netclassAttr;
147 wxGridCellAttr* m_fontAttr;
148 wxGridCellAttr* m_colorAttr;
149};
150
151
152#endif // FIELDS_GRID_TABLE_H
Implementation of conversion functions that require both schematic and board internal units.
Dialog helper object to sit in the inheritance tree between wxDialog and any class written by wxFormB...
Definition: dialog_shim.h:83
wxString GetValue(int aRow, int aCol) override
LIB_ID_VALIDATOR m_libIdValidator
wxGridCellAttr * m_nonUrlAttr
wxGridCellAttr * m_readOnlyAttr
wxGridCellAttr * m_vAlignAttr
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
wxGridCellAttr * m_netclassAttr
int GetNumberCols() override
bool GetValueAsBool(int aRow, int aCol) override
void onUnitsChanged(wxCommandEvent &aEvent)
wxGridCellAttr * m_boolAttr
SCH_FIELD_VALIDATOR m_fieldNameValidator
DIALOG_SHIM * m_dialog
wxString GetColLabelValue(int aCol) override
wxGridCellAttr * m_footprintAttr
wxGridCellAttr * m_filepathAttr
wxGridCellAttr * m_orientationAttr
SCH_FIELD_VALIDATOR m_urlValidator
void SetValue(int aRow, int aCol, const wxString &aValue) override
wxGridCellAttr * m_fontAttr
SCH_BASE_FRAME * m_frame
wxGridCellAttr * m_referenceAttr
wxGridCellAttr * m_colorAttr
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
bool IsEmptyCell(int row, int col) override
FIELDS_GRID_TABLE(DIALOG_SHIM *aDialog, SCH_BASE_FRAME *aFrame, WX_GRID *aGrid, LIB_SYMBOL *aSymbol)
SCH_FIELD_VALIDATOR m_valueValidator
SCH_FIELD_VALIDATOR m_referenceValidator
wxGridCellAttr * GetAttr(int row, int col, wxGridCellAttr::wxAttrKind kind) override
wxString StringFromBool(bool aValue) const
SCH_FIELD_VALIDATOR m_nonUrlValidator
wxGridCellAttr * m_urlAttr
void SetValueAsBool(int aRow, int aCol, bool aValue) override
int GetNumberRows() override
bool BoolFromString(wxString aValue) const
wxGridCellAttr * m_valueAttr
void initGrid(WX_GRID *aGrid)
wxGridCellAttr * m_fieldNameAttr
wxGridCellAttr * m_hAlignAttr
SCH_FIELD_VALIDATOR m_filepathValidator
FIELDS_GRID_TRICKS(WX_GRID *aGrid, DIALOG_SHIM *aDialog)
virtual void showPopupMenu(wxMenu &menu) override
virtual void doPopupSelection(wxCommandEvent &event) override
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:59
Custom validator that verifies that a string defines a valid LIB_ID.
Definition: validators.h:173
Define a library symbol object.
Definition: lib_symbol.h:99
A shim class between EDA_DRAW_FRAME and several derived classes: SYMBOL_EDIT_FRAME,...
Schematic editor (Eeschema) main window.
A text control validator used for validating the text allowed in library and schematic symbol fields.
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:55
Schematic symbol object.
Definition: sch_symbol.h:79
FIELDS_DATA_COL_ORDER
@ FDC_TEXT_SIZE
@ FDC_BOLD
@ FDC_POSY
@ FDC_ITALIC
@ FDC_COUNT
@ FDC_NAME
@ FDC_H_ALIGN
@ FDC_COLOR
@ FDC_SHOWN
@ FDC_VALUE
@ FDC_POSX
@ FDC_ORIENTATION
@ FDC_V_ALIGN
@ FDC_FONT
Definitions of control validators for schematic dialogs.
KICAD_T
The set of class identification values stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
Custom text control validator definitions.