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 The 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, see <https://www.gnu.org/licenses/>.
18 */
19
22#include <wx/event.h>
23#include <kiway_player.h>
24
25
26wxDEFINE_EVENT( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxCommandEvent );
27
28
30 const wxString& aTitle ) :
31 DIALOG_BOOK_REPORTER_BASE( aParent, wxID_ANY, aTitle ),
32 m_frame( aParent )
33{
34 SetName( aName );
36 m_sdbSizerApply->Hide();
38}
39
40
42{
43 m_notebook->DeleteAllPages();
44}
45
46
47void DIALOG_BOOK_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& aEvent )
48{
49 m_frame->ExecuteRemoteCommand( aEvent.GetLinkInfo().GetHref().ToStdString().c_str() );
50}
51
52
54{
55 wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
56 wxTAB_TRAVERSAL );
57 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
58
59 WX_HTML_REPORT_BOX* reporter = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition,
60 wxDefaultSize,
61 wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE );
62
63 sizer->Add( reporter, 1, wxEXPAND | wxALL, 5 );
64 panel->SetSizer( sizer );
65 panel->Layout();
66 m_notebook->AddPage( panel, aTitle );
67
68 reporter->SetUnits( m_frame->GetUserUnits() );
69 reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
70 wxHtmlLinkEventHandler( DIALOG_BOOK_REPORTER::OnErrorLinkClicked ),
71 nullptr, this );
72
73 return reporter;
74}
75
76
77wxPanel* DIALOG_BOOK_REPORTER::AddBlankPage( const wxString& aTitle )
78{
79 wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
80 wxTAB_TRAVERSAL );
81 m_notebook->AddPage( panel, aTitle );
82
83 return panel;
84}
85
86
88{
89 return m_notebook->GetPageCount();
90}
91
92
93void DIALOG_BOOK_REPORTER::OnClose( wxCloseEvent& aEvent )
94{
95 // Dialog is mode-less so let the parent know that it needs to be destroyed.
96 if( !IsModal() && !IsQuasiModal() )
97 {
98 wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, aEvent.GetId() );
99
100 evt->SetEventObject( this );
101 evt->SetString( GetName() );
102 wxWindow* parent = GetParent();
103
104 if( parent )
105 wxQueueEvent( parent, evt );
106 }
107
108 aEvent.Skip();
109}
110
111
112void DIALOG_BOOK_REPORTER::OnApply( wxCommandEvent& event )
113{
114 wxCloseEvent closeEvent;
115 closeEvent.SetId( m_sdbSizerApply->GetId() );
116 OnClose( closeEvent );
117}
118
119
120void DIALOG_BOOK_REPORTER::OnOK( wxCommandEvent& event )
121{
122 wxCloseEvent closeEvent;
123 closeEvent.SetId( m_sdbSizerOK->GetId() );
124 OnClose( closeEvent );
125}
DIALOG_BOOK_REPORTER_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxString &title=_("Report"), const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxDEFAULT_DIALOG_STYLE|wxRESIZE_BORDER)
void OnErrorLinkClicked(wxHtmlLinkEvent &aEvent)
void OnOK(wxCommandEvent &event) override
void OnClose(wxCloseEvent &aEvent) override
void OnApply(wxCommandEvent &event) 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:90
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.
A slimmed down version of WX_HTML_REPORT_PANEL.
wxDEFINE_EVENT(EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxCommandEvent)
IbisParser parser & reporter