2022-11-03 02:50:49 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2022 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 3 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef KICAD_PG_EDITORS_H
|
|
|
|
#define KICAD_PG_EDITORS_H
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
|
|
|
|
#include <wx/propgrid/propgrid.h>
|
|
|
|
#include <wx/propgrid/editors.h>
|
|
|
|
|
|
|
|
class EDA_DRAW_FRAME;
|
|
|
|
class PROPERTY_EDITOR_UNIT_BINDER;
|
|
|
|
|
|
|
|
class PG_UNIT_EDITOR : public wxPGTextCtrlEditor
|
|
|
|
{
|
|
|
|
public:
|
2022-11-30 17:09:57 +00:00
|
|
|
static const wxString EDITOR_NAME;
|
|
|
|
|
2022-11-03 02:50:49 +00:00
|
|
|
PG_UNIT_EDITOR( EDA_DRAW_FRAME* aFrame );
|
|
|
|
|
|
|
|
virtual ~PG_UNIT_EDITOR();
|
|
|
|
|
2023-02-16 03:16:49 +00:00
|
|
|
wxString GetName() const override { return m_editorName; }
|
2022-11-03 02:50:49 +00:00
|
|
|
|
|
|
|
wxPGWindowList CreateControls( wxPropertyGrid* aPropGrid, wxPGProperty* aProperty,
|
|
|
|
const wxPoint& aPos, const wxSize& aSize ) const override;
|
|
|
|
|
|
|
|
bool GetValueFromControl( wxVariant& aVariant, wxPGProperty* aProperty,
|
|
|
|
wxWindow* aCtrl ) const override;
|
2022-11-29 16:31:00 +00:00
|
|
|
|
2022-12-03 00:37:44 +00:00
|
|
|
void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const override;
|
|
|
|
|
|
|
|
bool OnEvent( wxPropertyGrid* aPropGrid, wxPGProperty* aProperty, wxWindow* aCtrl,
|
|
|
|
wxEvent& aEvent ) const override;
|
|
|
|
|
2022-11-29 16:31:00 +00:00
|
|
|
/**
|
|
|
|
* When restarting an editor, the instance of PG_UNIT_EDITOR may be the same
|
|
|
|
* but the referenced frame is different. This re-binds the frame to the editor
|
|
|
|
* and associated controls
|
|
|
|
* @param aFrame New frame to bind
|
|
|
|
*/
|
|
|
|
void UpdateFrame( EDA_DRAW_FRAME* aFrame );
|
|
|
|
|
2023-02-16 03:16:49 +00:00
|
|
|
static wxString BuildEditorName( EDA_DRAW_FRAME* aFrame );
|
|
|
|
|
2022-11-03 02:50:49 +00:00
|
|
|
protected:
|
|
|
|
EDA_DRAW_FRAME* m_frame;
|
|
|
|
|
|
|
|
std::unique_ptr<PROPERTY_EDITOR_UNIT_BINDER> m_unitBinder;
|
2023-02-16 03:16:49 +00:00
|
|
|
|
|
|
|
wxString m_editorName;
|
2022-11-03 02:50:49 +00:00
|
|
|
};
|
|
|
|
|
2023-01-22 17:10:36 +00:00
|
|
|
|
|
|
|
class PG_CHECKBOX_EDITOR : public wxPGCheckBoxEditor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static const wxString EDITOR_NAME;
|
|
|
|
|
|
|
|
PG_CHECKBOX_EDITOR();
|
|
|
|
|
|
|
|
virtual ~PG_CHECKBOX_EDITOR() {}
|
|
|
|
|
|
|
|
wxString GetName() const override { return EDITOR_NAME; }
|
|
|
|
|
|
|
|
wxPGWindowList CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
|
|
|
|
const wxPoint& aPos, const wxSize& aSize ) const override;
|
|
|
|
};
|
|
|
|
|
2023-06-29 03:54:27 +00:00
|
|
|
|
|
|
|
class PG_COLOR_EDITOR : public wxPGEditor
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static const wxString EDITOR_NAME;
|
|
|
|
|
|
|
|
PG_COLOR_EDITOR() {}
|
|
|
|
|
|
|
|
virtual ~PG_COLOR_EDITOR() {}
|
|
|
|
|
|
|
|
wxString GetName() const override { return EDITOR_NAME; }
|
|
|
|
|
|
|
|
wxPGWindowList CreateControls( wxPropertyGrid* aGrid, wxPGProperty* aProperty,
|
|
|
|
const wxPoint& aPos, const wxSize& aSize ) const override;
|
|
|
|
|
2023-07-16 21:37:26 +00:00
|
|
|
void UpdateControl( wxPGProperty* aProperty, wxWindow* aCtrl ) const override;
|
2023-06-29 03:54:27 +00:00
|
|
|
|
|
|
|
bool OnEvent( wxPropertyGrid* aGrid, wxPGProperty* aProperty, wxWindow* aWindow,
|
2023-07-16 21:37:26 +00:00
|
|
|
wxEvent& aEvent ) const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
KIGFX::COLOR4D colorFromVariant( const wxVariant& aVariant ) const;
|
|
|
|
|
|
|
|
KIGFX::COLOR4D colorFromProperty( wxPGProperty* aProperty ) const;
|
2023-06-29 03:54:27 +00:00
|
|
|
};
|
|
|
|
|
2022-11-03 02:50:49 +00:00
|
|
|
#endif //KICAD_PG_EDITORS_H
|