KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pg_editors.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) 2022 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation, either version 3 of the License, or (at your
9 * option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License along
17 * with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19
20#ifndef KICAD_PG_EDITORS_H
21#define KICAD_PG_EDITORS_H
22
23#include <memory>
24
25#include <wx/propgrid/propgrid.h>
26#include <wx/propgrid/editors.h>
27
28class EDA_DRAW_FRAME;
30
31class PG_UNIT_EDITOR : public wxPGTextCtrlEditor
32{
33public:
34 static const wxString EDITOR_NAME;
35
37
38 virtual ~PG_UNIT_EDITOR();
39
40 wxString GetName() const override { return m_editorName; }
41
42 wxPGWindowList CreateControls( wxPropertyGrid* aPropGrid, wxPGProperty* aProperty,
43 const wxPoint& aPos, const wxSize& aSize ) const override;
44
45 bool GetValueFromControl( wxVariant& aVariant, wxPGProperty* aProperty,
46 wxWindow* aCtrl ) const override;
47
48 void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const override;
49
50 bool OnEvent( wxPropertyGrid* aPropGrid, wxPGProperty* aProperty, wxWindow* aCtrl,
51 wxEvent& aEvent ) const override;
52
59 void UpdateFrame( EDA_DRAW_FRAME* aFrame );
60
61 static wxString BuildEditorName( EDA_DRAW_FRAME* aFrame );
62
63protected:
65
66 std::unique_ptr<PROPERTY_EDITOR_UNIT_BINDER> m_unitBinder;
67
68 wxString m_editorName;
69};
70
71
72class PG_CHECKBOX_EDITOR : public wxPGCheckBoxEditor
73{
74public:
75 static const wxString EDITOR_NAME;
76
78
80
81 wxString GetName() const override { return EDITOR_NAME; }
82
83 wxPGWindowList CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
84 const wxPoint& aPos, const wxSize& aSize ) const override;
85};
86
87
88class PG_COLOR_EDITOR : public wxPGEditor
89{
90public:
91 static const wxString EDITOR_NAME;
92
94
95 virtual ~PG_COLOR_EDITOR() {}
96
97 wxString GetName() const override { return EDITOR_NAME; }
98
99 wxPGWindowList CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
100 const wxPoint& aPos, const wxSize& aSize ) const override;
101
102 void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const override;
103
104 bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aWindow,
105 wxEvent& aEvent ) const override;
106
107private:
108 KIGFX::COLOR4D colorFromVariant( const wxVariant& aVariant ) const;
109
110 KIGFX::COLOR4D colorFromProperty( wxPGProperty* aProperty ) const;
111};
112
113
114class PG_RATIO_EDITOR : public wxPGTextCtrlEditor
115{
116public:
117 static const wxString EDITOR_NAME;
118
119 wxString GetName() const override { return EDITOR_NAME; }
120
121 bool GetValueFromControl( wxVariant& aVariant, wxPGProperty* aProperty,
122 wxWindow* aCtrl ) const override;
123
124 void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const override;
125};
126
127
128#endif //KICAD_PG_EDITORS_H
The base class for create windows for drawing purpose.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
wxString GetName() const override
Definition: pg_editors.h:81
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
Definition: pg_editors.cpp:277
static const wxString EDITOR_NAME
Definition: pg_editors.h:75
virtual ~PG_CHECKBOX_EDITOR()
Definition: pg_editors.h:79
static const wxString EDITOR_NAME
Definition: pg_editors.h:91
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
Definition: pg_editors.cpp:297
virtual ~PG_COLOR_EDITOR()
Definition: pg_editors.h:95
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aWindow, wxEvent &aEvent) const override
Definition: pg_editors.cpp:290
wxString GetName() const override
Definition: pg_editors.h:97
KIGFX::COLOR4D colorFromVariant(const wxVariant &aVariant) const
Definition: pg_editors.cpp:347
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
Definition: pg_editors.cpp:340
KIGFX::COLOR4D colorFromProperty(wxPGProperty *aProperty) const
Definition: pg_editors.cpp:362
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
Definition: pg_editors.cpp:368
static const wxString EDITOR_NAME
Definition: pg_editors.h:117
wxString GetName() const override
Definition: pg_editors.h:119
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
Definition: pg_editors.cpp:430
std::unique_ptr< PROPERTY_EDITOR_UNIT_BINDER > m_unitBinder
Definition: pg_editors.h:66
wxPGWindowList CreateControls(wxPropertyGrid *aPropGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
Definition: pg_editors.cpp:74
static const wxString EDITOR_NAME
Definition: pg_editors.h:34
wxString GetName() const override
Definition: pg_editors.h:40
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
Definition: pg_editors.cpp:112
void UpdateFrame(EDA_DRAW_FRAME *aFrame)
When restarting an editor, the instance of PG_UNIT_EDITOR may be the same but the referenced frame is...
Definition: pg_editors.cpp:58
EDA_DRAW_FRAME * m_frame
Definition: pg_editors.h:64
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
Definition: pg_editors.cpp:168
wxString m_editorName
Definition: pg_editors.h:68
bool OnEvent(wxPropertyGrid *aPropGrid, wxPGProperty *aProperty, wxWindow *aCtrl, wxEvent &aEvent) const override
Definition: pg_editors.cpp:149
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
Definition: pg_editors.cpp:52
virtual ~PG_UNIT_EDITOR()
Definition: pg_editors.cpp:47
Specialization for wxPropertyGrid, where we have no labels and units are displayed in the editor.
Definition: unit_binder.h:277