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 );
}
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<wxFormBuilder_Project>
<FileVersion major="1" minor="10" />
<object class="Project" expanded="1">
<property name="class_decoration"></property>
<property name="code_generation">C++</property>
<property name="disconnect_events">1</property>
<property name="disconnect_mode">source_name</property>
<property name="disconnect_python_events">0</property>
<property name="encoding">UTF-8</property>
<property name="event_generation">connect</property>
<property name="file">dialog_scripting_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">0</property>
<property name="name">DIALOG_SCRIPTING_BASE</property>
<property name="namespace"></property>
<property name="path">.</property>
<property name="precompiled_header"></property>
<property name="relative_path">1</property>
<property name="skip_python_events">1</property>
<property name="use_enum">0</property>
<property name="use_microsoft_bom">0</property>
<object class="Frame" expanded="1">
<property name="bg"></property>
<property name="center">wxBOTH</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="event_handler">impl_virtual</property>
<property name="extra_style"></property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">DIALOG_SCRIPTING_BASE</property>
<property name="pos"></property>
<property name="size">500,600</property>
<property name="style">wxDEFAULT_FRAME_STYLE</property>
<property name="subclass"></property>
<property name="title">Scripting Test Window</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style">wxTAB_TRAVERSAL</property>
<property name="xrc_skip_sizer">1</property>
<event name="OnActivate"></event>
<event name="OnActivateApp"></event>
<event name="OnChar"></event>
<event name="OnClose"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnHibernate"></event>
<event name="OnIconize"></event>
<event name="OnIdle"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer4</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxTextCtrl" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="maximum_size"></property>
<property name="maxlength">0</property>
<property name="minimum_size">480,500</property>
<property name="name">m_txScript</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style">wxHSCROLL|wxTE_MULTILINE</property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="value"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnText"></event>
<event name="OnTextEnter"></event>
<event name="OnTextMaxLen"></event>
<event name="OnTextURL"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="bg"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">&amp;Run</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_btRun</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass"></property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">OnRunButtonClick</event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
</object>
</object>
</object>
</wxFormBuilder_Project>
///////////////////////////////////////////////////////////////////////////
// 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