|
KiCad PCB EDA Suite
|
wxTextCtrl wrapper to handle math expression evaluation. More...
#include <text_ctrl_eval.h>
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. | |
| wxString | GetFormula () const |
| Return the expression behind the displayed value, or the displayed text if there is none. | |
| bool | RestoreFormula (const wxString &aFormula) |
| Show the result of an expression returned by GetFormula() and retain the expression so that it reappears for editing when the control gains focus. | |
| void | DeferToBinder () |
| Leave evaluation to a UNIT_BINDER bound to this control. | |
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 |
| bool | m_deferToBinder |
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 38 of file text_ctrl_eval.h.
| 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 25 of file text_ctrl_eval.cpp.
References m_deferToBinder, m_eval, onTextEnter(), onTextFocusGet(), onTextFocusLost(), and UNSCALED.
Referenced by SetCustomEval().
|
inlinevirtual |
Definition at line 46 of file text_ctrl_eval.h.
|
inline |
Leave evaluation to a UNIT_BINDER bound to this control.
Definition at line 79 of file text_ctrl_eval.h.
References m_deferToBinder.
|
protected |
Definition at line 111 of file text_ctrl_eval.cpp.
References m_deferToBinder, and m_eval.
Referenced by onTextEnter(), and onTextFocusLost().
| wxString TEXT_CTRL_EVAL::GetFormula | ( | ) | const |
Return the expression behind the displayed value, or the displayed text if there is none.
Definition at line 45 of file text_ctrl_eval.cpp.
References m_eval.
|
protected |
Definition at line 101 of file text_ctrl_eval.cpp.
References evaluate().
Referenced by TEXT_CTRL_EVAL().
|
protected |
Definition at line 73 of file text_ctrl_eval.cpp.
References m_deferToBinder, m_eval, and SetValue().
Referenced by TEXT_CTRL_EVAL().
|
protected |
Definition at line 84 of file text_ctrl_eval.cpp.
References evaluate(), m_customEval, and m_deferToBinder.
Referenced by TEXT_CTRL_EVAL().
| bool TEXT_CTRL_EVAL::RestoreFormula | ( | const wxString & | aFormula | ) |
Show the result of an expression returned by GetFormula() and retain the expression so that it reappears for editing when the control gains focus.
Definition at line 56 of file text_ctrl_eval.cpp.
References m_deferToBinder, and m_eval.
|
inline |
Definition at line 50 of file text_ctrl_eval.h.
References m_customEval, and TEXT_CTRL_EVAL().
|
override |
Set a new value in evaluator buffer and display it in the wxTextCtrl.
| aValue | is the new value to store and display if aValue is empty, the value "0" is stored and displayed |
Definition at line 38 of file text_ctrl_eval.cpp.
References m_eval.
Referenced by onTextFocusGet(), and PANEL_PREVIEW_3D_MODEL::PANEL_PREVIEW_3D_MODEL().
|
private |
Definition at line 92 of file text_ctrl_eval.h.
Referenced by onTextFocusLost(), and SetCustomEval().
|
private |
Definition at line 93 of file text_ctrl_eval.h.
Referenced by DeferToBinder(), evaluate(), onTextFocusGet(), onTextFocusLost(), RestoreFormula(), and TEXT_CTRL_EVAL().
|
protected |
Numeric expression evaluator.
Definition at line 83 of file text_ctrl_eval.h.
Referenced by evaluate(), GetFormula(), onTextFocusGet(), RestoreFormula(), SetValue(), and TEXT_CTRL_EVAL().