tbx
0.7.6
|
Class to display text in a window. More...
#include <textview.h>
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::Window & | window () |
Get the window the text view is on. More... | |
const tbx::Margin & | margin () 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... | |
![]() | |
virtual | ~Listener () |
Destroy the listener object. | |
Additional Inherited Members | |
![]() | |
Listener () | |
Construct the Listener object. | |
Class to display text in a window.
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
window | to show it in |
wrap | true to wrap to window width. Default false |
|
inline |
Get current background colour for the text.
void tbx::view::TextView::background | ( | tbx::Colour | colour | ) |
Set the current background colour for the text.
colour | new background colour |
Note: This colour is used for painting the text only it does not fill the text view area.
colour | new background colour |
|
inline |
Get current foreground colour for the text.
void tbx::view::TextView::foreground | ( | tbx::Colour | colour | ) |
Set the current foreground colour for the text.
colour | new foreground colour |
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.
file_name | - name of file to load |
|
inline |
Get the margin between the text view contents and the edge of the Window.
void tbx::view::TextView::margin | ( | const tbx::Margin & | margin | ) |
Change the margin.
margin | new margin |
|
virtual |
Window has been opened or resized, so re do layout.
event | details on open window event |
Implements tbx::OpenWindowListener.
|
virtual |
Redraw the window.
event | details on what needs to be redrawn |
Implements tbx::RedrawListener.
void tbx::view::TextView::refresh | ( | ) |
Refresh the whole report view.
It should also be called if all the data changes.
|
inline |
Get the current size of the text.
|
inline |
Get a pointer to the text.
void tbx::view::TextView::text | ( | const char * | text | ) |
Set the text for the text view.
text | pointer to zero terminated text |
void tbx::view::TextView::text | ( | const std::string & | text | ) |
Set the text for the text view.
text | new text for the text view |
|
inline |
Get the window the text view is on.
|
inline |
Check it text view is set to wrap text.
void tbx::view::TextView::wrap | ( | bool | w | ) |
Set wrap to window width on or off.
w | set to true to turn on wrapping. |