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.

119 lines
3.7 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 CERN
  5. * Copyright (C) 2015 KiCad Developers, see change_log.txt for contributors.
  6. * Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
  7. *
  8. * This program is free software: you can redistribute it and/or modify it
  9. * under the terms of the GNU General Public License as published by the
  10. * Free Software Foundation, either version 2 of the License, or (at your
  11. * option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful, but
  14. * WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  16. * General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License along
  19. * with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. #ifndef __WX_HTML_REPORT_PANEL_H__
  22. #define __WX_HTML_REPORT_PANEL_H__
  23. #include <wx/wx.h>
  24. #include <reporter.h>
  25. #include <vector>
  26. #include "wx_html_report_panel_base.h"
  27. /**
  28. * Class WX_HTML_REPORT_PANEL
  29. *
  30. * A widget for browsing a rich text error/status report. Used in numerous
  31. * dialogs in eeschema and pcbnew. Provides error filtering functionality
  32. * and saving report files.
  33. *
  34. * The messages are reported throuth a REPORTER object
  35. */
  36. class WX_HTML_REPORT_PANEL : public WX_HTML_REPORT_PANEL_BASE
  37. {
  38. public:
  39. WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY,
  40. const wxPoint& pos = wxDefaultPosition,
  41. const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL );
  42. ~WX_HTML_REPORT_PANEL();
  43. ///> returns the reporter object that reports to this panel
  44. REPORTER& Reporter();
  45. ///> reports a string directly.
  46. void Report( const wxString& aText, REPORTER::SEVERITY aSeverity );
  47. ///> clears the report panel
  48. void Clear();
  49. ///> sets the frame label
  50. void SetLabel( const wxString& aLabel );
  51. ///> Sets the lasy update. If this mode is on, messages are stored but the display
  52. ///> is not updated (Updating display can be very time consumming if there are many messages)
  53. ///> A call to Flush() will be needed after build the report
  54. void SetLazyUpdate( bool aLazyUpdate );
  55. ///> Forces updating the HTML page, after the report is built in lazy mode
  56. void Flush();
  57. ///> Set the visible severity filter.
  58. ///> if aSeverities < 0 the m_showAll option is set
  59. void SetVisibleSeverities( int aSeverities );
  60. ///> @return the visible severity filter.
  61. ///> If the m_showAll option is set, the mask is < 0
  62. int GetVisibleSeverities();
  63. private:
  64. struct REPORT_LINE
  65. {
  66. REPORTER::SEVERITY severity;
  67. wxString message;
  68. };
  69. typedef std::vector<REPORT_LINE> REPORT_LINES;
  70. wxString addHeader( const wxString& aBody );
  71. wxString generateHtml( const REPORT_LINE& aLine );
  72. wxString generatePlainText( const REPORT_LINE& aLine );
  73. void refreshView();
  74. void scrollToBottom();
  75. void syncCheckboxes();
  76. void onCheckBoxShowAll( wxCommandEvent& event );
  77. void onCheckBoxShowWarnings( wxCommandEvent& event );
  78. void onCheckBoxShowErrors( wxCommandEvent& event );
  79. void onCheckBoxShowInfos( wxCommandEvent& event );
  80. void onCheckBoxShowActions( wxCommandEvent& event );
  81. void onBtnSaveToFile( wxCommandEvent& event );
  82. ///> copy of the report, stored for filtering
  83. REPORT_LINES m_report;
  84. ///> the reporter
  85. WX_HTML_PANEL_REPORTER m_reporter;
  86. ///> message severities to display (mask)
  87. int m_severities;
  88. ///> show all messages flag (overrides m_severities)
  89. bool m_showAll;
  90. wxString m_html;
  91. bool m_lazyUpdate;
  92. };
  93. #endif //__WX_HTML_REPORT_PANEL_H__