Audacity 3.2.0
Public Member Functions | Protected Member Functions | List of all members
wxWidgetsBasicUI Class Referencefinal

An implementation of BasicUI::Services in terms of the wxWidgets toolkit. More...

#include <wxWidgetsBasicUI.h>

Inheritance diagram for wxWidgetsBasicUI:
[legend]
Collaboration diagram for wxWidgetsBasicUI:
[legend]

Public Member Functions

 ~wxWidgetsBasicUI () override
 
- Public Member Functions inherited from BasicUI::Services
virtual ~Services ()
 
virtual void DoCallAfter (const Action &action)=0
 
virtual void DoYield ()=0
 
virtual void DoShowErrorDialog (const WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const ErrorDialogOptions &options)=0
 
virtual MessageBoxResult DoMessageBox (const TranslatableString &message, MessageBoxOptions options)=0
 
virtual std::unique_ptr< ProgressDialogDoMakeProgress (const TranslatableString &title, const TranslatableString &message, unsigned flag, const TranslatableString &remainingLabelText)=0
 
virtual std::unique_ptr< GenericProgressDialogDoMakeGenericProgress (const WindowPlacement &placement, const TranslatableString &title, const TranslatableString &message)=0
 
virtual int DoMultiDialog (const TranslatableString &message, const TranslatableString &title, const TranslatableStrings &buttons, const ManualPageID &helpPage, const TranslatableString &boxMsg, bool log)=0
 
virtual bool DoOpenInDefaultBrowser (const wxString &url)=0
 

Protected Member Functions

void DoCallAfter (const BasicUI::Action &action) override
 
void DoYield () override
 
void DoShowErrorDialog (const BasicUI::WindowPlacement &placement, const TranslatableString &dlogTitle, const TranslatableString &message, const ManualPageID &helpPage, const BasicUI::ErrorDialogOptions &options) override
 
BasicUI::MessageBoxResult DoMessageBox (const TranslatableString &message, BasicUI::MessageBoxOptions options) override
 
std::unique_ptr< BasicUI::ProgressDialogDoMakeProgress (const TranslatableString &title, const TranslatableString &message, unsigned flags, const TranslatableString &remainingLabelText) override
 
std::unique_ptr< BasicUI::GenericProgressDialogDoMakeGenericProgress (const BasicUI::WindowPlacement &placement, const TranslatableString &title, const TranslatableString &message) override
 
int DoMultiDialog (const TranslatableString &message, const TranslatableString &title, const TranslatableStrings &buttons, const ManualPageID &helpPage, const TranslatableString &boxMsg, bool log) override
 
bool DoOpenInDefaultBrowser (const wxString &url) override
 

Detailed Description

An implementation of BasicUI::Services in terms of the wxWidgets toolkit.

This is a singleton that doesn't need AUDACITY_DLL_API visibility

Definition at line 20 of file wxWidgetsBasicUI.h.

Constructor & Destructor Documentation

◆ ~wxWidgetsBasicUI()

wxWidgetsBasicUI::~wxWidgetsBasicUI ( )
overridedefault

Member Function Documentation

◆ DoCallAfter()

void wxWidgetsBasicUI::DoCallAfter ( const BasicUI::Action action)
overrideprotectedvirtual

Implements BasicUI::Services.

Definition at line 29 of file wxWidgetsBasicUI.cpp.

30{
31 wxTheApp->CallAfter(action);
32}

◆ DoMakeGenericProgress()

std::unique_ptr< GenericProgressDialog > wxWidgetsBasicUI::DoMakeGenericProgress ( const BasicUI::WindowPlacement placement,
const TranslatableString title,
const TranslatableString message 
)
overrideprotectedvirtual

Implements BasicUI::Services.

Definition at line 199 of file wxWidgetsBasicUI.cpp.

203{
204 return std::make_unique<MyGenericProgress>(
205 title, message, wxWidgetsWindowPlacement::GetParent(placement));
206}
static const auto title
static wxWindow * GetParent(const WindowPlacement &placement)
Retrieve the pointer to window, if placement is of this type; else null.

References wxWidgetsWindowPlacement::GetParent(), and title.

Here is the call graph for this function:

◆ DoMakeProgress()

std::unique_ptr< BasicUI::ProgressDialog > wxWidgetsBasicUI::DoMakeProgress ( const TranslatableString title,
const TranslatableString message,
unsigned  flags,
const TranslatableString remainingLabelText 
)
overrideprotectedvirtual

Implements BasicUI::Services.

Definition at line 159 of file wxWidgetsBasicUI.cpp.

163{
164 unsigned options = 0;
165 if (!(flags & ProgressShowStop))
166 options |= pdlgHideStopButton;
167 if (!(flags & ProgressShowCancel))
168 options |= pdlgHideCancelButton;
169 if ((flags & ProgressHideTime))
170 options |= pdlgHideElapsedTime;
171 if ((flags & ProgressConfirmStopOrCancel))
172 options |= pdlgConfirmStopCancel;
173 // Usually wxWindow objects should not be managed by std::unique_ptr
174 // See https://docs.wxwidgets.org/3.0/overview_windowdeletion.html
175 // But on macOS the use of wxWindowPtr for the progress dialog sometimes
176 // causes hangs.
177 return std::make_unique<::ProgressDialog>(
178 title, message, options, remainingLabelText);
179}
@ pdlgConfirmStopCancel
@ pdlgHideStopButton
@ pdlgHideElapsedTime
@ pdlgHideCancelButton
@ ProgressHideTime
Definition: BasicUI.h:140
@ ProgressShowCancel
Definition: BasicUI.h:139
@ ProgressConfirmStopOrCancel
Definition: BasicUI.h:141
@ ProgressShowStop
Definition: BasicUI.h:138

References pdlgConfirmStopCancel, pdlgHideCancelButton, pdlgHideElapsedTime, pdlgHideStopButton, BasicUI::ProgressConfirmStopOrCancel, BasicUI::ProgressHideTime, BasicUI::ProgressShowCancel, BasicUI::ProgressShowStop, and title.

◆ DoMessageBox()

BasicUI::MessageBoxResult wxWidgetsBasicUI::DoMessageBox ( const TranslatableString message,
BasicUI::MessageBoxOptions  options 
)
overrideprotectedvirtual

Implements BasicUI::Services.

Definition at line 88 of file wxWidgetsBasicUI.cpp.

91{
92 // Compute the style argument to pass to wxWidgets
93 long style = 0;
94 switch (options.iconStyle) {
95 case Icon::Warning :
96 style = wxICON_WARNING;
97 break;
98 case Icon::Error :
99 style = wxICON_ERROR;
100 break;
101 case Icon::Question :
102 style = wxICON_QUESTION;
103 break;
104 case Icon::Information :
105 style = wxICON_INFORMATION;
106 break;
107 default:
108 break;
109 }
110 switch (options.buttonStyle) {
111 case Button::Ok :
112 style |= wxOK;
113 break;
114 case Button::YesNo :
115 style |= wxYES_NO;
116 break;
117 default:
118 break;
119 }
120 if (!options.yesOrOkDefaultButton && options.buttonStyle == Button::YesNo)
121 style |= wxNO_DEFAULT;
122 if (options.cancelButton)
123 style |= wxCANCEL;
124 if (options.centered)
125 style |= wxCENTER;
126
127 // Preserving the default style AudacityMessageBox had,
128 // when none of the above were explicitly specified
129 if (!style)
130 style = wxOK | wxCENTRE;
131
132 // This calls through to ::wxMessageBox:
133 auto wxResult =
134 ::AudacityMessageBox(message, options.caption, style,
135 options.parent
137 : nullptr);
138 // This switch exhausts all possibilities for the return from::wxMessageBox.
139 // see utilscmn.cpp in wxWidgets.
140 // Remap to our toolkit-neutral enumeration.
141 switch (wxResult) {
142 case wxYES:
143 return MessageBoxResult::Yes;
144 case wxNO:
145 return MessageBoxResult::No;
146 case wxOK:
147 return MessageBoxResult::Ok;
148 case wxCANCEL:
149 return MessageBoxResult::Cancel;
150 case wxHELP:
151 // should not happen, because we don't ever pass wxHELP
152 default:
153 wxASSERT(false);
154 return MessageBoxResult::None;
155 }
156}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
TranslatableString caption
Definition: BasicUI.h:121
WindowPlacement * parent
Definition: BasicUI.h:120

References AudacityMessageBox(), BasicUI::MessageBoxOptions::buttonStyle, BasicUI::MessageBoxOptions::cancelButton, BasicUI::MessageBoxOptions::caption, BasicUI::MessageBoxOptions::centered, wxWidgetsWindowPlacement::GetParent(), BasicUI::MessageBoxOptions::iconStyle, BasicUI::MessageBoxOptions::parent, and BasicUI::MessageBoxOptions::yesOrOkDefaultButton.

Here is the call graph for this function:

◆ DoMultiDialog()

int wxWidgetsBasicUI::DoMultiDialog ( const TranslatableString message,
const TranslatableString title,
const TranslatableStrings buttons,
const ManualPageID helpPage,
const TranslatableString boxMsg,
bool  log 
)
overrideprotectedvirtual

Implements BasicUI::Services.

Definition at line 208 of file wxWidgetsBasicUI.cpp.

213{
214 return ::ShowMultiDialog(message, title, buttons, helpPage, boxMsg, log);
215}
int ShowMultiDialog(const TranslatableString &message, const TranslatableString &title, const TranslatableStrings &buttons, const ManualPageID &helpPage, const TranslatableString &boxMsg, bool log)

References ShowMultiDialog(), and title.

Here is the call graph for this function:

◆ DoOpenInDefaultBrowser()

bool wxWidgetsBasicUI::DoOpenInDefaultBrowser ( const wxString &  url)
overrideprotectedvirtual

Implements BasicUI::Services.

Definition at line 217 of file wxWidgetsBasicUI.cpp.

218{
219 return wxLaunchDefaultBrowser(url);
220}

◆ DoShowErrorDialog()

void wxWidgetsBasicUI::DoShowErrorDialog ( const BasicUI::WindowPlacement placement,
const TranslatableString dlogTitle,
const TranslatableString message,
const ManualPageID helpPage,
const BasicUI::ErrorDialogOptions options 
)
overrideprotectedvirtual

Implements BasicUI::Services.

Definition at line 39 of file wxWidgetsBasicUI.cpp.

45{
46 using namespace BasicUI;
47 bool modal = true;
48 auto parent = wxWidgetsWindowPlacement::GetParent(placement);
49 switch (options.type) {
50 case ErrorDialogType::ModalErrorReport: {
51#ifdef HAS_SENTRY_REPORTING
52 ErrorReportDialog dlog(parent, dlogTitle, message, helpPage,
53 options.log, modal);
54
55 dlog.CentreOnParent();
56 dlog.ShowModal();
57 return;
58#else
59 break;
60#endif
61 }
62 case ErrorDialogType::ModelessError: {
63 if (!parent)
64 parent = wxTheApp->GetTopWindow();
65 // To be nonmodal, either it needs a parent, to avoid leaks, or it must
66 // guarantee eventual deletion of itself. There might be no top window
67 // on MacOS. Let's just force it to be modal in that case.
68 if (parent)
69 modal = false;
70 break;
71 }
72 default:
73 break;
74 }
75 auto pDlog = Destroy_ptr<ErrorDialog>( safenew ErrorDialog{ parent,
76 dlogTitle, message, helpPage, options.log,
77 options.modalHelp, modal } );
78 pDlog->CentreOnParent();
79 if (modal)
80 pDlog->ShowModal();
81 else {
82 pDlog->Show();
83 pDlog.release(); // not a memory leak, because it has a parent
84 }
85}
#define safenew
Definition: MemoryX.h:10
std::unique_ptr< T, Destroyer< T > > Destroy_ptr
a convenience for using Destroyer
Definition: MemoryX.h:162
Gives an Error message with an option for help.
Definition: ErrorDialog.h:26
A dialog, that has "Send", "Don't send" and help buttons.
ErrorDialogType type
Type of help dialog.
Definition: BasicUI.h:67
std::wstring log
Optional extra logging information to be shown.
Definition: BasicUI.h:71
bool modalHelp
Whether the secondary help dialog with more information should be modal.
Definition: BasicUI.h:69

References wxWidgetsWindowPlacement::GetParent(), BasicUI::ErrorDialogOptions::log, BasicUI::ErrorDialogOptions::modalHelp, safenew, and BasicUI::ErrorDialogOptions::type.

Here is the call graph for this function:

◆ DoYield()

void wxWidgetsBasicUI::DoYield ( )
overrideprotectedvirtual

Implements BasicUI::Services.

Definition at line 34 of file wxWidgetsBasicUI.cpp.

35{
36 wxTheApp->Yield();
37}

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