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-2021 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 22 #ifndef __WX_HTML_REPORT_PANEL_H__ 23 #define __WX_HTML_REPORT_PANEL_H__ 24 25 #include <reporter.h> 26 #include <vector> 27 28 #include "wx_html_report_panel_base.h" 29 30 /** 31 * A widget for browsing a rich text error/status report. Used in numerous 32 * dialogs in eeschema and pcbnew. Provides error filtering functionality 33 * and saving report files. 34 * 35 * The messages are reported through a REPORTER object 36 */ 37 class WX_HTML_REPORT_PANEL : public WX_HTML_REPORT_PANEL_BASE 38 { 39 public: 40 WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, 41 const wxPoint& pos = wxDefaultPosition, 42 const wxSize& size = wxSize( 500,300 ), long style = wxTAB_TRAVERSAL ); 43 ~WX_HTML_REPORT_PANEL(); 44 45 ///< Set the min size of the area which displays html messages: 46 void MsgPanelSetMinSize( const wxSize& aMinSize ); 47 48 ///< returns the reporter object that reports to this panel 49 REPORTER& Reporter(); 50 51 /** 52 * Reports the string 53 * @param aText string message to report 54 * @param aSeverity string classification level bitfield 55 * @param aLocation REPORTER::LOCATION enum for placement of message 56 */ 57 void Report( const wxString& aText, SEVERITY aSeverity, 58 REPORTER::LOCATION aLocation = REPORTER::LOC_BODY ); 59 60 ///< clears the report panel 61 void Clear(); 62 63 ///< return the number of messages matching the given severity mask. 64 int Count( int severityMask ); 65 66 ///< sets the frame label 67 void SetLabel( const wxString& aLabel ) override; 68 69 ///< Sets the lazy update. If this mode is on, messages are stored but the display 70 ///< is not updated (Updating display can be very time consuming if there are many messages) 71 ///< A call to Flush() will be needed after build the report 72 void SetLazyUpdate( bool aLazyUpdate ); 73 74 ///< Forces updating the HTML page, after the report is built in lazy mode 75 ///< If aSort = true, the body messages will be ordered by severity 76 void Flush( bool aSort = false ); 77 78 ///< Set the visible severity filter. 79 ///< if aSeverities < 0 the m_showAll option is set 80 void SetVisibleSeverities( int aSeverities ); 81 82 ///< @return the visible severity filter. 83 ///< If the m_showAll option is set, the mask is < 0 84 int GetVisibleSeverities() const; 85 86 ///< @return the visible severity filter. 87 ///< If the m_showAll option is set, the mask is < 0 88 void SetShowSeverity( SEVERITY aSeverity, bool aValue ); 89 90 ///< Set the report full file name to the string 91 void SetFileName( const wxString& aReportFileName ); 92 93 ///< @return reference to the current report fill file name string. 94 wxString& GetFileName( void ); 95 96 97 private: 98 struct REPORT_LINE 99 { 100 SEVERITY severity; 101 wxString message; 102 }; 103 104 typedef std::vector<REPORT_LINE> REPORT_LINES; 105 106 wxString addHeader( const wxString& aBody ); 107 wxString generateHtml( const REPORT_LINE& aLine ); 108 wxString generatePlainText( const REPORT_LINE& aLine ); 109 void updateBadges(); 110 111 void scrollToBottom(); 112 void syncCheckboxes(); 113 114 void onRightClick( wxMouseEvent& event ) override; 115 void onMenuEvent( wxMenuEvent& event ); 116 void onCheckBoxShowAll( wxCommandEvent& event ) override; 117 void onCheckBoxShowWarnings( wxCommandEvent& event ) override; 118 void onCheckBoxShowErrors( wxCommandEvent& event ) override; 119 void onCheckBoxShowInfos( wxCommandEvent& event ) override; 120 void onCheckBoxShowActions( wxCommandEvent& event ) override; 121 122 void onBtnSaveToFile( wxCommandEvent& event ) override; 123 124 void onThemeChanged( wxSysColourChangedEvent &aEvent ); 125 126 private: 127 WX_HTML_PANEL_REPORTER m_reporter; 128 129 REPORT_LINES m_report; ///< copy of the report, stored for filtering 130 REPORT_LINES m_reportTail; ///< Lines to print at the end, regardless of sorting 131 REPORT_LINES m_reportHead; ///< ... and at the beginning, regardless of sorting 132 133 int m_severities; ///< message severities to display (mask) 134 bool m_lazyUpdate; 135 136 wxString m_reportFileName; ///< defaults to the not very useful /bin/report.txt 137 }; 138 139 #endif //__WX_HTML_REPORT_PANEL_H__ 140