]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/progdlgg.h
added template wxScopedArray<> too
[wxWidgets.git] / include / wx / generic / progdlgg.h
CommitLineData
0655ad29 1////////////////////////////////////////////////////
8fa2e6a2
KB
2// Name: progdlgg.h
3// Purpose: wxProgressDialog class
9d55bfef 4// Author: Karsten Ballueder
8fa2e6a2
KB
5// Modified by:
6// Created: 09.05.1999
7// RCS-ID: $Id$
9d55bfef 8// Copyright: (c) Karsten Ballueder
65571936 9// Licence: wxWindows licence
0655ad29 10////////////////////////////////////////////////////
8fa2e6a2
KB
11
12#ifndef __PROGDLGH_G__
13#define __PROGDLGH_G__
14
ecda9475 15#include "wx/defs.h"
fe8635a7 16#include "wx/progdlg.h"
8fa2e6a2 17
ce4169a4 18#if wxUSE_PROGRESSDLG
8fa2e6a2 19
0655ad29 20#include "wx/dialog.h"
8fa2e6a2 21
b5dbe15d
VS
22class WXDLLIMPEXP_FWD_CORE wxButton;
23class WXDLLIMPEXP_FWD_CORE wxGauge;
24class WXDLLIMPEXP_FWD_CORE wxStaticText;
0655ad29
VZ
25
26/* Progress dialog which shows a moving progress bar.
8fa2e6a2
KB
27 Taken from the Mahogany project.*/
28
53a2db12 29class WXDLLIMPEXP_CORE wxProgressDialog : public wxDialog
8fa2e6a2
KB
30{
31DECLARE_DYNAMIC_CLASS(wxProgressDialog)
32public:
695f550b 33 /* Creates and displays dialog, disables event handling for other
8fa2e6a2
KB
34 frames or parent frame to avoid recursion problems.
35 @param title title for window
36 @param message message to display in window
9726da4f 37 @param maximum value for status bar, if <= 0, no bar is shown
8fa2e6a2 38 @param parent window or NULL
9726da4f 39 @param style is the bit mask of wxPD_XXX constants from wx/defs.h
695f550b
VZ
40 */
41 wxProgressDialog(const wxString& title, const wxString& message,
42 int maximum = 100,
43 wxWindow *parent = NULL,
44 int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
45 /* Destructor.
46 Re-enables event handling for other windows.
47 */
48 virtual ~wxProgressDialog();
49
50 /* Update the status bar to the new value.
8fa2e6a2
KB
51 @param value new value
52 @param newmsg if used, new message to display
d29a9a8a 53 @return true if ABORT button has not been pressed
695f550b
VZ
54 */
55 virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL);
fe8635a7
RR
56
57 /* Switches the dialog to use a gauge in indeterminate mode and calls
58 wxGauge::Pulse() to show to the user a bit of progress */
f4aa7ec3 59 virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
fe8635a7 60
6f02a879
VZ
61 // Must provide overload to avoid hiding it (and warnings about it)
62 virtual void Update() { wxDialog::Update(); }
8fa2e6a2 63
af237ae4
FM
64 virtual bool Show( bool show = true );
65
695f550b 66 /* Can be called to continue after the cancel button has been pressed, but
8fa2e6a2 67 the program decided to continue the operation (e.g., user didn't
be9abe3f 68 confirm it)
695f550b
VZ
69 */
70 void Resume();
8fa2e6a2 71
af237ae4
FM
72 int GetValue() const;
73 int GetRange() const;
74 wxString GetMessage() const;
7d1dcec2 75
ef8698d6 76protected:
695f550b
VZ
77 // callback for optional abort button
78 void OnCancel(wxCommandEvent&);
ef8698d6 79
695f550b
VZ
80 // callback for optional skip button
81 void OnSkip(wxCommandEvent&);
ecda9475 82
695f550b
VZ
83 // callback to disable "hard" window closing
84 void OnClose(wxCloseEvent&);
8fa2e6a2 85
695f550b
VZ
86 // must be called to reenable the other windows temporarily disabled while
87 // the dialog was shown
88 void ReenableOtherWindows();
ef8698d6 89
8fa2e6a2 90private:
695f550b
VZ
91 // create the label with given text and another one to show the time nearby
92 // as the next windows in the sizer, returns the created control
93 wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer);
0655ad29 94
fe8635a7 95 // updates the label message
695f550b
VZ
96 void UpdateMessage(const wxString &newmsg);
97
98 // common part of Update() and Pulse(), returns true if not cancelled
99 bool DoAfterUpdate(bool *skip);
100
101 // shortcuts for enabling buttons
102 void EnableClose();
103 void EnableSkip(bool enable = true);
104 void EnableAbort(bool enable = true);
105 void DisableSkip() { EnableSkip(false); }
106 void DisableAbort() { EnableAbort(false); }
107
af237ae4 108 // the widget displaying current status (may be NULL)
695f550b
VZ
109 wxGauge *m_gauge;
110 // the message displayed
111 wxStaticText *m_msg;
112 // displayed elapsed, estimated, remaining time
113 wxStaticText *m_elapsed,
114 *m_estimated,
115 *m_remaining;
116 // time when the dialog was created
117 unsigned long m_timeStart;
118 // time when the dialog was closed or cancelled
119 unsigned long m_timeStop;
120 // time between the moment the dialog was closed/cancelled and resume
121 unsigned long m_break;
122
123 // parent top level window (may be NULL)
124 wxWindow *m_parentTop;
abceee76 125
69c69546
WS
126 // continue processing or not (return value for Update())
127 enum
128 {
129 Uncancelable = -1, // dialog can't be canceled
130 Canceled, // can be cancelled and, in fact, was
131 Continue, // can be cancelled but wasn't
132 Finished // finished, waiting to be removed from screen
133 } m_state;
cbc66a27 134
69c69546
WS
135 // skip some portion
136 bool m_skip;
ecda9475
WS
137
138#if !defined(__SMARTPHONE__)
69c69546
WS
139 // the abort and skip buttons (or NULL if none)
140 wxButton *m_btnAbort;
141 wxButton *m_btnSkip;
ecda9475 142#endif
cbc66a27 143
69c69546
WS
144 // the maximum value
145 int m_maximum;
146
147 // saves the time when elapsed time was updated so there is only one
148 // update per second
149 unsigned long m_last_timeupdate;
150 // tells how often a change of the estimated time has to be confirmed
151 // before it is actually displayed - this reduces the frequence of updates
152 // of estimated and remaining time
153 const int m_delay;
154 // counts the confirmations
155 int m_ctdelay;
156 unsigned long m_display_estimated;
8fa2e6a2 157
69c69546
WS
158 bool m_hasAbortButton,
159 m_hasSkipButton;
2c5ef4e2 160
bdc8dd3c 161#if defined(__WXMSW__ ) || defined(__WXPM__)
69c69546
WS
162 // the factor we use to always keep the value in 16 bit range as the native
163 // control only supports ranges from 0 to 65,535
164 size_t m_factor;
7c349adb
VZ
165#endif // __WXMSW__
166
69c69546 167 // for wxPD_APP_MODAL case
b5dbe15d 168 class WXDLLIMPEXP_FWD_CORE wxWindowDisabler *m_winDisabler;
cbc66a27 169
69c69546 170 DECLARE_EVENT_TABLE()
22f3361e 171 DECLARE_NO_COPY_CLASS(wxProgressDialog)
8fa2e6a2 172};
ce4169a4 173
555f645a
WS
174#endif // wxUSE_PROGRESSDLG
175
176#endif // __PROGDLGH_G__