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