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, see <https://www.gnu.org/licenses/>.
19 */
20#ifndef PROPERTIES_PANEL_H
21#define PROPERTIES_PANEL_H
22
23#include <wx/panel.h>
24#include <wx/propgrid/propgrid.h>
25
26#include <vector>
27#include <memory>
28
29class EDA_BASE_FRAME;
30class EDA_ITEM;
31class SELECTION;
32class PROPERTY_BASE;
33class wxStaticText;
34
35class PROPERTIES_PANEL : public wxPanel
36{
37public:
38 PROPERTIES_PANEL( wxWindow* aParent, EDA_BASE_FRAME* aFrame );
39
40 virtual ~PROPERTIES_PANEL();
41
42 virtual void UpdateData() = 0;
43
44 virtual void AfterCommit() {}
45
46 wxPropertyGrid* GetPropertyGrid()
47 {
48 return m_grid;
49 }
50
51 int PropertiesCount() const
52 {
53 return m_displayed.size();
54 }
55
56 const std::vector<PROPERTY_BASE*>& Properties() const
57 {
58 return m_displayed;
59 }
60
62
63 void SetSplitterProportion( float aProportion );
65
66protected:
72 virtual void rebuildProperties( const SELECTION& aSelection );
73
74 virtual wxPGProperty* createPGProperty( const PROPERTY_BASE* aProperty ) const = 0;
75
76 // Event handlers
77 virtual void valueChanging( wxPropertyGridEvent& aEvent ) { aEvent.Skip(); }
78 virtual void valueChanged( wxPropertyGridEvent& aEvent ) { aEvent.Skip(); }
79 void onCharHook( wxKeyEvent& aEvent );
80 void onShow( wxShowEvent& aEvent );
81
82 virtual void OnLanguageChanged( wxCommandEvent& aEvent );
83
89 virtual bool getItemValue( EDA_ITEM* aItem, PROPERTY_BASE* aProperty, wxVariant& aValue );
90
100 bool extractValueAndWritability( const SELECTION& aSelection, const wxString& aPropName,
101 wxVariant& aValue, bool& aWritable, wxPGChoices& aChoices );
102
103public:
105
106protected:
107 std::vector<PROPERTY_BASE*> m_displayed; // no ownership of pointers
108 wxPropertyGrid* m_grid;
110 wxStaticText* m_caption;
111
114};
115
125
126#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:96
float m_splitter_key_proportion
Proportion of the grid column splitter that is used for the key column (0.0 - 1.0)
PROPERTIES_PANEL(wxWindow *aParent, EDA_BASE_FRAME *aFrame)
virtual void valueChanging(wxPropertyGridEvent &aEvent)
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 extractValueAndWritability(const SELECTION &aSelection, const wxString &aPropName, wxVariant &aValue, bool &aWritable, wxPGChoices &aChoices)
Processes a selection and determines whether the given property should be available or not and what t...
virtual 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
SUPPRESS_GRID_CHANGED_EVENTS(PROPERTIES_PANEL *aPanel)