+#include "wx/progdlg.h"
+#include "wx/evtloop.h"
+
+// ---------------------------------------------------------------------------
+// macros
+// ---------------------------------------------------------------------------
+
+/* Macro for avoiding #ifdefs when value have to be different depending on size of
+ device we display on - take it from something like wxDesktopPolicy in the future
+ */
+
+#if defined(__SMARTPHONE__)
+ #define wxLARGESMALL(large,small) small
+#else
+ #define wxLARGESMALL(large,small) large
+#endif
+
+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+#define LAYOUT_MARGIN wxLARGESMALL(8,2)
+
+static const int wxID_SKIP = 32000; // whatever
+
+// ----------------------------------------------------------------------------
+// event tables
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(wxGenericProgressDialog, wxDialog)
+ EVT_BUTTON(wxID_CANCEL, wxGenericProgressDialog::OnCancel)
+ EVT_BUTTON(wxID_SKIP, wxGenericProgressDialog::OnSkip)
+
+ EVT_CLOSE(wxGenericProgressDialog::OnClose)
+END_EVENT_TABLE()
+
+// ============================================================================
+// wxGenericProgressDialog implementation
+// ============================================================================
+
+wxIMPLEMENT_CLASS(wxProgressDialog, wxDialog)
+
+// ----------------------------------------------------------------------------
+// wxGenericProgressDialog creation
+// ----------------------------------------------------------------------------
+
+void wxGenericProgressDialog::Init(wxWindow *parent, int style)
+{
+ // we may disappear at any moment, let the others know about it
+ SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT);
+
+ // Initialize all our members that we always use (even when we don't
+ // create a valid window in this class).
+
+ m_pdStyle = style;
+
+ m_parentTop = wxGetTopLevelParent(parent);
+
+ m_gauge = NULL;
+ m_msg = NULL;
+ m_elapsed =
+ m_estimated =
+ m_remaining = NULL;
+
+ m_state = Uncancelable;
+ m_maximum = 0;
+
+ m_timeStart = wxGetCurrentTime();
+ m_timeStop = (unsigned long)-1;
+ m_break = 0;
+
+ m_skip = false;
+
+#if !defined(__SMARTPHONE__)
+ m_btnAbort =
+ m_btnSkip = NULL;
+#endif
+
+ m_display_estimated =
+ m_last_timeupdate =
+ m_ctdelay = 0;
+
+ m_delay = 3;
+
+ m_winDisabler = NULL;
+ m_tempEventLoop = NULL;
+}
+
+wxGenericProgressDialog::wxGenericProgressDialog(wxWindow *parent, int style)
+ : wxDialog()
+{
+ Init(parent, style);
+}
+
+wxGenericProgressDialog::wxGenericProgressDialog(const wxString& title,
+ const wxString& message,
+ int maximum,
+ wxWindow *parent,
+ int style)
+ : wxDialog()
+{
+ Init(parent, style);
+
+ Create( title, message, maximum, parent, style );
+}
+
+void wxGenericProgressDialog::Create( const wxString& title,
+ const wxString& message,
+ int maximum,
+ wxWindow *parent,
+ int style )
+{
+ wxDialog::Create(GetParentForModalDialog(parent, style), wxID_ANY, title);
+
+ SetParent( GetParentForModalDialog(parent, style) );
+ SetTitle( title );
+
+ SetMaximum(maximum);
+
+ // We need a running event loop in order to update the dialog and be able
+ // to process clicks on its buttons, so ensure that there is one running
+ // even if this means we have to start it ourselves (this happens most
+ // commonly during the program initialization, e.g. for the progress
+ // dialogs shown from overridden wxApp::OnInit()).
+ if ( !wxEventLoopBase::GetActive() )
+ {
+ m_tempEventLoop = new wxEventLoop;
+ wxEventLoop::SetActive(m_tempEventLoop);
+ }
+
+#if defined(__WXMSW__) && !defined(__WXUNIVERSAL__)
+ // we have to remove the "Close" button from the title bar then as it is
+ // confusing to have it - it doesn't work anyhow
+ //
+ // FIXME: should probably have a (extended?) window style for this
+ if ( !HasPDFlag(wxPD_CAN_ABORT) )
+ {
+ EnableCloseButton(false);
+ }
+#endif // wxMSW
+
+#if defined(__SMARTPHONE__)
+ SetLeftMenu();
+#endif