2020-09-22 23:16:02 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2023-03-09 11:25:32 +00:00
|
|
|
* Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
|
2020-09-22 23:16:02 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2023-03-09 17:41:18 +00:00
|
|
|
#include <dialogs/dialog_book_reporter.h>
|
2022-09-03 18:29:02 +00:00
|
|
|
#include <widgets/wx_html_report_box.h>
|
2021-06-03 11:49:49 +00:00
|
|
|
#include <wx/wxhtml.h>
|
2020-09-22 23:16:02 +00:00
|
|
|
|
2023-03-09 11:25:32 +00:00
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
wxDEFINE_EVENT( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxCommandEvent );
|
2020-09-22 23:16:02 +00:00
|
|
|
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
DIALOG_BOOK_REPORTER::DIALOG_BOOK_REPORTER( KIWAY_PLAYER* aParent, const wxString& aName,
|
|
|
|
const wxString& aTitle ) :
|
|
|
|
DIALOG_BOOK_REPORTER_BASE( aParent, wxID_ANY, aTitle ),
|
|
|
|
m_frame( aParent )
|
|
|
|
{
|
|
|
|
SetName( aName );
|
2021-11-16 19:39:58 +00:00
|
|
|
SetupStandardButtons();
|
2023-03-13 16:03:48 +00:00
|
|
|
finishDialogSettings();
|
2020-09-22 23:16:02 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-09 17:41:18 +00:00
|
|
|
void DIALOG_BOOK_REPORTER::DeleteAllPages()
|
2020-09-22 23:16:02 +00:00
|
|
|
{
|
|
|
|
m_notebook->DeleteAllPages();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-09 17:41:18 +00:00
|
|
|
void DIALOG_BOOK_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& aEvent )
|
2020-10-16 23:15:44 +00:00
|
|
|
{
|
2023-03-09 17:41:18 +00:00
|
|
|
m_frame->ExecuteRemoteCommand( aEvent.GetLinkInfo().GetHref().ToStdString().c_str() );
|
2020-10-16 23:15:44 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2023-03-09 17:41:18 +00:00
|
|
|
WX_HTML_REPORT_BOX* DIALOG_BOOK_REPORTER::AddHTMLPage( const wxString& aTitle )
|
2020-09-22 23:16:02 +00:00
|
|
|
{
|
|
|
|
wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxTAB_TRAVERSAL );
|
|
|
|
wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
|
|
|
|
|
|
|
|
WX_HTML_REPORT_BOX* reporter = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
2021-07-19 23:56:05 +00:00
|
|
|
wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE );
|
2020-09-22 23:16:02 +00:00
|
|
|
|
2021-07-19 23:56:05 +00:00
|
|
|
sizer->Add( reporter, 1, wxEXPAND | wxALL, 5 );
|
2020-09-22 23:16:02 +00:00
|
|
|
panel->SetSizer( sizer );
|
|
|
|
panel->Layout();
|
|
|
|
m_notebook->AddPage( panel, aTitle );
|
|
|
|
|
|
|
|
reporter->SetUnits( m_frame->GetUserUnits() );
|
2021-07-19 23:56:05 +00:00
|
|
|
reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
|
2023-03-09 17:41:18 +00:00
|
|
|
wxHtmlLinkEventHandler( DIALOG_BOOK_REPORTER::OnErrorLinkClicked ),
|
2021-07-19 23:56:05 +00:00
|
|
|
nullptr, this );
|
2020-09-22 23:16:02 +00:00
|
|
|
|
|
|
|
return reporter;
|
|
|
|
}
|
|
|
|
|
2021-08-17 14:37:33 +00:00
|
|
|
|
2023-03-09 17:41:18 +00:00
|
|
|
wxPanel* DIALOG_BOOK_REPORTER::AddBlankPage( const wxString& aTitle )
|
|
|
|
{
|
|
|
|
wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
|
|
|
wxTAB_TRAVERSAL );
|
|
|
|
m_notebook->AddPage( panel, aTitle );
|
|
|
|
|
|
|
|
return panel;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
int DIALOG_BOOK_REPORTER::GetPageCount() const
|
2021-08-17 14:37:33 +00:00
|
|
|
{
|
|
|
|
return m_notebook->GetPageCount();
|
|
|
|
}
|
|
|
|
|
2023-03-13 16:03:48 +00:00
|
|
|
|
|
|
|
void DIALOG_BOOK_REPORTER::OnClose( wxCloseEvent& aEvent )
|
|
|
|
{
|
|
|
|
// Dialog is mode-less so let the parent know that it needs to be destroyed.
|
|
|
|
if( !IsModal() && !IsQuasiModal() )
|
|
|
|
{
|
|
|
|
wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxID_ANY );
|
|
|
|
|
|
|
|
evt->SetEventObject( this );
|
|
|
|
evt->SetString( GetName() );
|
|
|
|
wxWindow* parent = GetParent();
|
|
|
|
|
|
|
|
if( parent )
|
|
|
|
wxQueueEvent( parent, evt );
|
|
|
|
}
|
|
|
|
|
|
|
|
aEvent.Skip();
|
|
|
|
}
|