derivative_parameter_controller.cpp
2.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "derivative_parameter_controller.h"
#include "values_controller.h"
#include <assert.h>
namespace Graph {
DerivativeParameterController::DerivativeParameterController(ValuesController * valuesController) :
ViewController(valuesController),
m_hideColumn(I18n::Message::HideDerivativeColumn),
#if COPY_COLUMN
m_copyColumn(I18n::Message::CopyColumnInList),
#endif
m_selectableTableView(this),
m_function(nullptr),
m_valuesController(valuesController)
{
}
const char * DerivativeParameterController::title() {
strlcpy(m_pageTitle, I18n::translate(I18n::Message::DerivativeColumn), k_maxNumberOfCharsInTitle);
for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) {
if (m_pageTitle[currentChar] == '(') {
m_pageTitle[currentChar-2] = *m_function->name();
break;
}
}
return m_pageTitle;
}
View * DerivativeParameterController::view() {
return &m_selectableTableView;
}
void DerivativeParameterController::setFunction(CartesianFunction * function) {
m_function = function;
}
void DerivativeParameterController::didBecomeFirstResponder() {
selectCellAtLocation(0, 0);
app()->setFirstResponder(&m_selectableTableView);
}
bool DerivativeParameterController::handleEvent(Ion::Events::Event event) {
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
switch (selectedRow()) {
case 0:
{
m_valuesController->selectCellAtLocation(m_valuesController->selectedColumn()-1, m_valuesController->selectedRow());
m_function->setDisplayDerivative(false);
StackViewController * stack = (StackViewController *)(parentResponder());
stack->pop();
return true;
}
#if COPY_COLUMN
case 1:
/* TODO: implement function copy column */
return true;
#endif
default:
assert(false);
return false;
}
}
return false;
}
int DerivativeParameterController::numberOfRows() {
return k_totalNumberOfCell;
};
HighlightCell * DerivativeParameterController::reusableCell(int index) {
assert(index >= 0);
assert(index < k_totalNumberOfCell);
#if COPY_COLUMN
HighlightCell * cells[] = {&m_hideColumn, &m_copyColumn};
#else
HighlightCell * cells[] = {&m_hideColumn};
#endif
return cells[index];
}
int DerivativeParameterController::reusableCellCount() {
return k_totalNumberOfCell;
}
KDCoordinate DerivativeParameterController::cellHeight() {
return Metric::ParameterCellHeight;
}
}