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