2007-09-13 11:55:46 +00:00
|
|
|
/***********/
|
|
|
|
/* kicad.h */
|
|
|
|
/***********/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
#ifndef KICAD_H
|
|
|
|
#define KICAD_H
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
#ifdef KICAD_PYTHON
|
|
|
|
#include <pyhandler.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <vector>
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
#include <wx/treectrl.h>
|
2007-05-28 18:09:49 +00:00
|
|
|
#include <wx/dragimag.h>
|
2009-04-05 20:49:15 +00:00
|
|
|
#include <wx/filename.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "wxstruct.h"
|
2009-04-05 20:49:15 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
class WinEDA_CommandFrame;
|
2007-05-06 16:03:28 +00:00
|
|
|
class WinEDA_TreePrj;
|
|
|
|
class WinEDA_PrjFrame;
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
/*******************************************/
|
|
|
|
/* classe pour la Fenetre generale de kicad*/
|
|
|
|
/*******************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
/* class WinEDA_MainFrame
|
|
|
|
* This is the main kicad frame
|
|
|
|
*/
|
2007-09-13 11:55:46 +00:00
|
|
|
class WinEDA_MainFrame : public WinEDA_BasicFrame
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-09-13 11:55:46 +00:00
|
|
|
/* This class is the main entry point of the py API */
|
2007-05-06 16:03:28 +00:00
|
|
|
public:
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
WinEDA_CommandFrame* m_CommandWin;
|
|
|
|
WinEDA_PrjFrame* m_LeftWin;
|
|
|
|
wxSashLayoutWindow* m_BottomWin;
|
|
|
|
wxTextCtrl* m_DialogWin;
|
2007-10-31 17:47:44 +00:00
|
|
|
WinEDA_Toolbar* m_VToolBar; // Verticam Toolbar (not used)
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString m_BoardFileName;
|
|
|
|
wxString m_SchematicRootFileName;
|
|
|
|
wxFileName m_ProjectFileName;
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
int m_LeftWin_Width;
|
|
|
|
int m_CommandWin_Height;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
public:
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
// Constructor and destructor
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_MainFrame( wxWindow* parent, const wxString& title,
|
2007-10-31 17:47:44 +00:00
|
|
|
const wxPoint& pos, const wxSize& size );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
~WinEDA_MainFrame();
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
void OnCloseWindow( wxCloseEvent& Event );
|
|
|
|
void OnSize( wxSizeEvent& event );
|
|
|
|
void OnPaint( wxPaintEvent& event );
|
|
|
|
void ReDraw( wxDC* DC );
|
|
|
|
void OnSashDrag( wxSashEvent& event );
|
|
|
|
void OnLoadProject( wxCommandEvent& event );
|
|
|
|
void OnSaveProject( wxCommandEvent& event );
|
|
|
|
void OnArchiveFiles( wxCommandEvent& event );
|
|
|
|
void OnUnarchiveFiles( wxCommandEvent& event );
|
|
|
|
void OnRunPcbNew( wxCommandEvent& event );
|
|
|
|
void OnRunCvpcb( wxCommandEvent& event );
|
|
|
|
void OnRunEeschema( wxCommandEvent& event );
|
|
|
|
void OnRunGerbview( wxCommandEvent& event );
|
|
|
|
|
|
|
|
#ifdef KICAD_PYTHON
|
|
|
|
void OnRunPythonScript( wxCommandEvent& event );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void OnOpenTextEditor( wxCommandEvent& event );
|
|
|
|
void OnOpenFileInTextEditor( wxCommandEvent& event );
|
|
|
|
void OnOpenFileInEditor( wxCommandEvent& event );
|
|
|
|
|
|
|
|
void OnFileHistory( wxCommandEvent& event );
|
|
|
|
void OnExit( wxCommandEvent& event );
|
|
|
|
void Process_Preferences( wxCommandEvent& event );
|
|
|
|
void ReCreateMenuBar();
|
|
|
|
void RecreateBaseHToolbar();
|
|
|
|
void PrintMsg( const wxString& text );
|
|
|
|
void ClearMsg();
|
|
|
|
void SetLanguage( wxCommandEvent& event );
|
|
|
|
void OnRefresh( wxCommandEvent& event );
|
|
|
|
void OnSelectDefaultPdfBrowser( wxCommandEvent& event );
|
|
|
|
void OnSelectPreferredPdfBrowser( wxCommandEvent& event );
|
|
|
|
void OnSelectPreferredEditor( wxCommandEvent& event );
|
|
|
|
|
|
|
|
void OnUpdateDefaultPdfBrowser( wxUpdateUIEvent& event );
|
|
|
|
void OnUpdatePreferredPdfBrowser( wxUpdateUIEvent& event );
|
|
|
|
|
|
|
|
void CreateNewProject( const wxString PrjFullFileName );
|
|
|
|
|
|
|
|
void LoadSettings();
|
|
|
|
void SaveSettings();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
#ifdef KICAD_PYTHON
|
2009-04-05 20:49:15 +00:00
|
|
|
void OnRefreshPy();
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
boost::python::object GetPrjName() const;
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
WinEDA_MainFrame( const WinEDA_MainFrame& ) { }
|
|
|
|
|
|
|
|
WinEDA_MainFrame() { }
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
boost::python::object ToWx();
|
|
|
|
void AddFastLaunchPy( boost::python::object& button );
|
|
|
|
WinEDA_PrjFrame* GetTree() const;
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
// Order of this enum changes AddFile() internal working
|
|
|
|
// please update both
|
|
|
|
enum TreeFileType {
|
2007-09-13 11:55:46 +00:00
|
|
|
TREE_PROJECT = 1,
|
|
|
|
TREE_SCHEMA,
|
|
|
|
TREE_PCB,
|
|
|
|
TREE_PY,
|
|
|
|
TREE_GERBER,
|
|
|
|
TREE_PDF,
|
|
|
|
TREE_TXT,
|
|
|
|
TREE_NET,
|
|
|
|
TREE_UNKNOWN,
|
|
|
|
TREE_DIRECTORY,
|
|
|
|
TREE_MAX,
|
2007-05-28 18:09:49 +00:00
|
|
|
};
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
/**************************************************************/
|
|
|
|
/* class WinEDA_CommandFrame: window handling command buttons */
|
|
|
|
/**************************************************************/
|
|
|
|
|
|
|
|
/** class WinEDA_CommandFrame
|
|
|
|
* This is the window handling the main tools to launch eeschema, cvpcb, pcbnew and gerbview
|
|
|
|
*/
|
|
|
|
class WinEDA_CommandFrame : public wxSashLayoutWindow
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
WinEDA_CommandFrame( wxWindow* parent, int id, wxPoint pos, wxSize size, long style );
|
|
|
|
~WinEDA_CommandFrame()
|
|
|
|
{ }
|
|
|
|
|
|
|
|
/** Function AddFastLaunch
|
|
|
|
* add a Bitmap Button (fast launch button) to the window
|
|
|
|
*/
|
|
|
|
public: void AddFastLaunch( wxBitmapButton * button );
|
|
|
|
private:
|
|
|
|
|
|
|
|
/** Function CreateCommandToolbar
|
|
|
|
* Create the main buttons (fast launch buttons)
|
|
|
|
*/
|
|
|
|
void CreateCommandToolbar( void );
|
|
|
|
|
|
|
|
private:
|
|
|
|
wxPoint m_ButtonLastPosition; /** position of the last button in the window */
|
|
|
|
int m_ButtonSeparation; /** button distance in pixels */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-05-28 18:09:49 +00:00
|
|
|
/***********************************************************/
|
|
|
|
/* Classes pour l'arbre de hierarchie de gestion du projet */
|
|
|
|
/***********************************************************/
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
/** class TreePrjItemData
|
|
|
|
* Handle one item (a file or a directory name) for the tree file
|
|
|
|
*/
|
2007-09-13 11:55:46 +00:00
|
|
|
class TreePrjItemData : public wxTreeItemData
|
2007-05-28 18:09:49 +00:00
|
|
|
{
|
|
|
|
public:
|
2007-09-13 11:55:46 +00:00
|
|
|
TreeFileType m_Type;
|
2007-10-31 17:47:44 +00:00
|
|
|
bool m_IsRootFile; // True if m_Filename is a root schematic (same name as project)
|
|
|
|
wxString m_FileName; // Filename for a file, or directory name
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
private:
|
2007-09-13 11:55:46 +00:00
|
|
|
wxTreeCtrl* m_Parent;
|
|
|
|
wxMenu m_fileMenu;
|
|
|
|
int m_State;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
TreePrjItemData( TreeFileType type, const wxString& data, wxTreeCtrl* parent );
|
2007-10-31 17:47:44 +00:00
|
|
|
TreePrjItemData() : m_Parent( NULL ) { }
|
|
|
|
|
|
|
|
TreePrjItemData( const TreePrjItemData& src ) :
|
|
|
|
m_Type( src.m_Type )
|
|
|
|
, m_FileName( src.m_FileName )
|
|
|
|
, m_Parent( src.m_Parent )
|
2007-09-13 11:55:46 +00:00
|
|
|
{
|
|
|
|
SetState( src.m_State );
|
|
|
|
}
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
TreeFileType GetType() const
|
|
|
|
{
|
|
|
|
return m_Type;
|
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
wxString GetFileName() const
|
|
|
|
{
|
|
|
|
return m_FileName;
|
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
void SetFileName( const wxString& name )
|
|
|
|
{
|
|
|
|
m_FileName = name;
|
|
|
|
}
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
wxString GetDir() const;
|
|
|
|
|
|
|
|
void OnRename( wxTreeEvent& event, bool check = true );
|
|
|
|
bool Rename( const wxString& name, bool check = true );
|
|
|
|
bool Delete( bool check = true );
|
|
|
|
void Move( TreePrjItemData* dest );
|
modified the treeprj so that, instead of recursively scanning and adding
*all* the nested files and directories within the current working directory, it scans the first
level of files and directories. When a user double-clicks on a folder, *then*
the childeren of that directory are added to the wxTreeCtrl. This means that the little
triangle does not appear until the user opens a directory .. but, i think this is
a worthwile price to pay given below.
This prevents (or at least mitigates) memory overflow in the case that kicad starts in root, or,
in my case, it starts in my home directory, where thanks to wine & other sw,
there are far too many directories.
also modified the TreePrjItemData so that it stores the full pathnames in m_FileName,
not paths relative to the CWD. I'm not sure if this is the correct thing to do,
especially with the python interface, so change it back if it is more complicated.
the move and rename commands threw a segfault on my system
(Debian etch, wxWidgets 2.8.7),
and since there are better ways to rename and move files, this functionality
was disabled until somebody can fix it (alas, I don't have time for this now)
2007-12-16 18:44:12 +00:00
|
|
|
void Activate(WinEDA_PrjFrame* prjframe);
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
const wxMenu* GetMenu()
|
|
|
|
{
|
|
|
|
return &m_fileMenu;
|
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
void SetState( int state );
|
|
|
|
|
|
|
|
#ifdef KICAD_PYTHON
|
|
|
|
boost::python::object GetFileNamePy() const;
|
|
|
|
bool RenamePy( const boost::python::str& newname, bool check = true );
|
|
|
|
|
|
|
|
boost::python::object GetDirPy() const;
|
|
|
|
|
|
|
|
boost::python::object GetIdPy() const;
|
|
|
|
|
|
|
|
boost::python::object GetMenuPy();
|
|
|
|
|
|
|
|
#endif
|
2007-05-28 18:09:49 +00:00
|
|
|
};
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
/** class WinEDA_PrjFrame
|
|
|
|
* Window to display the tree files
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
class WinEDA_PrjFrame : public wxSashLayoutWindow
|
|
|
|
{
|
2007-05-28 18:09:49 +00:00
|
|
|
private:
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
std::vector<wxMenu*> m_ContextMenus;
|
|
|
|
std::vector<wxString> m_Filters;
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
wxMenu* m_PopupMenu;
|
2007-05-28 18:09:49 +00:00
|
|
|
wxCursor m_DragCursor;
|
|
|
|
wxCursor m_Default;
|
|
|
|
|
|
|
|
protected:
|
2007-09-13 11:55:46 +00:00
|
|
|
wxMenu* GetContextMenu( int type );
|
|
|
|
void NewFile( TreeFileType type );
|
|
|
|
void NewFile( const wxString& name, TreeFileType type, wxTreeItemId& root );
|
|
|
|
TreePrjItemData* GetSelectedData();
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
public:
|
2007-09-13 11:55:46 +00:00
|
|
|
WinEDA_MainFrame* m_Parent;
|
|
|
|
WinEDA_TreePrj* m_TreeProject;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
wxTreeItemId m_root;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
public:
|
2007-09-13 11:55:46 +00:00
|
|
|
static wxString GetFileExt( TreeFileType type );
|
2009-04-05 20:49:15 +00:00
|
|
|
static wxString GetFileWildcard( TreeFileType type );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
WinEDA_PrjFrame( WinEDA_MainFrame* parent,
|
|
|
|
const wxPoint& pos, const wxSize& size );
|
2009-05-21 17:42:42 +00:00
|
|
|
~WinEDA_PrjFrame();
|
2007-09-13 11:55:46 +00:00
|
|
|
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 );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
#ifdef KICAD_PYTHON
|
2007-09-13 11:55:46 +00:00
|
|
|
boost::python::object ToWx();
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
WinEDA_PrjFrame()
|
|
|
|
{
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
WinEDA_PrjFrame( const WinEDA_PrjFrame& )
|
|
|
|
{
|
2007-09-13 11:55:46 +00:00
|
|
|
}
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
void OnRunPy( wxCommandEvent& event );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
boost::python::object GetMenuPy( TreeFileType );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
boost::python::object GetFtExPy( TreeFileType ) const;
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
void RemoveFilterPy( const boost::python::str& filter );
|
|
|
|
void AddFilter( const boost::python::str& filter );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
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,
|
2007-10-31 17:47:44 +00:00
|
|
|
TreeFileType type,
|
|
|
|
boost::python::object& root );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
TreePrjItemData* FindItemData( const boost::python::str& name );
|
|
|
|
|
|
|
|
boost::python::object GetCurrentMenu();
|
|
|
|
int AddStatePy( boost::python::object& bitmap );
|
2007-05-28 18:09:49 +00:00
|
|
|
|
|
|
|
#endif
|
|
|
|
|
modified the treeprj so that, instead of recursively scanning and adding
*all* the nested files and directories within the current working directory, it scans the first
level of files and directories. When a user double-clicks on a folder, *then*
the childeren of that directory are added to the wxTreeCtrl. This means that the little
triangle does not appear until the user opens a directory .. but, i think this is
a worthwile price to pay given below.
This prevents (or at least mitigates) memory overflow in the case that kicad starts in root, or,
in my case, it starts in my home directory, where thanks to wine & other sw,
there are far too many directories.
also modified the TreePrjItemData so that it stores the full pathnames in m_FileName,
not paths relative to the CWD. I'm not sure if this is the correct thing to do,
especially with the python interface, so change it back if it is more complicated.
the move and rename commands threw a segfault on my system
(Debian etch, wxWidgets 2.8.7),
and since there are better ways to rename and move files, this functionality
was disabled until somebody can fix it (alas, I don't have time for this now)
2007-12-16 18:44:12 +00:00
|
|
|
bool AddFile( const wxString& name, wxTreeItemId& root );
|
2007-09-13 11:55:46 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2007-10-31 17:47:44 +00:00
|
|
|
/** Class TreeCtrl
|
|
|
|
* This is the class to show (as a tree) the files in the project directory
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
class WinEDA_TreePrj : public wxTreeCtrl
|
|
|
|
{
|
2007-09-13 11:55:46 +00:00
|
|
|
DECLARE_DYNAMIC_CLASS( WinEDA_TreePrj )
|
2007-05-06 16:03:28 +00:00
|
|
|
private:
|
2007-09-13 11:55:46 +00:00
|
|
|
WinEDA_PrjFrame* m_Parent;
|
|
|
|
wxImageList* m_ImageList;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
public:
|
2007-05-28 18:09:49 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
WinEDA_PrjFrame* GetParent()
|
|
|
|
{
|
|
|
|
return m_Parent;
|
|
|
|
}
|
2007-10-31 17:47:44 +00:00
|
|
|
|
|
|
|
|
|
|
|
WinEDA_TreePrj( WinEDA_PrjFrame* parent );
|
2007-09-13 11:55:46 +00:00
|
|
|
~WinEDA_TreePrj();
|
2007-05-28 18:09:49 +00:00
|
|
|
private:
|
2007-09-13 11:55:46 +00:00
|
|
|
/* overlayed sort function */
|
|
|
|
int OnCompareItems( const wxTreeItemId& item1, const wxTreeItemId& item2 );
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|