Numworks Epsilon  1.4.1
Graphing Calculator Operating System
calculation_type_controller.cpp
Go to the documentation of this file.
2 #include <assert.h>
3 #include "app.h"
4 #include "images/calcul1_icon.h"
5 #include "images/calcul2_icon.h"
6 #include "images/calcul3_icon.h"
7 #include "images/calcul4_icon.h"
8 #include "images/focused_calcul1_icon.h"
9 #include "images/focused_calcul2_icon.h"
10 #include "images/focused_calcul3_icon.h"
11 #include "images/focused_calcul4_icon.h"
12 
13 namespace Probability {
14 
15 CalculationTypeController::CalculationTypeController(Responder * parentResponder, Law * law, Calculation * calculation, CalculationController * calculationController) :
16  ViewController(parentResponder),
17  m_selectableTableView(this),
18  m_law(law),
19  m_calculation(calculation),
20  m_calculationController(calculationController)
21 {
22  assert(m_calculation != nullptr);
23  m_selectableTableView.setMargins(0);
24  m_selectableTableView.setVerticalCellOverlap(0);
25  m_selectableTableView.setShowsIndicators(false);
26  m_selectableTableView.setColorsBackground(false);
27 }
28 
30  return &m_selectableTableView;
31 }
32 
34  selectCellAtLocation(0, (int)m_calculation->type());
35 }
36 
37 
39  m_selectableTableView.deselectTable();
40 }
41 
43  app()->setFirstResponder(&m_selectableTableView);
44 }
45 
47  if (event == Ion::Events::OK || event == Ion::Events::EXE) {
48  m_calculationController->setCalculationAccordingToIndex(selectedRow());
49  m_calculationController->reload();
51  return true;
52  }
53  if (event == Ion::Events::Back || event == Ion::Events::Right) {
54  if (event == Ion::Events::Right) {
55  m_calculationController->selectCellAtLocation(1,0);
56  }
58  return true;
59  }
60  return false;
61 }
62 
64  if (m_law->isContinuous()) {
65  return k_numberOfImages-1;
66  }
67  return k_numberOfImages;
68 }
69 
71  return ImageCell::k_width;
72 }
73 
75  return ImageCell::k_height;
76 }
77 
79  assert(index >= 0);
80  assert(index < k_numberOfImages);
81  return &m_imageCells[index];
82 }
83 
85  return k_numberOfImages;
86 }
87 
89  ImageCell * myCell = (ImageCell *)cell;
90  const Image * images[k_numberOfImages] = {ImageStore::Calcul1Icon, ImageStore::Calcul2Icon, ImageStore::Calcul3Icon, ImageStore::Calcul4Icon};
91  const Image * focusedImages[k_numberOfImages] = {ImageStore::FocusedCalcul1Icon, ImageStore::FocusedCalcul2Icon, ImageStore::FocusedCalcul3Icon, ImageStore::FocusedCalcul4Icon};
92  myCell->setImage(images[index], focusedImages[index]);
93 }
94 
95 }
virtual bool isContinuous() const =0
void setShowsIndicators(bool s)
Definition: scroll_view.h:28
#define assert(e)
Definition: assert.h:9
static constexpr KDCoordinate k_height
Definition: image_cell.h:14
constexpr Event EXE
Definition: events.h:114
int16_t KDCoordinate
Definition: coordinate.h:6
void setVerticalCellOverlap(KDCoordinate o)
Definition: table_view.h:14
HighlightCell * reusableCell(int index) override
bool handleEvent(Ion::Events::Event event) override
Definition: image.h:6
constexpr Event Back
Definition: events.h:66
void setCalculationAccordingToIndex(int index, bool forceReinitialisation=false)
void willDisplayCellForIndex(HighlightCell *cell, int index) override
CalculationTypeController(Responder *parentResponder, Law *law, Calculation *calculation, CalculationController *calculationController)
static constexpr KDCoordinate k_width
Definition: image_cell.h:13
void setColorsBackground(bool c)
Definition: scroll_view.h:30
void setImage(const Image *image, const Image *focusedImage)
Definition: image_cell.cpp:22
void setMargins(KDCoordinate top, KDCoordinate right, KDCoordinate bottom, KDCoordinate left)
Definition: scroll_view.h:22
void setFirstResponder(Responder *responder)
Definition: app.cpp:62
Definition: view.h:23
constexpr Event Right
Definition: events.h:64
App * app()
Definition: responder.cpp:77
void dismissModalViewController()
Definition: app.cpp:93
constexpr Event OK
Definition: events.h:65
virtual Type type()=0