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

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:

Inheritance graph
[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
 Get the minimum value.
void setMaximum (int maximum)
 Set the maximum value.
int maximum () const
 Get 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
 Get the current value.
bool wasCanceled () const
 Return if the progress dialog was cancelled.

Public Attributes

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:

  //...

  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);

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

    if (!progress.wasCanceled()) {
      convertContactDetails(contacts_[i]);
    } else {
      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.

ExtProgressDialog-1.png

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.

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 [inline]

Return if the progress dialog was cancelled.

See also:
canceled, cancel()


Member Data Documentation

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()


Generated on Fri Apr 24 16:26:01 2009 for Wt by doxygen 1.5.6