2010-01-23 19:44:49 +00:00
/**********************************************************************
Audacity : A Digital Audio Editor
HelpText . cpp
James Crook
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /**
\ file HelpText . cpp
\ brief Given a key , returns some html .
*/ /********************************************************************/
2019-03-22 15:01:00 +00:00
# include "Audacity.h" // for USE_* macros
2018-11-10 19:47:12 +00:00
# include "HelpText.h"
2018-11-11 02:40:37 +00:00
2018-11-11 17:27:44 +00:00
# include "Experimental.h"
2010-01-23 19:44:49 +00:00
# include <wx/string.h>
# include <wx/intl.h>
# include "FileNames.h"
2019-05-11 11:18:24 +00:00
# include "Internat.h"
2017-04-02 22:07:13 +00:00
# include "AllThemeResources.h"
2010-01-23 19:44:49 +00:00
2017-04-02 22:07:13 +00:00
wxString HtmlColourOfIndex ( int i ) {
wxColour c = theTheme . Colour ( i ) ;
return wxString : : Format ( " \" #%02X%02X%02X \" " ,
c . Red ( ) , c . Green ( ) , c . Blue ( ) ) ;
}
2010-01-23 19:44:49 +00:00
2013-09-21 19:15:42 +00:00
static wxString WrapText ( const wxString & Text )
2010-01-23 19:44:49 +00:00
{
return wxString ( wxT ( " " ) ) +
wxT ( " <html><head></head> " ) +
2017-04-02 22:07:13 +00:00
wxT ( " <body bgcolor= " ) + HtmlColourOfIndex ( clrTrackInfo ) + wxT ( " > " ) +
wxT ( " <font color= " ) + HtmlColourOfIndex ( clrTrackPanelText ) + wxT ( " > " ) +
2010-01-23 19:44:49 +00:00
wxT ( " <p> " ) + Text +
2017-04-02 22:07:13 +00:00
wxT ( " </font> " ) +
2010-01-23 19:44:49 +00:00
wxT ( " </body></html> " ) ;
}
2017-08-25 12:54:37 +00:00
static wxString InnerLink ( const wxString & Key , const wxString & Text )
2010-01-23 19:44:49 +00:00
{
return wxString ( wxT ( " " ) ) +
wxT ( " <a href='innerlink: " ) +
Key +
wxT ( " '> " ) +
Text +
wxT ( " </a> " ) ;
}
2013-09-21 19:15:42 +00:00
static wxString WikiLink ( const wxString & Key , const wxString & Text )
2010-01-23 19:44:49 +00:00
{
return wxString ( wxT ( " " ) ) +
2017-08-25 12:54:37 +00:00
wxT ( " <a href='https://www.audacityteam.org/wiki/index.php?title= " ) +
2010-01-23 19:44:49 +00:00
Key +
wxT ( " '> " ) +
Text +
wxT ( " </a> " ) ;
}
2013-09-21 19:15:42 +00:00
static wxString FileLink ( const wxString & Key , const wxString & Text )
2010-01-23 19:44:49 +00:00
{
return wxString ( wxT ( " " ) ) +
wxT ( " <a href=' " ) +
wxT ( " file: " ) +
FileNames : : HtmlHelpDir ( ) +
Key +
wxT ( " '> " ) +
Text +
wxT ( " </a> " ) ;
}
2016-09-10 20:34:14 +00:00
static wxString TypedLink ( const wxString & Key , const wxString & Text )
2010-01-23 19:44:49 +00:00
{
return wxString ( wxT ( " " ) ) +
wxT ( " <a href=' " ) +
Key +
wxT ( " '> " ) +
Text +
wxT ( " </a> " ) ;
}
2013-09-21 19:15:42 +00:00
static wxString LinkExpand ( const wxString & Text )
2010-01-23 19:44:49 +00:00
{
wxString Temp = Text ;
int i , j , k ;
while ( ( i = Temp . First ( wxT ( " [[ " ) ) ) ! = wxNOT_FOUND )
{
wxString Key = Temp . Mid ( i + 2 ) ;
j = Key . First ( wxT ( " | " ) ) ;
if ( j = = wxNOT_FOUND )
return Temp ;
wxString LinkText = Key . Mid ( j + 1 ) ;
k = LinkText . First ( wxT ( " ]] " ) ) ;
if ( k = = wxNOT_FOUND )
return Temp ;
Key = Key . Mid ( 0 , j ) ;
LinkText = LinkText . Mid ( 0 , k ) ;
2017-04-02 22:07:13 +00:00
LinkText = wxString ( " <font color= " ) + HtmlColourOfIndex ( clrSample ) + wxT ( " > " ) + LinkText + " </font> " ;
2010-01-23 19:44:49 +00:00
wxString Replacement ;
if ( Key . StartsWith ( wxT ( " wiki: " ) ) )
{
Replacement = WikiLink ( Key . Mid ( 5 ) , LinkText ) ;
}
else if ( Key . StartsWith ( wxT ( " file: " ) ) )
{
Replacement = FileLink ( Key . Mid ( 5 ) , LinkText ) ;
}
else if ( Key . StartsWith ( wxT ( " http: " ) ) )
{
2016-09-10 20:34:14 +00:00
Replacement = TypedLink ( Key , LinkText ) ;
}
2017-08-23 16:48:05 +00:00
else if ( Key . StartsWith ( wxT ( " https: " ) ) )
{
Replacement = TypedLink ( Key , LinkText ) ;
}
2016-09-10 20:34:14 +00:00
else if ( Key . StartsWith ( wxT ( " mailto: " ) ) )
{
Replacement = TypedLink ( Key , LinkText ) ;
}
else if ( Key . StartsWith ( wxT ( " *URL* " ) ) )
{
Replacement = TypedLink ( Key , LinkText ) ;
2010-01-23 19:44:49 +00:00
}
else
{
2017-08-25 12:54:37 +00:00
Replacement = InnerLink ( Key , LinkText ) ;
2010-01-23 19:44:49 +00:00
}
2017-04-02 22:07:13 +00:00
2010-01-23 19:44:49 +00:00
Temp = Temp . Mid ( 0 , i ) + Replacement + Temp . Mid ( i + j + k + 5 ) ; // 5 for the [[|]]
}
return Temp ;
}
wxString TitleText ( const wxString & Key )
{
if ( Key = = wxT ( " welcome " ) )
{
return _ ( " Welcome! " ) ;
}
if ( Key = = wxT ( " play " ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2010-01-23 19:44:49 +00:00
return _ ( " Playing Audio " ) ;
}
if ( ( Key = = wxT ( " record " ) ) | | ( Key = = wxT ( " norecord " ) ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2010-01-23 19:44:49 +00:00
return _ ( " Recording Audio " ) ;
}
if ( Key = = wxT ( " inputdevice " ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2014-07-21 21:37:53 +00:00
return _ ( " Recording - Choosing the Recording Device " ) ;
2010-01-23 19:44:49 +00:00
}
if ( Key = = wxT ( " inputsource " ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2014-07-21 21:37:53 +00:00
return _ ( " Recording - Choosing the Recording Source " ) ;
2010-01-23 19:44:49 +00:00
}
if ( Key = = wxT ( " inputlevel " ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2014-07-21 21:37:53 +00:00
return _ ( " Recording - Setting the Recording Level " ) ;
2010-01-23 19:44:49 +00:00
}
if ( ( Key = = wxT ( " edit " ) ) | | ( Key = = wxT ( " grey " ) ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2010-01-23 19:44:49 +00:00
return _ ( " Editing and greyed out Menus " ) ;
}
if ( Key = = wxT ( " export " ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2010-01-23 19:44:49 +00:00
return _ ( " Exporting an Audio File " ) ;
}
if ( Key = = wxT ( " save " ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2010-01-23 19:44:49 +00:00
return _ ( " Saving an Audacity Project " ) ;
}
if ( Key = = wxT ( " wma-proprietary " ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2011-07-29 08:34:04 +00:00
return _ ( " Support for Other Formats " ) ;
2010-01-23 19:44:49 +00:00
}
if ( Key = = wxT ( " burncd " ) )
{
2012-03-20 15:36:02 +00:00
/* i18n-hint: Title for a topic.*/
2010-01-23 19:44:49 +00:00
return _ ( " Burn to CD " ) ;
}
if ( Key = = wxT ( " remotehelp " ) )
{
return _ ( " No Local Help " ) ;
}
return Key ;
}
2013-09-21 19:15:42 +00:00
static wxString HelpTextBuiltIn ( const wxString & Key )
2010-01-23 19:44:49 +00:00
{
2017-09-02 01:42:19 +00:00
// PRL: Is it necessary to define these outside of conditional compilation so that both get into the .pot file?
auto alphamsg = _ ( " <br><br>The version of Audacity you are using is an <b>Alpha test version</b>. " ) ;
auto betamsg = _ ( " <br><br>The version of Audacity you are using is a <b>Beta test version</b>. " ) ;
if ( Key = = wxT ( " welcome " ) )
2010-01-23 19:44:49 +00:00
{
2014-06-25 10:12:25 +00:00
/// TO-DO: Make the links to help here use the widgets/HelpSystem mechanism
2017-04-02 22:07:13 +00:00
/// so that they are consistent
2012-03-20 21:59:30 +00:00
/* i18n-hint: Preserve [[file:quick_help.html as it's the name of a file.*/
2017-03-02 16:33:19 +00:00
wxString result =
2016-05-01 12:42:00 +00:00
wxString ( wxT ( " " ) ) +
2017-09-11 04:08:31 +00:00
# if defined(IS_ALPHA) || defined(IS_BETA)
2017-02-28 19:05:06 +00:00
wxT ( " <hr><center><h3> " ) + _ ( " Get the Official Released Version of Audacity " ) + wxT ( " </h3></center> " ) +
VerCheckHtml ( ) +
2017-09-11 04:08:31 +00:00
# ifdef IS_ALPHA
2017-09-02 01:42:19 +00:00
alphamsg
# else
betamsg
# endif
+ " " +
_ ( " We strongly recommend that you use our latest stable released version, which has full documentation and support.<br><br> " ) +
2018-02-05 15:08:38 +00:00
_ ( " You can help us get Audacity ready for release by joining our [[https://www.audacityteam.org/community/|community]].<hr><br><br> " ) +
2018-02-05 12:47:05 +00:00
# endif
2017-04-02 22:07:13 +00:00
// DA: Support methods text.
# ifdef EXPERIMENTAL_DA
2018-02-26 14:09:07 +00:00
// Deliberately not translated.
2017-04-02 22:07:13 +00:00
wxT ( " <center><h3>DarkAudacity " ) + AUDACITY_VERSION_STRING + wxT ( " </h3></center> " ) +
2018-02-26 14:09:07 +00:00
wxT ( " <br><br>DarkAudacity is based on Audacity: " ) + wxT ( " <ul><li> " ) +
wxT ( " [[http://www.darkaudacity.com|www.darkaudacity.com]] - for differences between them. " ) + wxT ( " </li><li> " ) +
wxT ( " email to [[mailto:james@audacityteam.org|james@audacityteam.org]] - for help using DarkAudacity. " ) + wxT ( " </li><li> " ) +
wxT ( " [[http://www.darkaudacity.com/video.html|Tutorials]] - for getting started with DarkAudacity. " ) + wxT ( " </li></ul> " ) +
2017-04-02 22:07:13 +00:00
wxT ( " <br><br>Audacity has these support methods: " ) + wxT ( " <ul><li> " ) +
2017-08-25 12:54:37 +00:00
wxT ( " [[https://manual.audacityteam.org/|Manual]] - for comprehensive Audacity documentation " ) + wxT ( " </li><li> " ) +
wxT ( " [[https://forum.audacityteam.org/|Forum]] - for large knowledge base on using Audacity. " ) + wxT ( " </li></ul> " ) ;
2017-04-02 22:07:13 +00:00
# else
2016-05-01 12:42:00 +00:00
wxT ( " <center><h3>Audacity " ) + AUDACITY_VERSION_STRING + wxT ( " </h3><h3> " ) +
_ ( " How to get help " ) + wxT ( " </h3></center> " ) +
_ ( " These are our support methods: " ) + wxT ( " <p><ul><li> " ) +
2018-02-05 15:08:38 +00:00
_ ( " [[file:quick_help.html|Quick Help]] - if not installed locally, [[https://manual.audacityteam.org/quick_help.html|view online]] " ) + wxT ( " </li><li> " ) +
_ ( " [[file:index.html|Manual]] - if not installed locally, [[https://manual.audacityteam.org/|view online]] " ) + wxT ( " </li><li> " ) +
_ ( " [[https://forum.audacityteam.org/|Forum]] - ask your question directly, online. " ) + wxT ( " </li></ul></p><p> " ) + wxT ( " <b> " ) +
_ ( " More:</b> Visit our [[https://wiki.audacityteam.org/index.php|Wiki]] for tips, tricks, extra tutorials and effects plug-ins. " ) + wxT ( " </p> " ) ;
2017-04-02 22:07:13 +00:00
# endif
2017-03-02 16:33:19 +00:00
2017-09-11 04:08:31 +00:00
# ifdef USE_ALPHA_MANUAL
2017-03-02 16:33:19 +00:00
result . Replace ( " //manual.audacityteam.org/quick_help.html " , " //alphamanual.audacityteam.org/man/Quick_Help " ) ;
result . Replace ( " //manual.audacityteam.org/ " , " //alphamanual.audacityteam.org/man/ " ) ;
# endif
return WrapText ( result ) ;
2010-01-23 19:44:49 +00:00
}
2011-07-29 08:34:04 +00:00
if ( Key = = wxT ( " wma-proprietary " ) )
{
return WrapText (
wxString ( wxT ( " <p> " ) ) +
2018-02-05 15:08:38 +00:00
_ ( " Audacity can import unprotected files in many other formats (such as M4A and WMA, \
2011-07-29 08:34:04 +00:00
compressed WAV files from portable recorders and audio from video files ) if you download and install \
2018-02-05 15:08:38 +00:00
the optional [ [ https : / / manual . audacityteam . org / man / faq_opening_and_saving_files . html # foreign | \
FFmpeg library ] ] to your computer . " ) + wxT( " < / p > < p > " ) +
2011-07-29 08:34:04 +00:00
_ ( " You can also read our help on importing \
2018-02-05 15:08:38 +00:00
[[https://manual.audacityteam.org/man/playing_and_recording.html#midi|MIDI files]] \
2018-08-29 17:20:50 +00:00
and tracks from [ [ https : / / manual . audacityteam . org / man / faq_opening_and_saving_files . html # fromcd | \
2018-02-05 15:08:38 +00:00
audio CDs ] ] . " )
+ wxT ( " </p> " )
2011-07-29 08:34:04 +00:00
) ;
}
2010-01-23 19:44:49 +00:00
// Remote help allows us to link to a local copy of the help if it exists,
2010-09-28 01:50:45 +00:00
// or provide a message that takes you to the Internet if it does not.
2010-01-23 19:44:49 +00:00
// It's used by the menu item Help > Index
if ( Key = = wxT ( " remotehelp " ) )
{
// *URL* will be replaced by whatever URL we are looking for.
2017-04-02 22:07:13 +00:00
// DA: View the manual on line is expected.
# ifdef EXPERIMENTAL_DA
return WrapText ( _ ( " The Manual does not appear to be installed. \
Please [[*URL*|view the Manual online]] . < br > < br > \
To always view the Manual online , change \ " Location of Manual \" in \
2017-10-19 17:08:04 +00:00
Interface Preferences to \ " From Internet \" . " ) ) ;
2017-04-02 22:07:13 +00:00
# else
2018-02-05 15:08:38 +00:00
return WrapText ( _ ( " The Manual does not appear to be installed. \
2016-09-10 20:34:14 +00:00
Please [[*URL*|view the Manual online]] or \
2018-02-05 15:08:38 +00:00
[ [ https : / / manual . audacityteam . org / man / unzipping_the_manual . html | \
2016-09-10 20:34:14 +00:00
download the Manual ] ] . < br > < br > \
2016-08-09 16:55:03 +00:00
To always view the Manual online , change \ " Location of Manual \" in \
2018-02-05 15:08:38 +00:00
Interface Preferences to \ " From Internet \" . " ) ) ;
2017-04-02 22:07:13 +00:00
# endif
2010-01-23 19:44:49 +00:00
}
return wxT ( " " ) ;
}
wxString HelpText ( const wxString & Key )
{
// Possible future enhancement...
// We could look for the text as a local file and use
// that if we find it...
// if( wxFileExists( Path+Key ) )
// ...
wxString Text ;
Text = HelpTextBuiltIn ( Key ) ;
2019-02-12 00:10:48 +00:00
if ( ! Text . empty ( ) )
2010-01-23 19:44:49 +00:00
return LinkExpand ( Text ) ;
// Perhaps useful for debugging - we'll return key that we didn't find.
return WrapText ( Key ) ;
}
2016-09-10 20:34:14 +00:00
2017-04-02 22:07:13 +00:00
2016-09-10 20:34:14 +00:00
wxString FormatHtmlText ( const wxString & Text ) {
wxString localeStr = wxLocale : : GetSystemEncodingName ( ) ;
return
wxT ( " <html><head><META http-equiv= \" Content-Type \" content= \" text/html; charset= " ) +
localeStr +
wxT ( " \" ></head> " ) +
WrapText ( LinkExpand ( Text ) ) +
wxT ( " </html> " ) ;
2016-09-11 12:03:37 +00:00
}
2019-05-11 11:18:24 +00:00
// Function to give the extra arguments to put on the version check string.
const wxString VerCheckArgs ( ) {
wxString result = wxString ( " from_ver= " ) + AUDACITY_VERSION_STRING ;
# ifdef REV_LONG
result + = wxString ( " &CommitId= " ) + wxString ( REV_LONG ) . Left ( 6 ) ;
# endif
result + = wxString ( " &Time= " ) + wxString ( __DATE__ ) + wxString ( __TIME__ ) ;
result . Replace ( " " , " " ) ;
return result ;
}
// Text of hyperlink to check versions.
const wxString VerCheckHtml ( ) {
wxString result = " <center>[[ " ;
result + = VerCheckUrl ( ) + " | " + _ ( " Check Online " ) ;
result + = " ]]</center> \n " ;
return result ;
}
// Url with Version check args attached.
const wxString VerCheckUrl ( ) {
//The version we intend to use for live Audacity.
# define VER_CHECK_URL "https: //www.audacityteam.org/download/?"
//For testing of our scriptlet.
//#define VER_CHECK_URL "http://www.audacityteam.org/slug/?"
//For testing locally
//#define VER_CHECK_URL "http://localhost:63342/WorkingDocs/demos/download.html?"
return wxString ( wxT ( VER_CHECK_URL ) ) + VerCheckArgs ( ) ;
}