KiCad PCB EDA Suite
Loading...
Searching...
No Matches
properties_panel.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) 2016 CERN
5 * @author Maciej Suminski <[email protected]>
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#ifndef PROPERTIES_PANEL_H
25#define PROPERTIES_PANEL_H
26
27#include <wx/panel.h>
28#include <wx/propgrid/propgrid.h>
29
30#include <vector>
31#include <memory>
32
33class EDA_BASE_FRAME;
34class EDA_ITEM;
35class SELECTION;
36class PROPERTY_BASE;
37class wxStaticText;
38
39class PROPERTIES_PANEL : public wxPanel
40{
41public:
42 PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame );
43
45 {
46 }
47
48 virtual void UpdateData() = 0;
49
50 virtual void AfterCommit() {}
51
52 wxPropertyGrid* GetPropertyGrid()
53 {
54 return m_grid;
55 }
56
57 int PropertiesCount() const
58 {
59 return m_displayed.size();
60 }
61
62 const std::vector<PROPERTY_BASE*>& Properties() const
63 {
64 return m_displayed;
65 }
66
68
69 void SetSplitterProportion( float aProportion );
71
72 void OnLanguageChanged();
73
74protected:
80 virtual void rebuildProperties( const SELECTION& aSelection );
81
82 virtual wxPGProperty* createPGProperty( const PROPERTY_BASE* aProperty ) const = 0;
83
84 // Event handlers
85 virtual void valueChanging( wxPropertyGridEvent& aEvent ) {}
86 virtual void valueChanged( wxPropertyGridEvent& aEvent ) {}
87 void onCharHook( wxKeyEvent& aEvent );
88 void onShow( wxShowEvent& aEvent );
89
95 bool getItemValue( EDA_ITEM* aItem, PROPERTY_BASE* aProperty, wxVariant& aValue );
96
106 bool extractValueAndWritability( const SELECTION& aSelection, PROPERTY_BASE* aProperty,
107 wxVariant& aValue, bool& aWritable );
108
109protected:
110 std::vector<PROPERTY_BASE*> m_displayed;
111 wxPropertyGrid* m_grid;
113 wxStaticText* m_caption;
114
117};
118
119#endif /* PROPERTIES_PANEL_H */
The base frame for deriving all KiCad main window classes.
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
float m_splitter_key_proportion
Proportion of the grid column splitter that is used for the key column (0.0 - 1.0)
virtual ~PROPERTIES_PANEL()
virtual void valueChanging(wxPropertyGridEvent &aEvent)
bool extractValueAndWritability(const SELECTION &aSelection, PROPERTY_BASE *aProperty, wxVariant &aValue, bool &aWritable)
Processes a selection and determines whether the given property should be available or not and what t...
wxPropertyGrid * m_grid
float SplitterProportion() const
const std::vector< PROPERTY_BASE * > & Properties() const
wxPropertyGrid * GetPropertyGrid()
wxStaticText * m_caption
void SetSplitterProportion(float aProportion)
int PropertiesCount() const
std::vector< PROPERTY_BASE * > m_displayed
virtual void AfterCommit()
virtual void UpdateData()=0
virtual void valueChanged(wxPropertyGridEvent &aEvent)
bool getItemValue(EDA_ITEM *aItem, PROPERTY_BASE *aProperty, wxVariant &aValue)
Utility to fetch a property value and convert to wxVariant Precondition: aItem is known to have prope...
virtual void rebuildProperties(const SELECTION &aSelection)
Generates the property grid for a given selection of items.
void onCharHook(wxKeyEvent &aEvent)
virtual wxPGProperty * createPGProperty(const PROPERTY_BASE *aProperty) const =0
void onShow(wxShowEvent &aEvent)
EDA_BASE_FRAME * m_frame