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.

65 lines
2.2 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 change_log.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. #ifndef WX_HTML_REPORT_BOX_H
  20. #define WX_HTML_REPORT_BOX_H
  21. #include <wx/wx.h>
  22. #include <reporter.h>
  23. #include <vector>
  24. #include <wx/html/htmlwin.h>
  25. #include <eda_units.h>
  26. /**
  27. * A slimmed down version of #WX_HTML_REPORT_PANEL
  28. */
  29. class WX_HTML_REPORT_BOX : public wxHtmlWindow, public REPORTER
  30. {
  31. public:
  32. WX_HTML_REPORT_BOX( wxWindow* parent, wxWindowID id = wxID_ANY,
  33. const wxPoint& pos = wxDefaultPosition,
  34. const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL );
  35. REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
  36. bool HasMessage() const override { return !m_messages.empty(); }
  37. void SetUnits( EDA_UNITS aUnits ) { m_units = aUnits; }
  38. EDA_UNITS GetUnits() const override { return m_units; }
  39. void SetImmediateMode() { m_immediateMode = true; }
  40. void Flush();
  41. void Clear();
  42. private:
  43. wxString addHeader( const wxString& aBody );
  44. wxString generateHtml( const wxString& aLine );
  45. EDA_UNITS m_units;
  46. // Indicates messages should be flushed as they are added. Required for progress-related
  47. // reports, but can be very slow for larger reports.
  48. bool m_immediateMode;
  49. ///< copy of the report, stored for filtering
  50. std::vector<wxString> m_messages;
  51. };
  52. #endif //WX_HTML_REPORT_BOX_H