]>
Commit | Line | Data |
---|---|---|
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 |
22 | class WXDLLIMPEXP_FWD_CORE wxButton; |
23 | class WXDLLIMPEXP_FWD_CORE wxGauge; | |
24 | class 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 | 30 | class WXDLLIMPEXP_CORE wxProgressDialog : public wxDialog |
8fa2e6a2 | 31 | { |
8fa2e6a2 | 32 | public: |
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 | ||
51 | // Must provide overload to avoid hiding it (and warnings about it) | |
52 | virtual void Update() { wxDialog::Update(); } | |
53 | ||
54 | virtual bool Show( bool show = true ); | |
55 | ||
ef8698d6 | 56 | protected: |
695f550b VZ |
57 | // callback for optional abort button |
58 | void OnCancel(wxCommandEvent&); | |
ef8698d6 | 59 | |
695f550b VZ |
60 | // callback for optional skip button |
61 | void OnSkip(wxCommandEvent&); | |
ecda9475 | 62 | |
695f550b VZ |
63 | // callback to disable "hard" window closing |
64 | void OnClose(wxCloseEvent&); | |
8fa2e6a2 | 65 | |
695f550b VZ |
66 | // must be called to reenable the other windows temporarily disabled while |
67 | // the dialog was shown | |
68 | void ReenableOtherWindows(); | |
ef8698d6 | 69 | |
8fa2e6a2 | 70 | private: |
695f550b VZ |
71 | // create the label with given text and another one to show the time nearby |
72 | // as the next windows in the sizer, returns the created control | |
73 | wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer); | |
0655ad29 | 74 | |
fe8635a7 | 75 | // updates the label message |
695f550b VZ |
76 | void UpdateMessage(const wxString &newmsg); |
77 | ||
78 | // common part of Update() and Pulse(), returns true if not cancelled | |
79 | bool DoAfterUpdate(bool *skip); | |
80 | ||
81 | // shortcuts for enabling buttons | |
82 | void EnableClose(); | |
83 | void EnableSkip(bool enable = true); | |
84 | void EnableAbort(bool enable = true); | |
85 | void DisableSkip() { EnableSkip(false); } | |
86 | void DisableAbort() { EnableAbort(false); } | |
87 | ||
af237ae4 | 88 | // the widget displaying current status (may be NULL) |
695f550b VZ |
89 | wxGauge *m_gauge; |
90 | // the message displayed | |
91 | wxStaticText *m_msg; | |
92 | // displayed elapsed, estimated, remaining time | |
93 | wxStaticText *m_elapsed, | |
94 | *m_estimated, | |
95 | *m_remaining; | |
96 | // time when the dialog was created | |
97 | unsigned long m_timeStart; | |
98 | // time when the dialog was closed or cancelled | |
99 | unsigned long m_timeStop; | |
100 | // time between the moment the dialog was closed/cancelled and resume | |
101 | unsigned long m_break; | |
102 | ||
103 | // parent top level window (may be NULL) | |
104 | wxWindow *m_parentTop; | |
abceee76 | 105 | |
69c69546 WS |
106 | // continue processing or not (return value for Update()) |
107 | enum | |
108 | { | |
109 | Uncancelable = -1, // dialog can't be canceled | |
110 | Canceled, // can be cancelled and, in fact, was | |
111 | Continue, // can be cancelled but wasn't | |
112 | Finished // finished, waiting to be removed from screen | |
113 | } m_state; | |
cbc66a27 | 114 | |
69c69546 WS |
115 | // skip some portion |
116 | bool m_skip; | |
ecda9475 WS |
117 | |
118 | #if !defined(__SMARTPHONE__) | |
69c69546 WS |
119 | // the abort and skip buttons (or NULL if none) |
120 | wxButton *m_btnAbort; | |
121 | wxButton *m_btnSkip; | |
ecda9475 | 122 | #endif |
cbc66a27 | 123 | |
69c69546 WS |
124 | // the maximum value |
125 | int m_maximum; | |
126 | ||
127 | // saves the time when elapsed time was updated so there is only one | |
128 | // update per second | |
129 | unsigned long m_last_timeupdate; | |
130 | // tells how often a change of the estimated time has to be confirmed | |
131 | // before it is actually displayed - this reduces the frequence of updates | |
132 | // of estimated and remaining time | |
133 | const int m_delay; | |
134 | // counts the confirmations | |
135 | int m_ctdelay; | |
136 | unsigned long m_display_estimated; | |
8fa2e6a2 | 137 | |
69c69546 WS |
138 | bool m_hasAbortButton, |
139 | m_hasSkipButton; | |
2c5ef4e2 | 140 | |
bdc8dd3c | 141 | #if defined(__WXMSW__ ) || defined(__WXPM__) |
69c69546 WS |
142 | // the factor we use to always keep the value in 16 bit range as the native |
143 | // control only supports ranges from 0 to 65,535 | |
144 | size_t m_factor; | |
7c349adb VZ |
145 | #endif // __WXMSW__ |
146 | ||
69c69546 | 147 | // for wxPD_APP_MODAL case |
b5dbe15d | 148 | class WXDLLIMPEXP_FWD_CORE wxWindowDisabler *m_winDisabler; |
cbc66a27 | 149 | |
69c69546 | 150 | DECLARE_EVENT_TABLE() |
ed1288ee | 151 | DECLARE_DYNAMIC_CLASS(wxProgressDialog) |
c0c133e1 | 152 | wxDECLARE_NO_COPY_CLASS(wxProgressDialog); |
8fa2e6a2 | 153 | }; |
ce4169a4 | 154 | |
555f645a WS |
155 | #endif // wxUSE_PROGRESSDLG |
156 | ||
157 | #endif // __PROGDLGH_G__ |