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