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>
61#if !wxCHECK_VERSION(3, 0, 0)
67#if !wxCHECK_VERSION(3, 0, 0)
84 const wxString &message,
85 const int xSize,
const int ySize)
89 wxDefaultPosition, wxDefaultSize,
90 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxMAXIMIZE_BOX );
95 S.StartVerticalLay(1);
97 S.AddTitle( shortMsg );
98 S.Style( wxTE_MULTILINE | wxTE_READONLY | wxTE_RICH | wxTE_RICH2 |
99 wxTE_AUTO_URL | wxTE_NOHIDESEL | wxHSCROLL | wxTE_PROCESS_ENTER)
100 .AddTextWindow(message)
101 ->Bind(wxEVT_TEXT_ENTER, [&dlog](
auto&) {
102 dlog.EndModal(wxID_OK);
106 S.StartHorizontalLay(wxALIGN_CENTER_HORIZONTAL, 0);
108 S.EndHorizontalLay();
113 dlog.SetMinSize( wxSize(xSize/2, ySize/2) );
114 dlog.SetSize( wxSize(xSize, ySize) );
121 const wxString &HtmlText,
132 auto pFrame =
safenew wxFrame {
133 pParent, wxID_ANY, Title.Translation(), wxDefaultPosition, wxDefaultSize,
134#if defined(__WXMAC__)
142 wxDEFAULT_FRAME_STYLE
147 pWnd =
safenew HtmlTextHelpDialog{ pFrame, Title };
152 pFrame->SetTransparent(0);
155 S.Style( wxNO_BORDER | wxTAB_TRAVERSAL )
159 S.StartHorizontalLay( wxEXPAND,
false );
161 S.Id( wxID_BACKWARD )
164 .ToolTip(
XO(
"Backwards" ) )
167 .AddButton(
XXO(
"<") );
171 .ToolTip(
XO(
"Forwards" ) )
174 .AddButton(
XXO(
">") );
176 S.EndHorizontalLay();
180 bIsFile ? wxSize(500, 400) : wxSize(480, 240),
181 wxHW_SCROLLBAR_AUTO);
183 html->SetRelatedFrame( pFrame,
wxT(
"Help: %s") );
185 html->LoadFile( HtmlText );
187 html->SetPage( HtmlText);
189 S.Prop(1).Focus().Position( wxEXPAND )
192 S.Id( wxID_CANCEL ).AddButton(
XXO(
"Close"), wxALIGN_CENTER,
true );
200 wxIcon ic{ wxICON(AudacityLogo) };
205 pFrame->SetIcon( ic );
210 pWnd->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
212 pFrame->CreateStatusBar();
215 pFrame->SetSizeHints(pWnd->GetSize());
217 pFrame->
SetName(Title.Translation());
225 html->SetRelatedStatusBar( 0 );
235 bool alwaysDefaultBrowser)
238 wxString HelpMode =
wxT(
"Local");
241 gPrefs->
Read(
wxT(
"/GUI/Help"), &HelpMode, {
"FromInternet"} );
245 if( (HelpMode ==
wxT(
"Standard")) || (HelpMode ==
wxT(
"InBrowser")) )
257 if (localFileName.Find(
'#',
true) != wxNOT_FOUND)
258 HelpMode =
wxT(
"FromInternet");
263 if (localFileName.Find(
'#',
true) != wxNOT_FOUND)
264 localfile = localFileName.BeforeLast(
'#');
266 localfile = localFileName;
268 if( (HelpMode ==
wxT(
"FromInternet")) && !remoteURL.
empty() )
273 else if( localfile.empty() || !wxFileExists( localfile ))
275 if (remoteURL.
empty())
279 wxASSERT(!remoteURL.
empty());
283 Text.Replace(
wxT(
"*URL*"), remoteURL.
GET());
286 ShowHtmlText(parent,
XO(
"Help on the Internet"), Text,
false,
true);
294 else if( HelpMode ==
wxT(
"Local") || alwaysDefaultBrowser)
302 ShowHtmlText( parent, {}, localFileName,
true, bModal );
312 const wxString ReleaseSuffix = L
".html";
315 wxString webHelpPath;
316 wxString webHelpPage;
317 wxString releasePageName;
319 const auto &PageNameStr = PageName.
GET();
320 if (PageNameStr.Find(
'#',
true) != wxNOT_FOUND)
322 releasePageName = PageNameStr.BeforeLast(
'#');
323 anchor =
wxT(
"#") + PageNameStr.AfterLast(
'#');
327 releasePageName = PageName.
GET();
343 if (releasePageName == L
"Main_Page")
345 releasePageName = L
"index" + ReleaseSuffix + anchor;
349 else if (releasePageName == L
"Quick_Help")
351 releasePageName = L
"quick_help" + ReleaseSuffix + anchor;
357 else if (releasePageName.StartsWith(
"http" ) )
360 releasePageName += anchor;
367 releasePageName = releasePageName.Lower();
375 re.Compile(
wxT(
"%.."));
376 re.ReplaceAll(&releasePageName, (
wxT(
"_")));
378 re.Compile(
wxT(
"[^[:alnum:] . [:space:]]"));
379 re.ReplaceAll(&releasePageName, (
wxT(
"_")));
381 releasePageName.Replace(
wxT(
" "),
wxT(
"+"),
true);
383 re.Compile(
wxT(
"__+"));
384 re.ReplaceAll(&releasePageName, (
wxT(
"_")));
386 releasePageName.Replace(
wxT(
"_."),
wxT(
"."),
true);
388 releasePageName = releasePageName + ReleaseSuffix + anchor;
395 webHelpPage = webHelpPath + releasePageName;
398 wxLogMessage(
wxT(
"Help button pressed: PageName %s, releasePageName %s"),
399 PageName.
GET(), releasePageName);
400 wxLogMessage(
wxT(
"webHelpPage %s, localHelpPage %s"),
401 webHelpPage, localHelpPage);
414#include <wx/wxprec.h>
416#include <wx/mimetype.h>
417#include <wx/filename.h>
429 :
wxDialogWrapper{ pParent, ID,
title, wxDefaultPosition, wxDefaultSize, wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER }
432 const int minWidth = 400;
433 const int minHeight = 250;
438 if (width < minWidth || width > wxSystemSettings::GetMetric(wxSYS_SCREEN_X))
440 if (height < minHeight || height > wxSystemSettings::GetMetric(wxSYS_SCREEN_Y))
443 SetMinSize(wxSize(minWidth, minHeight));
444 SetSize(wxDefaultPosition.x, wxDefaultPosition.y, width, height, wxSIZE_AUTO);
464 EndModal(wxID_CANCEL);
466 auto parent = GetParent();
473 auto grandparent = GetParent()->GetParent();
479 if(grandparent && grandparent->IsShown()) {
480 grandparent->Raise();
488 if (event.GetKeyCode() == WXK_ESCAPE)
500 if( (pWnd = FindWindowById( wxID_BACKWARD,
this )) != NULL )
502 pWnd->Enable(
mpHtml->HistoryCanBack());
504 if( (pWnd = FindWindowById( wxID_FORWARD,
this )) != NULL )
506 pWnd->Enable(
mpHtml->HistoryCanForward());
512 wxURI uri(link.
GET());
526 wxString href = link.GetHref();
528 if( href.StartsWith(
wxT(
"innerlink:help:")))
533 else if( href.StartsWith(
wxT(
"innerlink:")) )
537 if( wxFileExists( FileName ) )
544 SetPage(
HelpText( href.Mid( 10 )));
548 else if( href.StartsWith(
wxT(
"mailto:")) || href.StartsWith(
wxT(
"file:")) )
553 else if( !href.StartsWith(
wxT(
"http:")) && !href.StartsWith(
wxT(
"https:")) )
555 HtmlWindow::OnLinkClicked( link );
562 wxFrame * pFrame = GetRelatedFrame();
578 {
XO(
"Local") ,
XO(
"From Internet") , },
579 {
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()