KiCad PCB EDA Suite
bitmap2cmp_main.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) 1992-2010 jean-pierre.charras
5  * Copyright (C) 1992-2019 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 <bitmap2cmp_gui.h>
26 #include <bitmap2cmp_settings.h>
27 #include <kiface_i.h>
28 #include <kiway.h>
29 #include <pgm_base.h>
31 
32 
33 //-----<KIFACE>-----------------------------------------------------------------
34 
35 namespace BMP2CMP {
36 
37 static struct IFACE : public KIFACE_I
38 {
39  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override;
40 
41  wxWindow* CreateWindow( wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
42  {
44  Pgm().GetSettingsManager().RegisterSettings( KifaceSettings() );
45  return new BM2CMP_FRAME( aKiway, aParent );
46  }
47 
59  void* IfaceOrAddress( int aDataId ) override
60  {
61  return NULL;
62  }
63 
64  IFACE( const char* aDSOname, KIWAY::FACE_T aType ) :
65  KIFACE_I( aDSOname, aType )
66  {}
67 
68 } kiface( "BMP2CMP", KIWAY::FACE_BMP2CMP );
69 
70 } // namespace BMP2CMP
71 
72 using namespace BMP2CMP;
73 
74 static PGM_BASE* process;
75 
77 {
78  return kiface;
79 }
80 
81 
82 // KIFACE_GETTER's actual spelling is a substitution macro found in kiway.h.
83 // KIFACE_GETTER will not have name mangling due to declaration in kiway.h.
84 KIFACE* KIFACE_GETTER( int* aKIFACEversion, int aKIWAYversion, PGM_BASE* aProgram )
85 {
87  return &kiface;
88 }
89 
90 
91 #if defined(BUILD_KIWAY_DLLS)
92 PGM_BASE& Pgm()
93 {
94  wxASSERT( process ); // KIFACE_GETTER has already been called.
95  return *process;
96 }
97 #endif
98 
99 
100 bool IFACE::OnKifaceStart( PGM_BASE* aProgram, int aCtlBits )
101 {
102  return start_common( aCtlBits );
103 }
KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE.
Definition: kiface_i.h:37
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:104
bool start_common(int aCtlBits)
Common things to do for a top program module, during OnKifaceStart().
Definition: kiface_i.cpp:89
PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:137
APP_SETTINGS_BASE * KifaceSettings() const
Definition: kiface_i.h:103
KIFACE * KIFACE_GETTER(int *aKIFACEversion, int aKIWAYversion, PGM_BASE *aProgram)
No name mangling. Each KIFACE (DSO/DLL) will implement this once.
void * IfaceOrAddress(int aDataId) override
Function IfaceOrAddress return a pointer to the requested object.
#define NULL
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Function CreateWindow creates a wxWindow for the current project.
static PGM_BASE * process
KIWAY is a minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the s...
Definition: kiway.h:273
int PGM_BASE * aProgram
Definition: cvpcb/cvpcb.cpp:97
IFACE(const char *aDSOname, KIWAY::FACE_T aType)
FACE_T
Known KIFACE implementations.
Definition: kiway.h:279
see class PGM_BASE
KIFACE is used by a participant in the KIWAY alchemy.
Definition: kiway.h:150
int aKIWAYversion
Definition: cvpcb/cvpcb.cpp:96
void InitSettings(APP_SETTINGS_BASE *aSettings)
Definition: kiface_i.h:105
BMP2CMP::IFACE KIFACE_I kiface("BMP2CMP", KIWAY::FACE_BMP2CMP)
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Function OnKifaceStart is called just once shortly after the DSO is loaded.