KiCad PCB EDA Suite
Loading...
Searching...
No Matches
pcb_calculator.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) 2015 jean-pierre.charras
5 * Copyright (C) 2015-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 3
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 along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#include <pgm_base.h>
22#include <kiface_base.h>
24
27
28// Pcb_calculator data file extension:
29const wxString PcbCalcDataFileExt( wxT( "pcbcalc" ) );
30
31
32namespace PCBCALC {
33
34static struct IFACE : public KIFACE_BASE
35{
36 // Of course all are virtual overloads, implementations of the KIFACE.
37
38 IFACE( const char* aName, KIWAY::FACE_T aType ) :
39 KIFACE_BASE( aName, aType )
40 {}
41
42 bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway ) override;
43
44 void OnKifaceEnd() override;
45
46 wxWindow* CreateKiWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway,
47 int aCtlBits = 0 ) override
48 {
49 return new PCB_CALCULATOR_FRAME( aKiway, aParent );
50 }
51
62 void* IfaceOrAddress( int aDataId ) override
63 {
64 return nullptr;
65 }
66
67} kiface( "pcb_calculator", KIWAY::FACE_PCB_CALCULATOR );
68
69
70} // namespace
71
72
73using namespace PCBCALC;
74
75
77
78
79// KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
80// KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
81KIFACE_API KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
82{
83 return &kiface;
84}
85
86
87bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits, KIWAY* aKiway )
88{
91 start_common( aCtlBits );
92
93 return true;
94}
95
96
98{
99 end_common();
100}
A KIFACE implementation.
Definition: kiface_base.h:39
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition: kiface_base.h:97
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_base.cpp:42
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_base.h:95
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_base.cpp:32
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:284
FACE_T
Known KIFACE implementations.
Definition: kiway.h:290
@ FACE_PCB_CALCULATOR
Definition: kiway.h:296
PCB calculator the main frame.
Container for data for KiCad programs.
Definition: pgm_base.h:102
virtual SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:142
T * RegisterSettings(T *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
#define KIFACE_API
Definition: import_export.h:61
#define KIFACE_GETTER
Definition: kiway.h:110
PCBCALC::IFACE KIFACE_BASE kiface("pcb_calculator", KIWAY::FACE_PCB_CALCULATOR)
KIFACE_BASE & Kiface()
Global KIFACE_BASE "get" accessor.
const wxString PcbCalcDataFileExt(wxT("pcbcalc"))
see class PGM_BASE
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
Implement a participant in the KIWAY alchemy.
Definition: kiway.h:151
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits, KIWAY *aKiway) override
Typically start_common() is called from here.
wxWindow * CreateKiWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Create a wxWindow for the current project.
IFACE(const char *aName, KIWAY::FACE_T aType)
void * IfaceOrAddress(int aDataId) override
Return a pointer to the requested object.
void OnKifaceEnd() override
Called just once just before the DSO is to be unloaded.