KiCad PCB EDA Suite
mocks_eeschema.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) 2019 KiCad Developers, see CHANGELOG.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 
24 #include <kiface_i.h>
25 #include <pgm_base.h>
26 #include <transform.h>
27 
28 #include <sch_edit_frame.h>
30 
31 // The main sheet of the project
33 
34 // a transform matrix, to display components in lib editor
36 
37 static struct IFACE : public KIFACE_I
38 {
39  // Of course all are overloads, implementations of the KIFACE.
40 
41  IFACE( const char* aName, KIWAY::FACE_T aType ) : KIFACE_I( aName, aType )
42  {
43  }
44 
45  bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override
46  {
47  return true;
48  }
49 
50  void OnKifaceEnd() override
51  {
52  }
53 
54  wxWindow* CreateWindow(
55  wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
56  {
57  assert( false );
58  return nullptr;
59  }
60 
72  void* IfaceOrAddress( int aDataId ) override
73  {
74  return NULL;
75  }
76 } kiface( "mock_eeschema", KIWAY::FACE_SCH );
77 
78 static struct PGM_MOCK_EESCHEMA_FRAME : public PGM_BASE
79 {
80  bool OnPgmInit();
81 
82  void OnPgmExit()
83  {
84  Kiway.OnKiwayEnd();
85 
86  // Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
87  // earlier than wxApp and earlier than static destruction would.
89  }
90 
91  void MacOpenFile( const wxString& aFileName ) override
92  {
93  wxFileName filename( aFileName );
94 
95  if( filename.FileExists() )
96  {
97 #if 0
98  // this pulls in EDA_DRAW_FRAME type info, which we don't want in
99  // the single_top link image.
100  KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
101 #else
102  KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
103 #endif
104 
105  if( frame )
106  frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
107  }
108  }
109 } program;
110 
112 {
113  return program;
114 }
115 
116 
118 {
119  return kiface;
120 }
virtual bool OpenProjectFiles(const std::vector< wxString > &aFileList, int aCtl=0)
Function OpenProjectFiles is abstract, and opens a project or set of files given by aFileList.
Definition: kiway_player.h:118
KIFACE_I is a KIFACE (I)mplementation, with some features useful for DSOs which implement a KIFACE.
Definition: kiface_i.h:37
KIWAY_PLAYER is a wxFrame capable of the OpenProjectFiles function, meaning it can load a portion of ...
Definition: kiway_player.h:59
PGM_MOCK_EESCHEMA_FRAME program
bool OnKifaceStart(PGM_BASE *aProgram, int aCtlBits) override
Function OnKifaceStart is called just once shortly after the DSO is loaded.
void MacOpenFile(const wxString &aFileName) override
Function MacOpenFile is specific to MacOSX (not used under Linux or Windows).
PGM_BASE keeps program (whole process) data for KiCad programs.
Definition: pgm_base.h:137
VTBL_ENTRY wxApp & App()
Function App returns a bare naked wxApp, which may come from wxPython, SINGLE_TOP,...
Definition: pgm_base.cpp:138
void Destroy()
Definition: pgm_base.cpp:127
wxWindow * CreateWindow(wxWindow *aParent, int aClassId, KIWAY *aKiway, int aCtlBits=0) override
Function CreateWindow creates a wxWindow for the current project.
void OnKifaceEnd() override
Function OnKifaceEnd is called just once just before the DSO is to be unloaded.
IFACE(const char *aName, KIWAY::FACE_T aType)
void OnKiwayEnd()
Definition: kiway.cpp:537
SCH_SHEET * g_RootSheet
for transforming drawing coordinates for a wxDC device context.
Definition: transform.h:45
#define NULL
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
void * IfaceOrAddress(int aDataId) override
Function IfaceOrAddress return a pointer to the requested object.
FACE_T
Known KIFACE implementations.
Definition: kiway.h:279
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:215
eeschema DSO
Definition: kiway.h:281
see class PGM_BASE
IFACE KIFACE_I kiface("mock_eeschema", KIWAY::FACE_SCH)
PGM_BASE & Pgm()
The global Program "get" accessor.
TRANSFORM DefaultTransform
KIFACE_I & Kiface()
Global KIFACE_I "get" accessor.
KIWAY Kiway