28#include <wx/clipbrd.h>
32#include <wx/filedlg.h>
35#include <wx/textctrl.h>
72 GetSizer()->SetSizeHints(
this );
112 return a.severity < b.severity;
132 int x, y, xUnit, yUnit;
135 m_htmlView->GetScrollPixelsPerUnit( &xUnit, &yUnit );
158 for(
const REPORT_LINE& reportLine : reportLineArray )
160 if( severityMask & reportLine.severity )
181 retv = wxS(
"<font color=#F04040 size=3>" ) +
_(
"Error:" ) + wxS(
" </font>" )
182 + wxS(
"<font size=3>" ) + aLine.
message + wxS(
"</font><br>" );
185 retv = wxS(
"<font size=3>" ) +
_(
"Warning:" ) + wxS(
" " ) + aLine.
message + wxS(
"</font><br>" );
188 retv = wxS(
"<font color=#909090 size=3>" ) + aLine.
message + wxS(
"</font><br>" );
191 retv = wxS(
"<font color=#60D060 size=3>" ) + aLine.
message + wxS(
"</font><br>" );
194 retv = wxS(
"<font size=3>" ) + aLine.
message + wxS(
"</font><br>" );
202 retv = wxS(
"<font color=#D00000 size=3>" ) +
_(
"Error:" ) + wxS(
" </font>" )
203 + wxS(
"<font size=3>" ) + aLine.
message + wxS(
"</font><br>" );
206 retv = wxS(
"<font size=3>" ) +
_(
"Warning:" ) + wxS(
" " ) + aLine.
message + wxS(
"</font><br>" );
209 retv = wxS(
"<font color=#808080 size=3>" ) + aLine.
message + wxS(
"</font><br>" );
212 retv = wxS(
"<font color=#008000 size=3>" ) + aLine.
message + wxS(
"</font><br>" );
215 retv = wxS(
"<font size=3>" ) + aLine.
message + wxS(
"</font><br>" );
221 retv.Replace( wxS(
" " ), wxS(
" " ) );
234 default:
return aLine.
message + wxT(
"\n" );
242 popup.Append( wxID_COPY,
_(
"Copy" ) );
243 popup.Append( wxID_SELECTALL,
_(
"Select All" ) );
250 if( event.GetId() == wxID_COPY )
254 if( wxTheClipboard->Open() )
256 bool primarySelection = wxTheClipboard->IsUsingPrimarySelection();
257 wxTheClipboard->UsePrimarySelection(
false );
258 wxTheClipboard->SetData(
new wxTextDataObject(
m_htmlView->SelectionToText() ) );
259 wxTheClipboard->Flush();
260 wxTheClipboard->Close();
261 wxTheClipboard->UsePrimarySelection( primarySelection );
264 else if( event.GetId() == wxID_SELECTALL )
303 fn = wxT(
"report.txt" );
306 fn.SetPath( parent->Prj().GetProjectPath() );
313 wxWindow* topLevelParent = wxGetTopLevelParent(
this );
315 wxFileDialog dlg( topLevelParent,
_(
"Save Report File" ), fn.GetPath(), fn.GetFullName(),
318 if( dlg.ShowModal() != wxID_OK )
323 if( fn.GetExt().IsEmpty() )
326 wxFFile f( fn.GetFullPath(),
"wb" );
330 wxMessageBox( wxString::Format(
_(
"Cannot write report to file '%s'." ), fn.GetFullPath().GetData() ),
331 _(
"File save error" ), wxOK | wxICON_ERROR, wxGetTopLevelParent(
this ) );
361 m_box->GetStaticBox()->SetLabel( aLabel );
389 wxCHECK_MSG(
m_panel !=
nullptr, *
this,
390 wxT(
"No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
392 m_panel->Report( aText, aSeverity );
401 wxCHECK_MSG(
m_panel !=
nullptr, *
this,
402 wxT(
"No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
413 wxCHECK_MSG(
m_panel !=
nullptr, *
this,
414 wxT(
"No WX_HTML_REPORT_PANEL object defined in WX_HTML_PANEL_REPORTER." ) );
430 return m_panel->Count( aSeverityMask ) > 0;
A mix in class which holds the location of a wxWindow's KIWAY.
A pure virtual class used to derive REPORTER objects from.
LOCATION
Location where the message is to be reported.
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
Report a string with a given severity.
bool HasMessageOfSeverity(int aSeverityMask) const override
Returns true if the reporter has one or more messages matching the specified severity mask.
bool HasMessage() const override
Returns true if any messages were reported.
REPORTER & ReportTail(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Places the report at the end of the list, for objects that support report ordering.
REPORTER & ReportHead(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Places the report at the beginning of the list for objects that support ordering.
REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
Report a string with a given severity.
WX_HTML_REPORT_PANEL * m_panel
wxCheckBox * m_checkBoxShowAll
NUMBER_BADGE * m_warningsBadge
WX_HTML_REPORT_PANEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(-1,-1), long style=wxTAB_TRAVERSAL, const wxString &name=wxEmptyString)
NUMBER_BADGE * m_errorsBadge
wxFlexGridSizer * m_fgSizer
wxCheckBox * m_checkBoxShowActions
wxCheckBox * m_checkBoxShowWarnings
wxCheckBox * m_checkBoxShowErrors
wxCheckBox * m_checkBoxShowInfos
void Clear()
Clears the report panel.
wxString m_reportFileName
defaults to the not very useful /bin/report.txt
void onThemeChanged(wxSysColourChangedEvent &aEvent)
REPORT_LINES m_report
copy of the report, stored for filtering
void onRightClick(wxMouseEvent &event) override
int Count(int severityMask)
Return the number of messages matching the given severity mask.
WX_HTML_PANEL_REPORTER m_reporter
void SetLabel(const wxString &aLabel) override
Set the frame label.
std::vector< REPORT_LINE > REPORT_LINES
int GetVisibleSeverities() const
void MsgPanelSetMinSize(const wxSize &aMinSize)
Set the min size of the area which displays html messages.
wxString generateHtml(const REPORT_LINE &aLine)
void Report(const wxString &aText, SEVERITY aSeverity, REPORTER::LOCATION aLocation=REPORTER::LOC_BODY)
Report the string.
void Flush(bool aSort=false)
Force updating the HTML page, after the report is built in lazy mode If aSort = true,...
void onMenuEvent(wxMenuEvent &event)
wxString generatePlainText(const REPORT_LINE &aLine)
void onCheckBox(wxCommandEvent &event) override
void onBtnSaveToFile(wxCommandEvent &event) override
REPORT_LINES m_reportHead
... and at the beginning, regardless of sorting
REPORTER & Reporter()
Return the reporter object that reports to this panel.
REPORT_LINES m_reportTail
Lines to print at the end, regardless of sorting.
WX_HTML_REPORT_PANEL(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxTAB_TRAVERSAL)
static wxString TextFileWildcard()
KICOMMON_API wxFont GetInfoFont(wxWindow *aWindow)
bool ConvertSmartQuotesAndDashes(wxString *aString)
Convert curly quotes and em/en dashes to straight quotes and dashes.
Definition of file extensions used in Kicad.
static int RPT_SEVERITY_ALL