]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/progdlgg.h
Applied wxGauge:Pulse() patch.
[wxWidgets.git] / include / wx / generic / progdlgg.h
1 ////////////////////////////////////////////////////
2 // Name: progdlgg.h
3 // Purpose: wxProgressDialog class
4 // Author: Karsten Ballüder
5 // Modified by:
6 // Created: 09.05.1999
7 // RCS-ID: $Id$
8 // Copyright: (c) Karsten Ballüder
9 // Licence: wxWindows licence
10 ////////////////////////////////////////////////////
11
12 #ifndef __PROGDLGH_G__
13 #define __PROGDLGH_G__
14
15 #include "wx/defs.h"
16 #include "wx/progdlg.h"
17
18 #if wxUSE_PROGRESSDLG
19
20 #include "wx/dialog.h"
21
22 class WXDLLEXPORT wxButton;
23 class WXDLLEXPORT wxGauge;
24 class WXDLLEXPORT wxStaticText;
25
26 /* Progress dialog which shows a moving progress bar.
27 Taken from the Mahogany project.*/
28
29 class WXDLLEXPORT wxProgressDialog : public wxDialog
30 {
31 DECLARE_DYNAMIC_CLASS(wxProgressDialog)
32 public:
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
40 */
41 wxProgressDialog(const wxString &title, wxString const &message,
42 int maximum = 100,
43 wxWindow *parent = NULL,
44 int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
45 /* Destructor.
46 Re-enables event handling for other windows.
47 */
48 virtual ~wxProgressDialog();
49
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
54 */
55 virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL);
56
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 UpdatePulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
60
61 // Must provide overload to avoid hiding it (and warnings about it)
62 virtual void Update() { wxDialog::Update(); }
63
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
66 confirm it)
67 */
68 void Resume();
69
70 virtual bool Show( bool show = true );
71
72 protected:
73 // callback for optional abort button
74 void OnCancel(wxCommandEvent& event);
75
76 // callback for optional skip button
77 void OnSkip(wxCommandEvent& event);
78
79 // callback to disable "hard" window closing
80 void OnClose(wxCloseEvent& event);
81
82 // must be called to reenable the other windows temporarily disabled while
83 // the dialog was shown
84 void ReenableOtherWindows();
85
86 private:
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);
90
91 // updates the label message
92 void UpdateMessage(const wxString &newmsg);
93
94 // shortcuts for enabling buttons
95 void EnableClose();
96 void EnableSkip(bool enable=true);
97 void EnableAbort(bool enable=true);
98 inline void DisableSkip() { EnableSkip(false); }
99 inline void DisableAbort() { EnableAbort(false); }
100
101 // the status bar
102 wxGauge *m_gauge;
103 // the message displayed
104 wxStaticText *m_msg;
105 // displayed elapsed, estimated, remaining time
106 class wxStaticText *m_elapsed,
107 *m_estimated,
108 *m_remaining;
109 // time when the dialog was created
110 unsigned long m_timeStart;
111 // time when the dialog was closed or cancelled
112 unsigned long m_timeStop;
113 // time between the moment the dialog was closed/cancelled and resume
114 unsigned long m_break;
115
116 // parent top level window (may be NULL)
117 wxWindow *m_parentTop;
118
119 // continue processing or not (return value for Update())
120 enum
121 {
122 Uncancelable = -1, // dialog can't be canceled
123 Canceled, // can be cancelled and, in fact, was
124 Continue, // can be cancelled but wasn't
125 Finished // finished, waiting to be removed from screen
126 } m_state;
127
128 // skip some portion
129 bool m_skip;
130
131 #if !defined(__SMARTPHONE__)
132 // the abort and skip buttons (or NULL if none)
133 wxButton *m_btnAbort;
134 wxButton *m_btnSkip;
135 #endif
136
137 // the maximum value
138 int m_maximum;
139
140 // saves the time when elapsed time was updated so there is only one
141 // update per second
142 unsigned long m_last_timeupdate;
143 // tells how often a change of the estimated time has to be confirmed
144 // before it is actually displayed - this reduces the frequence of updates
145 // of estimated and remaining time
146 const int m_delay;
147 // counts the confirmations
148 int m_ctdelay;
149 unsigned long m_display_estimated;
150
151 bool m_hasAbortButton,
152 m_hasSkipButton;
153
154 #if defined(__WXMSW__ ) || defined(__WXPM__)
155 // the factor we use to always keep the value in 16 bit range as the native
156 // control only supports ranges from 0 to 65,535
157 size_t m_factor;
158 #endif // __WXMSW__
159
160 // for wxPD_APP_MODAL case
161 class WXDLLEXPORT wxWindowDisabler *m_winDisabler;
162
163 DECLARE_EVENT_TABLE()
164 DECLARE_NO_COPY_CLASS(wxProgressDialog)
165 };
166
167 #endif // wxUSE_PROGRESSDLG
168
169 #endif // __PROGDLGH_G__