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