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.

78 lines
2.4 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2024 KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software: you can redistribute it and/or modify it
  7. * under the terms of the GNU General Public License as published by the
  8. * Free Software Foundation, either version 3 of the License, or (at your
  9. * option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful, but
  12. * WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License along
  17. * with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <wx/button.h>
  20. #include <wx/sizer.h>
  21. #include <dialogs/dialog_embed_files.h>
  22. DIALOG_EMBED_FILES::DIALOG_EMBED_FILES( wxWindow* aParent, const wxString& aTitle ) :
  23. DIALOG_SHIM( aParent, wxID_ANY, aTitle, wxDefaultPosition, wxDefaultSize,
  24. wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER ),
  25. m_contentPanel( nullptr )
  26. {
  27. // Construction delayed until after panel is installed
  28. }
  29. void DIALOG_EMBED_FILES::InstallPanel( wxPanel* aPanel )
  30. {
  31. m_contentPanel = aPanel;
  32. // Now perform the body of the constructor
  33. auto mainSizer = new wxBoxSizer( wxVERTICAL );
  34. SetSizer( mainSizer );
  35. mainSizer->Add( m_contentPanel, 1, wxEXPAND|wxLEFT|wxTOP|wxRIGHT, 5 );
  36. m_contentPanel->SetMinSize( FromDIP( wxSize( 1000, 600 ) ) );
  37. auto sdbSizer = new wxStdDialogButtonSizer();
  38. auto sdbSizerOK = new wxButton( this, wxID_OK );
  39. sdbSizer->AddButton( sdbSizerOK );
  40. auto sdbSizerCancel = new wxButton( this, wxID_CANCEL );
  41. sdbSizer->AddButton( sdbSizerCancel );
  42. sdbSizer->Realize();
  43. mainSizer->Add( sdbSizer, 0, wxALL|wxEXPAND, 5 );
  44. SetupStandardButtons();
  45. finishDialogSettings();
  46. // On some windows manager (Unity, XFCE), this dialog is not always raised, depending
  47. // on how the dialog is run.
  48. Raise();
  49. }
  50. bool DIALOG_EMBED_FILES::TransferDataToWindow()
  51. {
  52. return m_contentPanel->TransferDataToWindow();
  53. }
  54. bool DIALOG_EMBED_FILES::TransferDataFromWindow()
  55. {
  56. /**
  57. * N.B. *do not* call wxDialog::TransferDataFromWindow() in the dialog code.
  58. */
  59. return m_contentPanel->TransferDataFromWindow();
  60. }