]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/progdlgg.h
Simplify and correct MSW selection of background brush for children painting.
[wxWidgets.git] / include / wx / generic / progdlgg.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: progdlgg.h
3 // Purpose: wxProgressDialog 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/defs.h"
16 #include "wx/progdlg.h"
17
18 #if wxUSE_PROGRESSDLG
19
20 #include "wx/dialog.h"
21
22 class WXDLLIMPEXP_FWD_CORE wxButton;
23 class WXDLLIMPEXP_FWD_CORE wxGauge;
24 class WXDLLIMPEXP_FWD_CORE wxStaticText;
25
26 /*
27 Progress dialog which shows a moving progress bar.
28 Taken from the Mahogany project.
29 */
30 class WXDLLIMPEXP_CORE wxProgressDialog : public wxDialog
31 {
32 public:
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);
37
38 virtual ~wxProgressDialog();
39
40 virtual bool Update(int value, const wxString& newmsg = wxEmptyString, bool *skip = NULL);
41 virtual bool Pulse(const wxString& newmsg = wxEmptyString, bool *skip = NULL);
42
43 void Resume();
44
45 int GetValue() const;
46 int GetRange() const;
47 wxString GetMessage() const;
48
49 void SetRange(int maximum);
50
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
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
61 protected:
62 // callback for optional abort button
63 void OnCancel(wxCommandEvent&);
64
65 // callback for optional skip button
66 void OnSkip(wxCommandEvent&);
67
68 // callback to disable "hard" window closing
69 void OnClose(wxCloseEvent&);
70
71 // must be called to reenable the other windows temporarily disabled while
72 // the dialog was shown
73 void ReenableOtherWindows();
74
75 private:
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);
79
80 // updates the label message
81 void UpdateMessage(const wxString &newmsg);
82
83 // common part of Update() and Pulse(), returns true if not cancelled
84 bool DoAfterUpdate(bool *skip);
85
86 // shortcuts for enabling buttons
87 void EnableClose();
88 void EnableSkip(bool enable = true);
89 void EnableAbort(bool enable = true);
90 void DisableSkip() { EnableSkip(false); }
91 void DisableAbort() { EnableAbort(false); }
92
93 // the widget displaying current status (may be NULL)
94 wxGauge *m_gauge;
95 // the message displayed
96 wxStaticText *m_msg;
97 // displayed elapsed, estimated, remaining time
98 wxStaticText *m_elapsed,
99 *m_estimated,
100 *m_remaining;
101 // time when the dialog was created
102 unsigned long m_timeStart;
103 // time when the dialog was closed or cancelled
104 unsigned long m_timeStop;
105 // time between the moment the dialog was closed/cancelled and resume
106 unsigned long m_break;
107
108 // parent top level window (may be NULL)
109 wxWindow *m_parentTop;
110
111 // continue processing or not (return value for Update())
112 enum
113 {
114 Uncancelable = -1, // dialog can't be canceled
115 Canceled, // can be cancelled and, in fact, was
116 Continue, // can be cancelled but wasn't
117 Finished // finished, waiting to be removed from screen
118 } m_state;
119
120 // skip some portion
121 bool m_skip;
122
123 #if !defined(__SMARTPHONE__)
124 // the abort and skip buttons (or NULL if none)
125 wxButton *m_btnAbort;
126 wxButton *m_btnSkip;
127 #endif
128
129 // the maximum value
130 int m_maximum;
131
132 // saves the time when elapsed time was updated so there is only one
133 // update per second
134 unsigned long m_last_timeupdate;
135 // tells how often a change of the estimated time has to be confirmed
136 // before it is actually displayed - this reduces the frequence of updates
137 // of estimated and remaining time
138 const int m_delay;
139 // counts the confirmations
140 int m_ctdelay;
141 unsigned long m_display_estimated;
142
143 bool m_hasAbortButton,
144 m_hasSkipButton;
145
146 #if defined(__WXMSW__ ) || defined(__WXPM__)
147 // the factor we use to always keep the value in 16 bit range as the native
148 // control only supports ranges from 0 to 65,535
149 size_t m_factor;
150 #endif // __WXMSW__
151
152 // for wxPD_APP_MODAL case
153 class WXDLLIMPEXP_FWD_CORE wxWindowDisabler *m_winDisabler;
154
155 DECLARE_EVENT_TABLE()
156 DECLARE_DYNAMIC_CLASS(wxProgressDialog)
157 wxDECLARE_NO_COPY_CLASS(wxProgressDialog);
158 };
159
160 #endif // wxUSE_PROGRESSDLG
161
162 #endif // __PROGDLGH_G__