forked from boricj/numworks-rpn
-
Notifications
You must be signed in to change notification settings - Fork 7
/
rpn_stack_controller.h
59 lines (44 loc) · 1.85 KB
/
rpn_stack_controller.h
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
#ifndef RPN_STACK_CONTROLLER_H
#define RPN_STACK_CONTROLLER_H
#include <escher.h>
#include "rpn_stack.h"
namespace Rpn {
class ContentView;
class InputController;
class StackController : public ViewController, public ListViewDataSource, public SelectableTableViewDataSource {
public:
StackController(Responder * parentResponder, Stack * stack, InputController * inputController, ContentView * view, Poincare::Context *context);
View * view() override;
void didBecomeFirstResponder() override;
bool handleEvent(Ion::Events::Event event) override;
int numberOfRows() const override { return m_stack->length(); }
KDCoordinate rowHeight(int i) override;
HighlightCell * reusableCell(int index, int type) override { return &m_cells[index]; }
int reusableCellCount(int type) { return Stack::k_stackSize; };
virtual int typeAtLocation(int i, int j) { return 0; }
void willDisplayCellForIndex(HighlightCell * cell, int index) override;
const char* operator[](size_t idx) const { return (*m_stack)[idx]; }
Stack& stack() { return *m_stack; }
void erase(bool upTo);
bool approximate() { return m_stack->approximate; }
void setApproximate(bool approx) { m_stack->approximate = approx; }
void reloadAndScroll(int index = -1);
bool empty() { return m_stack->empty(); }
I18n::Message operator()(const char* text);
I18n::Message operator()(Stack::StackOperation op);
I18n::Message operator()(Stack::SpecialOperation op);
I18n::Message operator()(Poincare::ExpressionNode::Type op);
I18n::Message operator()(I18n::Message op);
SelectableTableView* stackView();
constexpr static int k_padding = 4;
private:
bool isFull();
Poincare::Layout createLayout(int index);
Stack * m_stack;
InputController * m_inputController;
ContentView * m_view;
Poincare::Context * m_context;
EvenOddExpressionCell m_cells[Stack::k_stackSize];
};
}
#endif