74 const wxPoint& aPos,
const wxSize& aSize )
const
78 wxString
text = aProperty->GetValueAsString( wxPG_EDITABLE_VALUE );
79 wxWindow* win = aPropGrid->GenerateEditorTextCtrl( aPos, aSize,
text,
nullptr, 0,
80 aProperty->GetMaxLength() );
81 wxPGWindowList ret( win,
nullptr );
105 wxVariant var = aProperty->GetValue();
107 if( var.GetType() == wxPG_VARIANT_TYPE_LONG )
111 else if( var.GetType() == wxPG_VARIANT_TYPE_DOUBLE )
115 else if( var.GetType() == wxT(
"EDA_ANGLE" ) )
120 else if( !aProperty->IsValueUnspecified() )
122 wxFAIL_MSG( wxT(
"PG_UNIT_EDITOR should only be used with numeric properties!" ) );
128 wxWindow* aCtrl, wxEvent& aEvent )
const
130 if( aEvent.GetEventType() == wxEVT_LEFT_UP )
132 if( wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl ) )
134 if( !textCtrl->HasFocus() )
136 textCtrl->SelectAll();
142 return wxPGTextCtrlEditor::OnEvent( aPropGrid, aProperty, aCtrl, aEvent );
147 wxWindow* aCtrl )
const
152 wxTextCtrl* textCtrl =
dynamic_cast<wxTextCtrl*
>( aCtrl );
153 wxCHECK_MSG( textCtrl,
false,
"PG_UNIT_EDITOR requires a text control!" );
154 wxString textVal = textCtrl->GetValue();
156 if( aProperty->UsesAutoUnspecified() && textVal.empty() )
167 if( aVariant.GetType() == wxT(
"EDA_ANGLE" ) )
170 changed = ( aVariant.IsNull() || angle != ad->
Angle() );
180 changed = ( aVariant.IsNull() || angle.
AsDegrees() != aVariant.GetDouble() );
192 changed = ( aVariant.IsNull() || result != aVariant.GetLong() );
203 if( !changed && aVariant.IsNull() )
217 const wxPoint& aPos,
const wxSize& aSize )
const
222 if( aProperty->IsValueUnspecified() )
223 aProperty->SetValueFromInt( 0 );
225 return wxPGCheckBoxEditor::CreateControls( aGrid, aProperty, aPos, aSize );
230 wxEvent& aEvent )
const
237 const wxPoint& aPos,
const wxSize& aSize )
const
248 colorProp->GetBackgroundColor(), defColor,
250 editor->SetPosition( aPos );
253 editor->Bind( COLOR_SWATCH_CHANGED,
254 [=]( wxCommandEvent& aEvt )
259 aGrid->ChangePropertyValue( colorProp, val );
262#if wxCHECK_VERSION( 3, 3, 0 )
263 if( aGrid->GetInternalFlags() & wxPropertyGrid::wxPG_FL_ACTIVATION_BY_CLICK )
265 if( aGrid->GetInternalFlags() & wxPG_FL_ACTIVATION_BY_CLICK )
271 editor->GetNewSwatchColor();
281 if(
auto swatch =
dynamic_cast<COLOR_SWATCH*
>( aCtrl ) )
291 if( aVariant.IsType( wxS(
"COLOR4D" ) ) )
const KIGFX::COLOR4D & Color()
A simple color swatch of the kind used to set layer colors.
const EDA_ANGLE & Angle()
void SetAngle(const EDA_ANGLE &aAngle)
The base class for create windows for drawing purpose.
A color representation with 4 components: red, green, blue, alpha.
static const COLOR4D UNSPECIFIED
For legacy support; used as a value to indicate color hasn't been set yet.
A wxEnumProperty that displays a color next to the enum value.
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
static const wxString EDITOR_NAME
static const wxString EDITOR_NAME
wxPGWindowList CreateControls(wxPropertyGrid *aGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
bool OnEvent(wxPropertyGrid *aGrid, wxPGProperty *aProperty, wxWindow *aWindow, wxEvent &aEvent) const override
KIGFX::COLOR4D colorFromVariant(const wxVariant &aVariant) const
void UpdateControl(wxPGProperty *aProperty, wxWindow *aCtrl) const override
KIGFX::COLOR4D colorFromProperty(wxPGProperty *aProperty) const
std::unique_ptr< PROPERTY_EDITOR_UNIT_BINDER > m_unitBinder
wxPGWindowList CreateControls(wxPropertyGrid *aPropGrid, wxPGProperty *aProperty, const wxPoint &aPos, const wxSize &aSize) const override
static const wxString EDITOR_NAME
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...
PG_UNIT_EDITOR(EDA_DRAW_FRAME *aFrame)
bool GetValueFromControl(wxVariant &aVariant, wxPGProperty *aProperty, wxWindow *aCtrl) const override
bool OnEvent(wxPropertyGrid *aPropGrid, wxPGProperty *aProperty, wxWindow *aCtrl, wxEvent &aEvent) const override
static wxString BuildEditorName(EDA_DRAW_FRAME *aFrame)
virtual ~PG_UNIT_EDITOR()
EDA_UNITS GetUserUnits() const