Numworks Epsilon  1.4.1
Graphing Calculator Operating System
text_input.h
Go to the documentation of this file.
1 #ifndef ESCHER_TEXT_INPUT_H
2 #define ESCHER_TEXT_INPUT_H
3 
4 #include <assert.h>
5 #include <string.h>
9 
11 public:
13  Toolbox * toolbox() override;
14  const char * text() const { return nonEditableContentView()->text(); }
17  void setTextColor(KDColor textColor);
18  bool removeChar();
19  size_t cursorLocation() const { return nonEditableContentView()->cursorLocation(); }
20  bool setCursorLocation(int location);
21  virtual void scrollToCursor();
22  virtual bool handleEventWithText(const char * text, bool indenting = false) = 0;
23 protected:
24  class ContentView : public View {
25  public:
29  void setTextColor(KDColor textColor);
30  size_t cursorLocation() const { return m_cursorIndex; }
32  virtual const char * text() const = 0;
33  virtual bool insertTextAtLocation(const char * text, int location) = 0;
34  virtual bool removeChar() = 0;
35  virtual bool removeEndOfLine() = 0;
37  protected:
38  virtual void layoutSubviews() override;
39  void reloadRectFromCursorPosition(size_t index, bool lineBreak = false);
40  virtual KDRect characterFrameAtIndex(size_t index) const = 0;
45  size_t m_cursorIndex;
46  private:
47  int numberOfSubviews() const override;
48  View * subviewAtIndex(int index) override;
49  virtual size_t editedTextLength() const = 0;
50  };
51 protected:
52  /* If the text to be appended is too long to be added without overflowing the
53  * buffer, nothing is done (not even adding few letters from the text to reach
54  * the maximum buffer capacity) and false is returned. */
55  bool insertTextAtLocation(const char * textBuffer, int location);
56  virtual bool removeEndOfLine();
58  return const_cast<ContentView *>(nonEditableContentView());
59  }
60  virtual const ContentView * nonEditableContentView() const = 0;
61 private:
62  virtual TextInputDelegate * delegate() = 0;
63 };
64 
65 #endif
bool setCursorLocation(int location)
Definition: text_input.cpp:97
void setTextColor(KDColor textColor)
Definition: text_input.cpp:21
void setTextColor(KDColor textColor)
Definition: text_input.cpp:76
size_t cursorLocation() const
Definition: text_input.h:30
void setBackgroundColor(KDColor backgroundColor)
Definition: text_input.cpp:16
size_t cursorLocation() const
Definition: text_input.h:19
virtual bool removeChar()=0
Responder * parentResponder() const
Definition: responder.cpp:12
KDColor backgroundColor() const
Definition: text_input.h:28
KDText::FontSize m_fontSize
Definition: text_input.h:42
void setBackgroundColor(KDColor backgroundColor)
Definition: text_input.cpp:72
TextCursorView m_cursorView
Definition: text_input.h:41
virtual bool handleEventWithText(const char *text, bool indenting=false)=0
virtual void scrollToCursor()
Definition: text_input.cpp:86
void setCursorLocation(int cursorLocation)
Definition: text_input.cpp:26
Toolbox * toolbox() override
Definition: text_input.cpp:65
virtual bool removeEndOfLine()
Definition: text_input.cpp:114
bool insertTextAtLocation(const char *textBuffer, int location)
Definition: text_input.cpp:103
ContentView * contentView()
Definition: text_input.h:57
bool removeChar()
Definition: text_input.cpp:80
virtual KDRect characterFrameAtIndex(size_t index) const =0
const char * text() const
Definition: text_input.h:14
virtual const char * text() const =0
Definition: rect.h:26
Definition: color.h:6
Definition: view.h:23
void reloadRectFromCursorPosition(size_t index, bool lineBreak=false)
Definition: text_input.cpp:49
virtual bool removeEndOfLine()=0
virtual const ContentView * nonEditableContentView() const =0
KDColor backgroundColor() const
Definition: text_input.h:16
ContentView(KDText::FontSize size, KDColor textColor, KDColor backgroundColor)
Definition: text_input.cpp:6
TextInput(Responder *parentResponder, View *contentView)
Definition: text_input.cpp:60
virtual bool insertTextAtLocation(const char *text, int location)=0
virtual void layoutSubviews() override
Definition: text_input.cpp:45
FontSize
Definition: text.h:10