KiCad PCB EDA Suite
panel_fp_lib_table.cpp
Go to the documentation of this file.
1/*
2 * This program source code file is part of KiCad, a free EDA CAD application.
3 *
4 * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <[email protected]>
5 * Copyright (C) 2013-2021 CERN
6 * Copyright (C) 2012-2022 KiCad Developers, see AUTHORS.txt for contributors.
7 *
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License
10 * as published by the Free Software Foundation; either version 2
11 * of the License, or (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, you may find one here:
20 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21 * or you may search the http://www.gnu.org website for the version 2 license,
22 * or you may write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24 */
25
26
27/* TODO:
28
29*) After any change to uri, reparse the environment variables.
30
31*/
32
33
34#include <set>
35#include <wx/dir.h>
36#include <wx/regex.h>
37#include <wx/grid.h>
38#include <wx/dirdlg.h>
39#include <wx/filedlg.h>
40
41#include <project.h>
42#include <3d_viewer/eda_3d_viewer_frame.h> // for KICAD7_3DMODEL_DIR
43#include <panel_fp_lib_table.h>
44#include <lib_id.h>
45#include <fp_lib_table.h>
46#include <lib_table_lexer.h>
47#include <invoke_pcb_dialog.h>
48#include <bitmaps.h>
50#include <widgets/wx_grid.h>
52#include <confirm.h>
53#include <lib_table_grid.h>
55#include <pgm_base.h>
56#include <pcb_edit_frame.h>
57#include <env_paths.h>
61#include <kiway.h>
62#include <kiway_express.h>
65#include <pcbnew_id.h> // For ID_PCBNEW_END_LIST
67#include <paths.h>
68#include <macros.h>
69// clang-format off
70
75{
76 wxString m_Description;
77 wxString m_FileFilter;
79 bool m_IsFile;
81};
82
86enum {
92};
93
99static const std::map<int, SUPPORTED_FILE_TYPE>& fileTypes()
100{
101 /*
102 * TODO(C++20): Clean this up
103 * This is wrapped inside a function to prevent a static initialization order fiasco
104 * with the file extension variables. Once C++20 is allowed in KiCad code, those file
105 * extensions can be made constexpr and this can be removed from a function call and
106 * placed in the file normally.
107 */
108 static const std::map<int, SUPPORTED_FILE_TYPE> fileTypes =
109 {
111 {
112 wxT( "KiCad (folder with .kicad_mod files)" ), wxT( "" ),
114 }
115 },
117 {
118 "Altium (*.PcbLib)", AltiumFootprintLibPathWildcard(), "", true, IO_MGR::ALTIUM_DESIGNER
119 }
120 },
122 {
123 wxT( "Eagle 6.x (*.lbr)" ), EagleFootprintLibPathWildcard(), wxT( "" ),
124 true, IO_MGR::EAGLE
125 }
126 },
128 {
129 wxT( "KiCad legacy (*.mod)" ), LegacyFootprintLibPathWildcard(), wxT( "" ),
130 true, IO_MGR::LEGACY
131 }
132 },
134 {
135 wxT( "Geda (folder with *.fp files)" ), wxT( "" ),
137 }
138 },
139 };
140
141 return fileTypes;
142}
143// clang-format on
144
145
150class LIBRARY_TRAVERSER : public wxDirTraverser
151{
152public:
153 LIBRARY_TRAVERSER( wxString aSearchExtension, wxString aInitialDir )
154 : m_searchExtension( aSearchExtension ),
155 m_currentDir( aInitialDir )
156 {
157 }
158
159 virtual wxDirTraverseResult OnFile( const wxString& aFileName ) override
160 {
161 wxFileName file( aFileName );
162
163 if( m_searchExtension.IsSameAs( file.GetExt(), false ) )
164 m_foundDirs.insert( { m_currentDir, 1 } );
165
166 return wxDIR_CONTINUE;
167 }
168
169 virtual wxDirTraverseResult OnOpenError( const wxString& aOpenErrorName ) override
170 {
171 m_failedDirs.insert( { aOpenErrorName, 1 } );
172 return wxDIR_IGNORE;
173 }
174
176 {
177 return m_failedDirs.size() > 0;
178 }
179
180 virtual wxDirTraverseResult OnDir( const wxString& aDirName ) override
181 {
182 m_currentDir = aDirName;
183 return wxDIR_CONTINUE;
184 }
185
186 void GetPaths( wxArrayString& aPathArray )
187 {
188 for( std::pair<const wxString, int>& foundDirsPair : m_foundDirs )
189 aPathArray.Add( foundDirsPair.first );
190 }
191
192 void GetFailedPaths( wxArrayString& aPathArray )
193 {
194 for( std::pair<const wxString, int>& failedDirsPair : m_failedDirs )
195 aPathArray.Add( failedDirsPair.first );
196 }
197
198private:
200 wxString m_currentDir;
201 std::unordered_map<wxString, int> m_foundDirs;
202 std::unordered_map<wxString, int> m_failedDirs;
203};
204
205
210{
211 friend class PANEL_FP_LIB_TABLE;
212 friend class FP_GRID_TRICKS;
213
214protected:
215 LIB_TABLE_ROW* at( size_t aIndex ) override { return &m_rows.at( aIndex ); }
216
217 size_t size() const override { return m_rows.size(); }
218
220 {
221 return dynamic_cast< LIB_TABLE_ROW* >( new FP_LIB_TABLE_ROW );
222 }
223
224 LIB_TABLE_ROWS_ITER begin() override { return m_rows.begin(); }
225
227 {
228 return m_rows.insert( aIterator, aRow );
229 }
230
231 void push_back( LIB_TABLE_ROW* aRow ) override { m_rows.push_back( aRow ); }
232
234 {
235 return m_rows.erase( aFirst, aLast );
236 }
237
238public:
239
240 FP_LIB_TABLE_GRID( const FP_LIB_TABLE& aTableToEdit )
241 {
242 m_rows = aTableToEdit.m_rows;
243 }
244};
245
246
247#define MYID_OPTIONS_EDITOR 15151
248
249
251{
252public:
254 LIB_TABLE_GRID_TRICKS( aGrid ), m_dialog( aParent )
255 { }
256
257protected:
259
260 void optionsEditor( int aRow )
261 {
262 FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
263
264 if( tbl->GetNumberRows() > aRow )
265 {
266 LIB_TABLE_ROW* row = tbl->at( (size_t) aRow );
267 const wxString& options = row->GetOptions();
268 wxString result = options;
269
270 InvokePluginOptionsEditor( m_dialog, row->GetNickName(), row->GetType(), options,
271 &result );
272
273 if( options != result )
274 {
275 row->SetOptions( result );
276 m_grid->Refresh();
277 }
278 }
279 }
280
281 bool handleDoubleClick( wxGridEvent& aEvent ) override
282 {
283 if( aEvent.GetCol() == COL_OPTIONS )
284 {
285 optionsEditor( aEvent.GetRow() );
286 return true;
287 }
288
289 return false;
290 }
291
292 void showPopupMenu( wxMenu& menu ) override
293 {
294 if( m_grid->GetGridCursorCol() == COL_OPTIONS )
295 {
296 menu.Append( MYID_OPTIONS_EDITOR, _( "Options Editor..." ), _( "Edit options" ) );
297 menu.AppendSeparator();
298 }
299
301 }
302
303 void doPopupSelection( wxCommandEvent& event ) override
304 {
305 if( event.GetId() == MYID_OPTIONS_EDITOR )
306 optionsEditor( m_grid->GetGridCursorRow() );
307 else
309 }
310
313 void paste_text( const wxString& cb_text ) override
314 {
315 FP_LIB_TABLE_GRID* tbl = (FP_LIB_TABLE_GRID*) m_grid->GetTable();
316 size_t ndx = cb_text.find( "(fp_lib_table" );
317
318 if( ndx != std::string::npos )
319 {
320 // paste the FP_LIB_TABLE_ROWs of s-expression (fp_lib_table), starting
321 // at column 0 regardless of current cursor column.
322
323 STRING_LINE_READER slr( TO_UTF8( cb_text ), wxT( "Clipboard" ) );
324 LIB_TABLE_LEXER lexer( &slr );
325 FP_LIB_TABLE tmp_tbl;
326 bool parsed = true;
327
328 try
329 {
330 tmp_tbl.Parse( &lexer );
331 }
332 catch( PARSE_ERROR& pe )
333 {
334 DisplayError( m_dialog, pe.What() );
335 parsed = false;
336 }
337
338 if( parsed )
339 {
340 // make sure the table is big enough...
341 if( tmp_tbl.GetCount() > (unsigned) tbl->GetNumberRows() )
342 tbl->AppendRows( tmp_tbl.GetCount() - tbl->GetNumberRows() );
343
344 for( unsigned i = 0; i < tmp_tbl.GetCount(); ++i )
345 tbl->m_rows.replace( i, tmp_tbl.At( i ).clone() );
346 }
347
348 m_grid->AutoSizeColumns( false );
349 }
350 else
351 {
352 // paste spreadsheet formatted text.
353 GRID_TRICKS::paste_text( cb_text );
354
355 m_grid->AutoSizeColumns( false );
356 }
357 }
358};
359
360
362 FP_LIB_TABLE* aGlobal, const wxString& aGlobalTblPath,
363 FP_LIB_TABLE* aProject, const wxString& aProjectTblPath,
364 const wxString& aProjectBasePath ) :
365 PANEL_FP_LIB_TABLE_BASE( aParent ),
366 m_global( aGlobal ),
367 m_project( aProject ),
368 m_projectBasePath( aProjectBasePath ),
369 m_parent( aParent )
370{
371 m_global_grid->SetTable( new FP_LIB_TABLE_GRID( *aGlobal ), true );
372
373 // add Cut, Copy, and Paste to wxGrids
374 m_path_subs_grid->PushEventHandler( new GRID_TRICKS( m_path_subs_grid ) );
375
376 wxArrayString choices;
377
378 choices.Add( IO_MGR::ShowType( IO_MGR::KICAD_SEXP ) );
379 choices.Add( IO_MGR::ShowType( IO_MGR::LEGACY ) );
381 choices.Add( IO_MGR::ShowType( IO_MGR::EAGLE ) );
382 choices.Add( IO_MGR::ShowType( IO_MGR::GEDA_PCB ) );
383
384 /* PCAD_PLUGIN does not support Footprint*() functions
385 choices.Add( IO_MGR::ShowType( IO_MGR::PCAD ) );
386 */
387 PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
388
389 if( cfg->m_lastFootprintLibDir.IsEmpty() )
391
393
394 auto autoSizeCol =
395 [&]( WX_GRID* aGrid, int aCol )
396 {
397 int prevWidth = aGrid->GetColSize( aCol );
398
399 aGrid->AutoSizeColumn( aCol, false );
400 aGrid->SetColSize( aCol, std::max( prevWidth, aGrid->GetColSize( aCol ) ) );
401 };
402
403 auto setupGrid =
404 [&]( WX_GRID* aGrid )
405 {
406 // Give a bit more room for wxChoice editors
407 aGrid->SetDefaultRowSize( aGrid->GetDefaultRowSize() + 4 );
408
409 // add Cut, Copy, and Paste to wxGrids
410 aGrid->PushEventHandler( new FP_GRID_TRICKS( m_parent, aGrid ) );
411
412 aGrid->SetSelectionMode( wxGrid::wxGridSelectRows );
413
414 wxGridCellAttr* attr;
415
416 attr = new wxGridCellAttr;
417 attr->SetEditor( new GRID_CELL_PATH_EDITOR( m_parent, aGrid,
419 wxEmptyString, true,
421 aGrid->SetColAttr( COL_URI, attr );
422
423 attr = new wxGridCellAttr;
424 attr->SetEditor( new wxGridCellChoiceEditor( choices ) );
425 aGrid->SetColAttr( COL_TYPE, attr );
426
427 attr = new wxGridCellAttr;
428 attr->SetRenderer( new wxGridCellBoolRenderer() );
429 attr->SetReadOnly(); // not really; we delegate interactivity to GRID_TRICKS
430 aGrid->SetColAttr( COL_ENABLED, attr );
431
432 // No visibility control for footprint libraries yet; this feature is primarily
433 // useful for database libraries and it's only implemented for schematic symbols
434 // at the moment.
435 aGrid->HideCol( COL_VISIBLE );
436
437 // all but COL_OPTIONS, which is edited with Option Editor anyways.
438 autoSizeCol( aGrid, COL_NICKNAME );
439 autoSizeCol( aGrid, COL_TYPE );
440 autoSizeCol( aGrid, COL_URI );
441 autoSizeCol( aGrid, COL_DESCR );
442
443 // Gives a selection to each grid, mainly for delete button. wxGrid's wake up with
444 // a currentCell which is sometimes not highlighted.
445 if( aGrid->GetNumberRows() > 0 )
446 aGrid->SelectRow( 0 );
447 };
448
449 setupGrid( m_global_grid );
450
452
453 if( aProject )
454 {
455 m_project_grid->SetTable( new FP_LIB_TABLE_GRID( *aProject ), true );
456 setupGrid( m_project_grid );
457 }
458 else
459 {
460 m_pageNdx = 0;
461 m_notebook->DeletePage( 1 );
462 m_project_grid = nullptr;
463 }
464
465 m_path_subs_grid->SetColLabelValue( 0, _( "Name" ) );
466 m_path_subs_grid->SetColLabelValue( 1, _( "Value" ) );
467
468 // select the last selected page
469 m_notebook->SetSelection( m_pageNdx );
471
472 // for ALT+A handling, we want the initial focus to be on the first selected grid.
474
475 // Configure button logos
481
482 // For aesthetic reasons, we must set the size of m_browseButton to match the other bitmaps
483 // manually (for instance m_append_button)
484 Layout(); // Needed at least on MSW to compute the actual buttons sizes, after initializing
485 // their bitmaps
486 wxSize buttonSize = m_append_button->GetSize();
487
489 m_browseButton->SetMinSize( buttonSize );
490
491 // Populate the browse library options
492 wxMenu* browseMenu = m_browseButton->GetSplitButtonMenu();
493
494 for( const std::pair<const int, SUPPORTED_FILE_TYPE>& fileType : fileTypes() )
495 {
496 browseMenu->Append( fileType.first, fileType.second.m_Description );
497
498 browseMenu->Bind( wxEVT_COMMAND_MENU_SELECTED, &PANEL_FP_LIB_TABLE::browseLibrariesHandler,
499 this, fileType.first );
500 }
501
502 Layout();
503
504 // This is the button only press for the browse button instead of the menu
506}
507
508
510{
511 // Delete the GRID_TRICKS.
512 // Any additional event handlers should be popped before the window is deleted.
513 m_global_grid->PopEventHandler( true );
514
515 if( m_project_grid )
516 m_project_grid->PopEventHandler( true );
517
518 m_path_subs_grid->PopEventHandler( true );
519}
520
521
523{
524 wxString msg;
525
526 for( FP_LIB_TABLE_GRID* model : { global_model(), project_model() } )
527 {
528 if( !model )
529 continue;
530
531 for( int r = 0; r < model->GetNumberRows(); )
532 {
533 wxString nick = model->GetValue( r, COL_NICKNAME ).Trim( false ).Trim();
534 wxString uri = model->GetValue( r, COL_URI ).Trim( false ).Trim();
535 unsigned illegalCh = 0;
536
537 if( !nick || !uri )
538 {
539 if( !nick && !uri )
540 msg = _( "A library table row nickname and path cells are empty." );
541 else if( !nick )
542 msg = _( "A library table row nickname cell is empty." );
543 else
544 msg = _( "A library table row path cell is empty." );
545
546 wxMessageDialog badCellDlg( this, msg, _( "Invalid Row Definition" ),
547 wxYES_NO | wxCENTER | wxICON_QUESTION | wxYES_DEFAULT );
548 badCellDlg.SetExtendedMessage( _( "Empty cells will result in all rows that are "
549 "invalid to be removed from the table." ) );
550 badCellDlg.SetYesNoLabels( wxMessageDialog::ButtonLabel( _( "Remove Invalid Cells" ) ),
551 wxMessageDialog::ButtonLabel( _( "Cancel Table Update" ) ) );
552
553 if( badCellDlg.ShowModal() == wxID_NO )
554 return false;
555
556 // Delete the "empty" row, where empty means missing nick or uri.
557 // This also updates the UI which could be slow, but there should only be a few
558 // rows to delete, unless the user fell asleep on the Add Row
559 // button.
560 model->DeleteRows( r, 1 );
561 }
562 else if( ( illegalCh = LIB_ID::FindIllegalLibraryNameChar( nick ) ) )
563 {
564 msg = wxString::Format( _( "Illegal character '%c' in nickname '%s'." ),
565 illegalCh,
566 nick );
567
568 // show the tabbed panel holding the grid we have flunked:
569 if( model != cur_model() )
570 m_notebook->SetSelection( model == global_model() ? 0 : 1 );
571
572 m_cur_grid->MakeCellVisible( r, 0 );
573 m_cur_grid->SetGridCursor( r, 1 );
574
575 wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
576 errdlg.ShowModal();
577 return false;
578 }
579 else
580 {
581 // set the trimmed values back into the table so they get saved to disk.
582 model->SetValue( r, COL_NICKNAME, nick );
583 model->SetValue( r, COL_URI, uri );
584
585 // Make sure to not save a hidden flag
586 model->SetValue( r, COL_VISIBLE, wxS( "1" ) );
587
588 ++r; // this row was OK.
589 }
590 }
591 }
592
593 // check for duplicate nickNames, separately in each table.
594 for( FP_LIB_TABLE_GRID* model : { global_model(), project_model() } )
595 {
596 if( !model )
597 continue;
598
599 for( int r1 = 0; r1 < model->GetNumberRows() - 1; ++r1 )
600 {
601 wxString nick1 = model->GetValue( r1, COL_NICKNAME );
602
603 for( int r2 = r1 + 1; r2 < model->GetNumberRows(); ++r2 )
604 {
605 wxString nick2 = model->GetValue( r2, COL_NICKNAME );
606
607 if( nick1 == nick2 )
608 {
609 msg = wxString::Format( _( "Multiple libraries cannot share the same "
610 "nickname ('%s')." ),
611 nick1 );
612
613 // show the tabbed panel holding the grid we have flunked:
614 if( model != cur_model() )
615 m_notebook->SetSelection( model == global_model() ? 0 : 1 );
616
617 // go to the lower of the two rows, it is technically the duplicate:
618 m_cur_grid->MakeCellVisible( r2, 0 );
619 m_cur_grid->SetGridCursor( r2, 1 );
620
621 wxMessageDialog errdlg( this, msg, _( "Library Nickname Error" ) );
622 errdlg.ShowModal();
623 return false;
624 }
625 }
626 }
627 }
628
629 return true;
630}
631
632
633void PANEL_FP_LIB_TABLE::OnUpdateUI( wxUpdateUIEvent& event )
634{
635 m_pageNdx = (unsigned) std::max( 0, m_notebook->GetSelection() );
637}
638
639
640void PANEL_FP_LIB_TABLE::appendRowHandler( wxCommandEvent& event )
641{
643 return;
644
645 if( m_cur_grid->AppendRows( 1 ) )
646 {
647 int last_row = m_cur_grid->GetNumberRows() - 1;
648
649 // wx documentation is wrong, SetGridCursor does not make visible.
650 m_cur_grid->MakeCellVisible( last_row, 0 );
651 m_cur_grid->SetGridCursor( last_row, 1 );
652 m_cur_grid->EnableCellEditControl( true );
653 m_cur_grid->ShowCellEditControl();
654 }
655}
656
657
658void PANEL_FP_LIB_TABLE::deleteRowHandler( wxCommandEvent& event )
659{
661 return;
662
663 int curRow = m_cur_grid->GetGridCursorRow();
664 int curCol = m_cur_grid->GetGridCursorCol();
665
666 // In a wxGrid, collect rows that have a selected cell, or are selected
667 // It is not so easy: it depends on the way the selection was made.
668 // Here, we collect rows selected by clicking on a row label, and rows that contain any
669 // previously-selected cells.
670 // If no candidate, just delete the row with the grid cursor.
671 wxArrayInt selectedRows = m_cur_grid->GetSelectedRows();
672 wxGridCellCoordsArray cells = m_cur_grid->GetSelectedCells();
673 wxGridCellCoordsArray blockTopLeft = m_cur_grid->GetSelectionBlockTopLeft();
674 wxGridCellCoordsArray blockBotRight = m_cur_grid->GetSelectionBlockBottomRight();
675
676 // Add all row having cell selected to list:
677 for( unsigned ii = 0; ii < cells.GetCount(); ii++ )
678 selectedRows.Add( cells[ii].GetRow() );
679
680 // Handle block selection
681 if( !blockTopLeft.IsEmpty() && !blockBotRight.IsEmpty() )
682 {
683 for( int i = blockTopLeft[0].GetRow(); i <= blockBotRight[0].GetRow(); ++i )
684 selectedRows.Add( i );
685 }
686
687 // Use the row having the grid cursor only if we have no candidate:
688 if( selectedRows.size() == 0 && m_cur_grid->GetGridCursorRow() >= 0 )
689 selectedRows.Add( m_cur_grid->GetGridCursorRow() );
690
691 if( selectedRows.size() == 0 )
692 {
693 wxBell();
694 return;
695 }
696
697 std::sort( selectedRows.begin(), selectedRows.end() );
698
699 // Remove selected rows (note: a row can be stored more than once in list)
700 int last_row = -1;
701
702 for( int ii = selectedRows.GetCount()-1; ii >= 0; ii-- )
703 {
704 int row = selectedRows[ii];
705
706 if( row != last_row )
707 {
708 last_row = row;
709 m_cur_grid->DeleteRows( row, 1 );
710 }
711 }
712
713 if( m_cur_grid->GetNumberRows() > 0 && curRow >= 0 )
714 m_cur_grid->SetGridCursor( std::min( curRow, m_cur_grid->GetNumberRows() - 1 ), curCol );
715}
716
717
718void PANEL_FP_LIB_TABLE::moveUpHandler( wxCommandEvent& event )
719{
721 return;
722
724 int curRow = m_cur_grid->GetGridCursorRow();
725
726 // @todo: add multiple selection moves.
727 if( curRow >= 1 )
728 {
729 boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
730 tbl->m_rows.release( tbl->m_rows.begin() + curRow );
731
732 --curRow;
733 tbl->m_rows.insert( tbl->m_rows.begin() + curRow, move_me.release() );
734
735 if( tbl->GetView() )
736 {
737 // Update the wxGrid
738 wxGridTableMessage msg( tbl, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, curRow, 0 );
739 tbl->GetView()->ProcessTableMessage( msg );
740 }
741
742 m_cur_grid->MakeCellVisible( curRow, m_cur_grid->GetGridCursorCol() );
743 m_cur_grid->SetGridCursor( curRow, m_cur_grid->GetGridCursorCol() );
744 }
745}
746
747
748void PANEL_FP_LIB_TABLE::moveDownHandler( wxCommandEvent& event )
749{
751 return;
752
754 int curRow = m_cur_grid->GetGridCursorRow();
755
756 // @todo: add multiple selection moves.
757 if( unsigned( curRow + 1 ) < tbl->m_rows.size() )
758 {
759 boost::ptr_vector< LIB_TABLE_ROW >::auto_type move_me =
760 tbl->m_rows.release( tbl->m_rows.begin() + curRow );
761
762 ++curRow;
763 tbl->m_rows.insert( tbl->m_rows.begin() + curRow, move_me.release() );
764
765 if( tbl->GetView() )
766 {
767 // Update the wxGrid
768 wxGridTableMessage msg( tbl, wxGRIDTABLE_NOTIFY_ROWS_INSERTED, curRow - 1, 0 );
769 tbl->GetView()->ProcessTableMessage( msg );
770 }
771
772 m_cur_grid->MakeCellVisible( curRow, m_cur_grid->GetGridCursorCol() );
773 m_cur_grid->SetGridCursor( curRow, m_cur_grid->GetGridCursorCol() );
774 }
775}
776
777
779{
781 return;
782
783 std::map<int, SUPPORTED_FILE_TYPE>::const_iterator fileTypeIt;
784
785 // We are bound both to the menu and button with this one handler
786 // So we must set the file type based on it
787 if( event.GetEventType() == wxEVT_BUTTON )
788 {
789 // Let's default to adding a kicad footprint file for just the footprint
790 fileTypeIt = fileTypes().find( ID_PANEL_FPLIB_ADD_KICADMOD );
791 }
792 else
793 {
794 fileTypeIt = fileTypes().find( event.GetId() );
795 }
796
797 if( fileTypeIt == fileTypes().end() )
798 {
799 wxLogWarning( wxT( "File type selection event received but could not find the file type "
800 "in the table" ) );
801 return;
802 }
803
804 SUPPORTED_FILE_TYPE fileType = fileTypeIt->second;
805
806 PCBNEW_SETTINGS* cfg = Pgm().GetSettingsManager().GetAppSettings<PCBNEW_SETTINGS>();
807
808 wxArrayString files;
809
810 wxString title;
811
812 title.Printf( _( "Select %s Library" ), fileType.m_Description );
813
814 wxString openDir = cfg->m_lastFootprintLibDir;
815
817 openDir = m_lastProjectLibDir;
818
819 if( fileType.m_IsFile )
820 {
821 wxFileDialog dlg( this, title, openDir, wxEmptyString, fileType.m_FileFilter,
822 wxFD_OPEN | wxFD_FILE_MUST_EXIST | wxFD_MULTIPLE );
823
824 int result = dlg.ShowModal();
825
826 if( result == wxID_CANCEL )
827 return;
828
829 dlg.GetPaths( files );
830
832 cfg->m_lastFootprintLibDir = dlg.GetDirectory();
833 else
834 m_lastProjectLibDir = dlg.GetDirectory();
835 }
836 else
837 {
838#if wxCHECK_VERSION( 3, 1, 4 ) // 3.1.4 required for wxDD_MULTIPLE
839 wxDirDialog dlg( nullptr, title, openDir,
840 wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST | wxDD_MULTIPLE );
841
842 int result = dlg.ShowModal();
843
844 if( result == wxID_CANCEL )
845 return;
846
847 dlg.GetPaths( files );
848#else
849 wxDirDialog dlg( nullptr, title, openDir, wxDD_DEFAULT_STYLE | wxDD_DIR_MUST_EXIST );
850
851 int result = dlg.ShowModal();
852
853 if( result == wxID_CANCEL )
854 return;
855
856 // is there a file extension configured to hunt out their containing folders?
857 if( fileType.m_FolderSearchExtension != "" )
858 {
859 wxDir rootDir( dlg.GetPath() );
860
861 LIBRARY_TRAVERSER traverser( fileType.m_FolderSearchExtension, rootDir.GetName() );
862 rootDir.Traverse( traverser );
863
864 traverser.GetPaths( files );
865
866 if( traverser.HasDirectoryOpenFailures() )
867 {
868 wxArrayString failedDirs;
869 traverser.GetPaths( failedDirs );
870 wxString detailedMsg = _( "The following directories could not be opened: \n" );
871
872 for( const wxString& path : failedDirs )
873 detailedMsg << path << wxT( "\n" );
874
875 DisplayErrorMessage( this, _( "Failed to open directories to look for libraries" ),
876 detailedMsg );
877 }
878 }
879 else
880 {
881 files.Add( dlg.GetPath() );
882 }
883#endif
884
885 if( !files.IsEmpty() )
886 {
887 wxFileName first( files.front() );
888
890 cfg->m_lastFootprintLibDir = first.GetPath();
891 else
892 m_lastProjectLibDir = first.GetPath();
893 }
894 }
895
896 // Drop the last directory if the path is a .pretty folder
898 cfg->m_lastFootprintLibDir = cfg->m_lastFootprintLibDir.BeforeLast( wxFileName::GetPathSeparator() );
899
900 const ENV_VAR_MAP& envVars = Pgm().GetLocalEnvVariables();
901 bool addDuplicates = false;
902 bool applyToAll = false;
903 wxString warning = _( "Warning: Duplicate Nicknames" );
904 wxString msg = _( "A library nicknamed '%s' already exists." );
905 wxString detailedMsg = _( "One of the nicknames will need to be changed after "
906 "adding this library." );
907
908 for( const wxString& filePath : files )
909 {
910 wxFileName fn( filePath );
911 wxString nickname = LIB_ID::FixIllegalChars( fn.GetName(), true );
912 bool doAdd = true;
913
914 if( fileType.m_Plugin == IO_MGR::KICAD_SEXP && fn.GetExt() != KiCadFootprintLibPathExtension )
915 nickname = LIB_ID::FixIllegalChars( fn.GetFullName(), true );
916
917 if( cur_model()->ContainsNickname( nickname ) )
918 {
919 if( !applyToAll )
920 {
921 // The cancel button adds the library to the table anyway
922 addDuplicates = OKOrCancelDialog( this, warning, wxString::Format( msg, nickname ),
923 detailedMsg, _( "Skip" ), _( "Add Anyway" ),
924 &applyToAll ) == wxID_CANCEL;
925 }
926
927 doAdd = addDuplicates;
928 }
929
930 if( doAdd && m_cur_grid->AppendRows( 1 ) )
931 {
932 int last_row = m_cur_grid->GetNumberRows() - 1;
933
934 m_cur_grid->SetCellValue( last_row, COL_NICKNAME, nickname );
935
936 m_cur_grid->SetCellValue( last_row, COL_TYPE, IO_MGR::ShowType( fileType.m_Plugin ) );
937
938 // try to use path normalized to an environmental variable or project path
939 wxString path = NormalizePath( filePath, &envVars, m_projectBasePath );
940
941 // Do not use the project path in the global library table. This will almost
942 // assuredly be wrong for a different project.
943 if( m_pageNdx == 0 && path.Contains( wxT( "${KIPRJMOD}" ) ) )
944 path = fn.GetFullPath();
945
946 m_cur_grid->SetCellValue( last_row, COL_URI, path );
947 }
948 }
949
950 if( !files.IsEmpty() )
951 {
952 int new_row = m_cur_grid->GetNumberRows() - 1;
953 m_cur_grid->MakeCellVisible( new_row, m_cur_grid->GetGridCursorCol() );
954 m_cur_grid->SetGridCursor( new_row, m_cur_grid->GetGridCursorCol() );
955 }
956}
957
958
960{
961 // Account for scroll bars
962 aWidth -= ( m_path_subs_grid->GetSize().x - m_path_subs_grid->GetClientSize().x );
963
964 m_path_subs_grid->AutoSizeColumn( 0 );
965 m_path_subs_grid->SetColSize( 0, std::max( 72, m_path_subs_grid->GetColSize( 0 ) ) );
966 m_path_subs_grid->SetColSize( 1, std::max( 120, aWidth - m_path_subs_grid->GetColSize( 0 ) ) );
967}
968
969
970void PANEL_FP_LIB_TABLE::onSizeGrid( wxSizeEvent& event )
971{
972 adjustPathSubsGridColumns( event.GetSize().GetX() );
973
974 event.Skip();
975}
976
977
979{
981 return false;
982
983 if( verifyTables() )
984 {
985 if( *global_model() != *m_global )
986 {
988
989 m_global->Clear();
990 m_global->m_rows.transfer( m_global->m_rows.end(), global_model()->m_rows.begin(),
991 global_model()->m_rows.end(), global_model()->m_rows );
992 m_global->reindex();
993 }
994
995 if( project_model() && *project_model() != *m_project )
996 {
998
999 m_project->Clear();
1000 m_project->m_rows.transfer( m_project->m_rows.end(), project_model()->m_rows.begin(),
1001 project_model()->m_rows.end(), project_model()->m_rows );
1002 m_project->reindex();
1003 }
1004
1005 return true;
1006 }
1007
1008 return false;
1009}
1010
1011
1015{
1016 wxRegEx re( ".*?(\\$\\{(.+?)\\})|(\\$\\((.+?)\\)).*?", wxRE_ADVANCED );
1017 wxASSERT( re.IsValid() ); // wxRE_ADVANCED is required.
1018
1019 std::set< wxString > unique;
1020
1021 // clear the table
1023
1024 for( FP_LIB_TABLE_GRID* tbl : { global_model(), project_model() } )
1025 {
1026 if( !tbl )
1027 continue;
1028
1029 for( int row = 0; row < tbl->GetNumberRows(); ++row )
1030 {
1031 wxString uri = tbl->GetValue( row, COL_URI );
1032
1033 while( re.Matches( uri ) )
1034 {
1035 wxString envvar = re.GetMatch( uri, 2 );
1036
1037 // if not ${...} form then must be $(...)
1038 if( envvar.IsEmpty() )
1039 envvar = re.GetMatch( uri, 4 );
1040
1041 // ignore duplicates
1042 unique.insert( envvar );
1043
1044 // delete the last match and search again
1045 uri.Replace( re.GetMatch( uri, 0 ), wxEmptyString );
1046 }
1047 }
1048 }
1049
1050 // Make sure this special environment variable shows up even if it was
1051 // not used yet. It is automatically set by KiCad to the directory holding
1052 // the current project.
1053 unique.insert( PROJECT_VAR_NAME );
1054 unique.insert( FP_LIB_TABLE::GlobalPathEnvVariableName() );
1055 // This special environment variable is used to locate 3d shapes
1056 unique.insert( KICAD7_3DMODEL_DIR );
1057
1058 for( const wxString& evName : unique )
1059 {
1060 int row = m_path_subs_grid->GetNumberRows();
1061 m_path_subs_grid->AppendRows( 1 );
1062
1063 m_path_subs_grid->SetCellValue( row, 0, wxT( "${" ) + evName + wxT( "}" ) );
1064 m_path_subs_grid->SetCellEditor( row, 0, new GRID_CELL_READONLY_TEXT_EDITOR() );
1065
1066 wxString evValue;
1067 wxGetEnv( evName, &evValue );
1068 m_path_subs_grid->SetCellValue( row, 1, evValue );
1069 m_path_subs_grid->SetCellEditor( row, 1, new GRID_CELL_READONLY_TEXT_EDITOR() );
1070 }
1071
1072 // No combobox editors here, but it looks better if its consistent with the other
1073 // grids in the dialog.
1074 m_path_subs_grid->SetDefaultRowSize( m_path_subs_grid->GetDefaultRowSize() + 2 );
1075
1076 adjustPathSubsGridColumns( m_path_subs_grid->GetRect().GetWidth() );
1077}
1078
1079//-----</event handlers>---------------------------------
1080
1081
1082
1084
1085
1086void InvokePcbLibTableEditor( KIWAY* aKiway, wxWindow* aCaller )
1087{
1088 FP_LIB_TABLE* globalTable = &GFootprintTable;
1089 wxString globalTablePath = FP_LIB_TABLE::GetGlobalTableFileName();
1090 FP_LIB_TABLE* projectTable = aKiway->Prj().PcbFootprintLibs();
1091 wxString projectTablePath = aKiway->Prj().FootprintLibTblName();
1092 wxString msg;
1093
1094 DIALOG_EDIT_LIBRARY_TABLES dlg( aCaller, _( "Footprint Libraries" ) );
1095 dlg.SetKiway( &dlg, aKiway );
1096
1097 if( aKiway->Prj().IsNullProject() )
1098 projectTable = nullptr;
1099
1100 dlg.InstallPanel( new PANEL_FP_LIB_TABLE( &dlg, globalTable, globalTablePath,
1101 projectTable, projectTablePath,
1102 aKiway->Prj().GetProjectPath() ) );
1103
1104 if( dlg.ShowModal() == wxID_CANCEL )
1105 return;
1106
1107 if( dlg.m_GlobalTableChanged )
1108 {
1109 try
1110 {
1111 globalTable->Save( globalTablePath );
1112 }
1113 catch( const IO_ERROR& ioe )
1114 {
1115 msg.Printf( _( "Error saving global library table:\n\n%s" ), ioe.What() );
1116 wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1117 }
1118 }
1119
1120 if( projectTable && dlg.m_ProjectTableChanged )
1121 {
1122 try
1123 {
1124 projectTable->Save( projectTablePath );
1125 }
1126 catch( const IO_ERROR& ioe )
1127 {
1128 msg.Printf( _( "Error saving project-specific library table:\n\n%s" ), ioe.What() );
1129 wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
1130 }
1131 }
1132
1133 auto editor = (FOOTPRINT_EDIT_FRAME*) aKiway->Player( FRAME_FOOTPRINT_EDITOR, false );
1134
1135 if( editor )
1136 {
1137 editor->SyncLibraryTree( true );
1138 editor->RefreshLibraryTree();
1139 }
1140
1141 auto viewer = (FOOTPRINT_VIEWER_FRAME*) aKiway->Player( FRAME_FOOTPRINT_VIEWER, false );
1142
1143 if( viewer )
1144 viewer->ReCreateLibraryList();
1145
1146 std::string payload = "";
1147 aKiway->ExpressMail( FRAME_CVPCB, MAIL_RELOAD_LIB, payload );
1148}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
@ small_folder
void SetInitialFocus(wxWindow *aWindow)
Sets the window (usually a wxTextCtrl) that should be focused when the dialog is shown.
Definition: dialog_shim.h:97
Component library viewer main window.
bool handleDoubleClick(wxGridEvent &aEvent) override
void doPopupSelection(wxCommandEvent &event) override
void paste_text(const wxString &cb_text) override
handle specialized clipboard text, with leading "(fp_lib_table", OR spreadsheet formatted text.
DIALOG_EDIT_LIBRARY_TABLES * m_dialog
FP_GRID_TRICKS(DIALOG_EDIT_LIBRARY_TABLES *aParent, WX_GRID *aGrid)
void showPopupMenu(wxMenu &menu) override
void optionsEditor(int aRow)
This class builds a wxGridTableBase by wrapping an FP_LIB_TABLE object.
size_t size() const override
FP_LIB_TABLE_GRID(const FP_LIB_TABLE &aTableToEdit)
LIB_TABLE_ROWS_ITER begin() override
LIB_TABLE_ROWS_ITER erase(LIB_TABLE_ROWS_ITER aFirst, LIB_TABLE_ROWS_ITER aLast) override
LIB_TABLE_ROW * makeNewRow() override
LIB_TABLE_ROW * at(size_t aIndex) override
void push_back(LIB_TABLE_ROW *aRow) override
LIB_TABLE_ROWS_ITER insert(LIB_TABLE_ROWS_ITER aIterator, LIB_TABLE_ROW *aRow) override
Hold a record identifying a library accessed by the appropriate footprint library PLUGIN object in th...
Definition: fp_lib_table.h:41
static const wxString GlobalPathEnvVariableName()
Return the name of the environment variable used to hold the directory of locally installed "KiCad sp...
virtual void Parse(LIB_TABLE_LEXER *aLexer) override
Parse the #LIB_TABLE_LEXER s-expression library table format into the appropriate LIB_TABLE_ROW objec...
static wxString GetGlobalTableFileName()
Editor for wxGrid cells that adds a file/folder browser to the grid input field.
Add mouse and command handling (such as cut, copy, and paste) to a WX_GRID instance.
Definition: grid_tricks.h:61
virtual void paste_text(const wxString &cb_text)
WX_GRID * m_grid
I don't own the grid, but he owns me.
Definition: grid_tricks.h:121
Hold an error message and may be used when throwing exceptions containing meaningful error messages.
Definition: ki_exception.h:76
virtual const wxString What() const
A composite of Problem() and Where()
Definition: exceptions.cpp:30
static const wxString ShowType(PCB_FILE_T aFileType)
Return a brief name for a plugin given aFileType enum.
Definition: io_mgr.cpp:77
PCB_FILE_T
The set of file types that the IO_MGR knows about, and for which there has been a plugin written.
Definition: io_mgr.h:54
@ LEGACY
Legacy Pcbnew file formats prior to s-expression.
Definition: io_mgr.h:55
@ ALTIUM_DESIGNER
Definition: io_mgr.h:60
@ KICAD_SEXP
S-expression Pcbnew file format.
Definition: io_mgr.h:56
@ EAGLE
Definition: io_mgr.h:57
@ GEDA_PCB
Geda PCB file formats.
Definition: io_mgr.h:64
void SetKiway(wxWindow *aDest, KIWAY *aKiway)
It is only used for debugging, since "this" is not a wxWindow*.
A minimalistic software bus for communications between various DLLs/DSOs (DSOs) within the same KiCad...
Definition: kiway.h:274
virtual KIWAY_PLAYER * Player(FRAME_T aFrameType, bool doCreate=true, wxTopLevelWindow *aParent=nullptr)
Return the KIWAY_PLAYER* given a FRAME_T.
Definition: kiway.cpp:394
virtual void ExpressMail(FRAME_T aDestination, MAIL_T aCommand, std::string &aPayload, wxWindow *aSource=nullptr)
Send aPayload to aDestination from aSource.
Definition: kiway.cpp:491
virtual PROJECT & Prj() const
Return the PROJECT associated with this KIWAY.
Definition: kiway.cpp:192
Traverser implementation that looks to find any and all "folder" libraries by looking for files with ...
void GetPaths(wxArrayString &aPathArray)
virtual wxDirTraverseResult OnOpenError(const wxString &aOpenErrorName) override
std::unordered_map< wxString, int > m_failedDirs
void GetFailedPaths(wxArrayString &aPathArray)
LIBRARY_TRAVERSER(wxString aSearchExtension, wxString aInitialDir)
std::unordered_map< wxString, int > m_foundDirs
virtual wxDirTraverseResult OnDir(const wxString &aDirName) override
virtual wxDirTraverseResult OnFile(const wxString &aFileName) override
static unsigned FindIllegalLibraryNameChar(const UTF8 &aLibraryName)
Looks for characters that are illegal in library nicknames.
Definition: lib_id.cpp:242
static UTF8 FixIllegalChars(const UTF8 &aLibItemName, bool aLib)
Replace illegal LIB_ID item name characters with underscores '_'.
Definition: lib_id.cpp:190
void showPopupMenu(wxMenu &menu) override
void doPopupSelection(wxCommandEvent &event) override
This abstract base class mixes any object derived from LIB_TABLE into wxGridTableBase so the result c...
bool AppendRows(size_t aNumRows=1) override
int GetNumberRows() override
Hold a record identifying a library accessed by the appropriate plug in object in the LIB_TABLE.
const wxString & GetOptions() const
Return the options string, which may hold a password or anything else needed to instantiate the under...
virtual const wxString GetType() const =0
Return the type of library represented by this row.
const wxString & GetNickName() const
LIB_TABLE_ROW * clone() const
void SetOptions(const wxString &aOptions)
Change the library options strings.
LIB_TABLE_ROW & At(unsigned aIndex)
Get the 'n'th LIB_TABLE_ROW object.
LIB_TABLE_ROWS m_rows
void Clear()
Delete all rows.
unsigned GetCount() const
Get the number of rows contained in the table.
void Save(const wxString &aFileName) const
Write this library table to aFileName in s-expression form.
void reindex()
Class PANEL_FP_LIB_TABLE_BASE.
STD_BITMAP_BUTTON * m_move_up_button
STD_BITMAP_BUTTON * m_append_button
STD_BITMAP_BUTTON * m_move_down_button
STD_BITMAP_BUTTON * m_delete_button
Dialog to show and edit symbol library tables.
bool verifyTables()
Trim important fields, removes blank row entries, and checks for duplicates.
void onSizeGrid(wxSizeEvent &event) override
void moveUpHandler(wxCommandEvent &event) override
void adjustPathSubsGridColumns(int aWidth)
FP_LIB_TABLE_GRID * cur_model() const
FP_LIB_TABLE_GRID * project_model() const
void moveDownHandler(wxCommandEvent &event) override
FP_LIB_TABLE_GRID * global_model() const
static size_t m_pageNdx
FP_LIB_TABLE * m_global
void populateEnvironReadOnlyTable()
Populate the readonly environment variable table with names and values by examining all the full_uri ...
void deleteRowHandler(wxCommandEvent &event) override
void browseLibrariesHandler(wxCommandEvent &event)
bool TransferDataFromWindow() override
FP_LIB_TABLE * m_project
DIALOG_EDIT_LIBRARY_TABLES * m_parent
void OnUpdateUI(wxUpdateUIEvent &event) override
void appendRowHandler(wxCommandEvent &event) override
PANEL_FP_LIB_TABLE(DIALOG_EDIT_LIBRARY_TABLES *aParent, FP_LIB_TABLE *aGlobal, const wxString &aGlobalTblPath, FP_LIB_TABLE *aProject, const wxString &aProjectTblPath, const wxString &aProjectBasePath)
static wxString GetDefaultUserFootprintsPath()
Gets the default path we point users to create projects.
Definition: paths.cpp:108
wxString m_lastFootprintLibDir
virtual const wxString GetProjectPath() const
Return the full path of the project.
Definition: project.cpp:126
virtual FP_LIB_TABLE * PcbFootprintLibs(KIWAY &aKiway)
Return the table of footprint libraries.
Definition: project.cpp:324
virtual const wxString FootprintLibTblName() const
Returns the path and filename of this project's footprint library table.
Definition: project.cpp:150
virtual bool IsNullProject() const
Check if this project is a null project (i.e.
Definition: project.cpp:138
void SetWidthPadding(int aPadding)
wxMenu * GetSplitButtonMenu()
void SetMinSize(const wxSize &aSize) override
void SetBitmap(const wxBitmap &aBmp)
void SetBitmap(const wxBitmap &aBmp)
Is a LINE_READER that reads from a multiline 8 bit wide std::string.
Definition: richio.h:241
void SetTable(wxGridTableBase *table, bool aTakeOwnership=false)
Hide wxGrid's SetTable() method with one which doesn't mess up the grid column widths when setting th...
Definition: wx_grid.cpp:164
void ClearRows()
wxWidgets recently added an ASSERT which fires if the position is greater than or equal to the number...
Definition: wx_grid.h:139
bool CommitPendingChanges(bool aQuietMode=false)
Close any open cell edit controls.
Definition: wx_grid.cpp:423
int OKOrCancelDialog(wxWindow *aParent, const wxString &aWarning, const wxString &aMessage, const wxString &aDetailedMessage, const wxString &aOKLabel, const wxString &aCancelLabel, bool *aApplyToAll)
Display a warning dialog with aMessage and returns the user response.
Definition: confirm.cpp:273
void DisplayError(wxWindow *aParent, const wxString &aText, int aDisplayTime)
Display an error or warning message box with aMessage.
Definition: confirm.cpp:300
void DisplayErrorMessage(wxWindow *aParent, const wxString &aText, const wxString &aExtraInfo)
Display an error message with aMessage.
Definition: confirm.cpp:325
This file is part of the common library.
FP_LIB_TABLE GFootprintTable
The global footprint library table.
Definition: cvpcb.cpp:134
void InvokePluginOptionsEditor(wxWindow *aCaller, const wxString &aNickname, const wxString &aPluginType, const wxString &aOptions, wxString *aResult)
Function InvokePluginOptionsEditor calls DIALOG_FP_PLUGIN_OPTIONS dialog so that plugin options set c...
#define _(s)
#define KICAD7_3DMODEL_DIR
A variable name whose value holds the path of 3D shape files.
wxString NormalizePath(const wxFileName &aFilePath, const ENV_VAR_MAP *aEnvVars, const wxString &aProjectPath)
Normalize a file path to an environmental variable, if possible.
Definition: env_paths.cpp:71
@ FRAME_FOOTPRINT_VIEWER
Definition: frame_type.h:42
@ FRAME_FOOTPRINT_EDITOR
Definition: frame_type.h:41
@ FRAME_CVPCB
Definition: frame_type.h:48
const std::string KiCadFootprintLibPathExtension
const std::string KiCadFootprintFileExtension
const std::string GedaPcbFootprintLibFileExtension
wxString EagleFootprintLibPathWildcard()
wxString AltiumFootprintLibPathWildcard()
wxString LegacyFootprintLibPathWildcard()
std::map< wxString, ENV_VAR_ITEM > ENV_VAR_MAP
LIB_TABLE_ROWS::iterator LIB_TABLE_ROWS_ITER
@ COL_DESCR
@ COL_NICKNAME
@ COL_OPTIONS
@ COL_ENABLED
@ COL_URI
This file contains miscellaneous commonly used macros and functions.
#define TO_UTF8(wxstring)
Convert a wxString to a UTF8 encoded C string for all wxWidgets build modes.
Definition: macros.h:96
@ MAIL_RELOAD_LIB
Definition: mail_type.h:55
static const std::map< int, SUPPORTED_FILE_TYPE > & fileTypes()
Map with event id as the key to supported file types that will be listed for the add a library option...
void InvokePcbLibTableEditor(KIWAY *aKiway, wxWindow *aCaller)
Function InvokePcbLibTableEditor shows the modal DIALOG_FP_LIB_TABLE for purposes of editing the glob...
#define MYID_OPTIONS_EDITOR
@ ID_PANEL_FPLIB_ADD_EAGLE6
@ ID_PANEL_FPLIB_ADD_KICADMOD
@ ID_PANEL_FPLIB_ADD_GEDA
@ ID_PANEL_FPLIB_ADD_ALTIUM
@ ID_PANEL_FPLIB_ADD_KICADLEGACY
@ ID_PCBNEW_END_LIST
Definition: pcbnew_id.h:123
see class PGM_BASE
#define PROJECT_VAR_NAME
A variable name whose value holds the current project directory.
Definition: project.h:39
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
KIWAY Kiway & Pgm(), KFCTL_STANDALONE
The global Program "get" accessor.
Definition: single_top.cpp:111
FormatType fileType(const char *aFileName)
A filename or source description, a problem input line, a line number, a byte offset,...
Definition: ki_exception.h:119
Container that describes file type info for the add a library options.
bool m_IsFile
Whether the library is a folder or a file.
wxString m_Description
Description shown in the file picker dialog.
wxString m_FileFilter
Filter used for file pickers if m_IsFile is true.
IO_MGR::PCB_FILE_T m_Plugin
wxString m_FolderSearchExtension
In case of folders it stands for extensions of files stored inside.
Definition of file extensions used in Kicad.