Numworks Epsilon  1.4.1
Graphing Calculator Operating System
variable_box_controller.h
Go to the documentation of this file.
1 #ifndef CODE_VARIABLE_BOX_CONTROLLER_H
2 #define CODE_VARIABLE_BOX_CONTROLLER_H
3 
4 #include <escher.h>
5 #include "menu_controller.h"
6 #include "script_node.h"
7 #include "script_node_cell.h"
8 #include "script_store.h"
9 
10 namespace Code {
11 
13 public:
14  VariableBoxController(MenuController * menuController, ScriptStore * scriptStore);
15  void didBecomeFirstResponder() override;
16  void setTextInputCaller(TextInput * textInput);
17  void viewWillAppear() override;
18  void viewDidDisappear() override;
19 private:
20  class ContentViewController : public ViewController, public SimpleListViewDataSource, public SelectableTableViewDataSource {
21  public:
22  ContentViewController(Responder * parentResponder, MenuController * menuController, ScriptStore * scriptStore);
23  void setTextInputCaller(TextInput * textInput);
24  void reloadData();
25 
26  void addFunctionAtIndex(const char * functionName, int scriptIndex);
27  void addVariableAtIndex(const char * variableName, int scriptIndex);
28 
29  /* ViewController */
30  const char * title() override;
31  View * view() override { return &m_selectableTableView; }
32  void viewWillAppear() override;
33  void viewDidDisappear() override;
34 
35  /* Responder */
36  void didBecomeFirstResponder() override;
37  bool handleEvent(Ion::Events::Event event) override;
38 
39  /* SimpleListViewDataSource */
40  KDCoordinate cellHeight() override { return Metric::ToolboxRowHeight; }
41  int numberOfRows() override;
42  HighlightCell * reusableCell(int index) override;
43  int reusableCellCount() override;
44  void willDisplayCellForIndex(HighlightCell * cell, int index) override;
45  private:
46  constexpr static int k_maxNumberOfDisplayedRows = 6; //240/40
47  constexpr static int k_maxScriptNodesCount = 32;
48  void insertTextInCaller(const char * text);
49  int m_scriptNodesCount;
50  ScriptNode m_scriptNodes[k_maxScriptNodesCount];
51  MenuController * m_menuController;
52  ScriptStore * m_scriptStore;
53  TextInput * m_textInputCaller;
54  ScriptNodeCell m_leafCells[k_maxNumberOfDisplayedRows];
55  SelectableTableView m_selectableTableView;
56  };
57  ContentViewController m_contentViewController;
58 };
59 
60 }
61 #endif
int16_t KDCoordinate
Definition: coordinate.h:6
Responder * parentResponder() const
Definition: responder.cpp:12
const char * title() override
Definition: app.cpp:7
bool handleEvent(Ion::Events::Event event) override
Definition: view.h:23
static constexpr KDCoordinate ToolboxRowHeight
Definition: metric.h:27
VariableBoxController(MenuController *menuController, ScriptStore *scriptStore)
constexpr uint8_t numberOfRows
Definition: keyboard.h:35
void setTextInputCaller(TextInput *textInput)