Blame view

Giac_maj/epsilon-giac/apps/probability/calculation_controller.h 2.62 KB
6663b6c9   adorian   projet complet av...
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
  #ifndef PROBABILITY_CALCULATION_CONTROLLER_H
  #define PROBABILITY_CALCULATION_CONTROLLER_H
  
  #include <escher.h>
  #include "law/law.h"
  #include "law_curve_view.h"
  #include "image_table_view.h"
  #include "calculation/calculation.h"
  #include "../shared/text_field_delegate.h"
  
  namespace Probability {
  
  class CalculationController : public ViewController, public Shared::TextFieldDelegate {
  public:
    CalculationController(Responder * parentResponder, Law * law, Calculation * calculation);
    View * view() override;
    const char * title() override;
    void reload();
    void setCalculationAccordingToIndex(int index, bool forceReinitialisation = false);
    bool handleEvent(Ion::Events::Event event) override;
    void viewWillAppear() override;
    void didBecomeFirstResponder() override;
    void selectSubview(int subviewIndex);
    bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
    bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
    bool textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) override;
  private:
    void updateTitle();
    Shared::TextFieldDelegateApp * textFieldDelegateApp() override;
    Calculation * m_calculation;
    class ContentView : public View {
    public:
      ContentView(Responder * parentResponder, CalculationController * calculationController, Calculation * Calculation, Law * law);
      void setCalculation(Calculation * calculation, int index);
      void layoutSubviews() override;
      void drawRect(KDContext * ctx, KDRect rect) const override;
      LawCurveView * lawCurveView();
      ImageTableView * imageTableView();
      EditableTextCell * calculationCellAtIndex(int index);
      void willDisplayEditableCellAtIndex(int index);
      constexpr static int k_maxNumberOfEditableFields = 3;
    private:
      constexpr static KDCoordinate k_largeTextFieldWidth = 60;
      constexpr static KDCoordinate k_textFieldWidth = 50;
      constexpr static KDCoordinate k_textWidthMargin = 5;
      constexpr static KDCoordinate k_titleHeightMargin = 5;
      int numberOfSubviews() const override;
      View * subviewAtIndex(int index) override;
      MessageTextView m_titleView;
      LawCurveView m_lawCurveView;
      ImageTableView m_imageTableView;
      MessageTextView m_text[k_maxNumberOfEditableFields];
      char m_draftTextBuffer[TextField::maxBufferSize()];
      EditableTextCell m_calculationCell[k_maxNumberOfEditableFields];
      Calculation * m_calculation;
    };
    ContentView m_contentView;
    Law * m_law;
    int m_highlightedSubviewIndex;
    constexpr static int k_maxNumberOfTitleCharacters = 30;
    char m_titleBuffer[k_maxNumberOfTitleCharacters];
  };
  
  }
  
  #endif