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.

135 lines
4.5 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. ///> Set the min size of the area which displays html messages:
  44. void MsgPanelSetMinSize( const wxSize& aMinSize );
  45. ///> returns the reporter object that reports to this panel
  46. REPORTER& Reporter();
  47. /**
  48. * Reports the string
  49. * @param aText string message to report
  50. * @param aSeverity string classification level bitfield
  51. * @param aLocation REPORTER::LOCATION enum for placement of message
  52. */
  53. void Report( const wxString& aText, REPORTER::SEVERITY aSeverity,
  54. REPORTER::LOCATION aLocation = REPORTER::LOC_BODY );
  55. ///> clears the report panel
  56. void Clear();
  57. ///> return the number of messages matching the given severity mask.
  58. int Count( int severityMask );
  59. ///> sets the frame label
  60. void SetLabel( const wxString& aLabel ) override;
  61. ///> Sets the lasy update. If this mode is on, messages are stored but the display
  62. ///> is not updated (Updating display can be very time consumming if there are many messages)
  63. ///> A call to Flush() will be needed after build the report
  64. void SetLazyUpdate( bool aLazyUpdate );
  65. ///> Forces updating the HTML page, after the report is built in lazy mode
  66. ///> If aSort = true, the body messages will be ordered by severity
  67. void Flush( bool aSort = false );
  68. ///> Set the visible severity filter.
  69. ///> if aSeverities < 0 the m_showAll option is set
  70. void SetVisibleSeverities( int aSeverities );
  71. ///> @return the visible severity filter.
  72. ///> If the m_showAll option is set, the mask is < 0
  73. int GetVisibleSeverities();
  74. private:
  75. struct REPORT_LINE
  76. {
  77. REPORTER::SEVERITY severity;
  78. wxString message;
  79. };
  80. typedef std::vector<REPORT_LINE> REPORT_LINES;
  81. wxString addHeader( const wxString& aBody );
  82. wxString generateHtml( const REPORT_LINE& aLine );
  83. wxString generatePlainText( const REPORT_LINE& aLine );
  84. void updateBadges();
  85. void scrollToBottom();
  86. void syncCheckboxes();
  87. void onRightClick( wxMouseEvent& event ) override;
  88. void onMenuEvent( wxMenuEvent& event );
  89. void onCheckBoxShowAll( wxCommandEvent& event ) override;
  90. void onCheckBoxShowWarnings( wxCommandEvent& event ) override;
  91. void onCheckBoxShowErrors( wxCommandEvent& event ) override;
  92. void onCheckBoxShowInfos( wxCommandEvent& event ) override;
  93. void onCheckBoxShowActions( wxCommandEvent& event ) override;
  94. void onBtnSaveToFile( wxCommandEvent& event ) override;
  95. ///> copy of the report, stored for filtering
  96. REPORT_LINES m_report;
  97. ///> Lines to print at the very end of the report, regardless of sorting
  98. REPORT_LINES m_reportTail;
  99. ///> Lines to print at the very beginning of the report, regardless of sorting
  100. REPORT_LINES m_reportHead;
  101. ///> the reporter
  102. WX_HTML_PANEL_REPORTER m_reporter;
  103. ///> message severities to display (mask)
  104. int m_severities;
  105. bool m_lazyUpdate;
  106. };
  107. #endif //__WX_HTML_REPORT_PANEL_H__