]>
Commit | Line | Data |
---|---|---|
23324ae1 FM |
1 | ///////////////////////////////////////////////////////////////////////////// |
2 | // Name: progdlg.h | |
e54c96f1 | 3 | // Purpose: interface of wxProgressDialog |
23324ae1 FM |
4 | // Author: wxWidgets team |
5 | // RCS-ID: $Id$ | |
526954c5 | 6 | // Licence: wxWindows licence |
23324ae1 FM |
7 | ///////////////////////////////////////////////////////////////////////////// |
8 | ||
86381d42 RD |
9 | #define wxPD_CAN_ABORT 0x0001 |
10 | #define wxPD_APP_MODAL 0x0002 | |
11 | #define wxPD_AUTO_HIDE 0x0004 | |
12 | #define wxPD_ELAPSED_TIME 0x0008 | |
13 | #define wxPD_ESTIMATED_TIME 0x0010 | |
14 | #define wxPD_SMOOTH 0x0020 | |
15 | #define wxPD_REMAINING_TIME 0x0040 | |
16 | #define wxPD_CAN_SKIP 0x0080 | |
17 | ||
23324ae1 FM |
18 | /** |
19 | @class wxProgressDialog | |
7c913512 | 20 | |
23324ae1 | 21 | This class represents a dialog that shows a short message and a |
3a567740 | 22 | progress bar. Optionally, it can display ABORT and SKIP buttons, and |
23324ae1 | 23 | the elapsed, remaining and estimated time for the end of the progress. |
7c913512 | 24 | |
3a567740 FM |
25 | Note that you must be aware that wxProgressDialog internally calls |
26 | wxEventLoopBase::YieldFor with @c wxEVT_CATEGORY_UI and @c wxEVT_CATEGORY_USER_INPUT | |
27 | and this may cause unwanted re-entrancies or the out-of-order processing | |
28 | of pending events (to help preventing the last problem if you're using | |
29 | wxProgressDialog in a multi-threaded application you should be sure to use | |
30 | wxThreadEvent for your inter-threads communications). | |
31 | ||
23324ae1 | 32 | @beginStyleTable |
8c6791e4 | 33 | @style{wxPD_APP_MODAL} |
23324ae1 FM |
34 | Make the progress dialog modal. If this flag is not given, it is |
35 | only "locally" modal - that is the input to the parent window is | |
36 | disabled, but not to the other ones. | |
8c6791e4 | 37 | @style{wxPD_AUTO_HIDE} |
23324ae1 FM |
38 | Causes the progress dialog to disappear from screen as soon as the |
39 | maximum value of the progress meter has been reached. | |
8f139810 | 40 | If this style is not present, the dialog will become a modal dialog |
cc31a982 VZ |
41 | (see wxDialog::ShowModal) once the maximum value has been reached |
42 | and wait for the user to dismiss it. | |
8c6791e4 | 43 | @style{wxPD_SMOOTH} |
8f139810 FM |
44 | Causes smooth progress of the gauge control (uses a wxGauge with the |
45 | @c wxGA_SMOOTH style). | |
8c6791e4 | 46 | @style{wxPD_CAN_ABORT} |
23324ae1 FM |
47 | This flag tells the dialog that it should have a "Cancel" button |
48 | which the user may press. If this happens, the next call to | |
49 | Update() will return @false. | |
8c6791e4 | 50 | @style{wxPD_CAN_SKIP} |
23324ae1 FM |
51 | This flag tells the dialog that it should have a "Skip" button |
52 | which the user may press. If this happens, the next call to | |
53 | Update() will return @true in its skip parameter. | |
8c6791e4 | 54 | @style{wxPD_ELAPSED_TIME} |
23324ae1 FM |
55 | This flag tells the dialog that it should show elapsed time (since |
56 | creating the dialog). | |
8c6791e4 | 57 | @style{wxPD_ESTIMATED_TIME} |
23324ae1 | 58 | This flag tells the dialog that it should show estimated time. |
8c6791e4 | 59 | @style{wxPD_REMAINING_TIME} |
23324ae1 FM |
60 | This flag tells the dialog that it should show remaining time. |
61 | @endStyleTable | |
7c913512 | 62 | |
23324ae1 FM |
63 | @library{wxbase} |
64 | @category{cmndlg} | |
65 | */ | |
66 | class wxProgressDialog : public wxDialog | |
67 | { | |
68 | public: | |
69 | /** | |
70 | Constructor. Creates the dialog, displays it and disables user input | |
b1b95a65 FM |
71 | for other windows, or, if @c wxPD_APP_MODAL flag is not given, for its |
72 | parent window only. | |
3c4f71cc | 73 | |
7c913512 | 74 | @param title |
4cc4bfaf | 75 | Dialog title to show in titlebar. |
7c913512 | 76 | @param message |
4cc4bfaf | 77 | Message displayed above the progress bar. |
7c913512 | 78 | @param maximum |
4cc4bfaf | 79 | Maximum value for the progress bar. |
af237ae4 FM |
80 | In the generic implementation the progress bar is constructed |
81 | only if this value is greater than zero. | |
7c913512 | 82 | @param parent |
4cc4bfaf | 83 | Parent window. |
7c913512 | 84 | @param style |
4cc4bfaf | 85 | The dialog style. See wxProgressDialog. |
23324ae1 FM |
86 | */ |
87 | wxProgressDialog(const wxString& title, const wxString& message, | |
88 | int maximum = 100, | |
4cc4bfaf | 89 | wxWindow* parent = NULL, |
23324ae1 FM |
90 | int style = wxPD_AUTO_HIDE | wxPD_APP_MODAL); |
91 | ||
92 | /** | |
93 | Destructor. Deletes the dialog and enables all top level windows. | |
94 | */ | |
adaaa686 | 95 | virtual ~wxProgressDialog(); |
23324ae1 | 96 | |
af237ae4 FM |
97 | /** |
98 | Returns the last value passed to the Update() function or | |
99 | @c wxNOT_FOUND if the dialog has no progress bar. | |
100 | ||
101 | @since 2.9.0 | |
102 | */ | |
103 | int GetValue() const; | |
104 | ||
105 | /** | |
106 | Returns the maximum value of the progress meter, as passed to | |
107 | the constructor or @c wxNOT_FOUND if the dialog has no progress bar. | |
108 | ||
109 | @since 2.9.0 | |
110 | */ | |
111 | int GetRange() const; | |
112 | ||
113 | /** | |
114 | Returns the last message passed to the Update() function; | |
115 | if you always passed wxEmptyString to Update() then the message | |
116 | set through the constructor is returned. | |
117 | ||
118 | @since 2.9.0 | |
119 | */ | |
120 | wxString GetMessage() const; | |
121 | ||
23324ae1 | 122 | /** |
3b2fb7a1 VZ |
123 | Like Update() but makes the gauge control run in indeterminate mode. |
124 | ||
125 | In indeterminate mode the remaining and the estimated time labels (if | |
4c51a665 | 126 | present) are set to "Unknown" or to @a newmsg (if it's non-empty). |
3b2fb7a1 VZ |
127 | Each call to this function moves the progress bar a bit to indicate |
128 | that some progress was done. | |
129 | ||
130 | @see wxGauge::Pulse(), Update() | |
23324ae1 | 131 | */ |
43c48e1e | 132 | virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool* skip = NULL); |
23324ae1 FM |
133 | |
134 | /** | |
b1b95a65 | 135 | Can be used to continue with the dialog, after the user had clicked the "Abort" button. |
23324ae1 FM |
136 | */ |
137 | void Resume(); | |
138 | ||
ed1288ee FM |
139 | /** |
140 | Changes the maximum value of the progress meter given in the constructor. | |
141 | This function can only be called (with a positive value) if the value passed | |
142 | in the constructor was positive. | |
143 | ||
144 | @since 2.9.1 | |
145 | */ | |
146 | void SetRange(int maximum); | |
147 | ||
f994a8ac VZ |
148 | |
149 | /** | |
150 | Returns true if the "Cancel" button was pressed. | |
151 | ||
152 | Normally a Cancel button press is indicated by Update() returning | |
153 | @false but sometimes it may be more convenient to check if the dialog | |
154 | was cancelled from elsewhere in the code and this function allows to | |
155 | do it. | |
156 | ||
157 | It always returns @false if the Cancel button is not shown at all. | |
158 | ||
159 | @since 2.9.1 | |
160 | */ | |
161 | bool WasCancelled() const; | |
162 | ||
163 | /** | |
164 | Returns true if the "Skip" button was pressed. | |
165 | ||
166 | This is similar to WasCancelled() but returns @true if the "Skip" | |
167 | button was pressed, not the "Cancel" one. | |
168 | ||
169 | @since 2.9.1 | |
170 | */ | |
171 | bool WasSkipped() const; | |
172 | ||
173 | ||
23324ae1 | 174 | /** |
3b2fb7a1 VZ |
175 | Updates the dialog, setting the progress bar to the new value and |
176 | updating the message if new one is specified. | |
177 | ||
178 | Returns @true unless the "Cancel" button has been pressed. | |
b1b95a65 | 179 | |
23324ae1 | 180 | If @false is returned, the application can either immediately destroy the |
b1b95a65 FM |
181 | dialog or ask the user for the confirmation and if the abort is not confirmed |
182 | the dialog may be resumed with Resume() function. | |
3c4f71cc | 183 | |
cc31a982 VZ |
184 | If @a value is the maximum value for the dialog, the behaviour of the |
185 | function depends on whether @c wxPD_AUTO_HIDE was used when the dialog | |
186 | was created. If it was, the dialog is hidden and the function returns | |
187 | immediately. If it was not, the dialog becomes a modal dialog and waits | |
188 | for the user to dismiss it, meaning that this function does not return | |
189 | until this happens. | |
190 | ||
3b2fb7a1 VZ |
191 | Notice that you may want to call Fit() to change the dialog size to |
192 | conform to the length of the new message if desired. The dialog does | |
193 | not do this automatically. | |
194 | ||
7c913512 | 195 | @param value |
b1b95a65 | 196 | The new value of the progress meter. It should be less than or equal to |
8f139810 | 197 | the maximum value given to the constructor. |
7c913512 | 198 | @param newmsg |
4cc4bfaf FM |
199 | The new messages for the progress dialog text, if it is |
200 | empty (which is the default) the message is not changed. | |
7c913512 | 201 | @param skip |
b1b95a65 FM |
202 | If "Skip" button was pressed since last Update() call, |
203 | this is set to @true. | |
23324ae1 | 204 | */ |
11e3af6e | 205 | virtual bool Update(int value, const wxString& newmsg = wxEmptyString, |
4cc4bfaf | 206 | bool* skip = NULL); |
23324ae1 | 207 | }; |
e54c96f1 | 208 |