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 The 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
128class PG_FPID_EDITOR : public wxPGTextCtrlEditor
129{
130public:
131 static const wxString EDITOR_NAME;
132
134
135 virtual ~PG_FPID_EDITOR() {}
136
137 wxString GetName() const override { return m_editorName; }
138
139 void UpdateFrame( EDA_DRAW_FRAME* aFrame );
140
141 static wxString BuildEditorName( EDA_DRAW_FRAME* aFrame );
142
143 wxPGWindowList CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
144 const wxPoint& aPos, const wxSize& aSize ) const override;
145
146 bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aCtrl,
147 wxEvent& aEvent ) const override;
148
149private:
151 wxString m_editorName;
152};
153
154
155class PG_URL_EDITOR : public wxPGTextCtrlEditor
156{
157public:
158 static const wxString EDITOR_NAME;
159
160 PG_URL_EDITOR( EDA_DRAW_FRAME* aFrame );
161
162 virtual ~PG_URL_EDITOR() {}
163
164 wxString GetName() const override { return m_editorName; }
165
166 void UpdateFrame( EDA_DRAW_FRAME* aFrame );
167
168 static wxString BuildEditorName( EDA_DRAW_FRAME* aFrame );
169
170 wxPGWindowList CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
171 const wxPoint& aPos, const wxSize& aSize ) const override;
172
173 bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aCtrl,
174 wxEvent& aEvent ) const override;
175
176private:
178 wxString m_editorName;
179};
180
181
182#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
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
virtual ~PG_COLOR_EDITOR()
Definition pg_editors.h:95
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aWindow, wxEvent &aEvent) const override
wxString GetName() const override
Definition pg_editors.h:97
KIGFX::COLOR4D colorFromVariant(const wxVariant &aVariant) const
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
KIGFX::COLOR4D colorFromProperty(wxPGProperty *aProperty) const
wxString m_editorName
Definition pg_editors.h:151
wxString GetName() const override
Definition pg_editors.h:137
void UpdateFrame(EDA_DRAW_FRAME *aFrame)
virtual ~PG_FPID_EDITOR()
Definition pg_editors.h:135
PG_FPID_EDITOR(EDA_DRAW_FRAME *aFrame)
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
static const wxString EDITOR_NAME
Definition pg_editors.h:131
EDA_DRAW_FRAME * m_frame
Definition pg_editors.h:150
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aCtrl, wxEvent &aEvent) const override
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
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
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
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
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...
EDA_DRAW_FRAME * m_frame
Definition pg_editors.h:64
PG_UNIT_EDITOR(EDA_DRAW_FRAME *aFrame)
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
wxString m_editorName
Definition pg_editors.h:68
bool OnEvent(wxPropertyGrid *aPropGrid, wxPGProperty *aProperty, wxWindow *aCtrl, wxEvent &aEvent) const override
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
virtual ~PG_UNIT_EDITOR()
static const wxString EDITOR_NAME
Definition pg_editors.h:158
PG_URL_EDITOR(EDA_DRAW_FRAME *aFrame)
virtual ~PG_URL_EDITOR()
Definition pg_editors.h:162
wxString m_editorName
Definition pg_editors.h:178
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
void UpdateFrame(EDA_DRAW_FRAME *aFrame)
EDA_DRAW_FRAME * m_frame
Definition pg_editors.h:177
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aCtrl, wxEvent &aEvent) const override
wxString GetName() const override
Definition pg_editors.h:164
Specialization for wxPropertyGrid, where we have no labels and units are displayed in the editor.