Files
Upsilon/apps/shared/values_function_parameter_controller.cpp
Émilie Feral 7acac8cec7 [apps/shared] Move partial class values controller and function
parameter controller to shared to be used by sequences

Change-Id: I7908c184c757bb35856763bd339d3b34cf4ffe81
2017-03-03 09:38:53 +01:00

65 lines
1.8 KiB
C++

#include "values_function_parameter_controller.h"
#include <assert.h>
namespace Shared {
ValuesFunctionParameterController::ValuesFunctionParameterController(char symbol) :
ViewController(nullptr),
m_copyColumn(PointerTableCellWithChevron((char*)"Copier la colonne dans une liste")),
m_selectableTableView(SelectableTableView(this, this, Metric::CommonTopMargin, Metric::CommonRightMargin,
Metric::CommonBottomMargin, Metric::CommonLeftMargin)),
m_pageTitle{"Colonne f(x)"},
m_function(nullptr)
{
for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) {
if (m_pageTitle[currentChar] == '(') {
m_pageTitle[currentChar+1] = symbol;
return;
}
}
}
const char * ValuesFunctionParameterController::title() const {
return m_pageTitle;
}
View * ValuesFunctionParameterController::view() {
return &m_selectableTableView;
}
void ValuesFunctionParameterController::setFunction(Function * function) {
m_function = function;
for (int currentChar = 0; currentChar < k_maxNumberOfCharsInTitle; currentChar++) {
if (m_pageTitle[currentChar] == '(') {
m_pageTitle[currentChar-1] = *m_function->name();
return;
}
}
}
void ValuesFunctionParameterController::didBecomeFirstResponder() {
m_selectableTableView.reloadData();
m_selectableTableView.selectCellAtLocation(0, 0);
app()->setFirstResponder(&m_selectableTableView);
}
int ValuesFunctionParameterController::numberOfRows() {
return 1;
};
HighlightCell * ValuesFunctionParameterController::reusableCell(int index) {
assert(index == 0);
return &m_copyColumn;
}
int ValuesFunctionParameterController::reusableCellCount() {
return 1;
}
KDCoordinate ValuesFunctionParameterController::cellHeight() {
return Metric::ParameterCellHeight;
}
}