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 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_component.h>
31 #include <grid_tricks.h>
32 
33 class SCH_BASE_FRAME;
34 class DIALOG_SHIM;
35 
36 
38 {
39 public:
40  FIELDS_GRID_TRICKS( wxGrid* aGrid, DIALOG_SHIM* aDialog ) :
41  GRID_TRICKS( aGrid ),
42  m_dlg( aDialog )
43  {}
44 
45 protected:
46  virtual void showPopupMenu( wxMenu& menu ) override;
47  virtual void doPopupSelection( wxCommandEvent& event ) override;
49 };
50 
51 
53 {
65 
66  FDC_COUNT // keep as last
67 };
68 
69 
70 template <class T>
71 class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector<T>
72 {
73 public:
74  FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, LIB_PART* aPart );
76 
77  int GetNumberRows() override { return (int) this->size(); }
78  int GetNumberCols() override { return FDC_COUNT; }
79 
80  wxString GetColLabelValue( int aCol ) override;
81 
82  bool IsEmptyCell( int row, int col ) override
83  {
84  return false; // don't allow adjacent cell overflow, even if we are actually empty
85  }
86 
87  bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
88  bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
89  wxGridCellAttr* GetAttr( int row, int col, wxGridCellAttr::wxAttrKind kind ) override;
90 
91  wxString GetValue( int aRow, int aCol ) override;
92  bool GetValueAsBool( int aRow, int aCol ) override;
93 
94  void SetValue( int aRow, int aCol, const wxString &aValue ) override;
95  void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
96 
97 private:
101 
105 
106  wxGridCellAttr* m_readOnlyAttr;
107  wxGridCellAttr* m_fieldNameAttr;
108  wxGridCellAttr* m_referenceAttr;
109  wxGridCellAttr* m_valueAttr;
110  wxGridCellAttr* m_footprintAttr;
111  wxGridCellAttr* m_urlAttr;
112  wxGridCellAttr* m_boolAttr;
113  wxGridCellAttr* m_vAlignAttr;
114  wxGridCellAttr* m_hAlignAttr;
115  wxGridCellAttr* m_orientationAttr;
116 };
117 
118 
119 #endif // FIELDS_GRID_TABLE_H
virtual void showPopupMenu(wxMenu &menu) override
FIELDS_GRID_TRICKS(wxGrid *aGrid, DIALOG_SHIM *aDialog)
int GetNumberRows() override
Implementation of conversion functions that require both schematic and board internal units...
Class GRID_TRICKS is used to add cut, copy, and paste to an otherwise unmodied wxGrid instance...
Definition: grid_tricks.h:51
wxGridCellAttr * m_referenceAttr
SCH_BASE_FRAME * m_frame
Class DIALOG_SHIM may sit in the inheritance tree between wxDialog and any class written by wxFormBui...
Definition: dialog_shim.h:53
wxGridCellAttr * m_readOnlyAttr
wxGridCellAttr * m_hAlignAttr
SCH_FIELD_VALIDATOR m_referenceValidator
bool IsEmptyCell(int row, int col) override
Defintions of control validators for schematic dialogs.
SCH_FIELD_VALIDATOR m_fieldNameValidator
wxGridCellAttr * m_boolAttr
Define a library symbol object.
wxGridCellAttr * m_fieldNameAttr
FIELDS_DATA_COL_ORDER
wxGridCellAttr * m_urlAttr
Definition the SCH_COMPONENT class for Eeschema.
SCH_FIELD_VALIDATOR m_valueValidator
wxGridCellAttr * m_vAlignAttr
wxGridCellAttr * m_orientationAttr
wxGridCellAttr * m_valueAttr
EDA_UNITS_T m_userUnits
class SCH_FILED_VALIDATOR
A shim class between EDA_DRAW_FRAME and several derived classes: LIB_EDIT_FRAME, LIB_VIEW_FRAME, and SCH_EDIT_FRAME, and it brings in a common way of handling the provided virtual functions for the derived classes.
wxGridCellAttr * m_footprintAttr
int GetNumberCols() override
virtual void doPopupSelection(wxCommandEvent &event) override
EDA_UNITS_T
Definition: common.h:159