33#include <wx/stattext.h>
34#include <wx/textctrl.h>
36#include <wx/html/htmlwin.h>
37#include <wx/settings.h>
38#include <wx/statusbr.h>
43#include "../ShuttleGui.h"
45#include "../HelpText.h"
48#include "../prefs/GUIPrefs.h"
50#ifdef USE_ALPHA_MANUAL
70#if !wxCHECK_VERSION(3, 0, 0)
76#if !wxCHECK_VERSION(3, 0, 0)
93 const wxString &message,
94 const int xSize,
const int ySize)
98 wxDefaultPosition, wxDefaultSize,
99 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX );
104 S.StartVerticalLay(1);
106 S.AddTitle( shortMsg );
107 S.Style( wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_RICH2 |
108 wxTE_AUTO_URL | wxTE_NOHIDESEL | wxHSCROLL )
109 .AddTextWindow(message);
112 S.StartHorizontalLay(wxALIGN_CENTER_HORIZONTAL, 0);
114 S.EndHorizontalLay();
119 dlog.SetMinSize( wxSize(xSize/2, ySize/2) );
120 dlog.SetSize( wxSize(xSize, ySize) );
127 const wxString &HtmlText,
138 auto pFrame =
safenew wxFrame {
139 pParent, wxID_ANY, Title.
Translation(), wxDefaultPosition, wxDefaultSize,
140#if defined(__WXMAC__)
148 wxDEFAULT_FRAME_STYLE
153 pWnd =
safenew HtmlTextHelpDialog{ pFrame, Title };
158 pFrame->SetTransparent(0);
161 S.Style( wxNO_BORDER | wxTAB_TRAVERSAL )
165 S.StartHorizontalLay( wxEXPAND,
false );
167 S.Id( wxID_BACKWARD )
170 .ToolTip(
XO(
"Backwards" ) )
173 .AddButton(
XXO(
"<") );
177 .ToolTip(
XO(
"Forwards" ) )
180 .AddButton(
XXO(
">") );
182 S.EndHorizontalLay();
186 bIsFile ? wxSize(500, 400) : wxSize(480, 240),
187 wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
189 html->SetRelatedFrame( pFrame, wxT(
"Help: %s") );
191 html->LoadFile( HtmlText );
193 html->SetPage( HtmlText);
195 S.Prop(1).Focus().Position( wxEXPAND )
198 S.Id( wxID_CANCEL ).AddButton(
XXO(
"Close"), wxALIGN_CENTER,
true );
206 wxIcon ic{ wxICON(AudacityLogo) };
211 pFrame->SetIcon( ic );
216 pWnd->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
218 pFrame->CreateStatusBar();
221 pFrame->SetSizeHints(pWnd->GetSize());
231 html->SetRelatedStatusBar( 0 );
241 bool alwaysDefaultBrowser)
244 wxString HelpMode = wxT(
"Local");
247#ifdef EXPERIMENTAL_DA
248 gPrefs->Read(wxT(
"/GUI/Help"), &HelpMode, wxT(
"FromInternet") );
250 gPrefs->Read(wxT(
"/GUI/Help"), &HelpMode, wxT(
"Local") );
255 if( (HelpMode == wxT(
"Standard")) || (HelpMode == wxT(
"InBrowser")) )
267 if (localFileName.Find(
'#',
true) != wxNOT_FOUND)
268 HelpMode = wxT(
"FromInternet");
273 if (localFileName.Find(
'#',
true) != wxNOT_FOUND)
274 localfile = localFileName.BeforeLast(
'#');
276 localfile = localFileName;
278 if( (HelpMode == wxT(
"FromInternet")) && !remoteURL.
empty() )
283 else if( localfile.empty() || !wxFileExists( localfile ))
287 wxASSERT( !remoteURL.
empty() );
290 wxString Text =
HelpText( wxT(
"remotehelp") );
291 Text.Replace( wxT(
"*URL*"), remoteURL.
GET() );
294 ShowHtmlText( parent,
XO(
"Help on the Internet"), Text,
false,
true );
296 else if( HelpMode == wxT(
"Local") || alwaysDefaultBrowser)
304 ShowHtmlText( parent, {}, localFileName,
true, bModal );
314 const wxString ReleaseSuffix = L
".html";
317 wxString webHelpPath;
318 wxString webHelpPage;
319 wxString releasePageName;
321 const auto &PageNameStr = PageName.
GET();
322 if (PageNameStr.Find(
'#',
true) != wxNOT_FOUND)
324 releasePageName = PageNameStr.BeforeLast(
'#');
325 anchor = wxT(
"#") + PageNameStr.AfterLast(
'#');
329 releasePageName = PageName.
GET();
345 if (releasePageName == L
"Main_Page")
347 releasePageName = L
"index" + ReleaseSuffix + anchor;
351 else if (releasePageName == L
"Quick_Help")
354#ifdef EXPERIMENTAL_DA
355 releasePageName = L
"video" + ReleaseSuffix + anchor;
357 webHelpPath = L
"http://www.darkaudacity.com/";
359 releasePageName = L
"quick_help" + ReleaseSuffix + anchor;
366 else if (releasePageName.StartsWith(
"http" ) )
369 releasePageName += anchor;
376 releasePageName = releasePageName.Lower();
384 re.Compile(wxT(
"%.."));
385 re.ReplaceAll(&releasePageName, (wxT(
"_")));
387 re.Compile(wxT(
"[^[:alnum:] . [:space:]]"));
388 re.ReplaceAll(&releasePageName, (wxT(
"_")));
390 releasePageName.Replace(wxT(
" "), wxT(
"+"),
true);
392 re.Compile(wxT(
"__+"));
393 re.ReplaceAll(&releasePageName, (wxT(
"_")));
395 releasePageName.Replace(wxT(
"_."), wxT(
"."),
true);
397 releasePageName = releasePageName + ReleaseSuffix + anchor;
404#ifdef USE_ALPHA_MANUAL
405 webHelpPage = webHelpPath + PageName.
GET();
407 webHelpPage = webHelpPath + releasePageName;
410 wxLogMessage(wxT(
"Help button pressed: PageName %s, releasePageName %s"),
411 PageName.
GET(), releasePageName);
412 wxLogMessage(wxT(
"webHelpPage %s, localHelpPage %s"),
413 webHelpPage, localHelpPage);
426#include <wx/wxprec.h>
428#include <wx/mimetype.h>
429#include <wx/filename.h>
441 :
wxDialogWrapper{ pParent, ID,
title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER }
444 const int minWidth = 400;
445 const int minHeight = 250;
447 gPrefs->Read(wxT(
"/GUI/BrowserWidth"), &width, minWidth);
448 gPrefs->Read(wxT(
"/GUI/BrowserHeight"), &height, minHeight);
450 if (width < minWidth || width > wxSystemSettings::GetMetric(wxSYS_SCREEN_X))
452 if (height < minHeight || height > wxSystemSettings::GetMetric(wxSYS_SCREEN_Y))
455 SetMinSize(wxSize(minWidth, minHeight));
456 SetSize(wxDefaultPosition.x, wxDefaultPosition.y, width, height, wxSIZE_AUTO);
476 EndModal(wxID_CANCEL);
478 auto parent = GetParent();
480 gPrefs->Write(wxT(
"/GUI/BrowserWidth"), GetSize().GetX());
481 gPrefs->Write(wxT(
"/GUI/BrowserHeight"), GetSize().GetY());
485 auto grandparent = GetParent()->GetParent();
491 if(grandparent && grandparent->IsShown()) {
492 grandparent->Raise();
500 if (event.GetKeyCode() == WXK_ESCAPE)
512 if( (pWnd = FindWindowById( wxID_BACKWARD,
this )) != NULL )
514 pWnd->Enable(
mpHtml->HistoryCanBack());
516 if( (pWnd = FindWindowById( wxID_FORWARD,
this )) != NULL )
518 pWnd->Enable(
mpHtml->HistoryCanForward());
524 wxURI uri(link.
GET());
525 wxLaunchDefaultBrowser(uri.BuildURI());
538 wxString href = link.GetHref();
540 if( href.StartsWith( wxT(
"innerlink:help:")))
545 else if( href.StartsWith(wxT(
"innerlink:")) )
549 if( wxFileExists( FileName ) )
556 SetPage(
HelpText( href.Mid( 10 )));
560 else if( href.StartsWith(wxT(
"mailto:")) || href.StartsWith(wxT(
"file:")) )
565 else if( !href.StartsWith( wxT(
"http:")) && !href.StartsWith( wxT(
"https:")) )
567 HtmlWindow::OnLinkClicked( link );
574 wxFrame * pFrame = GetRelatedFrame();
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
ChoiceSetting GUIManualLocation
void OpenInDefaultBrowser(const URLString &link)
TranslatableString TitleText(const wxString &Key)
wxString HelpText(const wxString &Key)
Adds some event handling to an HtmlWindow.
void OnClose(wxCommandEvent &event)
void OnKeyDown(wxKeyEvent &event)
void OnBackward(wxCommandEvent &event)
void OnForward(wxCommandEvent &event)
bool Write(const wxString &value)
const EnumValueSymbol & Default() const
const wxString & Internal() const
virtual bool Flush(bool bCurrentOnly=false) wxOVERRIDE
static void ShowHelp(wxWindow *parent, const FilePath &localFileName, const URLString &remoteURL, bool bModal=false, bool alwaysDefaultBrowser=false)
static const wxString LocalHelpManDir
static void ShowInfoDialog(wxWindow *parent, const TranslatableString &dlogTitle, const TranslatableString &shortMsg, const wxString &message, const int xSize, const int ySize)
Displays cuttable information in a text ctrl, with an OK button.
static const wxString HelpHostname
static const wxString HelpServerHomeDir
static const wxString HelpServerManDir
static void ShowHtmlText(wxWindow *pParent, const TranslatableString &Title, const wxString &HtmlText, bool bIsFile=false, bool bModal=false)
const wxString & GET() const
Explicit conversion to wxString, meant to be ugly-looking and demanding of a comment why it's correct...
An HtmlWindow that handles linked clicked - usually the link will go to our own local copy of the man...
LinkingHtmlWindow(wxWindow *parent, wxWindowID id=-1, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxHW_SCROLLBAR_AUTO)
void OnLinkClicked(const wxHtmlLinkInfo &link) override
Derived from ShuttleGuiBase, an Audacity specific class for shuttling data to and from GUI.
Template generates different TaggedIdentifier classes that don't interconvert implicitly.
wxBitmap & Bitmap(int iIndex)
Holds a msgid for the translation catalog; may also bind format arguments.
wxString Translation() const
virtual ~HtmlTextHelpDialog()
HtmlTextHelpDialog(wxWindow *pParent, const TranslatableString &title)
void SetName(const TranslatableString &title)
FILES_API FilePath HtmlHelpDir()