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/event.h>
27#include <kiway_player.h>
28
29
30wxDEFINE_EVENT( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxCommandEvent );
31
32
34 const wxString& aTitle ) :
35 DIALOG_BOOK_REPORTER_BASE( aParent, wxID_ANY, aTitle ),
36 m_frame( aParent )
37{
38 SetName( aName );
41}
42
43
45{
46 m_notebook->DeleteAllPages();
47}
48
49
50void DIALOG_BOOK_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& aEvent )
51{
52 m_frame->ExecuteRemoteCommand( aEvent.GetLinkInfo().GetHref().ToStdString().c_str() );
53}
54
55
57{
58 wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
59 wxTAB_TRAVERSAL );
60 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
61
62 WX_HTML_REPORT_BOX* reporter = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition,
63 wxDefaultSize,
64 wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE );
65
66 sizer->Add( reporter, 1, wxEXPAND | wxALL, 5 );
67 panel->SetSizer( sizer );
68 panel->Layout();
69 m_notebook->AddPage( panel, aTitle );
70
71 reporter->SetUnits( m_frame->GetUserUnits() );
72 reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
73 wxHtmlLinkEventHandler( DIALOG_BOOK_REPORTER::OnErrorLinkClicked ),
74 nullptr, this );
75
76 return reporter;
77}
78
79
80wxPanel* DIALOG_BOOK_REPORTER::AddBlankPage( const wxString& aTitle )
81{
82 wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
83 wxTAB_TRAVERSAL );
84 m_notebook->AddPage( panel, aTitle );
85
86 return panel;
87}
88
89
91{
92 return m_notebook->GetPageCount();
93}
94
95
96void DIALOG_BOOK_REPORTER::OnClose( wxCloseEvent& aEvent )
97{
98 // Dialog is mode-less so let the parent know that it needs to be destroyed.
99 if( !IsModal() && !IsQuasiModal() )
100 {
101 wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxID_ANY );
102
103 evt->SetEventObject( this );
104 evt->SetString( GetName() );
105 wxWindow* parent = GetParent();
106
107 if( parent )
108 wxQueueEvent( parent, evt );
109 }
110
111 aEvent.Skip();
112}
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:113
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:65
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:177
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)