Audacity 3.2.0
Macros | 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.

Macros

#define VER_CHECK_URL   "https://www.audacityteam.org/download/?"
 

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)
 
const wxString VerCheckArgs ()
 
const wxString VerCheckHtml ()
 
const URLString VerCheckUrl ()
 

Detailed Description

Given a key, returns some html.

Definition in file HelpText.cpp.

Macro Definition Documentation

◆ VER_CHECK_URL

#define VER_CHECK_URL   "https://www.audacityteam.org/download/?"

Function Documentation

◆ FileLink()

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

Definition at line 63 of file HelpText.cpp.

64{
65 return wxString(wxT("")) +
66 wxT("<a href='") +
67 wxT("file:") +
69 Key +
70 wxT("'>") +
71 Text +
72 wxT("</a>");
73}
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 335 of file HelpText.cpp.

335 {
336
337 wxString localeStr = wxLocale::GetSystemEncodingName();
338
339 return
340 wxT("<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=") +
341 localeStr +
342 wxT("\"></head>") +
343 WrapText( LinkExpand( Text ))+
344 wxT("</html>");
345}
static wxString WrapText(const wxString &Text)
Definition: HelpText.cpp:42
static wxString LinkExpand(const wxString &Text)
Definition: HelpText.cpp:85

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

Referenced by 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 315 of file HelpText.cpp.

316{
317
318 // Possible future enhancement...
319 // We could look for the text as a local file and use
320 // that if we find it...
321 // if( wxFileExists( Path+Key ) )
322 // ...
323
324 wxString Text;
325 Text = HelpTextBuiltIn( Key );
326
327 if( !Text.empty())
328 return LinkExpand( Text );
329
330 // Perhaps useful for debugging - we'll return key that we didn't find.
331 return WrapText( Key );
332}
static wxString HelpTextBuiltIn(const wxString &Key)
Definition: HelpText.cpp:200

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

Referenced by ErrorDialog::OnHelp(), ErrorReportDialog::OnHelp(), LinkingHtmlWindow::OnLinkClicked(), SplashDialog::Populate(), SplashDialog::Show2(), 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 200 of file HelpText.cpp.

201{
202 // PRL: Is it necessary to define these outside of conditional compilation so that both get into the .pot file?
203 const auto alphamsg = XO(
204"<br><br>The version of Audacity you are using is an <b>Alpha test version</b>.");
205 const auto betamsg = XO(
206"<br><br>The version of Audacity you are using is a <b>Beta test version</b>.");
207
208 if (Key == wxT("welcome"))
209 {
210 wxStringOutputStream o;
211 wxTextOutputStream s(o);
212 s
213#if defined(IS_ALPHA) || defined(IS_BETA)
214 << wxT("<hr><center><h3>")
215 << XO("Get the Official Released Version of Audacity")
216 << wxT("</h3></center>")
217 << VerCheckHtml()
218#ifdef IS_ALPHA
219 << alphamsg
220#else
221 << betamsg
222#endif
223 << wxT(" ")
224 << XO(
225"We strongly recommend that you use our latest stable released version, which has full documentation and support.<br><br>")
226 << XO(
227"You can help us get Audacity ready for release by joining our [[https://www.audacityteam.org/community/|community]].<hr><br><br>")
228#endif
229
230 << wxT("<center><h3>")
231#ifndef HAS_WHATS_NEW
232 << wxT("Audacity ") << AUDACITY_VERSION_STRING
233#else
234 /* i18n-hint: %s is replaced with Audacity version */
235 << XO("What's new in Audacity %s").Format(AUDACITY_VERSION_STRING)
236 << wxT(R"(<p><a href=")") << WhatsNewURL << wxT(R"(">)")
237 << wxT(R"(<img src="memory:whats_new_btn.jpeg" width="263" height="148" /></a></p>)")
238#endif
239 << wxT("</h3><h3>")
240 << XO("How to get help")
241 << wxT("</h3></center>")
242 << XO("These are our support methods:")
243 << wxT("<p><ul><li>")
244 /* i18n-hint: Preserve '[[help:Quick_Help|' as it's the name of a link.*/
245 << XO("[[help:Quick_Help|Quick Help]]")
246 << wxT("</li><li>")
247 << XO(
248/* i18n-hint: Preserve '[[help:Main_Page|' as it's the name of a link.*/
249" [[help:Main_Page|Manual]]")
250 << wxT("</li><li>")
251 << XO("[[https://support.audacityteam.org/|Tutorials & How-tos]]")
252 << wxT("</li><li>")
253 << XO(
254" [[https://forum.audacityteam.org/|Forum]] - ask your question directly, online.")
255 << wxT("</li></ul></p>")
256 ;
257
258 auto result = o.GetString();
259
260 return WrapText( result );
261 }
262 if(Key==wxT("wma-proprietary"))
263 {
264 wxStringOutputStream o;
265 wxTextOutputStream s(o);
266 s
267 << wxT("<p>")
268 << XO(
269"Audacity can import unprotected files in many other formats (such as M4A and WMA, \
270compressed WAV files from portable recorders and audio from video files) if you download and install \
271the optional [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#foreign| \
272FFmpeg library]] to your computer.")
273 << wxT("</p><p>")
274 << XO(
275"You can also read our help on importing \
276[[https://manual.audacityteam.org/man/playing_and_recording.html#midi|MIDI files]] \
277and tracks from [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#fromcd| \
278audio CDs]].")
279 << wxT("</p>")
280 ;
281 return WrapText( o.GetString() );
282 }
283
284 // Remote help allows us to link to a local copy of the help if it exists,
285 // or provide a message that takes you to the Internet if it does not.
286 // It's used by the menu item Help > Index
287 if(Key == wxT("remotehelp") )
288 {
289 wxStringOutputStream o;
290 wxTextOutputStream s(o);
291 s
292// *URL* will be replaced by whatever URL we are looking for.
293// DA: View the manual on line is expected.
294#ifdef EXPERIMENTAL_DA
295 << XO(
296"The Manual does not appear to be installed. \
297Please [[*URL*|view the Manual online]].<br><br>\
298To always view the Manual online, change \"Location of Manual\" in \
299Interface Preferences to \"From Internet\".")
300#else
301 << XO(
302"The Manual does not appear to be installed. \
303Please [[*URL*|view the Manual online]] or \
304[[https://manual.audacityteam.org/man/unzipping_the_manual.html| \
305download the Manual]].<br><br>\
306To always view the Manual online, change \"Location of Manual\" in \
307Interface Preferences to \"From Internet\".")
308#endif
309 ;
310 return WrapText( o.GetString() );
311 }
312 return {};
313}
XO("Cut/Copy/Paste")
const wxString VerCheckHtml()
Definition: HelpText.cpp:359

References VerCheckHtml(), 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 36 of file HelpText.cpp.

36 {
37 wxColour c = theTheme.Colour(i);
38 return wxString::Format("\"#%02X%02X%02X\"",
39 c.Red(), c.Green(), c.Blue() );
40}
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 53 of file HelpText.cpp.

54{
55 return wxString(wxT("")) +
56 wxT("<a href='innerlink:") +
57 Key +
58 wxT("'>") +
59 Text +
60 wxT("</a>");
61}

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 85 of file HelpText.cpp.

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

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 135 of file HelpText.cpp.

136{
137 if(Key==wxT("welcome"))
138 {
139 return XO("Welcome!");
140 }
141
142 if(Key ==wxT("play") )
143 {
144 /* i18n-hint: Title for a topic.*/
145 return XO("Playing Audio");
146 }
147 if((Key ==wxT("record") ) || (Key ==wxT("norecord") ))
148 {
149 /* i18n-hint: Title for a topic.*/
150 return XO("Recording Audio");
151 }
152 if(Key ==wxT("inputdevice") )
153 {
154 /* i18n-hint: Title for a topic.*/
155 return XO("Recording - Choosing the Recording Device");
156 }
157 if(Key ==wxT("inputsource") )
158 {
159 /* i18n-hint: Title for a topic.*/
160 return XO("Recording - Choosing the Recording Source");
161 }
162 if(Key ==wxT("inputlevel") )
163 {
164 /* i18n-hint: Title for a topic.*/
165 return XO("Recording - Setting the Recording Level");
166 }
167 if((Key ==wxT("edit") ) || (Key==wxT("grey")))
168 {
169 /* i18n-hint: Title for a topic.*/
170 return XO("Editing and greyed out Menus");
171 }
172 if(Key ==wxT("export") )
173 {
174 /* i18n-hint: Title for a topic.*/
175 return XO("Exporting an Audio File");
176 }
177 if(Key ==wxT("save") )
178 {
179 /* i18n-hint: Title for a topic.*/
180 return XO("Saving an Audacity Project");
181 }
182 if(Key ==wxT("wma-proprietary") )
183 {
184 /* i18n-hint: Title for a topic.*/
185 return XO("Support for Other Formats");
186 }
187 if(Key ==wxT("burncd") )
188 {
189 /* i18n-hint: Title for a topic.*/
190 return XO("Burn to CD" );
191 }
192 if(Key == wxT("remotehelp") )
193 {
194 return XO("No Local Help");
195 }
196 // Uh oh, no translation...
197 return Verbatim( Key );
198}
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 75 of file HelpText.cpp.

76{
77 return wxString(wxT("")) +
78 wxT("<a href='") +
79 Key +
80 wxT("'>") +
81 Text +
82 wxT("</a>");
83}

References wxT().

Referenced by LinkExpand().

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

◆ VerCheckArgs()

const wxString VerCheckArgs ( )

Definition at line 348 of file HelpText.cpp.

348 {
349 wxString result = wxString("from_ver=") + AUDACITY_VERSION_STRING;
350#ifdef REV_LONG
351 result += wxString("&CommitId=")+wxString(REV_LONG).Left(6);
352#endif
353 result += wxString("&Time=") + wxString( __DATE__ ) + wxString( __TIME__ );
354 result.Replace(" ","");
355 return result;
356}

Referenced by VerCheckUrl().

Here is the caller graph for this function:

◆ VerCheckHtml()

const wxString VerCheckHtml ( )

Definition at line 359 of file HelpText.cpp.

360{
361 wxStringOutputStream o;
362 wxTextOutputStream s(o);
363 s
364 << "<center>[["
365 << VerCheckUrl().GET()
366 << "|"
367 << XO("Check Online")
368 << "]]</center>\n";
369 return o.GetString();
370}
const URLString VerCheckUrl()
Definition: HelpText.cpp:373
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

References Identifier::GET(), VerCheckUrl(), and XO().

Referenced by HelpTextBuiltIn(), and AboutDialog::PopulateInformationPage().

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

◆ VerCheckUrl()

const URLString VerCheckUrl ( )

Definition at line 373 of file HelpText.cpp.

374{
375 //The version we intend to use for live Audacity.
376#define VER_CHECK_URL "https://www.audacityteam.org/download/?"
377//For testing of our scriptlet.
378//#define VER_CHECK_URL "http://www.audacityteam.org/slug/?"
379//For testing locally
380//#define VER_CHECK_URL "http://localhost:63342/WorkingDocs/demos/download.html?"
381
382 return wxString( wxT(VER_CHECK_URL)) +VerCheckArgs();
383}
const wxString VerCheckArgs()
Definition: HelpText.cpp:348
#define VER_CHECK_URL

References VER_CHECK_URL, VerCheckArgs(), and wxT().

Referenced by VerCheckHtml().

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 42 of file HelpText.cpp.

43{
44 return wxString(wxT(""))+
45 wxT("<html><head></head>") +
46 wxT("<body bgcolor=") + HtmlColourOfIndex(clrTrackInfo) + wxT(">") +
47 wxT("<font color=") + HtmlColourOfIndex(clrTrackPanelText) + wxT(">") +
48 wxT("<p>") + Text +
49 wxT("</font>")+
50 wxT("</body></html>");
51}

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: