Wt::Ext::MessageBox Class Reference
[Ext widgets]

A standard dialog for confirmation or to get simple user input. More...

#include <Wt/Ext/MessageBox>

Inherits Wt::Ext::Dialog.

Inherited by Wt::Ext::ProgressDialog.

List of all members.

Public Member Functions

 MessageBox (bool i18n=false)
 Create an empty message box.
 MessageBox (const WString &caption, const WString &text, Icon icon, WFlags< StandardButton > buttons, bool i18n=false)
 Create a message box with given caption, text, icon, and buttons.
void setText (const WString &text)
 Set the text for the message box.
const WStringtext () const
 Get the message box text.
void setIcon (Icon icon)
 Set the icon.
Icon icon () const
 Get the icon.
void setButtons (WFlags< StandardButton > buttons)
 Set standard buttons for the message box.
WFlags< StandardButtonbuttons () const
 Get the standard buttons.
StandardButton result ()
 Get the result of this message box.
void enablePrompt (bool enable)
 Show a single-line input field.
bool hasPrompt () const
 Return if the messagebox may show a prompt.
void enableTextArea (bool enable)
 Show a multi-line input field.
bool hasTextArea () const
 Return if the messagebox may show a prompt.
void setValue (const WString &value)
 Set the value in the input field.
const WStringvalue () const
 Get the value of the input field.
Signal< StandardButton > & buttonClicked ()
 Signal emitted when a button is clicked.
virtual void setHidden (bool hidden)
 Show or hide the message box.
virtual void refresh ()
 Refresh the widget.

Static Public Member Functions

static StandardButton show (const WString &caption, const WString &text, WFlags< StandardButton > buttons, bool i18n=false)
 Convenience method to show a message box, blocking the current thread.
static StandardButton prompt (const WString &caption, const WString &text, WString &value, bool multiLine=false, bool i18n=false)
 Convenience method to show a message box prompting for input, blocking the current thread.

Detailed Description

A standard dialog for confirmation or to get simple user input.

The message box shows a message in a dialog window, with a number of buttons. These buttons may only be standard buttons.

There are two distinct ways for using a MessageBox, which reflect the two ways of dealing with a Dialog box.

The easiest way is using the static show() method, which shows a message box, blocks the current thread, and returns the button that was pressed by the user. Since this uses the Dialog::exec(), it suffers from the same scalability issues.

The more elaborate way is by creating a MessageBox, and connecting the buttonClicked signal to a method. This method then interpretes the result and deletes the message box.

The API is slightly different from the WMessageBox API:

ExtMessageBox-1.png

Example of a MessageBox


Constructor & Destructor Documentation

Wt::Ext::MessageBox::MessageBox ( bool  i18n = false  ) 

Create an empty message box.

The button labels may be set fixed English (if i18n = false), or fetched from a resource bundle if i18n = true. In that case, the key for each button is exactly the same as the English text.

Wt::Ext::MessageBox::MessageBox ( const WString caption,
const WString text,
Icon  icon,
WFlags< StandardButton buttons,
bool  i18n = false 
)

Create a message box with given caption, text, icon, and buttons.

The button labels may be set fixed English (if i18n = false), or fetched from a resource bundle if i18n = true. In that case, the key for each button is exactly the same as the English text.


Member Function Documentation

void Wt::Ext::MessageBox::enablePrompt ( bool  enable  ) 

Show a single-line input field.

A message box may contain either a prompt, or a text area field, but not both. The value may be set using setValue() and retrieved using value().

See also:
enableTextArea(), setValue(), value()
void Wt::Ext::MessageBox::enableTextArea ( bool  enable  ) 

Show a multi-line input field.

A message box may contain either a prompt, or a text area field, but not both. The value may be set using setValue() and retrieved using value().

See also:
enablePrompt(), setValue(), value()
bool Wt::Ext::MessageBox::hasPrompt (  )  const [inline]

Return if the messagebox may show a prompt.

See also:
enablePrompt()
bool Wt::Ext::MessageBox::hasTextArea (  )  const [inline]

Return if the messagebox may show a prompt.

See also:
enableTextArea()
StandardButton Wt::Ext::MessageBox::prompt ( const WString caption,
const WString text,
WString value,
bool  multiLine = false,
bool  i18n = false 
) [static]

Convenience method to show a message box prompting for input, blocking the current thread.

Show a message box that prompts for input, blocking the current thread until the message box is closed, and return the result.

When the user confirmed message box, the value is updated with the edited value.

void Wt::Ext::MessageBox::refresh (  )  [virtual]

Refresh the widget.

The refresh method is invoked when the locale is changed using WApplication::setLocale() or when the user hit the refresh button.

The widget must actualize its contents in response.

Reimplemented from Wt::Ext::Panel.

StandardButton Wt::Ext::MessageBox::result (  )  [inline]

Get the result of this message box.

This value is only defined after a button has been clicked.

void Wt::Ext::MessageBox::setValue ( const WString value  ) 

Set the value in the input field.

See also:
enableTextArea(), enablePrompt()
StandardButton Wt::Ext::MessageBox::show ( const WString caption,
const WString text,
WFlags< StandardButton buttons,
bool  i18n = false 
) [static]

Convenience method to show a message box, blocking the current thread.

Show a message box, blocking the current thread until the message box is closed, and return the result.

const WString& Wt::Ext::MessageBox::value (  )  const [inline]

Get the value of the input field.

See also:
enableTextArea(), enablePrompt()

Reimplemented in Wt::Ext::ProgressDialog.


Generated on Thu May 13 05:16:19 2010 for Wt by doxygen 1.6.3