Numworks Epsilon  1.4.1
Graphing Calculator Operating System
input_view_controller.h
Go to the documentation of this file.
1 #ifndef ESCHER_INPUT_VIEW_CONTROLLER_H
2 #define ESCHER_INPUT_VIEW_CONTROLLER_H
3 
5 #include <escher/invocation.h>
6 #include <escher/text_field.h>
8 
10 public:
12  void edit(Responder * caller, Ion::Events::Event event, void * context, const char * initialText, Invocation::Action successAction, Invocation::Action failureAction);
13  const char * textBody();
14  bool textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) override;
16  bool textFieldShouldFinishEditing(TextField * textField, Ion::Events::Event event) override;
17  bool textFieldDidFinishEditing(TextField * textField, const char * text, Ion::Events::Event event) override;
18  bool textFieldDidAbortEditing(TextField * textField, const char * text) override;
19  Toolbox * toolboxForTextInput(TextInput * textInput) override;
20 private:
21  class TextFieldController : public ViewController {
22  public:
23  TextFieldController(Responder * parentResponder, TextFieldDelegate * textFieldDelegate);
24  void didBecomeFirstResponder() override;
25  View * view() override;
26  TextField * textField();
27  private:
28  class ContentView : public Responder, public View {
29  public:
30  ContentView(Responder * parentResponder, TextFieldDelegate * textFieldDelegate);
31  void didBecomeFirstResponder() override;
32  TextField * textField();
33  void drawRect(KDContext * ctx, KDRect rect) const override;
34  KDSize minimalSizeForOptimalDisplay() const override;
35  private:
36  View * subviewAtIndex(int index) override;
37  int numberOfSubviews() const override;
38  void layoutSubviews() override;
39  constexpr static KDCoordinate k_inputHeight = 37;
40  constexpr static KDCoordinate k_separatorThickness = 1;
41  constexpr static KDCoordinate k_textMargin = 5;
42  TextField m_textField;
43  char m_textBody[TextField::maxBufferSize()];
44  };
45  ContentView m_view;
46  };
47  TextFieldController m_textFieldController;
48  Invocation m_successAction;
49  Invocation m_failureAction;
50  TextFieldDelegate * m_textFieldDelegate;
51 };
52 
53 #endif
void(* Action)(void *context, void *sender)
Definition: invocation.h:6
bool textFieldShouldFinishEditing(TextField *textField, Ion::Events::Event event) override
void edit(Responder *caller, Ion::Events::Event event, void *context, const char *initialText, Invocation::Action successAction, Invocation::Action failureAction)
static constexpr int maxBufferSize()
Definition: text_field.h:23
bool textFieldDidAbortEditing(TextField *textField, const char *text) override
int16_t KDCoordinate
Definition: coordinate.h:6
Responder * parentResponder() const
Definition: responder.cpp:12
Definition: size.h:6
void didBecomeFirstResponder() override
Toolbox * toolboxForTextInput(TextInput *textInput) override
Definition: rect.h:26
Definition: view.h:23
bool textFieldDidFinishEditing(TextField *textField, const char *text, Ion::Events::Event event) override
InputViewController(Responder *parentResponder, ViewController *child, TextFieldDelegate *textFieldDelegate)
bool textFieldDidReceiveEvent(TextField *textField, Ion::Events::Event event) override