tbx  0.7.5
Public Member Functions | List of all members
tbx::view::TextView Class Reference

Class to display text in a window. More...

#include <textview.h>

Inheritance diagram for tbx::view::TextView:
tbx::RedrawListener tbx::OpenWindowListener tbx::Listener

Public Member Functions

 TextView (tbx::Window window, bool wrap=false)
 Construct a text view. More...
 
virtual ~TextView ()
 Destructor removes listeners from window and deletes the text.
 
void update_window_extent ()
 Update the Window extent after a change in size of text.
 
void refresh ()
 Refresh the whole report view. More...
 
tbx::Windowwindow ()
 Get the window the text view is on. More...
 
const tbx::Marginmargin () const
 Get the margin between the text view contents and the edge of the Window. More...
 
void margin (const tbx::Margin &margin)
 Change the margin. More...
 
const char * text () const
 Get a pointer to the text. More...
 
void text (const char *text)
 Set the text for the text view. More...
 
void text (const std::string &text)
 Set the text for the text view. More...
 
unsigned int size () const
 Get the current size of the text. More...
 
tbx::Colour background () const
 Get current background colour for the text. More...
 
void background (tbx::Colour colour)
 Set the current background colour for the text. More...
 
tbx::Colour foreground () const
 Get current foreground colour for the text. More...
 
void foreground (tbx::Colour colour)
 Set the current foreground colour for the text. More...
 
bool load_file (const std::string &file_name)
 Load text for view from file. More...
 
bool wrap () const
 Check it text view is set to wrap text. More...
 
void wrap (bool w)
 Set wrap to window width on or off. More...
 
virtual void redraw (const tbx::RedrawEvent &event)
 Redraw the window. More...
 
virtual void open_window (tbx::OpenWindowEvent &event)
 Window has been opened or resized, so re do layout. More...
 
- Public Member Functions inherited from tbx::Listener
virtual ~Listener ()
 Destroy the listener object.
 

Additional Inherited Members

- Protected Member Functions inherited from tbx::Listener
 Listener ()
 Construct the Listener object.
 

Detailed Description

Class to display text in a window.

Constructor & Destructor Documentation

◆ TextView()

tbx::view::TextView::TextView ( tbx::Window  window,
bool  wrap = false 
)

Construct a text view.

Default to black text on with a white background text colour

Parameters
windowto show it in
wraptrue to wrap to window width. Default false

Member Function Documentation

◆ background() [1/2]

tbx::Colour tbx::view::TextView::background ( ) const
inline

Get current background colour for the text.

Returns
background colour

◆ background() [2/2]

void tbx::view::TextView::background ( tbx::Colour  colour)

Set the current background colour for the text.

Parameters
colournew background colour

Note: This colour is used for painting the text only it does not fill the text view area.

Parameters
colournew background colour

◆ foreground() [1/2]

tbx::Colour tbx::view::TextView::foreground ( ) const
inline

Get current foreground colour for the text.

Returns
foreground colour

◆ foreground() [2/2]

void tbx::view::TextView::foreground ( tbx::Colour  colour)

Set the current foreground colour for the text.

Parameters
colournew foreground colour

◆ load_file()

bool tbx::view::TextView::load_file ( const std::string &  file_name)

Load text for view from file.

Replace all control codes (character < ASCII 32) except line feed (10) with a space.

Parameters
file_name- name of file to load
Returns
true if file loaded OK.

◆ margin() [1/2]

const tbx::Margin& tbx::view::TextView::margin ( ) const
inline

Get the margin between the text view contents and the edge of the Window.

Returns
the margin

◆ margin() [2/2]

void tbx::view::TextView::margin ( const tbx::Margin margin)

Change the margin.

Parameters
marginnew margin

◆ open_window()

void tbx::view::TextView::open_window ( tbx::OpenWindowEvent event)
virtual

Window has been opened or resized, so re do layout.

Parameters
eventdetails on open window event

Implements tbx::OpenWindowListener.

◆ redraw()

void tbx::view::TextView::redraw ( const tbx::RedrawEvent event)
virtual

Redraw the window.

Parameters
eventdetails on what needs to be redrawn

Implements tbx::RedrawListener.

◆ refresh()

void tbx::view::TextView::refresh ( )

Refresh the whole report view.

It should also be called if all the data changes.

◆ size()

unsigned int tbx::view::TextView::size ( ) const
inline

Get the current size of the text.

Returns
size in bytes of the text

◆ text() [1/3]

const char* tbx::view::TextView::text ( ) const
inline

Get a pointer to the text.

Returns
a zero terminated pointer to the text

◆ text() [2/3]

void tbx::view::TextView::text ( const char *  text)

Set the text for the text view.

Parameters
textpointer to zero terminated text

◆ text() [3/3]

void tbx::view::TextView::text ( const std::string &  text)

Set the text for the text view.

Parameters
textnew text for the text view

◆ window()

tbx::Window& tbx::view::TextView::window ( )
inline

Get the window the text view is on.

Returns
Window that displays the text view

◆ wrap() [1/2]

bool tbx::view::TextView::wrap ( ) const
inline

Check it text view is set to wrap text.

Returns
true if text view will wrap text

◆ wrap() [2/2]

void tbx::view::TextView::wrap ( bool  w)

Set wrap to window width on or off.

Parameters
wset to true to turn on wrapping.

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