#include <panel.h>
|
|
static const std::string | name = "equation" |
| | Name of this panel.
|
| |
|
| static MiloPanelPtr | makePanel (const std::string &name, const std::string &init) |
| |
|
static std::unordered_map< std::string, panel_factory > | panel_map |
| | Map of name to panel create functions.
|
| |
Panel class for Equation class.
Function pointer to handle key event. Pointer to event passed as argument. Return true, if event changed equation.
Function pointer to handle mouse event. Return true, if event changed equation.
Function pointer to handle mouse event. Pointer to event passed as argument. Return true, if event changed equation.
| UI::EqnPanel::EqnPanel |
( |
| ) |
|
|
inline |
| UI::EqnPanel::EqnPanel |
( |
std::istream & |
is | ) |
|
|
inline |
| UI::EqnPanel::EqnPanel |
( |
const std::string & |
eq | ) |
|
|
inline |
Check where there is an active input in this equation object.
- Returns
- If true, there is an active input.
Implements UI::MiloPanel.
| bool EqnPanel::do_alphaNumber |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle letter or number key event. Insert letter or number key into equation if there is a current input or selection.
- Parameters
-
- Returns
- True if key event is processed.
| bool EqnPanel::do_backspace |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle backspace key event. Erase selection if it exists, or previous factor before current input.
- Parameters
-
- Returns
- True if backspace is processed.
| bool EqnPanel::do_divide |
( |
const KeyEvent & |
event | ) |
|
|
private |
Insert divide term.
- Parameters
-
- Returns
- True if successful.
| bool EqnPanel::do_down |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle down arrow key event. Transverse the entire equation tree to the right of the selection or the current input. Select last node if there is no selection or input.
- Parameters
-
- Returns
- Always true.
| bool EqnPanel::do_enter |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle enter key event. Either disable current input or replace current selection with a new input.
- Parameters
-
- Returns
- True if enter is proccessed.
| bool EqnPanel::do_init |
( |
| ) |
|
|
staticprivate |
Static initialization for class.
| bool EqnPanel::do_left |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle left arrow key event. Move to node to the left of selection or current input.
- Parameters
-
- Returns
- True if left arrow proccessed.
| bool EqnPanel::do_left_parenthesis |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle left parenthesis key event. Add "(*)". Side effect will be to add any functions that matches or an expression as a new factor.
- Parameters
-
- Returns
- True if successful.
| bool EqnPanel::do_mouse_clicked |
( |
const MouseEvent & |
mouse | ) |
|
|
private |
Handle mouse click. If mouse clicks on node select it or activate input.
- Parameters
-
- Returns
- True if node selected.
| bool EqnPanel::do_mouse_double |
( |
const MouseEvent & |
mouse | ) |
|
|
private |
Handle mouse double click. If no node found, return false. Otherwise activate if input selected or add input before selected node.
- Parameters
-
- Returns
- True, if node found.
| bool EqnPanel::do_mouse_position |
( |
const MouseEvent & |
mouse | ) |
|
|
private |
Handle mouse position reports, Update part of equation selected by mouse dragging.
- Parameters
-
- Returns
- Always false.
| bool EqnPanel::do_mouse_pressed |
( |
const MouseEvent & |
mouse | ) |
|
|
private |
Handle mouse press event. If node has been selected, remember it and mouse coordinates.
- Parameters
-
- Returns
- Always false.
| bool EqnPanel::do_mouse_released |
( |
const MouseEvent & |
mouse | ) |
|
|
private |
Handle mouse release event. If mouse released where it was pressed, select node. Otherwise, end mouse dragging state.
- Parameters
-
- Returns
- Always true.
| bool EqnPanel::do_plus_minus |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle +/- key event. Add a new term with a new input. New term is positive or negative depending on whether character is +/-.
- Parameters
-
- Returns
- True if input is active.
| bool EqnPanel::do_power |
( |
const KeyEvent & |
event | ) |
|
|
private |
Insert power factor.
- Parameters
-
- Returns
- True if successfull.
| bool EqnPanel::do_right |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle right arrow key event. Move to node to the right of selection or current input.
- Parameters
-
- Returns
- True if right arrow proccessed.
| bool EqnPanel::do_shift_down |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle down arrow with shift key event. Select the expression to the right of the current input or add it to the existing selection.
- Parameters
-
- Returns
- True if down arrow with shift is processed.
| bool EqnPanel::do_shift_left |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle left arrow with shift key event. Either add factor on the left to selection or select factor to left of cursor.
- Parameters
-
- Returns
- True if shift left arrow is processed.
| bool EqnPanel::do_shift_right |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle right arrow with shift key event. Either add factor on the right to selection or select factor to right of cursor.
- Parameters
-
- Returns
- True if shift right arrow is processed.
| bool EqnPanel::do_shift_up |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle up arrow with shift key event. Select the expression to the left of the current input or add it to the existing selection.
- Parameters
-
- Returns
- True if up arrow with shift is processed.
| bool EqnPanel::do_space |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle space key event. Either select factor at input or select one level higher.
- Parameters
-
- Returns
- True if successful.
| bool EqnPanel::do_tab |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle tab key event. Move to next input. If shift down move to previous input.
- Parameters
-
- Returns
- Always true
| bool EqnPanel::do_up |
( |
const KeyEvent & |
event | ) |
|
|
private |
Handle up arrow key event. Transverse the entire equation tree to the left of the selection or the current input. Select first node if there is no selection or input.
- Parameters
-
- Returns
- Always true.
| void EqnPanel::doDraw |
( |
| ) |
|
|
virtual |
| void EqnPanel::doKey |
( |
const KeyEvent & |
key | ) |
|
|
virtual |
| bool EqnPanel::doMenu |
( |
const std::string & |
menuFunctionName | ) |
|
|
virtual |
Execute panel specific function based on its name. Used for menu handling.
- Parameters
-
| menuFunctionName | Name of menu function to be executed. |
- Returns
- True if menuFunctionName found.
Implements UI::MiloPanel.
| void EqnPanel::doMouse |
( |
const MouseEvent & |
mouse | ) |
|
|
virtual |
Static function to emit a key event to a panel.
- Parameters
-
| panel | EqnPanel to handle key event. |
| key | Key event. |
- Returns
- True if key event was handled.
| void EqnPanel::getCursorOrig |
( |
int & |
x, |
|
|
int & |
y |
|
) |
| |
|
virtual |
Get coordinates of current active input.
- Parameters
-
| [out] | x | Horizontal origin of curosr. |
| [out] | y | Vertical origin cursor. |
Implements UI::MiloPanel.
Get reference to current equation.
- Returns
- Reference to current equation.
| void EqnPanel::loadState |
( |
std::istream & |
is | ) |
|
|
virtual |
| Equation& UI::EqnPanel::newEqn |
( |
std::string |
eq | ) |
|
|
inline |
New equation from string such as 'a+b/c'
- Parameters
-
| eq | String containing equation to be created. |
- Returns
- Refrence to new equation
| Equation& UI::EqnPanel::newEqn |
( |
std::istream & |
is | ) |
|
|
inline |
New equation from xml stream.
- Parameters
-
| is | Input stream containing xml. |
- Returns
- Refrence to new equation
| void EqnPanel::popUndo |
( |
| ) |
|
|
virtual |
Restore state of panel on top of undo stack.
Implements UI::MiloPanel.
| void EqnPanel::pushUndo |
( |
| ) |
|
|
virtual |
| void EqnPanel::saveState |
( |
std::ostream & |
fs | ) |
|
|
virtual |
| void UI::EqnPanel::set_refresh |
( |
bool |
refresh | ) |
|
|
inline |
Set drawing refresh state for panel
- Parameters
-
| refresh | If true, refresh on every draw |
Map of events to functions that handle key events.
Initial value:= {
{ string(
"simplify"), [](
EqnPanel& p) {
return p.getEqn().simplify(); } },
{ string(
"normalize"), [](
EqnPanel& p) { p.getEqn().normalize();
return true; } },
}
Map of names to functions that handle menu calls.
Initial value:= {
{ MouseEvent(Mouse::RELEASED, 1), [](
EqnPanel& p,
const MouseEvent& m) {
return p.do_mouse_released(m); } },
{ MouseEvent(Mouse::PRESSED, 1), [](
EqnPanel& p,
const MouseEvent& m) {
return p.do_mouse_pressed(m); } },
{ MouseEvent(Mouse::CLICKED, 1), [](
EqnPanel& p,
const MouseEvent& m) {
return p.do_mouse_clicked(m); } },
{ MouseEvent(Mouse::DOUBLE, 1), [](
EqnPanel& p,
const MouseEvent& m) {
return p.do_mouse_double(m); } },
{ MouseEvent(Mouse::POSITION, 0), [](
EqnPanel& p,
const MouseEvent& m) {
return p.do_mouse_position(m); } }
}
Map of events to functions that handle mouse events.
The documentation for this class was generated from the following files: