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

footprint wizard UI and footprint wizard lists

parent 23bec4b8
......@@ -99,6 +99,8 @@ set(PCBNEW_DIALOGS
dialogs/dialog_scripting.cpp
footprint_wizard.cpp
footprint_wizard_frame.cpp
dialogs/dialog_footprint_wizard_list_base.cpp
dialogs/dialog_footprint_wizard_list.cpp
)
# some of the files here may be going to the dialog srcs in fact....
......
......@@ -13,6 +13,32 @@ void FOOTPRINT_WIZARD::register_wizard()
std::vector<FOOTPRINT_WIZARD*> FOOTPRINT_WIZARDS::m_FootprintWizards;
FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard(int aIndex)
{
return m_FootprintWizards[aIndex];
}
FOOTPRINT_WIZARD* FOOTPRINT_WIZARDS::GetWizard(wxString aName)
{
int max = GetSize();
for(int i=0; i<max;i++)
{
FOOTPRINT_WIZARD *wizard = GetWizard(i);
wxString name = wizard->GetName();
if (name.Cmp(aName))
return wizard;
}
return NULL;
}
int FOOTPRINT_WIZARDS::GetSize()
{
return m_FootprintWizards.size();
}
void FOOTPRINT_WIZARDS::register_wizard(FOOTPRINT_WIZARD *aWizard)
{
......
......@@ -37,6 +37,9 @@ private:
public:
static void register_wizard(FOOTPRINT_WIZARD *wizard);
static FOOTPRINT_WIZARD* GetWizard(wxString aName);
static FOOTPRINT_WIZARD* GetWizard(int aIndex);
static int GetSize();
};
......
/**
* @file dialog_scripting.cpp
*/
#include <wx-2.8/wx/generic/grid.h>
#include <fctsys.h>
#include <pcbnew.h>
#include <wxPcbStruct.h>
#include <pcbcommon.h>
#include <dialog_footprint_wizard_list.h>
#include <class_footprint_wizard.h>
DIALOG_FOOTPRINT_WIZARD_LIST::DIALOG_FOOTPRINT_WIZARD_LIST( wxWindow* aParent )
: DIALOG_FOOTPRINT_WIZARD_LIST_BASE( aParent )
{
SetFocus();
int n_wizards = FOOTPRINT_WIZARDS::GetSize();
// Current wizard selection, empty or first
m_FootprintWizard = NULL;
if (n_wizards)
m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard(0);
// Choose selection mode and insert the needed rows
m_footprintWizardsGrid->SetSelectionMode(wxGrid::wxGridSelectRows);
m_footprintWizardsGrid->InsertRows(0,n_wizards,true);
// Put all wizards in the list
for (int i=0;i<n_wizards;i++)
{
FOOTPRINT_WIZARD *wizard = FOOTPRINT_WIZARDS::GetWizard(i);
wxString name = wizard->GetName();
wxString description = wizard->GetDescription();
wxString image = wizard->GetImage();
m_footprintWizardsGrid->SetCellValue(i,1,name);
m_footprintWizardsGrid->SetCellValue(i,2,description);
}
// Select the first row
m_footprintWizardsGrid->ClearSelection();
m_footprintWizardsGrid->SelectRow(0,false);
}
void DIALOG_FOOTPRINT_WIZARD_LIST::OnCellWizardClick( wxGridEvent& event )
{
int click_row = event.GetRow();
m_FootprintWizard = FOOTPRINT_WIZARDS::GetWizard(click_row);
}
FOOTPRINT_WIZARD* DIALOG_FOOTPRINT_WIZARD_LIST::GetWizard()
{
return m_FootprintWizard;
}
void DIALOG_FOOTPRINT_WIZARD_LIST::OnOpenButtonClick( wxCommandEvent& event )
{
this->MakeModal(false);
this->Close(true);
}
<?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_footprint_wizard_list_base</property>
<property name="first_id">1000</property>
<property name="help_provider">none</property>
<property name="internationalize">1</property>
<property name="name">DIALOG_FOOTPRINT_WIZARD_LIST_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="Dialog" 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_FOOTPRINT_WIZARD_LIST_BASE</property>
<property name="pos"></property>
<property name="size"></property>
<property name="style">wxDEFAULT_DIALOG_STYLE</property>
<property name="subclass"></property>
<property name="title">Footprint Wizards</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="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="OnInitDialog"></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">1</property>
<object class="wxGrid" expanded="1">
<property name="autosize_cols">0</property>
<property name="autosize_rows">1</property>
<property name="bg"></property>
<property name="cell_bg"></property>
<property name="cell_font"></property>
<property name="cell_horiz_alignment">wxALIGN_LEFT</property>
<property name="cell_text"></property>
<property name="cell_vert_alignment">wxALIGN_TOP</property>
<property name="col_label_horiz_alignment">wxALIGN_LEFT</property>
<property name="col_label_size">20</property>
<property name="col_label_values">&quot;Preview&quot; &quot;Name&quot; &quot;Description&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">3</property>
<property name="column_sizes">80,80,325</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="drag_col_move">0</property>
<property name="drag_col_size">1</property>
<property name="drag_grid_size">0</property>
<property name="drag_row_size">1</property>
<property name="editing">0</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label_bg"></property>
<property name="label_font"></property>
<property name="label_text"></property>
<property name="margin_height">0</property>
<property name="margin_width">0</property>
<property name="maximum_size"></property>
<property name="minimum_size">-1,120</property>
<property name="name">m_footprintWizardsGrid</property>
<property name="permission">protected</property>
<property name="pos"></property>
<property name="row_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="row_label_size">1</property>
<property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="row_sizes"></property>
<property name="rows">0</property>
<property name="size"></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="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellLeftClick">OnCellWizardClick</event>
<event name="OnGridCellLeftDClick"></event>
<event name="OnGridCellRightClick"></event>
<event name="OnGridCellRightDClick"></event>
<event name="OnGridCmdCellChange"></event>
<event name="OnGridCmdCellLeftClick"></event>
<event name="OnGridCmdCellLeftDClick"></event>
<event name="OnGridCmdCellRightClick"></event>
<event name="OnGridCmdCellRightDClick"></event>
<event name="OnGridCmdColSize"></event>
<event name="OnGridCmdEditorCreated"></event>
<event name="OnGridCmdEditorHidden"></event>
<event name="OnGridCmdEditorShown"></event>
<event name="OnGridCmdLabelLeftClick"></event>
<event name="OnGridCmdLabelLeftDClick"></event>
<event name="OnGridCmdLabelRightClick"></event>
<event name="OnGridCmdLabelRightDClick"></event>
<event name="OnGridCmdRangeSelect"></event>
<event name="OnGridCmdRowSize"></event>
<event name="OnGridCmdSelectCell"></event>
<event name="OnGridColSize"></event>
<event name="OnGridEditorCreated"></event>
<event name="OnGridEditorHidden"></event>
<event name="OnGridEditorShown"></event>
<event name="OnGridLabelLeftClick"></event>
<event name="OnGridLabelLeftDClick"></event>
<event name="OnGridLabelRightClick"></event>
<event name="OnGridLabelRightDClick"></event>
<event name="OnGridRangeSelect"></event>
<event name="OnGridRowSize"></event>
<event name="OnGridSelectCell"></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 class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER|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">Open</property>
<property name="maximum_size"></property>
<property name="minimum_size"></property>
<property name="name">m_btOpen</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">OnOpenButtonClick</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>
/////////////////////////////////////////////////////////////////////////////
// Name: dialog_footprint_wizard_list.h
/////////////////////////////////////////////////////////////////////////////
#ifndef _DIALOG_FOOTPRINT_WIZARD_LIST_H_
#define _DIALOG_FOOTPRINT_WIZARD_LIST_H_
#include <dialog_footprint_wizard_list_base.h>
#include <class_footprint_wizard.h>
class DIALOG_FOOTPRINT_WIZARD_LIST: public DIALOG_FOOTPRINT_WIZARD_LIST_BASE
{
private:
wxDialog * m_Parent;
FOOTPRINT_WIZARD *m_FootprintWizard;
public:
DIALOG_FOOTPRINT_WIZARD_LIST(wxWindow * parent );
FOOTPRINT_WIZARD* GetWizard();
private:
void OnCellWizardClick( wxGridEvent& event );
void OnOpenButtonClick( wxCommandEvent& event );
};
#endif // _DIALOG_FOOTPRINT_WIZARD_LIST_H_
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#include "dialog_footprint_wizard_list_base.h"
///////////////////////////////////////////////////////////////////////////
DIALOG_FOOTPRINT_WIZARD_LIST_BASE::DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow* parent, wxWindowID id, const wxString& title, const wxPoint& pos, const wxSize& size, long style ) : wxDialog( parent, id, title, pos, size, style )
{
this->SetSizeHints( wxDefaultSize, wxDefaultSize );
wxBoxSizer* bSizer4;
bSizer4 = new wxBoxSizer( wxVERTICAL );
m_footprintWizardsGrid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 );
// Grid
m_footprintWizardsGrid->CreateGrid( 0, 3 );
m_footprintWizardsGrid->EnableEditing( false );
m_footprintWizardsGrid->EnableGridLines( true );
m_footprintWizardsGrid->EnableDragGridSize( false );
m_footprintWizardsGrid->SetMargins( 0, 0 );
// Columns
m_footprintWizardsGrid->SetColSize( 0, 80 );
m_footprintWizardsGrid->SetColSize( 1, 80 );
m_footprintWizardsGrid->SetColSize( 2, 325 );
m_footprintWizardsGrid->EnableDragColMove( false );
m_footprintWizardsGrid->EnableDragColSize( true );
m_footprintWizardsGrid->SetColLabelSize( 20 );
m_footprintWizardsGrid->SetColLabelValue( 0, _("Preview") );
m_footprintWizardsGrid->SetColLabelValue( 1, _("Name") );
m_footprintWizardsGrid->SetColLabelValue( 2, _("Description") );
m_footprintWizardsGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
// Rows
m_footprintWizardsGrid->AutoSizeRows();
m_footprintWizardsGrid->EnableDragRowSize( true );
m_footprintWizardsGrid->SetRowLabelSize( 1 );
m_footprintWizardsGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_footprintWizardsGrid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_footprintWizardsGrid->SetMinSize( wxSize( -1,120 ) );
bSizer4->Add( m_footprintWizardsGrid, 1, wxALL, 5 );
m_btOpen = new wxButton( this, wxID_ANY, _("Open"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer4->Add( m_btOpen, 0, wxALIGN_CENTER|wxALL, 5 );
this->SetSizer( bSizer4 );
this->Layout();
bSizer4->Fit( this );
this->Centre( wxBOTH );
// Connect Events
m_footprintWizardsGrid->Connect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnCellWizardClick ), NULL, this );
m_btOpen->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnOpenButtonClick ), NULL, this );
}
DIALOG_FOOTPRINT_WIZARD_LIST_BASE::~DIALOG_FOOTPRINT_WIZARD_LIST_BASE()
{
// Disconnect Events
m_footprintWizardsGrid->Disconnect( wxEVT_GRID_CELL_LEFT_CLICK, wxGridEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnCellWizardClick ), NULL, this );
m_btOpen->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FOOTPRINT_WIZARD_LIST_BASE::OnOpenButtonClick ), NULL, this );
}
///////////////////////////////////////////////////////////////////////////
// C++ code generated with wxFormBuilder (version Sep 8 2010)
// http://www.wxformbuilder.org/
//
// PLEASE DO "NOT" EDIT THIS FILE!
///////////////////////////////////////////////////////////////////////////
#ifndef __dialog_footprint_wizard_list_base__
#define __dialog_footprint_wizard_list_base__
#include <wx/intl.h>
#include <wx/colour.h>
#include <wx/settings.h>
#include <wx/string.h>
#include <wx/font.h>
#include <wx/grid.h>
#include <wx/gdicmn.h>
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
/// Class DIALOG_FOOTPRINT_WIZARD_LIST_BASE
///////////////////////////////////////////////////////////////////////////////
class DIALOG_FOOTPRINT_WIZARD_LIST_BASE : public wxDialog
{
private:
protected:
wxGrid* m_footprintWizardsGrid;
wxButton* m_btOpen;
// Virtual event handlers, overide them in your derived class
virtual void OnCellWizardClick( wxGridEvent& event ) { event.Skip(); }
virtual void OnOpenButtonClick( wxCommandEvent& event ) { event.Skip(); }
public:
DIALOG_FOOTPRINT_WIZARD_LIST_BASE( wxWindow* parent, wxWindowID id = wxID_ANY, const wxString& title = _("Footprint Wizards"), const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxDEFAULT_DIALOG_STYLE );
~DIALOG_FOOTPRINT_WIZARD_LIST_BASE();
};
#endif //__dialog_footprint_wizard_list_base__
......@@ -17,7 +17,7 @@
#include <pcbnew_id.h>
#include "footprint_wizard_frame.h"
#include <wildcards_and_files_ext.h>
#include <dialogs/dialog_footprint_wizard_list.h>
#define NEXT_PART 1
#define NEW_PART 0
......@@ -77,28 +77,31 @@ void FOOTPRINT_WIZARD_FRAME::DisplayWizardInfos()
}
void FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard( wxCommandEvent& event )
void FOOTPRINT_WIZARD_FRAME::SelectFootprintWizard()
{
wxString msg;
if( g_LibraryNames.GetCount() == 0 )
return;
EDA_LIST_DIALOG dlg( this, _( "Select Current Wizard:" ),
g_LibraryNames, m_wizardName );
if( dlg.ShowModal() != wxID_OK )
return;
if( m_wizardName == dlg.GetTextSelection() )
return;
DIALOG_FOOTPRINT_WIZARD_LIST *selectWizard =
new DIALOG_FOOTPRINT_WIZARD_LIST(this);
selectWizard->ShowModal();
m_FootprintWizard = selectWizard->GetWizard();
m_wizardName = dlg.GetTextSelection();
if (m_FootprintWizard)
{
m_wizardName = m_FootprintWizard->GetName();
m_wizardDescription = m_FootprintWizard->GetDescription();
}
DisplayWizardInfos();
ReCreatePageList();
ReCreateParameterList();
}
void FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard( wxCommandEvent& event )
{
SelectFootprintWizard();
}
......
......@@ -58,8 +58,12 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
EVT_SASH_DRAGGED( ID_FOOTPRINT_WIZARD_PARAMETERS, FOOTPRINT_WIZARD_FRAME::OnSashDrag )
/* Toolbar events */
EVT_TOOL( ID_FOOTPRINT_WIZARD_SELECT_WIZARD,
FOOTPRINT_WIZARD_FRAME::SelectCurrentWizard)
EVT_TOOL( ID_FOOTPRINT_WIZARD_NEXT,
FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
EVT_TOOL( ID_FOOTPRINT_WIZARD_PREVIOUS,
FOOTPRINT_WIZARD_FRAME::Process_Special_Functions )
/* EVT_TOOL( ID_FOOTPRINT_WIZARD_DONE,
......@@ -111,6 +115,7 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
SetIcon( icon );
m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr;
m_FootprintWizard = NULL;
m_PageList= NULL;
m_ParameterList = NULL;
m_PageListWindow = NULL;
......@@ -238,7 +243,10 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
Zoom_Automatique( false );
#endif
Show( true );
this->SelectFootprintWizard();
}
......@@ -321,37 +329,21 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
{
if( m_PageList == NULL )
return;
m_PageList->Clear();
m_PageList->Append(wxT("Pads"));
m_PageList->Append(wxT("Shield"));
m_PageList->SetSelection( 0, true );
/*for( unsigned ii = 0; ii < g_LibraryNames.GetCount(); ii++ )
{
m_PageList->Append( g_LibraryNames[ii] );
}*/
#if 0
// Search for a previous selection:
int index = m_PageList->FindString( m_libraryName );
if (m_FootprintWizard == NULL)
return;
if( index != wxNOT_FOUND )
{
m_PageList->SetSelection( index, true );
}
else
m_PageList->Clear();
int max_page = m_FootprintWizard->GetNumParameterPages();
for (int i=0;i<max_page;i++)
{
/* If not found, clear current library selection because it can be
* deleted after a config change. */
m_libraryName = wxEmptyString;
m_footprintName = wxEmptyString;
wxString name = m_FootprintWizard->GetParameterPageName(i);
m_PageList->Append(name);
}
#endif
m_PageList->SetSelection( 0, true );
ReCreateParameterList();
ReCreateHToolbar();
DisplayWizardInfos();
m_canvas->Refresh();
......@@ -362,19 +354,23 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
{
if( m_ParameterList == NULL )
return;
if (m_FootprintWizard == NULL )
return;
int page = m_PageList->GetSelection();
if (page<0)
return;
m_ParameterList->Clear();
wxArrayString fpList;
wxArrayString fpList = m_FootprintWizard->GetParameterNames(page);
m_ParameterList->Append( fpList );
m_ParameterList->Append(wxT("N"));
m_ParameterList->Append(wxT("pitch"));
m_ParameterList->Append(wxT("width"));
m_ParameterList->Append(wxT("height"));
m_ParameterList->SetSelection( 0, true );
//m_ParameterList->SetSelection( index, true );
}
......@@ -383,11 +379,7 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
int ii = m_PageList->GetSelection();
if( ii < 0 )
return;
wxString name = m_PageList->GetString( ii );
printf("page=%d\n",ii);
return;
ReCreateParameterList();
m_canvas->Refresh();
......
......@@ -32,7 +32,7 @@
#include <wx/gdicmn.h>
#include <class_footprint_wizard.h>
class wxSashLayoutWindow;
class wxListBox;
class wxSemaphore;
......@@ -57,6 +57,8 @@ private:
// Flags
wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog
wxString m_configPath; // subpath for configuration
FOOTPRINT_WIZARD* m_FootprintWizard;
protected:
wxString m_wizardName; //< name of the current wizard
......@@ -89,6 +91,8 @@ private:
*/
void ReCreatePageList();
void ReCreateParameterList();
void SelectFootprintWizard();
void Process_Special_Functions( wxCommandEvent& event );
void DisplayWizardInfos();
......
......@@ -73,6 +73,13 @@ wxString PYTHON_FOOTPRINT_WIZARD::CallRetStrMethod(const char* aMethod, PyObject
return ret;
}
wxArrayString PYTHON_FOOTPRINT_WIZARD::CallRetArrayStrMethod
(const char *aMethod, PyObject *aArglist)
{
}
wxString PYTHON_FOOTPRINT_WIZARD::GetName()
{
return CallRetStrMethod("GetName");
......@@ -128,6 +135,23 @@ wxString PYTHON_FOOTPRINT_WIZARD::GetParameterPageName(int aPage)
wxArrayString PYTHON_FOOTPRINT_WIZARD::GetParameterNames(int aPage)
{
wxArrayString a;
wxString ret;
PyObject *arglist;
PyObject *result;
/* Time to call the callback */
arglist = Py_BuildValue("(i)", aPage);
result = CallMethod("GetParameterPageNames",arglist);
Py_DECREF(arglist);
if (result)
{
// TODO GET ITEMS IN LIST
const char *str_res = PyString_AsString(result);
ret = wxString::FromUTF8(str_res);
Py_DECREF(result);
}
return a;
}
......
......@@ -15,6 +15,9 @@ class PYTHON_FOOTPRINT_WIZARD: public FOOTPRINT_WIZARD
PyObject *m_PyWizard;
PyObject *CallMethod(const char *aMethod, PyObject *aArglist=NULL);
wxString CallRetStrMethod(const char *aMethod, PyObject *aArglist=NULL);
wxArrayString CallRetArrayStrMethod(const char *aMethod,
PyObject *aArglist=NULL);
public:
PYTHON_FOOTPRINT_WIZARD(PyObject *wizard);
~PYTHON_FOOTPRINT_WIZARD();
......
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