Audacity 3.2.0
Static Public Member Functions | List of all members
LogWindow Class Reference

Maintains the unique logging window which displays debug information. More...

#include <LogWindow.h>

Static Public Member Functions

static void Show (bool show=true)
 Show or hide the unique logging window; create it on demand the first time it is shown. More...
 
static void Destroy ()
 Destroys the log window (if any) More...
 

Detailed Description

Maintains the unique logging window which displays debug information.

Definition at line 15 of file LogWindow.h.

Member Function Documentation

◆ Destroy()

void LogWindow::Destroy ( )
static

Destroys the log window (if any)

Definition at line 178 of file LogWindow.cpp.

179{
180 sFrame.reset();
181}
Destroy_ptr< wxFrame > sFrame
Definition: LogWindow.cpp:43

References anonymous_namespace{LogWindow.cpp}::sFrame.

Referenced by QuitAudacity().

Here is the caller graph for this function:

◆ Show()

void LogWindow::Show ( bool  show = true)
static

Show or hide the unique logging window; create it on demand the first time it is shown.

Definition at line 61 of file LogWindow.cpp.

62{
63 // Hide the frame if created, otherwise do nothing
64 if (!show) {
65 if (sFrame) {
66 sFrame->Show(false);
67 }
68 return;
69 }
70
71 // If the frame already exists, refresh its contents and show it
72 auto pLogger = AudacityLogger::Get();
73 if (sFrame) {
74 if (!sFrame->IsShown() && sText) {
75 if (pLogger)
76 sText->ChangeValue(pLogger->GetBuffer());
77 sText->SetInsertionPointEnd();
78 sText->ShowPosition(sText->GetLastPosition());
79 }
80 sFrame->Show();
81 sFrame->Raise();
82 return;
83 }
84
85 // This is the first use, so create the frame
87 { safenew wxFrame(NULL, wxID_ANY, _("Audacity Log")) };
88 frame->SetName(frame->GetTitle());
89 frame->SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
90
91 // loads either the XPM or the windows resource, depending on the platform
92 {
93#if !defined(__WXMAC__) && !defined(__WXX11__)
94#if defined(__WXMSW__)
95 wxIcon ic{wxICON(AudacityLogo)};
96#elif defined(__WXGTK__)
97 wxIcon ic{wxICON(AudacityLogoAlpha)};
98#else
99 wxIcon ic{};
100 ic.CopyFromBitmap(theTheme.Bitmap(bmpAudacityLogo48x48));
101#endif
102 frame->SetIcon(ic);
103#endif
104 }
105
106 // Log text
107 ShuttleGui S(frame.get(), eIsCreating);
108
109 S.Style(wxNO_BORDER | wxTAB_TRAVERSAL).Prop(true).StartPanel();
110 {
111 S.StartVerticalLay(true);
112 {
113 sText = S.Style(wxTE_MULTILINE | wxHSCROLL | wxTE_READONLY | wxTE_RICH)
114 .AddTextWindow({});
115
116 // Populated TextWindow created above
117 if (pLogger) *sText << pLogger->GetBuffer();
118
119 S.AddSpace(0, 5);
120 S.StartHorizontalLay(wxALIGN_CENTER, 0);
121 {
122 S.AddSpace(10, 0);
123 S.Id(LoggerID_Save).AddButton(XXO("&Save..."));
124 S.Id(LoggerID_Clear).AddButton(XXO("Cl&ear"));
125 S.Id(LoggerID_Close).AddButton(XXO("&Close"));
126 S.AddSpace(10, 0);
127 }
128 S.EndHorizontalLay();
129 S.AddSpace(0, 3);
130 }
131 S.EndVerticalLay();
132 }
133 S.EndPanel();
134
135 // Give a place for the menu help text to go
136 // frame->CreateStatusBar();
137
138 frame->Layout();
139
140 // Hook into the frame events
141 frame->Bind(wxEVT_CLOSE_WINDOW, OnCloseWindow );
142
143 frame->Bind( wxEVT_COMMAND_MENU_SELECTED, OnSave, LoggerID_Save);
144 frame->Bind( wxEVT_COMMAND_MENU_SELECTED, OnClear, LoggerID_Clear);
145 frame->Bind( wxEVT_COMMAND_MENU_SELECTED, OnClose, LoggerID_Close);
149
150 sFrame = std::move( frame );
151
152 sFrame->Show();
153
154 if (pLogger)
155 pLogger->Flush();
156
157 // Also create the listeners
158 if (!pUpdater)
159 pUpdater.emplace();
160
161 if (pLogger) {
162 pLogger->SetListener([]{
163 if (auto pLogger = AudacityLogger::Get()) {
164 if (sFrame && sFrame->IsShown()) {
165 if (sText)
166 sText->ChangeValue(pLogger->GetBuffer());
167 return true;
168 }
169 }
170 return false;
171 });
172
173 // Initial flush populates sText
174 pLogger->Flush();
175 }
176}
wxEVT_COMMAND_BUTTON_CLICKED
XXO("&Cut/Copy/Paste Toolbar")
#define _(s)
Definition: Internat.h:73
@ LoggerID_Clear
Definition: LogWindow.cpp:38
@ LoggerID_Close
Definition: LogWindow.cpp:39
@ LoggerID_Save
Definition: LogWindow.cpp:37
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:164
@ eIsCreating
Definition: ShuttleGui.h:37
THEME_API Theme theTheme
Definition: Theme.cpp:82
#define S(N)
Definition: ToChars.cpp:64
static AudacityLogger * Get()
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
wxBitmap & Bitmap(int iIndex)
void OnClear(wxCommandEvent &WXUNUSED(e))
Definition: LogWindow.cpp:202
std::optional< LogWindowUpdater > pUpdater
Definition: LogWindow.cpp:53
void OnClose(wxCommandEvent &WXUNUSED(e))
Definition: LogWindow.cpp:196
void OnCloseWindow(wxCloseEvent &WXUNUSED(e))
Definition: LogWindow.cpp:184
void OnSave(wxCommandEvent &WXUNUSED(e))
Definition: LogWindow.cpp:209
wxWeakRef< wxTextCtrl > sText
Definition: LogWindow.cpp:44

References _, ThemeBase::Bitmap(), eIsCreating, AudacityLogger::Get(), LoggerID_Clear, LoggerID_Close, LoggerID_Save, anonymous_namespace{LogWindow.cpp}::OnClear(), anonymous_namespace{LogWindow.cpp}::OnClose(), anonymous_namespace{LogWindow.cpp}::OnCloseWindow(), anonymous_namespace{LogWindow.cpp}::OnSave(), anonymous_namespace{LogWindow.cpp}::pUpdater, S, safenew, anonymous_namespace{LogWindow.cpp}::sFrame, anonymous_namespace{LogWindow.cpp}::sText, theTheme, wxEVT_COMMAND_BUTTON_CLICKED, and XXO().

Referenced by anonymous_namespace{HelpMenus.cpp}::OnShowLog(), MultiDialog::OnShowLog(), and anonymous_namespace{LogWindow.cpp}::LogWindowUpdater::UpdatePrefs().

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

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