diff --git a/pcbnew/CMakeLists.txt b/pcbnew/CMakeLists.txt index 1d7404752e..fed90c4d57 100644 --- a/pcbnew/CMakeLists.txt +++ b/pcbnew/CMakeLists.txt @@ -86,6 +86,8 @@ set(PCBNEW_DIALOGS dialogs/dialog_SVG_print.cpp dialogs/dialog_SVG_print_base.cpp dialogs/dialog_set_grid_base.cpp + dialogs/dialog_scripting_base.cpp + dialogs/dialog_scripting.cpp ) set(PCBNEW_SRCS diff --git a/pcbnew/dialogs/dialog_scripting.cpp b/pcbnew/dialogs/dialog_scripting.cpp new file mode 100644 index 0000000000..6bc9822cab --- /dev/null +++ b/pcbnew/dialogs/dialog_scripting.cpp @@ -0,0 +1,29 @@ +/** + * @file dialog_scripting.cpp + */ + + +#include +#include +#include +#include +#include +#include + + +DIALOG_SCRIPTING::DIALOG_SCRIPTING( wxWindow* parent ) + : DIALOG_SCRIPTING_BASE( parent ) +{ + SetFocus(); + +} + + + +void DIALOG_SCRIPTING::OnRunButtonClick( wxCommandEvent& event ) +{ + wxCharBuffer buffer = m_txScript->GetValue().ToUTF8(); + PyRun_SimpleString(buffer.data()); +} + + diff --git a/pcbnew/dialogs/dialog_scripting.h b/pcbnew/dialogs/dialog_scripting.h new file mode 100644 index 0000000000..9f3a4638ca --- /dev/null +++ b/pcbnew/dialogs/dialog_scripting.h @@ -0,0 +1,22 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: dialog_scripting.h +///////////////////////////////////////////////////////////////////////////// + +#ifndef _DIALOG_SCRIPTING_H_ +#define _DIALOG_SCRIPTING_H_ + +#include + +class DIALOG_SCRIPTING: public DIALOG_SCRIPTING_BASE +{ +private: + wxDialog * m_Parent; + +public: + DIALOG_SCRIPTING(wxWindow * parent ); + +private: + void OnRunButtonClick( wxCommandEvent& event ); +}; + +#endif // _DIALOG_SCRIPTING_H_ diff --git a/pcbnew/dialogs/dialog_scripting_base.cpp b/pcbnew/dialogs/dialog_scripting_base.cpp new file mode 100644 index 0000000000..4064b79b95 --- /dev/null +++ b/pcbnew/dialogs/dialog_scripting_base.cpp @@ -0,0 +1,41 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Sep 8 2010) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#include "dialog_scripting_base.h" + +/////////////////////////////////////////////////////////////////////////// + +DIALOG_SCRIPTING_BASE::DIALOG_SCRIPTING_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxFrame( parent, id, title, pos, size, style ) +{ + this->SetSizeHints( wxDefaultSize, wxDefaultSize ); + + wxBoxSizer* bSizer4; + bSizer4 = new wxBoxSizer( wxVERTICAL ); + + m_txScript = new wxTextCtrl( this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxTE_MULTILINE ); + m_txScript->SetMinSize( wxSize( 480,500 ) ); + + bSizer4->Add( m_txScript, 0, wxALL, 5 ); + + m_btRun = new wxButton( this, wxID_ANY, wxT("&Run"), wxDefaultPosition, wxDefaultSize, 0 ); + bSizer4->Add( m_btRun, 0, wxALL, 5 ); + + this->SetSizer( bSizer4 ); + this->Layout(); + + this->Centre( wxBOTH ); + + // Connect Events + m_btRun->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCRIPTING_BASE::OnRunButtonClick ), NULL, this ); +} + +DIALOG_SCRIPTING_BASE::~DIALOG_SCRIPTING_BASE() +{ + // Disconnect Events + m_btRun->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_SCRIPTING_BASE::OnRunButtonClick ), NULL, this ); + +} diff --git a/pcbnew/dialogs/dialog_scripting_base.fbp b/pcbnew/dialogs/dialog_scripting_base.fbp new file mode 100644 index 0000000000..0852d2f913 --- /dev/null +++ b/pcbnew/dialogs/dialog_scripting_base.fbp @@ -0,0 +1,207 @@ + + + + + + C++ + 1 + source_name + 0 + UTF-8 + connect + dialog_scripting_base + 1000 + none + 0 + DIALOG_SCRIPTING_BASE + + . + + 1 + 1 + 0 + 0 + + + wxBOTH + + 1 + 1 + impl_virtual + + + + 0 + wxID_ANY + + + DIALOG_SCRIPTING_BASE + + 500,600 + wxDEFAULT_FRAME_STYLE + + Scripting Test Window + + + wxFILTER_NONE + wxDefaultValidator + + + + wxTAB_TRAVERSAL + 1 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + bSizer4 + wxVERTICAL + none + + 5 + wxALL + 0 + + + + 1 + 1 + + + 0 + wxID_ANY + + 0 + 480,500 + m_txScript + protected + + + wxHSCROLL|wxTE_MULTILINE + + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + + + 1 + 0 + 1 + + + 0 + wxID_ANY + &Run + + + m_btRun + protected + + + + + + + wxFILTER_NONE + wxDefaultValidator + + + + + OnRunButtonClick + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/pcbnew/dialogs/dialog_scripting_base.h b/pcbnew/dialogs/dialog_scripting_base.h new file mode 100644 index 0000000000..87dc68b746 --- /dev/null +++ b/pcbnew/dialogs/dialog_scripting_base.h @@ -0,0 +1,46 @@ +/////////////////////////////////////////////////////////////////////////// +// C++ code generated with wxFormBuilder (version Sep 8 2010) +// http://www.wxformbuilder.org/ +// +// PLEASE DO "NOT" EDIT THIS FILE! +/////////////////////////////////////////////////////////////////////////// + +#ifndef __dialog_scripting_base__ +#define __dialog_scripting_base__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/////////////////////////////////////////////////////////////////////////// + + +/////////////////////////////////////////////////////////////////////////////// +/// Class DIALOG_SCRIPTING_BASE +/////////////////////////////////////////////////////////////////////////////// +class DIALOG_SCRIPTING_BASE : public wxFrame +{ + private: + + protected: + wxTextCtrl* m_txScript; + wxButton* m_btRun; + + // Virtual event handlers, overide them in your derived class + virtual void OnRunButtonClick( wxCommandEvent& event ) { event.Skip(); } + + + public: + + DIALOG_SCRIPTING_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = wxT("Scripting Test Window"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 500,600 ), long style = wxDEFAULT_FRAME_STYLE|wxTAB_TRAVERSAL ); + ~DIALOG_SCRIPTING_BASE(); + +}; + +#endif //__dialog_scripting_base__ diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index be4b4871c5..ed9af5708e 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -46,8 +46,11 @@ #include #include #include +#include +#include + // Colors for layers and items COLORS_DESIGN_SETTINGS g_ColorsSettings; int g_DrawDefaultLineThickness = 60; /* Default line thickness in PCnew units used to draw @@ -131,6 +134,12 @@ static void swig_add_builtin() { } +static BOARD *st_board; + +BOARD *GetBoard() +{ + return st_board; +} bool EDA_APP::OnInit() { @@ -244,6 +253,8 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); */ frame->SetFocus(); frame->GetCanvas()->SetFocus(); - + st_board = frame->GetBoard(); + DIALOG_SCRIPTING* sw = new DIALOG_SCRIPTING(frame); + sw->Show(true); return true; } diff --git a/pcbnew/scripting/pcbnew.i b/pcbnew/scripting/pcbnew.i index 5754c54be3..8301253399 100644 --- a/pcbnew/scripting/pcbnew.i +++ b/pcbnew/scripting/pcbnew.i @@ -8,6 +8,9 @@ #include #include #include + + + BOARD *GetBoard(); %} %include @@ -16,7 +19,7 @@ %include - +BOARD *GetBoard(); /*%template(BOARD_ITEM_List) DLIST; %template(MODULE_List) DLIST;