Commit 76fed4f9 authored by Dick Hollenbeck's avatar Dick Hollenbeck

*) Add PLUGIN::FootprintLibOptions( PROPERTIES* ), and extend DIALOG_FP_PLUGIN_OPTIONS to use it.

*) Move button handlers to LEFT MOUSE CLICK from COMMAND events, so wxGrid focus is not lost.
*) Sketch out the concept of COW support for the GITHUB_PLUGIN in its @todo.
parent 1f1a8853
...@@ -68,9 +68,6 @@ int DIALOG_DESIGN_RULES::s_LastTabSelection = -1; ...@@ -68,9 +68,6 @@ int DIALOG_DESIGN_RULES::s_LastTabSelection = -1;
// methods for the helper class NETS_LIST_CTRL // methods for the helper class NETS_LIST_CTRL
/** OnGetItemText (overlaid method)
* needed by wxListCtrl with wxLC_VIRTUAL options
*/
wxString NETS_LIST_CTRL::OnGetItemText( long item, long column ) const wxString NETS_LIST_CTRL::OnGetItemText( long item, long column ) const
{ {
if( column == 0 ) if( column == 0 )
...@@ -87,14 +84,7 @@ wxString NETS_LIST_CTRL::OnGetItemText( long item, long column ) const ...@@ -87,14 +84,7 @@ wxString NETS_LIST_CTRL::OnGetItemText( long item, long column ) const
} }
/** void NETS_LIST_CTRL::SetRowItems( unsigned aRow,
* Function setRowItems
* Initialize the net name and the net class name at row aRow
* @param aRow = row index (if aRow > number of stored row, empty rows will be created)
* @param aNetname = the string to display in row aRow, column 0
* @param aNetclassName = the string to display in row aRow, column 1
*/
void NETS_LIST_CTRL::setRowItems( unsigned aRow,
const wxString& aNetname, const wxString& aNetname,
const wxString& aNetclassName ) const wxString& aNetclassName )
{ {
...@@ -422,7 +412,7 @@ void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl, ...@@ -422,7 +412,7 @@ void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl,
wxSize class_needed = sDC.GetTextExtent( (*i)->clazz ); wxSize class_needed = sDC.GetTextExtent( (*i)->clazz );
net_colsize = std::max( net_colsize, net_needed.x ); net_colsize = std::max( net_colsize, net_needed.x );
class_colsize = std::max( class_colsize, class_needed.x ); class_colsize = std::max( class_colsize, class_needed.x );
aListCtrl->setRowItems( row, (*i)->net, (*i)->clazz ); aListCtrl->SetRowItems( row, (*i)->net, (*i)->clazz );
} }
int margin = sDC.GetTextExtent( wxT("XX") ).x;; int margin = sDC.GetTextExtent( wxT("XX") ).x;;
......
...@@ -7,39 +7,51 @@ ...@@ -7,39 +7,51 @@
#include <wx/listctrl.h> #include <wx/listctrl.h>
/* helper class to display lists of nets and associated netclasses /**
* Class NETS_LIST_CTRL
* is a helper to display lists of nets and associated netclasses
* used in dialog design rules. * used in dialog design rules.
* It s needed because the 2 wxListCtlr used to display lists of nets * It's needed because the 2 "wxListCtl"s used to display lists of nets
* use the wxLC_VIRTUAL option. * uses the wxLC_VIRTUAL option. The method:
* The virtual wxString OnGetItemText(long item, long column) const method *
* must be overlaid. * virtual wxString OnGetItemText( long item, long column ) const
*
* must be overloaded.
*/ */
class NETS_LIST_CTRL: public wxListCtrl class NETS_LIST_CTRL: public wxListCtrl
{ {
private:
wxArrayString m_Netnames; ///< an array to store the list of nets (column 0)
wxArrayString m_Classnames; ///< an array to store the list of netclasse (column 1)
public: public:
NETS_LIST_CTRL(wxWindow* parent, wxWindowID id, NETS_LIST_CTRL( wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxLC_ICON ):
const wxSize& size = wxDefaultSize,
long style = wxLC_ICON):
wxListCtrl( parent, id, pos, size, style ) wxListCtrl( parent, id, pos, size, style )
{ {
}; };
NETS_LIST_CTRL()
{
};
void setRowItems(unsigned aRow, const wxString & aNetname, const wxString & aNetclassName );
void ClearList() void ClearList()
{ {
SetItemCount(0); SetItemCount( 0 );
m_Netnames.Clear(); m_Netnames.Clear();
m_Classnames.Clear(); m_Classnames.Clear();
} }
virtual wxString OnGetItemText(long item, long column) const; /**
* Function OnGetItemText
* is an overloaded method needed by wxListCtrl with wxLC_VIRTUAL options
*/
virtual wxString OnGetItemText( long item, long column ) const;
/**
* Function SetRowItems
* sets the net name and the net class name at @a aRow.
* @param aRow = row index (if aRow > number of stored row, empty rows will be created)
* @param aNetname = the string to display in row aRow, column 0
* @param aNetclassName = the string to display in row aRow, column 1
*/
void SetRowItems( unsigned aRow, const wxString& aNetname, const wxString& aNetclassName );
private:
wxArrayString m_Netnames; ///< column 0: nets
wxArrayString m_Classnames; ///< column 1: netclasses
}; };
......
...@@ -198,7 +198,7 @@ public: ...@@ -198,7 +198,7 @@ public:
case COL_NICKNAME: return _( "Nickname" ); case COL_NICKNAME: return _( "Nickname" );
case COL_URI: return _( "Library Path" ); case COL_URI: return _( "Library Path" );
// keep this text fairly long so column is sized wide enough // keep this "Plugin Type" text fairly long so column is sized wide enough
case COL_TYPE: return _( "Plugin Type" ); case COL_TYPE: return _( "Plugin Type" );
case COL_OPTIONS: return _( "Options" ); case COL_OPTIONS: return _( "Options" );
case COL_DESCR: return _( "Description" ); case COL_DESCR: return _( "Description" );
...@@ -583,12 +583,16 @@ private: ...@@ -583,12 +583,16 @@ private:
wxString result; wxString result;
const wxString& options = row.GetOptions(); const wxString& options = row.GetOptions();
InvokePluginOptionsEditor( this, row.GetNickName(), options, &result ); InvokePluginOptionsEditor( this, row.GetNickName(), row.GetType(), options, &result );
if( options != result ) if( options != result )
{ {
row.SetOptions( result ); row.SetOptions( result );
m_cur_grid->AutoSizeColumn( COL_OPTIONS, false );
// all but options:
m_cur_grid->AutoSizeColumn( COL_NICKNAME, false );
m_cur_grid->AutoSizeColumn( COL_URI, false );
m_cur_grid->AutoSizeColumn( COL_TYPE, false );
} }
} }
......
...@@ -48,7 +48,8 @@ class DIALOG_FP_PLUGIN_OPTIONS : public DIALOG_FP_PLUGIN_OPTIONS_BASE ...@@ -48,7 +48,8 @@ class DIALOG_FP_PLUGIN_OPTIONS : public DIALOG_FP_PLUGIN_OPTIONS_BASE
public: public:
DIALOG_FP_PLUGIN_OPTIONS( wxTopLevelWindow* aParent, DIALOG_FP_PLUGIN_OPTIONS( wxTopLevelWindow* aParent,
const wxString& aNickname, const wxString& aOptions, wxString* aResult ) : const wxString& aNickname, const wxString& aPluginType,
const wxString& aOptions, wxString* aResult ) :
DIALOG_FP_PLUGIN_OPTIONS_BASE( aParent ), DIALOG_FP_PLUGIN_OPTIONS_BASE( aParent ),
m_callers_options( aOptions ), m_callers_options( aOptions ),
m_result( aResult ) m_result( aResult )
...@@ -61,6 +62,7 @@ public: ...@@ -61,6 +62,7 @@ public:
// add Cut, Copy, and Paste to wxGrid // add Cut, Copy, and Paste to wxGrid
m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) ); m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
// Fill the grid with aOptions
string options = TO_UTF8( aOptions ); string options = TO_UTF8( aOptions );
PROPERTIES* props = FP_LIB_TABLE::ParseOptions( options ); PROPERTIES* props = FP_LIB_TABLE::ParseOptions( options );
...@@ -80,6 +82,31 @@ public: ...@@ -80,6 +82,31 @@ public:
delete props; delete props;
} }
// Option Choices Panel:
IO_MGR::PCB_FILE_T pi_type = IO_MGR::EnumFromStr( aPluginType );
PLUGIN::RELEASER pi( IO_MGR::PluginFind( pi_type ) );
PROPERTIES choices;
pi->FootprintLibOptions( &choices );
if( choices.size() )
{
int needed_rows = (int) choices.size() - m_option_choices->GetNumberRows();
if( needed_rows > 0 )
m_option_choices->AppendRows( needed_rows );
int row = 0;
for( PROPERTIES::const_iterator it = choices.begin(); it != choices.end(); ++it, ++row )
{
DBG(printf( "[%s]:'%s'\n", it->first.c_str(), it->second.c_str() );)
m_option_choices->SetCellValue( row, 0, FROM_UTF8( it->first.c_str() ) );
m_option_choices->SetCellValue( row, 1, FROM_UTF8( it->second.c_str() ) );
}
}
m_option_choices->AutoSizeColumns( false );
if( !col_width_option ) if( !col_width_option )
{ {
m_grid->AutoSizeColumns( false ); m_grid->AutoSizeColumns( false );
...@@ -176,10 +203,7 @@ private: ...@@ -176,10 +203,7 @@ private:
EndModal( 0 ); EndModal( 0 );
} }
int appendRow()
//-----<event handlers>------------------------------------------------------
void onAddRow( wxCommandEvent& event )
{ {
if( m_grid->AppendRows( 1 ) ) if( m_grid->AppendRows( 1 ) )
{ {
...@@ -188,10 +212,47 @@ private: ...@@ -188,10 +212,47 @@ private:
// wx documentation is wrong, SetGridCursor does not make visible. // wx documentation is wrong, SetGridCursor does not make visible.
m_grid->MakeCellVisible( last_row, 0 ); m_grid->MakeCellVisible( last_row, 0 );
m_grid->SetGridCursor( last_row, 0 ); m_grid->SetGridCursor( last_row, 0 );
return last_row;
}
return -1;
} }
//-----<event handlers>------------------------------------------------------
void onAppendOption( wxMouseEvent& event )
{
int selected_row = m_option_choices->GetCursorRow();
if( selected_row >= 0 )
{
wxString option = m_option_choices->GetCellValue( selected_row, 0 );
int row_count = m_grid->GetNumberRows();
int row;
for( row=0; row<row_count; ++row )
{
wxString col0 = m_grid->GetCellValue( row, 0 );
if( !col0 ) // empty col0
break;
}
if( row == row_count )
row = appendRow();
m_grid->SetCellValue( row, 0, option );
m_grid->AutoSizeColumns( false );
}
}
void onAppendRow( wxMouseEvent& event )
{
appendRow();
} }
void onDeleteRow( wxCommandEvent& event ) void onDeleteRow( wxMouseEvent& event )
{ {
int rowCount = m_grid->GetNumberRows(); int rowCount = m_grid->GetNumberRows();
int curRow = getCursorRow(); int curRow = getCursorRow();
...@@ -205,7 +266,7 @@ private: ...@@ -205,7 +266,7 @@ private:
} }
} }
void onMoveUp( wxCommandEvent& event ) void onMoveUp( wxMouseEvent& event )
{ {
int curRow = getCursorRow(); int curRow = getCursorRow();
if( curRow >= 1 ) if( curRow >= 1 )
...@@ -238,7 +299,7 @@ private: ...@@ -238,7 +299,7 @@ private:
} }
} }
void onMoveDown( wxCommandEvent& event ) void onMoveDown( wxMouseEvent& event )
{ {
int curRow = getCursorRow(); int curRow = getCursorRow();
if( curRow + 1 < m_grid->GetNumberRows() ) if( curRow + 1 < m_grid->GetNumberRows() )
...@@ -292,9 +353,10 @@ private: ...@@ -292,9 +353,10 @@ private:
void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller, void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller,
const wxString& aNickname, const wxString& aOptions, wxString* aResult ) const wxString& aNickname, const wxString& aPluginType,
const wxString& aOptions, wxString* aResult )
{ {
DIALOG_FP_PLUGIN_OPTIONS dlg( aCaller, aNickname, aOptions, aResult ); DIALOG_FP_PLUGIN_OPTIONS dlg( aCaller, aNickname, aPluginType, aOptions, aResult );
dlg.ShowModal(); dlg.ShowModal();
} }
...@@ -19,13 +19,14 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, ...@@ -19,13 +19,14 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
wxBoxSizer* m_horizontal_sizer; wxBoxSizer* m_horizontal_sizer;
m_horizontal_sizer = new wxBoxSizer( wxHORIZONTAL ); m_horizontal_sizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbSizer1; wxStaticBoxSizer* m_grid_sizer;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Plugin Options:") ), wxVERTICAL ); m_grid_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Plugin Options:") ), wxVERTICAL );
m_grid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, 0 ); m_grid_sizer->SetMinSize( wxSize( -1,300 ) );
m_grid = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxVSCROLL );
// Grid // Grid
m_grid->CreateGrid( 5, 2 ); m_grid->CreateGrid( 1, 2 );
m_grid->EnableEditing( true ); m_grid->EnableEditing( true );
m_grid->EnableGridLines( true ); m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false ); m_grid->EnableDragGridSize( false );
...@@ -41,53 +42,91 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, ...@@ -41,53 +42,91 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
// Rows // Rows
m_grid->EnableDragRowSize( false ); m_grid->EnableDragRowSize( false );
m_grid->SetRowLabelSize( 80 ); m_grid->SetRowLabelSize( 40 );
m_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE ); m_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance // Label Appearance
// Cell Defaults // Cell Defaults
m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP ); m_grid->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
sbSizer1->Add( m_grid, 1, wxEXPAND, 5 ); m_grid_sizer->Add( m_grid, 1, wxEXPAND|wxTOP, 5 );
wxBoxSizer* bSizer6; wxBoxSizer* m_button_sizer;
bSizer6 = new wxBoxSizer( wxHORIZONTAL ); m_button_sizer = new wxBoxSizer( wxHORIZONTAL );
m_add_row = new wxButton( this, wxID_ANY, _("Add Row"), wxDefaultPosition, wxDefaultSize, 0 ); m_add_row = new wxButton( this, wxID_ANY, _("Append"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_add_row, 0, wxALL, 5 ); m_add_row->SetToolTip( _("Append a blank row") );
m_delete_row = new wxButton( this, wxID_ANY, _("Delete Row"), wxDefaultPosition, wxDefaultSize, 0 ); m_button_sizer->Add( m_add_row, 0, wxALL, 5 );
bSizer6->Add( m_delete_row, 0, wxALL, 5 );
m_delete_row = new wxButton( this, wxID_ANY, _("Delete"), wxDefaultPosition, wxDefaultSize, 0 );
m_delete_row->SetToolTip( _("Delete the selected row") );
m_button_sizer->Add( m_delete_row, 0, wxALL, 5 );
m_move_up = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 ); m_move_up = new wxButton( this, wxID_ANY, _("Move Up"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_move_up, 0, wxALL, 5 ); m_move_up->SetToolTip( _("Move the selected row up one position") );
m_button_sizer->Add( m_move_up, 0, wxALL, 5 );
m_move_down = new wxButton( this, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 ); m_move_down = new wxButton( this, wxID_ANY, _("Move Down"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_move_down, 0, wxALL, 5 ); m_move_down->SetToolTip( _("Move the selected row down one position") );
m_button_sizer->Add( m_move_down, 0, wxALL, 5 );
sbSizer1->Add( bSizer6, 0, wxALIGN_CENTER, 5 ); m_grid_sizer->Add( m_button_sizer, 0, wxALIGN_CENTER, 5 );
m_horizontal_sizer->Add( sbSizer1, 1, wxEXPAND, 5 ); m_horizontal_sizer->Add( m_grid_sizer, 3, wxEXPAND, 5 );
wxBoxSizer* bSizer3; wxGridSizer* m_choose_size;
bSizer3 = new wxBoxSizer( wxHORIZONTAL ); m_choose_size = new wxGridSizer( 1, 1, 0, 0 );
m_button1 = new wxButton( this, wxID_ANY, _("<<"), wxDefaultPosition, wxDefaultSize, 0 ); m_button1 = new wxButton( this, wxID_ANY, _("<<"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer3->Add( m_button1, 0, wxALIGN_CENTER|wxALL, 5 ); m_button1->SetMaxSize( wxSize( 50,-1 ) );
m_choose_size->Add( m_button1, 0, wxALIGN_CENTER|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT, 5 );
m_horizontal_sizer->Add( bSizer3, 0, wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL|wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer3; m_horizontal_sizer->Add( m_choose_size, 0, wxEXPAND, 5 );
sbSizer3 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Option Choices:") ), wxHORIZONTAL );
wxStaticBoxSizer* m_options_sizer;
m_options_sizer = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Option Choices:") ), wxHORIZONTAL );
m_options_sizer->SetMinSize( wxSize( 200,-1 ) );
m_option_choices = new wxGrid( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxHSCROLL|wxVSCROLL );
// Grid
m_option_choices->CreateGrid( 0, 2 );
m_option_choices->EnableEditing( false );
m_option_choices->EnableGridLines( true );
m_option_choices->EnableDragGridSize( false );
m_option_choices->SetMargins( 0, 0 );
m_listCtrl1 = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxVSCROLL ); // Columns
sbSizer3->Add( m_listCtrl1, 1, wxEXPAND, 5 ); m_option_choices->AutoSizeColumns();
m_option_choices->EnableDragColMove( false );
m_option_choices->EnableDragColSize( true );
m_option_choices->SetColLabelSize( 30 );
m_option_choices->SetColLabelValue( 0, _("Option") );
m_option_choices->SetColLabelValue( 1, _("Description") );
m_option_choices->SetColLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Rows
m_option_choices->AutoSizeRows();
m_option_choices->EnableDragRowSize( true );
m_option_choices->SetRowLabelSize( 0 );
m_option_choices->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
m_option_choices->SetDefaultCellAlignment( wxALIGN_LEFT, wxALIGN_TOP );
m_options_sizer->Add( m_option_choices, 1, wxEXPAND|wxTOP, 5 );
m_horizontal_sizer->Add( sbSizer3, 1, wxEXPAND, 5 ); m_horizontal_sizer->Add( m_options_sizer, 4, wxEXPAND, 5 );
bSizer4->Add( m_horizontal_sizer, 1, wxALL|wxEXPAND, 5 ); bSizer4->Add( m_horizontal_sizer, 1, wxALL|wxEXPAND, 5 );
...@@ -110,10 +149,11 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent, ...@@ -110,10 +149,11 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
// Connect Events // Connect Events
this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ) ); this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ) );
m_add_row->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAddRow ), NULL, this ); m_add_row->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendRow ), NULL, this );
m_delete_row->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this ); m_delete_row->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
m_move_up->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this ); m_move_up->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this );
m_move_down->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this ); m_move_down->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
m_button1->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendOption ), NULL, this );
m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this ); m_sdbSizer1Cancel->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this );
m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this ); m_sdbSizer1OK->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );
} }
...@@ -122,10 +162,11 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::~DIALOG_FP_PLUGIN_OPTIONS_BASE() ...@@ -122,10 +162,11 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::~DIALOG_FP_PLUGIN_OPTIONS_BASE()
{ {
// Disconnect Events // Disconnect Events
this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ) ); this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ) );
m_add_row->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAddRow ), NULL, this ); m_add_row->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendRow ), NULL, this );
m_delete_row->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this ); m_delete_row->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
m_move_up->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this ); m_move_up->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), NULL, this );
m_move_down->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this ); m_move_down->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
m_button1->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendOption ), NULL, this );
m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this ); m_sdbSizer1Cancel->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onCancelButtonClick ), NULL, this );
m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this ); m_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );
......
...@@ -23,7 +23,6 @@ class DIALOG_SHIM; ...@@ -23,7 +23,6 @@ class DIALOG_SHIM;
#include <wx/button.h> #include <wx/button.h>
#include <wx/sizer.h> #include <wx/sizer.h>
#include <wx/statbox.h> #include <wx/statbox.h>
#include <wx/listctrl.h>
#include <wx/dialog.h> #include <wx/dialog.h>
/////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////
...@@ -43,17 +42,18 @@ class DIALOG_FP_PLUGIN_OPTIONS_BASE : public DIALOG_SHIM ...@@ -43,17 +42,18 @@ class DIALOG_FP_PLUGIN_OPTIONS_BASE : public DIALOG_SHIM
wxButton* m_move_up; wxButton* m_move_up;
wxButton* m_move_down; wxButton* m_move_down;
wxButton* m_button1; wxButton* m_button1;
wxListCtrl* m_listCtrl1; wxGrid* m_option_choices;
wxStdDialogButtonSizer* m_sdbSizer1; wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK; wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel; wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class // Virtual event handlers, overide them in your derived class
virtual void onCancelButtonClick( wxCloseEvent& event ) = 0; virtual void onCancelButtonClick( wxCloseEvent& event ) = 0;
virtual void onAddRow( wxCommandEvent& event ) = 0; virtual void onAppendRow( wxMouseEvent& event ) = 0;
virtual void onDeleteRow( wxCommandEvent& event ) = 0; virtual void onDeleteRow( wxMouseEvent& event ) = 0;
virtual void onMoveUp( wxCommandEvent& event ) = 0; virtual void onMoveUp( wxMouseEvent& event ) = 0;
virtual void onMoveDown( wxCommandEvent& event ) = 0; virtual void onMoveDown( wxMouseEvent& event ) = 0;
virtual void onAppendOption( wxMouseEvent& event ) = 0;
virtual void onCancelButtonClick( wxCommandEvent& event ) = 0; virtual void onCancelButtonClick( wxCommandEvent& event ) = 0;
virtual void onOKButtonClick( wxCommandEvent& event ) = 0; virtual void onOKButtonClick( wxCommandEvent& event ) = 0;
......
...@@ -35,6 +35,9 @@ ...@@ -35,6 +35,9 @@
from RAM as needed. Therefore the PLUGIN is read only for accessing from RAM as needed. Therefore the PLUGIN is read only for accessing
remote pretty libraries. If you want to support writing to the repo, then you remote pretty libraries. If you want to support writing to the repo, then you
could use the above API. could use the above API.
@todo: Derive this PLUGIN from KICAD_PLUGIN so we can use its FootprintSave().
*/ */
#ifdef WIN32 #ifdef WIN32
...@@ -50,6 +53,7 @@ ...@@ -50,6 +53,7 @@
#include <wx/zipstrm.h> #include <wx/zipstrm.h>
#include <wx/mstream.h> #include <wx/mstream.h>
#include <wx/uri.h> #include <wx/uri.h>
//#include <wx/strconv.h>
#include <fctsys.h> #include <fctsys.h>
// Under Windows Mingw/msys, avhttp.hpp should be included after fctsys.h // Under Windows Mingw/msys, avhttp.hpp should be included after fctsys.h
...@@ -173,6 +177,23 @@ bool GITHUB_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath ) ...@@ -173,6 +177,23 @@ bool GITHUB_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
} }
void GITHUB_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
{
// inherit options supported by all PLUGINs.
PLUGIN::FootprintLibOptions( aListToAppendTo );
(*aListToAppendTo)["allow_pretty_writing_to_this_dir"] = wxString(
_( "Set this property to a directory where footprints are written to.\n"
"The directory should have a 'pretty' extension"
)).utf8_str();
(*aListToAppendTo)["cache_github_zip_in_this_dir"] = wxString(
_( "Set this property to a directory where the github *.zip file will be cached.\n"
"This should speed up subsequent visits to this library."
)).utf8_str();
}
void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR ) void GITHUB_PLUGIN::cacheLib( const wxString& aLibraryPath ) throw( IO_ERROR )
{ {
if( !m_cache || m_lib_path != aLibraryPath ) if( !m_cache || m_lib_path != aLibraryPath )
......
...@@ -54,6 +54,8 @@ public: ...@@ -54,6 +54,8 @@ public:
bool IsFootprintLibWritable( const wxString& aLibraryPath ); bool IsFootprintLibWritable( const wxString& aLibraryPath );
void FootprintLibOptions( PROPERTIES* aListToAppendTo ) const;
//-----</PLUGIN API>--------------------------------------------------------- //-----</PLUGIN API>---------------------------------------------------------
GITHUB_PLUGIN(); // constructor, if any, must be zero arg GITHUB_PLUGIN(); // constructor, if any, must be zero arg
......
...@@ -71,11 +71,12 @@ int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal, F ...@@ -71,11 +71,12 @@ int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal, F
* *
* @param aCaller is the wxTopLevelWindow which is invoking the dialog. * @param aCaller is the wxTopLevelWindow which is invoking the dialog.
* @param aNickname is the footprint library whose options are being edited. * @param aNickname is the footprint library whose options are being edited.
* @param aPluginType is something that will pass through IO_MGR::EnumFromStr().
* @param aOptionsIn is the options string on calling into this function. * @param aOptionsIn is the options string on calling into this function.
* @param aResult is where to put the result of the editing. * @param aResult is where to put the result of the editing.
*/ */
void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller, void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller, const wxString& aNickname,
const wxString& aNickname, const wxString& aOptions, wxString* aResult ); const wxString& aPluginType, const wxString& aOptions, wxString* aResult );
/** /**
* Function InvokePcbLibTableEditor * Function InvokePcbLibTableEditor
......
...@@ -418,6 +418,34 @@ public: ...@@ -418,6 +418,34 @@ public:
*/ */
virtual bool IsFootprintLibWritable( const wxString& aLibraryPath ); virtual bool IsFootprintLibWritable( const wxString& aLibraryPath );
/**
* Function FootprintLibOptions
* appends supported PLUGIN options to @a aListToAppenTo along with
* internationalized descriptions. Options are typically appended so
* that a derived PLUGIN can call its base class
* function by the same name first, thus inheriting options declared there.
* (Some base class options could pertain to all Footprint*() functions
* in all derived PLUGINs.) Note that since aListToAppendTo is a PROPERTIES
* object, all options will be unique and last guy wins.
*
* @param aListToAppendTo holds a tuple of
* <dl>
<dt>option</dt>
<dd>This eventually is what shows up into the fp-lib-table "options"
field, possibly combined with others.</dd>
<dt>internationalized description</dt>
<dd>The internationalized description is displayed in DIALOG_FP_PLUGIN_OPTIONS.
* It may be multi-line and be quite explanatory of the option.</dd>
</dl>
* <br>
* In the future perhaps @a aListToAppendTo evolves to something capable of also
* holding a wxValidator for the cells in said dialog:
* http://forums.wxwidgets.org/viewtopic.php?t=23277&p=104180.
This would require a 3 column list, and introducing wx GUI knowledge to
PLUGIN, which has been avoided to date.
*/
virtual void FootprintLibOptions( PROPERTIES* aListToAppendTo ) const;
//-----</PUBLIC PLUGIN API>------------------------------------------------ //-----</PUBLIC PLUGIN API>------------------------------------------------
......
...@@ -108,3 +108,14 @@ bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath ) ...@@ -108,3 +108,14 @@ bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
not_implemented( this, __FUNCTION__ ); not_implemented( this, __FUNCTION__ );
return false; return false;
} }
void PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const
{
// (*aListToAppendTo)["debug_level"] = TO_UTF8( _( "Enable debug logging for Footprint*() functions in this PLUGIN." ) );
// (*aListToAppendTo)["read_filter_regex"] = TO_UTF8( _("Regular expression footprint name filter") );
// (*aListToAppendTo)["enable transaction logging"] = ""; // mere presence enables, value is moot.
}
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