Numworks Epsilon  1.4.1
Graphing Calculator Operating System
toolbox.h
Go to the documentation of this file.
1 #ifndef ESCHER_TOOLBOX_H
2 #define ESCHER_TOOLBOX_H
3 
11 
13 public:
14  Toolbox(Responder * parentResponder, const char * title = 0);
15  void setSender(Responder * sender);
16 
17  // StackViewController
18  bool handleEvent(Ion::Events::Event event) override;
19  void didBecomeFirstResponder() override;
20  void viewWillAppear() override;
21  void viewDidDisappear() override;
22 
23  //ListViewDataSource
24  virtual KDCoordinate rowHeight(int j) override;
25  int numberOfRows() override;
26  HighlightCell * reusableCell(int index, int type) override;
27  int reusableCellCount(int type) override;
28  void willDisplayCellForIndex(HighlightCell * cell, int index) override;
29  KDCoordinate cumulatedHeightFromIndex(int j) override;
30  int indexFromCumulatedHeight(KDCoordinate offsetY) override;
31  int typeAtLocation(int i, int j) override;
32 
33 protected:
34  class Stack {
35  public:
36  class State {
37  public:
39  bool isNull();
40  int selectedRow() { return m_selectedRow; }
41  KDCoordinate verticalScroll() { return m_verticalScroll; }
42  private:
43  int m_selectedRow;
44  KDCoordinate m_verticalScroll;
45  };
46  void push(int selectedRow, KDCoordinate verticalScroll);
47  void pop();
48  State * stateAtIndex(int index);
49  int depth();
50  void resetStack();
51  private:
52  constexpr static int k_maxModelTreeDepth = 3;
53  State m_statesStack[k_maxModelTreeDepth];
54  };
55 
56  class ListController : public ViewController {
57  public:
59  const char * title() override;
60  View * view() override;
61  void didBecomeFirstResponder() override;
62  void setFirstSelectedRow(int firstSelectedRow);
63  private:
64  SelectableTableView * m_selectableTableView;
65  int m_firstSelectedRow;
66  const char * m_title;
67  };
68 
69  static constexpr int LeafCellType = 0;
70  static constexpr int NodeCellType = 1;
71  int stackDepth();
73  bool selectSubMenu(ToolboxMessageTree * selectedMessageTree);
74  bool returnToPreviousMenu();
75  virtual Responder * sender();
76  virtual bool selectLeaf(ToolboxMessageTree * selectedMessageTree) = 0;
77  virtual const ToolboxMessageTree * rootModel() = 0;
78  virtual MessageTableCellWithMessage * leafCellAtIndex(int index) = 0;
79  virtual MessageTableCellWithChevron * nodeCellAtIndex(int index) = 0;
80  virtual int maxNumberOfDisplayedRows() = 0;
85  /* m_messageTreeModel points at the messageTree of the tree (describing the
86  * whole model) where we are located. It enables to know which rows are leaves
87  * and which are subtrees. */
88 
89 private:
90  Responder * m_sender;
91 };
92 
93 #endif
virtual MessageTableCellWithChevron * nodeCellAtIndex(int index)=0
virtual int maxNumberOfDisplayedRows()=0
bool handleEventForRow(Ion::Events::Event event, int selectedRow)
Definition: toolbox.cpp:191
ListController m_listController
Definition: toolbox.h:83
int numberOfRows() override
Definition: toolbox.cpp:128
int typeAtLocation(int i, int j) override
Definition: toolbox.cpp:179
SelectableTableView m_selectableTableView
Definition: toolbox.h:81
int16_t KDCoordinate
Definition: coordinate.h:6
void willDisplayCellForIndex(HighlightCell *cell, int index) override
Definition: toolbox.cpp:149
Responder * parentResponder() const
Definition: responder.cpp:12
int indexFromCumulatedHeight(KDCoordinate offsetY) override
Definition: toolbox.cpp:170
bool handleEvent(Ion::Events::Event event) override
Definition: toolbox.cpp:103
void didBecomeFirstResponder() override
Definition: toolbox.cpp:76
State(int selectedRow=-1, KDCoordinate verticalScroll=0)
Definition: toolbox.cpp:8
void resetStack()
Definition: toolbox.cpp:52
bool selectSubMenu(ToolboxMessageTree *selectedMessageTree)
Definition: toolbox.cpp:206
const char * title() override
void setFirstSelectedRow(int firstSelectedRow)
Definition: toolbox.cpp:82
int reusableCellCount(int type) override
Definition: toolbox.cpp:145
Toolbox(Responder *parentResponder, const char *title=0)
Definition: toolbox.cpp:88
Stack m_stack
Definition: toolbox.h:82
virtual bool selectLeaf(ToolboxMessageTree *selectedMessageTree)=0
virtual Responder * sender()
Definition: toolbox.cpp:238
KDCoordinate verticalScroll()
Definition: toolbox.h:41
bool returnToPreviousMenu()
Definition: toolbox.cpp:215
void didBecomeFirstResponder() override
Definition: toolbox.cpp:107
void viewWillAppear() override
Definition: toolbox.cpp:111
ToolboxMessageTree * m_messageTreeModel
Definition: toolbox.h:84
View * view() override
Definition: toolbox.cpp:72
void setSender(Responder *sender)
Definition: toolbox.cpp:99
KDCoordinate cumulatedHeightFromIndex(int j) override
Definition: toolbox.cpp:162
static constexpr int LeafCellType
Definition: toolbox.h:69
int stackDepth()
Definition: toolbox.cpp:187
const char * title() override
Definition: toolbox.cpp:68
virtual const ToolboxMessageTree * rootModel()=0
static constexpr int NodeCellType
Definition: toolbox.h:70
HighlightCell * reusableCell(int index, int type) override
Definition: toolbox.cpp:135
Definition: view.h:23
void push(int selectedRow, KDCoordinate verticalScroll)
Definition: toolbox.cpp:23
virtual KDCoordinate rowHeight(int j) override
Definition: toolbox.cpp:124
ListController(Responder *parentResponder, SelectableTableView *tableView, const char *title)
Definition: toolbox.cpp:60
virtual MessageTableCellWithMessage * leafCellAtIndex(int index)=0
void pop()
Definition: toolbox.cpp:44
void viewDidDisappear() override
Definition: toolbox.cpp:119
State * stateAtIndex(int index)
Definition: toolbox.cpp:32