Audacity  3.0.3
ProjectStatus.h
Go to the documentation of this file.
1 /**********************************************************************
2 
3 Audacity: A Digital Audio Editor
4 
5 ProjectStatus.h
6 
7 Paul Licameli
8 
9 **********************************************************************/
10 
11 #ifndef __AUDACITY_PROJECT_STATUS__
12 #define __AUDACITY_PROJECT_STATUS__
13 #endif
14 
15 #include <utility>
16 #include <vector>
17 #include <wx/event.h> // to declare custom event type
18 #include "ClientData.h" // to inherit
19 #include "Prefs.h"
20 
21 class AudacityProject;
22 class wxWindow;
23 
24 enum StatusBarField : int {
28 
30 };
31 
32 struct PROJECT_API ProjectStatusEvent final : wxEvent{
34  ~ProjectStatusEvent() override;
35  wxEvent *Clone() const override;
37 };
38 
39 // Type of event emitted by the project when its status message is set
41  EVT_PROJECT_STATUS_UPDATE, ProjectStatusEvent);
42 
43 class PROJECT_API ProjectStatus final
44  : public ClientData::Base
45  , public PrefsListener
46 {
47 public:
48  static ProjectStatus &Get( AudacityProject &project );
49  static const ProjectStatus &Get( const AudacityProject &project );
50 
51  explicit ProjectStatus( AudacityProject &project );
52  ProjectStatus( const ProjectStatus & ) = delete;
53  ProjectStatus &operator= ( const ProjectStatus & ) = delete;
54  ~ProjectStatus() override;
55 
56  // Type of a function to report translatable strings, and also report an extra
57  // margin, to request that the corresponding field of the status bar should
58  // be wide enough to contain any of those strings plus the margin.
59  using StatusWidthResult = std::pair< std::vector<TranslatableString>, unsigned >;
60  using StatusWidthFunction = std::function<
62  >;
63  using StatusWidthFunctions = std::vector< StatusWidthFunction >;
64 
65  // Typically a static instance of this struct is used.
66  struct PROJECT_API RegisteredStatusWidthFunction
67  {
68  explicit
70  };
71 
72  static const StatusWidthFunctions &GetStatusWidthFunctions();
73 
75  void Set(const TranslatableString &msg,
77 
78  // PrefsListener implementation
79  void UpdatePrefs() override;
80 
81 private:
83  TranslatableString mLastStatusMessages[ nStatusBarFields ];
84 };
TranslatableString
Holds a msgid for the translation catalog; may also bind format arguments.
Definition: TranslatableString.h:32
field
#define field(n, t)
Definition: ImportAUP.cpp:167
ProjectStatus::mProject
AudacityProject & mProject
Definition: ProjectStatus.h:82
ProjectStatusEvent
Definition: ProjectStatus.h:32
StatusBarField
StatusBarField
Definition: ProjectStatus.h:24
stateStatusBarField
@ stateStatusBarField
Definition: ProjectStatus.h:25
ProjectStatusEvent::~ProjectStatusEvent
~ProjectStatusEvent() override
ClientData::Base
A convenient default parameter for class template Site.
Definition: ClientData.h:28
TrackInfo::UpdatePrefs
AUDACITY_DLL_API void UpdatePrefs(wxWindow *pParent)
ProjectStatus::ProjectStatus
ProjectStatus(const ProjectStatus &)=delete
ClientData.h
Utility ClientData::Site to register hooks into a host class that attach client data.
PrefsListener
A listener notified of changes in preferences.
Definition: Prefs.h:392
ProjectStatus::StatusWidthFunctions
std::vector< StatusWidthFunction > StatusWidthFunctions
Definition: ProjectStatus.h:63
mainStatusBarField
@ mainStatusBarField
Definition: ProjectStatus.h:26
BasicUI::Get
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
ProjectStatus
Definition: ProjectStatus.h:46
ProjectStatus::StatusWidthFunction
std::function< StatusWidthResult(const AudacityProject &, StatusBarField) > StatusWidthFunction
Definition: ProjectStatus.h:62
rateStatusBarField
@ rateStatusBarField
Definition: ProjectStatus.h:27
ProjectStatus::StatusWidthResult
std::pair< std::vector< TranslatableString >, unsigned > StatusWidthResult
Definition: ProjectStatus.h:59
ProjectStatus::RegisteredStatusWidthFunction
Definition: ProjectStatus.h:67
AudacityProject
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:92
ProjectStatus::~ProjectStatus
~ProjectStatus() override
ProjectStatusEvent::mField
StatusBarField mField
Definition: ProjectStatus.h:36
Prefs.h
wxDECLARE_EXPORTED_EVENT
wxDECLARE_EXPORTED_EVENT(PROJECT_API, EVT_PROJECT_STATUS_UPDATE, ProjectStatusEvent)
nStatusBarFields
@ nStatusBarFields
Definition: ProjectStatus.h:29