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

A dialog emulates a modal window that blocks the user-interface. More...

#include <Wt/Ext/Dialog>

Inheritance diagram for Wt::Ext::Dialog:

Inheritance graph
[legend]

List of all members.

Public Types

enum  DialogCode { Rejected, Accepted }
 The result of a modal dialog execution. More...

Public Member Functions

 Dialog (const WString &windowTitle=WString())
 Construct a Dialog with a given window title.
 ~Dialog ()
 Destruct a Dialog.
void setWindowTitle (const WString &windowTitle)
 Set the dialog window title.
const WStringwindowTitle () const
 Get the dialog window title.
WContainerWidgetcontents () const
 Get the dialog contents container.
DialogCode exec ()
 Execute the dialog in a recursive event loop.
virtual void done (DialogCode r)
 Stop a recursive event loop.
virtual void accept ()
 Stop a recursive event loop with result Accepted.
virtual void reject ()
 Stop a recursive event loop with result Rejected.
DialogCode result () const
 Get the result that was set for this dialog.
virtual void setHidden (bool hidden)
 Set whether the widget must be hidden.
void addButton (Button *button)
 Add a button at the bottom of this dialog.
void removeButton (Button *button)
 Remove a button from the bottom of this dialog.
const std::vector< Button * > & buttons () const
 Get the list of buttons at the bottom of this dialog.
void setDefaultButton (Button *button)
 Configure a default button for this dialog.
ButtondefaultButton () const
 Get the default button for this dialog.
void setSizeGripEnabled (bool enabled)
 Configure a size grip to allow the user to resize this dialog.
bool isSizeGripEnabled () const
 Return if the size grip is enabled.

Public Attributes

Signal< DialogCodefinished
 Signal emitted when the recursive event loop is ended.


Detailed Description

A dialog emulates a modal window that blocks the user-interface.

A modal window blocks the user interface, and does not allow the user to interact with any other part of the user interface until the dialog is closed.

There are two ways for using a Dialog window.

The easiest way is using the exec() method: after creating a Dialog window, call the exec() method which blocks until the dialog window is closed, and returns the dialog result. Typically, an OK button will be connected to the accept() slot, and a Cancel button to the reject() slot. This solution has the drawback that it is not scalable to many concurrent sessions, since every recursive event loop (which is running during the exec() method) locks a thread. Therefore it is only suitable for software that doesn't need to scale (to thousands of users).

A second way is by treating the Dialog as another widget. The Dialog is created with the proper content, and for example an OK button is connected to a method which deletes the dialog. Unlike other widgets, a dialog is hidden by default. You must use the method show() or setHidden(true) to show the dialog. Using Dialog in this way doesn't lock up a thread.

Since Dialog is a Panel, the dialog contents may be layed out inside the dialog using layout managers. To be compatible with WDialog howevere, a contents() method is provided which creates a WFitLayout that fits a single WContainerWidget widget inside the dialog.

Only one Dialog window may exist at any time in a single application. An attempt to instantiate a second dialog will result in undefined behaviour.

The API is a superset of the WDialog API:

In addition, unlike WDialog, an Ext dialog may be dragged by the user.

ExtDialog-1.png

An example Dialog using BorderLayouts


Member Enumeration Documentation

The result of a modal dialog execution.

Enumerator:
Rejected  Dialog closed with reject().
Accepted  Dialog closed with accept().


Constructor & Destructor Documentation

Wt::Ext::Dialog::Dialog ( const WString windowTitle = WString()  ) 

Construct a Dialog with a given window title.

Only a single Dialog may be constructed at any time. Unlike other widgets, a dialog should not need be added to a container widget to be displayed.


Member Function Documentation

void Wt::Ext::Dialog::setWindowTitle ( const WString windowTitle  ) 

Set the dialog window title.

Is the same as Panel::setTitle(const WString&)

const WString& Wt::Ext::Dialog::windowTitle (  )  const [inline]

Get the dialog window title.

Is the same as Panel::title()

WContainerWidget * Wt::Ext::Dialog::contents (  )  const

Get the dialog contents container.

The first invocation to this method creates a single WContainerWidget that is fitted in the panel content area, like this:

      WContainerWidget *contents = new WContainerWidget();
      dialog->setLayout(new WFitLayout());
      dialog->layout()->addWidget(contents);

Dialog::DialogCode Wt::Ext::Dialog::exec (  ) 

Execute the dialog in a recursive event loop.

Executes the dialog. This blocks the current thread of execution until one of done(DialogCode), accept() or reject() is called.

Warning: using exec() does not scale to many concurrent sessions, since the thread is locked.

See also:
done(DialogCode r), accept(), reject()

void Wt::Ext::Dialog::done ( DialogCode  r  )  [virtual]

Stop a recursive event loop.

Sets the dialog result, and ends a recursive event loop that was started using the exec() method.

void Wt::Ext::Dialog::accept (  )  [virtual]

Stop a recursive event loop with result Accepted.

See also:
done(DialogCode), reject()

void Wt::Ext::Dialog::reject (  )  [virtual]

Stop a recursive event loop with result Rejected.

See also:
done(DialogCode), accept()

DialogCode Wt::Ext::Dialog::result (  )  const [inline]

Get the result that was set for this dialog.

See also:
done(DialogCode)

void Wt::Ext::Dialog::setHidden ( bool   )  [virtual]

Set whether the widget must be hidden.

Hide or show the widget (including all its descendant widgets). setHidden(false) will show this widget and all child widgets that are not hidden.

See also:
hide(), show()

Reimplemented from Wt::Ext::Widget.

Reimplemented in Wt::Ext::MessageBox.

void Wt::Ext::Dialog::addButton ( Button button  ) 

Add a button at the bottom of this dialog.

Is the same as Panel::addFooterButton()

void Wt::Ext::Dialog::removeButton ( Button button  ) 

Remove a button from the bottom of this dialog.

The button must have been previously added using addButton(). Is the same as Panel::removeFooterButton()

const std::vector<Button *>& Wt::Ext::Dialog::buttons (  )  const [inline]

Get the list of buttons at the bottom of this dialog.

Is the same as Panel::footerButtons()

Reimplemented in Wt::Ext::MessageBox.

void Wt::Ext::Dialog::setDefaultButton ( Button button  ) 

Configure a default button for this dialog.

The button must have been previously added using addButton(). A default button is activated when the user presses Return in the dialog.

See also:
Button::setDefault()

Reimplemented from Wt::Ext::Panel.

Button * Wt::Ext::Dialog::defaultButton (  )  const

Get the default button for this dialog.

See also:
setDefaultButton(), Button::isDefault()

Reimplemented from Wt::Ext::Panel.

void Wt::Ext::Dialog::setSizeGripEnabled ( bool  enabled  ) 

Configure a size grip to allow the user to resize this dialog.

When a size grip is enabled, then the user may resize the dialog window.

The default is true.

bool Wt::Ext::Dialog::isSizeGripEnabled (  )  const [inline]

Return if the size grip is enabled.

See also:
setSizeGripEnabled()


Member Data Documentation

Signal emitted when the recursive event loop is ended.

See also:
done(DialogCode), accept(), reject()


Generated on Mon Jan 26 14:14:14 2009 for Wt by doxygen 1.5.6