KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dialog_book_reporter.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2020-2023 KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
26#include <wx/wxhtml.h>
27
28
29wxDEFINE_EVENT( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxCommandEvent );
30
31
33 const wxString& aTitle ) :
34 DIALOG_BOOK_REPORTER_BASE( aParent, wxID_ANY, aTitle ),
35 m_frame( aParent )
36{
37 SetName( aName );
40}
41
42
44{
45 m_notebook->DeleteAllPages();
46}
47
48
49void DIALOG_BOOK_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& aEvent )
50{
51 m_frame->ExecuteRemoteCommand( aEvent.GetLinkInfo().GetHref().ToStdString().c_str() );
52}
53
54
56{
57 wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
58 wxTAB_TRAVERSAL );
59 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
60
61 WX_HTML_REPORT_BOX* reporter = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition,
62 wxDefaultSize,
63 wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE );
64
65 sizer->Add( reporter, 1, wxEXPAND | wxALL, 5 );
66 panel->SetSizer( sizer );
67 panel->Layout();
68 m_notebook->AddPage( panel, aTitle );
69
70 reporter->SetUnits( m_frame->GetUserUnits() );
71 reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
72 wxHtmlLinkEventHandler( DIALOG_BOOK_REPORTER::OnErrorLinkClicked ),
73 nullptr, this );
74
75 return reporter;
76}
77
78
79wxPanel* DIALOG_BOOK_REPORTER::AddBlankPage( const wxString& aTitle )
80{
81 wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
82 wxTAB_TRAVERSAL );
83 m_notebook->AddPage( panel, aTitle );
84
85 return panel;
86}
87
88
90{
91 return m_notebook->GetPageCount();
92}
93
94
95void DIALOG_BOOK_REPORTER::OnClose( wxCloseEvent& aEvent )
96{
97 // Dialog is mode-less so let the parent know that it needs to be destroyed.
98 if( !IsModal() && !IsQuasiModal() )
99 {
100 wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxID_ANY );
101
102 evt->SetEventObject( this );
103 evt->SetString( GetName() );
104 wxWindow* parent = GetParent();
105
106 if( parent )
107 wxQueueEvent( parent, evt );
108 }
109
110 aEvent.Skip();
111}
Class DIALOG_BOOK_REPORTER_BASE.
void OnErrorLinkClicked(wxHtmlLinkEvent &aEvent)
void OnClose(wxCloseEvent &aEvent) override
DIALOG_BOOK_REPORTER(KIWAY_PLAYER *aParent, const wxString &aName, const wxString &aDialogTitle)
wxPanel * AddBlankPage(const wxString &aTitle)
WX_HTML_REPORT_BOX * AddHTMLPage(const wxString &aTitle)
void SetupStandardButtons(std::map< int, wxString > aLabels={})
bool IsQuasiModal() const
Definition: dialog_shim.h:107
void finishDialogSettings()
In all dialogs, we must call the same functions to fix minimal dlg size, the default position and per...
A wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of a KiCad project.
Definition: kiway_player.h:67
virtual void ExecuteRemoteCommand(const char *cmdline)
Execute a remote command sent via socket (to port KICAD_PCB_PORT_SERVICE_NUMBER, currently 4242).
Definition: kiway_player.h:179
EDA_UNITS GetUserUnits() const
A slimmed down version of WX_HTML_REPORT_PANEL.
void SetUnits(EDA_UNITS aUnits)
wxDEFINE_EVENT(EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxCommandEvent)