Audacity 3.2.0
ErrorDialog.cpp
Go to the documentation of this file.
1/**********************************************************************
2
3 Audacity: A Digital Audio Editor
4
5 ErrorDialog.cpp
6
7 Jimmy Johnson
8 Leland Lucius
9
10*******************************************************************//********************************************************************/
16
17
18#include "ErrorDialog.h"
19
20#include <wx/app.h>
21#include <wx/collpane.h>
22#include <wx/icon.h>
23#include <wx/sizer.h>
24#include <wx/statbmp.h>
25#include <wx/stattext.h>
26#include <wx/html/htmlwin.h>
27#include <wx/settings.h>
28#include <wx/statusbr.h>
29#include <wx/textctrl.h>
30#include <wx/artprov.h>
31
32#include "AllThemeResources.h"
33#include "CodeConversions.h"
34#include "ShuttleGui.h"
35#include "HelpText.h"
36#include "Prefs.h"
37#include "HelpSystem.h"
38
39BEGIN_EVENT_TABLE(ErrorDialog, wxDialogWrapper)
40 EVT_COLLAPSIBLEPANE_CHANGED( wxID_ANY, ErrorDialog::OnPane )
44
46 wxWindow *parent,
47 const TranslatableString & dlogTitle,
48 const TranslatableString & message,
49 const ManualPageID & helpPage,
50 const std::wstring & log,
51 const bool Close, const bool modal)
52: wxDialogWrapper(parent, wxID_ANY, dlogTitle,
53 wxDefaultPosition, wxDefaultSize,
54 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER)
55{
56 SetName();
57
58 long buttonMask;
59
60 // only add the help button if we have a URL
61 buttonMask = (helpPage.empty()) ? eOkButton : (eHelpButton | eOkButton);
62 dhelpPage = helpPage;
63 dClose = Close;
64 dModal = modal;
65
67
68 S.SetBorder(2);
69 S.StartHorizontalLay(wxEXPAND, 0);
70 {
71 S.SetBorder(20);
72 wxBitmap bitmap = wxArtProvider::GetBitmap(wxART_WARNING);
73 S.AddWindow(safenew wxStaticBitmap(S.GetParent(), -1, bitmap));
74
75 S.SetBorder(20);
76 S.AddFixedText(message, false, 500);
77 }
78 S.EndHorizontalLay();
79
80 S.SetBorder(2);
81 if (!log.empty())
82 {
83 S.StartHorizontalLay(wxEXPAND, 1);
84 {
85 S.SetBorder(5);
86
87 auto pane = safenew wxCollapsiblePane(S.GetParent(),
88 wxID_ANY,
89 XO("Show &Log...").Translation());
90 S.Style(wxEXPAND | wxALIGN_LEFT);
91 S.Prop(1);
92 S.AddWindow(pane);
93
94 ShuttleGui SI(pane->GetPane(), eIsCreating);
95 auto text = SI.AddTextWindow(log);
96 text->SetInsertionPointEnd();
97 text->ShowPosition(text->GetLastPosition());
98 text->SetMinSize(wxSize(700, 250));
99 }
100 S.EndHorizontalLay();
101 }
102
103 S.SetBorder(2);
104 S.AddStandardButtons(buttonMask);
105
106 Layout();
107 GetSizer()->Fit(this);
108 SetMinSize(GetSize());
109 Center();
110}
111
112void ErrorDialog::OnPane(wxCollapsiblePaneEvent & event)
113{
114 if (!event.GetCollapsed())
115 {
116 Center();
117 }
118}
119
120void ErrorDialog::OnOk(wxCommandEvent & WXUNUSED(event))
121{
122 if (dModal)
123 EndModal(true);
124 else
125 Destroy();
126}
127
128void ErrorDialog::OnHelp(wxCommandEvent & WXUNUSED(event))
129{
130 const auto &str = dhelpPage.GET();
131 if( str.StartsWith(wxT("innerlink:")) )
132 {
134 this,
135 TitleText(str.Mid( 10 ) ),
136 HelpText( str.Mid( 10 )),
137 false,
138 true );
139 return;
140 }
142 //OpenInDefaultBrowser( dhelpURL );
143 if(dClose)
144 EndModal(true);
145}
wxT("CloseDown"))
END_EVENT_TABLE()
Declare functions to perform UTF-8 to std::wstring conversions.
#define str(a)
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XO("Cut/Copy/Paste")
TranslatableString TitleText(const wxString &Key)
Definition: HelpText.cpp:127
wxString HelpText(const wxString &Key)
Definition: HelpText.cpp:238
#define safenew
Definition: MemoryX.h:9
@ eIsCreating
Definition: ShuttleGui.h:37
@ eOkButton
Definition: ShuttleGui.h:609
@ eHelpButton
Definition: ShuttleGui.h:613
#define S(N)
Definition: ToChars.cpp:64
Gives an Error message with an option for help.
Definition: ErrorDialog.h:26
void OnHelp(wxCommandEvent &event)
void OnPane(wxCollapsiblePaneEvent &event)
ManualPageID dhelpPage
Definition: ErrorDialog.h:39
void OnOk(wxCommandEvent &event)
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
Definition: HelpSystem.cpp:231
static void ShowHtmlText(wxWindow *pParent, const TranslatableString &Title, const wxString &HtmlText, bool bIsFile=false, bool bModal=false)
Definition: HelpSystem.cpp:119
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
Definition: Identifier.h:66
wxTextCtrl * AddTextWindow(const wxString &Value)
Multiline text box that grows.
Definition: ShuttleGui.cpp:737
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Definition: ShuttleGui.h:640
Holds a msgid for the translation catalog; may also bind format arguments.
STL namespace.