KiCad PCB EDA Suite
sim_workbook.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) 2021 MikoĊ‚aj Wielgus <wielgusmikolaj@gmail.com>
5  * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #include <sim/sim_workbook.h>
26 
27 
28 SIM_WORKBOOK::SIM_WORKBOOK() : wxAuiNotebook()
29 {
30  m_modified = false;
31 }
32 
33 
34 SIM_WORKBOOK::SIM_WORKBOOK( wxWindow* aParent, wxWindowID aId, const wxPoint& aPos, const wxSize&
35  aSize, long aStyle ) : wxAuiNotebook( aParent, aId, aPos, aSize, aStyle )
36 {
37  m_modified = false;
38 }
39 
40 
41 bool SIM_WORKBOOK::AddPage( wxWindow* page, const wxString& caption, bool select, const wxBitmap& bitmap )
42 {
43  bool res = wxAuiNotebook::AddPage( page, caption, select, bitmap );
44  setModified( res );
45  return res;
46 }
47 
48 
49 bool SIM_WORKBOOK::AddPage( wxWindow* page, const wxString& text, bool select, int imageId )
50 {
51  bool res = wxAuiNotebook::AddPage( page, text, select, imageId );
52  setModified( res );
53  return res;
54 }
55 
56 
58 {
59  bool res = wxAuiNotebook::DeleteAllPages();
60  setModified( res );
61  return res;
62 }
63 
64 
65 bool SIM_WORKBOOK::DeletePage( size_t page )
66 {
67  bool res = wxAuiNotebook::DeletePage( page );
68  setModified( res );
69  return res;
70 }
71 
72 
73 bool SIM_WORKBOOK::AddTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aTitle,
74  const wxString& aName, int aPoints, const double* aX, const double* aY,
75  SIM_PLOT_TYPE aType, const wxString& aParam )
76 {
77  bool res = aPlotPanel->addTrace( aTitle, aName, aPoints, aX, aY, aType, aParam );
78  setModified( res );
79  return res;
80 }
81 
82 
83 bool SIM_WORKBOOK::DeleteTrace( SIM_PLOT_PANEL* aPlotPanel, const wxString& aName )
84 {
85  bool res = aPlotPanel->deleteTrace( aName );
86  setModified( res );
87  return res;
88 }
89 
91 {
92  m_modified = false;
93  wxPostEvent( GetParent(), wxCommandEvent( EVT_WORKBOOK_CLR_MODIFIED ) );
94 }
95 
96 void SIM_WORKBOOK::setModified( bool value )
97 {
98  m_modified = value;
99  wxPostEvent( GetParent(), wxCommandEvent( EVT_WORKBOOK_MODIFIED ) );
100 }
101 
102 wxDEFINE_EVENT( EVT_WORKBOOK_MODIFIED, wxCommandEvent );
103 wxDEFINE_EVENT( EVT_WORKBOOK_CLR_MODIFIED, wxCommandEvent );
wxDEFINE_EVENT(EVT_WORKBOOK_MODIFIED, wxCommandEvent)
bool addTrace(const wxString &aTitle, const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aType, const wxString &aParam)
bool DeletePage(size_t aPage) override
bool AddPage(wxWindow *aPage, const wxString &aCaption, bool aSelect=false, const wxBitmap &aBitmap=wxNullBitmap)
void setModified(bool value=true)
Dirty bit, indicates something in the workbook has changed.
bool DeleteAllPages() override
bool AddTrace(SIM_PLOT_PANEL *aPlotPanel, const wxString &aTitle, const wxString &aName, int aPoints, const double *aX, const double *aY, SIM_PLOT_TYPE aType, const wxString &aParam)
bool DeleteTrace(SIM_PLOT_PANEL *aPlotPanel, const wxString &aName)
void ClrModified()
bool deleteTrace(const wxString &aName)
SIM_PLOT_TYPE
Definition: sim_types.h:46