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, 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 );
40 m_sdbSizerApply->Hide();
42}
43
44
46{
47 m_notebook->DeleteAllPages();
48}
49
50
51void DIALOG_BOOK_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& aEvent )
52{
53 m_frame->ExecuteRemoteCommand( aEvent.GetLinkInfo().GetHref().ToStdString().c_str() );
54}
55
56
58{
59 wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
60 wxTAB_TRAVERSAL );
61 wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
62
63 WX_HTML_REPORT_BOX* reporter = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition,
64 wxDefaultSize,
65 wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE );
66
67 sizer->Add( reporter, 1, wxEXPAND | wxALL, 5 );
68 panel->SetSizer( sizer );
69 panel->Layout();
70 m_notebook->AddPage( panel, aTitle );
71
72 reporter->SetUnits( m_frame->GetUserUnits() );
73 reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
74 wxHtmlLinkEventHandler( DIALOG_BOOK_REPORTER::OnErrorLinkClicked ),
75 nullptr, this );
76
77 return reporter;
78}
79
80
81wxPanel* DIALOG_BOOK_REPORTER::AddBlankPage( const wxString& aTitle )
82{
83 wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
84 wxTAB_TRAVERSAL );
85 m_notebook->AddPage( panel, aTitle );
86
87 return panel;
88}
89
90
92{
93 return m_notebook->GetPageCount();
94}
95
96
97void DIALOG_BOOK_REPORTER::OnClose( wxCloseEvent& aEvent )
98{
99 // Dialog is mode-less so let the parent know that it needs to be destroyed.
100 if( !IsModal() && !IsQuasiModal() )
101 {
102 wxCommandEvent* evt = new wxCommandEvent( EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, aEvent.GetId() );
103
104 evt->SetEventObject( this );
105 evt->SetString( GetName() );
106 wxWindow* parent = GetParent();
107
108 if( parent )
109 wxQueueEvent( parent, evt );
110 }
111
112 aEvent.Skip();
113}
114
115
116void DIALOG_BOOK_REPORTER::OnApply( wxCommandEvent& event )
117{
118 wxCloseEvent closeEvent;
119 closeEvent.SetId( m_sdbSizerApply->GetId() );
120 OnClose( closeEvent );
121}
122
123
124void DIALOG_BOOK_REPORTER::OnOK( wxCommandEvent& event )
125{
126 wxCloseEvent closeEvent;
127 closeEvent.SetId( m_sdbSizerOK->GetId() );
128 OnClose( closeEvent );
129}
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:93
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.
void SetUnits(EDA_UNITS aUnits)
wxDEFINE_EVENT(EDA_EVT_CLOSE_DIALOG_BOOK_REPORTER, wxCommandEvent)