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 WikiLink (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 73 of file HelpText.cpp.

74{
75 return wxString(wxT("")) +
76 wxT("<a href='") +
77 wxT("file:") +
79 Key +
80 wxT("'>") +
81 Text +
82 wxT("</a>");
83}
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 349 of file HelpText.cpp.

349 {
350
351 wxString localeStr = wxLocale::GetSystemEncodingName();
352
353 return
354 wxT("<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=") +
355 localeStr +
356 wxT("\"></head>") +
357 WrapText( LinkExpand( Text ))+
358 wxT("</html>");
359}
static wxString WrapText(const wxString &Text)
Definition: HelpText.cpp:42
static wxString LinkExpand(const wxString &Text)
Definition: HelpText.cpp:95

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

330{
331
332 // Possible future enhancement...
333 // We could look for the text as a local file and use
334 // that if we find it...
335 // if( wxFileExists( Path+Key ) )
336 // ...
337
338 wxString Text;
339 Text = HelpTextBuiltIn( Key );
340
341 if( !Text.empty())
342 return LinkExpand( Text );
343
344 // Perhaps useful for debugging - we'll return key that we didn't find.
345 return WrapText( Key );
346}
static wxString HelpTextBuiltIn(const wxString &Key)
Definition: HelpText.cpp:214

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

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

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

96{
97 wxString Temp = Text;
98 int i,j,k;
99 while( (i=Temp.First( wxT("[[") ))!= wxNOT_FOUND )
100 {
101 wxString Key = Temp.Mid(i+2);
102 j = Key.First( wxT("|") );
103 if( j==wxNOT_FOUND )
104 return Temp;
105 wxString LinkText = Key.Mid( j+1);
106 k = LinkText.First( wxT("]]") );
107 if( k==wxNOT_FOUND )
108 return Temp;
109 Key = Key.Mid( 0, j );
110 LinkText = LinkText.Mid( 0, k );
111
112 LinkText=wxString("<font color=") + HtmlColourOfIndex(clrSample) + wxT(">") +LinkText+"</font>";
113 wxString Replacement;
114 if( Key.StartsWith( wxT("wiki:") ))
115 {
116 Replacement = WikiLink( Key.Mid( 5 ), LinkText );
117 }
118 else if( Key.StartsWith( wxT("file:") ))
119 {
120 Replacement = FileLink( Key.Mid( 5 ), LinkText );
121 }
122 else if( Key.StartsWith( wxT("http:") ))
123 {
124 Replacement = TypedLink( Key, LinkText );
125 }
126 else if( Key.StartsWith( wxT("https:") ))
127 {
128 Replacement = TypedLink( Key, LinkText );
129 }
130 else if( Key.StartsWith( wxT("mailto:") ))
131 {
132 Replacement = TypedLink( Key, LinkText );
133 }
134 else if( Key.StartsWith( wxT("*URL*") ))
135 {
136 Replacement = TypedLink( Key, LinkText );
137 }
138 else
139 {
140 Replacement = InnerLink( Key, LinkText );
141 }
142
143
144 Temp = Temp.Mid( 0, i ) + Replacement + Temp.Mid( i + j + k + 5 );// 5 for the [[|]]
145 }
146 return Temp;
147}
static wxString TypedLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:85
static wxString WikiLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:63
static wxString FileLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:73
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(), WikiLink(), 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 149 of file HelpText.cpp.

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

86{
87 return wxString(wxT("")) +
88 wxT("<a href='") +
89 Key +
90 wxT("'>") +
91 Text +
92 wxT("</a>");
93}

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

362 {
363 wxString result = wxString("from_ver=") + AUDACITY_VERSION_STRING;
364#ifdef REV_LONG
365 result += wxString("&CommitId=")+wxString(REV_LONG).Left(6);
366#endif
367 result += wxString("&Time=") + wxString( __DATE__ ) + wxString( __TIME__ );
368 result.Replace(" ","");
369 return result;
370}

Referenced by VerCheckUrl().

Here is the caller graph for this function:

◆ VerCheckHtml()

const wxString VerCheckHtml ( )

Definition at line 373 of file HelpText.cpp.

374{
375 wxStringOutputStream o;
376 wxTextOutputStream s(o);
377 s
378 << "<center>[["
379 << VerCheckUrl().GET()
380 << "|"
381 << XO("Check Online")
382 << "]]</center>\n";
383 return o.GetString();
384}
const URLString VerCheckUrl()
Definition: HelpText.cpp:387
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 387 of file HelpText.cpp.

388{
389 //The version we intend to use for live Audacity.
390#define VER_CHECK_URL "https://www.audacityteam.org/download/?"
391//For testing of our scriptlet.
392//#define VER_CHECK_URL "http://www.audacityteam.org/slug/?"
393//For testing locally
394//#define VER_CHECK_URL "http://localhost:63342/WorkingDocs/demos/download.html?"
395
396 return wxString( wxT(VER_CHECK_URL)) +VerCheckArgs();
397}
const wxString VerCheckArgs()
Definition: HelpText.cpp:362
#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:

◆ WikiLink()

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

Definition at line 63 of file HelpText.cpp.

64{
65 return wxString(wxT("")) +
66 wxT("<a href='https://www.audacityteam.org/wiki/index.php?title=") +
67 Key +
68 wxT("'>") +
69 Text +
70 wxT("</a>");
71}

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 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: