[apps/shared] Move partial class values controller and function

parameter controller to shared to be used by sequences

Change-Id: I7908c184c757bb35856763bd339d3b34cf4ffe81
This commit is contained in:
Émilie Feral
2017-02-24 16:05:45 +01:00
parent c51d7cda01
commit 7acac8cec7
9 changed files with 504 additions and 354 deletions

View File

@@ -0,0 +1,64 @@
#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;
}
}