mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-01-20 09:17:23 +01:00
52 lines
2.1 KiB
C++
52 lines
2.1 KiB
C++
#ifndef ESCHER_INPUT_VIEW_CONTROLLER_H
|
|
#define ESCHER_INPUT_VIEW_CONTROLLER_H
|
|
|
|
#include <escher/modal_view_controller.h>
|
|
#include <escher/invocation.h>
|
|
#include <escher/text_field.h>
|
|
#include <escher/text_field_delegate.h>
|
|
|
|
class InputViewController : public ModalViewController, TextFieldDelegate {
|
|
public:
|
|
InputViewController(Responder * parentResponder, ViewController * child, TextFieldDelegate * textFieldDelegate);
|
|
void edit(Responder * caller, Ion::Events::Event event, void * context, const char * initialText, Invocation::Action successAction, Invocation::Action failureAction);
|
|
const char * textBody();
|
|
void setTextFieldDelegate(TextFieldDelegate * textFieldDelegate);
|
|
bool textFieldDidReceiveEvent(TextField * textField, Ion::Events::Event event) override;
|
|
bool textFieldDidFinishEditing(TextField * textField, const char * text) override;
|
|
bool textFieldDidAbortEditing(TextField * textField, const char * text) override;
|
|
Toolbox * toolboxForTextField(TextField * textFied) override;
|
|
private:
|
|
class TextFieldController : public ViewController {
|
|
public:
|
|
TextFieldController(Responder * parentResponder, TextFieldDelegate * textFieldDelegate);
|
|
void didBecomeFirstResponder() override;
|
|
View * view() override;
|
|
TextField * textField();
|
|
private:
|
|
class ContentView : public Responder, public View {
|
|
public:
|
|
ContentView(Responder * parentResponder, TextFieldDelegate * textFieldDelegate);
|
|
void didBecomeFirstResponder() override;
|
|
TextField * textField();
|
|
void drawRect(KDContext * ctx, KDRect rect) const override;
|
|
KDSize minimalSizeForOptimalDisplay() const override;
|
|
private:
|
|
View * subviewAtIndex(int index) override;
|
|
int numberOfSubviews() const override;
|
|
void layoutSubviews() override;
|
|
constexpr static int k_inputHeight = 37;
|
|
constexpr static int k_separatorThickness = 1;
|
|
TextField m_textField;
|
|
char m_textBody[255];
|
|
};
|
|
ContentView m_view;
|
|
};
|
|
TextFieldController m_textFieldController;
|
|
Invocation m_successAction;
|
|
Invocation m_failureAction;
|
|
TextFieldDelegate * m_textFieldDelegate;
|
|
};
|
|
|
|
#endif
|