Kicad: files renaming and code cleaning

This commit is contained in:
charras 2010-02-19 15:01:32 +00:00
parent a70a580596
commit 7a19adfcdb
9 changed files with 234 additions and 226 deletions

View File

@ -5,6 +5,7 @@ include_directories(${CMAKE_CURRENT_SOURCE_DIR}
) )
set(KICAD_SRCS set(KICAD_SRCS
class_treeprojectfiles.cpp
commandframe.cpp commandframe.cpp
files-io.cpp files-io.cpp
kicad.cpp kicad.cpp
@ -13,8 +14,7 @@ set(KICAD_SRCS
menubar.cpp menubar.cpp
preferences.cpp preferences.cpp
prjconfig.cpp prjconfig.cpp
treeprj_datas.cpp tree_project_frame.cpp)
treeprj_frame.cpp)
if(WIN32) if(WIN32)
if(MINGW) if(MINGW)

View File

@ -1,6 +1,6 @@
/***************/ /*
/* treeprj.cpp */ * file class_treeprojectfiles.cpp
/***************/ */
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
#include <pyhandler.h> #include <pyhandler.h>
@ -14,6 +14,8 @@
#include "bitmaps.h" #include "bitmaps.h"
#include "kicad.h" #include "kicad.h"
#include "tree_project_frame.h"
#include "class_treeprojectfiles.h"
#include "wx/image.h" #include "wx/image.h"
#include "wx/imaglist.h" #include "wx/imaglist.h"
@ -22,10 +24,10 @@
#include "wx/dir.h" #include "wx/dir.h"
IMPLEMENT_ABSTRACT_CLASS( WinEDA_TreePrj, wxTreeCtrl ) IMPLEMENT_ABSTRACT_CLASS( TREEPROJECTFILES, wxTreeCtrl )
WinEDA_TreePrj::WinEDA_TreePrj( WinEDA_PrjFrame* parent ) : TREEPROJECTFILES::TREEPROJECTFILES( TREE_PROJECT_FRAME* parent ) :
wxTreeCtrl( parent, ID_PROJECT_TREE, wxTreeCtrl( parent, ID_PROJECT_TREE,
wxDefaultPosition, wxDefaultSize, wxDefaultPosition, wxDefaultSize,
wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS, wxDefaultValidator, wxTR_HAS_BUTTONS | wxTR_EDIT_LABELS, wxDefaultValidator,
@ -51,7 +53,7 @@ WinEDA_TreePrj::WinEDA_TreePrj( WinEDA_PrjFrame* parent ) :
} }
WinEDA_TreePrj::~WinEDA_TreePrj() TREEPROJECTFILES::~TREEPROJECTFILES()
{ {
if( m_ImageList ) if( m_ImageList )
delete m_ImageList; delete m_ImageList;
@ -64,7 +66,7 @@ WinEDA_TreePrj::~WinEDA_TreePrj()
* root file names after * root file names after
* file names last by alphabetic order * file names last by alphabetic order
*/ */
int WinEDA_TreePrj::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 ) int TREEPROJECTFILES::OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 )
{ {
TreePrjItemData* myitem1 = (TreePrjItemData*) GetItemData( item1 ); TreePrjItemData* myitem1 = (TreePrjItemData*) GetItemData( item1 );
TreePrjItemData* myitem2 = (TreePrjItemData*) GetItemData( item2 ); TreePrjItemData* myitem2 = (TreePrjItemData*) GetItemData( item2 );
@ -235,7 +237,7 @@ void TreePrjItemData::Move( TreePrjItemData* dest )
// We should move recursively all files, but that's quite boring // We should move recursively all files, but that's quite boring
// let's just refresh that's all ... TODO (change this to a better code ...) // let's just refresh that's all ... TODO (change this to a better code ...)
wxCommandEvent dummy; wxCommandEvent dummy;
dynamic_cast<WinEDA_TreePrj*>( m_Parent )->GetParent()->m_Parent->OnRefresh( dummy ); dynamic_cast<TREEPROJECTFILES*>( m_Parent )->GetParent()->m_Parent->OnRefresh( dummy );
} }
} }
@ -262,7 +264,7 @@ bool TreePrjItemData::Rename( const wxString& name, bool check )
if( newFile == m_FileName ) if( newFile == m_FileName )
return false; return false;
wxString ext = WinEDA_PrjFrame::GetFileExt( GetType() ); wxString ext = TREE_PROJECT_FRAME::GetFileExt( GetType() );
wxRegEx reg( wxT ( "^.*\\" ) + ext + wxT( "$" ), wxRE_ICASE ); wxRegEx reg( wxT ( "^.*\\" ) + ext + wxT( "$" ), wxRE_ICASE );
@ -339,7 +341,7 @@ bool TreePrjItemData::Delete( bool check )
/* Called under item activation */ /* Called under item activation */
void TreePrjItemData::Activate( WinEDA_PrjFrame* prjframe ) void TreePrjItemData::Activate( TREE_PROJECT_FRAME* prjframe )
{ {
wxString sep = wxFileName().GetPathSeparator(); wxString sep = wxFileName().GetPathSeparator();
wxString FullFileName = GetFileName(); wxString FullFileName = GetFileName();
@ -434,7 +436,7 @@ void TreePrjItemData::Activate( WinEDA_PrjFrame* prjframe )
} }
TreePrjItemData* WinEDA_PrjFrame::GetSelectedData() TreePrjItemData* TREE_PROJECT_FRAME::GetSelectedData()
{ {
return dynamic_cast<TreePrjItemData*>( m_TreeProject->GetItemData( m_TreeProject->GetSelection() ) ); return dynamic_cast<TreePrjItemData*>( m_TreeProject->GetItemData( m_TreeProject->GetSelection() ) );
} }

View File

@ -57,7 +57,7 @@ static void WinEDAClear()
static object GetTypeExt( enum TreeFileType type ) static object GetTypeExt( enum TreeFileType type )
{ {
return PyHandler::Convert( WinEDA_PrjFrame::GetFileExt( type ) ); return PyHandler::Convert( TREE_PROJECT_FRAME::GetFileExt( type ) );
} }
@ -78,7 +78,7 @@ object WinEDA_MainFrame::ToWx()
} }
WinEDA_PrjFrame* WinEDA_MainFrame::GetTree() const TREE_PROJECT_FRAME* WinEDA_MainFrame::GetTree() const
{ {
return m_LeftWin; return m_LeftWin;
} }
@ -107,36 +107,36 @@ void WinEDA_MainFrame::AddFastLaunchPy( object& button )
/*****************************************************************************/ /*****************************************************************************/
// WinEDA_PrjFrame Special binding functions: // TREE_PROJECT_FRAME Special binding functions:
// (one line functions are simple wrappers) // (one line functions are simple wrappers)
/*****************************************************************************/ /*****************************************************************************/
// TODO To WxWidgets ? // TODO To WxWidgets ?
object WinEDA_PrjFrame::ToWx() object TREE_PROJECT_FRAME::ToWx()
{ {
return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) ); return object( handle<>( borrowed( wxPyMake_wxObject( this, false ) ) ) );
} }
// TODO Get ? // TODO Get ?
object WinEDA_PrjFrame::GetFtExPy( enum TreeFileType type ) const object TREE_PROJECT_FRAME::GetFtExPy( enum TreeFileType type ) const
{ {
return PyHandler::Convert( GetFileExt( type ) ); return PyHandler::Convert( GetFileExt( type ) );
} }
// Get python menu // Get python menu
object WinEDA_PrjFrame::GetMenuPy( enum TreeFileType type ) object TREE_PROJECT_FRAME::GetMenuPy( enum TreeFileType type )
{ {
return object( handle<>( borrowed( wxPyMake_wxObject( GetContextMenu( (int) type ), false ) ) ) ); return object( handle<>( borrowed( wxPyMake_wxObject( GetContextMenu( (int) type ), false ) ) ) );
} }
// Get tree control // Get tree control
object WinEDA_PrjFrame::GetTreeCtrl() object TREE_PROJECT_FRAME::GetTreeCtrl()
{ {
return object( handle<>( borrowed( wxPyMake_wxObject( m_TreeProject, false ) ) ) ); return object( handle<>( borrowed( wxPyMake_wxObject( m_TreeProject, false ) ) ) );
} }
// Get current menu // Get current menu
object WinEDA_PrjFrame::GetCurrentMenu() object TREE_PROJECT_FRAME::GetCurrentMenu()
{ {
return object( handle<>( borrowed( wxPyMake_wxObject( m_PopupMenu, false ) ) ) ); return object( handle<>( borrowed( wxPyMake_wxObject( m_PopupMenu, false ) ) ) );
} }
@ -146,7 +146,7 @@ object WinEDA_PrjFrame::GetCurrentMenu()
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::NewFilePy( const str& name, void TREE_PROJECT_FRAME::NewFilePy( const str& name,
enum TreeFileType type, enum TreeFileType type,
object& id ) object& id )
/*****************************************************************************/ /*****************************************************************************/
@ -163,7 +163,7 @@ void WinEDA_PrjFrame::NewFilePy( const str& name,
* @brief Add a file to the tree under root, or m_root if conversion is wrong * @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 TREE_PROJECT_FRAME::AddFilePy( const str& file, object& root )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxTreeItemId* theroot = &m_root; wxTreeItemId* theroot = &m_root;
@ -181,7 +181,7 @@ void WinEDA_PrjFrame::AddFilePy( const str& file, object& root )
* @brief convert wxTreeItem into TreePrjItemData * @brief convert wxTreeItem into TreePrjItemData
*/ */
/*****************************************************************************/ /*****************************************************************************/
TreePrjItemData* WinEDA_PrjFrame::GetItemData( const object& item ) TreePrjItemData* TREE_PROJECT_FRAME::GetItemData( const object& item )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxTreeItemId* id = NULL; wxTreeItemId* id = NULL;
@ -269,53 +269,53 @@ static void py_kicad_init()
.value( "MAX", TREE_MAX ); .value( "MAX", TREE_MAX );
class_<WinEDA_PrjFrame>( "TreeWindow" ) class_<TREE_PROJECT_FRAME>( "TreeWindow" )
// wx Interface // wx Interface
.def( "ToWx", &WinEDA_PrjFrame::ToWx ) .def( "ToWx", &TREE_PROJECT_FRAME::ToWx )
// common features // common features
.def( "GetContextMenu", &WinEDA_PrjFrame::GetMenuPy ) .def( "GetContextMenu", &TREE_PROJECT_FRAME::GetMenuPy )
.def( "GetFileExtension", &WinEDA_PrjFrame::GetFtExPy ) .def( "GetFileExtension", &TREE_PROJECT_FRAME::GetFtExPy )
// file filters control // file filters control
.def( "AddFilter", &WinEDA_PrjFrame::AddFilter ) .def( "AddFilter", &TREE_PROJECT_FRAME::AddFilter )
.def( "ClearFilters", &WinEDA_PrjFrame::ClearFilters ) .def( "ClearFilters", &TREE_PROJECT_FRAME::ClearFilters )
.def( "RemoveFilter", &WinEDA_PrjFrame::RemoveFilterPy ) .def( "RemoveFilter", &TREE_PROJECT_FRAME::RemoveFilterPy )
.def( "GetFilters", &WinEDA_PrjFrame::GetFilters, .def( "GetFilters", &TREE_PROJECT_FRAME::GetFilters,
return_value_policy < copy_const_reference >() ) return_value_policy < copy_const_reference >() )
.def( "GetCurrentMenu", &WinEDA_PrjFrame::GetCurrentMenu ) .def( "GetCurrentMenu", &TREE_PROJECT_FRAME::GetCurrentMenu )
/** Project tree control **/ /** Project tree control **/
// AddState // AddState
.def( "AddState", .def( "AddState",
&WinEDA_PrjFrame::AddStatePy ) &TREE_PROJECT_FRAME::AddStatePy )
// GetTreeCtrl // GetTreeCtrl
.def( "GetTreeCtrl", .def( "GetTreeCtrl",
&WinEDA_PrjFrame::GetTreeCtrl ) &TREE_PROJECT_FRAME::GetTreeCtrl )
// GetItemData // GetItemData
.def( "GetItemData", .def( "GetItemData",
&WinEDA_PrjFrame::GetItemData, &TREE_PROJECT_FRAME::GetItemData,
return_value_policy < reference_existing_object >() ) return_value_policy < reference_existing_object >() )
// FindItemData // FindItemData
.def( "FindItemData", .def( "FindItemData",
&WinEDA_PrjFrame::FindItemData, &TREE_PROJECT_FRAME::FindItemData,
return_value_policy < reference_existing_object >() ) return_value_policy < reference_existing_object >() )
// NewFile // NewFile
.def( "NewFile", .def( "NewFile",
&WinEDA_PrjFrame::NewFilePy ) &TREE_PROJECT_FRAME::NewFilePy )
// AddFile // AddFile
.def( "AddFile", .def( "AddFile",
&WinEDA_PrjFrame::AddFilePy ) &TREE_PROJECT_FRAME::AddFilePy )
; /* ENDOF class_<WinEDA_PrjFrame>( "TreeWindow" ) */ ; /* ENDOF class_<TREE_PROJECT_FRAME>( "TreeWindow" ) */
class_<WinEDA_MainFrame>( "MainFrame" ) class_<WinEDA_MainFrame>( "MainFrame" )

View File

@ -6,11 +6,6 @@
*/ */
/*****************************************************************************/ /*****************************************************************************/
#ifdef __GNUG__
#pragma implementation
#endif
#include "fctsys.h" #include "fctsys.h"
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
#include "common.h" #include "common.h"
@ -24,6 +19,7 @@
#endif #endif
#include "kicad.h" #include "kicad.h"
#include "tree_project_frame.h"
#include "macros.h" #include "macros.h"
#include "build_version.h" #include "build_version.h"

View File

@ -20,8 +20,8 @@
#include "appl_wxstruct.h" #include "appl_wxstruct.h"
class RIGHT_KM_FRAME; class RIGHT_KM_FRAME;
class WinEDA_TreePrj; class TREEPROJECTFILES;
class WinEDA_PrjFrame; class TREE_PROJECT_FRAME;
/** /**
@ -67,7 +67,7 @@ class WinEDA_MainFrame : public WinEDA_BasicFrame
{ {
/* This class is the main entry point of the py API */ /* This class is the main entry point of the py API */
public: public:
WinEDA_PrjFrame* m_LeftWin; TREE_PROJECT_FRAME* m_LeftWin;
RIGHT_KM_FRAME* m_RightWin; RIGHT_KM_FRAME* m_RightWin;
WinEDA_Toolbar* m_VToolBar; // Vertical toolbar (not used) WinEDA_Toolbar* m_VToolBar; // Vertical toolbar (not used)
wxString m_BoardFileName; wxString m_BoardFileName;
@ -140,7 +140,7 @@ public:
boost::python::object ToWx(); boost::python::object ToWx();
void AddFastLaunchPy( boost::python::object& button ); void AddFastLaunchPy( boost::python::object& button );
WinEDA_PrjFrame* GetTree() const; TREE_PROJECT_FRAME* GetTree() const;
#endif #endif
@ -247,7 +247,7 @@ public:
bool Rename( const wxString& name, bool check = true ); bool Rename( const wxString& name, bool check = true );
bool Delete( bool check = true ); bool Delete( bool check = true );
void Move( TreePrjItemData* dest ); void Move( TreePrjItemData* dest );
void Activate( WinEDA_PrjFrame* prjframe ); void Activate( TREE_PROJECT_FRAME* prjframe );
const wxMenu* GetMenu() const wxMenu* GetMenu()
{ {
@ -271,132 +271,4 @@ public:
#endif #endif
}; };
/** class WinEDA_PrjFrame
* Window to display the tree files
*/
class WinEDA_PrjFrame : public wxSashLayoutWindow
{
private:
std::vector<wxMenu*> m_ContextMenus;
std::vector<wxString> m_Filters;
wxMenu* m_PopupMenu;
wxCursor m_DragCursor;
wxCursor m_Default;
protected:
wxMenu* GetContextMenu( int type );
void NewFile( TreeFileType type );
void NewFile( const wxString& name, TreeFileType type,
wxTreeItemId& root );
TreePrjItemData* GetSelectedData();
public:
WinEDA_MainFrame* m_Parent;
WinEDA_TreePrj* m_TreeProject;
wxTreeItemId m_root;
public:
static wxString GetFileExt( TreeFileType type );
static wxString GetFileWildcard( TreeFileType type );
WinEDA_PrjFrame( WinEDA_MainFrame* parent );
~WinEDA_PrjFrame();
void OnSelect( wxTreeEvent& Event );
void OnRenameAsk( wxTreeEvent& Event );
void OnRename( wxTreeEvent& Event );
void OnDragStart( wxTreeEvent& event );
void OnDragEnd( wxTreeEvent& event );
void OnRight( wxTreeEvent& Event );
void ReCreateTreePrj();
void OnTxtEdit( wxCommandEvent& event );
void OnDeleteFile( wxCommandEvent& event );
void OnRenameFile( wxCommandEvent& event );
void OnNewFile( wxCommandEvent& event );
void OnNewDirectory( wxCommandEvent& event );
void OnNewSchFile( wxCommandEvent& event );
void OnNewBrdFile( wxCommandEvent& event );
void OnNewPyFile( wxCommandEvent& event );
void OnNewGerberFile( wxCommandEvent& event );
void OnNewTxtFile( wxCommandEvent& event );
void OnNewNetFile( wxCommandEvent& event );
void ClearFilters();
const std::vector<wxString>& GetFilters();
void RemoveFilter( const wxString& filter );
#ifdef KICAD_PYTHON
boost::python::object ToWx();
WinEDA_PrjFrame()
{
}
WinEDA_PrjFrame( const WinEDA_PrjFrame& )
{
}
void OnRunPy( wxCommandEvent& event );
boost::python::object GetMenuPy( TreeFileType );
boost::python::object GetFtExPy( TreeFileType ) const;
void RemoveFilterPy( const boost::python::str& filter );
void AddFilter( const boost::python::str& filter );
boost::python::object GetTreeCtrl();
TreePrjItemData* GetItemData( const boost::python::object& item );
void AddFilePy( const boost::python::str& name,
boost::python::object& root );
void NewFilePy( const boost::python::str& name,
TreeFileType type,
boost::python::object& root );
TreePrjItemData* FindItemData( const boost::python::str& name );
boost::python::object GetCurrentMenu();
int AddStatePy( boost::python::object& bitmap );
#endif
bool AddFile( const wxString& name, wxTreeItemId& root );
DECLARE_EVENT_TABLE()
};
/** Class TreeCtrl
* This is the class to show (as a tree) the files in the project directory
*/
class WinEDA_TreePrj : public wxTreeCtrl
{
DECLARE_DYNAMIC_CLASS( WinEDA_TreePrj )
private:
WinEDA_PrjFrame* m_Parent;
wxImageList* m_ImageList;
public:
WinEDA_PrjFrame* GetParent()
{
return m_Parent;
}
WinEDA_TreePrj( WinEDA_PrjFrame* parent );
~WinEDA_TreePrj();
private:
/* overridden sort function */
int OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 );
};
#endif #endif

View File

@ -19,6 +19,7 @@
#include "macros.h" #include "macros.h"
#include "kicad.h" #include "kicad.h"
#include "tree_project_frame.h"
static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) ); static const wxString TreeFrameWidthEntry( wxT( "LeftWinWidth" ) );
@ -62,7 +63,7 @@ WinEDA_MainFrame::WinEDA_MainFrame( wxWindow* parent,
clientsize = GetClientSize(); clientsize = GetClientSize();
// Left window: is the box which display tree project // Left window: is the box which display tree project
m_LeftWin = new WinEDA_PrjFrame( this ); m_LeftWin = new TREE_PROJECT_FRAME( this );
// Bottom Window: box to display messages // Bottom Window: box to display messages
m_RightWin = new RIGHT_KM_FRAME( this ); m_RightWin = new RIGHT_KM_FRAME( this );

View File

@ -13,6 +13,7 @@
#include "gestfich.h" #include "gestfich.h"
#include "prjconfig.h" #include "prjconfig.h"
#include "kicad.h" #include "kicad.h"
#include "tree_project_frame.h"
#include "build_version.h" #include "build_version.h"

View File

@ -19,6 +19,8 @@
#include "macros.h" #include "macros.h"
#include "kicad.h" #include "kicad.h"
#include "tree_project_frame.h"
#include "class_treeprojectfiles.h"
#include "wx/image.h" #include "wx/image.h"
#include "wx/imaglist.h" #include "wx/imaglist.h"
@ -82,7 +84,7 @@ const wxString TextFileWildcard( wxT( "Text files (*.txt)|*.txt" ) );
* @brief TODO * @brief TODO
*/ */
/******************************************************************/ /******************************************************************/
WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent ) : TREE_PROJECT_FRAME::TREE_PROJECT_FRAME( WinEDA_MainFrame* parent ) :
wxSashLayoutWindow( parent, wxSashLayoutWindow( parent,
ID_LEFT_FRAME, ID_LEFT_FRAME,
wxDefaultPosition, wxDefaultPosition,
@ -238,7 +240,7 @@ WinEDA_PrjFrame::WinEDA_PrjFrame( WinEDA_MainFrame* parent ) :
ReCreateTreePrj(); ReCreateTreePrj();
} }
WinEDA_PrjFrame::~WinEDA_PrjFrame() TREE_PROJECT_FRAME::~TREE_PROJECT_FRAME()
{ {
size_t i; size_t i;
wxMenu* menu; wxMenu* menu;
@ -255,26 +257,26 @@ WinEDA_PrjFrame::~WinEDA_PrjFrame()
/*****************************************************************************/ /*****************************************************************************/
BEGIN_EVENT_TABLE( WinEDA_PrjFrame, wxSashLayoutWindow ) BEGIN_EVENT_TABLE( TREE_PROJECT_FRAME, wxSashLayoutWindow )
/*****************************************************************************/ /*****************************************************************************/
EVT_TREE_BEGIN_LABEL_EDIT( ID_PROJECT_TREE, WinEDA_PrjFrame::OnRenameAsk ) EVT_TREE_BEGIN_LABEL_EDIT( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnRenameAsk )
EVT_TREE_END_LABEL_EDIT( ID_PROJECT_TREE, WinEDA_PrjFrame::OnRename ) EVT_TREE_END_LABEL_EDIT( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnRename )
EVT_TREE_ITEM_ACTIVATED( ID_PROJECT_TREE, WinEDA_PrjFrame::OnSelect ) EVT_TREE_ITEM_ACTIVATED( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnSelect )
EVT_TREE_ITEM_RIGHT_CLICK( ID_PROJECT_TREE, WinEDA_PrjFrame::OnRight ) EVT_TREE_ITEM_RIGHT_CLICK( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnRight )
EVT_TREE_BEGIN_DRAG( ID_PROJECT_TREE, WinEDA_PrjFrame::OnDragStart ) EVT_TREE_BEGIN_DRAG( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnDragStart )
EVT_TREE_END_DRAG( ID_PROJECT_TREE, WinEDA_PrjFrame::OnDragEnd ) EVT_TREE_END_DRAG( ID_PROJECT_TREE, TREE_PROJECT_FRAME::OnDragEnd )
EVT_MENU( ID_PROJECT_TXTEDIT, WinEDA_PrjFrame::OnTxtEdit ) EVT_MENU( ID_PROJECT_TXTEDIT, TREE_PROJECT_FRAME::OnTxtEdit )
EVT_MENU( ID_PROJECT_NEWFILE, WinEDA_PrjFrame::OnNewFile ) EVT_MENU( ID_PROJECT_NEWFILE, TREE_PROJECT_FRAME::OnNewFile )
EVT_MENU( ID_PROJECT_NEWDIR, WinEDA_PrjFrame::OnNewDirectory ) EVT_MENU( ID_PROJECT_NEWDIR, TREE_PROJECT_FRAME::OnNewDirectory )
EVT_MENU( ID_PROJECT_NEWPY, WinEDA_PrjFrame::OnNewPyFile ) EVT_MENU( ID_PROJECT_NEWPY, TREE_PROJECT_FRAME::OnNewPyFile )
EVT_MENU( ID_PROJECT_NEWTXT, WinEDA_PrjFrame::OnNewTxtFile ) EVT_MENU( ID_PROJECT_NEWTXT, TREE_PROJECT_FRAME::OnNewTxtFile )
EVT_MENU( ID_PROJECT_DELETE, WinEDA_PrjFrame::OnDeleteFile ) EVT_MENU( ID_PROJECT_DELETE, TREE_PROJECT_FRAME::OnDeleteFile )
EVT_MENU( ID_PROJECT_RENAME, WinEDA_PrjFrame::OnRenameFile ) EVT_MENU( ID_PROJECT_RENAME, TREE_PROJECT_FRAME::OnRenameFile )
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
EVT_MENU( ID_PROJECT_RUNPY, WinEDA_PrjFrame::OnRunPy ) EVT_MENU( ID_PROJECT_RUNPY, TREE_PROJECT_FRAME::OnRunPy )
#endif /* KICAD_PYTHON */ #endif /* KICAD_PYTHON */
@ -287,7 +289,7 @@ END_EVENT_TABLE()
* @brief 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 ) void TREE_PROJECT_FRAME::OnDragStart( wxTreeEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
/* Ensure item is selected /* Ensure item is selected
@ -310,7 +312,7 @@ void WinEDA_PrjFrame::OnDragStart( wxTreeEvent& event )
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnDragEnd( wxTreeEvent& event ) void TREE_PROJECT_FRAME::OnDragEnd( wxTreeEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
m_Parent->SetCursor( wxNullCursor ); m_Parent->SetCursor( wxNullCursor );
@ -355,7 +357,7 @@ void WinEDA_PrjFrame::OnDragEnd( wxTreeEvent& event )
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::ClearFilters() void TREE_PROJECT_FRAME::ClearFilters()
/*****************************************************************************/ /*****************************************************************************/
{ {
m_Filters.clear(); m_Filters.clear();
@ -363,7 +365,7 @@ void WinEDA_PrjFrame::ClearFilters()
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::RemoveFilter( const wxString& filter ) void TREE_PROJECT_FRAME::RemoveFilter( const wxString& filter )
/*****************************************************************************/ /*****************************************************************************/
{ {
for( unsigned int i = 0; i < m_Filters.size(); i++ ) for( unsigned int i = 0; i < m_Filters.size(); i++ )
@ -384,7 +386,7 @@ void WinEDA_PrjFrame::RemoveFilter( const wxString& filter )
* @brief 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 ) TreePrjItemData* TREE_PROJECT_FRAME::FindItemData( const boost::python::str& name )
/*****************************************************************************/ /*****************************************************************************/
{ {
// (Interative tree parsing) // (Interative tree parsing)
@ -448,7 +450,7 @@ TreePrjItemData* WinEDA_PrjFrame::FindItemData( const boost::python::str& name )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::RemoveFilterPy( const boost::python::str& filter ) void TREE_PROJECT_FRAME::RemoveFilterPy( const boost::python::str& filter )
/*****************************************************************************/ /*****************************************************************************/
{ {
RemoveFilter( PyHandler::MakeStr( filter ) ); RemoveFilter( PyHandler::MakeStr( filter ) );
@ -459,7 +461,7 @@ void WinEDA_PrjFrame::RemoveFilterPy( const boost::python::str& filter )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::AddFilter( const boost::python::str& filter ) void TREE_PROJECT_FRAME::AddFilter( const boost::python::str& filter )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxRegEx reg; wxRegEx reg;
@ -478,7 +480,7 @@ void WinEDA_PrjFrame::AddFilter( const boost::python::str& filter )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
const std::vector<wxString>& WinEDA_PrjFrame::GetFilters() const std::vector<wxString>& TREE_PROJECT_FRAME::GetFilters()
/*****************************************************************************/ /*****************************************************************************/
{ {
return m_Filters; return m_Filters;
@ -489,7 +491,7 @@ const std::vector<wxString>& WinEDA_PrjFrame::GetFilters()
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
wxMenu* WinEDA_PrjFrame::GetContextMenu( int type ) wxMenu* TREE_PROJECT_FRAME::GetContextMenu( int type )
/*****************************************************************************/ /*****************************************************************************/
{ {
return m_ContextMenus[type]; return m_ContextMenus[type];
@ -500,7 +502,7 @@ wxMenu* WinEDA_PrjFrame::GetContextMenu( int type )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnNewDirectory( wxCommandEvent& event ) void TREE_PROJECT_FRAME::OnNewDirectory( wxCommandEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
NewFile( TREE_DIRECTORY ); NewFile( TREE_DIRECTORY );
@ -511,7 +513,7 @@ void WinEDA_PrjFrame::OnNewDirectory( wxCommandEvent& event )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnNewFile( wxCommandEvent& event ) void TREE_PROJECT_FRAME::OnNewFile( wxCommandEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
NewFile( TREE_UNKNOWN ); NewFile( TREE_UNKNOWN );
@ -522,7 +524,7 @@ void WinEDA_PrjFrame::OnNewFile( wxCommandEvent& event )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnNewPyFile( wxCommandEvent& event ) void TREE_PROJECT_FRAME::OnNewPyFile( wxCommandEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
NewFile( TREE_PY ); NewFile( TREE_PY );
@ -533,7 +535,7 @@ void WinEDA_PrjFrame::OnNewPyFile( wxCommandEvent& event )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnNewTxtFile( wxCommandEvent& event ) void TREE_PROJECT_FRAME::OnNewTxtFile( wxCommandEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
NewFile( TREE_TXT ); NewFile( TREE_TXT );
@ -544,7 +546,7 @@ void WinEDA_PrjFrame::OnNewTxtFile( wxCommandEvent& event )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::NewFile( TreeFileType type ) void TREE_PROJECT_FRAME::NewFile( TreeFileType type )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxString mask = GetFileExt( type ); wxString mask = GetFileExt( type );
@ -595,7 +597,7 @@ void WinEDA_PrjFrame::NewFile( TreeFileType type )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::NewFile( const wxString& name, void TREE_PROJECT_FRAME::NewFile( const wxString& name,
TreeFileType type, TreeFileType type,
wxTreeItemId& root ) wxTreeItemId& root )
/*****************************************************************************/ /*****************************************************************************/
@ -627,7 +629,7 @@ void WinEDA_PrjFrame::NewFile( const wxString& name,
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
wxString WinEDA_PrjFrame::GetFileExt( TreeFileType type ) wxString TREE_PROJECT_FRAME::GetFileExt( TreeFileType type )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxString ext; wxString ext;
@ -675,7 +677,7 @@ wxString WinEDA_PrjFrame::GetFileExt( TreeFileType type )
/* /*
* Return the wxFileDialog wildcard string for the selected file type. * Return the wxFileDialog wildcard string for the selected file type.
*/ */
wxString WinEDA_PrjFrame::GetFileWildcard( TreeFileType type ) wxString TREE_PROJECT_FRAME::GetFileWildcard( TreeFileType type )
{ {
wxString ext; wxString ext;
@ -726,7 +728,7 @@ wxString WinEDA_PrjFrame::GetFileWildcard( TreeFileType type )
* @return TODO * @return TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root ) bool TREE_PROJECT_FRAME::AddFile( const wxString& name, wxTreeItemId& root )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxTreeItemId cellule; wxTreeItemId cellule;
@ -897,7 +899,7 @@ bool WinEDA_PrjFrame::AddFile( const wxString& name, wxTreeItemId& root )
* @return TODO * @return TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::ReCreateTreePrj() void TREE_PROJECT_FRAME::ReCreateTreePrj()
/*****************************************************************************/ /*****************************************************************************/
{ {
wxTreeItemId rootcellule; wxTreeItemId rootcellule;
@ -905,7 +907,7 @@ void WinEDA_PrjFrame::ReCreateTreePrj()
bool prjOpened = false; bool prjOpened = false;
if( !m_TreeProject ) if( !m_TreeProject )
m_TreeProject = new WinEDA_TreePrj( this ); m_TreeProject = new TREEPROJECTFILES( this );
else else
m_TreeProject->DeleteAllItems(); m_TreeProject->DeleteAllItems();
@ -980,7 +982,7 @@ void WinEDA_PrjFrame::ReCreateTreePrj()
* @brief Opens *popup* the context menu * @brief Opens *popup* the context menu
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnRight( wxTreeEvent& Event ) void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
/*****************************************************************************/ /*****************************************************************************/
{ {
int tree_id; int tree_id;
@ -1053,7 +1055,7 @@ void WinEDA_PrjFrame::OnRight( wxTreeEvent& Event )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnTxtEdit( wxCommandEvent& event ) void TREE_PROJECT_FRAME::OnTxtEdit( wxCommandEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
TreePrjItemData* tree_data = GetSelectedData(); TreePrjItemData* tree_data = GetSelectedData();
@ -1081,7 +1083,7 @@ void WinEDA_PrjFrame::OnTxtEdit( wxCommandEvent& event )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnDeleteFile( wxCommandEvent& ) void TREE_PROJECT_FRAME::OnDeleteFile( wxCommandEvent& )
/*****************************************************************************/ /*****************************************************************************/
{ {
TreePrjItemData* tree_data = GetSelectedData(); TreePrjItemData* tree_data = GetSelectedData();
@ -1096,7 +1098,7 @@ void WinEDA_PrjFrame::OnDeleteFile( wxCommandEvent& )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnRenameFile( wxCommandEvent& ) void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxTreeItemId curr_item = m_TreeProject->GetSelection(); wxTreeItemId curr_item = m_TreeProject->GetSelection();
@ -1122,7 +1124,7 @@ void WinEDA_PrjFrame::OnRenameFile( wxCommandEvent& )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnRunPy( wxCommandEvent& event ) void TREE_PROJECT_FRAME::OnRunPy( wxCommandEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
TreePrjItemData* tree_data = GetSelectedData(); TreePrjItemData* tree_data = GetSelectedData();
@ -1141,7 +1143,7 @@ void WinEDA_PrjFrame::OnRunPy( wxCommandEvent& event )
* @brief Add a state to the image list * @brief Add a state to the image list
*/ */
/*****************************************************************************/ /*****************************************************************************/
int WinEDA_PrjFrame::AddStatePy( boost::python::object& bitmap ) int TREE_PROJECT_FRAME::AddStatePy( boost::python::object& bitmap )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxBitmap* image; wxBitmap* image;
@ -1175,7 +1177,7 @@ int WinEDA_PrjFrame::AddStatePy( boost::python::object& bitmap )
* @brief Prevent the main project to be renamed * @brief Prevent the main project to be renamed
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnRenameAsk( wxTreeEvent& event ) void TREE_PROJECT_FRAME::OnRenameAsk( wxTreeEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
TreePrjItemData* tree_data = GetSelectedData(); TreePrjItemData* tree_data = GetSelectedData();
@ -1191,7 +1193,7 @@ void WinEDA_PrjFrame::OnRenameAsk( wxTreeEvent& event )
* @brief Rename a tree item on demand of the context menu * @brief Rename a tree item on demand of the context menu
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnRename( wxTreeEvent& event ) void TREE_PROJECT_FRAME::OnRename( wxTreeEvent& event )
/*****************************************************************************/ /*****************************************************************************/
{ {
TreePrjItemData* tree_data = GetSelectedData(); TreePrjItemData* tree_data = GetSelectedData();
@ -1207,7 +1209,7 @@ void WinEDA_PrjFrame::OnRename( wxTreeEvent& event )
* @brief TODO * @brief TODO
*/ */
/*****************************************************************************/ /*****************************************************************************/
void WinEDA_PrjFrame::OnSelect( wxTreeEvent& Event ) void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
/*****************************************************************************/ /*****************************************************************************/
{ {
wxString FullFileName; wxString FullFileName;

134
kicad/tree_project_frame.h Normal file
View File

@ -0,0 +1,134 @@
/*
* file tree_project_frame.h
*/
/*
* This program source code file is part of KICAD, a free EDA CAD application.
*
* Copyright (C) 1992-2009 Jean-Pierre Charras, jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 1992-2009 Kicad Developers, see change_log.txt for contributors.
*
* 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
*/
#ifndef TREEPRJ_FRAME_H
#define TREEPRJ_FRAME_H
/** class TREE_PROJECT_FRAME
* Window to display the tree files
*/
class TREE_PROJECT_FRAME : public wxSashLayoutWindow
{
private:
std::vector<wxMenu*> m_ContextMenus;
std::vector<wxString> m_Filters;
wxMenu* m_PopupMenu;
wxCursor m_DragCursor;
wxCursor m_Default;
protected:
wxMenu* GetContextMenu( int type );
void NewFile( TreeFileType type );
void NewFile( const wxString& name, TreeFileType type,
wxTreeItemId& root );
TreePrjItemData* GetSelectedData();
public:
WinEDA_MainFrame* m_Parent;
TREEPROJECTFILES* m_TreeProject;
wxTreeItemId m_root;
public:
static wxString GetFileExt( TreeFileType type );
static wxString GetFileWildcard( TreeFileType type );
TREE_PROJECT_FRAME( WinEDA_MainFrame* parent );
~TREE_PROJECT_FRAME();
void OnSelect( wxTreeEvent& Event );
void OnRenameAsk( wxTreeEvent& Event );
void OnRename( wxTreeEvent& Event );
void OnDragStart( wxTreeEvent& event );
void OnDragEnd( wxTreeEvent& event );
void OnRight( wxTreeEvent& Event );
void ReCreateTreePrj();
void OnTxtEdit( wxCommandEvent& event );
void OnDeleteFile( wxCommandEvent& event );
void OnRenameFile( wxCommandEvent& event );
void OnNewFile( wxCommandEvent& event );
void OnNewDirectory( wxCommandEvent& event );
void OnNewSchFile( wxCommandEvent& event );
void OnNewBrdFile( wxCommandEvent& event );
void OnNewPyFile( wxCommandEvent& event );
void OnNewGerberFile( wxCommandEvent& event );
void OnNewTxtFile( wxCommandEvent& event );
void OnNewNetFile( wxCommandEvent& event );
void ClearFilters();
const std::vector<wxString>& GetFilters();
void RemoveFilter( const wxString& filter );
#ifdef KICAD_PYTHON
boost::python::object ToWx();
TREE_PROJECT_FRAME()
{
}
TREE_PROJECT_FRAME( const TREE_PROJECT_FRAME& )
{
}
void OnRunPy( wxCommandEvent& event );
boost::python::object GetMenuPy( TreeFileType );
boost::python::object GetFtExPy( TreeFileType ) const;
void RemoveFilterPy( const boost::python::str& filter );
void AddFilter( const boost::python::str& filter );
boost::python::object GetTreeCtrl();
TreePrjItemData* GetItemData( const boost::python::object& item );
void AddFilePy( const boost::python::str& name,
boost::python::object& root );
void NewFilePy( const boost::python::str& name,
TreeFileType type,
boost::python::object& root );
TreePrjItemData* FindItemData( const boost::python::str& name );
boost::python::object GetCurrentMenu();
int AddStatePy( boost::python::object& bitmap );
#endif
bool AddFile( const wxString& name, wxTreeItemId& root );
DECLARE_EVENT_TABLE()
};
#endif // TREEPRJ_FRAME_H