Audacity 3.2.0
ProjectWindows.cpp
Go to the documentation of this file.
1/*!********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 @file ProjectWindows.cpp
6
7 Paul Licameli split from Project.cpp
8
9**********************************************************************/
10
11#include "ProjectWindows.h"
12#include "Project.h"
13
14#include <wx/frame.h>
15
16namespace {
18{
20 static const ProjectWindows &Get( const AudacityProject &project );
22 : mAttachedWindows{project}
23 {}
24
25 wxWeakRef< wxWindow > mPanel{};
26 wxWeakRef< wxFrame > mFrame{};
27
29};
30
33 return std::make_unique<ProjectWindows>(project);
34 }
35};
36
38{
39 return project.AttachedObjects::Get< ProjectWindows >( key );
40}
41
43{
44 return Get( const_cast< AudacityProject & >( project ) );
45}
46}
47
48AUDACITY_DLL_API wxWindow &GetProjectPanel( AudacityProject &project )
49{
50 auto ptr = ProjectWindows::Get(project).mPanel;
51 if ( !ptr )
53 return *ptr;
54}
55
56AUDACITY_DLL_API const wxWindow &GetProjectPanel(
58{
59 auto ptr = ProjectWindows::Get(project).mPanel;
60 if ( !ptr )
62 return *ptr;
63}
64
65AUDACITY_DLL_API void SetProjectPanel(
66 AudacityProject &project, wxWindow &panel )
67{
68 ProjectWindows::Get(project).mPanel = &panel;
69}
70
71AUDACITY_DLL_API wxFrame &GetProjectFrame( AudacityProject &project )
72{
73 auto ptr = ProjectWindows::Get(project).mFrame;
74 if ( !ptr )
76 return *ptr;
77}
78
79AUDACITY_DLL_API const wxFrame &GetProjectFrame( const AudacityProject &project )
80{
81 auto ptr = ProjectWindows::Get(project).mFrame;
82 if ( !ptr )
84 return *ptr;
85}
86
88 if (!project)
89 return nullptr;
90 return ProjectWindows::Get(*project).mFrame;
91}
92
93const wxFrame *FindProjectFrame( const AudacityProject *project ) {
94 if (!project)
95 return nullptr;
96 return ProjectWindows::Get(*project).mFrame;
97}
98
100{
101 ProjectWindows::Get(project).mFrame = &frame;
102}
103
105{
106 return ProjectWindows::Get(project).mAttachedWindows;
107}
#define THROW_INCONSISTENCY_EXCEPTION
Throw InconsistencyException, using C++ preprocessor to identify the source code location.
wxFrame * FindProjectFrame(AudacityProject *project)
Get a pointer to the window associated with a project, or null if the given pointer is null,...
void SetProjectFrame(AudacityProject &project, wxFrame &frame)
AUDACITY_DLL_API wxWindow & GetProjectPanel(AudacityProject &project)
Get the main sub-window of the project frame that displays track data.
AUDACITY_DLL_API void SetProjectPanel(AudacityProject &project, wxWindow &panel)
AUDACITY_DLL_API wxFrame & GetProjectFrame(AudacityProject &project)
Get the top-level window associated with the project (as a wxFrame only, when you do not need to use ...
AUDACITY_DLL_API AttachedWindows & GetAttachedWindows(AudacityProject &project)
accessors for certain important windows associated with each project
const auto project
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:90
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:274
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:196
const AudacityProject::AttachedObjects::RegisteredFactory key
A convenient default parameter for class template Site.
Definition: ClientData.h:28