1 ////////////////////////////////////////////////////
3 // Purpose: wxProgressDialog class
4 // Author: Karsten Ballüder
8 // Copyright: (c) Karsten Ballüder
9 // Licence: wxWindows licence
10 ////////////////////////////////////////////////////
12 #ifndef __PROGDLGH_G__
13 #define __PROGDLGH_G__
19 #include "wx/dialog.h"
21 class WXDLLEXPORT wxButton
;
22 class WXDLLEXPORT wxGauge
;
23 class WXDLLEXPORT wxStaticText
;
25 /* Progress dialog which shows a moving progress bar.
26 Taken from the Mahogany project.*/
28 class WXDLLEXPORT wxProgressDialog
: public wxDialog
30 DECLARE_DYNAMIC_CLASS(wxProgressDialog
)
32 /* Creates and displays dialog, disables event handling for other
33 frames or parent frame to avoid recursion problems.
34 @param title title for window
35 @param message message to display in window
36 @param maximum value for status bar, if <= 0, no bar is shown
37 @param parent window or NULL
38 @param style is the bit mask of wxPD_XXX constants from wx/defs.h
40 wxProgressDialog(const wxString
&title
, wxString
const &message
,
42 wxWindow
*parent
= NULL
,
43 int style
= wxPD_APP_MODAL
| wxPD_AUTO_HIDE
);
45 Re-enables event handling for other windows.
49 /* Update the status bar to the new value.
50 @param value new value
51 @param newmsg if used, new message to display
52 @returns true if ABORT button has not been pressed
54 virtual bool Update(int value
, const wxString
& newmsg
= wxEmptyString
, bool *skip
= NULL
);
55 // Must provide overload to avoid hiding it (and warnings about it)
56 virtual void Update() { wxDialog::Update(); }
58 /* Can be called to continue after the cancel button has been pressed, but
59 the program decided to continue the operation (e.g., user didn't
64 virtual bool Show( bool show
= true );
67 // callback for optional abort button
68 void OnCancel(wxCommandEvent
& event
);
70 // callback for optional skip button
71 void OnSkip(wxCommandEvent
& event
);
73 // callback to disable "hard" window closing
74 void OnClose(wxCloseEvent
& event
);
76 // must be called to reenable the other windows temporarily disabled while
77 // the dialog was shown
78 void ReenableOtherWindows();
81 // create the label with given text and another one to show the time nearby
82 // as the next windows in the sizer, returns the created control
83 wxStaticText
*CreateLabel(const wxString
& text
, wxSizer
*sizer
);
85 // shortcuts for enabling buttons
87 void EnableSkip(bool enable
=true);
88 void EnableAbort(bool enable
=true);
89 inline void DisableSkip() { EnableSkip(false); }
90 inline void DisableAbort() { EnableAbort(false); }
94 // the message displayed
96 // displayed elapsed, estimated, remaining time
97 class wxStaticText
*m_elapsed
,
100 // time when the dialog was created
101 unsigned long m_timeStart
;
102 // time when the dialog was closed or cancelled
103 unsigned long m_timeStop
;
104 // time between the moment the dialog was closed/cancelled and resume
105 unsigned long m_break
;
107 // parent top level window (may be NULL)
108 wxWindow
*m_parentTop
;
110 // continue processing or not (return value for Update())
113 Uncancelable
= -1, // dialog can't be canceled
114 Canceled
, // can be cancelled and, in fact, was
115 Continue
, // can be cancelled but wasn't
116 Finished
// finished, waiting to be removed from screen
122 #if !defined(__SMARTPHONE__)
123 // the abort and skip buttons (or NULL if none)
124 wxButton
*m_btnAbort
;
131 // saves the time when elapsed time was updated so there is only one
133 unsigned long m_last_timeupdate
;
134 // tells how often a change of the estimated time has to be confirmed
135 // before it is actually displayed - this reduces the frequence of updates
136 // of estimated and remaining time
138 // counts the confirmations
140 unsigned long m_display_estimated
;
142 bool m_hasAbortButton
,
145 #if defined(__WXMSW__ ) || defined(__WXPM__)
146 // the factor we use to always keep the value in 16 bit range as the native
147 // control only supports ranges from 0 to 65,535
151 // for wxPD_APP_MODAL case
152 class WXDLLEXPORT wxWindowDisabler
*m_winDisabler
;
154 DECLARE_EVENT_TABLE()
155 DECLARE_NO_COPY_CLASS(wxProgressDialog
)
158 #endif // wxUSE_PROGRESSDLG
160 #endif // __PROGDLGH_G__