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
);
56 /* Can be called to continue after the cancel button has been pressed, but
57 the program decided to continue the operation (e.g., user didn't
62 virtual bool Show( bool show
= true );
65 // callback for optional abort button
66 void OnCancel(wxCommandEvent
& event
);
68 // callback for optional skip button
69 void OnSkip(wxCommandEvent
& event
);
71 // callback to disable "hard" window closing
72 void OnClose(wxCloseEvent
& event
);
74 // must be called to reenable the other windows temporarily disabled while
75 // the dialog was shown
76 void ReenableOtherWindows();
79 // create the label with given text and another one to show the time nearby
80 // as the next windows in the sizer, returns the created control
81 wxStaticText
*CreateLabel(const wxString
& text
, wxSizer
*sizer
);
83 // shortcuts for enabling buttons
85 void EnableSkip(bool enable
=true);
86 void EnableAbort(bool enable
=true);
87 inline void DisableSkip() { EnableSkip(false); }
88 inline void DisableAbort() { EnableAbort(false); }
92 // the message displayed
94 // displayed elapsed, estimated, remaining time
95 class wxStaticText
*m_elapsed
,
98 // time when the dialog was created
99 unsigned long m_timeStart
;
100 // time when the dialog was closed or cancelled
101 unsigned long m_timeStop
;
102 // time between the moment the dialog was closed/cancelled and resume
103 unsigned long m_break
;
105 // parent top level window (may be NULL)
106 wxWindow
*m_parentTop
;
108 // continue processing or not (return value for Update())
111 Uncancelable
= -1, // dialog can't be canceled
112 Canceled
, // can be cancelled and, in fact, was
113 Continue
, // can be cancelled but wasn't
114 Finished
// finished, waiting to be removed from screen
120 #if !defined(__SMARTPHONE__)
121 // the abort and skip buttons (or NULL if none)
122 wxButton
*m_btnAbort
;
129 // saves the time when elapsed time was updated so there is only one
131 unsigned long m_last_timeupdate
;
132 // tells how often a change of the estimated time has to be confirmed
133 // before it is actually displayed - this reduces the frequence of updates
134 // of estimated and remaining time
136 // counts the confirmations
138 unsigned long m_display_estimated
;
140 bool m_hasAbortButton
,
143 #if defined(__WXMSW__ ) || defined(__WXPM__)
144 // the factor we use to always keep the value in 16 bit range as the native
145 // control only supports ranges from 0 to 65,535
149 // for wxPD_APP_MODAL case
150 class WXDLLEXPORT wxWindowDisabler
*m_winDisabler
;
152 DECLARE_EVENT_TABLE()
154 // Virtual function hiding supression
155 virtual void Update() { wxDialog::Update(); }
157 DECLARE_NO_COPY_CLASS(wxProgressDialog
)
160 #endif // wxUSE_PROGRESSDLG
162 #endif // __PROGDLGH_G__