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.

88 lines
3.0 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020-2021 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_constraints_reporter.h>
  24. #include <pcb_edit_frame.h>
  25. #include <tool/tool_manager.h>
  26. #include <wx_html_report_box.h>
  27. #include <tools/pcb_actions.h>
  28. #include <wx/wxhtml.h>
  29. DIALOG_CONSTRAINTS_REPORTER::DIALOG_CONSTRAINTS_REPORTER( PCB_EDIT_FRAME* aParent ) :
  30. DIALOG_CONSTRAINTS_REPORTER_BASE( aParent ),
  31. m_frame( aParent )
  32. {
  33. }
  34. void DIALOG_CONSTRAINTS_REPORTER::FinishInitialization()
  35. {
  36. m_sdbSizerOK->SetDefault();
  37. finishDialogSettings();
  38. }
  39. void DIALOG_CONSTRAINTS_REPORTER::DeleteAllPages()
  40. {
  41. m_notebook->DeleteAllPages();
  42. }
  43. void DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked( wxHtmlLinkEvent& event )
  44. {
  45. if( event.GetLinkInfo().GetHref() == "boardsetup" )
  46. m_frame->ShowBoardSetupDialog( _( "Custom Rules" ) );
  47. else if( event.GetLinkInfo().GetHref() == "drc" )
  48. m_frame->GetToolManager()->RunAction( PCB_ACTIONS::runDRC, true );
  49. }
  50. WX_HTML_REPORT_BOX* DIALOG_CONSTRAINTS_REPORTER::AddPage( const wxString& aTitle )
  51. {
  52. wxPanel* panel = new wxPanel( m_notebook, wxID_ANY, wxDefaultPosition, wxDefaultSize,
  53. wxTAB_TRAVERSAL );
  54. wxBoxSizer* sizer = new wxBoxSizer( wxVERTICAL );
  55. WX_HTML_REPORT_BOX* reporter = new WX_HTML_REPORT_BOX( panel, wxID_ANY, wxDefaultPosition,
  56. wxDefaultSize,
  57. wxHW_SCROLLBAR_AUTO | wxBORDER_SIMPLE );
  58. sizer->Add( reporter, 1, wxEXPAND | wxALL, 5 );
  59. panel->SetSizer( sizer );
  60. panel->Layout();
  61. m_notebook->AddPage( panel, aTitle );
  62. reporter->SetUnits( m_frame->GetUserUnits() );
  63. reporter->Connect( wxEVT_COMMAND_HTML_LINK_CLICKED,
  64. wxHtmlLinkEventHandler( DIALOG_CONSTRAINTS_REPORTER::OnErrorLinkClicked ),
  65. nullptr, this );
  66. return reporter;
  67. }
  68. int DIALOG_CONSTRAINTS_REPORTER::GetPageCount() const
  69. {
  70. return m_notebook->GetPageCount();
  71. }