KiCad PCB EDA Suite
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 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 #include <fctsys.h>
21 #include <pgm_base.h>
22 #include <kiface_i.h>
23 #include <confirm.h>
24 #include <gestfich.h>
26 
27 #include <wx/wx.h>
28 
31 #include <pcb_calculator.h>
32 
33 #include <bitmaps.h>
34 #include <build_version.h>
35 
36 // Pcb_calculator data file extension:
37 const wxString PcbCalcDataFileExt( wxT("pcbcalc") );
38 
39 
40 // PCB_CALCULATOR_APP
41 
42 
43 namespace PCBCALC {
44 
45 static struct IFACE : public KIFACE_I
46 {
47  // Of course all are virtual overloads, implementations of the KIFACE.
48 
49  IFACE( const char* aName, KIWAY::FACE_T aType ) :
50  KIFACE_I( aName, aType )
51  {}
52 
53  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
54 
55  void OnKifaceEnd() override;
56 
57  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
58  {
59  return new PCB_CALCULATOR_FRAME( aKiway, aParent );
60  }
61 
73  void* IfaceOrAddress( int aDataId ) override
74  {
75  return NULL;
76  }
77 
78 } kiface( "pcb_calculator", KIWAY::FACE_PCB_CALCULATOR );
79 
80 } // namespace
81 
82 using namespace PCBCALC;
83 
84 static PGM_BASE* process;
85 
86 KIFACE_I& Kiface() { return kiface; }
87 
88 
89 // KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
90 // KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
91 MY_API( KIFACE* ) KIFACE_GETTER( int* aKIFACEversion, int aKiwayVersion, PGM_BASE* aProgram )
92 {
94  return &kiface;
95 }
96 
97 
99 {
100  wxASSERT( process ); // KIFACE_GETTER has already been called.
101  return *process;
102 }
103 
104 
105 bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
106 {
109  start_common( aCtlBits );
110 
111  return true;
112 }
113 
114 
116 {
117  end_common();
118 }
KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE.
Definition: kiface_i.h:37
void * IfaceOrAddress(int aDataId) override
Function IfaceOrAddress return a pointer to the requested object.
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:89
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Function CreateWindow creates a wxWindow for the current project.
VTBL_ENTRY SETTINGS_MANAGER & GetSettingsManager() const
Definition: pgm_base.h:175
This file is part of the common library TODO brief description.
const wxString PcbCalcDataFileExt(wxT("pcbcalc"))
This file is part of the common library.
PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:137
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
IFACE(const char *aName, KIWAY::FACE_T aType)
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_i.h:103
#define NULL
void end_common()
Common things to do for a top program module, during OnKifaceEnd();.
Definition: kiface_i.cpp:99
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Function OnKifaceStart is called just once shortly after the DSO is loaded.
void OnKifaceEnd() override
Function OnKifaceEnd is called just once just before the DSO is to be unloaded.
MY_API(KIFACE *) KIFACE_GETTER(int *aKIFACEversion
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
#define KIFACE_GETTER
Definition: kiway.h:112
FACE_T
Known KIFACE implementations.
Definition: kiway.h:279
JSON_SETTINGS * RegisterSettings(JSON_SETTINGS *aSettings, bool aLoadNow=true)
Takes ownership of the pointer passed in.
see class PGM_BASE
KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:150
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition: kiface_i.h:105
PGM_BASE & Pgm()
The global Program "get" accessor.
static PGM_BASE * process
int aKiwayVersion
int PGM_BASE * aProgram
PCBCALC::IFACE KIFACE_I kiface("pcb_calculator", KIWAY::FACE_PCB_CALCULATOR)