KiCad PCB EDA Suite
Loading...
Searching...
No Matches
TEXT_CTRL_EVAL Class Reference

wxTextCtrl wrapper to handle math expression evaluation. More...

#include <text_ctrl_eval.h>

Inheritance diagram for TEXT_CTRL_EVAL:

Public Member Functions

 TEXT_CTRL_EVAL (wxWindow *aParent, wxWindowID aId, const wxString &aValue=wxEmptyString, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=0, const wxValidator &aValidator=wxDefaultValidator, const wxString &aName=wxTextCtrlNameStr)
 
virtual ~TEXT_CTRL_EVAL ()
 
void SetCustomEval (std::function< void(TEXT_CTRL_EVAL *aCtrl)> aCustomEval)
 
void SetValue (const wxString &aValue) override
 Set a new value in evaluator buffer and display it in the wxTextCtrl.
 

Protected Member Functions

void onTextFocusGet (wxFocusEvent &aEvent)
 
void onTextFocusLost (wxFocusEvent &aEvent)
 
void onTextEnter (wxCommandEvent &aEvent)
 
void evaluate ()
 

Protected Attributes

NUMERIC_EVALUATOR m_eval
 Numeric expression evaluator.
 

Private Attributes

std::optional< std::function< void(TEXT_CTRL_EVAL *aCtrl)> > m_customEval
 

Detailed Description

wxTextCtrl wrapper to handle math expression evaluation.

Expressions are evaluated after the text control loses the focus. If user decides to modify the expression, he will get the original expression to modify.

Definition at line 41 of file text_ctrl_eval.h.

Constructor & Destructor Documentation

◆ TEXT_CTRL_EVAL()

TEXT_CTRL_EVAL::TEXT_CTRL_EVAL ( wxWindow * aParent,
wxWindowID aId,
const wxString & aValue = wxEmptyString,
const wxPoint & aPos = wxDefaultPosition,
const wxSize & aSize = wxDefaultSize,
long aStyle = 0,
const wxValidator & aValidator = wxDefaultValidator,
const wxString & aName = wxTextCtrlNameStr )

Definition at line 29 of file text_ctrl_eval.cpp.

References m_eval, onTextEnter(), onTextFocusGet(), onTextFocusLost(), and UNSCALED.

Referenced by SetCustomEval().

◆ ~TEXT_CTRL_EVAL()

virtual TEXT_CTRL_EVAL::~TEXT_CTRL_EVAL ( )
inlinevirtual

Definition at line 49 of file text_ctrl_eval.h.

Member Function Documentation

◆ evaluate()

void TEXT_CTRL_EVAL::evaluate ( )
protected

Definition at line 80 of file text_ctrl_eval.cpp.

References m_eval, and SetValue().

Referenced by onTextEnter(), and onTextFocusLost().

◆ onTextEnter()

void TEXT_CTRL_EVAL::onTextEnter ( wxCommandEvent & aEvent)
protected

Definition at line 70 of file text_ctrl_eval.cpp.

References evaluate().

Referenced by TEXT_CTRL_EVAL().

◆ onTextFocusGet()

void TEXT_CTRL_EVAL::onTextFocusGet ( wxFocusEvent & aEvent)
protected

Definition at line 48 of file text_ctrl_eval.cpp.

References m_eval, and SetValue().

Referenced by TEXT_CTRL_EVAL().

◆ onTextFocusLost()

void TEXT_CTRL_EVAL::onTextFocusLost ( wxFocusEvent & aEvent)
protected

Definition at line 59 of file text_ctrl_eval.cpp.

References evaluate(), and m_customEval.

Referenced by TEXT_CTRL_EVAL().

◆ SetCustomEval()

void TEXT_CTRL_EVAL::SetCustomEval ( std::function< void(TEXT_CTRL_EVAL *aCtrl)> aCustomEval)
inline

Definition at line 53 of file text_ctrl_eval.h.

References m_customEval, and TEXT_CTRL_EVAL().

◆ SetValue()

void TEXT_CTRL_EVAL::SetValue ( const wxString & aValue)
override

Set a new value in evaluator buffer and display it in the wxTextCtrl.

Parameters
aValueis the new value to store and display if aValue is empty, the value "0" is stored and displayed

Definition at line 41 of file text_ctrl_eval.cpp.

References m_eval.

Referenced by evaluate(), onTextFocusGet(), and PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL().

Member Data Documentation

◆ m_customEval

std::optional<std::function<void( TEXT_CTRL_EVAL* aCtrl )> > TEXT_CTRL_EVAL::m_customEval
private

Definition at line 77 of file text_ctrl_eval.h.

Referenced by onTextFocusLost(), and SetCustomEval().

◆ m_eval

NUMERIC_EVALUATOR TEXT_CTRL_EVAL::m_eval
protected

Numeric expression evaluator.

Definition at line 68 of file text_ctrl_eval.h.

Referenced by evaluate(), onTextFocusGet(), SetValue(), and TEXT_CTRL_EVAL().


The documentation for this class was generated from the following files: