Wt: Wt::Ext::ProgressDialog Class Reference

Wt 3.3.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Hierarchy
- Class Members

Public Member Functions
Wt::Ext::ProgressDialog Class Reference
Ext widgets (Wt::Ext, deprecated)

A standard dialog to inform the user of progress during a time consuming task. More...

`#include <Wt/Ext/ProgressDialog>`

Inheritance diagram for Wt::Ext::ProgressDialog:
[legend]

List of all members.

## Public Member Functions
| ProgressDialog (bool i18n=false)
| Create a new progress dialog.
| ProgressDialog (const WString &text, const WString &cancelButtonText, int minimum, int maximum, bool i18n=false)
| Create a new progress dialog.
void | setMinimum (int minimum)
| Set the minimum value.
int | minimum () const
| Return the minimum value.
void | setMaximum (int maximum)
| Set the maximum value.
int | maximum () const
| Return the maximum value.
void | setRange (int minimum, int maximum)
| Define the range.
void | cancel ()
| Cancel the dialog.
void | reset ()
| Reset the dialog.
void | setCancelButtonText (const WString &text)
| Set the text used for the cancel button.
void | setValue (int progress)
| Set the current value (in the range from minimum() to maximum()).
int | value () const
| Return the current value.
bool | wasCanceled () const
| Return if the progress dialog was cancelled.
Signal & | canceled ()
| Signal emitted when the user cancels the dialog.

## Detailed Description

A standard dialog to inform the user of progress during a time consuming task.

A progress bar is shown to show progress from minimum() to maximum(), with the current value within (this range) set using setValue(). When the user cancels the dialog, the dialog is hidden and the canceled() signal is emitted.

The progress dialog may be used in two ways.

The easiest way is using a code snippet like this:

     Wt::Ext::ProgressDialog progress("Converting contact details...", "Cancel", 0, contacts_.size());
     progress.setWindowTitle("Import Contacts");

     for (unsigned i = 0; i < contacts_.size(); ++i) {
       progress.setValue(i);

       Wt::WApplication::instance()->processEvents();

       if (!progress.wasCanceled()) {
         convertContactDetails(contacts_[i]);
       } else {
         Wt::Ext::MessageBox::show("Operation cancelled",
                   "You may import your contact details any time later.", Ok);
         break;
       }
     }

Using this approach, WApplication::processEvents() is used to synchronize the server and client state. This approach has the drawback that browser interactivity is limited.

The more involved approach involves the use of WTimer to update the progress in conjunction with a worker thread to do the actual work.

Example of a ProgressDialog

## Constructor & Destructor Documentation

Wt::Ext::ProgressDialog::ProgressDialog | ( | bool | i18n = `false` | ) |

Create a new progress dialog.

Creates a new dialog, with window title 'Progress...', no message, and a Cancel button. The progress range is defined from 0 to 100.

Wt::Ext::ProgressDialog::ProgressDialog | ( | const WString & | text,
|  | const WString & | cancelButtonText,
|  | int | minimum,
|  | int | maximum,
|  | bool | i18n = `false`
| ) |  |

Create a new progress dialog.

Creates a new dialog, with window title 'Progress...', the given message, and a Cancel button. The progress range is defined from minimum to maximum

## Member Function Documentation

void Wt::Ext::ProgressDialog::cancel | ( |  | ) |

Cancel the dialog.

Sets the state to cancelled, and hides the dialog. Calling this method does not emit the canceled signal.

Signal& Wt::Ext::ProgressDialog::canceled | ( |  | ) |

Signal emitted when the user cancels the dialog.

When the user cancels the dialog, the dialog is hidden, and the state is set to being cancelled.

See also:
  wasCanceled()

void Wt::Ext::ProgressDialog::reset | ( |  | ) |

Reset the dialog.

The value is reset to the minimum(), and the cancelled state is cleared.

bool Wt::Ext::ProgressDialog::wasCanceled | ( |  | ) | const

Return if the progress dialog was cancelled.

See also:
  canceled, cancel()

All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator