Blame view

build2/epsilon-master/apps/calculation/edit_expression_controller.h 3.28 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
67
68
69
70
71
72
73
74
  #ifndef CALCULATION_EDIT_EXPRESSION_CONTROLLER_H
  #define CALCULATION_EDIT_EXPRESSION_CONTROLLER_H
  
  #include <escher.h>
  #include <poincare/expression_layout.h>
  #include "expression_field.h"
  #include "../shared/text_field_delegate.h"
  #include "../shared/expression_layout_field_delegate.h"
  #include "history_controller.h"
  #include "calculation_store.h"
  
  namespace Calculation {
  class HistoryController;
  
  /* TODO: implement a split view */
  class EditExpressionController : public DynamicViewController, public Shared::TextFieldDelegate, public Shared::ExpressionLayoutFieldDelegate {
  public:
    EditExpressionController(Responder * parentResponder, HistoryController * historyController, CalculationStore * calculationStore);
    void didBecomeFirstResponder() override;
    void viewDidDisappear() override;
    bool handleEvent(Ion::Events::Event event) override;
    void insertTextBody(const char * text);
  
    /* TextFieldDelegate */
    bool textFieldDidReceiveEvent(::TextField * textField, Ion::Events::Event event) override;
    bool textFieldDidFinishEditing(::TextField * textField, const char * text, Ion::Events::Event event) override;
    bool textFieldDidAbortEditing(::TextField * textField) override;
  
    /* ExpressionLayoutFieldDelegate */
    bool expressionLayoutFieldDidReceiveEvent(::ExpressionLayoutField * expressionLayoutField, Ion::Events::Event event) override;
    bool expressionLayoutFieldDidFinishEditing(::ExpressionLayoutField * expressionLayoutField, Poincare::ExpressionLayout * layout, Ion::Events::Event event) override;
    bool expressionLayoutFieldDidAbortEditing(::ExpressionLayoutField * expressionLayoutField) override;
    void expressionLayoutFieldDidChangeSize(::ExpressionLayoutField * expressionLayoutField) override;
  
  private:
    class ContentView : public View {
    public:
      ContentView(Responder * parentResponder, TableView * subview, TextFieldDelegate * textFieldDelegate, ExpressionLayoutFieldDelegate * expressionLayoutFieldDelegate);
      ~ContentView();
      ContentView(const ContentView& other) = delete;
      ContentView(ContentView&& other) = delete;
      ContentView& operator=(const ContentView& other) = delete;
      ContentView& operator=(ContentView&& other) = delete;
      void reload();
      TableView * mainView() { return m_mainView; }
      ExpressionField * expressionField() { return &m_expressionField; }
      /* View */
      int numberOfSubviews() const override { return 2; }
      View * subviewAtIndex(int index) override;
      void layoutSubviews() override;
    private:
      static constexpr int k_bufferLength = TextField::maxBufferSize();
      TableView * m_mainView;
      char m_textBody[k_bufferLength];
      Poincare::ExpressionLayout * m_layout;
      ExpressionField m_expressionField;
    };
    View * loadView() override;
    void unloadView(View * view) override;
    void reloadView();
    bool inputViewDidReceiveEvent(Ion::Events::Event event);
    bool inputViewDidFinishEditing(const char * text, Poincare::ExpressionLayout * layout);
    bool inputViewDidAbortEditing(const char * text);
    Shared::TextFieldDelegateApp * textFieldDelegateApp() override;
    Shared::ExpressionFieldDelegateApp * expressionFieldDelegateApp() override;
    char m_cacheBuffer[Calculation::k_printedExpressionSize];
    HistoryController * m_historyController;
    CalculationStore * m_calculationStore;
    bool m_inputViewHeightIsMaximal;
  };
  
  }
  
  #endif