void wxGenericProgressDialog::EnableAbort(bool enable) { if( HasPDFlag(wxPD_CAN_ABORT) ) { if(m_btnAbort) m_btnAbort->Enable(enable); } }
void wxGenericProgressDialog::EnableSkip(bool enable) { if ( HasPDFlag(wxPD_CAN_SKIP) ) { if(m_btnSkip) m_btnSkip->Enable(enable); } }
void wxGenericProgressDialog::EnableClose() { if(HasPDFlag(wxPD_CAN_ABORT)) { if(m_btnAbort) { m_btnAbort->Enable(); m_btnAbort->SetLabel(_("Close")); } } }
void wxGenericProgressDialog::ReenableOtherWindows() { if ( HasPDFlag(wxPD_APP_MODAL) ) { wxDELETE(m_winDisabler); } else { if ( m_parentTop ) m_parentTop->Enable(); } }
void wxGenericProgressDialog::DisableOtherWindows() { if ( HasPDFlag(wxPD_APP_MODAL) ) { m_winDisabler = new wxWindowDisabler(this); } else { if ( m_parentTop ) m_parentTop->Disable(); m_winDisabler = NULL; } }
void wxGenericProgressDialog::EnableClose() { if(HasPDFlag(wxPD_CAN_ABORT)) { #ifdef __SMARTPHONE__ SetLeftMenu(wxID_CANCEL, _("Close")); #else if(m_btnAbort) { m_btnAbort->Enable(); m_btnAbort->SetLabel(_("Close")); } #endif } }
void wxGenericProgressDialog::EnableAbort(bool enable) { if( HasPDFlag(wxPD_CAN_ABORT) ) { #ifdef __SMARTPHONE__ if(enable) SetLeftMenu(wxID_CANCEL); // stock buttons makes Cancel label else SetLeftMenu(); #else if(m_btnAbort) m_btnAbort->Enable(enable); #endif } }
void wxGenericProgressDialog::EnableSkip(bool enable) { if ( HasPDFlag(wxPD_CAN_SKIP) ) { #ifdef __SMARTPHONE__ if(enable) SetRightMenu(wxID_SKIP, _("Skip")); else SetRightMenu(); #else if(m_btnSkip) m_btnSkip->Enable(enable); #endif } }
bool wxGenericProgressDialog::WasSkipped() const { return HasPDFlag(wxPD_CAN_SKIP) && m_skip; }
bool wxGenericProgressDialog::WasCancelled() const { return HasPDFlag(wxPD_CAN_ABORT) && m_state == Canceled; }
bool wxGenericProgressDialog::Update(int value, const wxString& newmsg, bool *skip) { if ( !DoBeforeUpdate(skip) ) return false; wxCHECK_MSG( m_gauge, false, "dialog should be fully created" ); #ifdef __WXMSW__ value /= m_factor; #endif // __WXMSW__ wxASSERT_MSG( value <= m_maximum, wxT("invalid progress value") ); m_gauge->SetValue(value); UpdateMessage(newmsg); if ( (m_elapsed || m_remaining || m_estimated) && (value != 0) ) { unsigned long elapsed; unsigned long display_remaining; UpdateTimeEstimates( value, elapsed, m_display_estimated, display_remaining ); SetTimeLabel(elapsed, m_elapsed); SetTimeLabel(m_display_estimated, m_estimated); SetTimeLabel(display_remaining, m_remaining); } if ( value == m_maximum ) { if ( m_state == Finished ) { // ignore multiple calls to Update(m_maximum): it may sometimes be // troublesome to ensure that Update() is not called twice with the // same value (e.g. because of the rounding errors) and if we don't // return now we're going to generate asserts below return true; } // so that we return true below and that out [Cancel] handler knew what // to do m_state = Finished; if( !HasPDFlag(wxPD_AUTO_HIDE) ) { EnableClose(); DisableSkip(); #if defined(__WXMSW__) && !defined(__WXUNIVERSAL__) EnableCloseButton(); #endif // __WXMSW__ if ( newmsg.empty() ) { // also provide the finishing message if the application didn't m_msg->SetLabel(_("Done.")); } // allow the window to repaint: // NOTE: since we yield only for UI events with this call, there // should be no side-effects wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI); // NOTE: this call results in a new event loop being created // and to a call to ProcessPendingEvents() (which may generate // unwanted re-entrancies). (void)ShowModal(); } else // auto hide { // reenable other windows before hiding this one because otherwise // Windows wouldn't give the focus back to the window which had // been previously focused because it would still be disabled ReenableOtherWindows(); Hide(); } } else // not at maximum yet { DoAfterUpdate(); } // update the display in case yielding above didn't do it Update(); return m_state != Canceled; }
bool wxGenericProgressDialog::Create( const wxString& title, const wxString& message, int maximum, wxWindow *parent, int style ) { SetTopParent(parent); m_parentTop = wxGetTopLevelParent(parent); m_pdStyle = style; wxWindow* const realParent = GetParentForModalDialog(parent, GetWindowStyle()); if (!wxDialog::Create(realParent, wxID_ANY, title)) return false; 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 m_state = HasPDFlag(wxPD_CAN_ABORT) ? Continue : Uncancelable; // 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); int gauge_style = wxGA_HORIZONTAL; if ( style & wxPD_SMOOTH ) gauge_style |= wxGA_SMOOTH; #ifdef __WXMSW__ maximum /= m_factor; #endif m_gauge = new wxGauge ( this, wxID_ANY, maximum, wxDefaultPosition, // make the progress bar sufficiently long wxSize(wxMin(wxGetClientDisplayRect().width/3, 300), -1), gauge_style ); sizerTop->Add(m_gauge, 0, wxLEFT | wxRIGHT | wxTOP | wxEXPAND, 2*LAYOUT_MARGIN); m_gauge->SetValue(0); // create the estimated/remaining/total time zones if requested m_elapsed = m_estimated = m_remaining = NULL; // also count how many labels we really have size_t nTimeLabels = 0; wxSizer * const sizerLabels = new wxFlexGridSizer(2); if ( style & wxPD_ELAPSED_TIME ) { nTimeLabels++; m_elapsed = CreateLabel(GetElapsedLabel(), sizerLabels); } if ( style & wxPD_ESTIMATED_TIME ) { nTimeLabels++; m_estimated = CreateLabel(GetEstimatedLabel(), sizerLabels); } if ( style & wxPD_REMAINING_TIME ) { nTimeLabels++; m_remaining = CreateLabel(GetRemainingLabel(), sizerLabels); } sizerTop->Add(sizerLabels, 0, wxALIGN_CENTER_HORIZONTAL | wxTOP, LAYOUT_MARGIN); #if defined(__SMARTPHONE__) if ( HasPDFlag(wxPD_CAN_SKIP) ) SetRightMenu(wxID_SKIP, _("Skip")); if ( HasPDFlag(wxPD_CAN_ABORT) ) SetLeftMenu(wxID_CANCEL); #else m_btnAbort = m_btnSkip = NULL; wxBoxSizer *buttonSizer = new wxBoxSizer(wxHORIZONTAL); // Windows dialogs usually have buttons in the lower right corner const int sizerFlags = #if defined(__WXMSW__) || defined(__WXPM__) || defined(__WXOSX__) wxALIGN_RIGHT | wxALL #else // !MSW wxALIGN_CENTER_HORIZONTAL | wxBOTTOM | wxTOP #endif // MSW/!MSW ; if ( HasPDFlag(wxPD_CAN_SKIP) ) { m_btnSkip = new wxButton(this, wxID_SKIP, _("&Skip")); buttonSizer->Add(m_btnSkip, 0, sizerFlags, LAYOUT_MARGIN); } if ( HasPDFlag(wxPD_CAN_ABORT) ) { m_btnAbort = new wxButton(this, wxID_CANCEL); buttonSizer->Add(m_btnAbort, 0, sizerFlags, LAYOUT_MARGIN); } if ( !HasPDFlag(wxPD_CAN_SKIP | wxPD_CAN_ABORT) ) buttonSizer->AddSpacer(LAYOUT_MARGIN); sizerTop->Add(buttonSizer, 0, sizerFlags, LAYOUT_MARGIN ); #endif // __SMARTPHONE__/!__SMARTPHONE__ SetSizerAndFit(sizerTop); Centre(wxCENTER_FRAME | wxBOTH); DisableOtherWindows(); Show(); Enable(); // this one can be initialized even if the others are unknown for now // // NB: do it after calling Layout() to keep the labels correctly aligned if ( m_elapsed ) { SetTimeLabel(0, m_elapsed); } Update(); return true; }