You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

79 lines
2.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2023 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #include <dialog_footprint_chooser.h>
  24. #include <wx/sizer.h>
  25. #include <wx/button.h>
  26. #include <pcb_base_frame.h>
  27. #include <widgets/panel_footprint_chooser.h>
  28. DIALOG_FOOTPRINT_CHOOSER::DIALOG_FOOTPRINT_CHOOSER( PCB_BASE_FRAME* aParent,
  29. const LIB_ID& aPreselect,
  30. const wxArrayString& aFootprintHistoryList ) :
  31. DIALOG_SHIM( aParent, wxID_ANY, _( "Choose Footprint" ), wxDefaultPosition, wxDefaultSize,
  32. wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER )
  33. {
  34. wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
  35. m_chooserPanel = new PANEL_FOOTPRINT_CHOOSER( aParent, this, aFootprintHistoryList,
  36. // Filter
  37. []( LIB_TREE_NODE& aNode ) -> int
  38. {
  39. return 0;
  40. },
  41. // Close handler
  42. [this]()
  43. {
  44. EndModal( wxID_OK );
  45. } );
  46. sizer->Add( m_chooserPanel, 1, wxEXPAND, 5 );
  47. if( aPreselect.IsValid() )
  48. m_chooserPanel->SetPreselect( aPreselect );
  49. SetTitle( GetTitle() + wxString::Format( _( " (%d items loaded)" ),
  50. m_chooserPanel->GetItemCount() ) );
  51. wxStdDialogButtonSizer* sdbSizer = new wxStdDialogButtonSizer();
  52. wxButton* okButton = new wxButton( this, wxID_OK );
  53. wxButton* cancelButton = new wxButton( this, wxID_CANCEL );
  54. sdbSizer->AddButton( okButton );
  55. sdbSizer->AddButton( cancelButton );
  56. sdbSizer->Realize();
  57. sizer->Add( sdbSizer, 0, wxEXPAND | wxALL, 5 );
  58. SetSizer( sizer );
  59. SetInitialFocus( m_chooserPanel->GetFocusTarget() );
  60. SetupStandardButtons();
  61. m_chooserPanel->FinishSetup();
  62. Layout();
  63. }
  64. LIB_ID DIALOG_FOOTPRINT_CHOOSER::GetSelectedLibId() const
  65. {
  66. return m_chooserPanel->GetSelectedLibId();
  67. }