*) 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.
This commit is contained in:
Dick Hollenbeck 2013-11-11 18:17:27 -06:00
parent 1f1a88534e
commit 76fed4f995
12 changed files with 362 additions and 149 deletions

View File

@ -68,9 +68,6 @@ int DIALOG_DESIGN_RULES::s_LastTabSelection = -1;
// 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
{
if( column == 0 )
@ -87,14 +84,7 @@ wxString NETS_LIST_CTRL::OnGetItemText( long item, long column ) const
}
/**
* 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,
void NETS_LIST_CTRL::SetRowItems( unsigned aRow,
const wxString& aNetname,
const wxString& aNetclassName )
{
@ -422,7 +412,7 @@ void DIALOG_DESIGN_RULES::FillListBoxWithNetNames( NETS_LIST_CTRL* aListCtrl,
wxSize class_needed = sDC.GetTextExtent( (*i)->clazz );
net_colsize = std::max( net_colsize, net_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;;

View File

@ -7,39 +7,51 @@
#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.
* It s needed because the 2 wxListCtlr used to display lists of nets
* use the wxLC_VIRTUAL option.
* The virtual wxString OnGetItemText(long item, long column) const method
* must be overlaid.
* It's needed because the 2 "wxListCtl"s used to display lists of nets
* uses the wxLC_VIRTUAL option. The method:
*
* virtual wxString OnGetItemText( long item, long column ) const
*
* must be overloaded.
*/
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:
NETS_LIST_CTRL(wxWindow* parent, wxWindowID id,
const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize,
long style = wxLC_ICON):
NETS_LIST_CTRL( wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
const wxSize& size = wxDefaultSize, long style = wxLC_ICON ):
wxListCtrl( parent, id, pos, size, style )
{
};
NETS_LIST_CTRL()
{
};
void setRowItems(unsigned aRow, const wxString & aNetname, const wxString & aNetclassName );
void ClearList()
{
SetItemCount(0);
SetItemCount( 0 );
m_Netnames.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
};

View File

@ -198,7 +198,7 @@ public:
case COL_NICKNAME: return _( "Nickname" );
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_OPTIONS: return _( "Options" );
case COL_DESCR: return _( "Description" );
@ -583,12 +583,16 @@ private:
wxString result;
const wxString& options = row.GetOptions();
InvokePluginOptionsEditor( this, row.GetNickName(), options, &result );
InvokePluginOptionsEditor( this, row.GetNickName(), row.GetType(), options, &result );
if( options != 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 );
}
}

View File

@ -48,7 +48,8 @@ class DIALOG_FP_PLUGIN_OPTIONS : public DIALOG_FP_PLUGIN_OPTIONS_BASE
public:
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 ),
m_callers_options( aOptions ),
m_result( aResult )
@ -61,6 +62,7 @@ public:
// add Cut, Copy, and Paste to wxGrid
m_grid->PushEventHandler( new GRID_TRICKS( m_grid ) );
// Fill the grid with aOptions
string options = TO_UTF8( aOptions );
PROPERTIES* props = FP_LIB_TABLE::ParseOptions( options );
@ -80,6 +82,31 @@ public:
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 )
{
m_grid->AutoSizeColumns( false );
@ -176,10 +203,7 @@ private:
EndModal( 0 );
}
//-----<event handlers>------------------------------------------------------
void onAddRow( wxCommandEvent& event )
int appendRow()
{
if( m_grid->AppendRows( 1 ) )
{
@ -188,10 +212,47 @@ private:
// wx documentation is wrong, SetGridCursor does not make visible.
m_grid->MakeCellVisible( 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 onDeleteRow( wxCommandEvent& event )
void onAppendRow( wxMouseEvent& event )
{
appendRow();
}
void onDeleteRow( wxMouseEvent& event )
{
int rowCount = m_grid->GetNumberRows();
int curRow = getCursorRow();
@ -205,7 +266,7 @@ private:
}
}
void onMoveUp( wxCommandEvent& event )
void onMoveUp( wxMouseEvent& event )
{
int curRow = getCursorRow();
if( curRow >= 1 )
@ -238,7 +299,7 @@ private:
}
}
void onMoveDown( wxCommandEvent& event )
void onMoveDown( wxMouseEvent& event )
{
int curRow = getCursorRow();
if( curRow + 1 < m_grid->GetNumberRows() )
@ -292,9 +353,10 @@ private:
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();
}

View File

@ -19,13 +19,14 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
wxBoxSizer* m_horizontal_sizer;
m_horizontal_sizer = new wxBoxSizer( wxHORIZONTAL );
wxStaticBoxSizer* sbSizer1;
sbSizer1 = new wxStaticBoxSizer( new wxStaticBox( this, wxID_ANY, _("Plugin Options:") ), wxVERTICAL );
wxStaticBoxSizer* m_grid_sizer;
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
m_grid->CreateGrid( 5, 2 );
m_grid->CreateGrid( 1, 2 );
m_grid->EnableEditing( true );
m_grid->EnableGridLines( true );
m_grid->EnableDragGridSize( false );
@ -41,53 +42,91 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
// Rows
m_grid->EnableDragRowSize( false );
m_grid->SetRowLabelSize( 80 );
m_grid->SetRowLabelSize( 40 );
m_grid->SetRowLabelAlignment( wxALIGN_CENTRE, wxALIGN_CENTRE );
// Label Appearance
// Cell Defaults
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;
bSizer6 = new wxBoxSizer( wxHORIZONTAL );
wxBoxSizer* m_button_sizer;
m_button_sizer = new wxBoxSizer( wxHORIZONTAL );
m_add_row = new wxButton( this, wxID_ANY, _("Add Row"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_add_row, 0, wxALL, 5 );
m_add_row = new wxButton( this, wxID_ANY, _("Append"), wxDefaultPosition, wxDefaultSize, 0 );
m_add_row->SetToolTip( _("Append a blank row") );
m_delete_row = new wxButton( this, wxID_ANY, _("Delete Row"), wxDefaultPosition, wxDefaultSize, 0 );
bSizer6->Add( m_delete_row, 0, wxALL, 5 );
m_button_sizer->Add( m_add_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 );
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 );
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;
bSizer3 = new wxBoxSizer( wxHORIZONTAL );
wxGridSizer* m_choose_size;
m_choose_size = new wxGridSizer( 1, 1, 0, 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 );
m_horizontal_sizer->Add( m_choose_size, 0, wxEXPAND, 5 );
wxStaticBoxSizer* sbSizer3;
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_listCtrl1 = new wxListCtrl( this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxLC_REPORT|wxVSCROLL );
sbSizer3->Add( m_listCtrl1, 1, wxEXPAND, 5 );
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 );
// Columns
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 );
@ -110,10 +149,11 @@ DIALOG_FP_PLUGIN_OPTIONS_BASE::DIALOG_FP_PLUGIN_OPTIONS_BASE( wxWindow* parent,
// Connect Events
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_delete_row->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( 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_down->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
m_add_row->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendRow ), NULL, this );
m_delete_row->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
m_move_up->Connect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), 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_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()
{
// Disconnect Events
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_delete_row->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( 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_down->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveDown ), NULL, this );
m_add_row->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onAppendRow ), NULL, this );
m_delete_row->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onDeleteRow ), NULL, this );
m_move_up->Disconnect( wxEVT_LEFT_DOWN, wxMouseEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onMoveUp ), 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_sdbSizer1OK->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( DIALOG_FP_PLUGIN_OPTIONS_BASE::onOKButtonClick ), NULL, this );

View File

@ -103,18 +103,18 @@
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<property name="proportion">3</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Plugin Options:</property>
<property name="minimum_size"></property>
<property name="name">sbSizer1</property>
<property name="minimum_size">-1,300</property>
<property name="name">m_grid_sizer</property>
<property name="orient">wxVERTICAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<object class="wxGrid" expanded="1">
<property name="BottomDockable">1</property>
@ -185,11 +185,11 @@
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="row_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="row_label_size">80</property>
<property name="row_label_size">40</property>
<property name="row_label_values"></property>
<property name="row_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="row_sizes"></property>
<property name="rows">5</property>
<property name="rows">1</property>
<property name="show">1</property>
<property name="size"></property>
<property name="subclass"></property>
@ -197,7 +197,7 @@
<property name="tooltip"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<property name="window_style">wxVSCROLL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -261,7 +261,7 @@
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer6</property>
<property name="name">m_button_sizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<object class="sizeritem" expanded="1">
@ -297,7 +297,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Add Row</property>
<property name="label">Append</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -318,7 +318,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">Append a blank row</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
@ -326,7 +326,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onAddRow</event>
<event name="OnButtonClick"></event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -335,7 +335,7 @@
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftDown">onAppendRow</event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
@ -385,7 +385,7 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Delete Row</property>
<property name="label">Delete</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -406,7 +406,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">Delete the selected row</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
@ -414,7 +414,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onDeleteRow</event>
<event name="OnButtonClick"></event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -423,7 +423,7 @@
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftDown">onDeleteRow</event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
@ -494,7 +494,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">Move the selected row up one position</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
@ -502,7 +502,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onMoveUp</event>
<event name="OnButtonClick"></event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -511,7 +511,7 @@
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftDown">onMoveUp</event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
@ -582,7 +582,7 @@
<property name="style"></property>
<property name="subclass"></property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="tooltip">Move the selected row down one position</property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
@ -590,7 +590,7 @@
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnButtonClick">onMoveDown</event>
<event name="OnButtonClick"></event>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
@ -599,7 +599,7 @@
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftDown">onMoveDown</event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
@ -622,16 +622,19 @@
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL|wxEXPAND</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">0</property>
<object class="wxBoxSizer" expanded="1">
<property name="minimum_size"></property>
<property name="name">bSizer3</property>
<property name="orient">wxHORIZONTAL</property>
<object class="wxGridSizer" expanded="1">
<property name="cols">1</property>
<property name="hgap">0</property>
<property name="minimum_size">-1,-1</property>
<property name="name">m_choose_size</property>
<property name="permission">none</property>
<property name="rows">1</property>
<property name="vgap">0</property>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALIGN_CENTER|wxALL</property>
<property name="flag">wxALIGN_CENTER|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT</property>
<property name="proportion">0</property>
<object class="wxButton" expanded="1">
<property name="BottomDockable">1</property>
@ -665,7 +668,7 @@
<property name="label">&lt;&lt;</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="maximum_size">50,-1</property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
@ -700,7 +703,7 @@
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftDown">onAppendOption</event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
@ -722,20 +725,20 @@
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="proportion">1</property>
<property name="proportion">4</property>
<object class="wxStaticBoxSizer" expanded="1">
<property name="id">wxID_ANY</property>
<property name="label">Option Choices:</property>
<property name="minimum_size"></property>
<property name="name">sbSizer3</property>
<property name="minimum_size">200,-1</property>
<property name="name">m_options_sizer</property>
<property name="orient">wxHORIZONTAL</property>
<property name="permission">none</property>
<event name="OnUpdateUI"></event>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxEXPAND</property>
<property name="flag">wxEXPAND|wxTOP</property>
<property name="proportion">1</property>
<object class="wxListCtrl" expanded="1">
<object class="wxGrid" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
@ -744,25 +747,50 @@
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="autosize_cols">1</property>
<property name="autosize_rows">1</property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</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="center_pane">0</property>
<property name="close_button">1</property>
<property name="col_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="col_label_size">30</property>
<property name="col_label_values">&quot;Option&quot; &quot;Description&quot;</property>
<property name="col_label_vert_alignment">wxALIGN_CENTRE</property>
<property name="cols">2</property>
<property name="column_sizes"></property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</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="floatable">1</property>
<property name="font"></property>
<property name="grid_line_color"></property>
<property name="grid_lines">1</property>
<property name="gripper">0</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="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
@ -770,7 +798,7 @@
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">m_listCtrl1</property>
<property name="name">m_option_choices</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
@ -778,22 +806,55 @@
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="row_label_horiz_alignment">wxALIGN_CENTRE</property>
<property name="row_label_size">0</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="show">1</property>
<property name="size"></property>
<property name="style">wxLC_REPORT</property>
<property name="subclass"></property>
<property name="toolbar_pane">0</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">wxVSCROLL</property>
<property name="window_style">wxHSCROLL|wxVSCROLL</property>
<event name="OnChar"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnGridCellChange"></event>
<event name="OnGridCellLeftClick"></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>
@ -801,26 +862,6 @@
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnListBeginDrag"></event>
<event name="OnListBeginLabelEdit"></event>
<event name="OnListBeginRDrag"></event>
<event name="OnListCacheHint"></event>
<event name="OnListColBeginDrag"></event>
<event name="OnListColClick"></event>
<event name="OnListColDragging"></event>
<event name="OnListColEndDrag"></event>
<event name="OnListColRightClick"></event>
<event name="OnListDeleteAllItems"></event>
<event name="OnListDeleteItem"></event>
<event name="OnListEndLabelEdit"></event>
<event name="OnListInsertItem"></event>
<event name="OnListItemActivated"></event>
<event name="OnListItemDeselected"></event>
<event name="OnListItemFocused"></event>
<event name="OnListItemMiddleClick"></event>
<event name="OnListItemRightClick"></event>
<event name="OnListItemSelected"></event>
<event name="OnListKeyDown"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>

View File

@ -23,7 +23,6 @@ class DIALOG_SHIM;
#include <wx/button.h>
#include <wx/sizer.h>
#include <wx/statbox.h>
#include <wx/listctrl.h>
#include <wx/dialog.h>
///////////////////////////////////////////////////////////////////////////
@ -43,17 +42,18 @@ class DIALOG_FP_PLUGIN_OPTIONS_BASE : public DIALOG_SHIM
wxButton* m_move_up;
wxButton* m_move_down;
wxButton* m_button1;
wxListCtrl* m_listCtrl1;
wxGrid* m_option_choices;
wxStdDialogButtonSizer* m_sdbSizer1;
wxButton* m_sdbSizer1OK;
wxButton* m_sdbSizer1Cancel;
// Virtual event handlers, overide them in your derived class
virtual void onCancelButtonClick( wxCloseEvent& event ) = 0;
virtual void onAddRow( wxCommandEvent& event ) = 0;
virtual void onDeleteRow( wxCommandEvent& event ) = 0;
virtual void onMoveUp( wxCommandEvent& event ) = 0;
virtual void onMoveDown( wxCommandEvent& event ) = 0;
virtual void onAppendRow( wxMouseEvent& event ) = 0;
virtual void onDeleteRow( wxMouseEvent& event ) = 0;
virtual void onMoveUp( wxMouseEvent& event ) = 0;
virtual void onMoveDown( wxMouseEvent& event ) = 0;
virtual void onAppendOption( wxMouseEvent& event ) = 0;
virtual void onCancelButtonClick( wxCommandEvent& event ) = 0;
virtual void onOKButtonClick( wxCommandEvent& event ) = 0;

View File

@ -35,6 +35,9 @@
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
could use the above API.
@todo: Derive this PLUGIN from KICAD_PLUGIN so we can use its FootprintSave().
*/
#ifdef WIN32
@ -50,6 +53,7 @@
#include <wx/zipstrm.h>
#include <wx/mstream.h>
#include <wx/uri.h>
//#include <wx/strconv.h>
#include <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 )
}
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 )
{
if( !m_cache || m_lib_path != aLibraryPath )

View File

@ -54,6 +54,8 @@ public:
bool IsFootprintLibWritable( const wxString& aLibraryPath );
void FootprintLibOptions( PROPERTIES* aListToAppendTo ) const;
//-----</PLUGIN API>---------------------------------------------------------
GITHUB_PLUGIN(); // constructor, if any, must be zero arg

View File

@ -71,11 +71,12 @@ int InvokePcbLibTableEditor( wxTopLevelWindow* aCaller, FP_LIB_TABLE* aGlobal, F
*
* @param aCaller is the wxTopLevelWindow which is invoking the dialog.
* @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 aResult is where to put the result of the editing.
*/
void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller,
const wxString& aNickname, const wxString& aOptions, wxString* aResult );
void InvokePluginOptionsEditor( wxTopLevelWindow* aCaller, const wxString& aNickname,
const wxString& aPluginType, const wxString& aOptions, wxString* aResult );
/**
* Function InvokePcbLibTableEditor

View File

@ -418,6 +418,34 @@ public:
*/
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>------------------------------------------------

View File

@ -108,3 +108,14 @@ bool PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
not_implemented( this, __FUNCTION__ );
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.
}