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 "app.h"
3 #include "../apps_container.h"
4 #include "../constant.h"
5 #include <assert.h>
6 #include <float.h>
7 #include <cmath>
8 
9 using namespace Shared;
10 
11 namespace Statistics {
12 
14  Shared::StoreController(parentResponder, store, header),
15  m_titleCells{}
16 {
17 }
18 
20  ::StoreController::willDisplayCellAtLocation(cell, i, j);
21  if (cellAtLocationIsEditable(i, j)) {
22  return;
23  }
24  EvenOddMessageTextCell * mytitleCell = (EvenOddMessageTextCell *)cell;
25  if (i == 0) {
26  mytitleCell->setMessage(I18n::Message::Values);
27  return;
28  }
29  mytitleCell->setMessage(I18n::Message::Sizes);
30 }
31 
32 HighlightCell * StoreController::titleCells(int index) {
33  assert(index >= 0 && index < k_numberOfTitleCells);
34  return m_titleCells[index];
35 }
36 
37 bool StoreController::setDataAtLocation(double floatBody, int columnIndex, int rowIndex) {
38  if (std::fabs(floatBody) > FLT_MAX) {
39  return false;
40  }
41  if (columnIndex == 1) {
42  if (floatBody < 0) {
43  return false;
44  }
45  m_store->set(std::round(floatBody), columnIndex, rowIndex-1);
46  return true;
47  }
48  return Shared::StoreController::setDataAtLocation(floatBody, columnIndex, rowIndex);
49 }
50 
51 View * StoreController::loadView() {
52  for (int i = 0; i < k_numberOfTitleCells; i++) {
53  m_titleCells[i] = new EvenOddMessageTextCell(KDText::FontSize::Small);
54  }
56 }
57 
58 void StoreController::unloadView(View * view) {
59  for (int i = 0; i < k_numberOfTitleCells; i++) {
60  delete m_titleCells[i];
61  m_titleCells[i] = nullptr;
62  }
64 }
65 
66 }
#define assert(e)
Definition: assert.h:9
void set(double f, int i, int j)
#define fabs(x)
Definition: math.h:178
FloatPairStore * m_store
bool setDataAtLocation(double floatBody, int columnIndex, int rowIndex) override
#define FLT_MAX
Definition: float.h:6
void unloadView(View *view) override
#define round(x)
Definition: math.h:192
View * loadView() override
StoreController(Responder *parentResponder, FloatPairStore *store, ButtonRowController *header)
void setMessage(I18n::Message textContent, KDColor textColor=KDColorBlack)
Definition: view.h:23
static constexpr int k_numberOfTitleCells
bool cellAtLocationIsEditable(int columnIndex, int rowIndex) override
void willDisplayCellAtLocation(HighlightCell *cell, int i, int j) override