Audacity 3.2.0
Public Types | Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | List of all members
ProgressDialog Class Reference

ProgressDialog Class. More...

#include <ProgressDialog.h>

Inheritance diagram for ProgressDialog:
[legend]
Collaboration diagram for ProgressDialog:
[legend]

Public Types

using MessageColumn = std::vector< TranslatableString >
 
using MessageTable = std::vector< MessageColumn >
 

Public Member Functions

 ProgressDialog ()
 Methods for ProgressDialog. More...
 
 ProgressDialog (const TranslatableString &title, const TranslatableString &message={}, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})
 
virtual ~ProgressDialog ()
 
bool Create (const TranslatableString &title, const TranslatableString &message={}, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})
 
void Reinit ()
 
ProgressResult Update (int value, const TranslatableString &message={})
 
ProgressResult Update (double current, const TranslatableString &message={})
 
ProgressResult Update (double current, double total, const TranslatableString &message={})
 
ProgressResult Update (wxULongLong_t current, wxULongLong_t total, const TranslatableString &message={})
 
ProgressResult Update (wxLongLong current, wxLongLong total, const TranslatableString &message={})
 
ProgressResult Update (wxLongLong_t current, wxLongLong_t total, const TranslatableString &message={})
 
ProgressResult Update (int current, int total, const TranslatableString &message={})
 
void SetMessage (const TranslatableString &message)
 
- Public Member Functions inherited from wxDialogWrapper
 wxDialogWrapper ()
 
 wxDialogWrapper (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
bool Create (wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))
 
void SetTitle (const TranslatableString &title)
 
void SetLabel (const TranslatableString &title)
 
void SetName (const TranslatableString &title)
 
void SetName ()
 
- Public Member Functions inherited from wxTabTraversalWrapper< wxDialog >
 wxTabTraversalWrapper (Args &&... args)
 
 wxTabTraversalWrapper (const wxTabTraversalWrapper &)=delete
 
 wxTabTraversalWrapper (wxTabTraversalWrapper &&)=delete
 
wxTabTraversalWrapperoperator= (const wxTabTraversalWrapper &)=delete
 
wxTabTraversalWrapperoperator= (wxTabTraversalWrapper &&)=delete
 

Protected Member Functions

 ProgressDialog (const TranslatableString &title, const MessageTable &columns, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})
 
bool Create (const TranslatableString &title, const MessageTable &columns, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})
 

Protected Attributes

wxWindowRef mHadFocus
 
wxStaticText * mElapsed
 
wxStaticText * mRemaining
 
wxGauge * mGauge
 
wxLongLong_t mStartTime
 
wxLongLong_t mLastUpdate
 
wxLongLong_t mYieldTimer
 
int mLastValue
 
bool mCancel
 
bool mStop
 
bool mIsTransparent
 
bool m_bShowElapsedTime = true
 
bool m_bConfirmAction = false
 

Private Member Functions

void Init ()
 
bool SearchForWindow (const wxWindowList &list, const wxWindow *searchfor) const
 
void OnCancel (wxCommandEvent &e)
 
void OnStop (wxCommandEvent &e)
 
void OnCloseWindow (wxCloseEvent &e)
 
void Beep () const
 
bool ConfirmAction (const TranslatableString &sPrompt, const TranslatableString &sTitle, int iButtonID=-1)
 
void AddMessageAsColumn (wxBoxSizer *pSizer, const MessageColumn &column, bool bFirstColumn)
 

Private Attributes

wxEventLoopGuarantor mLoop
 
std::unique_ptr< wxWindowDisabler > mDisable
 
wxStaticText * mMessage {}
 
int mLastW { 0 }
 
int mLastH { 0 }
 

Detailed Description

ProgressDialog Class.

Custom progress dialog with Audacity specific semantics.

Definition at line 50 of file ProgressDialog.h.

Member Typedef Documentation

◆ MessageColumn

Definition at line 61 of file ProgressDialog.h.

◆ MessageTable

Definition at line 62 of file ProgressDialog.h.

Constructor & Destructor Documentation

◆ ProgressDialog() [1/3]

ProgressDialog::ProgressDialog ( )

Methods for ProgressDialog.

Definition at line 996 of file ProgressDialog.cpp.

998{
999}

◆ ProgressDialog() [2/3]

ProgressDialog::ProgressDialog ( const TranslatableString title,
const TranslatableString message = {},
int  flags = pdlgDefaultFlags,
const TranslatableString sRemainingLabelText = {} 
)

Definition at line 1001 of file ProgressDialog.cpp.

1006{
1007 Create(title, message, flags, sRemainingLabelText);
1008}
static const auto title
bool Create(const TranslatableString &title, const TranslatableString &message={}, int flags=pdlgDefaultFlags, const TranslatableString &sRemainingLabelText={})

References Create(), and title.

Here is the call graph for this function:

◆ ProgressDialog() [3/3]

ProgressDialog::ProgressDialog ( const TranslatableString title,
const MessageTable columns,
int  flags = pdlgDefaultFlags,
const TranslatableString sRemainingLabelText = {} 
)
protected

Definition at line 1010 of file ProgressDialog.cpp.

1015{
1016 Create(title, columns, flags, sRemainingLabelText);
1017}

References Create(), and title.

Here is the call graph for this function:

◆ ~ProgressDialog()

ProgressDialog::~ProgressDialog ( )
virtual

Definition at line 1022 of file ProgressDialog.cpp.

1023{
1024 // Delete the window disabler before hiding the dialog to allow
1025 // focus to return to the original window.
1026 mDisable.reset();
1027
1028 if (IsShown())
1029 {
1030 Show(false);
1031
1032 Beep();
1033 }
1034
1035#if defined(__WXGTK__)
1036 // Under GTK, when applying any effect that prompts the user, it's more than
1037 // like that FindFocus() will return NULL. So, make sure something has focus.
1038 if (GetParent()) {
1039 GetParent()->SetFocus();
1040 }
1041#endif
1042
1043 // Restore saved focus, but only if the window still exists.
1044 //
1045 // PRL: I'm conservatively preserving the old existence test, but I think
1046 // it's redundant now that we use wxWindowRef to avoid a dangling pointer
1047 if (mHadFocus && SearchForWindow(wxTopLevelWindows, mHadFocus)) {
1048 mHadFocus->SetFocus();
1049 }
1050}
std::unique_ptr< wxWindowDisabler > mDisable
void Beep() const
bool SearchForWindow(const wxWindowList &list, const wxWindow *searchfor) const
wxWindowRef mHadFocus

References Beep(), mDisable, mHadFocus, and SearchForWindow().

Here is the call graph for this function:

Member Function Documentation

◆ AddMessageAsColumn()

void ProgressDialog::AddMessageAsColumn ( wxBoxSizer *  pSizer,
const MessageColumn column,
bool  bFirstColumn 
)
private

Definition at line 1102 of file ProgressDialog.cpp.

1104 {
1105
1106 // Assuming that we don't want empty columns, bail out if there is no text.
1107 if (column.empty())
1108 return;
1109
1110 // Join strings
1111 auto sText = column[0];
1112 std::for_each( column.begin() + 1, column.end(),
1113 [&](const TranslatableString &text)
1114 { sText.Join( text, wxT("\n") ); });
1115
1116 // Create a statictext object and add to the sizer
1117 wxStaticText* oText = safenew wxStaticText(this,
1118 wxID_ANY,
1119 sText.Translation(),
1120 wxDefaultPosition,
1121 wxDefaultSize,
1122 wxALIGN_LEFT);
1123 oText->SetName(sText.Translation()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1124
1125 // If this is the first column then set the mMessage pointer so non-TimerRecord usages
1126 // will still work correctly in SetMessage()
1127 if (bFirstColumn) {
1128 mMessage = oText;
1129 }
1130
1131 pSizer->Add(oText, 1, wxEXPAND | wxALL, 5);
1132}
#define safenew
Definition: MemoryX.h:10
wxStaticText * mMessage
Holds a msgid for the translation catalog; may also bind format arguments.
wxWeakRef< wxTextCtrl > sText
Definition: LogWindow.cpp:44

References mMessage, safenew, and anonymous_namespace{LogWindow.cpp}::sText.

Referenced by Create().

Here is the caller graph for this function:

◆ Beep()

void ProgressDialog::Beep ( ) const
private

Definition at line 1603 of file ProgressDialog.cpp.

1604{
1605 int after;
1606 bool should;
1607 wxString name;
1608
1609 gPrefs->Read(wxT("/GUI/BeepOnCompletion"), &should, false);
1610 gPrefs->Read(wxT("/GUI/BeepAfterDuration"), &after, 60);
1611 gPrefs->Read(wxT("/GUI/BeepFileName"), &name, wxEmptyString);
1612
1613 if (should && wxGetUTCTimeMillis().GetValue() - mStartTime > after * 1000)
1614 {
1615 wxBusyCursor busy;
1616 wxSound s;
1617
1618 if (name.empty())
1619 {
1620 s.Create(sizeof(beep), beep);
1621 }
1622 else
1623 {
1624 s.Create(name);
1625 }
1626
1627 if (s.IsOk())
1628 {
1629 s.Play(wxSOUND_SYNC);
1630 }
1631 }
1632}
const TranslatableString name
Definition: Distortion.cpp:82
FileConfig * gPrefs
Definition: Prefs.cpp:71
static const unsigned char beep[]
wxLongLong_t mStartTime

References beep, TranslatableString::empty(), gPrefs, mStartTime, and name.

Referenced by ~ProgressDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ConfirmAction()

bool ProgressDialog::ConfirmAction ( const TranslatableString sPrompt,
const TranslatableString sTitle,
int  iButtonID = -1 
)
private

Definition at line 1636 of file ProgressDialog.cpp.

1638 {
1639
1640 // Check if confirmations are enabled?
1641 // If not then return TRUE
1642 if (m_bConfirmAction == false) {
1643 return true;
1644 }
1645
1646 AudacityMessageDialog dlgMessage(
1647 this,
1648 sPrompt,
1649 sTitle,
1650 wxYES_NO | wxICON_QUESTION | wxNO_DEFAULT | wxSTAY_ON_TOP );
1651 int iAction = dlgMessage.ShowModal();
1652
1653 bool bReturn = (iAction == wxID_YES);
1654 if ((bReturn == false) && (iButtonID > -1)) {
1655 // Set the focus back to the relevant button
1656 FindWindowById(iButtonID, this)->SetFocus();
1657 }
1658
1659 return bReturn;
1660}
Wrap wxMessageDialog so that caption IS translatable.

References m_bConfirmAction.

Referenced by OnCancel(), OnCloseWindow(), and OnStop().

Here is the caller graph for this function:

◆ Create() [1/2]

bool ProgressDialog::Create ( const TranslatableString title,
const MessageTable columns,
int  flags = pdlgDefaultFlags,
const TranslatableString sRemainingLabelText = {} 
)
protected

Definition at line 1153 of file ProgressDialog.cpp.

1157{
1158 Init();
1159
1160 wxWindow *parent =
1161#if defined(__WXMAC__)
1162 // Bug 2703: In release builds, the progress dialog will fall behind
1163 // the top level dialog (like effects dialogs). This does not happen
1164 // in debug builds and I was not able to track down the reason. So,
1165 // this is a workaround and should be reviewed as some point, like
1166 // when upgrading to the next WX version.
1167 GetParentForModalDialog(mHadFocus, 0);
1168#else
1169 GetParentForModalDialog(nullptr, 0);
1170#endif
1171
1172 // Set this boolean to indicate if we are using the "Elapsed" labels
1174 // Set this boolean to indicate if we confirm the Cancel/Stop actions
1176
1177 bool success = wxDialogWrapper::Create(parent,
1178 wxID_ANY,
1179 title,
1180 wxDefaultPosition,
1181 wxDefaultSize,
1182 wxDEFAULT_DIALOG_STYLE |
1183 wxFRAME_FLOAT_ON_PARENT);
1184 if (!success)
1185 {
1186 return false;
1187 }
1188
1189 SetName(); // This was added for NVDA screen reader and may now be redundant.
1190 SetExtraStyle(GetExtraStyle() | wxWS_EX_TRANSIENT); // Ancient code. Is it still required?
1191
1192 {
1193 wxWindow *window;
1194
1195 // There may be more than one column, so create a BoxSizer container
1196 auto uColSizer = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
1197 auto colSizer = uColSizer.get();
1198
1199 // TODO: this setting-up of a grid of text in a sizer might be worth
1200 // extracting as a utility for building other dialogs.
1201 {
1202 bool bFirstCol = true;
1203 for (const auto &column : columns) {
1204 AddMessageAsColumn(colSizer, column, bFirstCol);
1205 bFirstCol = false;
1206 }
1207 }
1208
1209 // and put message column(s) into a main vertical sizer.
1210 auto vertSizer = std::make_unique<wxBoxSizer>(wxVERTICAL);
1211 vertSizer->Add(uColSizer.release(), 1, wxEXPAND | wxALL, 10);
1212
1213 mGauge = safenew wxGauge(this,
1214 wxID_ANY,
1215 1000,
1216 wxDefaultPosition,
1217 wxDefaultSize,
1218 wxGA_HORIZONTAL);
1219 vertSizer->Add(mGauge, 0, wxEXPAND | wxLEFT | wxRIGHT | wxBOTTOM, 10);
1220
1221 {
1222 auto uGridSizer = std::make_unique<wxFlexGridSizer>(2, 2, 10, 10);
1223 // Only one row if we are not going to show the elapsed time
1224 if (m_bShowElapsedTime == false) {
1225 uGridSizer = std::make_unique<wxFlexGridSizer>(1, 2, 10, 10);
1226 }
1227 auto gridSizer = uGridSizer.get();
1228
1229 if (m_bShowElapsedTime) {
1230 window = safenew wxStaticText(this,
1231 wxID_ANY,
1232 _("Elapsed Time:"),
1233 wxDefaultPosition,
1234 wxDefaultSize,
1235 wxALIGN_RIGHT);
1236
1237 window->SetName(window->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1238 gridSizer->Add(window, 0, wxALIGN_RIGHT);
1239
1240 mElapsed = safenew wxStaticText(this,
1241 wxID_ANY,
1242 wxT("00:00:00"),
1243 wxDefaultPosition,
1244 wxDefaultSize,
1245 wxALIGN_LEFT);
1246
1247 mElapsed->SetName(mElapsed->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1248 gridSizer->Add(mElapsed, 0, wxALIGN_LEFT);
1249 }
1250
1251 // Customised "Remaining" label text
1252 auto sRemainingText = sRemainingLabelText;
1253 if (sRemainingText.empty()) {
1254 sRemainingText = XO("Remaining Time:");
1255 }
1256
1257 window = safenew wxStaticText(this,
1258 wxID_ANY,
1259 sRemainingText.Translation(),
1260 wxDefaultPosition,
1261 wxDefaultSize,
1262 wxALIGN_RIGHT);
1263 window->SetName(window->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1264 gridSizer->Add(window, 0, wxALIGN_RIGHT);
1265
1266 mRemaining = safenew wxStaticText(this,
1267 wxID_ANY,
1268 wxT("00:00:00"),
1269 wxDefaultPosition,
1270 wxDefaultSize,
1271 wxALIGN_LEFT);
1272 mRemaining->SetName(mRemaining->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1273 gridSizer->Add(mRemaining, 0, wxALIGN_LEFT);
1274
1275 vertSizer->Add(uGridSizer.release(), 0, wxALIGN_CENTER | wxLEFT | wxRIGHT | wxBOTTOM, 10);
1276 }
1277
1278 {
1279 auto uButtonBar = std::make_unique<wxBoxSizer>(wxHORIZONTAL);
1280 auto buttonBarSizer = uButtonBar.get();
1281
1282 if (!(flags & pdlgHideStopButton)) {
1283 window = safenew wxButton(this, wxID_OK, _("Stop"));
1284 buttonBarSizer->Add(window, 0, wxRIGHT, 10);
1285 }
1286 if (!(flags & pdlgHideCancelButton)) {
1287 window = safenew wxButton(this, wxID_CANCEL, _("Cancel"));
1288 buttonBarSizer->Add(window, 0, wxRIGHT, 10);
1289 }
1290 vertSizer->Add(uButtonBar.release(), 0, wxALIGN_RIGHT | wxRIGHT | wxBOTTOM, 10);
1291 }
1292
1293 SetSizerAndFit(vertSizer.release());
1294 }
1295 Layout();
1296
1297 // Center progress bar on Parent if it is nice and wide, otherwise Center on screen.
1298 int parentWidth = -1, parentHeight=-1;
1299 if( GetParent() ) GetParent()->GetSize( &parentWidth, &parentHeight );
1300 if (parentWidth > 400)
1301 CenterOnParent();
1302 else
1303 CenterOnScreen();
1304
1305 Reinit();
1306
1307 // Even though we won't necessarily show the dialog due to the 500ms
1308 // delay, we MUST disable other windows/menus anyway since we run the risk
1309 // of allowing other tasks to run before this one is complete.
1310 //
1311 // Reviewed this code per Proposed Features #1, at
1312 // http://wiki.audacityteam.org/wiki/Proposal_Timer_Record_Improvements.
1313 // Note that this causes a problem for Timer Record wait dialog
1314 // (see TimerRecordDialog::RunWaitDialog()), because it makes it
1315 // impossible to do any editing, even in other open projects,
1316 // while waiting for Timer Record to start -- and then also
1317 // while it's recording, it has a ProgressDialog, so really,
1318 // no editing in any project until Timer Record finishes.
1319 mDisable = std::make_unique<wxWindowDisabler>(this);
1320
1321 return true;
1322}
#define XO(s)
Definition: Internat.h:31
#define _(s)
Definition: Internat.h:75
@ pdlgConfirmStopCancel
@ pdlgHideStopButton
@ pdlgHideElapsedTime
@ pdlgHideCancelButton
wxStaticText * mElapsed
wxGauge * mGauge
void AddMessageAsColumn(wxBoxSizer *pSizer, const MessageColumn &column, bool bFirstColumn)
wxStaticText * mRemaining
bool Create(wxWindow *parent, wxWindowID id, const TranslatableString &title, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE, const TranslatableString &name=XO("Dialog"))

References _, AddMessageAsColumn(), wxDialogWrapper::Create(), Init(), m_bConfirmAction, m_bShowElapsedTime, mDisable, mElapsed, mGauge, mHadFocus, mRemaining, pdlgConfirmStopCancel, pdlgHideCancelButton, pdlgHideElapsedTime, pdlgHideStopButton, Reinit(), safenew, wxDialogWrapper::SetName(), title, and XO.

Here is the call graph for this function:

◆ Create() [2/2]

bool ProgressDialog::Create ( const TranslatableString title,
const TranslatableString message = {},
int  flags = pdlgDefaultFlags,
const TranslatableString sRemainingLabelText = {} 
)

Definition at line 1134 of file ProgressDialog.cpp.

1138{
1139 MessageTable columns(1);
1140 columns.back().push_back(message);
1141 auto result = Create(title, columns, flags, sRemainingLabelText);
1142
1143 if (result) {
1144 // Record some values used in case of change of message
1145 // TODO: make the following work in case of message tables
1146 wxClientDC dc(this);
1147 dc.GetMultiLineTextExtent(message.Translation(), &mLastW, &mLastH);
1148 }
1149
1150 return result;
1151}
std::vector< MessageColumn > MessageTable
wxString Translation() const

References Create(), mLastH, mLastW, title, and TranslatableString::Translation().

Referenced by Create(), and ProgressDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Init()

void ProgressDialog::Init ( )
private

Definition at line 1052 of file ProgressDialog.cpp.

1053{
1054 // There's a problem where the focus is not returned to the window that had
1055 // it before creating this object. The reason is because the focus events
1056 // that are sent to the parent window after the wxWindowDisabler are created
1057 // are tossed and focus will not get restored to the parent once the disabler
1058 // is deleted. (See bug #1173 for more info)
1059 //
1060 // So, we capture and restore the focus ourselves.
1061 mHadFocus = wxWindow::FindFocus();
1062
1063#if defined(__WXGTK__)
1064 // Under GTK, when applying any effect that prompts the user, it's more than
1065 // likely that FindFocus() will return NULL. So, make sure something has focus.
1066 if (GetParent())
1067 {
1068 GetParent()->SetFocus();
1069 }
1070#endif
1071}

References mHadFocus.

Referenced by Create().

Here is the caller graph for this function:

◆ OnCancel()

void ProgressDialog::OnCancel ( wxCommandEvent &  e)
private

Definition at line 1571 of file ProgressDialog.cpp.

1572{
1573 if (!ConfirmAction(
1574 XO("Are you sure you wish to cancel?"),
1575 XO("Confirm Cancel"), wxID_CANCEL)) {
1576 return;
1577 }
1578 FindWindowById(wxID_CANCEL, this)->Disable();
1579 mCancel = true;
1580}
bool ConfirmAction(const TranslatableString &sPrompt, const TranslatableString &sTitle, int iButtonID=-1)

References ConfirmAction(), mCancel, and XO.

Here is the call graph for this function:

◆ OnCloseWindow()

void ProgressDialog::OnCloseWindow ( wxCloseEvent &  e)
private

Definition at line 1594 of file ProgressDialog.cpp.

1595{
1596 if (!ConfirmAction(
1597 XO("Are you sure you wish to close?"), XO("Confirm Close"))) {
1598 return;
1599 }
1600 mCancel = true;
1601}

References ConfirmAction(), mCancel, and XO.

Here is the call graph for this function:

◆ OnStop()

void ProgressDialog::OnStop ( wxCommandEvent &  e)
private

Definition at line 1582 of file ProgressDialog.cpp.

1583{
1584 if (!ConfirmAction(
1585 XO("Are you sure you wish to stop?"),
1586 XO("Confirm Stop"), wxID_OK)) {
1587 return;
1588 }
1589 FindWindowById(wxID_OK, this)->Disable();
1590 mCancel = false;
1591 mStop = true;
1592}

References ConfirmAction(), mCancel, mStop, and XO.

Here is the call graph for this function:

◆ Reinit()

void ProgressDialog::Reinit ( )

Definition at line 1073 of file ProgressDialog.cpp.

1074{
1075 mLastValue = 0;
1076
1077 mStartTime = wxGetUTCTimeMillis().GetValue();
1080 mCancel = false;
1081 mStop = false;
1082
1083 // Because wxGTK is very sensitive about maintaining focus when
1084 // this window is not shown, we always show it. But, since we
1085 // want a 500ms delay before it's actually visible for those
1086 // quick tasks, we show it as transparent. If the initial
1087 // delay is exceeded, then we reset the dialog to full opacity.
1088 SetTransparent(0);
1089 mIsTransparent = true;
1090
1091 auto button = FindWindowById(wxID_CANCEL, this);
1092 if (button)
1093 button->Enable();
1094 button = FindWindowById(wxID_OK, this);
1095 if (button)
1096 button->Enable();
1097
1098 wxDialogWrapper::Show(true);
1099}
wxLongLong_t mLastUpdate
wxLongLong_t mYieldTimer

References mCancel, mIsTransparent, mLastUpdate, mLastValue, mStartTime, mStop, and mYieldTimer.

Referenced by Create().

Here is the caller graph for this function:

◆ SearchForWindow()

bool ProgressDialog::SearchForWindow ( const wxWindowList &  list,
const wxWindow *  searchfor 
) const
private

Definition at line 1558 of file ProgressDialog.cpp.

1559{
1560 for (auto win : list)
1561 {
1562 if (win == searchfor || SearchForWindow(win->GetChildren(), searchfor))
1563 {
1564 return true;
1565 }
1566 }
1567
1568 return false;
1569}

References SearchForWindow().

Referenced by SearchForWindow(), and ~ProgressDialog().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ SetMessage()

void ProgressDialog::SetMessage ( const TranslatableString message)

Definition at line 1510 of file ProgressDialog.cpp.

1511{
1512 if (!message.empty())
1513 {
1514 mMessage->SetLabel(message.Translation());
1515
1516 int w, h;
1517 wxClientDC dc(mMessage);
1518 dc.GetMultiLineTextExtent(message.Translation(), &w, &h);
1519
1520 auto sizeUpdated = false;
1521 const auto currentSize = GetClientSize();
1522 auto ds = currentSize;
1523
1524 // TODO: make the following work in case of message tables
1525 if (w > mLastW)
1526 {
1527 ds.x += (w - mLastW);
1528 sizeUpdated = true;
1529 mLastW = w;
1530 }
1531
1532 if (h > mLastH)
1533 {
1534 ds.y += (h - mLastH);
1535 sizeUpdated = true;
1536 mLastH = h;
1537 }
1538
1539 if (sizeUpdated)
1540 {
1541#if defined(__WXMAC__)
1542 wxSize sz = mMessage->GetSize();
1543 mMessage->SetMinSize(wxSize(wxMax(sz.x, mLastW), wxMax(sz.y, mLastH)));
1544#endif
1545 // No need to adjust for the margin here since we only add
1546 // to the existing dimensions.
1547 ds.x = wxMax(wxMax(ds.x, mLastW), wxMax(ds.y, mLastH));
1548 SetClientSize(ds);
1549 SetPosition(GetPosition() - (ds - currentSize) / 2);
1550 wxDialogWrapper::Update();
1551 }
1552 }
1553}

References TranslatableString::empty(), mLastH, mLastW, mMessage, and TranslatableString::Translation().

Referenced by anonymous_namespace{wxWidgetsBasicUI.cpp}::MyProgressDialog::SetMessage(), and Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update() [1/7]

ProgressResult ProgressDialog::Update ( double  current,
const TranslatableString message = {} 
)

Definition at line 1421 of file ProgressDialog.cpp.

1423{
1424 return Update((int)(current * 1000), message);
1425}
ProgressResult Update(int value, const TranslatableString &message={})

References Update().

Here is the call graph for this function:

◆ Update() [2/7]

ProgressResult ProgressDialog::Update ( double  current,
double  total,
const TranslatableString message = {} 
)

Definition at line 1494 of file ProgressDialog.cpp.

1496{
1497 if (total != 0)
1498 {
1499 return Update((int)(current * 1000.0 / total), message);
1500 }
1501 else
1502 {
1503 return Update(1000, message);
1504 }
1505}

References Update().

Here is the call graph for this function:

◆ Update() [3/7]

ProgressResult ProgressDialog::Update ( int  current,
int  total,
const TranslatableString message = {} 
)

Definition at line 1478 of file ProgressDialog.cpp.

1480{
1481 if (total != 0)
1482 {
1483 return Update((int)(current * ((double)(1000.0 / total))), message);
1484 }
1485 else
1486 {
1487 return Update(1000, message);
1488 }
1489}

References Update().

Here is the call graph for this function:

◆ Update() [4/7]

ProgressResult ProgressDialog::Update ( int  value,
const TranslatableString message = {} 
)

Definition at line 1327 of file ProgressDialog.cpp.

1329{
1330 if (mCancel)
1331 {
1332 // for compatibility with old Update, that returned false on cancel
1334 }
1335 else if (mStop)
1336 {
1337 return ProgressResult::Stopped;
1338 }
1339
1340 wxLongLong_t now = wxGetUTCTimeMillis().GetValue();
1341 wxLongLong_t elapsed = now - mStartTime;
1342
1343 if (elapsed < 500)
1344 {
1346 }
1347
1348 if (mIsTransparent)
1349 {
1350 SetTransparent(255);
1351 mIsTransparent = false;
1352 }
1353
1354 if (value <= 0)
1355 {
1356 value = 1;
1357 }
1358
1359 if (value > 1000)
1360 {
1361 value = 1000;
1362 }
1363
1364 wxLongLong_t estimate = elapsed * 1000ll / value;
1365 wxLongLong_t remains = (estimate + mStartTime) - now;
1366
1367 SetMessage(message);
1368
1369 if (value != mLastValue)
1370 {
1371 mGauge->SetValue(value);
1372 mGauge->Update();
1373 mLastValue = value;
1374 }
1375
1376 // Only update if a full second has passed or track progress is complete
1377 if ((now - mLastUpdate > 1000) || (value == 1000))
1378 {
1379 if (m_bShowElapsedTime) {
1380 wxTimeSpan tsElapsed(0, 0, 0, elapsed);
1381 mElapsed->SetLabel(tsElapsed.Format(wxT("%H:%M:%S")));
1382 mElapsed->SetName(mElapsed->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1383 mElapsed->Update();
1384 }
1385
1386 wxTimeSpan tsRemains(0, 0, 0, remains);
1387 mRemaining->SetLabel(tsRemains.Format(wxT("%H:%M:%S")));
1388 mRemaining->SetName(mRemaining->GetLabel()); // fix for bug 577 (NVDA/Narrator screen readers do not read static text in dialogs)
1389 mRemaining->Update();
1390
1391 mLastUpdate = now;
1392 }
1393
1394 wxDialogWrapper::Update();
1395
1396 // Copied from wx 3.0.2 generic progress dialog
1397 //
1398 // we have to yield because not only we want to update the display but
1399 // also to process the clicks on the cancel and skip buttons
1400 // NOTE: using YieldFor() this call shouldn't give re-entrancy problems
1401 // for event handlers not interested to UI/user-input events.
1402 //
1403 // LL: Added timer category to prevent extreme delays when processing effects
1404 // (and probably other things). I do not yet know why this happens and
1405 // I'm not too keen on having timer events processed here, but you do
1406 // what you have to do.
1407
1408 // Nyquist effects call Update on every callback, but YieldFor is
1409 // quite slow on Linux / Mac, so don't call too frequently. (bug 1575)
1410 if ((now - mYieldTimer > 50) || (value == 1000)) {
1411 wxEventLoopBase::GetActive()->YieldFor(wxEVT_CATEGORY_UI | wxEVT_CATEGORY_USER_INPUT | wxEVT_CATEGORY_TIMER);
1412 mYieldTimer = now;
1413 }
1414
1416}
void SetMessage(const TranslatableString &message)

References RefreshCode::Cancelled, m_bShowElapsedTime, mCancel, mElapsed, mGauge, mIsTransparent, mLastUpdate, mLastValue, mRemaining, mStartTime, mStop, mYieldTimer, SetMessage(), and BasicUI::Success.

Referenced by ProjectFileIO::CopyTo(), ImportRaw(), TransportUtilities::PlayCurrentRegionAndWait(), TransportUtilities::PlayPlayRegionAndWait(), TransportUtilities::RecordAndWait(), RemoveDependencies(), and Update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Update() [5/7]

ProgressResult ProgressDialog::Update ( wxLongLong  current,
wxLongLong  total,
const TranslatableString message = {} 
)

Definition at line 1446 of file ProgressDialog.cpp.

1448{
1449 if (total.GetValue() != 0)
1450 {
1451 return Update((int)(current.GetValue() * 1000ll / total.GetValue()), message);
1452 }
1453 else
1454 {
1455 return Update(1000, message);
1456 }
1457}

References Update().

Here is the call graph for this function:

◆ Update() [6/7]

ProgressResult ProgressDialog::Update ( wxLongLong_t  current,
wxLongLong_t  total,
const TranslatableString message = {} 
)

Definition at line 1462 of file ProgressDialog.cpp.

1464{
1465 if (total != 0)
1466 {
1467 return Update((int)(current * 1000ll / total), message);
1468 }
1469 else
1470 {
1471 return Update(1000, message);
1472 }
1473}

References Update().

Here is the call graph for this function:

◆ Update() [7/7]

ProgressResult ProgressDialog::Update ( wxULongLong_t  current,
wxULongLong_t  total,
const TranslatableString message = {} 
)

Definition at line 1430 of file ProgressDialog.cpp.

1432{
1433 if (total != 0)
1434 {
1435 return Update((int)(current * 1000 / total), message);
1436 }
1437 else
1438 {
1439 return Update(1000, message);
1440 }
1441}

References Update().

Here is the call graph for this function:

Member Data Documentation

◆ m_bConfirmAction

bool ProgressDialog::m_bConfirmAction = false
protected

Definition at line 121 of file ProgressDialog.h.

Referenced by ConfirmAction(), and Create().

◆ m_bShowElapsedTime

bool ProgressDialog::m_bShowElapsedTime = true
protected

Definition at line 120 of file ProgressDialog.h.

Referenced by Create(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mCancel

bool ProgressDialog::mCancel
protected

◆ mDisable

std::unique_ptr<wxWindowDisabler> ProgressDialog::mDisable
private

Definition at line 142 of file ProgressDialog.h.

Referenced by Create(), and ~ProgressDialog().

◆ mElapsed

wxStaticText* ProgressDialog::mElapsed
protected

Definition at line 105 of file ProgressDialog.h.

Referenced by Create(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mGauge

wxGauge* ProgressDialog::mGauge
protected

Definition at line 107 of file ProgressDialog.h.

Referenced by Create(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mHadFocus

wxWindowRef ProgressDialog::mHadFocus
protected

Definition at line 103 of file ProgressDialog.h.

Referenced by Create(), Init(), and ~ProgressDialog().

◆ mIsTransparent

bool ProgressDialog::mIsTransparent
protected

Definition at line 117 of file ProgressDialog.h.

Referenced by Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mLastH

int ProgressDialog::mLastH { 0 }
private

Definition at line 146 of file ProgressDialog.h.

Referenced by Create(), and SetMessage().

◆ mLastUpdate

wxLongLong_t ProgressDialog::mLastUpdate
protected

Definition at line 110 of file ProgressDialog.h.

Referenced by Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mLastValue

int ProgressDialog::mLastValue
protected

Definition at line 112 of file ProgressDialog.h.

Referenced by Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mLastW

int ProgressDialog::mLastW { 0 }
private

Definition at line 145 of file ProgressDialog.h.

Referenced by Create(), and SetMessage().

◆ mLoop

wxEventLoopGuarantor ProgressDialog::mLoop
private

Definition at line 140 of file ProgressDialog.h.

◆ mMessage

wxStaticText* ProgressDialog::mMessage {}
private

Definition at line 144 of file ProgressDialog.h.

Referenced by AddMessageAsColumn(), and SetMessage().

◆ mRemaining

wxStaticText* ProgressDialog::mRemaining
protected

Definition at line 106 of file ProgressDialog.h.

Referenced by Create(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mStartTime

wxLongLong_t ProgressDialog::mStartTime
protected

Definition at line 109 of file ProgressDialog.h.

Referenced by Beep(), Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mStop

bool ProgressDialog::mStop
protected

Definition at line 115 of file ProgressDialog.h.

Referenced by OnStop(), Reinit(), Update(), and TimerProgressDialog::UpdateProgress().

◆ mYieldTimer

wxLongLong_t ProgressDialog::mYieldTimer
protected

Definition at line 111 of file ProgressDialog.h.

Referenced by Reinit(), and Update().


The documentation for this class was generated from the following files: