Blame view

build3/apps/calculation/edit_expression_controller.h 1.99 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
  #ifndef CALCULATION_EDIT_EXPRESSION_CONTROLLER_H
  #define CALCULATION_EDIT_EXPRESSION_CONTROLLER_H
  
  #include <escher.h>
  #include "../shared/text_field_delegate.h"
  #include "history_controller.h"
  #include "calculation_store.h"
  #include "text_field.h"
  
  namespace Calculation {
  class HistoryController;
  
  /* TODO: implement a split view */
  class EditExpressionController : public DynamicViewController, public Shared::TextFieldDelegate {
  public:
    EditExpressionController(Responder * parentResponder, HistoryController * historyController, CalculationStore * calculationStore);
    void didBecomeFirstResponder() override;
    void viewDidDisappear() override;
    bool handleEvent(Ion::Events::Event event) override;
    const char * textBody();
    void insertTextBody(const char * text);
  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, const char * text) override;
  private:
    class ContentView : public View {
    public:
      ContentView(Responder * parentResponder, TableView * subview, TextFieldDelegate * textFieldDelegate);
      int numberOfSubviews() const override;
      View * subviewAtIndex(int index) override;
      void layoutSubviews() override;
      TextField * textField();
      TableView * mainView();
      void drawRect(KDContext * ctx, KDRect rect) const override;
    private:
      static constexpr KDCoordinate k_textFieldHeight = 37;
      static constexpr KDCoordinate k_textMargin= 5;
      constexpr static int k_separatorThickness = 1;
      TableView * m_mainView;
      TextField m_textField;
      char m_textBody[TextField::maxBufferSize()];
    };
    View * loadView() override;
    void unloadView(View * view) override;
    Shared::TextFieldDelegateApp * textFieldDelegateApp() override;
    char m_cacheBuffer[TextField::maxBufferSize()];
    HistoryController * m_historyController;
    CalculationStore * m_calculationStore;
  };
  
  }
  
  #endif