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, see <https://www.gnu.org/licenses/>.
19 */
20
21#pragma once
22
23#include <functional>
24#include <vector>
25#include <utility>
26
27#include <layer_ids.h>
28#include <lset.h>
29#include <widgets/wx_grid.h>
30#include <zone_settings.h>
31
32class PCB_BASE_FRAME;
33
34
36{
37public:
38 LAYER_PROPERTIES_GRID_TABLE( PCB_BASE_FRAME* aFrame, std::function<LSET()> getLayers );
40
41 int GetNumberRows() override { return (int) m_items.size(); }
42 int GetNumberCols() override { return 3; }
43
44 wxString GetColLabelValue( int aCol ) override
45 {
46 switch( aCol )
47 {
48 case 0: return _( "Layer" );
49 case 1: return _( "Offset X" );
50 case 2: return _( "Offset Y" );
51 default: return wxEmptyString;
52 }
53 }
54
55 bool CanGetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
56 {
57 switch( aCol )
58 {
59 case 0: return aTypeName == wxGRID_VALUE_NUMBER;
60 case 1: return aTypeName == wxGRID_VALUE_STRING;
61 case 2: return aTypeName == wxGRID_VALUE_STRING;
62 default: wxFAIL; return false;
63 }
64 }
65
66 bool CanSetValueAs( int aRow, int aCol, const wxString& aTypeName ) override
67 {
68 return CanGetValueAs( aRow, aCol, aTypeName );
69 }
70
71 wxString GetValue( int aRow, int aCol ) override;
72 void SetValue( int aRow, int aCol, const wxString& aValue ) override;
73
74 long GetValueAsLong( int aRow, int aCol ) override;
75 void SetValueAsLong( int aRow, int aCol, long aValue ) override;
76
77 void AddItem( PCB_LAYER_ID aLayer, const ZONE_LAYER_PROPERTIES& aProps );
78 bool AppendRows( size_t aNumRows = 1 ) override;
79 bool DeleteRows( size_t aPos, size_t aNumRows ) override;
80
81 const std::vector<std::pair<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>>& GetItems() { return m_items; }
82
83protected:
84 void onUnitsChanged( wxCommandEvent& aEvent );
85
86private:
88 std::function<LSET()> m_getLayersFunc;
89 std::vector<std::pair<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES>> m_items;
90};
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:56
Class ZONE_SETTINGS used to handle zones parameters in dialogs.