+// ----------------------------------------------------------------------------
+// constants
+// ----------------------------------------------------------------------------
+
+#define LAYOUT_MARGIN wxLARGESMALL(8,2)
+
+static const int wxID_SKIP = 32000; // whatever
+
+// ----------------------------------------------------------------------------
+// private functions
+// ----------------------------------------------------------------------------
+
+// update the label to show the given time (in seconds)
+static void SetTimeLabel(unsigned long val, wxStaticText *label);
+
+// ----------------------------------------------------------------------------
+// event tables
+// ----------------------------------------------------------------------------
+
+BEGIN_EVENT_TABLE(wxProgressDialog, wxDialog)
+ EVT_BUTTON(wxID_CANCEL, wxProgressDialog::OnCancel)
+ EVT_BUTTON(wxID_SKIP, wxProgressDialog::OnSkip)
+
+ EVT_CLOSE(wxProgressDialog::OnClose)
+END_EVENT_TABLE()
+
+IMPLEMENT_CLASS(wxProgressDialog, wxDialog)
+
+// ============================================================================
+// wxProgressDialog implementation
+// ============================================================================
+
+// ----------------------------------------------------------------------------
+// wxProgressDialog creation
+// ----------------------------------------------------------------------------
+
+wxProgressDialog::wxProgressDialog(const wxString& title,
+ const wxString& message,
+ int maximum,
+ wxWindow *parent,
+ int style)
+ : wxDialog(GetParentForModalDialog(parent), wxID_ANY, title),
+ m_skip(false),
+ m_delay(3),
+ m_hasAbortButton(false),
+ m_hasSkipButton(false)
+{
+ // we may disappear at any moment, let the others know about it
+ SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT);
+ m_windowStyle |= style;
+
+ m_hasAbortButton = (style & wxPD_CAN_ABORT) != 0;
+ m_hasSkipButton = (style & wxPD_CAN_SKIP) != 0;
+
+#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 ( !m_hasAbortButton )
+ {
+ EnableCloseButton(false);
+ }
+#endif // wxMSW
+
+#if defined(__SMARTPHONE__)
+ SetLeftMenu();
+#endif
+
+ m_state = m_hasAbortButton ? Continue : Uncancelable;
+ m_maximum = maximum;
+
+#if defined(__WXMSW__) || defined(__WXPM__)
+ // we can't have values > 65,536 in the progress control under Windows, so
+ // scale everything down
+ m_factor = m_maximum / 65536 + 1;
+ m_maximum /= m_factor;
+#endif // __WXMSW__
+
+ m_parentTop = wxGetTopLevelParent(parent);
+
+ wxClientDC dc(this);
+ dc.SetFont(wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
+ wxCoord widthText = 0;
+ dc.GetTextExtent(message, &widthText, NULL, NULL, NULL, NULL);
+
+ // top-level sizerTop
+ wxSizer * const sizerTop = new wxBoxSizer(wxVERTICAL);
+
+ m_msg = new wxStaticText(this, wxID_ANY, message);
+ sizerTop->Add(m_msg, 0, wxLEFT | wxTOP, 2*LAYOUT_MARGIN);
+
+ wxSize sizeLabel = m_msg->GetSize();
+ if ( maximum > 0 )
+ {
+ int gauge_style = wxGA_HORIZONTAL;
+ if ( style & wxPD_SMOOTH )
+ gauge_style |= wxGA_SMOOTH;
+ m_gauge = new wxGauge
+ (
+ this,
+ wxID_ANY,
+ m_maximum,
+ wxDefaultPosition,
+ // make the progress bar sufficiently long
+ wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1),
+ gauge_style
+ );