1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: wxProgressDialog class
4 // Author: Karsten Ballueder
5 // Modified by: Francesco Montorsi
8 // Copyright: (c) Karsten Ballueder
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef __PROGDLGH_G__
13 #define __PROGDLGH_G__
16 #include "wx/progdlg.h"
20 #include "wx/dialog.h"
22 class WXDLLIMPEXP_FWD_CORE wxButton
;
23 class WXDLLIMPEXP_FWD_CORE wxGauge
;
24 class WXDLLIMPEXP_FWD_CORE wxStaticText
;
27 Progress dialog which shows a moving progress bar.
28 Taken from the Mahogany project.
30 class WXDLLIMPEXP_CORE wxProgressDialog
: public wxDialog
33 wxProgressDialog(const wxString
& title
, const wxString
& message
,
35 wxWindow
*parent
= NULL
,
36 int style
= wxPD_APP_MODAL
| wxPD_AUTO_HIDE
);
38 virtual ~wxProgressDialog();
40 virtual bool Update(int value
, const wxString
& newmsg
= wxEmptyString
, bool *skip
= NULL
);
41 virtual bool Pulse(const wxString
& newmsg
= wxEmptyString
, bool *skip
= NULL
);
47 wxString
GetMessage() const;
49 void SetRange(int maximum
);
51 // Return whether "Cancel" or "Skip" button was pressed, always return
52 // false if the corresponding button is not shown.
53 bool WasCancelled() const;
54 bool WasSkipped() const;
56 // Must provide overload to avoid hiding it (and warnings about it)
57 virtual void Update() { wxDialog::Update(); }
59 virtual bool Show( bool show
= true );
62 // callback for optional abort button
63 void OnCancel(wxCommandEvent
&);
65 // callback for optional skip button
66 void OnSkip(wxCommandEvent
&);
68 // callback to disable "hard" window closing
69 void OnClose(wxCloseEvent
&);
71 // must be called to reenable the other windows temporarily disabled while
72 // the dialog was shown
73 void ReenableOtherWindows();
76 // create the label with given text and another one to show the time nearby
77 // as the next windows in the sizer, returns the created control
78 wxStaticText
*CreateLabel(const wxString
& text
, wxSizer
*sizer
);
80 // updates the label message
81 void UpdateMessage(const wxString
&newmsg
);
83 // common part of Update() and Pulse(), returns true if not cancelled
84 bool DoBeforeUpdate(bool *skip
);
86 // common part of Update() and Pulse()
89 // shortcuts for enabling buttons
91 void EnableSkip(bool enable
= true);
92 void EnableAbort(bool enable
= true);
93 void DisableSkip() { EnableSkip(false); }
94 void DisableAbort() { EnableAbort(false); }
96 // the widget displaying current status (may be NULL)
98 // the message displayed
100 // displayed elapsed, estimated, remaining time
101 wxStaticText
*m_elapsed
,
104 // time when the dialog was created
105 unsigned long m_timeStart
;
106 // time when the dialog was closed or cancelled
107 unsigned long m_timeStop
;
108 // time between the moment the dialog was closed/cancelled and resume
109 unsigned long m_break
;
111 // parent top level window (may be NULL)
112 wxWindow
*m_parentTop
;
114 // continue processing or not (return value for Update())
117 Uncancelable
= -1, // dialog can't be canceled
118 Canceled
, // can be cancelled and, in fact, was
119 Continue
, // can be cancelled but wasn't
120 Finished
// finished, waiting to be removed from screen
126 #if !defined(__SMARTPHONE__)
127 // the abort and skip buttons (or NULL if none)
128 wxButton
*m_btnAbort
;
135 // saves the time when elapsed time was updated so there is only one
137 unsigned long m_last_timeupdate
;
138 // tells how often a change of the estimated time has to be confirmed
139 // before it is actually displayed - this reduces the frequence of updates
140 // of estimated and remaining time
142 // counts the confirmations
144 unsigned long m_display_estimated
;
146 bool m_hasAbortButton
,
149 #if defined(__WXMSW__ ) || defined(__WXPM__)
150 // the factor we use to always keep the value in 16 bit range as the native
151 // control only supports ranges from 0 to 65,535
155 // for wxPD_APP_MODAL case
156 class WXDLLIMPEXP_FWD_CORE wxWindowDisabler
*m_winDisabler
;
158 DECLARE_EVENT_TABLE()
159 DECLARE_DYNAMIC_CLASS(wxProgressDialog
)
160 wxDECLARE_NO_COPY_CLASS(wxProgressDialog
);
163 #endif // wxUSE_PROGRESSDLG
165 #endif // __PROGDLGH_G__