Audacity 3.2.0
ProgressDialog.h
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ProgressDialog.h
6
7 Copyright
8 Leland Lucius
9 Vaughan Johnson
10
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 2 of the License, or
14 (at your option) any later version.
15
16*************************************************************************/
17
18#ifndef __AUDACITY_WIDGETS_PROGRESSDIALOG__
19#define __AUDACITY_WIDGETS_PROGRESSDIALOG__
20
21
22
23#include <vector>
24#include <wx/defs.h>
25#include <wx/evtloop.h> // member variable
26
27#include "wxPanelWrapper.h" // to inherit
28
29#include "BasicUI.h" // For ProgressResult
31
32class wxGauge;
33class wxStaticText;
34
36{
37 pdlgEmptyFlags = 0x00000000,
38 pdlgHideStopButton = 0x00000001,
40 pdlgHideElapsedTime = 0x00000004,
42
44};
45
49
50class AUDACITY_DLL_API ProgressDialog /* not final */ : public wxDialogWrapper
51{
52public:
54
55 // Display a simple message.
57 const TranslatableString & message = {},
58 int flags = pdlgDefaultFlags,
59 const TranslatableString & sRemainingLabelText = {});
60
61 using MessageColumn = std::vector< TranslatableString >;
62 using MessageTable = std::vector< MessageColumn >;
63
64protected:
65 // Display a table of messages.
66 // Each member of the table is a column of messages.
67 // Each member of a column is a string that should have no newlines,
68 // and each column should have the same number of elements, to make
69 // proper correspondences, but this is not checked.
71 const MessageTable & columns,
72 int flags = pdlgDefaultFlags,
73 const TranslatableString & sRemainingLabelText = {});
74
75public:
76 virtual ~ProgressDialog();
77
78 bool Create(const TranslatableString & title,
79 const TranslatableString & message = {},
80 int flags = pdlgDefaultFlags,
81 const TranslatableString & sRemainingLabelText = {});
82
83 void Reinit();
84
85protected:
86 bool Create(const TranslatableString & title,
87 const MessageTable & columns,
88 int flags = pdlgDefaultFlags,
89 const TranslatableString & sRemainingLabelText = {});
90
91public:
92 ProgressResult Update(int value, const TranslatableString & message = {});
93 ProgressResult Update(double current, const TranslatableString & message = {});
94 ProgressResult Update(double current, double total, const TranslatableString & message = {});
95 ProgressResult Update(wxULongLong_t current, wxULongLong_t total, const TranslatableString & message = {});
96 ProgressResult Update(wxLongLong current, wxLongLong total, const TranslatableString & message = {});
97 ProgressResult Update(wxLongLong_t current, wxLongLong_t total, const TranslatableString & message = {});
98 ProgressResult Update(int current, int total, const TranslatableString & message = {});
99
100 void SetMessage(const TranslatableString & message);
101
102protected:
103 wxWindowRef mHadFocus;
104
105 wxStaticText *mElapsed;
106 wxStaticText *mRemaining;
107 wxGauge *mGauge;
108
109 wxLongLong_t mStartTime;
110 wxLongLong_t mLastUpdate;
111 wxLongLong_t mYieldTimer;
112 int mLastValue; // gauge value, range = [0,1000]
113
115 bool mStop;
116
118
119 // MY: Booleans to hold the flag values
120 bool m_bShowElapsedTime = true;
121 bool m_bConfirmAction = false;
122
123private:
124 void Init();
125 bool SearchForWindow(const wxWindowList & list, const wxWindow *searchfor) const;
126 void OnCancel(wxCommandEvent & e);
127 void OnStop(wxCommandEvent & e);
128 void OnCloseWindow(wxCloseEvent & e);
129 void Beep() const;
130
131 bool ConfirmAction(const TranslatableString & sPrompt,
132 const TranslatableString & sTitle,
133 int iButtonID = -1);
134
135 void AddMessageAsColumn(wxBoxSizer * pSizer,
136 const MessageColumn &column, bool bFirstColumn);
137
138private:
139 // This guarantees we have an active event loop...possible during OnInit()
140 wxEventLoopGuarantor mLoop;
141
142 std::unique_ptr<wxWindowDisabler> mDisable;
143
144 wxStaticText *mMessage{} ;
145 int mLastW{ 0 };
146 int mLastH{ 0 };
147
148 DECLARE_EVENT_TABLE()
149};
150
151class AUDACITY_DLL_API TimerProgressDialog final : public ProgressDialog
152{
153public:
154 TimerProgressDialog(const wxLongLong_t duration,
156 const MessageTable & columns,
157 int flags = pdlgDefaultFlags,
158 const TranslatableString & sRemainingLabelText = {});
159
160 // Oh no, there is an inherited nullary "Update" in wxDialog!
161 // Choose another name then...
162 ProgressResult UpdateProgress();
163
164protected:
165 wxLongLong_t mDuration;
166
167 // Disallow direct use of the inherited overloads of Update because it
168 // doesn't support changes of message
170};
171
172#endif
Toolkit-neutral facade for basic user interface services.
static const auto title
ProgressDialogFlags
@ pdlgConfirmStopCancel
@ pdlgHideStopButton
@ pdlgHideElapsedTime
@ pdlgEmptyFlags
@ pdlgHideCancelButton
@ pdlgDefaultFlags
ProgressDialog Class.
std::unique_ptr< wxWindowDisabler > mDisable
wxStaticText * mElapsed
wxGauge * mGauge
wxStaticText * mRemaining
wxLongLong_t mStartTime
wxLongLong_t mLastUpdate
std::vector< MessageColumn > MessageTable
wxLongLong_t mYieldTimer
std::vector< TranslatableString > MessageColumn
wxEventLoopGuarantor mLoop
ProgressResult Update(int value, const TranslatableString &message={})
wxWindowRef mHadFocus
wxLongLong_t mDuration
Holds a msgid for the translation catalog; may also bind format arguments.
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"))
ProgressResult
Definition: BasicUI.h:145
void OnCloseWindow(wxCloseEvent &e)