]> git.saurik.com Git - wxWidgets.git/blame - include/wx/generic/progdlgg.h
Only compile wxStd{Input,Output}Stream if wxUSE_STREAMS==1.
[wxWidgets.git] / include / wx / generic / progdlgg.h
CommitLineData
ed1288ee 1///////////////////////////////////////////////////////////////////////////////
8fa2e6a2
KB
2// Name: progdlgg.h
3// Purpose: wxProgressDialog 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
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 25
ed1288ee
FM
26/*
27 Progress dialog which shows a moving progress bar.
28 Taken from the Mahogany project.
29*/
53a2db12 30class WXDLLIMPEXP_CORE wxProgressDialog : public wxDialog
8fa2e6a2 31{
8fa2e6a2 32public:
695f550b
VZ
33 wxProgressDialog(const wxString& title, const wxString& message,
34 int maximum = 100,
35 wxWindow *parent = NULL,
36 int style = wxPD_APP_MODAL | wxPD_AUTO_HIDE);
ed1288ee 37
695f550b
VZ
38 virtual ~wxProgressDialog();
39
695f550b 40 virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL);
f4aa7ec3 41 virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
fe8635a7 42
695f550b 43 void Resume();
8fa2e6a2 44
af237ae4
FM
45 int GetValue() const;
46 int GetRange() const;
47 wxString GetMessage() const;
7d1dcec2 48
ed1288ee
FM
49 void SetRange(int maximum);
50
f994a8ac
VZ
51 // Return whether "Cancel" or "Skip" button was pressed, always return
52 // false if the corresponding button is not shown.
53 bool WasCancelled() const;
54 bool WasSkipped() const;
55
ed1288ee
FM
56 // Must provide overload to avoid hiding it (and warnings about it)
57 virtual void Update() { wxDialog::Update(); }
58
59 virtual bool Show( bool show = true );
60
ef8698d6 61protected:
695f550b
VZ
62 // callback for optional abort button
63 void OnCancel(wxCommandEvent&);
ef8698d6 64
695f550b
VZ
65 // callback for optional skip button
66 void OnSkip(wxCommandEvent&);
ecda9475 67
695f550b
VZ
68 // callback to disable "hard" window closing
69 void OnClose(wxCloseEvent&);
8fa2e6a2 70
695f550b
VZ
71 // must be called to reenable the other windows temporarily disabled while
72 // the dialog was shown
73 void ReenableOtherWindows();
ef8698d6 74
8fa2e6a2 75private:
695f550b
VZ
76 // create the label with given text and another one to show the time nearby
77 // as the next windows in the sizer, returns the created control
78 wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer);
0655ad29 79
fe8635a7 80 // updates the label message
695f550b
VZ
81 void UpdateMessage(const wxString &newmsg);
82
83 // common part of Update() and Pulse(), returns true if not cancelled
86417abf
VZ
84 bool DoBeforeUpdate(bool *skip);
85
86 // common part of Update() and Pulse()
87 void DoAfterUpdate();
695f550b
VZ
88
89 // shortcuts for enabling buttons
90 void EnableClose();
91 void EnableSkip(bool enable = true);
92 void EnableAbort(bool enable = true);
93 void DisableSkip() { EnableSkip(false); }
94 void DisableAbort() { EnableAbort(false); }
95
af237ae4 96 // the widget displaying current status (may be NULL)
695f550b
VZ
97 wxGauge *m_gauge;
98 // the message displayed
99 wxStaticText *m_msg;
100 // displayed elapsed, estimated, remaining time
101 wxStaticText *m_elapsed,
102 *m_estimated,
103 *m_remaining;
104 // time when the dialog was created
105 unsigned long m_timeStart;
106 // time when the dialog was closed or cancelled
107 unsigned long m_timeStop;
108 // time between the moment the dialog was closed/cancelled and resume
109 unsigned long m_break;
110
111 // parent top level window (may be NULL)
112 wxWindow *m_parentTop;
abceee76 113
69c69546
WS
114 // continue processing or not (return value for Update())
115 enum
116 {
117 Uncancelable = -1, // dialog can't be canceled
118 Canceled, // can be cancelled and, in fact, was
119 Continue, // can be cancelled but wasn't
120 Finished // finished, waiting to be removed from screen
121 } m_state;
cbc66a27 122
69c69546
WS
123 // skip some portion
124 bool m_skip;
ecda9475
WS
125
126#if !defined(__SMARTPHONE__)
69c69546
WS
127 // the abort and skip buttons (or NULL if none)
128 wxButton *m_btnAbort;
129 wxButton *m_btnSkip;
ecda9475 130#endif
cbc66a27 131
69c69546
WS
132 // the maximum value
133 int m_maximum;
134
135 // saves the time when elapsed time was updated so there is only one
136 // update per second
137 unsigned long m_last_timeupdate;
138 // tells how often a change of the estimated time has to be confirmed
139 // before it is actually displayed - this reduces the frequence of updates
140 // of estimated and remaining time
141 const int m_delay;
142 // counts the confirmations
143 int m_ctdelay;
144 unsigned long m_display_estimated;
8fa2e6a2 145
69c69546
WS
146 bool m_hasAbortButton,
147 m_hasSkipButton;
2c5ef4e2 148
bdc8dd3c 149#if defined(__WXMSW__ ) || defined(__WXPM__)
69c69546
WS
150 // the factor we use to always keep the value in 16 bit range as the native
151 // control only supports ranges from 0 to 65,535
152 size_t m_factor;
7c349adb
VZ
153#endif // __WXMSW__
154
69c69546 155 // for wxPD_APP_MODAL case
b5dbe15d 156 class WXDLLIMPEXP_FWD_CORE wxWindowDisabler *m_winDisabler;
cbc66a27 157
69c69546 158 DECLARE_EVENT_TABLE()
ed1288ee 159 DECLARE_DYNAMIC_CLASS(wxProgressDialog)
c0c133e1 160 wxDECLARE_NO_COPY_CLASS(wxProgressDialog);
8fa2e6a2 161};
ce4169a4 162
555f645a
WS
163#endif // wxUSE_PROGRESSDLG
164
165#endif // __PROGDLGH_G__