Numworks Epsilon  1.4.1
Graphing Calculator Operating System
calculation_controller.h
Go to the documentation of this file.
1 #ifndef PROBABILITY_CALCULATION_CONTROLLER_H
2 #define PROBABILITY_CALCULATION_CONTROLLER_H
3 
4 #include <escher.h>
5 #include "law/law.h"
6 #include "law_curve_view.h"
7 #include "calculation_cell.h"
8 #include "responder_image_cell.h"
9 #include "calculation/calculation.h"
10 #include "../shared/parameter_text_field_delegate.h"
11 
12 namespace Probability {
13 
15 public:
17  /* Responder */
18  void didEnterResponderChain(Responder * previousResponder) override;
19  void didBecomeFirstResponder() override;
20  bool handleEvent(Ion::Events::Event event) override;
21 
22  /* ViewController */
23  View * view() override;
24  const char * title() override;
25  void viewWillAppear() override;
26  void viewDidDisappear() override;
27 
28  /* TableViewDataSource */
29  int numberOfRows() override;
30  int numberOfColumns() override;
31  KDCoordinate columnWidth(int i) override;
32  KDCoordinate rowHeight(int j) override;
33  KDCoordinate cumulatedWidthFromIndex(int i) override;
34  KDCoordinate cumulatedHeightFromIndex(int j) override;
35  int indexFromCumulatedWidth(KDCoordinate offsetX) override;
36  int indexFromCumulatedHeight(KDCoordinate offsetY) override;
37  HighlightCell * reusableCell(int index, int type) override;
38  int reusableCellCount(int type) override;
39  int typeAtLocation(int i, int j) override;
40  void willDisplayCellAtLocation(HighlightCell * cell, int i, int j) override;
41 
42  /* TextField delegate */
43  bool textFieldDidHandleEvent(TextField * textField, bool returnValue, bool textHasChanged) override;
44  bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
45  bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
46 
47  void reloadLawCurveView();
48  void reload();
49  void setCalculationAccordingToIndex(int index, bool forceReinitialisation = false);
50 private:
51  constexpr static int k_numberOfCalculationCells = 3;
52  constexpr static KDCoordinate k_tableMargin = 3;
53  Shared::TextFieldDelegateApp * textFieldDelegateApp() override;
54  void updateTitle();
55  class ContentView : public View {
56  public:
57  ContentView(SelectableTableView * selectableTableView, Law * law, Calculation * calculation);
58  LawCurveView * lawCurveView() {
59  return &m_lawCurveView;
60  }
61  private:
62  constexpr static KDCoordinate k_titleHeightMargin = 5;
63  int numberOfSubviews() const override;
64  View * subviewAtIndex(int index) override;
65  void layoutSubviews() override;
66  MessageTextView m_titleView;
67  SelectableTableView * m_selectableTableView;
68  LawCurveView m_lawCurveView;
69  };
70  ContentView m_contentView;
71  SelectableTableView m_selectableTableView;
72  ResponderImageCell m_imageCell;
73  char m_draftTextBuffer[TextField::maxBufferSize()];
74  CalculationCell m_calculationCells[k_numberOfCalculationCells];
75  Calculation * m_calculation;
76  Law * m_law;
77  constexpr static int k_maxNumberOfTitleCharacters = 30;
78  char m_titleBuffer[k_maxNumberOfTitleCharacters];
79 };
80 
81 }
82 
83 #endif
int indexFromCumulatedWidth(KDCoordinate offsetX) override
static constexpr int maxBufferSize()
Definition: text_field.h:23
KDCoordinate cumulatedHeightFromIndex(int j) override
int16_t KDCoordinate
Definition: coordinate.h:6
bool textFieldShouldFinishEditing(TextField *textField, Ion::Events::Event event) override
void willDisplayCellAtLocation(HighlightCell *cell, int i, int j) override
Responder * parentResponder() const
Definition: responder.cpp:12
bool textFieldDidFinishEditing(TextField *textField, const char *text, Ion::Events::Event event) override
void setCalculationAccordingToIndex(int index, bool forceReinitialisation=false)
KDCoordinate columnWidth(int i) override
bool textFieldDidHandleEvent(TextField *textField, bool returnValue, bool textHasChanged) override
HighlightCell * reusableCell(int index, int type) override
KDCoordinate rowHeight(int j) override
CalculationController(Responder *parentResponder, Law *law, Calculation *calculation)
int indexFromCumulatedHeight(KDCoordinate offsetY) override
Definition: view.h:23
void didEnterResponderChain(Responder *previousResponder) override
bool handleEvent(Ion::Events::Event event) override
KDCoordinate cumulatedWidthFromIndex(int i) override