Audacity 3.2.0
HelpUtilities.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3Audacity: A Digital Audio Editor
4
5@file HelpUtilities.cpp
6
7Paul Licameli split from HelpMenus.cpp
8
9**********************************************************************/
10
11#include "HelpUtilities.h"
12
13#include "Project.h"
14#include "ProjectWindows.h"
15#include "SelectFile.h"
16#include "ShuttleGui.h"
19
20#include <wx/button.h>
21#include <wx/frame.h>
22#include <wx/textctrl.h>
23
25 AudacityProject &project, const wxString &info,
26 const TranslatableString &description, const wxString &defaultPath,
27 bool fixedWidth)
28{
29 auto &window = GetProjectFrame( project );
30 wxDialogWrapper dlg( &window, wxID_ANY, description);
31 dlg.SetName();
33
34 wxTextCtrl *text;
35 S.StartVerticalLay();
36 {
37 text = S.Id(wxID_STATIC)
38 .Style(wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH)
39 .AddTextWindow("");
40
41 wxButton *save = safenew wxButton(S.GetParent(), wxID_OK, _("&Save"));
42 S.AddStandardButtons(eCancelButton, save);
43 }
44 S.EndVerticalLay();
45
46 if (fixedWidth) {
47 auto style = text->GetDefaultStyle();
48 style.SetFontFamily( wxFONTFAMILY_TELETYPE );
49 text->SetDefaultStyle(style);
50 }
51
52 *text << info;
53
54 dlg.SetSize(350, 450);
55
56 if (dlg.ShowModal() == wxID_OK)
57 {
58 const auto fileDialogTitle = XO("Save %s").Format( description );
59 wxString fName = SelectFile(FileNames::Operation::Export,
60 fileDialogTitle,
61 wxEmptyString,
62 defaultPath,
63 wxT("txt"),
65 wxFD_SAVE | wxFD_OVERWRITE_PROMPT | wxRESIZE_BORDER,
66 &window);
67 if (!fName.empty())
68 {
69 if (!text->SaveFile(fName))
70 {
72 XO("Unable to save %s").Format( description ),
73 fileDialogTitle);
74 }
75 }
76 }
77}
int AudacityMessageBox(const TranslatableString &message, const TranslatableString &caption, long style, wxWindow *parent, int x, int y)
void ShowDiagnostics(AudacityProject &project, const wxString &info, const TranslatableString &description, const wxString &defaultPath, bool fixedWidth)
#define XO(s)
Definition: Internat.h:31
#define _(s)
Definition: Internat.h:75
#define safenew
Definition: MemoryX.h:10
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 ...
accessors for certain important windows associated with each project
FilePath SelectFile(FileNames::Operation op, const TranslatableString &message, const FilePath &default_path, const FilePath &default_filename, const FileExtension &default_extension, const FileTypes &fileTypes, int flags, wxWindow *parent)
Definition: SelectFile.cpp:17
@ eIsCreating
Definition: ShuttleGui.h:39
@ eCancelButton
Definition: ShuttleGui.h:601
#define S(N)
Definition: ToChars.cpp:64
The top-level handle to an Audacity project. It serves as a source of events that other objects can b...
Definition: Project.h:89
FILES_API const FileType TextFiles
Definition: FileNames.h:74
Abstract base class used in importing a file.
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:631
Holds a msgid for the translation catalog; may also bind format arguments.
void SetName(const TranslatableString &title)