tbx  0.7.6
Public Member Functions | Protected Attributes | List of all members
tbx::TextDisplayWindow Class Reference

Class to show some text in a window in the centre of the screen, with an icon to the left and one or buttons at the bottom. More...

#include <textdisplaywindow.h>

Inheritance diagram for tbx::TextDisplayWindow:
tbx::RedrawListener tbx::HasBeenHiddenListener tbx::Listener tbx::Listener tbx::MessageWindow tbx::QuestionWindow

Public Member Functions

 TextDisplayWindow (const std::string &text, const char *buttons, int default_button=-1, int cancel_button=-1, int button_width=200)
 Construct a text display window with the given text and buttons. More...
 
virtual ~TextDisplayWindow ()
 Destructor, delete close command if necessary.
 
void title (const std::string &title)
 Set the title for the text display window. More...
 
tbx::Window window ()
 Get underlying window used for the message window.
 
void delete_on_hide ()
 Set up text display window to delete itself when it is hidden. More...
 
void close_command (tbx::Command *close_command, bool delete_command=false)
 Set command to be run when message window is closed. More...
 
void show ()
 Show the text display window. More...
 
void show_as_menu ()
 Show the text display window as a menu. More...
 
- Public Member Functions inherited from tbx::Listener
virtual ~Listener ()
 Destroy the listener object.
 

Protected Attributes

tbx::Window _window
 

Additional Inherited Members

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

Detailed Description

Class to show some text in a window in the centre of the screen, with an icon to the left and one or buttons at the bottom.

The window is created to fit the text.

The buttons are created with the component ids 10 and up.

Subclasses can use the _window protected member to modify the window and add event handlers.

The MessageWindow and QuestionWindow both derived from this class.

Constructor & Destructor Documentation

◆ TextDisplayWindow()

tbx::TextDisplayWindow::TextDisplayWindow ( const std::string &  text,
const char *  buttons,
int  default_button = -1,
int  cancel_button = -1,
int  button_width = 200 
)

Construct a text display window with the given text and buttons.

If the default button or cancel button are given a value other than -1 the window will be given the input focus when shown.

Parameters
textThe message for the window
buttonsstring contains semi-colon seperated list of button text
default_buttonindex (from 0) of button that is default button or -1 if there is not a default button
cancel_buttonindex (from 0) of button that is cancel button or -1 if there is not a cancel button
button_widthwidth of buttons (default 200 OS units)

Member Function Documentation

◆ close_command()

void tbx::TextDisplayWindow::close_command ( tbx::Command close_command,
bool  delete_command = false 
)

Set command to be run when message window is closed.

Closing includes using the close button or clicking outside it if it has been shown as a menu

Parameters
close_commandcommand to run on close
delete_close_commanddelete the close command when the window is deleted

◆ delete_on_hide()

void tbx::TextDisplayWindow::delete_on_hide ( )

Set up text display window to delete itself when it is hidden.

The text display window should have been created using new.

◆ show()

void tbx::TextDisplayWindow::show ( )

Show the text display window.

The size of the message is calculated and the window resized and gadgets moved accordingly at this point.

◆ show_as_menu()

void tbx::TextDisplayWindow::show_as_menu ( )

Show the text display window as a menu.

When shown as a menu clicking outside of the window will close it.

The size of the message is calculated and the window resized and gadgets moved accordingly at this point.

◆ title()

void tbx::TextDisplayWindow::title ( const std::string &  new_title)

Set the title for the text display window.

Parameters
new_titleNew caption for the text display window

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