1 ////////////////////////////////////////////////////
3 // Purpose: wxProgressDialog class
4 // Author: Karsten Ballueder
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
;
26 /* Progress dialog which shows a moving progress bar.
27 Taken from the Mahogany project.*/
29 class WXDLLEXPORT wxProgressDialog
: public wxDialog
31 DECLARE_DYNAMIC_CLASS(wxProgressDialog
)
33 /* Creates and displays dialog, disables event handling for other
34 frames or parent frame to avoid recursion problems.
35 @param title title for window
36 @param message message to display in window
37 @param maximum value for status bar, if <= 0, no bar is shown
38 @param parent window or NULL
39 @param style is the bit mask of wxPD_XXX constants from wx/defs.h
41 wxProgressDialog(const wxString
&title
, wxString
const &message
,
43 wxWindow
*parent
= NULL
,
44 int style
= wxPD_APP_MODAL
| wxPD_AUTO_HIDE
);
46 Re-enables event handling for other windows.
48 virtual ~wxProgressDialog();
50 /* Update the status bar to the new value.
51 @param value new value
52 @param newmsg if used, new message to display
53 @returns true if ABORT button has not been pressed
55 virtual bool Update(int value
, const wxString
& newmsg
= wxEmptyString
, bool *skip
= NULL
);
57 /* Switches the dialog to use a gauge in indeterminate mode and calls
58 wxGauge::Pulse() to show to the user a bit of progress */
59 virtual bool Pulse(const wxString
& newmsg
= wxEmptyString
, bool *skip
= NULL
);
61 // Must provide overload to avoid hiding it (and warnings about it)
62 virtual void Update() { wxDialog::Update(); }
64 /* Can be called to continue after the cancel button has been pressed, but
65 the program decided to continue the operation (e.g., user didn't
70 virtual bool Show( bool show
= true );
73 // callback for optional abort button
74 void OnCancel(wxCommandEvent
& event
);
76 // callback for optional skip button
77 void OnSkip(wxCommandEvent
& event
);
79 // callback to disable "hard" window closing
80 void OnClose(wxCloseEvent
& event
);
82 // must be called to reenable the other windows temporarily disabled while
83 // the dialog was shown
84 void ReenableOtherWindows();
87 // create the label with given text and another one to show the time nearby
88 // as the next windows in the sizer, returns the created control
89 wxStaticText
*CreateLabel(const wxString
& text
, wxSizer
*sizer
);
91 // updates the label message
92 void UpdateMessage(const wxString
&newmsg
);
94 // common part of Update() and Pulse(), returns true if not cancelled
95 bool DoAfterUpdate(bool *skip
);
97 // shortcuts for enabling buttons
99 void EnableSkip(bool enable
=true);
100 void EnableAbort(bool enable
=true);
101 inline void DisableSkip() { EnableSkip(false); }
102 inline void DisableAbort() { EnableAbort(false); }
106 // the message displayed
108 // displayed elapsed, estimated, remaining time
109 class wxStaticText
*m_elapsed
,
112 // time when the dialog was created
113 unsigned long m_timeStart
;
114 // time when the dialog was closed or cancelled
115 unsigned long m_timeStop
;
116 // time between the moment the dialog was closed/cancelled and resume
117 unsigned long m_break
;
119 // parent top level window (may be NULL)
120 wxWindow
*m_parentTop
;
122 // continue processing or not (return value for Update())
125 Uncancelable
= -1, // dialog can't be canceled
126 Canceled
, // can be cancelled and, in fact, was
127 Continue
, // can be cancelled but wasn't
128 Finished
// finished, waiting to be removed from screen
134 #if !defined(__SMARTPHONE__)
135 // the abort and skip buttons (or NULL if none)
136 wxButton
*m_btnAbort
;
143 // saves the time when elapsed time was updated so there is only one
145 unsigned long m_last_timeupdate
;
146 // tells how often a change of the estimated time has to be confirmed
147 // before it is actually displayed - this reduces the frequence of updates
148 // of estimated and remaining time
150 // counts the confirmations
152 unsigned long m_display_estimated
;
154 bool m_hasAbortButton
,
157 #if defined(__WXMSW__ ) || defined(__WXPM__)
158 // the factor we use to always keep the value in 16 bit range as the native
159 // control only supports ranges from 0 to 65,535
163 // for wxPD_APP_MODAL case
164 class WXDLLIMPEXP_FWD_CORE wxWindowDisabler
*m_winDisabler
;
166 DECLARE_EVENT_TABLE()
167 DECLARE_NO_COPY_CLASS(wxProgressDialog
)
170 #endif // wxUSE_PROGRESSDLG
172 #endif // __PROGDLGH_G__