]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/progdlgg.h
Implement HasSelection for the OSX WebKit backend.
[wxWidgets.git] / include / wx / generic / progdlgg.h
CommitLineData
ed1288ee 1///////////////////////////////////////////////////////////////////////////////
80fdcdb9 2// Name: wx/generic/progdlgg.h
c31d9c7f 3// Purpose: wxGenericProgressDialog class
9d55bfef 4// Author: Karsten Ballueder
ed1288ee 5// Modified by: Francesco Montorsi
8fa2e6a2
KB
6// Created: 09.05.1999
7// RCS-ID: $Id$
9d55bfef 8// Copyright: (c) Karsten Ballueder
65571936 9// Licence: wxWindows licence
ed1288ee 10///////////////////////////////////////////////////////////////////////////////
8fa2e6a2
KB
11
12#ifndef __PROGDLGH_G__
13#define __PROGDLGH_G__
14
0655ad29 15#include "wx/dialog.h"
8fa2e6a2 16
b5dbe15d 17class WXDLLIMPEXP_FWD_CORE wxButton;
7ad8a38a 18class WXDLLIMPEXP_FWD_CORE wxEventLoop;
b5dbe15d
VS
19class WXDLLIMPEXP_FWD_CORE wxGauge;
20class WXDLLIMPEXP_FWD_CORE wxStaticText;
79e58a40 21class WXDLLIMPEXP_FWD_CORE wxWindowDisabler;
0655ad29 22
ed1288ee
FM
23/*
24 Progress dialog which shows a moving progress bar.
25 Taken from the Mahogany project.
26*/
c31d9c7f 27class WXDLLIMPEXP_CORE wxGenericProgressDialog : public wxDialog
8fa2e6a2 28{
8fa2e6a2 29public:
c31d9c7f
VZ
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);
ed1288ee 34
c31d9c7f 35 virtual ~wxGenericProgressDialog();
695f550b 36
695f550b 37 virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL);
f4aa7ec3 38 virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
fe8635a7 39
695f550b 40 void Resume();
8fa2e6a2 41
af237ae4
FM
42 int GetValue() const;
43 int GetRange() const;
44 wxString GetMessage() const;
7d1dcec2 45
ed1288ee
FM
46 void SetRange(int maximum);
47
f994a8ac
VZ
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
ed1288ee
FM
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
c31d9c7f
VZ
58 // This enum is an implementation detail and should not be used
59 // by user code.
4f4d6f44 60 enum State
c31d9c7f
VZ
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
cc31a982
VZ
65 Finished, // finished, waiting to be removed from screen
66 Dismissed // was closed by user after finishing
c31d9c7f
VZ
67 };
68
ef8698d6 69protected:
c31d9c7f 70 // This ctor is used by the native MSW implementation only.
2de77c6a 71 wxGenericProgressDialog(wxWindow *parent, int style);
c31d9c7f
VZ
72
73 void Create(const wxString& title,
74 const wxString& message,
75 int maximum,
76 wxWindow *parent,
77 int style);
78
2de77c6a
VZ
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
c31d9c7f
VZ
85 // Return the labels to use for showing the elapsed/estimated/remaining
86 // times respectively.
d20dfbf0
MB
87 static wxString GetElapsedLabel() { return wxGetTranslation("Elapsed time:"); }
88 static wxString GetEstimatedLabel() { return wxGetTranslation("Estimated time:"); }
89 static wxString GetRemainingLabel() { return wxGetTranslation("Remaining time:"); }
c31d9c7f
VZ
90
91
e77570de
VZ
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
c31d9c7f
VZ
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
695f550b
VZ
110 // callback for optional abort button
111 void OnCancel(wxCommandEvent&);
ef8698d6 112
695f550b
VZ
113 // callback for optional skip button
114 void OnSkip(wxCommandEvent&);
ecda9475 115
695f550b
VZ
116 // callback to disable "hard" window closing
117 void OnClose(wxCloseEvent&);
8fa2e6a2 118
c31d9c7f
VZ
119 // called to disable the other windows while this dialog is shown
120 void DisableOtherWindows();
121
695f550b
VZ
122 // must be called to reenable the other windows temporarily disabled while
123 // the dialog was shown
124 void ReenableOtherWindows();
ef8698d6 125
c31d9c7f
VZ
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())
4f4d6f44 131 State m_state;
c31d9c7f
VZ
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
8fa2e6a2 149private:
c31d9c7f
VZ
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
2de77c6a 154 void Init(wxWindow *parent, int style);
c31d9c7f 155
695f550b
VZ
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);
0655ad29 159
fe8635a7 160 // updates the label message
695f550b
VZ
161 void UpdateMessage(const wxString &newmsg);
162
163 // common part of Update() and Pulse(), returns true if not cancelled
86417abf
VZ
164 bool DoBeforeUpdate(bool *skip);
165
166 // common part of Update() and Pulse()
167 void DoAfterUpdate();
695f550b
VZ
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
af237ae4 176 // the widget displaying current status (may be NULL)
695f550b
VZ
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;
695f550b
VZ
184
185 // parent top level window (may be NULL)
186 wxWindow *m_parentTop;
abceee76 187
e77570de
VZ
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
69c69546
WS
194 // skip some portion
195 bool m_skip;
ecda9475
WS
196
197#if !defined(__SMARTPHONE__)
69c69546
WS
198 // the abort and skip buttons (or NULL if none)
199 wxButton *m_btnAbort;
200 wxButton *m_btnSkip;
ecda9475 201#endif
cbc66a27 202
69c69546
WS
203 // saves the time when elapsed time was updated so there is only one
204 // update per second
205 unsigned long m_last_timeupdate;
c31d9c7f 206
69c69546 207 // tells how often a change of the estimated time has to be confirmed
c31d9c7f 208 // before it is actually displayed - this reduces the frequency of updates
69c69546 209 // of estimated and remaining time
c31d9c7f
VZ
210 int m_delay;
211
69c69546
WS
212 // counts the confirmations
213 int m_ctdelay;
214 unsigned long m_display_estimated;
8fa2e6a2 215
69c69546 216 // for wxPD_APP_MODAL case
79e58a40 217 wxWindowDisabler *m_winDisabler;
cbc66a27 218
7ad8a38a
VZ
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
69c69546 224 DECLARE_EVENT_TABLE()
c31d9c7f 225 wxDECLARE_NO_COPY_CLASS(wxGenericProgressDialog);
8fa2e6a2 226};
ce4169a4 227
555f645a 228#endif // __PROGDLGH_G__