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 WXDLLIMPEXP_CORE 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
, const wxString
& 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 @return 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 virtual bool Show( bool show
= true );
66 /* Can be called to continue after the cancel button has been pressed, but
67 the program decided to continue the operation (e.g., user didn't
74 wxString
GetMessage() const;
77 // callback for optional abort button
78 void OnCancel(wxCommandEvent
&);
80 // callback for optional skip button
81 void OnSkip(wxCommandEvent
&);
83 // callback to disable "hard" window closing
84 void OnClose(wxCloseEvent
&);
86 // must be called to reenable the other windows temporarily disabled while
87 // the dialog was shown
88 void ReenableOtherWindows();
91 // create the label with given text and another one to show the time nearby
92 // as the next windows in the sizer, returns the created control
93 wxStaticText
*CreateLabel(const wxString
& text
, wxSizer
*sizer
);
95 // updates the label message
96 void UpdateMessage(const wxString
&newmsg
);
98 // common part of Update() and Pulse(), returns true if not cancelled
99 bool DoAfterUpdate(bool *skip
);
101 // shortcuts for enabling buttons
103 void EnableSkip(bool enable
= true);
104 void EnableAbort(bool enable
= true);
105 void DisableSkip() { EnableSkip(false); }
106 void DisableAbort() { EnableAbort(false); }
108 // the widget displaying current status (may be NULL)
110 // the message displayed
112 // displayed elapsed, estimated, remaining time
113 wxStaticText
*m_elapsed
,
116 // time when the dialog was created
117 unsigned long m_timeStart
;
118 // time when the dialog was closed or cancelled
119 unsigned long m_timeStop
;
120 // time between the moment the dialog was closed/cancelled and resume
121 unsigned long m_break
;
123 // parent top level window (may be NULL)
124 wxWindow
*m_parentTop
;
126 // continue processing or not (return value for Update())
129 Uncancelable
= -1, // dialog can't be canceled
130 Canceled
, // can be cancelled and, in fact, was
131 Continue
, // can be cancelled but wasn't
132 Finished
// finished, waiting to be removed from screen
138 #if !defined(__SMARTPHONE__)
139 // the abort and skip buttons (or NULL if none)
140 wxButton
*m_btnAbort
;
147 // saves the time when elapsed time was updated so there is only one
149 unsigned long m_last_timeupdate
;
150 // tells how often a change of the estimated time has to be confirmed
151 // before it is actually displayed - this reduces the frequence of updates
152 // of estimated and remaining time
154 // counts the confirmations
156 unsigned long m_display_estimated
;
158 bool m_hasAbortButton
,
161 #if defined(__WXMSW__ ) || defined(__WXPM__)
162 // the factor we use to always keep the value in 16 bit range as the native
163 // control only supports ranges from 0 to 65,535
167 // for wxPD_APP_MODAL case
168 class WXDLLIMPEXP_FWD_CORE wxWindowDisabler
*m_winDisabler
;
170 DECLARE_EVENT_TABLE()
171 wxDECLARE_NO_COPY_CLASS(wxProgressDialog
);
174 #endif // wxUSE_PROGRESSDLG
176 #endif // __PROGDLGH_G__