Audacity  2.2.2
Functions
HelpText.cpp File Reference

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

#include <wx/string.h>
#include <wx/intl.h>
#include "Audacity.h"
#include "HelpText.h"
#include "FileNames.h"
#include "AboutDialog.h"
#include "AllThemeResources.h"
#include "Internat.h"

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 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)
 
wxString 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

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

Definition at line 63 of file HelpText.cpp.

References FileNames::HtmlHelpDir().

Referenced by LinkExpand().

64 {
65  return wxString(wxT("")) +
66  wxT("<a href='") +
67  wxT("file:") +
69  Key +
70  wxT("'>") +
71  Text +
72  wxT("</a>");
73 }
static wxString HtmlHelpDir()
Definition: FileNames.cpp:173
wxString FormatHtmlText ( const wxString &  Text)

Definition at line 317 of file HelpText.cpp.

References LinkExpand(), and WrapText().

Referenced by AboutDialog::PopulateAudacityPage(), AboutDialog::PopulateInformationPage(), and AboutDialog::PopulateLicensePage().

317  {
318 
319  wxString localeStr = wxLocale::GetSystemEncodingName();
320 
321  return
322  wxT("<html><head><META http-equiv=\"Content-Type\" content=\"text/html; charset=") +
323  localeStr +
324  wxT("\"></head>") +
325  WrapText( LinkExpand( Text ))+
326  wxT("</html>");
327 }
static wxString WrapText(const wxString &Text)
Definition: HelpText.cpp:32
static wxString LinkExpand(const wxString &Text)
Definition: HelpText.cpp:85
wxString HelpText ( const wxString &  Key)

Definition at line 297 of file HelpText.cpp.

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

Referenced by ErrorDialog::OnHelp(), LinkingHtmlWindow::OnLinkClicked(), SplashDialog::Populate(), SplashDialog::Show2(), and HelpSystem::ShowHelp().

298 {
299 
300  // Possible future enhancement...
301  // We could look for the text as a local file and use
302  // that if we find it...
303  // if( wxFileExists( Path+Key ) )
304  // ...
305 
306  wxString Text;
307  Text = HelpTextBuiltIn( Key );
308 
309  if( !Text.IsEmpty())
310  return LinkExpand( Text );
311 
312  // Perhaps useful for debugging - we'll return key that we didn't find.
313  return WrapText( Key );
314 }
static wxString HelpTextBuiltIn(const wxString &Key)
Definition: HelpText.cpp:203
static wxString WrapText(const wxString &Text)
Definition: HelpText.cpp:32
static wxString LinkExpand(const wxString &Text)
Definition: HelpText.cpp:85
static wxString HelpTextBuiltIn ( const wxString &  Key)
static

TO-DO: Make the links to help here use the widgets/HelpSystem mechanism so that they are consistent

Definition at line 203 of file HelpText.cpp.

References _(), AUDACITY_VERSION_STRING, VerCheckHtml(), and WrapText().

Referenced by HelpText().

204 {
205  // PRL: Is it necessary to define these outside of conditional compilation so that both get into the .pot file?
206  auto alphamsg = _("<br><br>The version of Audacity you are using is an <b>Alpha test version</b>.");
207  auto betamsg = _("<br><br>The version of Audacity you are using is a <b>Beta test version</b>.");
208 
209  if (Key == wxT("welcome"))
210  {
213  /* i18n-hint: Preserve [[file:quick_help.html as it's the name of a file.*/
214  wxString result =
215  wxString(wxT("")) +
216 #if defined(IS_ALPHA) || defined(IS_BETA)
217  wxT("<hr><center><h3>") + _("Get the Official Released Version of Audacity") + wxT("</h3></center>") +
218  VerCheckHtml() +
219 #ifdef IS_ALPHA
220  alphamsg
221 #else
222  betamsg
223 #endif
224  + " " +
225  _("We strongly recommend that you use our latest stable released version, which has full documentation and support.<br><br>") +
226  _("You can help us get Audacity ready for release by joining our [[https://www.audacityteam.org/community/|community]].<hr><br><br>") +
227 #endif
228 
229 // DA: Support methods text.
230 #ifdef EXPERIMENTAL_DA
231  wxT("<center><h3>DarkAudacity ") + AUDACITY_VERSION_STRING + wxT("</h3></center>") +
232  _("<br><br>DarkAudacity is based on Audacity:") + wxT("<ul><li>") +
233  _(" [[https://www.darkaudacity.com|www.darkaudacity.com]] - for differences between them.") + wxT("</li><li>") +
234  _(" email to [[mailto:[email protected]|[email protected]]] - for help using DarkAudacity.") + wxT("</li><li>") +
235  _(" [[https://www.darkaudacity.com/video.html|Tutorials]] - for getting started with DarkAudacity.") + wxT("</li></ul>") +
236 
237  wxT("<br><br>Audacity has these support methods:") + wxT("<ul><li>") +
238  wxT(" [[https://manual.audacityteam.org/|Manual]] - for comprehensive Audacity documentation") + wxT("</li><li>") +
239  wxT(" [[https://forum.audacityteam.org/|Forum]] - for large knowledge base on using Audacity.") + wxT("</li></ul>");
240 #else
241  wxT("<center><h3>Audacity ") + AUDACITY_VERSION_STRING + wxT("</h3><h3>") +
242  _("How to get help") + wxT("</h3></center>") +
243  _("These are our support methods:") + wxT("<p><ul><li>") +
244  _(" [[file:quick_help.html|Quick Help]] - if not installed locally, [[https://manual.audacityteam.org/quick_help.html|view online]]") + wxT("</li><li>") +
245  _(" [[file:index.html|Manual]] - if not installed locally, [[https://manual.audacityteam.org/|view online]]") + wxT("</li><li>") +
246  _(" [[https://forum.audacityteam.org/|Forum]] - ask your question directly, online.") + wxT("</li></ul></p><p>") + wxT("<b>") +
247  _("More:</b> Visit our [[https://wiki.audacityteam.org/index.php|Wiki]] for tips, tricks, extra tutorials and effects plug-ins.") + wxT("</p>");
248 #endif
249 
250 #ifdef USE_ALPHA_MANUAL
251  result.Replace( "//manual.audacityteam.org/quick_help.html","//alphamanual.audacityteam.org/man/Quick_Help" );
252  result.Replace( "//manual.audacityteam.org/","//alphamanual.audacityteam.org/man/" );
253 #endif
254 
255  return WrapText( result );
256  }
257  if(Key==wxT("wma-proprietary"))
258  {
259  return WrapText(
260  wxString(wxT("<p>"))+
261  _("Audacity can import unprotected files in many other formats (such as M4A and WMA, \
262 compressed WAV files from portable recorders and audio from video files) if you download and install \
263 the optional [[https://manual.audacityteam.org/man/faq_opening_and_saving_files.html#foreign| \
264 FFmpeg library]] to your computer.") + wxT("</p><p>") +
265  _("You can also read our help on importing \
266 [[https://manual.audacityteam.org/man/playing_and_recording.html#midi|MIDI files]] \
267 and tracks from [[http://manual.audacityteam.org/man/faq_opening_and_saving_files.html#fromcd| \
268 audio CDs]].")
269  + wxT("</p>")
270  );
271  }
272 
273  // Remote help allows us to link to a local copy of the help if it exists,
274  // or provide a message that takes you to the Internet if it does not.
275  // It's used by the menu item Help > Index
276  if(Key == wxT("remotehelp") )
277  {
278 // *URL* will be replaced by whatever URL we are looking for.
279 // DA: View the manual on line is expected.
280 #ifdef EXPERIMENTAL_DA
281  return WrapText(_("The Manual does not appear to be installed. \
282 Please [[*URL*|view the Manual online]].<br><br>\
283 To always view the Manual online, change \"Location of Manual\" in \
284 Interface Preferences to \"From Internet\"."));
285 #else
286  return WrapText( _("The Manual does not appear to be installed. \
287 Please [[*URL*|view the Manual online]] or \
288 [[https://manual.audacityteam.org/man/unzipping_the_manual.html| \
289 download the Manual]].<br><br>\
290 To always view the Manual online, change \"Location of Manual\" in \
291 Interface Preferences to \"From Internet\"."));
292 #endif
293  }
294  return wxT("");
295 }
#define AUDACITY_VERSION_STRING
Definition: Audacity.h:81
const wxString VerCheckHtml()
Definition: AboutDialog.cpp:96
static wxString WrapText(const wxString &Text)
Definition: HelpText.cpp:32
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
wxString HtmlColourOfIndex ( int  i)

Definition at line 26 of file HelpText.cpp.

References ThemeBase::Colour(), and theTheme.

Referenced by LinkExpand(), and WrapText().

26  {
27  wxColour c = theTheme.Colour(i);
28  return wxString::Format("\"#%02X%02X%02X\"",
29  c.Red(), c.Green(), c.Blue() );
30 }
AUDACITY_DLL_API Theme theTheme
Definition: Theme.cpp:209
wxColour & Colour(int iIndex)
Definition: Theme.cpp:1208
static wxString InnerLink ( const wxString &  Key,
const wxString &  Text 
)
static

Definition at line 43 of file HelpText.cpp.

Referenced by LinkExpand().

44 {
45  return wxString(wxT("")) +
46  wxT("<a href='innerlink:") +
47  Key +
48  wxT("'>") +
49  Text +
50  wxT("</a>");
51 }
static wxString LinkExpand ( const wxString &  Text)
static

Definition at line 85 of file HelpText.cpp.

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

Referenced by FormatHtmlText(), and HelpText().

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("wiki:") ))
105  {
106  Replacement = WikiLink( Key.Mid( 5 ), LinkText );
107  }
108  else if( Key.StartsWith( wxT("file:") ))
109  {
110  Replacement = FileLink( Key.Mid( 5 ), LinkText );
111  }
112  else if( Key.StartsWith( wxT("http:") ))
113  {
114  Replacement = TypedLink( Key, LinkText );
115  }
116  else if( Key.StartsWith( wxT("https:") ))
117  {
118  Replacement = TypedLink( Key, LinkText );
119  }
120  else if( Key.StartsWith( wxT("mailto:") ))
121  {
122  Replacement = TypedLink( Key, LinkText );
123  }
124  else if( Key.StartsWith( wxT("*URL*") ))
125  {
126  Replacement = TypedLink( Key, LinkText );
127  }
128  else
129  {
130  Replacement = InnerLink( Key, LinkText );
131  }
132 
133 
134  Temp = Temp.Mid( 0, i ) + Replacement + Temp.Mid( i + j + k + 5 );// 5 for the [[|]]
135  }
136  return Temp;
137 }
static wxString WikiLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:53
wxString HtmlColourOfIndex(int i)
Definition: HelpText.cpp:26
static wxString InnerLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:43
static wxString FileLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:63
static wxString TypedLink(const wxString &Key, const wxString &Text)
Definition: HelpText.cpp:75
wxString TitleText ( const wxString &  Key)

Definition at line 139 of file HelpText.cpp.

References _().

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

140 {
141  if(Key==wxT("welcome"))
142  {
143  return _("Welcome!");
144  }
145 
146  if(Key ==wxT("play") )
147  {
148  /* i18n-hint: Title for a topic.*/
149  return _("Playing Audio");
150  }
151  if((Key ==wxT("record") ) || (Key ==wxT("norecord") ))
152  {
153  /* i18n-hint: Title for a topic.*/
154  return _("Recording Audio");
155  }
156  if(Key ==wxT("inputdevice") )
157  {
158  /* i18n-hint: Title for a topic.*/
159  return _("Recording - Choosing the Recording Device");
160  }
161  if(Key ==wxT("inputsource") )
162  {
163  /* i18n-hint: Title for a topic.*/
164  return _("Recording - Choosing the Recording Source");
165  }
166  if(Key ==wxT("inputlevel") )
167  {
168  /* i18n-hint: Title for a topic.*/
169  return _("Recording - Setting the Recording Level");
170  }
171  if((Key ==wxT("edit") ) || (Key==wxT("grey")))
172  {
173  /* i18n-hint: Title for a topic.*/
174  return _("Editing and greyed out Menus");
175  }
176  if(Key ==wxT("export") )
177  {
178  /* i18n-hint: Title for a topic.*/
179  return _("Exporting an Audio File");
180  }
181  if(Key ==wxT("save") )
182  {
183  /* i18n-hint: Title for a topic.*/
184  return _("Saving an Audacity Project");
185  }
186  if(Key ==wxT("wma-proprietary") )
187  {
188  /* i18n-hint: Title for a topic.*/
189  return _("Support for Other Formats");
190  }
191  if(Key ==wxT("burncd") )
192  {
193  /* i18n-hint: Title for a topic.*/
194  return _("Burn to CD" );
195  }
196  if(Key == wxT("remotehelp") )
197  {
198  return _("No Local Help");
199  }
200  return Key;
201 }
_("Move Track &Down")+wxT("\t")+(GetActiveProject() -> GetCommandManager() ->GetKeyFromName(wxT("TrackMoveDown"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveTopID, _("Move Track to &Top")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveTop"))), OnMoveTrack) POPUP_MENU_ITEM(OnMoveBottomID, _("Move Track to &Bottom")+wxT("\t")+(GetActiveProject() ->GetCommandManager() ->GetKeyFromName(wxT("TrackMoveBottom"))), OnMoveTrack) void TrackMenuTable::OnSetName(wxCommandEvent &)
static wxString TypedLink ( const wxString &  Key,
const wxString &  Text 
)
static

Definition at line 75 of file HelpText.cpp.

Referenced by LinkExpand().

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

Definition at line 53 of file HelpText.cpp.

Referenced by LinkExpand().

54 {
55  return wxString(wxT("")) +
56  wxT("<a href='https://www.audacityteam.org/wiki/index.php?title=") +
57  Key +
58  wxT("'>") +
59  Text +
60  wxT("</a>");
61 }
static wxString WrapText ( const wxString &  Text)
static

Definition at line 32 of file HelpText.cpp.

References HtmlColourOfIndex().

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

33 {
34  return wxString(wxT(""))+
35  wxT("<html><head></head>") +
36  wxT("<body bgcolor=") + HtmlColourOfIndex(clrTrackInfo) + wxT(">") +
37  wxT("<font color=") + HtmlColourOfIndex(clrTrackPanelText) + wxT(">") +
38  wxT("<p>") + Text +
39  wxT("</font>")+
40  wxT("</body></html>");
41 }
wxString HtmlColourOfIndex(int i)
Definition: HelpText.cpp:26