Commit 4dc70b2f authored by Miguel Angel Ajo's avatar Miguel Angel Ajo

wxGrid instead of list, now we do really have values...

parent 4ead38a8
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
{ {
wxString msg; wxString msg;
int page;
switch( event.GetId() ) switch( event.GetId() )
{ {
...@@ -35,7 +36,7 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event ) ...@@ -35,7 +36,7 @@ void FOOTPRINT_WIZARD_FRAME::Process_Special_Functions( wxCommandEvent& event )
break; break;
case ID_FOOTPRINT_WIZARD_PREVIOUS: case ID_FOOTPRINT_WIZARD_PREVIOUS:
int page = m_PageList->GetSelection()-1; page = m_PageList->GetSelection()-1;
if (page<0) page=0; if (page<0) page=0;
m_PageList->SetSelection(page,true); m_PageList->SetSelection(page,true);
break; break;
......
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
#include <pcbnew_id.h> #include <pcbnew_id.h>
#include "footprint_wizard_frame.h" #include "footprint_wizard_frame.h"
#include <footprint_info.h> #include <footprint_info.h>
#include <wx/grid.h>
#include <hotkeys.h> #include <hotkeys.h>
#include <wildcards_and_files_ext.h> #include <wildcards_and_files_ext.h>
...@@ -73,7 +74,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME ) ...@@ -73,7 +74,7 @@ BEGIN_EVENT_TABLE( FOOTPRINT_WIZARD_FRAME, EDA_DRAW_FRAME )
/* listbox events */ /* listbox events */
EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList ) EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PAGE_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnPageList )
EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnParameterList ) EVT_LISTBOX( ID_FOOTPRINT_WIZARD_PARAMETER_LIST, FOOTPRINT_WIZARD_FRAME::ClickOnParameterGrid )
EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset ) EVT_MENU( ID_SET_RELATIVE_OFFSET, FOOTPRINT_WIZARD_FRAME::OnSetRelativeOffset )
END_EVENT_TABLE() END_EVENT_TABLE()
...@@ -111,15 +112,15 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s ...@@ -111,15 +112,15 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
// Give an icon // Give an icon
wxIcon icon; wxIcon icon;
icon.CopyFromBitmap( KiBitmap( modview_icon_xpm ) ); icon.CopyFromBitmap( KiBitmap( module_wizard_xpm) );
SetIcon( icon ); SetIcon( icon );
m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr; m_HotkeysZoomAndGridList = g_Module_Viewer_Hokeys_Descr;
m_FootprintWizard = NULL; m_FootprintWizard = NULL;
m_PageList= NULL; m_PageList= NULL;
m_ParameterList = NULL; m_ParameterGrid = NULL;
m_PageListWindow = NULL; m_PageListWindow = NULL;
m_ParameterListWindow = NULL; m_ParameterGridWindow = NULL;
m_Semaphore = semaphore; m_Semaphore = semaphore;
m_wizardName.Empty(); m_wizardName.Empty();
...@@ -160,22 +161,21 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s ...@@ -160,22 +161,21 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
0, NULL, wxLB_HSCROLL ); 0, NULL, wxLB_HSCROLL );
// Creates the component window display // Creates the component window display
m_ParameterListSize.y = size.y; m_ParameterGridSize.y = size.y;
win_pos.x = m_PageListSize.x; win_pos.x = m_PageListSize.x;
m_ParameterListWindow = new wxSashLayoutWindow( this, m_ParameterGridWindow = new wxSashLayoutWindow( this,
ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW, ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW,
win_pos, wxDefaultSize, win_pos, wxDefaultSize,
wxCLIP_CHILDREN | wxSW_3D, wxCLIP_CHILDREN | wxSW_3D,
wxT( "ParameterList" ) ); wxT( "ParameterList" ) );
m_ParameterListWindow->SetOrientation( wxLAYOUT_VERTICAL ); m_ParameterGridWindow->SetOrientation( wxLAYOUT_VERTICAL );
m_ParameterListWindow->SetSashVisible( wxSASH_RIGHT, true );
m_ParameterListWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
m_ParameterList = new wxListBox( m_ParameterListWindow, ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
wxPoint( 0, 0 ), wxDefaultSize,
0, NULL, wxLB_HSCROLL );
m_ParameterGridWindow->SetSashVisible( wxSASH_RIGHT, true );
m_ParameterGridWindow->SetExtraBorderSize( EXTRA_BORDER_SIZE );
m_ParameterGrid = new wxGrid(m_ParameterGridWindow,ID_FOOTPRINT_WIZARD_PARAMETER_LIST,
wxPoint(0,0),wxDefaultSize);
ReCreatePageList(); ReCreatePageList();
DisplayWizardInfos(); DisplayWizardInfos();
...@@ -211,8 +211,8 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s ...@@ -211,8 +211,8 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
Left().Row( 0 )); Left().Row( 0 ));
// Manage the list of parameters) // Manage the list of parameters)
m_auimgr.AddPane( m_ParameterListWindow, m_auimgr.AddPane( m_ParameterGridWindow,
wxAuiPaneInfo( info ).Name( wxT( "m_ParameterList" ) ). wxAuiPaneInfo( info ).Name( wxT( "m_ParameterGrid" ) ).
Left().Row( 1 ) ); Left().Row( 1 ) );
// Manage the draw panel // Manage the draw panel
...@@ -231,8 +231,8 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s ...@@ -231,8 +231,8 @@ FOOTPRINT_WIZARD_FRAME::FOOTPRINT_WIZARD_FRAME( wxWindow* parent, wxSemaphore* s
wxAuiPaneInfo& pane = m_auimgr.GetPane(m_PageListWindow); wxAuiPaneInfo& pane = m_auimgr.GetPane(m_PageListWindow);
pane.MinSize( wxSize(m_PageListSize.x, -1)); pane.MinSize( wxSize(m_PageListSize.x, -1));
} }
wxAuiPaneInfo& pane = m_auimgr.GetPane(m_ParameterListWindow); wxAuiPaneInfo& pane = m_auimgr.GetPane(m_ParameterGridWindow);
pane.MinSize(wxSize(m_ParameterListSize.x, -1)); pane.MinSize(wxSize(m_ParameterGridSize.x, -1));
m_auimgr.Update(); m_auimgr.Update();
...@@ -283,7 +283,7 @@ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event ) ...@@ -283,7 +283,7 @@ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event )
return; return;
m_PageListSize.y = GetClientSize().y - m_MsgFrameHeight; m_PageListSize.y = GetClientSize().y - m_MsgFrameHeight;
m_ParameterListSize.y = m_PageListSize.y; m_ParameterGridSize.y = m_PageListSize.y;
switch( event.GetId() ) switch( event.GetId() )
{ {
...@@ -299,9 +299,9 @@ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event ) ...@@ -299,9 +299,9 @@ void FOOTPRINT_WIZARD_FRAME::OnSashDrag( wxSashEvent& event )
case ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW: case ID_FOOTPRINT_WIZARD_PARAMETERS_WINDOW:
{ {
wxAuiPaneInfo& pane = m_auimgr.GetPane( m_ParameterListWindow ); wxAuiPaneInfo& pane = m_auimgr.GetPane( m_ParameterGridWindow );
m_ParameterListSize.x = event.GetDragRect().width; m_ParameterGridSize.x = event.GetDragRect().width;
pane.MinSize( m_ParameterListSize ); pane.MinSize( m_ParameterGridSize );
m_auimgr.Update(); m_auimgr.Update();
} }
break; break;
...@@ -352,7 +352,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList() ...@@ -352,7 +352,7 @@ void FOOTPRINT_WIZARD_FRAME::ReCreatePageList()
void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
{ {
if( m_ParameterList == NULL ) if( m_ParameterGrid == NULL )
return; return;
if (m_FootprintWizard == NULL ) if (m_FootprintWizard == NULL )
...@@ -363,13 +363,38 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList() ...@@ -363,13 +363,38 @@ void FOOTPRINT_WIZARD_FRAME::ReCreateParameterList()
if (page<0) if (page<0)
return; return;
m_ParameterList->Clear(); m_ParameterGrid->ClearGrid();
// Columns
m_ParameterGrid->AutoSizeColumns();
m_ParameterGrid->SetColLabelSize( 20 );
m_ParameterGrid->SetColLabelValue( 0, _("Parameter") );
m_ParameterGrid->SetColLabelValue( 1, _("Value") );
m_ParameterGrid->SetColLabelAlignment( wxALIGN_LEFT, wxALIGN_CENTRE );
// Rows
m_ParameterGrid->AutoSizeRows();
m_ParameterGrid->EnableDragRowSize( true );
m_ParameterGrid->SetRowLabelSize( 1 );
m_ParameterGrid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
wxArrayString fpList = m_FootprintWizard->GetParameterNames(page); wxArrayString fpList = m_FootprintWizard->GetParameterNames(page);
wxArrayString fvList = m_FootprintWizard->GetParameterValues(page);
m_ParameterGrid->CreateGrid(fpList.size(),2);
for (unsigned int i=0;i<fpList.size();i++)
{
m_ParameterGrid->SetCellValue( i, 0, fpList[i] );
m_ParameterGrid->SetReadOnly( i, 0 );
m_ParameterGrid->SetCellValue( i, 1 , fvList[i] );
}
m_ParameterGrid->AutoSizeColumns();
m_ParameterList->Append( fpList );
m_ParameterList->SetSelection( 0, true );
} }
...@@ -387,15 +412,14 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event ) ...@@ -387,15 +412,14 @@ void FOOTPRINT_WIZARD_FRAME::ClickOnPageList( wxCommandEvent& event )
} }
void FOOTPRINT_WIZARD_FRAME::ClickOnParameterList( wxCommandEvent& event ) void FOOTPRINT_WIZARD_FRAME::ClickOnParameterGrid( wxCommandEvent& event )
{ {
int ii = m_ParameterList->GetSelection(); int n=m_ParameterGrid->GetNumberRows();
if( ii < 0 ) for (int i=0;i<n;i++)
return; {
// Get values, send them to the object..
wxString name = m_ParameterList->GetString( ii ); }
ReloadFootprint(); ReloadFootprint();
...@@ -418,17 +442,17 @@ void FOOTPRINT_WIZARD_FRAME::LoadSettings( ) ...@@ -418,17 +442,17 @@ void FOOTPRINT_WIZARD_FRAME::LoadSettings( )
cfg = wxGetApp().GetSettings(); cfg = wxGetApp().GetSettings();
m_PageListSize.x = 150; // default width of libs list m_PageListSize.x = 150; // default width of libs list
m_ParameterListSize.x = 150; // default width of component list m_ParameterGridSize.x = 250; // default width of component list
cfg->Read( PARTLIST_WIDTH_KEY , &m_PageListSize.x ); cfg->Read( PARTLIST_WIDTH_KEY , &m_PageListSize.x );
cfg->Read( PARAMLIST_WIDTH_KEY, &m_ParameterListSize.x ); cfg->Read( PARAMLIST_WIDTH_KEY, &m_ParameterGridSize.x );
// Set parameters to a reasonable value. // Set parameters to a reasonable value.
if ( m_PageListSize.x > m_FrameSize.x/2 ) if ( m_PageListSize.x > m_FrameSize.x/2 )
m_PageListSize.x = m_FrameSize.x/2; m_PageListSize.x = m_FrameSize.x/2;
if ( m_ParameterListSize.x > m_FrameSize.x/2 ) if ( m_ParameterGridSize.x > m_FrameSize.x/2 )
m_ParameterListSize.x = m_FrameSize.x/2; m_ParameterGridSize.x = m_FrameSize.x/2;
} }
...@@ -444,7 +468,7 @@ void FOOTPRINT_WIZARD_FRAME::SaveSettings() ...@@ -444,7 +468,7 @@ void FOOTPRINT_WIZARD_FRAME::SaveSettings()
if ( m_PageListSize.x ) if ( m_PageListSize.x )
cfg->Write( PARTLIST_WIDTH_KEY, m_PageListSize.x ); cfg->Write( PARTLIST_WIDTH_KEY, m_PageListSize.x );
cfg->Write( PARAMLIST_WIDTH_KEY, m_ParameterListSize.x ); cfg->Write( PARAMLIST_WIDTH_KEY, m_ParameterGridSize.x );
} }
......
...@@ -36,6 +36,7 @@ ...@@ -36,6 +36,7 @@
class wxSashLayoutWindow; class wxSashLayoutWindow;
class wxListBox; class wxListBox;
class wxSemaphore; class wxSemaphore;
class wxGrid;
/** /**
...@@ -50,9 +51,9 @@ private: ...@@ -50,9 +51,9 @@ private:
wxSize m_PageListSize; // size of the window wxSize m_PageListSize; // size of the window
// List of components in the selected library // List of components in the selected library
wxSashLayoutWindow* m_ParameterListWindow; wxSashLayoutWindow* m_ParameterGridWindow;
wxListBox* m_ParameterList; // The list of parameters wxGrid* m_ParameterGrid; // The list of parameters
wxSize m_ParameterListSize; // size of the window wxSize m_ParameterGridSize; // size of the window
// Flags // Flags
wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog wxSemaphore* m_Semaphore; // != NULL if the frame must emulate a modal dialog
...@@ -103,7 +104,7 @@ private: ...@@ -103,7 +104,7 @@ private:
void ReCreateVToolbar(); void ReCreateVToolbar();
void OnLeftClick( wxDC* DC, const wxPoint& MousePos ); void OnLeftClick( wxDC* DC, const wxPoint& MousePos );
void ClickOnPageList( wxCommandEvent& event ); void ClickOnPageList( wxCommandEvent& event );
void ClickOnParameterList( wxCommandEvent& event ); void ClickOnParameterGrid( wxCommandEvent& event );
void OnSetRelativeOffset( wxCommandEvent& event ); void OnSetRelativeOffset( wxCommandEvent& event );
void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 ); void GeneralControl( wxDC* aDC, const wxPoint& aPosition, int aHotKey = 0 );
......
...@@ -17,6 +17,14 @@ class FPCFootprintWizard(FootprintWizardPlugin): ...@@ -17,6 +17,14 @@ class FPCFootprintWizard(FootprintWizardPlugin):
} }
def GetParameterValues(self,page_n):
name = self.GetParameterPageName(page_n)
values = self.parameters[name].values()
str_values = map( lambda x: str(x) , values)
print values,str_values
return str_values
def smdRectPad(self,module,size,pos,name): def smdRectPad(self,module,size,pos,name):
pad = D_PAD(module) pad = D_PAD(module)
# print "smdRectPad( size=",size,"pos=",pos,"name=",name,")" # print "smdRectPad( size=",size,"pos=",pos,"name=",name,")"
...@@ -70,10 +78,7 @@ class FPCFootprintWizard(FootprintWizardPlugin): ...@@ -70,10 +78,7 @@ class FPCFootprintWizard(FootprintWizardPlugin):
module.Add(pad_s1) module.Add(pad_s1)
e = EDGE_MODULE(module) e = EDGE_MODULE(module)
e.SetStart0(wxPointMM(-1,0)) e.SetStartEnd(wxPointMM(-1,0),wxPointMM(0,0))
e.SetStart(wxPointMM(-1,0))
e.SetEnd0(wxPointMM(0,0))
e.SetEnd(wxPointMM(0,0))
e.SetWidth(FromMM(0.2)) e.SetWidth(FromMM(0.2))
e.SetLayer(EDGE_LAYER) e.SetLayer(EDGE_LAYER)
e.SetShape(S_SEGMENT) e.SetShape(S_SEGMENT)
......
...@@ -84,14 +84,11 @@ class FootprintWizardPlugin(KiCadPlugin): ...@@ -84,14 +84,11 @@ class FootprintWizardPlugin(KiCadPlugin):
def GetParameterNames(self,page_n): def GetParameterNames(self,page_n):
name = self.GetParameterPageName(page_n) name = self.GetParameterPageName(page_n)
return self.parameters[name].keys() return self.parameters[name].keys()
def GetParameterValues(self,page_n):
name = self.GetParameterPageName(page_n)
return self.parameters[name].keys()
def GetParameterValues(self,page_n): def GetParameterValues(self,page_n):
name = self.GetParameterPageName(page_n) name = self.GetParameterPageName(page_n)
return self.parameters[name].values() values = self.parameters[name].values()
return map( lambda x: str(x) , values)
def SetParameterValues(self,page_n,values): def SetParameterValues(self,page_n,values):
......
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