Beautify code for kicad.cpp, kicad/mainframe.cpp, treeprj_frame.cpp
This commit is contained in:
parent
365dbe15b8
commit
e7cd29ece6
238
kicad/kicad.cpp
238
kicad/kicad.cpp
|
@ -1,6 +1,11 @@
|
||||||
/********************************/
|
/*****************************************************************************/
|
||||||
/* kicad.cpp - module principal */
|
/**
|
||||||
/********************************/
|
* @file kicad.cpp
|
||||||
|
* @brief Main kicad library manager file
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef __GNUG__
|
#ifdef __GNUG__
|
||||||
#pragma implementation
|
#pragma implementation
|
||||||
|
@ -13,13 +18,9 @@
|
||||||
|
|
||||||
#include <wx/image.h>
|
#include <wx/image.h>
|
||||||
|
|
||||||
//#define SPLASH_OK
|
|
||||||
|
|
||||||
#ifdef SPLASH_OK
|
#ifdef USE_SPLASH_IMAGE
|
||||||
|
|
||||||
/* Define Splash Image */
|
|
||||||
#define SPLASH_IMAGE logo_kicad.png
|
#define SPLASH_IMAGE logo_kicad.png
|
||||||
|
|
||||||
#include "wx/splash.h"
|
#include "wx/splash.h"
|
||||||
#include "wx/mediactrl.h"
|
#include "wx/mediactrl.h"
|
||||||
#endif
|
#endif
|
||||||
|
@ -35,95 +36,174 @@
|
||||||
#include <pyhandler.h>
|
#include <pyhandler.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* Routines exportees */
|
/* Export functions */
|
||||||
|
|
||||||
/* fonctions importees */
|
/* Import functions */
|
||||||
char *GetFileName(char *FullPathName);
|
char *GetFileName(char *FullPathName);
|
||||||
void ShowLogo(char * FonteFileName);
|
void ShowLogo(char * FonteFileName);
|
||||||
|
|
||||||
/* Routines locales */
|
/* Local functions */
|
||||||
|
|
||||||
/************************************/
|
|
||||||
/* Called to initialize the program */
|
|
||||||
/************************************/
|
|
||||||
|
|
||||||
|
/************************************/
|
||||||
|
/* Called to initialize the program */
|
||||||
|
/************************************/
|
||||||
// Create a new application object
|
// Create a new application object
|
||||||
IMPLEMENT_APP(WinEDA_App)
|
IMPLEMENT_APP(WinEDA_App)
|
||||||
|
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
#ifdef KICAD_PYTHON
|
||||||
using namespace boost::python;
|
using namespace boost::python;
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
// Global functions:
|
// Global functions:
|
||||||
|
/*****************************************************************************/
|
||||||
static WinEDA_MainFrame& GetMainFrame() { return *( wxGetApp().m_MainFrame ); }
|
static WinEDA_MainFrame& GetMainFrame() { return *( wxGetApp().m_MainFrame ); }
|
||||||
static void WinEDAPrint( str msg ) { GetMainFrame().PrintMsg( PyHandler::MakeStr( msg ) + wxT("\n") ); }
|
static void WinEDAPrint( str msg ) { GetMainFrame().PrintMsg( PyHandler::MakeStr( msg ) + wxT("\n") ); }
|
||||||
static void WinEDAClear() { GetMainFrame().ClearMsg(); }
|
static void WinEDAClear() { GetMainFrame().ClearMsg(); }
|
||||||
static object GetTypeExt( enum TreeFileType type ) { return PyHandler::Convert( WinEDA_PrjFrame::GetFileExt( type ) ); }
|
static object GetTypeExt( enum TreeFileType type ) { return PyHandler::Convert( WinEDA_PrjFrame::GetFileExt( type ) ); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
// WinEDA_MainFrame Special binding functions:
|
// WinEDA_MainFrame Special binding functions:
|
||||||
// (one line functions are simple wrappers)
|
// (one line functions are simple wrappers)
|
||||||
|
/*****************************************************************************/
|
||||||
object WinEDA_MainFrame::GetPrjName() const { return PyHandler::Convert( m_PrjFileName ); }
|
object WinEDA_MainFrame::GetPrjName() const { return PyHandler::Convert( m_PrjFileName ); }
|
||||||
object WinEDA_MainFrame::ToWx() { return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) ); }
|
object WinEDA_MainFrame::ToWx() { return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) ); }
|
||||||
WinEDA_PrjFrame* WinEDA_MainFrame::GetTree() const { return m_LeftWin; }
|
WinEDA_PrjFrame* WinEDA_MainFrame::GetTree() const { return m_LeftWin; }
|
||||||
|
|
||||||
void WinEDA_MainFrame::AddFastLaunchPy( object & button )
|
|
||||||
{
|
|
||||||
wxBitmapButton * btn;
|
|
||||||
bool success = wxPyConvertSwigPtr( button.ptr(), (void**)&btn, _T("wxBitmapButton"));
|
|
||||||
if ( !success ) return;
|
|
||||||
|
|
||||||
Py_INCREF( button.ptr() );
|
|
||||||
btn->Reparent( m_CommandWin );
|
/**
|
||||||
m_CommandWin->AddFastLaunch( btn );
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void WinEDA_MainFrame::AddFastLaunchPy( object & button )
|
||||||
|
/*****************************************************************************/
|
||||||
|
{
|
||||||
|
wxBitmapButton * btn;
|
||||||
|
|
||||||
|
bool success = wxPyConvertSwigPtr( button.ptr(), (void**)&btn, _T("wxBitmapButton"));
|
||||||
|
if(!success)
|
||||||
|
return;
|
||||||
|
|
||||||
|
Py_INCREF( button.ptr() );
|
||||||
|
btn->Reparent( m_CommandWin );
|
||||||
|
m_CommandWin->AddFastLaunch( btn );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
// WinEDA_PrjFrame Special binding functions:
|
// WinEDA_PrjFrame Special binding functions:
|
||||||
// (one line functions are simple wrappers)
|
// (one line functions are simple wrappers)
|
||||||
|
/*****************************************************************************/
|
||||||
|
// TODO To WxWidgets ?
|
||||||
|
object WinEDA_PrjFrame::ToWx()
|
||||||
|
{ return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) ); }
|
||||||
|
|
||||||
object WinEDA_PrjFrame::ToWx() { return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) ); }
|
// TODO Get ?
|
||||||
object WinEDA_PrjFrame::GetFtExPy( enum TreeFileType type ) const { return PyHandler::Convert( GetFileExt( type ) ); }
|
object WinEDA_PrjFrame::GetFtExPy( enum TreeFileType type ) const
|
||||||
object WinEDA_PrjFrame::GetMenuPy( enum TreeFileType type ) { return object( handle<>( borrowed( wxPyMake_wxObject( GetContextMenu( (int) type ), false ) ) ) ); }
|
{ return PyHandler::Convert( GetFileExt( type ) ); }
|
||||||
object WinEDA_PrjFrame::GetTreeCtrl() { return object( handle<>( borrowed( wxPyMake_wxObject( m_TreeProject, false ) ) ) ); }
|
|
||||||
object WinEDA_PrjFrame::GetCurrentMenu() { return object( handle<>( borrowed( wxPyMake_wxObject( m_PopupMenu, false ) ) ) ); }
|
|
||||||
|
|
||||||
void WinEDA_PrjFrame::NewFilePy( const str & name, enum TreeFileType type, object & id )
|
// Get python menu
|
||||||
|
object WinEDA_PrjFrame::GetMenuPy( enum TreeFileType type )
|
||||||
|
{ return object( handle<>( borrowed( wxPyMake_wxObject( GetContextMenu( (int) type ), false ) ) ) ); }
|
||||||
|
|
||||||
|
// Get tree control
|
||||||
|
object WinEDA_PrjFrame::GetTreeCtrl()
|
||||||
|
{ return object( handle<>( borrowed( wxPyMake_wxObject( m_TreeProject, false ) ) ) ); }
|
||||||
|
|
||||||
|
// Get current menu
|
||||||
|
object WinEDA_PrjFrame::GetCurrentMenu()
|
||||||
|
{ return object( handle<>( borrowed( wxPyMake_wxObject( m_PopupMenu, false ) ) ) ); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void WinEDA_PrjFrame::NewFilePy( const str & name,
|
||||||
|
enum TreeFileType type,
|
||||||
|
object & id )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxTreeItemId root;
|
wxTreeItemId root;
|
||||||
if (! wxPyConvertSwigPtr( id.ptr(), (void**)&root, _T("wxTreeItemId") ) ) return;
|
if (! wxPyConvertSwigPtr( id.ptr(), (void**)&root, _T("wxTreeItemId") ) ) return;
|
||||||
NewFile( PyHandler::MakeStr( name ), type, root );
|
NewFile( PyHandler::MakeStr( name ), type, root );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Add a file to the tree under root, or m_root if conversion is wrong
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::AddFilePy( const str & file, object & root )
|
void WinEDA_PrjFrame::AddFilePy( const str & file, object & root )
|
||||||
/* Add a file to the tree under root, or m_root if conversion is wrong */
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxTreeItemId * theroot = &m_root;
|
wxTreeItemId * theroot = &m_root;
|
||||||
if ( !wxPyConvertSwigPtr( root.ptr(), (void**)&root, _T("wxTreeItemId") ) )
|
|
||||||
{
|
if ( !wxPyConvertSwigPtr( root.ptr(), (void**)&root, _T("wxTreeItemId") ) )
|
||||||
theroot = &m_root;
|
{
|
||||||
}
|
theroot = &m_root;
|
||||||
AddFile( PyHandler::MakeStr( file ), *theroot );
|
}
|
||||||
|
|
||||||
|
AddFile( PyHandler::MakeStr( file ), *theroot );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief convert wxTreeItem into TreePrjItemData
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
TreePrjItemData * WinEDA_PrjFrame::GetItemData( const object & item )
|
TreePrjItemData * WinEDA_PrjFrame::GetItemData( const object & item )
|
||||||
/* convert wxTreeItem into TreePrjItemData */
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxTreeItemId *id = NULL;
|
wxTreeItemId *id = NULL;
|
||||||
if ( !wxPyConvertSwigPtr( item.ptr(), (void**)&id, _T("wxTreeItemId") ) ) return NULL;
|
|
||||||
return dynamic_cast<TreePrjItemData *>( m_TreeProject->GetItemData( *id ) );
|
if (!wxPyConvertSwigPtr( item.ptr(), (void**)&id, _T("wxTreeItemId")))
|
||||||
|
{
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
return dynamic_cast<TreePrjItemData *>( m_TreeProject->GetItemData( *id ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
// TreePrjItemData Special binding functions
|
// TreePrjItemData Special binding functions
|
||||||
// (one line functions are simple wrappers)
|
// (one line functions are simple wrappers)
|
||||||
|
/*****************************************************************************/
|
||||||
|
// Python rename
|
||||||
|
bool TreePrjItemData::RenamePy( const str & newname, bool check )
|
||||||
|
{ return Rename( PyHandler::MakeStr(newname), check ); }
|
||||||
|
|
||||||
bool TreePrjItemData::RenamePy( const str & newname, bool check ) { return Rename( PyHandler::MakeStr(newname), check ); }
|
// Get python directory
|
||||||
object TreePrjItemData::GetDirPy() const { return PyHandler::Convert( GetDir() ); }
|
object TreePrjItemData::GetDirPy() const
|
||||||
object TreePrjItemData::GetFileNamePy() const { return PyHandler::Convert( GetFileName() ); }
|
{ return PyHandler::Convert( GetDir() ); }
|
||||||
object TreePrjItemData::GetMenuPy() { return object( handle<>( borrowed( wxPyMake_wxObject( &m_fileMenu, false ) ) ) ); }
|
|
||||||
|
|
||||||
// kicad module init function
|
// Get python filename
|
||||||
// ( this function is called from PyHandler to init the kicad module )
|
object TreePrjItemData::GetFileNamePy() const
|
||||||
|
{ return PyHandler::Convert( GetFileName() ); }
|
||||||
|
|
||||||
|
// Get python menu
|
||||||
|
object TreePrjItemData::GetMenuPy()
|
||||||
|
{ return object( handle<>( borrowed( wxPyMake_wxObject( &m_fileMenu, false ) ) ) ); }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief KiCad python module init, \n
|
||||||
|
* This function is called from PyHandler to init the kicad module
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
static void py_kicad_init()
|
static void py_kicad_init()
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
def( "GetMainFrame", &GetMainFrame, return_value_policy< reference_existing_object >() );
|
def( "GetMainFrame", &GetMainFrame, return_value_policy< reference_existing_object >() );
|
||||||
def( "GetTypeExtension", &GetTypeExt );
|
def( "GetTypeExtension", &GetTypeExt );
|
||||||
|
@ -156,6 +236,7 @@ static void py_kicad_init()
|
||||||
.value( "DIRECTORY", TREE_DIRECTORY )
|
.value( "DIRECTORY", TREE_DIRECTORY )
|
||||||
.value( "MAX", TREE_MAX );
|
.value( "MAX", TREE_MAX );
|
||||||
|
|
||||||
|
|
||||||
class_<WinEDA_PrjFrame>( "TreeWindow" )
|
class_<WinEDA_PrjFrame>( "TreeWindow" )
|
||||||
// wx Interface
|
// wx Interface
|
||||||
.def( "ToWx", &WinEDA_PrjFrame::ToWx )
|
.def( "ToWx", &WinEDA_PrjFrame::ToWx )
|
||||||
|
@ -168,14 +249,38 @@ static void py_kicad_init()
|
||||||
.def( "RemoveFilter", &WinEDA_PrjFrame::RemoveFilterPy )
|
.def( "RemoveFilter", &WinEDA_PrjFrame::RemoveFilterPy )
|
||||||
.def( "GetFilters", &WinEDA_PrjFrame::GetFilters, return_value_policy < copy_const_reference >() )
|
.def( "GetFilters", &WinEDA_PrjFrame::GetFilters, return_value_policy < copy_const_reference >() )
|
||||||
.def( "GetCurrentMenu", &WinEDA_PrjFrame::GetCurrentMenu )
|
.def( "GetCurrentMenu", &WinEDA_PrjFrame::GetCurrentMenu )
|
||||||
// Project tree control
|
|
||||||
.def( "AddState", &WinEDA_PrjFrame::AddStatePy )
|
|
||||||
.def( "GetTreeCtrl", &WinEDA_PrjFrame::GetTreeCtrl )
|
/** Project tree control **/
|
||||||
.def( "GetItemData", &WinEDA_PrjFrame::GetItemData, return_value_policy < reference_existing_object >() )
|
|
||||||
.def( "FindItemData", &WinEDA_PrjFrame::FindItemData, return_value_policy < reference_existing_object >() )
|
// AddState
|
||||||
.def( "NewFile", &WinEDA_PrjFrame::NewFilePy )
|
.def( "AddState",
|
||||||
.def( "AddFile", &WinEDA_PrjFrame::AddFilePy )
|
&WinEDA_PrjFrame::AddStatePy )
|
||||||
;
|
|
||||||
|
// GetTreeCtrl
|
||||||
|
.def( "GetTreeCtrl",
|
||||||
|
&WinEDA_PrjFrame::GetTreeCtrl )
|
||||||
|
|
||||||
|
// GetItemData
|
||||||
|
.def( "GetItemData",
|
||||||
|
&WinEDA_PrjFrame::GetItemData,
|
||||||
|
return_value_policy < reference_existing_object >() )
|
||||||
|
|
||||||
|
// FindItemData
|
||||||
|
.def( "FindItemData",
|
||||||
|
&WinEDA_PrjFrame::FindItemData,
|
||||||
|
return_value_policy < reference_existing_object >() )
|
||||||
|
|
||||||
|
// NewFile
|
||||||
|
.def( "NewFile",
|
||||||
|
&WinEDA_PrjFrame::NewFilePy )
|
||||||
|
|
||||||
|
// AddFile
|
||||||
|
.def( "AddFile",
|
||||||
|
&WinEDA_PrjFrame::AddFilePy )
|
||||||
|
|
||||||
|
; /* ENDOF class_<WinEDA_PrjFrame>( "TreeWindow" ) */
|
||||||
|
|
||||||
|
|
||||||
class_<WinEDA_MainFrame>( "MainFrame" )
|
class_<WinEDA_MainFrame>( "MainFrame" )
|
||||||
// Wx interface
|
// Wx interface
|
||||||
|
@ -188,18 +293,25 @@ static void py_kicad_init()
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// common module init function
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Common python module init
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
static void py_common_init()
|
static void py_common_init()
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
def( "Print", &WinEDAPrint );
|
def( "Print", &WinEDAPrint );
|
||||||
def( "Clear", &WinEDAClear );
|
def( "Clear", &WinEDAClear );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
bool WinEDA_App::OnInit()
|
bool WinEDA_App::OnInit()
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxImage::AddHandler(new wxPNGHandler);
|
wxImage::AddHandler(new wxPNGHandler);
|
||||||
|
|
||||||
|
@ -236,8 +348,8 @@ bool WinEDA_App::OnInit()
|
||||||
m_MainFrame->m_LeftWin->ReCreateTreePrj();
|
m_MainFrame->m_LeftWin->ReCreateTreePrj();
|
||||||
SetTopWindow(m_MainFrame);
|
SetTopWindow(m_MainFrame);
|
||||||
|
|
||||||
/* Splash Screen Logo */
|
/* Splash screen logo */
|
||||||
#ifdef SPLASH_OK
|
#ifdef USE_SPLASH_IMAGE
|
||||||
wxString logoname( wxString(m_BinDir) + _T("logokicad.png") );
|
wxString logoname( wxString(m_BinDir) + _T("logokicad.png") );
|
||||||
wxBitmap splash_screen;
|
wxBitmap splash_screen;
|
||||||
if ( splash_screen.LoadFile( logoname, wxBITMAP_TYPE_PNG ) )
|
if ( splash_screen.LoadFile( logoname, wxBITMAP_TYPE_PNG ) )
|
||||||
|
@ -247,7 +359,7 @@ bool WinEDA_App::OnInit()
|
||||||
3000, m_MainFrame, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
3000, m_MainFrame, wxID_ANY, wxDefaultPosition, wxDefaultSize,
|
||||||
wxSIMPLE_BORDER|wxSTAY_ON_TOP);
|
wxSIMPLE_BORDER|wxSTAY_ON_TOP);
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* USE_SPLASH_IMAGE */
|
||||||
|
|
||||||
m_MainFrame->Show(TRUE);
|
m_MainFrame->Show(TRUE);
|
||||||
m_MainFrame->Raise();
|
m_MainFrame->Raise();
|
||||||
|
@ -265,5 +377,3 @@ bool WinEDA_App::OnInit()
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
// vim: tabstop=4 : noexpandtab :
|
|
||||||
|
|
|
@ -21,16 +21,19 @@
|
||||||
|
|
||||||
#include "kicad.h"
|
#include "kicad.h"
|
||||||
|
|
||||||
/****************/
|
|
||||||
/* Constructor */
|
|
||||||
/****************/
|
|
||||||
|
|
||||||
|
// Constructor
|
||||||
|
/*****************************************************************************/
|
||||||
WinEDA_MainFrame::WinEDA_MainFrame( WinEDA_App* eda_app,
|
WinEDA_MainFrame::WinEDA_MainFrame( WinEDA_App* eda_app,
|
||||||
wxWindow* parent, const wxString& title,
|
wxWindow* parent,
|
||||||
const wxPoint& pos, const wxSize& size ) :
|
const wxString& title,
|
||||||
WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, eda_app, title, pos, size )
|
const wxPoint& pos,
|
||||||
|
const wxSize& size ) :
|
||||||
|
WinEDA_BasicFrame( parent, KICAD_MAIN_FRAME, eda_app, title, pos, size )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxString msg;
|
wxString msg;
|
||||||
|
wxString line;
|
||||||
wxSize clientsize;
|
wxSize clientsize;
|
||||||
|
|
||||||
m_FrameName = wxT( "KicadFrame" );
|
m_FrameName = wxT( "KicadFrame" );
|
||||||
|
@ -44,8 +47,10 @@ WinEDA_MainFrame::WinEDA_MainFrame( WinEDA_App* eda_app,
|
||||||
GetSettings();
|
GetSettings();
|
||||||
if( m_Parent->m_EDA_Config )
|
if( m_Parent->m_EDA_Config )
|
||||||
{
|
{
|
||||||
m_Parent->m_EDA_Config->Read( wxT( "LeftWinWidth" ), &m_LeftWin_Width );
|
m_Parent->m_EDA_Config->Read( wxT( "LeftWinWidth" ),
|
||||||
m_Parent->m_EDA_Config->Read( wxT( "CommandWinWidth" ), &m_CommandWin_Height );
|
&m_LeftWin_Width );
|
||||||
|
m_Parent->m_EDA_Config->Read( wxT( "CommandWinWidth" ),
|
||||||
|
&m_CommandWin_Height );
|
||||||
}
|
}
|
||||||
|
|
||||||
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
SetSize( m_FramePos.x, m_FramePos.y, m_FrameSize.x, m_FrameSize.y );
|
||||||
|
@ -57,9 +62,9 @@ WinEDA_MainFrame::WinEDA_MainFrame( WinEDA_App* eda_app,
|
||||||
|
|
||||||
// Give an icon
|
// Give an icon
|
||||||
#ifdef __WINDOWS__
|
#ifdef __WINDOWS__
|
||||||
SetIcon( wxICON( a_kicad_icon ) );
|
SetIcon( wxICON( a_kicad_icon ) );
|
||||||
#else
|
#else
|
||||||
SetIcon( wxICON( kicad_icon ) );
|
SetIcon( wxICON( kicad_icon ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
clientsize = GetClientSize();
|
clientsize = GetClientSize();
|
||||||
|
@ -78,7 +83,7 @@ WinEDA_MainFrame::WinEDA_MainFrame( WinEDA_App* eda_app,
|
||||||
wxNO_BORDER | wxSW_3D );
|
wxNO_BORDER | wxSW_3D );
|
||||||
m_BottomWin->SetDefaultSize( wxSize( clientsize.x, 150 ) );
|
m_BottomWin->SetDefaultSize( wxSize( clientsize.x, 150 ) );
|
||||||
m_BottomWin->SetOrientation( wxLAYOUT_HORIZONTAL );
|
m_BottomWin->SetOrientation( wxLAYOUT_HORIZONTAL );
|
||||||
m_BottomWin->SetAlignment( wxLAYOUT_BOTTOM );
|
m_BottomWin->SetAlignment ( wxLAYOUT_BOTTOM );
|
||||||
m_BottomWin->SetSashVisible( wxSASH_TOP, TRUE );
|
m_BottomWin->SetSashVisible( wxSASH_TOP, TRUE );
|
||||||
m_BottomWin->SetSashVisible( wxSASH_LEFT, TRUE );
|
m_BottomWin->SetSashVisible( wxSASH_LEFT, TRUE );
|
||||||
m_BottomWin->SetExtraBorderSize( 2 );
|
m_BottomWin->SetExtraBorderSize( 2 );
|
||||||
|
@ -91,43 +96,41 @@ WinEDA_MainFrame::WinEDA_MainFrame( WinEDA_App* eda_app,
|
||||||
m_DialogWin->SetFont( *g_StdFont );
|
m_DialogWin->SetFont( *g_StdFont );
|
||||||
|
|
||||||
// m_CommandWin is the box with buttons which launch eechema, pcbnew ...
|
// m_CommandWin is the box with buttons which launch eechema, pcbnew ...
|
||||||
m_CommandWin = new WinEDA_CommandFrame( this, ID_MAIN_COMMAND,
|
m_CommandWin = new WinEDA_CommandFrame( this,
|
||||||
|
ID_MAIN_COMMAND,
|
||||||
wxPoint( m_LeftWin_Width,
|
wxPoint( m_LeftWin_Width,
|
||||||
0 ),
|
0 ),
|
||||||
wxSize( clientsize.x, m_CommandWin_Height ),
|
wxSize( clientsize.x,
|
||||||
|
m_CommandWin_Height ),
|
||||||
wxNO_BORDER | wxSW_3D );
|
wxNO_BORDER | wxSW_3D );
|
||||||
|
|
||||||
wxString line;
|
|
||||||
msg = wxGetCwd();
|
msg = wxGetCwd();
|
||||||
line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() );
|
line.Printf( _( "Ready\nWorking dir: %s\n" ), msg.GetData() );
|
||||||
PrintMsg( line );
|
PrintMsg( line );
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
#ifdef KICAD_PYTHON
|
||||||
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::LoadProject" ) );
|
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::LoadProject" ) );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************/
|
/*****************************************************************************/
|
||||||
/* Destructor */
|
|
||||||
/***************/
|
|
||||||
|
|
||||||
WinEDA_MainFrame::~WinEDA_MainFrame()
|
WinEDA_MainFrame::~WinEDA_MainFrame()
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
if( m_Parent->m_EDA_Config )
|
if( m_Parent->m_EDA_Config )
|
||||||
{
|
{
|
||||||
m_LeftWin_Width = m_LeftWin->GetSize().x;
|
m_LeftWin_Width = m_LeftWin->GetSize().x;
|
||||||
m_CommandWin_Height = m_CommandWin->GetSize().y;
|
m_CommandWin_Height = m_CommandWin->GetSize().y;
|
||||||
m_Parent->m_EDA_Config->Write( wxT( "LeftWinWidth" ), m_LeftWin_Width );
|
m_Parent->m_EDA_Config->Write( wxT( "LeftWinWidth" ), m_LeftWin_Width );
|
||||||
m_Parent->m_EDA_Config->Write( wxT( "CommandWinWidth" ), m_CommandWin_Height );
|
m_Parent->m_EDA_Config->Write( wxT( "CommandWinWidth" ), m_CommandWin_Height );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************/
|
/*******************************************************/
|
||||||
void WinEDA_MainFrame::PrintMsg( const wxString& text )
|
void WinEDA_MainFrame::PrintMsg( const wxString& text )
|
||||||
/*******************************************************/
|
/*******************************************************/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Put text in the dialog frame
|
* Put text in the dialog frame
|
||||||
*/
|
*/
|
||||||
|
@ -135,7 +138,7 @@ void WinEDA_MainFrame::PrintMsg( const wxString& text )
|
||||||
m_DialogWin->SetFont( *g_StdFont );
|
m_DialogWin->SetFont( *g_StdFont );
|
||||||
m_DialogWin->AppendText( text );
|
m_DialogWin->AppendText( text );
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
printf("%s\n", (const char*)text.mb_str() );
|
printf("%s\n", (const char*)text.mb_str() );
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -275,18 +278,18 @@ void WinEDA_MainFrame::ReDraw( wxDC* DC )
|
||||||
void WinEDA_MainFrame::Process_Special_Functions( wxCommandEvent& event )
|
void WinEDA_MainFrame::Process_Special_Functions( wxCommandEvent& event )
|
||||||
/**********************************************************************/
|
/**********************************************************************/
|
||||||
{
|
{
|
||||||
int id = event.GetId();
|
int id = event.GetId();
|
||||||
|
|
||||||
switch( id )
|
switch( id )
|
||||||
{
|
{
|
||||||
case ID_EXIT:
|
case ID_EXIT:
|
||||||
Close( TRUE );
|
Close( TRUE );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
DisplayError( this, wxT( "WinEDA_MainFrame::Process_Special_Functions error" ) );
|
DisplayError( this, wxT( "WinEDA_MainFrame::Process_Special_Functions error" ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -394,18 +397,21 @@ void WinEDA_MainFrame::OnRefresh( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/*********************************/
|
/*********************************/
|
||||||
void WinEDA_MainFrame::ClearMsg()
|
void WinEDA_MainFrame::ClearMsg()
|
||||||
/*********************************/
|
/*********************************/
|
||||||
{
|
{
|
||||||
m_DialogWin->Clear();
|
m_DialogWin->Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
#ifdef KICAD_PYTHON
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_MainFrame::OnRefreshPy()
|
void WinEDA_MainFrame::OnRefreshPy()
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
m_LeftWin->ReCreateTreePrj();
|
m_LeftWin->ReCreateTreePrj();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,9 +1,11 @@
|
||||||
/*********************/
|
/**
|
||||||
/* treeprj_frame.cpp */
|
* @file treeprj_frame.cpp
|
||||||
/*********************/
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
#ifdef KICAD_PYTHON
|
||||||
#include <pyhandler.h>
|
#include <pyhandler.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "fctsys.h"
|
#include "fctsys.h"
|
||||||
|
@ -45,32 +47,45 @@ const wxChar * s_AllowedExtensionsToList[] =
|
||||||
NULL // end of list
|
NULL // end of list
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent,
|
WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent,
|
||||||
const wxPoint& pos,
|
const wxPoint& pos,
|
||||||
const wxSize& size ) :
|
const wxSize& size ) :
|
||||||
wxSashLayoutWindow( parent, ID_LEFT_FRAME, pos, size,
|
wxSashLayoutWindow( parent,
|
||||||
wxNO_BORDER | wxSW_3D )
|
ID_LEFT_FRAME,
|
||||||
|
pos,
|
||||||
|
size,
|
||||||
|
wxNO_BORDER | wxSW_3D )
|
||||||
/******************************************************************/
|
/******************************************************************/
|
||||||
{
|
{
|
||||||
m_Parent = parent;
|
m_Parent = parent;
|
||||||
m_TreeProject = NULL;
|
m_TreeProject = NULL;
|
||||||
wxMenuItem* item;
|
wxMenu* menu = m_ContextMenus[TREE_PY];
|
||||||
m_PopupMenu = NULL;
|
wxMenuItem* item;
|
||||||
|
m_PopupMenu = NULL;
|
||||||
|
|
||||||
/* Filtering is now inverted: the filters are actually used to _enable_ support
|
/*
|
||||||
* for a given file type.
|
* Filtering is now inverted: the filters are actually used to _enable_ support
|
||||||
*/
|
* for a given file type.
|
||||||
m_Filters.push_back( wxT( "^.*\\.sch$" ) ); // note: sch filter must be first because of a test in AddFile() below
|
*/
|
||||||
for ( int ii = 0; s_AllowedExtensionsToList[ii] != NULL; ii++ )
|
|
||||||
{
|
// NOTE: sch filter must be first because of a test in AddFile() below
|
||||||
m_Filters.push_back( s_AllowedExtensionsToList[ii] );
|
m_Filters.push_back( wxT( "^.*\\.sch$" ) );
|
||||||
}
|
for ( int ii = 0; s_AllowedExtensionsToList[ii] != NULL; ii++ )
|
||||||
m_Filters.push_back( wxT( "^no kicad files found" ) );
|
{
|
||||||
|
m_Filters.push_back( s_AllowedExtensionsToList[ii] );
|
||||||
#ifdef KICAD_PYTHON
|
}
|
||||||
|
m_Filters.push_back( wxT( "^no kicad files found" ) );
|
||||||
|
|
||||||
|
|
||||||
|
#ifdef KICAD_PYTHON
|
||||||
m_Filters.push_back( wxT( "^.*\\.py$" ) );
|
m_Filters.push_back( wxT( "^.*\\.py$" ) );
|
||||||
|
|
||||||
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::RunScript" ) );
|
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::RunScript" ) );
|
||||||
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::EditScript" ) );
|
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::EditScript" ) );
|
||||||
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::TreeContextMenu" ) );
|
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::TreeContextMenu" ) );
|
||||||
|
@ -80,99 +95,127 @@ WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent,
|
||||||
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::DeleteFile" ) );
|
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::DeleteFile" ) );
|
||||||
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::RenameFile" ) );
|
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::RenameFile" ) );
|
||||||
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::MoveFile" ) );
|
PyHandler::GetInstance()->DeclareEvent( wxT( "kicad::MoveFile" ) );
|
||||||
#endif
|
#endif /* KICAD_PYTHON */
|
||||||
|
|
||||||
for( int i = 0; i < TREE_MAX; i++ )
|
|
||||||
m_ContextMenus.push_back( new wxMenu() );
|
|
||||||
|
|
||||||
// Python script context menu:
|
for( int i = 0; i < TREE_MAX; i++ )
|
||||||
|
m_ContextMenus.push_back( new wxMenu() );
|
||||||
|
|
||||||
wxMenu* menu = m_ContextMenus[TREE_PY];
|
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
// Python script context menu
|
||||||
|
#ifdef KICAD_PYTHON
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_RUNPY,
|
item = new wxMenuItem( menu, ID_PROJECT_RUNPY,
|
||||||
_( "&Run" ),
|
_( "&Run" ),
|
||||||
_( "Run the Python Script" ) );
|
_( "Run the Python Script" ) );
|
||||||
|
|
||||||
item->SetBitmap( icon_python_small_xpm );
|
item->SetBitmap( icon_python_small_xpm );
|
||||||
menu->Append( item );
|
menu->Append( item );
|
||||||
#endif
|
#endif /* KICAD_PYTHON */
|
||||||
|
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_TXTEDIT,
|
|
||||||
_( "&Edit in a text editor" ),
|
|
||||||
_( "&Open the file in a Text Editor" ) );
|
|
||||||
|
|
||||||
item->SetBitmap( icon_txt_xpm );
|
// ID_PROJECT_TXTEDIT
|
||||||
menu->Append( item );
|
item = new wxMenuItem( menu,
|
||||||
|
ID_PROJECT_TXTEDIT,
|
||||||
|
_( "&Edit in a text editor" ),
|
||||||
|
_( "&Open the file in a Text Editor" ) );
|
||||||
|
item->SetBitmap( icon_txt_xpm );
|
||||||
|
menu->Append( item );
|
||||||
|
|
||||||
// New files context menu:
|
|
||||||
wxMenu* menus[2];
|
// New files context menu:
|
||||||
menus[0] = m_ContextMenus[TREE_DIRECTORY];
|
wxMenu* menus[2];
|
||||||
menus[1] = m_ContextMenus[TREE_PROJECT];
|
menus[0] = m_ContextMenus[TREE_DIRECTORY];
|
||||||
|
menus[1] = m_ContextMenus[TREE_PROJECT];
|
||||||
|
|
||||||
for( int i = 0; i < 2; i++ )
|
for( int i = 0; i < 2; i++ )
|
||||||
{
|
{
|
||||||
menu = menus[i];
|
menu = menus[i];
|
||||||
|
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_NEWDIR, _( "New D&irectory" ), _(
|
// ID_PROJECT_NEWDIR
|
||||||
"Create a New Directory" ) );
|
item = new wxMenuItem( menu,
|
||||||
|
ID_PROJECT_NEWDIR,
|
||||||
|
_( "New D&irectory" ),
|
||||||
|
_( "Create a New Directory" ) );
|
||||||
|
item->SetBitmap( directory_xpm );
|
||||||
|
menu->Append( item );
|
||||||
|
|
||||||
item->SetBitmap( directory_xpm );
|
|
||||||
menu->Append( item );
|
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_NEWPY, _( "New P&ython Script" ), _(
|
|
||||||
"Create a New Python Script" ) );
|
|
||||||
|
|
||||||
|
// ID_PROJECT_NEWPY
|
||||||
|
#ifdef KICAD_PYTHON
|
||||||
|
item = new wxMenuItem( menu,
|
||||||
|
ID_PROJECT_NEWPY,
|
||||||
|
_( "New P&ython Script" ),
|
||||||
|
_( "Create a New Python Script" ) );
|
||||||
item->SetBitmap( new_python_xpm );
|
item->SetBitmap( new_python_xpm );
|
||||||
menu->Append( item );
|
menu->Append( item );
|
||||||
#endif
|
#endif /* KICAD_PYTHON */
|
||||||
|
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_NEWTXT, _( "New &Text File" ), _(
|
|
||||||
"Create a New Txt File" ) );
|
|
||||||
|
|
||||||
item->SetBitmap( new_txt_xpm );
|
// ID_PROJECT_NEWTXT
|
||||||
menu->Append( item );
|
item = new wxMenuItem( menu,
|
||||||
|
ID_PROJECT_NEWTXT,
|
||||||
|
_( "New &Text File" ),
|
||||||
|
_( "Create a New Txt File" ) );
|
||||||
|
item->SetBitmap( new_txt_xpm );
|
||||||
|
menu->Append( item );
|
||||||
|
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_NEWFILE, _( "New &File" ), _( "Create a New File" ) );
|
|
||||||
|
|
||||||
item->SetBitmap( new_xpm );
|
// ID_PROJECT_NEWFILE
|
||||||
menu->Append( item );
|
item = new wxMenuItem( menu,
|
||||||
|
ID_PROJECT_NEWFILE,
|
||||||
|
_( "New &File" ),
|
||||||
|
_( "Create a New File" ) );
|
||||||
|
item->SetBitmap( new_xpm );
|
||||||
|
menu->Append( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Put the Rename and Delete file menu commands:
|
// Put the Rename and Delete file menu commands:
|
||||||
for( int i = TREE_PROJECT + 1; i < TREE_MAX; i++ )
|
for( int i = TREE_PROJECT + 1; i < TREE_MAX; i++ )
|
||||||
{
|
{
|
||||||
menu = m_ContextMenus[i];
|
menu = m_ContextMenus[i];
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_RENAME,
|
|
||||||
TREE_DIRECTORY != i ? _ ("&Rename file") : _( "&Rename directory" ),
|
|
||||||
TREE_DIRECTORY != i ? _ ("Rename file") : _( "&Rename directory" ) );
|
|
||||||
|
|
||||||
|
|
||||||
|
// ID_PROJECT_RENAME
|
||||||
|
item = new wxMenuItem( menu,
|
||||||
|
ID_PROJECT_RENAME,
|
||||||
|
TREE_DIRECTORY != i ? _ ("&Rename file") :
|
||||||
|
_( "&Rename directory" ),
|
||||||
|
TREE_DIRECTORY != i ? _ ("Rename file") :
|
||||||
|
_( "&Rename directory" ) );
|
||||||
item->SetBitmap( right_xpm );
|
item->SetBitmap( right_xpm );
|
||||||
menu->Append( item );
|
menu->Append( item );
|
||||||
|
|
||||||
|
|
||||||
if( TREE_DIRECTORY != i )
|
if( TREE_DIRECTORY != i )
|
||||||
{
|
{
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_TXTEDIT,
|
// ID_PROJECT_TXTEDIT
|
||||||
_( "&Edit in a text editor" ),
|
item = new wxMenuItem( menu,
|
||||||
_( "Open the file in a Text Editor" ) );
|
ID_PROJECT_TXTEDIT,
|
||||||
|
_( "&Edit in a text editor" ),
|
||||||
|
_( "Open the file in a Text Editor" ) );
|
||||||
item->SetBitmap( icon_txt_xpm );
|
item->SetBitmap( icon_txt_xpm );
|
||||||
menu->Append( item );
|
menu->Append( item );
|
||||||
}
|
}
|
||||||
item = new wxMenuItem( menu, ID_PROJECT_DELETE,
|
|
||||||
TREE_DIRECTORY != i ? _ ("&Delete File") : _( "&Delete Directory" ),
|
|
||||||
TREE_DIRECTORY != i ? _ ("Delete the File") : _(
|
|
||||||
"&Delete the Directory and its content" ) );
|
|
||||||
|
|
||||||
|
// ID_PROJECT_DELETE
|
||||||
|
item = new wxMenuItem( menu,
|
||||||
|
ID_PROJECT_DELETE,
|
||||||
|
TREE_DIRECTORY != i ? _( "&Delete File" ) :
|
||||||
|
_( "&Delete Directory" ),
|
||||||
|
TREE_DIRECTORY != i ? _( "Delete the File" ) :
|
||||||
|
_( "&Delete the Directory and its content" ) );
|
||||||
item->SetBitmap( delete_xpm );
|
item->SetBitmap( delete_xpm );
|
||||||
menu->Append( item );
|
menu->Append( item );
|
||||||
}
|
}
|
||||||
|
|
||||||
ReCreateTreePrj();
|
ReCreateTreePrj();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
BEGIN_EVENT_TABLE( WinEDA_PrjFrame, wxSashLayoutWindow )
|
BEGIN_EVENT_TABLE( WinEDA_PrjFrame, wxSashLayoutWindow )
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
EVT_TREE_BEGIN_LABEL_EDIT( ID_PROJECT_TREE, WinEDA_PrjFrame::OnRenameAsk )
|
EVT_TREE_BEGIN_LABEL_EDIT( ID_PROJECT_TREE, WinEDA_PrjFrame::OnRenameAsk )
|
||||||
EVT_TREE_END_LABEL_EDIT( ID_PROJECT_TREE, WinEDA_PrjFrame::OnRename )
|
EVT_TREE_END_LABEL_EDIT( ID_PROJECT_TREE, WinEDA_PrjFrame::OnRename )
|
||||||
|
@ -188,25 +231,35 @@ EVT_MENU( ID_PROJECT_NEWTXT, WinEDA_PrjFrame::OnNewTxtFile )
|
||||||
EVT_MENU( ID_PROJECT_DELETE, WinEDA_PrjFrame::OnDeleteFile )
|
EVT_MENU( ID_PROJECT_DELETE, WinEDA_PrjFrame::OnDeleteFile )
|
||||||
EVT_MENU( ID_PROJECT_RENAME, WinEDA_PrjFrame::OnRenameFile )
|
EVT_MENU( ID_PROJECT_RENAME, WinEDA_PrjFrame::OnRenameFile )
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
|
||||||
EVT_MENU( ID_PROJECT_RUNPY, WinEDA_PrjFrame::OnRunPy )
|
|
||||||
#endif
|
|
||||||
END_EVENT_TABLE()
|
|
||||||
|
|
||||||
/********************************/
|
#ifdef KICAD_PYTHON
|
||||||
|
EVT_MENU( ID_PROJECT_RUNPY, WinEDA_PrjFrame::OnRunPy )
|
||||||
|
#endif /* KICAD_PYTHON */
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
|
END_EVENT_TABLE()
|
||||||
|
/*****************************************************************************/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*****************************************************************************/
|
||||||
WinEDA_TreePrj::~WinEDA_TreePrj()
|
WinEDA_TreePrj::~WinEDA_TreePrj()
|
||||||
/********************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************/
|
|
||||||
void WinEDA_PrjFrame::OnDragStart( wxTreeEvent& event )
|
|
||||||
/*******************************************************/
|
|
||||||
|
|
||||||
// Allowing drag&drop of file other than the currently opened project
|
/**
|
||||||
|
* @brief Allowing drag & drop of file other than the currently opened project
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void WinEDA_PrjFrame::OnDragStart( wxTreeEvent& event )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
/* Ensure item is selected (Under Windows start drag does not activate the item) */
|
/* Ensure item is selected
|
||||||
|
(Under Windows start drag does not activate the item) */
|
||||||
wxTreeItemId curr_item = event.GetItem();
|
wxTreeItemId curr_item = event.GetItem();
|
||||||
|
|
||||||
m_TreeProject->SelectItem( curr_item );
|
m_TreeProject->SelectItem( curr_item );
|
||||||
|
@ -224,9 +277,10 @@ void WinEDA_PrjFrame::OnDragStart( wxTreeEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************/
|
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnDragEnd( wxTreeEvent& event )
|
void WinEDA_PrjFrame::OnDragEnd( wxTreeEvent& event )
|
||||||
/*******************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
m_Parent->SetCursor( wxNullCursor );
|
m_Parent->SetCursor( wxNullCursor );
|
||||||
|
|
||||||
|
@ -261,17 +315,18 @@ void WinEDA_PrjFrame::OnDragEnd( wxTreeEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************************/
|
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::ClearFilters()
|
void WinEDA_PrjFrame::ClearFilters()
|
||||||
/************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
m_Filters.clear();
|
m_Filters.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************/
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::RemoveFilter( const wxString& filter )
|
void WinEDA_PrjFrame::RemoveFilter( const wxString& filter )
|
||||||
/*************************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
for( unsigned int i = 0; i < m_Filters.size(); i++ )
|
for( unsigned int i = 0; i < m_Filters.size(); i++ )
|
||||||
{
|
{
|
||||||
|
@ -284,13 +339,17 @@ void WinEDA_PrjFrame::RemoveFilter( const wxString& filter )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
#ifdef KICAD_PYTHON
|
||||||
|
|
||||||
/********************************************************************************/
|
|
||||||
TreePrjItemData* WinEDA_PrjFrame::FindItemData( const boost::python::str& name )
|
|
||||||
/********************************************************************************/
|
|
||||||
|
|
||||||
// Return the data corresponding to the file, or NULL
|
|
||||||
|
/**
|
||||||
|
* @brief Return the data corresponding to the file, or NULL
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
TreePrjItemData* WinEDA_PrjFrame::FindItemData(const boost::python::str& name)
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
// (Interative tree parsing)
|
// (Interative tree parsing)
|
||||||
std::vector< wxTreeItemId > roots1, roots2;
|
std::vector< wxTreeItemId > roots1, roots2;
|
||||||
|
@ -345,88 +404,140 @@ TreePrjItemData* WinEDA_PrjFrame::FindItemData( const boost::python::str& name )
|
||||||
reserve = tmp;
|
reserve = tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
void WinEDA_PrjFrame::RemoveFilterPy( const boost::python::str& filter )
|
/**
|
||||||
/******************************************************************/
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void WinEDA_PrjFrame::RemoveFilterPy(const boost::python::str& filter)
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
RemoveFilter( PyHandler::MakeStr( filter ) );
|
RemoveFilter( PyHandler::MakeStr( filter ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::AddFilter( const boost::python::str& filter )
|
void WinEDA_PrjFrame::AddFilter( const boost::python::str& filter )
|
||||||
/******************************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxRegEx reg;
|
wxRegEx reg;
|
||||||
wxString text = PyHandler::MakeStr( filter );
|
wxString text = PyHandler::MakeStr( filter );
|
||||||
|
|
||||||
if( !reg.Compile( text ) )
|
if( !reg.Compile( text ) )
|
||||||
return;
|
return;
|
||||||
m_Filters.push_back( text );
|
m_Filters.push_back( text );
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif /* KICAD_PYTHON */
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
const std::vector<wxString>& WinEDA_PrjFrame::GetFilters()
|
const std::vector<wxString>& WinEDA_PrjFrame::GetFilters()
|
||||||
/******************************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
return m_Filters;
|
return m_Filters;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
wxMenu* WinEDA_PrjFrame::GetContextMenu( int type )
|
wxMenu* WinEDA_PrjFrame::GetContextMenu( int type )
|
||||||
/******************************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
return m_ContextMenus[type];
|
return m_ContextMenus[type];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnNewDirectory( wxCommandEvent& event )
|
void WinEDA_PrjFrame::OnNewDirectory( wxCommandEvent& event )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
NewFile( TREE_DIRECTORY );
|
NewFile( TREE_DIRECTORY );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnNewFile( wxCommandEvent& event )
|
void WinEDA_PrjFrame::OnNewFile( wxCommandEvent& event )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
NewFile( TREE_UNKNOWN );
|
NewFile( TREE_UNKNOWN );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnNewPyFile( wxCommandEvent& event )
|
void WinEDA_PrjFrame::OnNewPyFile( wxCommandEvent& event )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
NewFile( TREE_PY );
|
NewFile( TREE_PY );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnNewTxtFile( wxCommandEvent& event )
|
void WinEDA_PrjFrame::OnNewTxtFile( wxCommandEvent& event )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
NewFile( TREE_TXT );
|
NewFile( TREE_TXT );
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::NewFile( TreeFileType type )
|
void WinEDA_PrjFrame::NewFile( TreeFileType type )
|
||||||
/******************************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxString filename;
|
wxString filename;
|
||||||
wxString mask = GetFileExt( type );
|
wxString mask = GetFileExt( type );
|
||||||
const wxString sep = wxFileName().GetPathSeparator();
|
const wxString sep = wxFileName().GetPathSeparator();
|
||||||
|
|
||||||
// Get the directory:
|
// Get the directory:
|
||||||
wxString dir;
|
wxString dir;
|
||||||
|
|
||||||
TreePrjItemData* treeData;
|
TreePrjItemData* treeData;
|
||||||
wxString FullFileName;
|
wxString FullFileName;
|
||||||
|
|
||||||
treeData = GetSelectedData();
|
|
||||||
if( !treeData )
|
|
||||||
return;
|
|
||||||
|
|
||||||
dir = treeData->GetDir();
|
treeData = GetSelectedData();
|
||||||
|
if( !treeData )
|
||||||
|
return;
|
||||||
|
|
||||||
// Ask for the new file name
|
dir = treeData->GetDir();
|
||||||
|
|
||||||
filename = EDA_FileSelector( TREE_DIRECTORY !=
|
// Ask for the new file name
|
||||||
|
filename = EDA_FileSelector( TREE_DIRECTORY !=
|
||||||
type ? _( "Create New File:" ) : _( "Create New Directory" ),
|
type ? _( "Create New File:" ) : _( "Create New Directory" ),
|
||||||
wxGetCwd() + sep + dir, /* Chemin par defaut */
|
wxGetCwd() + sep + dir, /* Chemin par defaut */
|
||||||
_( "noname" ) + mask, /* nom fichier par defaut */
|
_( "noname" ) + mask, /* nom fichier par defaut */
|
||||||
|
@ -436,63 +547,75 @@ void WinEDA_PrjFrame::NewFile( TreeFileType type )
|
||||||
wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
|
wxFD_SAVE | wxFD_OVERWRITE_PROMPT,
|
||||||
TRUE
|
TRUE
|
||||||
);
|
);
|
||||||
if( filename.IsEmpty() )
|
if( filename.IsEmpty() )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
TreeFileType rootType = treeData->GetType();
|
TreeFileType rootType = treeData->GetType();
|
||||||
wxTreeItemId root;
|
wxTreeItemId root;
|
||||||
|
|
||||||
if( TREE_DIRECTORY == rootType )
|
if( TREE_DIRECTORY == rootType )
|
||||||
{
|
{
|
||||||
root = m_TreeProject->GetSelection();
|
root = m_TreeProject->GetSelection();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
root = m_TreeProject->GetItemParent( m_TreeProject->GetSelection() );
|
root = m_TreeProject->GetItemParent( m_TreeProject->GetSelection() );
|
||||||
if( !root.IsOk() )
|
|
||||||
root = m_TreeProject->GetSelection();
|
|
||||||
}
|
|
||||||
|
|
||||||
NewFile( filename, type, root );
|
if( !root.IsOk() )
|
||||||
|
root = m_TreeProject->GetSelection();
|
||||||
|
}
|
||||||
|
|
||||||
|
NewFile( filename, type, root );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::NewFile( const wxString& name,
|
void WinEDA_PrjFrame::NewFile( const wxString& name,
|
||||||
TreeFileType type, wxTreeItemId& root )
|
TreeFileType type,
|
||||||
/******************************************************************/
|
wxTreeItemId& root )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
if( TREE_DIRECTORY != type )
|
if( TREE_DIRECTORY != type )
|
||||||
{
|
{
|
||||||
wxFile( name, wxFile::write );
|
wxFile( name, wxFile::write );
|
||||||
#ifdef KICAD_PYTHON
|
|
||||||
PyHandler::GetInstance()->TriggerEvent(
|
|
||||||
wxT( "kicad::NewFile" ), PyHandler::Convert( name ) );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxMkdir( name );
|
|
||||||
#ifdef KICAD_PYTHON
|
|
||||||
PyHandler::GetInstance()->TriggerEvent(
|
|
||||||
wxT( "kicad::NewDirectory" ), PyHandler::Convert( name ) );
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
|
|
||||||
AddFile( name, root );
|
#ifdef KICAD_PYTHON
|
||||||
|
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::NewFile" ),
|
||||||
|
PyHandler::Convert( name ) );
|
||||||
|
#endif /* KICAD_PYTHON */
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxMkdir( name );
|
||||||
|
|
||||||
|
#ifdef KICAD_PYTHON
|
||||||
|
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::NewDirectory" ),
|
||||||
|
PyHandler::Convert( name ) );
|
||||||
|
#endif /* KICAD_PYTHON */
|
||||||
|
}
|
||||||
|
|
||||||
|
AddFile( name, root );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
wxString WinEDA_PrjFrame::GetFileExt( TreeFileType type )
|
wxString WinEDA_PrjFrame::GetFileExt( TreeFileType type )
|
||||||
/******************************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxString ext;
|
wxString ext;
|
||||||
|
|
||||||
switch( type )
|
switch( type )
|
||||||
{
|
{
|
||||||
case 0:
|
case 0: // 0 is not used
|
||||||
break; // 0 is not used
|
break;
|
||||||
|
|
||||||
case TREE_PROJECT:
|
case TREE_PROJECT:
|
||||||
ext = wxT( ".pro" );
|
ext = wxT( ".pro" );
|
||||||
|
@ -534,13 +657,15 @@ wxString WinEDA_PrjFrame::GetFileExt( TreeFileType type )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************/
|
|
||||||
bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root )
|
|
||||||
/**************************************************************************/
|
|
||||||
|
|
||||||
/* add filename "name" to the tree
|
/**
|
||||||
* if name is a directory, add the sub directory file names
|
* @brief Add filename "name" to the tree \n
|
||||||
|
* if name is a directory, add the sub directory file names
|
||||||
|
* @return TODO
|
||||||
*/
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxTreeItemId cellule;
|
wxTreeItemId cellule;
|
||||||
|
|
||||||
|
@ -549,7 +674,7 @@ bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root )
|
||||||
|
|
||||||
if( wxDirExists( name ) )
|
if( wxDirExists( name ) )
|
||||||
{
|
{
|
||||||
type = TREE_DIRECTORY;
|
type = TREE_DIRECTORY;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -586,8 +711,7 @@ bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root )
|
||||||
fp = wxFopen( FullFileName, wxT( "rt" ) );
|
fp = wxFopen( FullFileName, wxT( "rt" ) );
|
||||||
if( fp == NULL )
|
if( fp == NULL )
|
||||||
{
|
{
|
||||||
//printf("Unable to open \"%s\"\n", (const char*) FullFileName.mb_str() );
|
return false;
|
||||||
return false; // why show a file we cannot open?
|
|
||||||
}
|
}
|
||||||
|
|
||||||
addFile = false;
|
addFile = false;
|
||||||
|
@ -640,8 +764,8 @@ bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root )
|
||||||
}
|
}
|
||||||
kid = m_TreeProject->GetNextChild(root, cookie);
|
kid = m_TreeProject->GetNextChild(root, cookie);
|
||||||
}
|
}
|
||||||
// Append the item (only appending the filename not the full path):
|
|
||||||
|
|
||||||
|
// Append the item (only appending the filename not the full path):
|
||||||
wxString file = wxFileNameFromPath( name );
|
wxString file = wxFileNameFromPath( name );
|
||||||
cellule = m_TreeProject->AppendItem( root, file );
|
cellule = m_TreeProject->AppendItem( root, file );
|
||||||
TreePrjItemData* data = new TreePrjItemData( type, name, m_TreeProject );
|
TreePrjItemData* data = new TreePrjItemData( type, name, m_TreeProject );
|
||||||
|
@ -659,41 +783,49 @@ bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root )
|
||||||
else
|
else
|
||||||
data->m_IsRootFile = false;
|
data->m_IsRootFile = false;
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
|
||||||
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::TreeAddFile" ), PyHandler::Convert( name ) );
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef ADD_FILES_IN_SUBDIRS
|
#ifdef KICAD_PYTHON
|
||||||
|
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::TreeAddFile" ),
|
||||||
|
PyHandler::Convert( name ) );
|
||||||
|
#endif /* KICAD_YTHON */
|
||||||
|
|
||||||
|
|
||||||
// When enabled This section adds dirs and files found in the subdirs
|
// When enabled This section adds dirs and files found in the subdirs
|
||||||
// in this case AddFile is recursive.
|
// in this case AddFile is recursive.
|
||||||
if( TREE_DIRECTORY == type )
|
#ifdef ADD_FILES_IN_SUBDIRS
|
||||||
{
|
if( TREE_DIRECTORY == type )
|
||||||
|
{
|
||||||
const wxString sep = wxFileName().GetPathSeparator();
|
const wxString sep = wxFileName().GetPathSeparator();
|
||||||
wxDir dir( name );
|
wxDir dir( name );
|
||||||
|
|
||||||
wxString dir_filename;
|
wxString dir_filename;
|
||||||
|
|
||||||
if( dir.GetFirst( &dir_filename ) )
|
if( dir.GetFirst( &dir_filename ) )
|
||||||
{
|
{
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
AddFile( name + sep + dir_filename, cellule );
|
AddFile( name + sep + dir_filename, cellule );
|
||||||
} while( dir.GetNext( &dir_filename ) );
|
}
|
||||||
|
while( dir.GetNext( &dir_filename ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Sort filenames by alphabetic order */
|
/* Sort filenames by alphabetic order */
|
||||||
m_TreeProject->SortChildren( cellule );
|
m_TreeProject->SortChildren( cellule );
|
||||||
}
|
}
|
||||||
#endif
|
#endif /* ADD_FILES_IN_SUBDIRS */
|
||||||
return true;
|
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/******************************************/
|
|
||||||
void WinEDA_PrjFrame::ReCreateTreePrj()
|
|
||||||
/******************************************/
|
|
||||||
|
|
||||||
/* Create or modify the tree showing project file names
|
/**
|
||||||
|
* @brief Create or modify the tree showing project file names
|
||||||
|
* @return TODO
|
||||||
*/
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void WinEDA_PrjFrame::ReCreateTreePrj()
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxTreeItemId rootcellule;
|
wxTreeItemId rootcellule;
|
||||||
wxString Text;
|
wxString Text;
|
||||||
|
@ -760,11 +892,13 @@ void WinEDA_PrjFrame::ReCreateTreePrj()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************/
|
|
||||||
void WinEDA_PrjFrame::OnRight( wxTreeEvent& Event )
|
|
||||||
/**************************************************/
|
|
||||||
|
|
||||||
// Opens (popup) the context menu
|
/**
|
||||||
|
* @brief Opens *popup* the context menu
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
void WinEDA_PrjFrame::OnRight( wxTreeEvent& Event )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
int tree_id;
|
int tree_id;
|
||||||
TreePrjItemData* tree_data;
|
TreePrjItemData* tree_data;
|
||||||
|
@ -819,19 +953,25 @@ void WinEDA_PrjFrame::OnRight( wxTreeEvent& Event )
|
||||||
|
|
||||||
// At last, call python to let python add menu items "on the fly"
|
// At last, call python to let python add menu items "on the fly"
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
|
||||||
|
#ifdef KICAD_PYTHON
|
||||||
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::TreeContextMenu" ),
|
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::TreeContextMenu" ),
|
||||||
PyHandler::Convert( FullFileName ) );
|
PyHandler::Convert( FullFileName ) );
|
||||||
#endif
|
#endif /* KICAD_PYTHON */
|
||||||
|
|
||||||
if( m_PopupMenu )
|
|
||||||
PopupMenu( m_PopupMenu );
|
if( m_PopupMenu )
|
||||||
|
PopupMenu( m_PopupMenu );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*******************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnTxtEdit( wxCommandEvent& event )
|
void WinEDA_PrjFrame::OnTxtEdit( wxCommandEvent& event )
|
||||||
/*******************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
TreePrjItemData* tree_data = GetSelectedData();
|
TreePrjItemData* tree_data = GetSelectedData();
|
||||||
|
|
||||||
|
@ -841,55 +981,70 @@ void WinEDA_PrjFrame::OnTxtEdit( wxCommandEvent& event )
|
||||||
wxString FullFileName = tree_data->GetFileName();
|
wxString FullFileName = tree_data->GetFileName();
|
||||||
AddDelimiterString( FullFileName );
|
AddDelimiterString( FullFileName );
|
||||||
wxString editorname = GetEditorName();
|
wxString editorname = GetEditorName();
|
||||||
|
|
||||||
if( !editorname.IsEmpty() )
|
if( !editorname.IsEmpty() )
|
||||||
{
|
{
|
||||||
#ifdef KICAD_PYTHON
|
|
||||||
|
#ifdef KICAD_PYTHON
|
||||||
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::EditScript" ),
|
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::EditScript" ),
|
||||||
PyHandler::Convert( FullFileName ) );
|
PyHandler::Convert( FullFileName ) );
|
||||||
#endif
|
#endif
|
||||||
ExecuteFile( this, editorname, FullFileName );
|
|
||||||
|
ExecuteFile( this, editorname, FullFileName );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnDeleteFile( wxCommandEvent& )
|
void WinEDA_PrjFrame::OnDeleteFile( wxCommandEvent& )
|
||||||
/***************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
TreePrjItemData* tree_data = GetSelectedData();
|
TreePrjItemData* tree_data = GetSelectedData();
|
||||||
|
|
||||||
if( !tree_data )
|
if( !tree_data )
|
||||||
return;
|
return;
|
||||||
tree_data->Delete();
|
tree_data->Delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnRenameFile( wxCommandEvent& )
|
void WinEDA_PrjFrame::OnRenameFile( wxCommandEvent& )
|
||||||
/***************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxTreeItemId curr_item = m_TreeProject->GetSelection();
|
wxTreeItemId curr_item = m_TreeProject->GetSelection();
|
||||||
TreePrjItemData* tree_data = GetSelectedData();
|
TreePrjItemData* tree_data = GetSelectedData();
|
||||||
|
|
||||||
if( !tree_data )
|
if( !tree_data )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString buffer = m_TreeProject->GetItemText( curr_item );
|
wxString buffer = m_TreeProject->GetItemText( curr_item );
|
||||||
wxString msg = _( "Change filename: " ) + tree_data->m_FileName;
|
wxString msg = _( "Change filename: " ) + tree_data->m_FileName;
|
||||||
if( Get_Message(msg, _("Change filename"), buffer, this ) != 0 )
|
|
||||||
return; //Abort command
|
|
||||||
|
|
||||||
if( tree_data->Rename( buffer, true ) )
|
if( Get_Message(msg, _("Change filename"), buffer, this ) != 0 )
|
||||||
{
|
return; //Abort command
|
||||||
m_TreeProject->SetItemText( curr_item, buffer );
|
|
||||||
}
|
if( tree_data->Rename( buffer, true ) )
|
||||||
|
m_TreeProject->SetItemText( curr_item, buffer );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#ifdef KICAD_PYTHON
|
#ifdef KICAD_PYTHON
|
||||||
/***************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnRunPy( wxCommandEvent& event )
|
void WinEDA_PrjFrame::OnRunPy( wxCommandEvent& event )
|
||||||
/***************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
TreePrjItemData* tree_data = GetSelectedData();
|
TreePrjItemData* tree_data = GetSelectedData();
|
||||||
|
|
||||||
|
@ -898,19 +1053,22 @@ void WinEDA_PrjFrame::OnRunPy( wxCommandEvent& event )
|
||||||
|
|
||||||
wxString FullFileName = tree_data->GetFileName();
|
wxString FullFileName = tree_data->GetFileName();
|
||||||
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::RunScript" ),
|
PyHandler::GetInstance()->TriggerEvent( wxT( "kicad::RunScript" ),
|
||||||
PyHandler::Convert( FullFileName ) );
|
PyHandler::Convert( FullFileName ) );
|
||||||
PyHandler::GetInstance()->RunScript( FullFileName );
|
PyHandler::GetInstance()->RunScript( FullFileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/****************************************************************/
|
|
||||||
int WinEDA_PrjFrame::AddStatePy( boost::python::object& bitmap )
|
|
||||||
/****************************************************************/
|
|
||||||
|
|
||||||
// Add a state to the image list ...
|
/**
|
||||||
|
* @brief Add a state to the image list
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
|
int WinEDA_PrjFrame::AddStatePy( boost::python::object& bitmap )
|
||||||
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxBitmap* image;
|
wxBitmap* image;
|
||||||
bool success = wxPyConvertSwigPtr( bitmap.ptr(), (void**) &image, _T( "wxBitmap" ) );
|
bool success = wxPyConvertSwigPtr( bitmap.ptr(),
|
||||||
|
(void**) &image, _T( "wxBitmap" ) );
|
||||||
|
|
||||||
if( !success )
|
if( !success )
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -931,13 +1089,16 @@ int WinEDA_PrjFrame::AddStatePy( boost::python::object& bitmap )
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#endif /* KICAD_PYTHON */
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
/***************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief Prevent the main project to be renamed
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnRenameAsk( wxTreeEvent& event )
|
void WinEDA_PrjFrame::OnRenameAsk( wxTreeEvent& event )
|
||||||
/***************************************************/
|
/*****************************************************************************/
|
||||||
/* Prevent the main project to be renamed */
|
|
||||||
{
|
{
|
||||||
TreePrjItemData* tree_data = GetSelectedData();
|
TreePrjItemData* tree_data = GetSelectedData();
|
||||||
|
|
||||||
|
@ -948,10 +1109,13 @@ void WinEDA_PrjFrame::OnRenameAsk( wxTreeEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/***************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief Rename a tree item on demand of the context menu
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnRename( wxTreeEvent& event )
|
void WinEDA_PrjFrame::OnRename( wxTreeEvent& event )
|
||||||
/***************************************************/
|
/*****************************************************************************/
|
||||||
/* rename a tree item on demand of the context menu */
|
|
||||||
{
|
{
|
||||||
TreePrjItemData* tree_data = GetSelectedData();
|
TreePrjItemData* tree_data = GetSelectedData();
|
||||||
|
|
||||||
|
@ -962,15 +1126,19 @@ void WinEDA_PrjFrame::OnRename( wxTreeEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**************************************************/
|
|
||||||
|
/**
|
||||||
|
* @brief TODO
|
||||||
|
*/
|
||||||
|
/*****************************************************************************/
|
||||||
void WinEDA_PrjFrame::OnSelect( wxTreeEvent& Event )
|
void WinEDA_PrjFrame::OnSelect( wxTreeEvent& Event )
|
||||||
/**************************************************/
|
/*****************************************************************************/
|
||||||
{
|
{
|
||||||
wxString FullFileName;
|
wxString FullFileName;
|
||||||
|
|
||||||
TreePrjItemData* tree_data = GetSelectedData();
|
TreePrjItemData* tree_data = GetSelectedData();
|
||||||
|
|
||||||
if( !tree_data )
|
if( !tree_data )
|
||||||
return;
|
return;
|
||||||
tree_data->Activate(this);
|
tree_data->Activate(this);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue