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