2015-06-16 14:20:42 +02:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2015 CERN
|
2025-01-01 13:30:11 -08:00
|
|
|
* Copyright The KiCad Developers, see AUTHORS.txt for contributors.
|
2015-06-16 14:20:42 +02:00
|
|
|
* Author: Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by the
|
|
|
|
* Free Software Foundation, either version 2 of the License, or (at your
|
|
|
|
* option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2025-08-09 18:59:24 +01:00
|
|
|
#pragma once
|
2015-06-16 14:20:42 +02:00
|
|
|
|
|
|
|
#include <reporter.h>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "wx_html_report_panel_base.h"
|
|
|
|
|
2024-08-27 19:15:25 -04:00
|
|
|
class WX_HTML_REPORT_PANEL;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* A wrapper for reporting to a wx HTML window.
|
|
|
|
*/
|
|
|
|
class KICOMMON_API WX_HTML_PANEL_REPORTER : public REPORTER
|
|
|
|
{
|
|
|
|
public:
|
2025-04-01 12:11:47 +01:00
|
|
|
WX_HTML_PANEL_REPORTER( WX_HTML_REPORT_PANEL* aPanel ) :
|
|
|
|
REPORTER(),
|
|
|
|
m_panel( aPanel )
|
|
|
|
{}
|
2024-08-27 19:15:25 -04:00
|
|
|
|
|
|
|
virtual ~WX_HTML_PANEL_REPORTER() {}
|
|
|
|
|
|
|
|
REPORTER& Report( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
2025-08-09 18:59:24 +01:00
|
|
|
REPORTER& ReportTail( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
|
|
|
REPORTER& ReportHead( const wxString& aText, SEVERITY aSeverity = RPT_SEVERITY_UNDEFINED ) override;
|
2024-08-27 19:15:25 -04:00
|
|
|
|
|
|
|
bool HasMessage() const override;
|
2024-08-27 05:49:37 +03:00
|
|
|
bool HasMessageOfSeverity( int aSeverityMask ) const override;
|
2024-08-27 19:15:25 -04:00
|
|
|
|
|
|
|
private:
|
|
|
|
WX_HTML_REPORT_PANEL* m_panel;
|
|
|
|
};
|
|
|
|
|
2015-06-16 14:20:42 +02:00
|
|
|
/**
|
2025-01-16 07:37:05 -05:00
|
|
|
* A widget for browsing a rich text error/status report.
|
2015-06-16 14:20:42 +02:00
|
|
|
*
|
2025-01-16 07:37:05 -05:00
|
|
|
* Used in numerous dialogs in Eeschema and Pcbnew. Provides error filtering functionality
|
|
|
|
* and saving report files. The messages are reported through a #REPORTER object
|
2015-06-16 14:20:42 +02:00
|
|
|
*/
|
2024-08-27 19:15:25 -04:00
|
|
|
class KICOMMON_API WX_HTML_REPORT_PANEL : public WX_HTML_REPORT_PANEL_BASE
|
2015-06-16 14:20:42 +02:00
|
|
|
{
|
|
|
|
public:
|
2025-08-09 18:59:24 +01:00
|
|
|
WX_HTML_REPORT_PANEL( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
|
|
|
|
const wxSize& size = wxSize( 500, 300 ), long style = wxTAB_TRAVERSAL );
|
2025-04-01 12:11:47 +01:00
|
|
|
|
2015-06-16 14:20:42 +02:00
|
|
|
~WX_HTML_REPORT_PANEL();
|
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// Set the min size of the area which displays html messages.
|
2015-12-04 18:06:54 +01:00
|
|
|
void MsgPanelSetMinSize( const wxSize& aMinSize );
|
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// Return the reporter object that reports to this panel.
|
2015-06-16 14:20:42 +02:00
|
|
|
REPORTER& Reporter();
|
|
|
|
|
2018-05-21 15:28:26 -07:00
|
|
|
/**
|
2025-01-16 07:37:05 -05:00
|
|
|
* Report the string.
|
|
|
|
*
|
|
|
|
* @param aText string message to report.
|
|
|
|
* @param aSeverity string classification level bitfield.
|
|
|
|
* @param aLocation REPORTER::LOCATION enum for placement of message.
|
2018-05-21 15:28:26 -07:00
|
|
|
*/
|
2025-08-09 18:59:24 +01:00
|
|
|
void Report( const wxString& aText, SEVERITY aSeverity, REPORTER::LOCATION aLocation = REPORTER::LOC_BODY );
|
2015-06-16 14:20:42 +02:00
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// Clears the report panel.
|
2015-06-16 14:20:42 +02:00
|
|
|
void Clear();
|
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// Return the number of messages matching the given severity mask.
|
2018-02-17 11:43:56 +00:00
|
|
|
int Count( int severityMask );
|
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// Set the frame label.
|
2016-09-24 14:53:15 -04:00
|
|
|
void SetLabel( const wxString& aLabel ) override;
|
2015-07-24 17:47:48 +02:00
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// Set the lazy update. If this mode is on, messages are stored but the display
|
|
|
|
/// is not updated (Updating display can be very time consuming if there are many messages)
|
|
|
|
/// A call to Flush() will be needed after build the report
|
2025-08-09 18:59:24 +01:00
|
|
|
void SetLazyUpdate( bool aLazyUpdate ) { m_lazyUpdate = aLazyUpdate; }
|
2015-07-24 17:47:48 +02:00
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// Force updating the HTML page, after the report is built in lazy mode
|
|
|
|
/// If aSort = true, the body messages will be ordered by severity
|
2018-05-21 15:28:26 -07:00
|
|
|
void Flush( bool aSort = false );
|
2015-07-24 17:47:48 +02:00
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// @return the visible severity filter.
|
|
|
|
/// If the m_showAll option is set, the mask is < 0
|
2020-11-18 19:50:36 +00:00
|
|
|
int GetVisibleSeverities() const;
|
2015-07-24 17:47:48 +02:00
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// Set the report full file name to the string.
|
2025-08-09 18:59:24 +01:00
|
|
|
void SetFileName( const wxString& aReportFileName ) { m_reportFileName = aReportFileName; }
|
2020-04-20 21:44:17 -04:00
|
|
|
|
2025-01-16 07:37:05 -05:00
|
|
|
/// @return reference to the current report fill file name string.
|
2025-08-09 18:59:24 +01:00
|
|
|
wxString& GetFileName( void ) { return m_reportFileName; }
|
2020-04-20 21:44:17 -04:00
|
|
|
|
2015-06-16 14:20:42 +02:00
|
|
|
private:
|
|
|
|
struct REPORT_LINE
|
|
|
|
{
|
2020-02-28 00:05:40 +00:00
|
|
|
SEVERITY severity;
|
2015-06-16 14:20:42 +02:00
|
|
|
wxString message;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef std::vector<REPORT_LINE> REPORT_LINES;
|
|
|
|
|
|
|
|
wxString generateHtml( const REPORT_LINE& aLine );
|
|
|
|
wxString generatePlainText( const REPORT_LINE& aLine );
|
2018-02-20 01:40:14 +00:00
|
|
|
void updateBadges();
|
2015-06-16 14:20:42 +02:00
|
|
|
|
|
|
|
void scrollToBottom();
|
|
|
|
|
2018-03-19 17:03:36 +01:00
|
|
|
void onRightClick( wxMouseEvent& event ) override;
|
|
|
|
void onMenuEvent( wxMenuEvent& event );
|
2025-08-09 18:59:24 +01:00
|
|
|
void onCheckBox( wxCommandEvent& event ) override;
|
2015-06-16 14:20:42 +02:00
|
|
|
|
2016-09-24 14:53:15 -04:00
|
|
|
void onBtnSaveToFile( wxCommandEvent& event ) override;
|
2015-06-16 14:20:42 +02:00
|
|
|
|
2021-09-14 19:26:03 +01:00
|
|
|
void onThemeChanged( wxSysColourChangedEvent &aEvent );
|
|
|
|
|
2021-02-25 15:05:26 +00:00
|
|
|
private:
|
2015-06-16 14:20:42 +02:00
|
|
|
WX_HTML_PANEL_REPORTER m_reporter;
|
|
|
|
|
2021-02-25 15:05:26 +00:00
|
|
|
REPORT_LINES m_report; ///< copy of the report, stored for filtering
|
|
|
|
REPORT_LINES m_reportTail; ///< Lines to print at the end, regardless of sorting
|
|
|
|
REPORT_LINES m_reportHead; ///< ... and at the beginning, regardless of sorting
|
2020-04-20 21:44:17 -04:00
|
|
|
|
2021-02-25 15:05:26 +00:00
|
|
|
bool m_lazyUpdate;
|
2020-04-20 21:44:17 -04:00
|
|
|
|
2021-02-25 15:05:26 +00:00
|
|
|
wxString m_reportFileName; ///< defaults to the not very useful /bin/report.txt
|
2015-06-16 14:20:42 +02:00
|
|
|
};
|