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"
14
15#include <wx/frame.h>
16
17namespace {
19{
20 static ProjectWindows &Get( AudacityProject &project );
21 static const ProjectWindows &Get( const AudacityProject &project );
23 : mAttachedWindows{project}
24 {}
25
26 wxWeakRef< wxWindow > mPanel{};
27 wxWeakRef< wxFrame > mFrame{};
28
30};
31
33 [](AudacityProject &project) {
34 return std::make_unique<ProjectWindows>(project);
35 }
36};
37
39{
40 return project.AttachedObjects::Get< ProjectWindows >( key );
41}
42
44{
45 return Get( const_cast< AudacityProject & >( project ) );
46}
47}
48
49AUDACITY_DLL_API wxWindow &GetProjectPanel( AudacityProject &project )
50{
51 auto ptr = ProjectWindows::Get(project).mPanel;
52 if ( !ptr )
54 return *ptr;
55}
56
57AUDACITY_DLL_API const wxWindow &GetProjectPanel(
58 const AudacityProject &project )
59{
60 auto ptr = ProjectWindows::Get(project).mPanel;
61 if ( !ptr )
63 return *ptr;
64}
65
66AUDACITY_DLL_API void SetProjectPanel(
67 AudacityProject &project, wxWindow &panel )
68{
69 ProjectWindows::Get(project).mPanel = &panel;
70}
71
72AUDACITY_DLL_API wxFrame &GetProjectFrame( AudacityProject &project )
73{
74 auto ptr = ProjectWindows::Get(project).mFrame;
75 if ( !ptr )
77 return *ptr;
78}
79
80AUDACITY_DLL_API const wxFrame &GetProjectFrame( const AudacityProject &project )
81{
82 auto ptr = ProjectWindows::Get(project).mFrame;
83 if ( !ptr )
85 return *ptr;
86}
87
88wxFrame *FindProjectFrame( AudacityProject *project ) {
89 if (!project)
90 return nullptr;
91 return ProjectWindows::Get(*project).mFrame;
92}
93
94const wxFrame *FindProjectFrame( const AudacityProject *project ) {
95 if (!project)
96 return nullptr;
97 return ProjectWindows::Get(*project).mFrame;
98}
99
100std::unique_ptr<const BasicUI::WindowPlacement>
102{
103 if (!project)
104 return std::make_unique<BasicUI::WindowPlacement>();
105 return std::make_unique<wxWidgetsWindowPlacement>(
106 &GetProjectFrame(*project));
107}
108
109void SetProjectFrame(AudacityProject &project, wxFrame &frame )
110{
111 ProjectWindows::Get(project).mFrame = &frame;
112}
113
115{
116 return ProjectWindows::Get(project).mAttachedWindows;
117}
#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)
std::unique_ptr< const BasicUI::WindowPlacement > ProjectFramePlacement(AudacityProject *project)
Make a WindowPlacement object suitable for project (which may be null)
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
ScreenshotBigDialogPtr mFrame
Definition: Screenshot.cpp:131
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
Client code makes static instance from a factory of attachments; passes it to Get or Find as a retrie...
Definition: ClientData.h:266
Services * Get()
Fetch the global instance, or nullptr if none is yet installed.
Definition: BasicUI.cpp:26
const AudacityProject::AttachedObjects::RegisteredFactory key
A convenient default parameter for class template Site.
Definition: ClientData.h:28