2008-11-02 14:54:53 +00:00
|
|
|
/**
|
|
|
|
* @file kicad.cpp
|
2011-09-30 14:15:37 -04:00
|
|
|
* @brief Main KiCad library manager file
|
2008-11-02 14:54:53 +00:00
|
|
|
*/
|
|
|
|
|
2012-01-22 22:33:36 -06:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <appl_wxstruct.h>
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
#ifdef USE_SPLASH_IMAGE
|
2008-08-20 22:44:37 +00:00
|
|
|
#define SPLASH_IMAGE logo_kicad.png
|
|
|
|
#include "wx/splash.h"
|
|
|
|
#include "wx/mediactrl.h"
|
2007-05-28 18:09:49 +00:00
|
|
|
#endif
|
|
|
|
|
2012-01-22 22:33:36 -06:00
|
|
|
#include <kicad.h>
|
|
|
|
#include <tree_project_frame.h>
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2012-01-22 22:33:36 -06:00
|
|
|
#include <build_version.h>
|
2010-01-05 08:48:49 +00:00
|
|
|
|
2011-08-19 11:08:41 -04:00
|
|
|
const wxString g_KicadPrjFilenameExtension( wxT( ".pro" ) );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
/* Import functions */
|
2008-12-08 15:27:13 +00:00
|
|
|
char* GetFileName( char* FullPathName );
|
|
|
|
void ShowLogo( char* FonteFileName );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
/* Local functions */
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
/************************************/
|
|
|
|
/* Called to initialize the program */
|
|
|
|
/************************************/
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
// Create a new application object
|
2011-09-06 10:09:40 -04:00
|
|
|
IMPLEMENT_APP( EDA_APP )
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2010-02-19 15:01:32 +00:00
|
|
|
/* MacOSX: Needed for file association
|
2010-01-16 19:42:58 +00:00
|
|
|
* http://wiki.wxwidgets.org/WxMac-specific_topics
|
|
|
|
*/
|
2011-09-06 10:09:40 -04:00
|
|
|
void EDA_APP::MacOpenFile( const wxString &fileName )
|
2011-08-19 11:08:41 -04:00
|
|
|
{
|
|
|
|
KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) GetTopWindow();
|
|
|
|
wxFileName fn = fileName;
|
2010-01-16 19:42:58 +00:00
|
|
|
|
|
|
|
frame->m_ProjectFileName = fn;
|
|
|
|
|
|
|
|
if( m_fileHistory.GetCount() )
|
|
|
|
{
|
|
|
|
frame->m_ProjectFileName = m_fileHistory.GetHistoryFile( 0 );
|
2011-08-19 11:08:41 -04:00
|
|
|
|
2010-01-16 19:42:58 +00:00
|
|
|
if( !frame->m_ProjectFileName.FileExists() )
|
2011-08-19 11:08:41 -04:00
|
|
|
{
|
2010-01-16 19:42:58 +00:00
|
|
|
m_fileHistory.RemoveFileFromHistory( 0 );
|
2011-08-19 11:08:41 -04:00
|
|
|
}
|
2010-01-16 19:42:58 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent cmd( 0, wxID_FILE1 );
|
|
|
|
frame->OnFileHistory( cmd );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-08-19 11:08:41 -04:00
|
|
|
wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() +
|
2011-09-06 10:09:40 -04:00
|
|
|
wxT( " " ) + frame->m_ProjectFileName.GetFullPath();
|
2011-08-19 11:08:41 -04:00
|
|
|
|
|
|
|
if( !fn.IsDirWritable() )
|
|
|
|
title += _( " [Read Only]" );
|
|
|
|
|
|
|
|
frame->SetTitle( title );
|
2010-01-16 19:42:58 +00:00
|
|
|
|
|
|
|
frame->m_LeftWin->ReCreateTreePrj();
|
|
|
|
|
|
|
|
frame->PrintMsg( _( "Working dir: " ) + frame->m_ProjectFileName.GetPath() +
|
2011-08-19 11:08:41 -04:00
|
|
|
_( "\nProject: " ) + frame->m_ProjectFileName.GetFullName() +
|
|
|
|
wxT( "\n" ) );
|
2010-01-16 19:42:58 +00:00
|
|
|
}
|
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
|
2011-09-06 10:09:40 -04:00
|
|
|
bool EDA_APP::OnInit()
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
2011-04-17 15:54:17 +02:00
|
|
|
KICAD_MANAGER_FRAME* frame;
|
2008-08-20 22:44:37 +00:00
|
|
|
|
2011-09-06 10:09:40 -04:00
|
|
|
InitEDA_Appl( wxT( "KiCad" ), APP_KICAD_T );
|
2008-08-20 22:44:37 +00:00
|
|
|
|
2009-07-03 07:32:48 +00:00
|
|
|
// read current setup and reopen last directory if no filename to open in command line
|
|
|
|
bool reopenLastUsedDirectory = argc == 1;
|
2011-08-19 11:08:41 -04:00
|
|
|
GetSettings( reopenLastUsedDirectory );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2008-08-22 09:15:33 +00:00
|
|
|
/* Make nameless project translatable */
|
2010-02-24 15:33:03 +00:00
|
|
|
wxFileName namelessProject( wxGetCwd(), NAMELESS_PROJECT, ProjectFileExtension );
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2011-04-17 15:54:17 +02:00
|
|
|
frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ),
|
2011-08-19 11:08:41 -04:00
|
|
|
wxPoint( 30, 20 ), wxSize( 600, 400 ) );
|
2008-12-08 15:27:13 +00:00
|
|
|
|
|
|
|
if( argc > 1 )
|
2011-08-19 11:08:41 -04:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
frame->m_ProjectFileName = argv[1];
|
2011-08-19 11:08:41 -04:00
|
|
|
}
|
2009-01-17 20:31:19 +00:00
|
|
|
else if( m_fileHistory.GetCount() )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
frame->m_ProjectFileName = m_fileHistory.GetHistoryFile( 0 );
|
2011-08-19 11:08:41 -04:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !frame->m_ProjectFileName.FileExists() )
|
2011-08-19 11:08:41 -04:00
|
|
|
{
|
2009-01-17 20:31:19 +00:00
|
|
|
m_fileHistory.RemoveFileFromHistory( 0 );
|
2011-08-19 11:08:41 -04:00
|
|
|
}
|
2009-04-05 20:49:15 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
wxCommandEvent cmd( 0, wxID_FILE1 );
|
|
|
|
frame->OnFileHistory( cmd );
|
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
2009-01-17 20:31:19 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( !frame->m_ProjectFileName.FileExists() )
|
|
|
|
{
|
|
|
|
wxCommandEvent cmd( 0, wxID_ANY );
|
|
|
|
frame->m_ProjectFileName = namelessProject;
|
|
|
|
frame->OnLoadProject( cmd );
|
|
|
|
}
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2011-08-19 11:08:41 -04:00
|
|
|
wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() +
|
2011-09-06 10:09:40 -04:00
|
|
|
wxT( " " ) + frame->m_ProjectFileName.GetFullPath();
|
2011-08-19 11:08:41 -04:00
|
|
|
|
|
|
|
if( !namelessProject.IsDirWritable() )
|
|
|
|
title += _( " [Read Only]" );
|
|
|
|
|
|
|
|
frame->SetTitle( title );
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->ReCreateMenuBar();
|
|
|
|
frame->RecreateBaseHToolbar();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->m_LeftWin->ReCreateTreePrj();
|
|
|
|
SetTopWindow( frame );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2008-11-02 14:54:53 +00:00
|
|
|
/* Splash screen logo */
|
|
|
|
#ifdef USE_SPLASH_IMAGE
|
2009-01-29 14:26:20 +00:00
|
|
|
wxBitmap bmp;
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString binDir = GetTraits()->GetStandardPaths().GetExecutablePath() +
|
2011-09-06 10:09:40 -04:00
|
|
|
wxFileName::GetPathSeparator();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
if( bmp.LoadFile( binDir + _T( "logokicad.png" ), wxBITMAP_TYPE_PNG ) )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
2008-12-08 15:27:13 +00:00
|
|
|
wxSplashScreen* splash = new wxSplashScreen( splash_screen,
|
|
|
|
wxSPLASH_CENTRE_ON_SCREEN | wxSPLASH_TIMEOUT,
|
|
|
|
3000,
|
|
|
|
frame,
|
|
|
|
wxID_ANY,
|
|
|
|
wxDefaultPosition,
|
|
|
|
wxDefaultSize,
|
|
|
|
wxSIMPLE_BORDER | wxSTAY_ON_TOP );
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
2008-11-02 14:54:53 +00:00
|
|
|
#endif /* USE_SPLASH_IMAGE */
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2011-08-19 11:08:41 -04:00
|
|
|
frame->Show( true );
|
2008-12-08 15:27:13 +00:00
|
|
|
frame->Raise();
|
2008-08-20 22:44:37 +00:00
|
|
|
|
2011-08-19 11:08:41 -04:00
|
|
|
return true;
|
2007-05-28 18:09:49 +00:00
|
|
|
}
|