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.

71 lines
2.0 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2020 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 2 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_html_report_box.h"
  20. WX_HTML_REPORT_BOX::WX_HTML_REPORT_BOX( wxWindow* parent, wxWindowID id, const wxPoint& pos,
  21. const wxSize& size, long style ) :
  22. wxHtmlWindow( parent, id, pos, size, style )
  23. {
  24. }
  25. REPORTER& WX_HTML_REPORT_BOX::Report( const wxString& aText, SEVERITY aSeverity )
  26. {
  27. m_messages.push_back( aText );
  28. return *this;
  29. }
  30. void WX_HTML_REPORT_BOX::Flush()
  31. {
  32. wxString html;
  33. for( const wxString& line : m_messages )
  34. html += generateHtml( line );
  35. SetPage( addHeader( html ) );
  36. }
  37. wxString WX_HTML_REPORT_BOX::addHeader( const wxString& aBody )
  38. {
  39. wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
  40. wxColour fgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
  41. return wxString::Format( wxT( "<html><body bgcolor='%s' text='%s'>%s</body></html>" ),
  42. bgcolor.GetAsString( wxC2S_HTML_SYNTAX ),
  43. fgcolor.GetAsString( wxC2S_HTML_SYNTAX ),
  44. aBody );
  45. }
  46. wxString WX_HTML_REPORT_BOX::generateHtml( const wxString& aLine )
  47. {
  48. return "<font size=3>" + aLine + "</font><br>";
  49. }
  50. void WX_HTML_REPORT_BOX::Clear()
  51. {
  52. m_messages.clear();
  53. }