2018-02-28 16:54:35 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-02-24 13:48:02 +00:00
|
|
|
* Copyright (C) 2018-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2018-02-28 16:54:35 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef FIELDS_GRID_TABLE_H
|
|
|
|
#define FIELDS_GRID_TABLE_H
|
|
|
|
|
|
|
|
#include <base_units.h>
|
|
|
|
#include <sch_validators.h>
|
|
|
|
#include <wx/grid.h>
|
2021-02-24 13:48:02 +00:00
|
|
|
#include <sch_symbol.h>
|
2018-02-28 16:54:35 +00:00
|
|
|
#include <grid_tricks.h>
|
2019-06-04 13:32:10 +00:00
|
|
|
#include <validators.h>
|
2018-02-28 16:54:35 +00:00
|
|
|
|
2018-08-08 20:57:53 +00:00
|
|
|
class SCH_BASE_FRAME;
|
|
|
|
class DIALOG_SHIM;
|
2021-10-12 20:05:37 +00:00
|
|
|
class SCH_LABEL_BASE;
|
2018-08-08 20:57:53 +00:00
|
|
|
|
|
|
|
|
2018-02-28 16:54:35 +00:00
|
|
|
class FIELDS_GRID_TRICKS : public GRID_TRICKS
|
|
|
|
{
|
|
|
|
public:
|
2019-03-04 11:02:12 +00:00
|
|
|
FIELDS_GRID_TRICKS( WX_GRID* aGrid, DIALOG_SHIM* aDialog ) :
|
2018-02-28 16:54:35 +00:00
|
|
|
GRID_TRICKS( aGrid ),
|
|
|
|
m_dlg( aDialog )
|
|
|
|
{}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual void showPopupMenu( wxMenu& menu ) override;
|
|
|
|
virtual void doPopupSelection( wxCommandEvent& event ) override;
|
|
|
|
DIALOG_SHIM* m_dlg;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
enum FIELDS_DATA_COL_ORDER
|
|
|
|
{
|
|
|
|
FDC_NAME,
|
|
|
|
FDC_VALUE,
|
|
|
|
FDC_SHOWN,
|
|
|
|
FDC_H_ALIGN,
|
|
|
|
FDC_V_ALIGN,
|
|
|
|
FDC_ITALIC,
|
|
|
|
FDC_BOLD,
|
|
|
|
FDC_TEXT_SIZE,
|
|
|
|
FDC_ORIENTATION,
|
|
|
|
FDC_POSX,
|
|
|
|
FDC_POSY,
|
|
|
|
|
|
|
|
FDC_COUNT // keep as last
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
template <class T>
|
|
|
|
class FIELDS_GRID_TABLE : public wxGridTableBase, public std::vector<T>
|
|
|
|
{
|
|
|
|
public:
|
2021-02-17 14:06:19 +00:00
|
|
|
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid,
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* aSymbol );
|
2021-02-17 14:06:19 +00:00
|
|
|
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid,
|
|
|
|
SCH_SHEET* aSheet );
|
2021-10-12 20:05:37 +00:00
|
|
|
FIELDS_GRID_TABLE( DIALOG_SHIM* aDialog, SCH_BASE_FRAME* aFrame, WX_GRID* aGrid,
|
|
|
|
SCH_LABEL_BASE* aLabel );
|
2018-02-28 16:54:35 +00:00
|
|
|
~FIELDS_GRID_TABLE();
|
|
|
|
|
|
|
|
int GetNumberRows() override { return (int) this->size(); }
|
|
|
|
int GetNumberCols() override { return FDC_COUNT; }
|
|
|
|
|
|
|
|
wxString GetColLabelValue( int aCol ) override;
|
|
|
|
|
|
|
|
bool IsEmptyCell( int row, int col ) override
|
|
|
|
{
|
|
|
|
return false; // don't allow adjacent cell overflow, even if we are actually empty
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
|
|
|
|
bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override;
|
|
|
|
wxGridCellAttr* GetAttr( int row, int col, wxGridCellAttr::wxAttrKind kind ) override;
|
|
|
|
|
|
|
|
wxString GetValue( int aRow, int aCol ) override;
|
|
|
|
bool GetValueAsBool( int aRow, int aCol ) override;
|
|
|
|
|
2021-07-27 12:22:27 +00:00
|
|
|
void SetValue( int aRow, int aCol, const wxString& aValue ) override;
|
2018-02-28 16:54:35 +00:00
|
|
|
void SetValueAsBool( int aRow, int aCol, bool aValue ) override;
|
|
|
|
|
2020-10-27 11:03:35 +00:00
|
|
|
wxString StringFromBool( bool aValue ) const;
|
|
|
|
bool BoolFromString( wxString aValue ) const;
|
2019-01-16 13:16:24 +00:00
|
|
|
|
2020-03-06 20:02:58 +00:00
|
|
|
protected:
|
2021-10-25 11:34:30 +00:00
|
|
|
void initGrid( WX_GRID* aGrid );
|
2020-03-06 20:02:58 +00:00
|
|
|
|
2021-12-22 21:43:41 +00:00
|
|
|
void onUnitsChanged( wxCommandEvent& aEvent );
|
|
|
|
|
2018-02-28 16:54:35 +00:00
|
|
|
private:
|
2019-12-20 14:11:39 +00:00
|
|
|
SCH_BASE_FRAME* m_frame;
|
2021-10-25 11:34:30 +00:00
|
|
|
DIALOG_SHIM* m_dialog;
|
2021-02-17 14:06:19 +00:00
|
|
|
WX_GRID* m_grid;
|
2020-03-06 20:02:58 +00:00
|
|
|
KICAD_T m_parentType;
|
|
|
|
int m_mandatoryFieldCount;
|
2021-06-10 18:51:46 +00:00
|
|
|
LIB_SYMBOL* m_part;
|
2020-03-06 20:02:58 +00:00
|
|
|
wxString m_curdir;
|
2018-02-28 16:54:35 +00:00
|
|
|
|
2018-07-21 20:23:13 +00:00
|
|
|
SCH_FIELD_VALIDATOR m_fieldNameValidator;
|
|
|
|
SCH_FIELD_VALIDATOR m_referenceValidator;
|
2018-09-13 15:39:14 +00:00
|
|
|
SCH_FIELD_VALIDATOR m_valueValidator;
|
2019-06-04 13:32:10 +00:00
|
|
|
LIB_ID_VALIDATOR m_libIdValidator;
|
|
|
|
SCH_FIELD_VALIDATOR m_urlValidator;
|
|
|
|
SCH_FIELD_VALIDATOR m_nonUrlValidator;
|
2020-03-06 20:02:58 +00:00
|
|
|
SCH_FIELD_VALIDATOR m_filepathValidator;
|
2018-02-28 16:54:35 +00:00
|
|
|
|
|
|
|
wxGridCellAttr* m_readOnlyAttr;
|
2018-07-21 20:23:13 +00:00
|
|
|
wxGridCellAttr* m_fieldNameAttr;
|
|
|
|
wxGridCellAttr* m_referenceAttr;
|
2018-09-13 15:39:14 +00:00
|
|
|
wxGridCellAttr* m_valueAttr;
|
2018-07-20 15:03:43 +00:00
|
|
|
wxGridCellAttr* m_footprintAttr;
|
|
|
|
wxGridCellAttr* m_urlAttr;
|
2019-05-10 12:21:08 +00:00
|
|
|
wxGridCellAttr* m_nonUrlAttr;
|
2020-03-06 20:02:58 +00:00
|
|
|
wxGridCellAttr* m_filepathAttr;
|
2018-07-21 20:23:13 +00:00
|
|
|
wxGridCellAttr* m_boolAttr;
|
|
|
|
wxGridCellAttr* m_vAlignAttr;
|
|
|
|
wxGridCellAttr* m_hAlignAttr;
|
|
|
|
wxGridCellAttr* m_orientationAttr;
|
2021-10-12 20:05:37 +00:00
|
|
|
wxGridCellAttr* m_netclassAttr;
|
2018-02-28 16:54:35 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // FIELDS_GRID_TABLE_H
|