KiCad PCB EDA Suite
Loading...
Searching...
No Matches
zone_layer_properties_grid.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) 2008-2018 Jean-Pierre Charras, [email protected]
5 * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, you may find one here:
19 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20 * or you may search the http://www.gnu.org website for the version 2 license,
21 * or you may write to the Free Software Foundation, Inc.,
22 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23 */
24
25#pragma once
26
27#include <functional>
28#include <vector>
29#include <utility>
30
31#include <layer_ids.h>
32#include <lset.h>
33#include <widgets/wx_grid.h>
34#include <zone_settings.h>
35
36class PCB_BASE_FRAME;
37
38
40{
41public:
42 LAYER_PROPERTIES_GRID_TABLE( PCB_BASE_FRAME* aFrame, std::function<LSET()> getLayers );
44
45 int GetNumberRows() override { return (int) m_items.size(); }
46 int GetNumberCols() override { return 3; }
47
48 wxString GetColLabelValue( int aCol ) override
49 {
50 switch( aCol )
51 {
52 case 0: return _( "Layer" );
53 case 1: return _( "Offset X" );
54 case 2: return _( "Offset Y" );
55 default: return wxEmptyString;
56 }
57 }
58
59 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
60 {
61 switch( aCol )
62 {
63 case 0: return aTypeName == wxGRID_VALUE_NUMBER;
64 case 1: return aTypeName == wxGRID_VALUE_STRING;
65 case 2: return aTypeName == wxGRID_VALUE_STRING;
66 default: wxFAIL; return false;
67 }
68 }
69
70 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
71 {
72 return CanGetValueAs( aRow, aCol, aTypeName );
73 }
74
75 wxString GetValue( int aRow, int aCol ) override;
76 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
77
78 long GetValueAsLong( int aRow, int aCol ) override;
79 void SetValueAsLong( int aRow, int aCol, long aValue ) override;
80
81 void AddItem( PCB_LAYER_ID aLayer, const ZONE_LAYER_PROPERTIES& aProps );
82 bool AppendRows( size_t aNumRows = 1 ) override;
83 bool DeleteRows( size_t aPos, size_t aNumRows ) override;
84
85 const std::vector<std::pair<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>>& GetItems() { return m_items; }
86
87protected:
88 void onUnitsChanged( wxCommandEvent& aEvent );
89
90private:
92 std::function<LSET()> m_getLayersFunc;
93 std::vector<std::pair<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>> m_items;
94};
wxString GetColLabelValue(int aCol) override
wxString GetValue(int aRow, int aCol) override
bool CanGetValueAs(int aRow, int aCol, const wxString &aTypeName) override
const std::vector< std::pair< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > > & GetItems()
void SetValueAsLong(int aRow, int aCol, long aValue) override
void SetValue(int aRow, int aCol, const wxString &aValue) override
void AddItem(PCB_LAYER_ID aLayer, const ZONE_LAYER_PROPERTIES &aProps)
std::vector< std::pair< PCB_LAYER_ID, ZONE_LAYER_PROPERTIES > > m_items
long GetValueAsLong(int aRow, int aCol) override
bool AppendRows(size_t aNumRows=1) override
bool DeleteRows(size_t aPos, size_t aNumRows) override
bool CanSetValueAs(int aRow, int aCol, const wxString &aTypeName) override
void onUnitsChanged(wxCommandEvent &aEvent)
LAYER_PROPERTIES_GRID_TABLE(PCB_BASE_FRAME *aFrame, std::function< LSET()> getLayers)
LSET is a set of PCB_LAYER_IDs.
Definition lset.h:37
Base PCB main window class for Pcbnew, Gerbview, and CvPcb footprint viewer.
#define _(s)
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60
Class ZONE_SETTINGS used to handle zones parameters in dialogs.