Commit b21dbd95 authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

Added a starting scripting dialog for tests

parent d7692cd1
...@@ -86,6 +86,8 @@ set(PCBNEW_DIALOGS ...@@ -86,6 +86,8 @@ set(PCBNEW_DIALOGS
dialogs/dialog_SVG_print.cpp dialogs/dialog_SVG_print.cpp
dialogs/dialog_SVG_print_base.cpp dialogs/dialog_SVG_print_base.cpp
dialogs/dialog_set_grid_base.cpp dialogs/dialog_set_grid_base.cpp
dialogs/dialog_scripting_base.cpp
dialogs/dialog_scripting.cpp
) )
set(PCBNEW_SRCS set(PCBNEW_SRCS
......
/**
* @file dialog_scripting.cpp
*/
#include <fctsys.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <pcbcommon.h>
#include <dialog_scripting.h>
#include <Python.h>
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());
}
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_scripting.h
/////////////////////////////////////////////////////////////////////////////
#ifndef _DIALOG_SCRIPTING_H_
#define _DIALOG_SCRIPTING_H_
#include <dialog_scripting_base.h>
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_
///////////////////////////////////////////////////////////////////////////
// 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 );
}
This diff is collapsed.
///////////////////////////////////////////////////////////////////////////
// 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 <wx/string.h>
#include <wx/textctrl.h>
#include <wx/gdicmn.h>
#include <wx/font.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/frame.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// 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__
...@@ -46,8 +46,11 @@ ...@@ -46,8 +46,11 @@
#include <hotkeys.h> #include <hotkeys.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
#include <Python.h> #include <Python.h>
#include <class_board.h>
#include <dialogs/dialog_scripting.h>
// Colors for layers and items // Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings; COLORS_DESIGN_SETTINGS g_ColorsSettings;
int g_DrawDefaultLineThickness = 60; /* Default line thickness in PCnew units used to draw int g_DrawDefaultLineThickness = 60; /* Default line thickness in PCnew units used to draw
...@@ -131,6 +134,12 @@ static void swig_add_builtin() { ...@@ -131,6 +134,12 @@ static void swig_add_builtin() {
} }
static BOARD *st_board;
BOARD *GetBoard()
{
return st_board;
}
bool EDA_APP::OnInit() bool EDA_APP::OnInit()
{ {
...@@ -244,6 +253,8 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); ...@@ -244,6 +253,8 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
*/ */
frame->SetFocus(); frame->SetFocus();
frame->GetCanvas()->SetFocus(); frame->GetCanvas()->SetFocus();
st_board = frame->GetBoard();
DIALOG_SCRIPTING* sw = new DIALOG_SCRIPTING(frame);
sw->Show(true);
return true; return true;
} }
...@@ -8,6 +8,9 @@ ...@@ -8,6 +8,9 @@
#include <class_module.h> #include <class_module.h>
#include <class_track.h> #include <class_track.h>
#include <class_pad.h> #include <class_pad.h>
BOARD *GetBoard();
%} %}
%include <class_board_item.h> %include <class_board_item.h>
...@@ -16,7 +19,7 @@ ...@@ -16,7 +19,7 @@
%include <class_track.h> %include <class_track.h>
BOARD *GetBoard();
/*%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>; /*%template(BOARD_ITEM_List) DLIST<BOARD_ITEM>;
%template(MODULE_List) DLIST<MODULE>; %template(MODULE_List) DLIST<MODULE>;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment