COSA
An Object-Oriented Platform for Arduino Programming
Textbox.hh
Go to the documentation of this file.
1 
21 #ifndef COSA_TEXTBOX_HH
22 #define COSA_TEXTBOX_HH
23 
24 #include "Cosa/Types.h"
25 #include "Cosa/IOStream.hh"
26 
27 #include <Canvas.h>
28 #include "Font.hh"
29 
30 extern System5x7 system5x7;
31 
39 class Textbox : public Canvas::Element, public IOStream::Device {
40 public:
45  Textbox(Canvas* canvas, Font* font = (Font*) &system5x7) :
46  Canvas::Element(canvas, font),
47  IOStream::Device()
48  {
49  set_text_port(0, 0, canvas->WIDTH, canvas->HEIGHT);
50  }
51 
59  void get_text_port(uint16_t& x, uint16_t& y, uint16_t& width, uint16_t& height)
60  {
61  x = m_text_port.x;
62  y = m_text_port.y;
63  width = m_text_port.width;
64  height = m_text_port.height;
65  }
66 
74  void set_text_port(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
75  {
76  m_text_port.x = x;
77  m_text_port.y = y;
78  m_text_port.width = width;
79  m_text_port.height = height;
80  set_cursor(x, y);
81  }
82 
87  uint8_t get_line_spacing()
88  {
90  }
91 
96  void set_line_spacing(uint8_t spacing)
97  {
99  }
100 
109  virtual int putchar(char c);
110 
111 protected:
114 };
115 
116 #endif
uint16_t width
Definition: Canvas.hh:125
uint16_t y
Definition: Canvas.hh:124
Definition: Font.hh:30
void set_text_port(uint16_t x, uint16_t y, uint16_t width, uint16_t height)
Definition: Textbox.hh:74
uint8_t get_line_spacing()
Definition: Textbox.hh:87
uint16_t x
Definition: Canvas.hh:123
Context * get_context() const
Definition: Canvas.hh:401
uint8_t LINE_SPACING
Definition: Font.hh:38
Canvas * m_canvas
Definition: Canvas.hh:326
System5x7 system5x7
Definition: System5x7.cpp:24
Canvas::rect16_t m_text_port
Definition: Textbox.hh:113
Textbox(Canvas *canvas, Font *font=(Font *)&system5x7)
Definition: Textbox.hh:45
virtual int putchar(char c)
Definition: Textbox.cpp:25
uint16_t HEIGHT
Definition: Canvas.hh:370
Definition: Canvas.hh:44
void set_cursor(uint16_t x, uint16_t y)
Definition: Canvas.hh:282
void set_line_spacing(uint8_t spacing)
Definition: Textbox.hh:96
Element(Canvas *canvas, Font *font=(Font *)&system5x7)
Definition: Canvas.hh:320
uint16_t WIDTH
Definition: Canvas.hh:369
uint16_t height
Definition: Canvas.hh:126
void get_text_port(uint16_t &x, uint16_t &y, uint16_t &width, uint16_t &height)
Definition: Textbox.hh:59
Font * get_text_font() const
Definition: Canvas.hh:226