2019-04-23 08:18:15 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2021-07-20 14:32:22 +00:00
|
|
|
* Copyright (C) 2019-2021 KiCad Developers, see AUTHORS.txt for contributors.
|
2019-04-23 08:18:15 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <kiface_i.h>
|
|
|
|
#include <pgm_base.h>
|
2019-06-25 23:39:58 +00:00
|
|
|
#include <transform.h>
|
2019-04-23 08:18:15 +00:00
|
|
|
|
|
|
|
#include <sch_edit_frame.h>
|
2020-01-13 01:44:19 +00:00
|
|
|
#include <settings/settings_manager.h>
|
2019-04-23 08:18:15 +00:00
|
|
|
|
2020-10-18 18:24:20 +00:00
|
|
|
#include <wx/app.h>
|
|
|
|
|
2019-04-23 08:18:15 +00:00
|
|
|
|
|
|
|
// a transform matrix, to display components in lib editor
|
|
|
|
TRANSFORM DefaultTransform = TRANSFORM( 1, 0, 0, -1 );
|
|
|
|
|
2021-07-20 14:32:22 +00:00
|
|
|
|
2019-04-23 08:18:15 +00:00
|
|
|
static struct IFACE : public KIFACE_I
|
|
|
|
{
|
|
|
|
// Of course all are overloads, implementations of the KIFACE.
|
|
|
|
|
|
|
|
IFACE( const char* aName, KIWAY::FACE_T aType ) : KIFACE_I( aName, aType )
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
bool OnKifaceStart( PGM_BASE* aProgram, int aCtlBits ) override
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void OnKifaceEnd() override
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
wxWindow* CreateWindow(
|
|
|
|
wxWindow* aParent, int aClassId, KIWAY* aKiway, int aCtlBits = 0 ) override
|
|
|
|
{
|
|
|
|
assert( false );
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2021-07-20 14:32:22 +00:00
|
|
|
* Return a pointer to the requested object.
|
|
|
|
*
|
|
|
|
* The safest way to use this is to retrieve a pointer to a static instance of an interface,
|
|
|
|
* similar to how the KIFACE interface is exported. But if you know what you are doing
|
2019-04-23 08:18:15 +00:00
|
|
|
* use it to retrieve anything you want.
|
|
|
|
*
|
|
|
|
* @param aDataId identifies which object you want the address of.
|
2021-07-20 14:32:22 +00:00
|
|
|
* @return requested object which must be cast into the know type.
|
2019-04-23 08:18:15 +00:00
|
|
|
*/
|
|
|
|
void* IfaceOrAddress( int aDataId ) override
|
|
|
|
{
|
2021-07-20 14:32:22 +00:00
|
|
|
return nullptr;
|
2019-04-23 08:18:15 +00:00
|
|
|
}
|
|
|
|
} kiface( "mock_eeschema", KIWAY::FACE_SCH );
|
|
|
|
|
2021-07-20 14:32:22 +00:00
|
|
|
|
2019-04-23 08:18:15 +00:00
|
|
|
static struct PGM_MOCK_EESCHEMA_FRAME : public PGM_BASE
|
|
|
|
{
|
|
|
|
bool OnPgmInit();
|
|
|
|
|
|
|
|
void OnPgmExit()
|
|
|
|
{
|
|
|
|
Kiway.OnKiwayEnd();
|
|
|
|
|
|
|
|
// Destroy everything in PGM_BASE, especially wxSingleInstanceCheckerImpl
|
|
|
|
// earlier than wxApp and earlier than static destruction would.
|
2020-10-06 09:22:07 +00:00
|
|
|
//PGM_BASE::Destroy();
|
2019-04-23 08:18:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void MacOpenFile( const wxString& aFileName ) override
|
|
|
|
{
|
|
|
|
wxFileName filename( aFileName );
|
|
|
|
|
|
|
|
if( filename.FileExists() )
|
|
|
|
{
|
|
|
|
#if 0
|
|
|
|
// this pulls in EDA_DRAW_FRAME type info, which we don't want in
|
|
|
|
// the single_top link image.
|
|
|
|
KIWAY_PLAYER* frame = dynamic_cast<KIWAY_PLAYER*>( App().GetTopWindow() );
|
|
|
|
#else
|
|
|
|
KIWAY_PLAYER* frame = (KIWAY_PLAYER*) App().GetTopWindow();
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if( frame )
|
|
|
|
frame->OpenProjectFiles( std::vector<wxString>( 1, aFileName ) );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} program;
|
|
|
|
|
2021-07-20 14:32:22 +00:00
|
|
|
|
2019-04-23 08:18:15 +00:00
|
|
|
PGM_BASE& Pgm()
|
|
|
|
{
|
|
|
|
return program;
|
|
|
|
}
|
|
|
|
|
2021-07-20 14:32:22 +00:00
|
|
|
|
2020-04-14 16:12:15 +00:00
|
|
|
// Similar to PGM_BASE& Pgm(), but return nullptr when a *.ki_face is run from
|
|
|
|
// a python script or something else.
|
|
|
|
// Therefore here return always nullptr
|
|
|
|
PGM_BASE* PgmOrNull()
|
|
|
|
{
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2019-04-23 08:18:15 +00:00
|
|
|
|
|
|
|
KIFACE_I& Kiface()
|
|
|
|
{
|
|
|
|
return kiface;
|
|
|
|
}
|