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
44 virtual ~PROPERTIES_PANEL();
45
46 virtual void UpdateData() = 0;
47
48 virtual void AfterCommit() {}
49
50 wxPropertyGrid* GetPropertyGrid()
51 {
52 return m_grid;
53 }
54
55 int PropertiesCount() const
56 {
57 return m_displayed.size();
58 }
59
60 const std::vector<PROPERTY_BASE*>& Properties() const
61 {
62 return m_displayed;
63 }
64
66
67 void SetSplitterProportion( float aProportion );
69
70protected:
76 virtual void rebuildProperties( const SELECTION& aSelection );
77
78 virtual wxPGProperty* createPGProperty( const PROPERTY_BASE* aProperty ) const = 0;
79
80 // Event handlers
81 virtual void valueChanging( wxPropertyGridEvent& aEvent ) { aEvent.Skip(); }
82 virtual void valueChanged( wxPropertyGridEvent& aEvent ) { aEvent.Skip(); }
83 void onCharHook( wxKeyEvent& aEvent );
84 void onShow( wxShowEvent& aEvent );
85
86 virtual void OnLanguageChanged( wxCommandEvent& aEvent );
87
93 bool getItemValue( EDA_ITEM* aItem, PROPERTY_BASE* aProperty, wxVariant& aValue );
94
104 bool extractValueAndWritability( const SELECTION& aSelection, PROPERTY_BASE* aProperty,
105 wxVariant& aValue, bool& aWritable );
106
107protected:
108 std::vector<PROPERTY_BASE*> m_displayed;
109 wxPropertyGrid* m_grid;
111 wxStaticText* m_caption;
112
115};
116
117#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:89
float m_splitter_key_proportion
Proportion of the grid column splitter that is used for the key column (0.0 - 1.0)
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 OnLanguageChanged(wxCommandEvent &aEvent)
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