1999-07-28 17:01:04 -04:00
|
|
|
////////////////////////////////////////////////////
|
1999-05-09 11:19:45 -04:00
|
|
|
// Name: progdlgg.h
|
|
|
|
// Purpose: wxProgressDialog class
|
2007-12-03 17:09:26 -05:00
|
|
|
// Author: Karsten Ballueder
|
1999-05-09 11:19:45 -04:00
|
|
|
// Modified by:
|
|
|
|
// Created: 09.05.1999
|
|
|
|
// RCS-ID: $Id$
|
2007-12-03 17:09:26 -05:00
|
|
|
// Copyright: (c) Karsten Ballueder
|
2004-05-23 16:53:33 -04:00
|
|
|
// Licence: wxWindows licence
|
1999-07-28 17:01:04 -04:00
|
|
|
////////////////////////////////////////////////////
|
1999-05-09 11:19:45 -04:00
|
|
|
|
|
|
|
#ifndef __PROGDLGH_G__
|
|
|
|
#define __PROGDLGH_G__
|
|
|
|
|
2004-12-30 10:07:28 -05:00
|
|
|
#include "wx/defs.h"
|
2006-09-09 09:36:54 -04:00
|
|
|
#include "wx/progdlg.h"
|
1999-05-09 11:19:45 -04:00
|
|
|
|
1999-06-15 16:21:59 -04:00
|
|
|
#if wxUSE_PROGRESSDLG
|
1999-05-09 11:19:45 -04:00
|
|
|
|
1999-07-28 17:01:04 -04:00
|
|
|
#include "wx/dialog.h"
|
1999-05-09 11:19:45 -04:00
|
|
|
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxButton;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxGauge;
|
|
|
|
class WXDLLIMPEXP_FWD_CORE wxStaticText;
|
1999-07-28 17:01:04 -04:00
|
|
|
|
|
|
|
/* Progress dialog which shows a moving progress bar.
|
1999-05-09 11:19:45 -04:00
|
|
|
Taken from the Mahogany project.*/
|
|
|
|
|
2008-03-26 11:06:00 -04:00
|
|
|
class WXDLLIMPEXP_CORE wxProgressDialog : public wxDialog
|
1999-05-09 11:19:45 -04:00
|
|
|
{
|
|
|
|
DECLARE_DYNAMIC_CLASS(wxProgressDialog)
|
|
|
|
public:
|
2008-01-06 10:05:57 -05:00
|
|
|
/* Creates and displays dialog, disables event handling for other
|
1999-05-09 11:19:45 -04:00
|
|
|
frames or parent frame to avoid recursion problems.
|
|
|
|
@param title title for window
|
|
|
|
@param message message to display in window
|
1999-05-27 08:49:40 -04:00
|
|
|
@param maximum value for status bar, if <= 0, no bar is shown
|
1999-05-09 11:19:45 -04:00
|
|
|
@param parent window or NULL
|
1999-05-27 08:49:40 -04:00
|
|
|
@param style is the bit mask of wxPD_XXX constants from wx/defs.h
|
2008-01-06 10:05:57 -05:00
|
|
|
*/
|
|
|
|
wxProgressDialog(const wxString& title, const wxString& message,
|
|
|
|
int maximum = 100,
|
|
|
|
wxWindow *parent = NULL,
|
|
|
|
int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
|
|
|
|
/* Destructor.
|
|
|
|
Re-enables event handling for other windows.
|
|
|
|
*/
|
|
|
|
virtual ~wxProgressDialog();
|
|
|
|
|
|
|
|
/* Update the status bar to the new value.
|
1999-05-09 11:19:45 -04:00
|
|
|
@param value new value
|
|
|
|
@param newmsg if used, new message to display
|
2008-05-10 21:38:53 -04:00
|
|
|
@return true if ABORT button has not been pressed
|
2008-01-06 10:05:57 -05:00
|
|
|
*/
|
|
|
|
virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL);
|
2006-09-09 09:36:54 -04:00
|
|
|
|
|
|
|
/* Switches the dialog to use a gauge in indeterminate mode and calls
|
|
|
|
wxGauge::Pulse() to show to the user a bit of progress */
|
2006-10-22 17:08:11 -04:00
|
|
|
virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
|
2006-09-09 09:36:54 -04:00
|
|
|
|
2006-02-08 16:47:09 -05:00
|
|
|
// Must provide overload to avoid hiding it (and warnings about it)
|
|
|
|
virtual void Update() { wxDialog::Update(); }
|
1999-05-09 11:19:45 -04:00
|
|
|
|
2008-01-06 10:05:57 -05:00
|
|
|
/* Can be called to continue after the cancel button has been pressed, but
|
1999-05-09 11:19:45 -04:00
|
|
|
the program decided to continue the operation (e.g., user didn't
|
1999-05-27 09:22:37 -04:00
|
|
|
confirm it)
|
2008-01-06 10:05:57 -05:00
|
|
|
*/
|
|
|
|
void Resume();
|
1999-05-09 11:19:45 -04:00
|
|
|
|
2008-01-06 10:05:57 -05:00
|
|
|
virtual bool Show( bool show = true );
|
2002-12-16 05:57:48 -05:00
|
|
|
|
2000-10-07 17:34:35 -04:00
|
|
|
protected:
|
2008-01-06 10:05:57 -05:00
|
|
|
// callback for optional abort button
|
|
|
|
void OnCancel(wxCommandEvent&);
|
2000-10-07 17:34:35 -04:00
|
|
|
|
2008-01-06 10:05:57 -05:00
|
|
|
// callback for optional skip button
|
|
|
|
void OnSkip(wxCommandEvent&);
|
2004-12-30 10:07:28 -05:00
|
|
|
|
2008-01-06 10:05:57 -05:00
|
|
|
// callback to disable "hard" window closing
|
|
|
|
void OnClose(wxCloseEvent&);
|
1999-05-09 11:19:45 -04:00
|
|
|
|
2008-01-06 10:05:57 -05:00
|
|
|
// must be called to reenable the other windows temporarily disabled while
|
|
|
|
// the dialog was shown
|
|
|
|
void ReenableOtherWindows();
|
2000-10-07 17:34:35 -04:00
|
|
|
|
1999-05-09 11:19:45 -04:00
|
|
|
private:
|
2008-01-06 10:05:57 -05:00
|
|
|
// create the label with given text and another one to show the time nearby
|
|
|
|
// as the next windows in the sizer, returns the created control
|
|
|
|
wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer);
|
1999-07-28 17:01:04 -04:00
|
|
|
|
2006-09-09 09:36:54 -04:00
|
|
|
// updates the label message
|
2008-01-06 10:05:57 -05:00
|
|
|
void UpdateMessage(const wxString &newmsg);
|
|
|
|
|
|
|
|
// common part of Update() and Pulse(), returns true if not cancelled
|
|
|
|
bool DoAfterUpdate(bool *skip);
|
|
|
|
|
|
|
|
// shortcuts for enabling buttons
|
|
|
|
void EnableClose();
|
|
|
|
void EnableSkip(bool enable = true);
|
|
|
|
void EnableAbort(bool enable = true);
|
|
|
|
void DisableSkip() { EnableSkip(false); }
|
|
|
|
void DisableAbort() { EnableAbort(false); }
|
|
|
|
|
|
|
|
// the status bar
|
|
|
|
wxGauge *m_gauge;
|
|
|
|
// the message displayed
|
|
|
|
wxStaticText *m_msg;
|
|
|
|
// displayed elapsed, estimated, remaining time
|
|
|
|
wxStaticText *m_elapsed,
|
|
|
|
*m_estimated,
|
|
|
|
*m_remaining;
|
|
|
|
// time when the dialog was created
|
|
|
|
unsigned long m_timeStart;
|
|
|
|
// time when the dialog was closed or cancelled
|
|
|
|
unsigned long m_timeStop;
|
|
|
|
// time between the moment the dialog was closed/cancelled and resume
|
|
|
|
unsigned long m_break;
|
|
|
|
|
|
|
|
// parent top level window (may be NULL)
|
|
|
|
wxWindow *m_parentTop;
|
2000-02-24 21:20:44 -05:00
|
|
|
|
2005-01-05 13:37:42 -05:00
|
|
|
// continue processing or not (return value for Update())
|
|
|
|
enum
|
|
|
|
{
|
|
|
|
Uncancelable = -1, // dialog can't be canceled
|
|
|
|
Canceled, // can be cancelled and, in fact, was
|
|
|
|
Continue, // can be cancelled but wasn't
|
|
|
|
Finished // finished, waiting to be removed from screen
|
|
|
|
} m_state;
|
2000-03-11 19:26:21 -05:00
|
|
|
|
2005-01-05 13:37:42 -05:00
|
|
|
// skip some portion
|
|
|
|
bool m_skip;
|
2004-12-30 10:07:28 -05:00
|
|
|
|
|
|
|
#if !defined(__SMARTPHONE__)
|
2005-01-05 13:37:42 -05:00
|
|
|
// the abort and skip buttons (or NULL if none)
|
|
|
|
wxButton *m_btnAbort;
|
|
|
|
wxButton *m_btnSkip;
|
2004-12-30 10:07:28 -05:00
|
|
|
#endif
|
2000-03-11 19:26:21 -05:00
|
|
|
|
2005-01-05 13:37:42 -05:00
|
|
|
// the maximum value
|
|
|
|
int m_maximum;
|
|
|
|
|
|
|
|
// saves the time when elapsed time was updated so there is only one
|
|
|
|
// update per second
|
|
|
|
unsigned long m_last_timeupdate;
|
|
|
|
// tells how often a change of the estimated time has to be confirmed
|
|
|
|
// before it is actually displayed - this reduces the frequence of updates
|
|
|
|
// of estimated and remaining time
|
|
|
|
const int m_delay;
|
|
|
|
// counts the confirmations
|
|
|
|
int m_ctdelay;
|
|
|
|
unsigned long m_display_estimated;
|
1999-05-09 11:19:45 -04:00
|
|
|
|
2005-01-05 13:37:42 -05:00
|
|
|
bool m_hasAbortButton,
|
|
|
|
m_hasSkipButton;
|
2004-09-16 18:04:38 -04:00
|
|
|
|
2002-08-18 22:23:40 -04:00
|
|
|
#if defined(__WXMSW__ ) || defined(__WXPM__)
|
2005-01-05 13:37:42 -05:00
|
|
|
// the factor we use to always keep the value in 16 bit range as the native
|
|
|
|
// control only supports ranges from 0 to 65,535
|
|
|
|
size_t m_factor;
|
2001-12-21 21:14:38 -05:00
|
|
|
#endif // __WXMSW__
|
|
|
|
|
2005-01-05 13:37:42 -05:00
|
|
|
// for wxPD_APP_MODAL case
|
2007-07-09 06:09:52 -04:00
|
|
|
class WXDLLIMPEXP_FWD_CORE wxWindowDisabler *m_winDisabler;
|
2000-03-11 19:26:21 -05:00
|
|
|
|
2005-01-05 13:37:42 -05:00
|
|
|
DECLARE_EVENT_TABLE()
|
2003-01-02 18:38:11 -05:00
|
|
|
DECLARE_NO_COPY_CLASS(wxProgressDialog)
|
1999-05-09 11:19:45 -04:00
|
|
|
};
|
1999-06-15 16:21:59 -04:00
|
|
|
|
2004-12-31 02:08:11 -05:00
|
|
|
#endif // wxUSE_PROGRESSDLG
|
|
|
|
|
|
|
|
#endif // __PROGDLGH_G__
|