Numworks Epsilon  1.4.1
Graphing Calculator Operating System
store_controller.cpp
Go to the documentation of this file.
1 #include "store_controller.h"
2 #include "../apps_container.h"
3 #include "../constant.h"
4 #include <assert.h>
5 
6 using namespace Poincare;
7 
8 namespace Shared {
9 
10 StoreController::StoreController(Responder * parentResponder, FloatPairStore * store, ButtonRowController * header) :
11  EditableCellTableViewController(parentResponder),
12  ButtonRowDelegate(header, nullptr),
13  m_editableCells{},
14  m_store(store),
15  m_storeParameterController(this, store)
16 {
17 }
18 
19 const char * StoreController::title() {
20  return I18n::translate(I18n::Message::DataTab);
21 }
22 
24  return 2;
25 };
26 
28  return k_cellWidth;
29 }
30 
32  return i*k_cellWidth;
33 }
34 
36  return (offsetX-1) / k_cellWidth;
37 }
38 
40  assert(index >= 0);
41  switch (type) {
42  case 0:
44  return titleCells(index);
45  case 1:
47  return m_editableCells[index];
48  default:
49  assert(false);
50  return nullptr;
51  }
52 }
53 
55  if (type == 0) {
56  return k_numberOfTitleCells;
57  }
59 }
60 
62  return j!=0;
63 }
64 
66  willDisplayCellAtLocationWithDisplayMode(cell, i, j, PrintFloat::Mode::Decimal);
67 }
68 
70  if (selectedRow() < 0) {
72  }
74 }
75 
77  if (event == Ion::Events::Up) {
79  assert(selectedRow() == -1);
81  return true;
82  }
83  if ((event == Ion::Events::OK || event == Ion::Events::EXE) && selectedRow() == 0) {
87  return true;
88  }
89  if (event == Ion::Events::Backspace) {
90  if (selectedRow() == 0 || selectedRow() == numberOfRows()-1) {
91  return false;
92  }
95  return true;
96  }
97  return false;
98 }
99 
102 }
103 
104 bool StoreController::cellAtLocationIsEditable(int columnIndex, int rowIndex) {
105  if (rowIndex > 0) {
106  return true;
107  }
108  return false;
109 }
110 
111 bool StoreController::setDataAtLocation(double floatBody, int columnIndex, int rowIndex) {
112  m_store->set(floatBody, columnIndex, rowIndex-1);
113  return true;
114 }
115 
116 double StoreController::dataAtLocation(int columnIndex, int rowIndex) {
117  return m_store->get(columnIndex, rowIndex-1);
118 }
119 
121  return m_store->numberOfPairs();
122 }
123 
126 }
127 
130  for (int i = 0; i < k_maxNumberOfEditableCells; i++) {
131  m_editableCells[i] = new EvenOddEditableTextCell(tableView, this, m_draftTextBuffer);
132  }
133  return tableView;
134 }
135 
137  for (int i = 0; i < k_maxNumberOfEditableCells; i++) {
138  delete m_editableCells[i];
139  m_editableCells[i] = nullptr;
140  }
142 }
143 
144 }
const char * title() override
static constexpr int k_maxNumberOfEditableCells
int numberOfColumns() override
void willDisplayCellAtLocationWithDisplayMode(HighlightCell *cell, int i, int j, Poincare::PrintFloat::Mode mode)
#define assert(e)
Definition: assert.h:9
void set(double f, int i, int j)
constexpr Event EXE
Definition: events.h:114
int16_t KDCoordinate
Definition: coordinate.h:6
void push(ViewController *vc, KDColor textColor=Palette::SubTab, KDColor backgroundColor=KDColorWhite, KDColor separatorColor=Palette::GreyBright)
Responder * parentResponder() const
Definition: responder.cpp:12
static constexpr KDCoordinate k_cellWidth
constexpr Event Up
Definition: events.h:62
int reusableCellCount(int type) override
static constexpr int k_maxNumberOfPairs
FloatPairStore * m_store
void willDisplayCellAtLocation(HighlightCell *cell, int i, int j) override
void reloadData(bool setFirstResponder=true)
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override
enum Message uint16_t enum Language uint16_t const char * translate(Message m, Language l=(Language) 0)
Definition: i18n.cpp:5
Responder * tabController() const override
int maxNumberOfElements() const override
void unloadView(View *view) override
bool handleEvent(Ion::Events::Event event) override
void unloadView(View *view) override
KDCoordinate columnWidth(int i) override
View * loadView() override
StoreParameterController m_storeParameterController
double get(int i, int j)
virtual View * loadView() override
int typeAtLocation(int i, int j) override
HighlightCell * reusableCell(int index, int type) override
virtual HighlightCell * titleCells(int index)=0
char m_draftTextBuffer[TextField::maxBufferSize()]
void setFirstResponder(Responder *responder)
Definition: app.cpp:62
Definition: view.h:23
double dataAtLocation(int columnIndex, int rowIndex) override
EvenOddEditableTextCell * m_editableCells[k_maxNumberOfEditableCells]
App * app()
Definition: responder.cpp:77
constexpr Event OK
Definition: events.h:65
static constexpr int k_numberOfTitleCells
SelectableTableView * selectableTableView()
int indexFromCumulatedWidth(KDCoordinate offsetX) override
KDCoordinate cumulatedWidthFromIndex(int i) override
void didBecomeFirstResponder() override
bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override
constexpr Event Backspace
Definition: events.h:76