Audacity 3.2.0
Functions
HelpText.cpp File Reference

Given a key, returns some html. More...

#include "HelpText.h"
#include <wx/colour.h>
#include <wx/sstream.h>
#include <wx/txtstrm.h>
#include "FileNames.h"
#include "Internat.h"
#include "AllThemeResources.h"
#include "Theme.h"
Include dependency graph for HelpText.cpp:

Go to the source code of this file.

Functions

wxString HtmlColourOfIndex (int i)
 
static wxString WrapText (const wxString &Text)
 
static wxString InnerLink (const wxString &Key, const wxString &Text)
 
static wxString FileLink (const wxString &Key, const wxString &Text)
 
static wxString TypedLink (const wxString &Key, const wxString &Text)
 
static wxString LinkExpand (const wxString &Text)
 
TranslatableString TitleText (const wxString &Key)
 
static wxString HelpTextBuiltIn (const wxString &Key)
 
wxString HelpText (const wxString &Key)
 
wxString FormatHtmlText (const wxString &Text)
 

Detailed Description

Given a key, returns some html.

Definition in file HelpText.cpp.

Function Documentation

◆ FileLink()

static wxString FileLink ( const wxString &  Key,
const wxString &  Text 
)
static

Definition at line 55 of file HelpText.cpp.

56{
57 return wxString(wxT("")) +
58 wxT("<a href='") +
59 wxT("file:") +
61 Key +
62 wxT("'>") +
63 Text +
64 wxT("</a>");
65}
wxT("CloseDown"))
FILES_API FilePath HtmlHelpDir()

References FileNames::HtmlHelpDir(), and wxT().

Referenced by LinkExpand().

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

◆ FormatHtmlText()

wxString FormatHtmlText ( const wxString &  Text)

Definition at line 258 of file HelpText.cpp.

258 {
259
260 wxString localeStr = wxLocale::GetSystemEncodingName();
261
262 return
263 wxT("<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=") +
264 localeStr +
265 wxT("\"></head>") +
266 WrapText( LinkExpand( Text ))+
267 wxT("</html>");
268}
static wxString WrapText(const wxString &Text)
Definition: HelpText.cpp:34
static wxString LinkExpand(const wxString &Text)
Definition: HelpText.cpp:77

References LinkExpand(), WrapText(), and wxT().

Referenced by anonymous_namespace{WhatsNewDialog.cpp}::MakeGetPluginsText(), anonymous_namespace{WhatsNewDialog.cpp}::MakeWhatsNewText(), AboutDialog::PopulateAudacityPage(), AboutDialog::PopulateInformationPage(), and AboutDialog::PopulateLicensePage().

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

◆ HelpText()

wxString HelpText ( const wxString &  Key)

Definition at line 238 of file HelpText.cpp.

239{
240
241 // Possible future enhancement...
242 // We could look for the text as a local file and use
243 // that if we find it...
244 // if( wxFileExists( Path+Key ) )
245 // ...
246
247 wxString Text;
248 Text = HelpTextBuiltIn( Key );
249
250 if( !Text.empty())
251 return LinkExpand( Text );
252
253 // Perhaps useful for debugging - we'll return key that we didn't find.
254 return WrapText( Key );
255}
static wxString HelpTextBuiltIn(const wxString &Key)
Definition: HelpText.cpp:192

References HelpTextBuiltIn(), LinkExpand(), and WrapText().

Referenced by ErrorDialog::OnHelp(), ErrorReportDialog::OnHelp(), LinkingHtmlWindow::OnLinkClicked(), and HelpSystem::ShowHelp().

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

◆ HelpTextBuiltIn()

static wxString HelpTextBuiltIn ( const wxString &  Key)
static

Definition at line 192 of file HelpText.cpp.

193{
194 if(Key==wxT("wma-proprietary"))
195 {
196 wxStringOutputStream o;
197 wxTextOutputStream s(o);
198 s
199 << wxT("<p>")
200 << XO(
201"Audacity can import unprotected files in many other formats (such as M4A and WMA, \
202compressed WAV files from portable recorders and audio from video files) if you download and install \
203the optional [[https://support.audacityteam.org/basics/installing-ffmpeg| \
204FFmpeg library]] to your computer.")
205 << wxT("</p><p>")
206 << XO(
207"You can also read our help on importing \
208[[https://manual.audacityteam.org/man/playing_and_recording.html#midi|MIDI files]] \
209and tracks from [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#fromcd| \
210audio CDs]].")
211 << wxT("</p>")
212 ;
213 return WrapText( o.GetString() );
214 }
215
216 // Remote help allows us to link to a local copy of the help if it exists,
217 // or provide a message that takes you to the Internet if it does not.
218 // It's used by the menu item Help > Index
219 if(Key == wxT("remotehelp") )
220 {
221 wxStringOutputStream o;
222 wxTextOutputStream s(o);
223 s
224// *URL* will be replaced by whatever URL we are looking for.
225 << XO(
226"The Manual does not appear to be installed. \
227Please [[*URL*|view the Manual online]] or \
228[[https://manual.audacityteam.org/man/unzipping_the_manual.html| \
229download the Manual]].<br><br>\
230To always view the Manual online, change \"Location of Manual\" in \
231Interface Preferences to \"From Internet\".")
232 ;
233 return WrapText( o.GetString() );
234 }
235 return {};
236}
XO("Cut/Copy/Paste")

References WrapText(), wxT(), and XO().

Referenced by HelpText().

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

◆ HtmlColourOfIndex()

wxString HtmlColourOfIndex ( int  i)

Definition at line 28 of file HelpText.cpp.

28 {
29 wxColour c = theTheme.Colour(i);
30 return wxString::Format("\"#%02X%02X%02X\"",
31 c.Red(), c.Green(), c.Blue() );
32}
THEME_API Theme theTheme
Definition: Theme.cpp:82
wxColour & Colour(int iIndex)

References ThemeBase::Colour(), and theTheme.

Referenced by LinkExpand(), and WrapText().

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

◆ InnerLink()

static wxString InnerLink ( const wxString &  Key,
const wxString &  Text 
)
static

Definition at line 45 of file HelpText.cpp.

46{
47 return wxString(wxT("")) +
48 wxT("<a href='innerlink:") +
49 Key +
50 wxT("'>") +
51 Text +
52 wxT("</a>");
53}

References wxT().

Referenced by LinkExpand().

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

◆ LinkExpand()

static wxString LinkExpand ( const wxString &  Text)
static

Definition at line 77 of file HelpText.cpp.

78{
79 wxString Temp = Text;
80 int i,j,k;
81 while( (i=Temp.First( wxT("[[") ))!= wxNOT_FOUND )
82 {
83 wxString Key = Temp.Mid(i+2);
84 j = Key.First( wxT("|") );
85 if( j==wxNOT_FOUND )
86 return Temp;
87 wxString LinkText = Key.Mid( j+1);
88 k = LinkText.First( wxT("]]") );
89 if( k==wxNOT_FOUND )
90 return Temp;
91 Key = Key.Mid( 0, j );
92 LinkText = LinkText.Mid( 0, k );
93
94 LinkText=wxString("<font color=") + HtmlColourOfIndex(clrSample) + wxT(">") +LinkText+"</font>";
95 wxString Replacement;
96 if( Key.StartsWith( wxT("file:") ))
97 {
98 Replacement = FileLink( Key.Mid( 5 ), LinkText );
99 }
100 else if( Key.StartsWith( wxT("http:") ))
101 {
102 Replacement = TypedLink( Key, LinkText );
103 }
104 else if( Key.StartsWith( wxT("https:") ))
105 {
106 Replacement = TypedLink( Key, LinkText );
107 }
108 else if( Key.StartsWith( wxT("mailto:") ))
109 {
110 Replacement = TypedLink( Key, LinkText );
111 }
112 else if( Key.StartsWith( wxT("*URL*") ))
113 {
114 Replacement = TypedLink( Key, LinkText );
115 }
116 else
117 {
118 Replacement = InnerLink( Key, LinkText );
119 }
120
121
122 Temp = Temp.Mid( 0, i ) + Replacement + Temp.Mid( i + j + k + 5 );// 5 for the [[|]]
123 }
124 return Temp;
125}
static wxString TypedLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:67
static wxString FileLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:55
static wxString InnerLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:45
wxString HtmlColourOfIndex(int i)
Definition: HelpText.cpp:28

References FileLink(), HtmlColourOfIndex(), InnerLink(), TypedLink(), and wxT().

Referenced by FormatHtmlText(), and HelpText().

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

◆ TitleText()

TranslatableString TitleText ( const wxString &  Key)

Definition at line 127 of file HelpText.cpp.

128{
129 if(Key==wxT("welcome"))
130 {
131 return XO("Welcome!");
132 }
133
134 if(Key ==wxT("play") )
135 {
136 /* i18n-hint: Title for a topic.*/
137 return XO("Playing Audio");
138 }
139 if((Key ==wxT("record") ) || (Key ==wxT("norecord") ))
140 {
141 /* i18n-hint: Title for a topic.*/
142 return XO("Recording Audio");
143 }
144 if(Key ==wxT("inputdevice") )
145 {
146 /* i18n-hint: Title for a topic.*/
147 return XO("Recording - Choosing the Recording Device");
148 }
149 if(Key ==wxT("inputsource") )
150 {
151 /* i18n-hint: Title for a topic.*/
152 return XO("Recording - Choosing the Recording Source");
153 }
154 if(Key ==wxT("inputlevel") )
155 {
156 /* i18n-hint: Title for a topic.*/
157 return XO("Recording - Setting the Recording Level");
158 }
159 if((Key ==wxT("edit") ) || (Key==wxT("grey")))
160 {
161 /* i18n-hint: Title for a topic.*/
162 return XO("Editing and greyed out Menus");
163 }
164 if(Key ==wxT("export") )
165 {
166 /* i18n-hint: Title for a topic.*/
167 return XO("Exporting an Audio File");
168 }
169 if(Key ==wxT("save") )
170 {
171 /* i18n-hint: Title for a topic.*/
172 return XO("Saving an Audacity Project");
173 }
174 if(Key ==wxT("wma-proprietary") )
175 {
176 /* i18n-hint: Title for a topic.*/
177 return XO("Support for Other Formats");
178 }
179 if(Key ==wxT("burncd") )
180 {
181 /* i18n-hint: Title for a topic.*/
182 return XO("Burn to CD" );
183 }
184 if(Key == wxT("remotehelp") )
185 {
186 return XO("No Local Help");
187 }
188 // Uh oh, no translation...
189 return Verbatim( Key );
190}
TranslatableString Verbatim(wxString str)
Require calls to the one-argument constructor to go through this distinct global function name.

References Verbatim(), wxT(), and XO().

Referenced by ErrorDialog::OnHelp(), ErrorReportDialog::OnHelp(), and LinkingHtmlWindow::OnLinkClicked().

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

◆ TypedLink()

static wxString TypedLink ( const wxString &  Key,
const wxString &  Text 
)
static

Definition at line 67 of file HelpText.cpp.

68{
69 return wxString(wxT("")) +
70 wxT("<a href='") +
71 Key +
72 wxT("'>") +
73 Text +
74 wxT("</a>");
75}

References wxT().

Referenced by LinkExpand().

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

◆ WrapText()

static wxString WrapText ( const wxString &  Text)
static

Definition at line 34 of file HelpText.cpp.

35{
36 return wxString(wxT(""))+
37 wxT("<html><head></head>") +
38 wxT("<body bgcolor=") + HtmlColourOfIndex(clrTrackInfo) + wxT(">") +
39 wxT("<font color=") + HtmlColourOfIndex(clrTrackPanelText) + wxT(">") +
40 wxT("<p>") + Text +
41 wxT("</font>")+
42 wxT("</body></html>");
43}

References HtmlColourOfIndex(), and wxT().

Referenced by FormatHtmlText(), HelpText(), and HelpTextBuiltIn().

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