Bug1407, better fix: but Timer Record Help dialog is now modal

This commit is contained in:
Paul Licameli 2016-06-20 14:02:44 -04:00
parent 186873e3cc
commit bb3b5a27be
4 changed files with 47 additions and 32 deletions

View File

@ -41,10 +41,11 @@ private:
};
// Helper class to make browser "simulate" a modal dialog
class HtmlTextHelpDialog final : public BrowserFrame
class HtmlTextHelpDialog final : public BrowserDialog
{
public:
HtmlTextHelpDialog() : BrowserFrame()
HtmlTextHelpDialog(wxWindow *pParent, const wxString &title)
: BrowserDialog{ pParent, title }
{
#if !wxCHECK_VERSION(3, 0, 0)
MakeModal( true );

View File

@ -100,13 +100,8 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
{
LinkingHtmlWindow *html;
BrowserFrame * pWnd;
if( bModal )
pWnd = new HtmlTextHelpDialog();
else
pWnd = new BrowserFrame();
pWnd->Create(pParent, wxID_ANY, Title, wxDefaultPosition, wxDefaultSize,
auto pFrame = safenew wxFrame {
pParent, wxID_ANY, Title, wxDefaultPosition, wxDefaultSize,
#if defined(__WXMAC__)
// On OSX, the html frame can go behind the help dialog and if the help
// html frame is modal, you can't get back to it. Pressing escape gets
@ -115,9 +110,15 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
// but acceptable in this case.
wxSTAY_ON_TOP |
#endif
wxDEFAULT_FRAME_STYLE);
wxDEFAULT_FRAME_STYLE
};
BrowserDialog * pWnd;
if( bModal )
pWnd = safenew HtmlTextHelpDialog{ pFrame, Title };
else
pWnd = safenew BrowserDialog{ pFrame, Title };
pWnd->SetName(pWnd->GetTitle());
ShuttleGui S( pWnd, eIsCreating );
S.SetStyle( wxNO_BORDER | wxTAB_TRAVERSAL );
@ -141,7 +142,7 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
bIsFile ? wxSize(500, 400) : wxSize(480, 240),
wxHW_SCROLLBAR_AUTO | wxSUNKEN_BORDER);
html->SetRelatedFrame( pWnd, wxT("Help: %s") );
html->SetRelatedFrame( pFrame, wxT("Help: %s") );
if( bIsFile )
html->LoadFile( HtmlText );
else
@ -162,18 +163,22 @@ void HelpSystem::ShowHtmlText(wxWindow *pParent,
wxIcon ic{};
ic.CopyFromBitmap(theTheme.Bitmap(bmpAudacityLogo48x48));
#endif
pWnd->SetIcon( ic );
pFrame->SetIcon( ic );
// -- END of ICON stuff -----
pWnd->mpHtml = html;
pWnd->SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
pWnd->CreateStatusBar();
pWnd->Centre();
pWnd->Layout();
pWnd->Fit();
pWnd->SetSizeHints(pWnd->GetSize());
pWnd->Show( true );
pFrame->CreateStatusBar();
pFrame->Centre();
pFrame->Layout();
pFrame->Fit();
pFrame->SetSizeHints(pWnd->GetSize());
pFrame->SetName(Title);
pFrame->Show( true );
pWnd->ShowModal();
html->SetRelatedStatusBar( 0 );
html->SetFocus();

View File

@ -28,32 +28,38 @@
#include "ErrorDialog.h"
#include "HelpSystem.h"
BEGIN_EVENT_TABLE(BrowserFrame, wxFrame)
EVT_BUTTON(wxID_FORWARD, BrowserFrame::OnForward)
EVT_BUTTON(wxID_BACKWARD, BrowserFrame::OnBackward)
EVT_BUTTON(wxID_CANCEL, BrowserFrame::OnClose)
EVT_KEY_DOWN(BrowserFrame::OnKeyDown)
BEGIN_EVENT_TABLE(BrowserDialog, wxDialog)
EVT_BUTTON(wxID_FORWARD, BrowserDialog::OnForward)
EVT_BUTTON(wxID_BACKWARD, BrowserDialog::OnBackward)
EVT_BUTTON(wxID_CANCEL, BrowserDialog::OnClose)
EVT_KEY_DOWN(BrowserDialog::OnKeyDown)
END_EVENT_TABLE()
void BrowserFrame::OnForward(wxCommandEvent & WXUNUSED(event))
BrowserDialog::BrowserDialog(wxWindow *pParent, const wxString &title)
: wxDialog{ pParent, ID, title }
{
}
void BrowserDialog::OnForward(wxCommandEvent & WXUNUSED(event))
{
mpHtml->HistoryForward();
UpdateButtons();
}
void BrowserFrame::OnBackward(wxCommandEvent & WXUNUSED(event))
void BrowserDialog::OnBackward(wxCommandEvent & WXUNUSED(event))
{
mpHtml->HistoryBack();
UpdateButtons();
}
void BrowserFrame::OnClose(wxCommandEvent & WXUNUSED(event))
void BrowserDialog::OnClose(wxCommandEvent & WXUNUSED(event))
{
Close();
EndModal(wxID_CANCEL);
}
void BrowserFrame::OnKeyDown(wxKeyEvent & event)
void BrowserDialog::OnKeyDown(wxKeyEvent & event)
{
bool bSkip = true;
if (event.GetKeyCode() == WXK_ESCAPE)
@ -65,7 +71,7 @@ void BrowserFrame::OnKeyDown(wxKeyEvent & event)
}
void BrowserFrame::UpdateButtons()
void BrowserDialog::UpdateButtons()
{
wxWindow * pWnd;
if( (pWnd = FindWindowById( wxID_BACKWARD, this )) != NULL )
@ -124,7 +130,8 @@ void LinkingHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link)
OpenInDefaultBrowser(link);
return;
}
BrowserFrame * pDlg = wxDynamicCast( GetRelatedFrame(), BrowserFrame );
BrowserDialog * pDlg = wxDynamicCast(
GetRelatedFrame()->FindWindow(BrowserDialog::ID), BrowserDialog );
if( pDlg )
{
pDlg->UpdateButtons();

View File

@ -36,9 +36,11 @@ class AUDACITY_DLL_API LinkingHtmlWindow final : public HtmlWindow
};
class BrowserFrame /* not final */ : public wxFrame
class BrowserDialog /* not final */ : public wxDialog
{
public:
enum { ID = 0 };
BrowserDialog(wxWindow *pParent, const wxString &title);
void OnForward(wxCommandEvent & event);
void OnBackward(wxCommandEvent & event);