COSA
An Object-Oriented Platform for Arduino Programming
Textbox Class Reference

#include <Textbox.hh>

Inheritance diagram for Textbox:
Inheritance graph
Collaboration diagram for Textbox:
Collaboration graph

Public Member Functions

 Textbox (Canvas *canvas, Font *font=(Font *)&system5x7)
 
void get_text_port (uint16_t &x, uint16_t &y, uint16_t &width, uint16_t &height)
 
void set_text_port (uint16_t x, uint16_t y, uint16_t width, uint16_t height)
 
uint8_t get_line_spacing ()
 
void set_line_spacing (uint8_t spacing)
 
virtual int putchar (char c)
 
color16_t get_canvas_color () const
 
color16_t set_canvas_color (color16_t color)
 
color16_t get_pen_color () const
 
color16_t set_pen_color (color16_t color)
 
color16_t get_text_color () const
 
color16_t set_text_color (color16_t color)
 
Fontget_text_font () const
 
Fontset_text_font (Font *font)
 
uint8_t get_text_scale () const
 
uint8_t set_text_scale (uint8_t scale)
 
void get_cursor (uint16_t &x, uint16_t &y) const
 
void set_cursor (uint16_t x, uint16_t y)
 
void move_cursor (int16_t dx, int16_t dy)
 
void non_blocking ()
 
void blocking ()
 
bool is_blocking () const
 
void eol (Mode mode)
 
Mode eol () const
 
virtual int available ()
 
virtual int room ()
 
virtual int puts (const char *s)
 
virtual int puts (str_P s)
 
virtual int write (const void *buf, size_t size)
 
virtual int write (const iovec_t *vec)
 
virtual int write_P (const void *buf, size_t size)
 
virtual int peekchar ()
 
virtual int peekchar (char c)
 
virtual int getchar ()
 
virtual char * gets (char *s, size_t count)
 
virtual int read (void *buf, size_t size)
 
virtual int read (iovec_t *vec)
 
virtual int flush ()
 
virtual void empty ()
 

Protected Attributes

Canvas::rect16_t m_text_port
 
Canvasm_canvas
 
color16_t m_pen_color
 Current foreground color. More...
 
color16_t m_canvas_color
 Current background color. More...
 
color16_t m_text_color
 Current text color. More...
 
uint8_t m_text_scale
 Current text scale. More...
 
Fontm_font
 Current font. More...
 
pos16_t m_cursor
 Current cursor position. More...
 
bool m_blocking
 
Mode m_eol
 

Detailed Description

Canvas Textbox element. Acts as an IOStream/console output to a canvas. As an element it holds its own canvas state; context. The textbox is defined by a port (x, y, width, height) on the canvas. Basic special character handling of carriage-return, line- and form-feed.

Definition at line 39 of file Textbox.hh.

Constructor & Destructor Documentation

Textbox::Textbox ( Canvas canvas,
Font font = (Font*) &system5x7 
)
inline

Construct text box on given canvas. Set textbox port to canvas size.

Parameters
[in]canvas.

Definition at line 45 of file Textbox.hh.

Member Function Documentation

int IOStream::Device::available ( )
virtualinherited

Number of bytes available (possible to read).

Returns
bytes.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, Soft::UART, UART, IOBuffer< SIZE >, and CC3000::Driver.

Definition at line 24 of file IOStream_Device.cpp.

void IOStream::Device::blocking ( )
inlineinherited

Set blocking mode.

Definition at line 85 of file IOStream.hh.

void IOStream::Device::empty ( )
virtualinherited

Empty internal device buffers.

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 175 of file IOStream_Device.cpp.

void IOStream::Device::eol ( Mode  mode)
inlineinherited

Set end of line mode.

Parameters
[in]modefor end of line.

Definition at line 103 of file IOStream.hh.

Mode IOStream::Device::eol ( ) const
inlineinherited

Get end of line mode.

Returns
mode.

Definition at line 112 of file IOStream.hh.

int IOStream::Device::flush ( )
virtualinherited

Flush internal device buffers. Wait for device to become idle.

Returns
zero(0) or negative error code.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.

Definition at line 169 of file IOStream_Device.cpp.

color16_t Canvas::Context::get_canvas_color ( ) const
inlineinherited

Get context canvas color.

Returns
color.

Definition at line 164 of file Canvas.hh.

void Canvas::Context::get_cursor ( uint16_t &  x,
uint16_t &  y 
) const
inlineinherited

Get context cursor position.

Parameters
[out]x.
[out]y.

Definition at line 271 of file Canvas.hh.

uint8_t Textbox::get_line_spacing ( )
inline

Get current line spacing.

Returns
line spacing.

Definition at line 87 of file Textbox.hh.

color16_t Canvas::Context::get_pen_color ( ) const
inlineinherited

Get context drawing color.

Returns
color.

Definition at line 185 of file Canvas.hh.

color16_t Canvas::Context::get_text_color ( ) const
inlineinherited

Get context text color.

Returns
color.

Definition at line 206 of file Canvas.hh.

Font* Canvas::Context::get_text_font ( ) const
inlineinherited

Get context text font.

Definition at line 226 of file Canvas.hh.

void Textbox::get_text_port ( uint16_t &  x,
uint16_t &  y,
uint16_t &  width,
uint16_t &  height 
)
inline

Get current text port.

Parameters
[out]x.
[out]y.
[out]width.
[out]height.

Definition at line 59 of file Textbox.hh.

uint8_t Canvas::Context::get_text_scale ( ) const
inlineinherited

Get context text scale.

Returns
text scale.

Definition at line 248 of file Canvas.hh.

int IOStream::Device::getchar ( )
virtualinherited

Read character from device.

Returns
character or EOF(-1).

Reimplemented in FAT16::File, CFFS::File, Soft::UART, UART, IOBuffer< SIZE >, and Socket.

Definition at line 112 of file IOStream_Device.cpp.

char * IOStream::Device::gets ( char *  s,
size_t  count 
)
virtualinherited

Read string terminated by new-line or until size into given string buffer. Returns pointer to string or NULL if empty line.

Parameters
[in]sstring buffer to read into.
[in]countmax number of bytes to read.
Returns
string pointer or NULL.

Definition at line 118 of file IOStream_Device.cpp.

bool IOStream::Device::is_blocking ( ) const
inlineinherited

Is blocking mode?

Returns
bool.

Definition at line 94 of file IOStream.hh.

void Canvas::Context::move_cursor ( int16_t  dx,
int16_t  dy 
)
inlineinherited

Move context cursor to delta position.

Parameters
[in]dx.
[in]dy.

Definition at line 293 of file Canvas.hh.

void IOStream::Device::non_blocking ( )
inlineinherited

Set non-blocking mode.

Definition at line 77 of file IOStream.hh.

int IOStream::Device::peekchar ( )
virtualinherited

Peek at the next character from device.

Returns
character or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 99 of file IOStream_Device.cpp.

int IOStream::Device::peekchar ( char  c)
virtualinherited

Peek for the given character in device buffer. Return number of characters or EOF(-1).

Parameters
[in]ccharacter to peek for.
Returns
available or EOF(-1).

Reimplemented in Soft::UART, UART, and IOBuffer< SIZE >.

Definition at line 105 of file IOStream_Device.cpp.

int Textbox::putchar ( char  c)
virtual

IOStream::Device Write character at current cursor position, with current text color, scale and font. The textbox will handle carriage-return, line-feed and form-feed. Scrolling is handled as a wrap-around.

Parameters
[in]ccharacter to write.
Returns
character written or EOF(-1).

Reimplemented from IOStream::Device.

Definition at line 25 of file Textbox.cpp.

int IOStream::Device::puts ( const char *  s)
virtualinherited

Write null terminated string to device. Terminating null is not written.

Parameters
[in]sstring to write.
Returns
zero(0) or negative error code.

Definition at line 43 of file IOStream_Device.cpp.

int IOStream::Device::puts ( str_P  s)
virtualinherited

Write null terminated string from program memory to device. Terminating null is not written.

Parameters
[in]sstring in program memory to write.
Returns
zero(0) or negative error code.

Definition at line 54 of file IOStream_Device.cpp.

int IOStream::Device::read ( void *  buf,
size_t  size 
)
virtualinherited

Read data to given buffer with given size from device.

Parameters
[in]bufbuffer to read into.
[in]sizenumber of bytes to read.
Returns
number of bytes read or EOF(-1).

Reimplemented in FAT16::File, W5200::Driver, W5500::Driver, W5100::Driver, CFFS::File, Socket, and CC3000::Driver.

Definition at line 144 of file IOStream_Device.cpp.

int IOStream::Device::read ( iovec_t vec)
virtualinherited

Read data to given buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to read into.
Returns
number of bytes read or EOF(-1).

Definition at line 157 of file IOStream_Device.cpp.

int IOStream::Device::room ( )
virtualinherited

Number of bytes room (write without blocking).

Returns
bytes.

Reimplemented in W5200::Driver, W5500::Driver, W5100::Driver, UART, IOBuffer< SIZE >, CC3000::Driver, and WIO.

Definition at line 30 of file IOStream_Device.cpp.

color16_t Canvas::Context::set_canvas_color ( color16_t  color)
inlineinherited

Set context canvas color. Return previous color.

Parameters
[in]color.
Returns
previous color.

Definition at line 174 of file Canvas.hh.

void Canvas::Context::set_cursor ( uint16_t  x,
uint16_t  y 
)
inlineinherited

Set context cursor position.

Parameters
[in]x.
[in]y.

Definition at line 282 of file Canvas.hh.

void Textbox::set_line_spacing ( uint8_t  spacing)
inline

Set current line spacing.

Parameters
[in]spacing.

Definition at line 96 of file Textbox.hh.

color16_t Canvas::Context::set_pen_color ( color16_t  color)
inlineinherited

Set context drawing color. Return previous color.

Parameters
[in]color
Returns
previous color.

Definition at line 195 of file Canvas.hh.

color16_t Canvas::Context::set_text_color ( color16_t  color)
inlineinherited

Set context text color. Return previous color.

Parameters
[in]color.
Returns
previous color.

Definition at line 216 of file Canvas.hh.

Font* Canvas::Context::set_text_font ( Font font)
inlineinherited

Set context text font. Return previous color.

Parameters
[in]font.
Returns
previous font.
Precondition
font != 0.

Definition at line 237 of file Canvas.hh.

void Textbox::set_text_port ( uint16_t  x,
uint16_t  y,
uint16_t  width,
uint16_t  height 
)
inline

Set current text position.

Parameters
[in]x.
[in]y.
[in]width.
[in]height.

Definition at line 74 of file Textbox.hh.

uint8_t Canvas::Context::set_text_scale ( uint8_t  scale)
inlineinherited

Set context text scale (1..n). Return previous text scale.

Parameters
[in]scale.
Returns
previous scale.
Precondition
scale > 0.

Definition at line 259 of file Canvas.hh.

int IOStream::Device::write ( const void *  buf,
size_t  size 
)
virtualinherited

Write data from buffer with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented in FAT16::File, HD44780, CFFS::File, VLCD, Socket, and CC3000::Driver.

Definition at line 65 of file IOStream_Device.cpp.

int IOStream::Device::write ( const iovec_t vec)
virtualinherited

Write data from buffers in null terminated io vector.

Parameters
[in]vecio vector with buffers to write.
Returns
number of bytes written or EOF(-1).

Definition at line 87 of file IOStream_Device.cpp.

int IOStream::Device::write_P ( const void *  buf,
size_t  size 
)
virtualinherited

Write data from buffer in program memory with given size to device.

Parameters
[in]bufbuffer to write.
[in]sizenumber of bytes to write.
Returns
number of bytes written or EOF(-1).

Reimplemented in CFFS::File, Socket, and CC3000::Driver.

Definition at line 76 of file IOStream_Device.cpp.

Member Data Documentation

bool IOStream::Device::m_blocking
protectedinherited

Blocking state

Definition at line 248 of file IOStream.hh.

Canvas* Canvas::Element::m_canvas
protectedinherited

Definition at line 326 of file Canvas.hh.

color16_t Canvas::Context::m_canvas_color
protectedinherited

Current background color.

Definition at line 301 of file Canvas.hh.

pos16_t Canvas::Context::m_cursor
protectedinherited

Current cursor position.

Definition at line 305 of file Canvas.hh.

Mode IOStream::Device::m_eol
protectedinherited

End of line mode

Definition at line 251 of file IOStream.hh.

Font* Canvas::Context::m_font
protectedinherited

Current font.

Definition at line 304 of file Canvas.hh.

color16_t Canvas::Context::m_pen_color
protectedinherited

Current foreground color.

Definition at line 300 of file Canvas.hh.

color16_t Canvas::Context::m_text_color
protectedinherited

Current text color.

Definition at line 302 of file Canvas.hh.

Canvas::rect16_t Textbox::m_text_port
protected

Textbox port rectangle.

Definition at line 113 of file Textbox.hh.

uint8_t Canvas::Context::m_text_scale
protectedinherited

Current text scale.

Definition at line 303 of file Canvas.hh.


The documentation for this class was generated from the following files: