From 76fed4f995a0bae05eb10f3bb4864a411595b895 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Mon, 11 Nov 2013 18:17:27 -0600 Subject: [PATCH] *) 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. --- pcbnew/dialogs/dialog_design_rules.cpp | 14 +- .../dialog_design_rules_aux_helper_class.h | 54 +++--- pcbnew/dialogs/dialog_fp_lib_table.cpp | 10 +- pcbnew/dialogs/dialog_fp_plugin_options.cpp | 82 +++++++-- .../dialogs/dialog_fp_plugin_options_base.cpp | 107 ++++++++---- .../dialogs/dialog_fp_plugin_options_base.fbp | 165 +++++++++++------- .../dialogs/dialog_fp_plugin_options_base.h | 12 +- pcbnew/github/github_plugin.cpp | 21 +++ pcbnew/github/github_plugin.h | 2 + pcbnew/invoke_pcb_dialog.h | 5 +- pcbnew/io_mgr.h | 28 +++ pcbnew/plugin.cpp | 11 ++ 12 files changed, 362 insertions(+), 149 deletions(-) diff --git a/pcbnew/dialogs/dialog_design_rules.cpp b/pcbnew/dialogs/dialog_design_rules.cpp index c2a278aecb..eecd0956b3 100644 --- a/pcbnew/dialogs/dialog_design_rules.cpp +++ b/pcbnew/dialogs/dialog_design_rules.cpp @@ -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;; diff --git a/pcbnew/dialogs/dialog_design_rules_aux_helper_class.h b/pcbnew/dialogs/dialog_design_rules_aux_helper_class.h index 8f214299b1..7b215fecfc 100644 --- a/pcbnew/dialogs/dialog_design_rules_aux_helper_class.h +++ b/pcbnew/dialogs/dialog_design_rules_aux_helper_class.h @@ -7,39 +7,51 @@ #include -/* 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): - wxListCtrl( parent, id, pos, size, style ) +public: + 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 }; diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index 34e95ec216..9c77364da6 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -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 ); } } diff --git a/pcbnew/dialogs/dialog_fp_plugin_options.cpp b/pcbnew/dialogs/dialog_fp_plugin_options.cpp index 5a5845c3d2..985b051727 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options.cpp +++ b/pcbnew/dialogs/dialog_fp_plugin_options.cpp @@ -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 ); } - - - //----------------------------------------------------------- - 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; + } + + //----------------------------------------------------------- + + 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; rowGetCellValue( 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(); } diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp b/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp index aeba36fc2d..dd7c99f693 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.cpp @@ -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 ); diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp b/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp index 8bd6b26e1a..4e5ca3d429 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.fbp @@ -103,18 +103,18 @@ 5 wxEXPAND - 1 + 3 wxID_ANY Plugin Options: - - sbSizer1 + -1,300 + m_grid_sizer wxVERTICAL none 5 - wxEXPAND + wxEXPAND|wxTOP 1 1 @@ -185,11 +185,11 @@ Resizable wxALIGN_CENTRE - 80 + 40 wxALIGN_CENTRE - 5 + 1 1 @@ -197,7 +197,7 @@ - + wxVSCROLL @@ -261,7 +261,7 @@ 0 - bSizer6 + m_button_sizer wxHORIZONTAL none @@ -297,7 +297,7 @@ 0 0 wxID_ANY - Add Row + Append 0 @@ -318,7 +318,7 @@ 0 - + Append a blank row wxFILTER_NONE wxDefaultValidator @@ -326,7 +326,7 @@ - onAddRow + @@ -335,7 +335,7 @@ - + onAppendRow @@ -385,7 +385,7 @@ 0 0 wxID_ANY - Delete Row + Delete 0 @@ -406,7 +406,7 @@ 0 - + Delete the selected row wxFILTER_NONE wxDefaultValidator @@ -414,7 +414,7 @@ - onDeleteRow + @@ -423,7 +423,7 @@ - + onDeleteRow @@ -494,7 +494,7 @@ 0 - + Move the selected row up one position wxFILTER_NONE wxDefaultValidator @@ -502,7 +502,7 @@ - onMoveUp + @@ -511,7 +511,7 @@ - + onMoveUp @@ -582,7 +582,7 @@ 0 - + Move the selected row down one position wxFILTER_NONE wxDefaultValidator @@ -590,7 +590,7 @@ - onMoveDown + @@ -599,7 +599,7 @@ - + onMoveDown @@ -622,16 +622,19 @@ 5 - wxALIGN_CENTER|wxALIGN_CENTER_VERTICAL|wxEXPAND + wxEXPAND 0 - - - bSizer3 - wxHORIZONTAL + + 1 + 0 + -1,-1 + m_choose_size none + 1 + 0 5 - wxALIGN_CENTER|wxALL + wxALIGN_CENTER|wxALIGN_CENTER_HORIZONTAL|wxALIGN_CENTER_VERTICAL|wxLEFT|wxRIGHT 0 1 @@ -665,7 +668,7 @@ << 0 - + 50,-1 0 @@ -700,7 +703,7 @@ - + onAppendOption @@ -722,20 +725,20 @@ 5 wxEXPAND - 1 + 4 wxID_ANY Option Choices: - - sbSizer3 + 200,-1 + m_options_sizer wxHORIZONTAL none 5 - wxEXPAND + wxEXPAND|wxTOP 1 - + 1 1 1 @@ -744,25 +747,50 @@ + 1 + 1 1 + + + wxALIGN_LEFT + + wxALIGN_TOP 0 1 + wxALIGN_CENTRE + 30 + "Option" "Description" + wxALIGN_CENTRE + 2 + 1 0 Dock 0 Left + 0 + 1 + 0 + 1 + 0 1 1 + + 1 0 0 wxID_ANY + + + + 0 + 0 0 @@ -770,7 +798,7 @@ 0 1 - m_listCtrl1 + m_option_choices 1 @@ -778,22 +806,55 @@ 1 Resizable + wxALIGN_CENTRE + 0 + + wxALIGN_CENTRE + + 0 1 - wxLC_REPORT 0 - - wxFILTER_NONE - wxDefaultValidator - - wxVSCROLL + wxHSCROLL|wxVSCROLL + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + @@ -801,26 +862,6 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/pcbnew/dialogs/dialog_fp_plugin_options_base.h b/pcbnew/dialogs/dialog_fp_plugin_options_base.h index 97b724d4d5..1af76d0b26 100644 --- a/pcbnew/dialogs/dialog_fp_plugin_options_base.h +++ b/pcbnew/dialogs/dialog_fp_plugin_options_base.h @@ -23,7 +23,6 @@ class DIALOG_SHIM; #include #include #include -#include #include /////////////////////////////////////////////////////////////////////////// @@ -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; diff --git a/pcbnew/github/github_plugin.cpp b/pcbnew/github/github_plugin.cpp index 9f77b103b5..0eb0f62c29 100644 --- a/pcbnew/github/github_plugin.cpp +++ b/pcbnew/github/github_plugin.cpp @@ -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 #include #include +//#include #include // 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 ) diff --git a/pcbnew/github/github_plugin.h b/pcbnew/github/github_plugin.h index 8e0a01e122..12d4629ecd 100644 --- a/pcbnew/github/github_plugin.h +++ b/pcbnew/github/github_plugin.h @@ -54,6 +54,8 @@ public: bool IsFootprintLibWritable( const wxString& aLibraryPath ); + void FootprintLibOptions( PROPERTIES* aListToAppendTo ) const; + //-------------------------------------------------------------- GITHUB_PLUGIN(); // constructor, if any, must be zero arg diff --git a/pcbnew/invoke_pcb_dialog.h b/pcbnew/invoke_pcb_dialog.h index b4a7bb55a1..e45724a380 100644 --- a/pcbnew/invoke_pcb_dialog.h +++ b/pcbnew/invoke_pcb_dialog.h @@ -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 diff --git a/pcbnew/io_mgr.h b/pcbnew/io_mgr.h index 33a0101647..bd5b92a61d 100644 --- a/pcbnew/io_mgr.h +++ b/pcbnew/io_mgr.h @@ -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 + *
+
option
+
This eventually is what shows up into the fp-lib-table "options" + field, possibly combined with others.
+
internationalized description
+
The internationalized description is displayed in DIALOG_FP_PLUGIN_OPTIONS. + * It may be multi-line and be quite explanatory of the option.
+
+ *
+ * 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; + //----------------------------------------------------- diff --git a/pcbnew/plugin.cpp b/pcbnew/plugin.cpp index 9fbce0e98b..5b4586afcc 100644 --- a/pcbnew/plugin.cpp +++ b/pcbnew/plugin.cpp @@ -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. +} +