29#include <wx/stattext.h>
30#include <wx/textctrl.h>
31#include <wx/html/htmlwin.h>
32#include <wx/settings.h>
33#include <wx/statusbr.h>
46#ifdef USE_ALPHA_MANUAL
66#if !wxCHECK_VERSION(3, 0, 0)
72#if !wxCHECK_VERSION(3, 0, 0)
89 const wxString &message,
90 const int xSize,
const int ySize)
94 wxDefaultPosition, wxDefaultSize,
95 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX );
100 S.StartVerticalLay(1);
102 S.AddTitle( shortMsg );
103 S.Style( wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_RICH2 |
104 wxTE_AUTO_URL | wxTE_NOHIDESEL | wxHSCROLL )
105 .AddTextWindow(message);
108 S.StartHorizontalLay(wxALIGN_CENTER_HORIZONTAL, 0);
110 S.EndHorizontalLay();
115 dlog.SetMinSize( wxSize(xSize/2, ySize/2) );
116 dlog.SetSize( wxSize(xSize, ySize) );
123 const wxString &HtmlText,
134 auto pFrame =
safenew wxFrame {
135 pParent, wxID_ANY, Title.
Translation(), wxDefaultPosition, wxDefaultSize,
136#if defined(__WXMAC__)
144 wxDEFAULT_FRAME_STYLE
149 pWnd =
safenew HtmlTextHelpDialog{ pFrame, Title };
154 pFrame->SetTransparent(0);
157 S.Style( wxNO_BORDER | wxTAB_TRAVERSAL )
161 S.StartHorizontalLay( wxEXPAND,
false );
163 S.Id( wxID_BACKWARD )
166 .ToolTip(
XO(
"Backwards" ) )
169 .AddButton(
XXO(
"<") );
173 .ToolTip(
XO(
"Forwards" ) )
176 .AddButton(
XXO(
">") );
178 S.EndHorizontalLay();
182 bIsFile ? wxSize(500, 400) : wxSize(480, 240),
183 wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
185 html->SetRelatedFrame( pFrame,
wxT(
"Help: %s") );
187 html->LoadFile( HtmlText );
189 html->SetPage( HtmlText);
191 S.Prop(1).Focus().Position( wxEXPAND )
194 S.Id( wxID_CANCEL ).AddButton(
XXO(
"Close"), wxALIGN_CENTER,
true );
202 wxIcon ic{ wxICON(AudacityLogo) };
207 pFrame->SetIcon( ic );
212 pWnd->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
214 pFrame->CreateStatusBar();
217 pFrame->SetSizeHints(pWnd->GetSize());
227 html->SetRelatedStatusBar( 0 );
237 bool alwaysDefaultBrowser)
240 wxString HelpMode =
wxT(
"Local");
243#ifdef EXPERIMENTAL_DA
244 gPrefs->
Read(
wxT(
"/GUI/Help"), &HelpMode, {
"FromInternet"} );
251 if( (HelpMode ==
wxT(
"Standard")) || (HelpMode ==
wxT(
"InBrowser")) )
263 if (localFileName.Find(
'#',
true) != wxNOT_FOUND)
264 HelpMode =
wxT(
"FromInternet");
269 if (localFileName.Find(
'#',
true) != wxNOT_FOUND)
270 localfile = localFileName.BeforeLast(
'#');
272 localfile = localFileName;
274 if( (HelpMode ==
wxT(
"FromInternet")) && !remoteURL.
empty() )
279 else if( localfile.empty() || !wxFileExists( localfile ))
281 if (remoteURL.
empty())
285 wxASSERT(!remoteURL.
empty());
289 Text.Replace(
wxT(
"*URL*"), remoteURL.
GET());
292 ShowHtmlText(parent,
XO(
"Help on the Internet"), Text,
false,
true);
300 else if( HelpMode ==
wxT(
"Local") || alwaysDefaultBrowser)
308 ShowHtmlText( parent, {}, localFileName,
true, bModal );
318 const wxString ReleaseSuffix = L
".html";
321 wxString webHelpPath;
322 wxString webHelpPage;
323 wxString releasePageName;
325 const auto &PageNameStr = PageName.
GET();
326 if (PageNameStr.Find(
'#',
true) != wxNOT_FOUND)
328 releasePageName = PageNameStr.BeforeLast(
'#');
329 anchor =
wxT(
"#") + PageNameStr.AfterLast(
'#');
333 releasePageName = PageName.
GET();
349 if (releasePageName == L
"Main_Page")
351 releasePageName = L
"index" + ReleaseSuffix + anchor;
355 else if (releasePageName == L
"Quick_Help")
358#ifdef EXPERIMENTAL_DA
359 releasePageName = L
"video" + ReleaseSuffix + anchor;
361 webHelpPath = L
"http://www.darkaudacity.com/";
363 releasePageName = L
"quick_help" + ReleaseSuffix + anchor;
370 else if (releasePageName.StartsWith(
"http" ) )
373 releasePageName += anchor;
380 releasePageName = releasePageName.Lower();
388 re.Compile(
wxT(
"%.."));
389 re.ReplaceAll(&releasePageName, (
wxT(
"_")));
391 re.Compile(
wxT(
"[^[:alnum:] . [:space:]]"));
392 re.ReplaceAll(&releasePageName, (
wxT(
"_")));
394 releasePageName.Replace(
wxT(
" "),
wxT(
"+"),
true);
396 re.Compile(
wxT(
"__+"));
397 re.ReplaceAll(&releasePageName, (
wxT(
"_")));
399 releasePageName.Replace(
wxT(
"_."),
wxT(
"."),
true);
401 releasePageName = releasePageName + ReleaseSuffix + anchor;
408#ifdef USE_ALPHA_MANUAL
409 webHelpPage = webHelpPath + PageName.
GET();
411 webHelpPage = webHelpPath + releasePageName;
414 wxLogMessage(
wxT(
"Help button pressed: PageName %s, releasePageName %s"),
415 PageName.
GET(), releasePageName);
416 wxLogMessage(
wxT(
"webHelpPage %s, localHelpPage %s"),
417 webHelpPage, localHelpPage);
430#include <wx/wxprec.h>
432#include <wx/mimetype.h>
433#include <wx/filename.h>
445 :
wxDialogWrapper{ pParent, ID,
title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER }
448 const int minWidth = 400;
449 const int minHeight = 250;
454 if (width < minWidth || width > wxSystemSettings::GetMetric(wxSYS_SCREEN_X))
456 if (height < minHeight || height > wxSystemSettings::GetMetric(wxSYS_SCREEN_Y))
459 SetMinSize(wxSize(minWidth, minHeight));
460 SetSize(wxDefaultPosition.x, wxDefaultPosition.y, width, height, wxSIZE_AUTO);
480 EndModal(wxID_CANCEL);
482 auto parent = GetParent();
489 auto grandparent = GetParent()->GetParent();
495 if(grandparent && grandparent->IsShown()) {
496 grandparent->Raise();
504 if (event.GetKeyCode() == WXK_ESCAPE)
516 if( (pWnd = FindWindowById( wxID_BACKWARD,
this )) != NULL )
518 pWnd->Enable(
mpHtml->HistoryCanBack());
520 if( (pWnd = FindWindowById( wxID_FORWARD,
this )) != NULL )
522 pWnd->Enable(
mpHtml->HistoryCanForward());
528 wxURI uri(link.
GET());
542 wxString href = link.GetHref();
544 if( href.StartsWith(
wxT(
"innerlink:help:")))
549 else if( href.StartsWith(
wxT(
"innerlink:")) )
553 if( wxFileExists( FileName ) )
560 SetPage(
HelpText( href.Mid( 10 )));
564 else if( href.StartsWith(
wxT(
"mailto:")) || href.StartsWith(
wxT(
"file:")) )
569 else if( !href.StartsWith(
wxT(
"http:")) && !href.StartsWith(
wxT(
"https:")) )
571 HtmlWindow::OnLinkClicked( link );
578 wxFrame * pFrame = GetRelatedFrame();
594 {
XO(
"Local") ,
XO(
"From Internet") , },
595 {
wxT(
"Local") ,
wxT(
"FromInternet") , }
Toolkit-neutral facade for basic user interface services.
EVT_BUTTON(wxID_NO, DependencyDialog::OnNo) EVT_BUTTON(wxID_YES
XXO("&Cut/Copy/Paste Toolbar")
void OpenInDefaultBrowser(const URLString &link)
ChoiceSetting GUIManualLocation
TranslatableString TitleText(const wxString &Key)
wxString HelpText(const wxString &Key)
audacity::BasicSettings * gPrefs
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
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)
virtual bool Flush() noexcept=0
virtual bool Write(const wxString &key, bool value)=0
virtual bool Read(const wxString &key, bool *value) const =0
void SetName(const TranslatableString &title)
bool OpenInDefaultBrowser(const wxString &url)
Open an URL in default browser.
FILES_API FilePath HtmlHelpDir()