]> git.saurik.com Git - wxWidgets.git/blob - include/wx/generic/progdlgg.h
need to include wx/treectrl.h to use CLASSINFO(wxTextCtrl)
[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 // Must provide overload to avoid hiding it (and warnings about it)
56 virtual void Update() { wxDialog::Update(); }
57
58 /* Can be called to continue after the cancel button has been pressed, but
59 the program decided to continue the operation (e.g., user didn't
60 confirm it)
61 */
62 void Resume();
63
64 virtual bool Show( bool show = true );
65
66 protected:
67 // callback for optional abort button
68 void OnCancel(wxCommandEvent& event);
69
70 // callback for optional skip button
71 void OnSkip(wxCommandEvent& event);
72
73 // callback to disable "hard" window closing
74 void OnClose(wxCloseEvent& event);
75
76 // must be called to reenable the other windows temporarily disabled while
77 // the dialog was shown
78 void ReenableOtherWindows();
79
80 private:
81 // create the label with given text and another one to show the time nearby
82 // as the next windows in the sizer, returns the created control
83 wxStaticText *CreateLabel(const wxString& text, wxSizer *sizer);
84
85 // shortcuts for enabling buttons
86 void EnableClose();
87 void EnableSkip(bool enable=true);
88 void EnableAbort(bool enable=true);
89 inline void DisableSkip() { EnableSkip(false); }
90 inline void DisableAbort() { EnableAbort(false); }
91
92 // the status bar
93 wxGauge *m_gauge;
94 // the message displayed
95 wxStaticText *m_msg;
96 // displayed elapsed, estimated, remaining time
97 class wxStaticText *m_elapsed,
98 *m_estimated,
99 *m_remaining;
100 // time when the dialog was created
101 unsigned long m_timeStart;
102 // time when the dialog was closed or cancelled
103 unsigned long m_timeStop;
104 // time between the moment the dialog was closed/cancelled and resume
105 unsigned long m_break;
106
107 // parent top level window (may be NULL)
108 wxWindow *m_parentTop;
109
110 // continue processing or not (return value for Update())
111 enum
112 {
113 Uncancelable = -1, // dialog can't be canceled
114 Canceled, // can be cancelled and, in fact, was
115 Continue, // can be cancelled but wasn't
116 Finished // finished, waiting to be removed from screen
117 } m_state;
118
119 // skip some portion
120 bool m_skip;
121
122 #if !defined(__SMARTPHONE__)
123 // the abort and skip buttons (or NULL if none)
124 wxButton *m_btnAbort;
125 wxButton *m_btnSkip;
126 #endif
127
128 // the maximum value
129 int m_maximum;
130
131 // saves the time when elapsed time was updated so there is only one
132 // update per second
133 unsigned long m_last_timeupdate;
134 // tells how often a change of the estimated time has to be confirmed
135 // before it is actually displayed - this reduces the frequence of updates
136 // of estimated and remaining time
137 const int m_delay;
138 // counts the confirmations
139 int m_ctdelay;
140 unsigned long m_display_estimated;
141
142 bool m_hasAbortButton,
143 m_hasSkipButton;
144
145 #if defined(__WXMSW__ ) || defined(__WXPM__)
146 // the factor we use to always keep the value in 16 bit range as the native
147 // control only supports ranges from 0 to 65,535
148 size_t m_factor;
149 #endif // __WXMSW__
150
151 // for wxPD_APP_MODAL case
152 class WXDLLEXPORT wxWindowDisabler *m_winDisabler;
153
154 DECLARE_EVENT_TABLE()
155 DECLARE_NO_COPY_CLASS(wxProgressDialog)
156 };
157
158 #endif // wxUSE_PROGRESSDLG
159
160 #endif // __PROGDLGH_G__