menu_controller.cpp
1.59 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
#include "menu_controller.h"
#include "../i18n.h"
#include <assert.h>
namespace Code {
MenuController::MenuController(Responder * parentResponder, Program * program) :
ViewController(parentResponder),
m_selectableTableView(this, this, 0, 1, Metric::CommonTopMargin, Metric::CommonRightMargin, Metric::CommonBottomMargin, Metric::CommonLeftMargin, this),
m_editorController(program),
m_executorController(program)
{
}
View * MenuController::view() {
return &m_selectableTableView;
}
void MenuController::didBecomeFirstResponder() {
m_selectableTableView.selectCellAtLocation(0, 0);
app()->setFirstResponder(&m_selectableTableView);
}
bool MenuController::handleEvent(Ion::Events::Event event) {
ViewController * vc[2] = {&m_editorController, &m_executorController};
if (event == Ion::Events::OK || event == Ion::Events::EXE) {
app()->displayModalViewController(vc[selectedRow()], 0.5f, 0.5f);
return true;
}
return false;
}
int MenuController::numberOfRows() {
return k_totalNumberOfCells;
};
HighlightCell * MenuController::reusableCell(int index) {
assert(index >= 0);
assert(index < k_totalNumberOfCells);
return &m_cells[index];
}
int MenuController::reusableCellCount() {
return k_totalNumberOfCells;
}
KDCoordinate MenuController::cellHeight() {
return Metric::ParameterCellHeight;
}
void MenuController::willDisplayCellForIndex(HighlightCell * cell, int index) {
MessageTableCell * myCell = (MessageTableCell *)cell;
I18n::Message titles[k_totalNumberOfCells] = {I18n::Message::EditProgram, I18n::Message::ExecuteProgram};
myCell->setMessage(titles[index]);
}
}