]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/progdlgg.h
No changes, just remove wxSplitterWindow::{Set,Get}NeedUpdating().
[wxWidgets.git] / include / wx / generic / progdlgg.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/generic/progdlgg.h
3 // Purpose: wxGenericProgressDialog class
4 // Author: Karsten Ballueder
5 // Modified by: Francesco Montorsi
6 // Created: 09.05.1999
7 // RCS-ID: $Id$
8 // Copyright: (c) Karsten Ballueder
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef __PROGDLGH_G__
13 #define __PROGDLGH_G__
14
15 #include "wx/dialog.h"
16
17 class WXDLLIMPEXP_FWD_CORE wxButton;
18 class WXDLLIMPEXP_FWD_CORE wxEventLoop;
19 class WXDLLIMPEXP_FWD_CORE wxGauge;
20 class WXDLLIMPEXP_FWD_CORE wxStaticText;
21 class WXDLLIMPEXP_FWD_CORE wxWindowDisabler;
22
23 /*
24 Progress dialog which shows a moving progress bar.
25 Taken from the Mahogany project.
26 */
27 class WXDLLIMPEXP_CORE wxGenericProgressDialog : public wxDialog
28 {
29 public:
30 wxGenericProgressDialog(const wxString& title, const wxString& message,
31 int maximum = 100,
32 wxWindow *parent = NULL,
33 int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
34
35 virtual ~wxGenericProgressDialog();
36
37 virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL);
38 virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
39
40 void Resume();
41
42 int GetValue() const;
43 int GetRange() const;
44 wxString GetMessage() const;
45
46 void SetRange(int maximum);
47
48 // Return whether "Cancel" or "Skip" button was pressed, always return
49 // false if the corresponding button is not shown.
50 bool WasCancelled() const;
51 bool WasSkipped() const;
52
53 // Must provide overload to avoid hiding it (and warnings about it)
54 virtual void Update() { wxDialog::Update(); }
55
56 virtual bool Show( bool show = true );
57
58 // This enum is an implementation detail and should not be used
59 // by user code.
60 enum State
61 {
62 Uncancelable = -1, // dialog can't be canceled
63 Canceled, // can be cancelled and, in fact, was
64 Continue, // can be cancelled but wasn't
65 Finished, // finished, waiting to be removed from screen
66 Dismissed // was closed by user after finishing
67 };
68
69 protected:
70 // This ctor is used by the native MSW implementation only.
71 wxGenericProgressDialog(wxWindow *parent, int style);
72
73 void Create(const wxString& title,
74 const wxString& message,
75 int maximum,
76 wxWindow *parent,
77 int style);
78
79 // Update just the m_maximum field, this is used by public SetRange() but,
80 // unlike it, doesn't update the controls state. This makes it useful for
81 // both this class and its derived classes that don't use m_gauge to
82 // display progress.
83 void SetMaximum(int maximum);
84
85 // Return the labels to use for showing the elapsed/estimated/remaining
86 // times respectively.
87 static wxString GetElapsedLabel() { return wxGetTranslation("Elapsed time:"); }
88 static wxString GetEstimatedLabel() { return wxGetTranslation("Estimated time:"); }
89 static wxString GetRemainingLabel() { return wxGetTranslation("Remaining time:"); }
90
91
92 // Similar to wxWindow::HasFlag() but tests for a presence of a wxPD_XXX
93 // flag in our (separate) flags instead of using m_windowStyle.
94 bool HasPDFlag(int flag) const { return (m_pdStyle & flag) != 0; }
95
96 // Return the progress dialog style. Prefer to use HasPDFlag() if possible.
97 int GetPDStyle() const { return m_pdStyle; }
98
99
100 // Updates estimated times from a given progress bar value and stores the
101 // results in provided arguments.
102 void UpdateTimeEstimates(int value,
103 unsigned long &elapsedTime,
104 unsigned long &estimatedTime,
105 unsigned long &remainingTime);
106
107 // Converts seconds to HH:mm:ss format.
108 static wxString GetFormattedTime(unsigned long timeInSec);
109
110 // callback for optional abort button
111 void OnCancel(wxCommandEvent&);
112
113 // callback for optional skip button
114 void OnSkip(wxCommandEvent&);
115
116 // callback to disable "hard" window closing
117 void OnClose(wxCloseEvent&);
118
119 // called to disable the other windows while this dialog is shown
120 void DisableOtherWindows();
121
122 // must be called to reenable the other windows temporarily disabled while
123 // the dialog was shown
124 void ReenableOtherWindows();
125
126 // return the top level parent window of this dialog (may be NULL)
127 wxWindow *GetTopParent() const { return m_parentTop; }
128
129
130 // continue processing or not (return value for Update())
131 State m_state;
132
133 // the maximum value
134 int m_maximum;
135
136 #if defined(__WXMSW__ ) || defined(__WXPM__)
137 // the factor we use to always keep the value in 16 bit range as the native
138 // control only supports ranges from 0 to 65,535
139 size_t m_factor;
140 #endif // __WXMSW__
141
142 // time when the dialog was created
143 unsigned long m_timeStart;
144 // time when the dialog was closed or cancelled
145 unsigned long m_timeStop;
146 // time between the moment the dialog was closed/cancelled and resume
147 unsigned long m_break;
148
149 private:
150 // update the label to show the given time (in seconds)
151 static void SetTimeLabel(unsigned long val, wxStaticText *label);
152
153 // common part of all ctors
154 void Init(wxWindow *parent, int style);
155
156 // create the label with given text and another one to show the time nearby
157 // as the next windows in the sizer, returns the created control
158 wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer);
159
160 // updates the label message
161 void UpdateMessage(const wxString &newmsg);
162
163 // common part of Update() and Pulse(), returns true if not cancelled
164 bool DoBeforeUpdate(bool *skip);
165
166 // common part of Update() and Pulse()
167 void DoAfterUpdate();
168
169 // shortcuts for enabling buttons
170 void EnableClose();
171 void EnableSkip(bool enable = true);
172 void EnableAbort(bool enable = true);
173 void DisableSkip() { EnableSkip(false); }
174 void DisableAbort() { EnableAbort(false); }
175
176 // the widget displaying current status (may be NULL)
177 wxGauge *m_gauge;
178 // the message displayed
179 wxStaticText *m_msg;
180 // displayed elapsed, estimated, remaining time
181 wxStaticText *m_elapsed,
182 *m_estimated,
183 *m_remaining;
184
185 // parent top level window (may be NULL)
186 wxWindow *m_parentTop;
187
188 // Progress dialog styles: this is not the same as m_windowStyle because
189 // wxPD_XXX constants clash with the existing TLW styles so to be sure we
190 // don't have any conflicts we just use a separate variable for storing
191 // them.
192 int m_pdStyle;
193
194 // skip some portion
195 bool m_skip;
196
197 #if !defined(__SMARTPHONE__)
198 // the abort and skip buttons (or NULL if none)
199 wxButton *m_btnAbort;
200 wxButton *m_btnSkip;
201 #endif
202
203 // saves the time when elapsed time was updated so there is only one
204 // update per second
205 unsigned long m_last_timeupdate;
206
207 // tells how often a change of the estimated time has to be confirmed
208 // before it is actually displayed - this reduces the frequency of updates
209 // of estimated and remaining time
210 int m_delay;
211
212 // counts the confirmations
213 int m_ctdelay;
214 unsigned long m_display_estimated;
215
216 // for wxPD_APP_MODAL case
217 wxWindowDisabler *m_winDisabler;
218
219 // Temporary event loop created by the dialog itself if there is no
220 // currently active loop when it is created.
221 wxEventLoop *m_tempEventLoop;
222
223
224 DECLARE_EVENT_TABLE()
225 wxDECLARE_NO_COPY_CLASS(wxGenericProgressDialog);
226 };
227
228 #endif // __PROGDLGH_G__