KiCad PCB EDA Suite
WX_HTML_REPORT_PANEL Class Reference

Class WX_HTML_REPORT_PANEL. More...

#include <wx_html_report_panel.h>

Inheritance diagram for WX_HTML_REPORT_PANEL:
WX_HTML_REPORT_PANEL_BASE

Classes

struct  REPORT_LINE
 

Public Member Functions

 WX_HTML_REPORT_PANEL (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxTAB_TRAVERSAL)
 
 ~WX_HTML_REPORT_PANEL ()
 
void MsgPanelSetMinSize (const wxSize &aMinSize)
 

Set the min size of the area which displays html messages:

More...
 
REPORTERReporter ()
 

returns the reporter object that reports to this panel

More...
 
void Report (const wxString &aText, REPORTER::SEVERITY aSeverity)
 

reports a string directly.

More...
 
void Clear ()
 

clears the report panel

More...
 
void SetLabel (const wxString &aLabel) override
 

sets the frame label

More...
 
void SetLazyUpdate (bool aLazyUpdate)
 

Sets the lasy update.

More...
 
void Flush ()
 

Forces updating the HTML page, after the report is built in lazy mode

More...
 
void SetVisibleSeverities (int aSeverities)
 

Set the visible severity filter.

More...
 
int GetVisibleSeverities ()
 > More...
 

Protected Attributes

wxStaticBoxSizer * m_box
 
wxHtmlWindow * m_htmlView
 
wxStaticText * m_staticText3
 
wxCheckBox * m_checkBoxShowAll
 
wxCheckBox * m_checkBoxShowWarnings
 
wxCheckBox * m_checkBoxShowErrors
 
wxCheckBox * m_checkBoxShowInfos
 
wxCheckBox * m_checkBoxShowActions
 
wxButton * m_btnSaveReportToFile
 

Private Types

typedef std::vector< REPORT_LINEREPORT_LINES
 

Private Member Functions

wxString addHeader (const wxString &aBody)
 
wxString generateHtml (const REPORT_LINE &aLine)
 
wxString generatePlainText (const REPORT_LINE &aLine)
 
void refreshView ()
 
void scrollToBottom ()
 
void syncCheckboxes ()
 
void onCheckBoxShowAll (wxCommandEvent &event) override
 
void onCheckBoxShowWarnings (wxCommandEvent &event) override
 
void onCheckBoxShowErrors (wxCommandEvent &event) override
 
void onCheckBoxShowInfos (wxCommandEvent &event) override
 
void onCheckBoxShowActions (wxCommandEvent &event) override
 
void onBtnSaveToFile (wxCommandEvent &event) override
 

Private Attributes

REPORT_LINES m_report
 

copy of the report, stored for filtering

More...
 
WX_HTML_PANEL_REPORTER m_reporter
 

the reporter

More...
 
int m_severities
 

message severities to display (mask)

More...
 
bool m_showAll
 

show all messages flag (overrides m_severities)

More...
 
wxString m_html
 
bool m_lazyUpdate
 

Detailed Description

Class WX_HTML_REPORT_PANEL.

A widget for browsing a rich text error/status report. Used in numerous dialogs in eeschema and pcbnew. Provides error filtering functionality and saving report files.

The messages are reported throuth a REPORTER object

Definition at line 41 of file wx_html_report_panel.h.

Member Typedef Documentation

typedef std::vector<REPORT_LINE> WX_HTML_REPORT_PANEL::REPORT_LINES
private

Definition at line 87 of file wx_html_report_panel.h.

Constructor & Destructor Documentation

WX_HTML_REPORT_PANEL::WX_HTML_REPORT_PANEL ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const wxPoint pos = wxDefaultPosition,
const wxSize &  size = wxSize( 500,300 ),
long  style = wxTAB_TRAVERSAL 
)

Definition at line 27 of file wx_html_report_panel.cpp.

References addHeader(), WX_HTML_REPORT_PANEL_BASE::m_htmlView, and syncCheckboxes().

31  :
32  WX_HTML_REPORT_PANEL_BASE( parent, id, pos, size, style ),
33  m_reporter( this ),
34  m_severities( -1 ),
35  m_showAll( true ),
36  m_lazyUpdate( false )
37 {
39  m_htmlView->SetPage( addHeader( "" ) );
40 }
wxString addHeader(const wxString &aBody)
WX_HTML_PANEL_REPORTER m_reporter
the reporter
bool m_showAll
show all messages flag (overrides m_severities)
WX_HTML_REPORT_PANEL_BASE(wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxTAB_TRAVERSAL)
int m_severities
message severities to display (mask)
WX_HTML_REPORT_PANEL::~WX_HTML_REPORT_PANEL ( )

Definition at line 43 of file wx_html_report_panel.cpp.

44 {
45 }

Member Function Documentation

wxString WX_HTML_REPORT_PANEL::addHeader ( const wxString &  aBody)
private

Definition at line 116 of file wx_html_report_panel.cpp.

Referenced by Flush(), refreshView(), and WX_HTML_REPORT_PANEL().

117 {
118  wxColour bgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
119  wxColour fgcolor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
120  wxString s = "<html><body bgcolor=\"" + bgcolor.GetAsString( wxC2S_HTML_SYNTAX ) +
121  "\" text=\"" + fgcolor.GetAsString( wxC2S_HTML_SYNTAX ) + "\">";
122  s += aBody;
123  s += "</body></html>";
124 
125  return s;
126 }
void WX_HTML_REPORT_PANEL::Clear ( )

clears the report panel

Definition at line 272 of file wx_html_report_panel.cpp.

References m_html, and m_report.

Referenced by DIALOG_NETLIST::OnReadNetlistFileClick(), and DIALOG_UPDATE_PCB::PerformUpdate().

273 {
274  m_html.clear();
275  m_report.clear();
276 }
REPORT_LINES m_report
copy of the report, stored for filtering
void WX_HTML_REPORT_PANEL::Flush ( )

Forces updating the HTML page, after the report is built in lazy mode

Definition at line 85 of file wx_html_report_panel.cpp.

References addHeader(), m_html, WX_HTML_REPORT_PANEL_BASE::m_htmlView, and scrollToBottom().

Referenced by DIALOG_NETLIST::OnReadNetlistFileClick(), and DIALOG_UPDATE_PCB::PerformUpdate().

86 {
87  m_htmlView->SetPage( addHeader( m_html ) );
89 }
wxString addHeader(const wxString &aBody)
wxString WX_HTML_REPORT_PANEL::generateHtml ( const REPORT_LINE aLine)
private

Definition at line 129 of file wx_html_report_panel.cpp.

References m_severities, m_showAll, WX_HTML_REPORT_PANEL::REPORT_LINE::message, REPORTER::RPT_ACTION, REPORTER::RPT_ERROR, REPORTER::RPT_INFO, REPORTER::RPT_WARNING, and WX_HTML_REPORT_PANEL::REPORT_LINE::severity.

Referenced by refreshView(), and Report().

130 {
131  if( !m_showAll && ! ( m_severities & aLine.severity ) )
132  return wxEmptyString;
133 
134  switch( aLine.severity )
135  {
136  case REPORTER::RPT_ERROR:
137  return wxString( "<font color=\"red\" size=2>" ) + _( "<b>Error: </b></font><font size=2>" ) + aLine.message + wxString( "</font><br>" );
139  return wxString( "<font color=\"orange\" size=2>" ) + _( "<b>Warning: </b></font><font size=2>" ) + aLine.message + wxString( "</font><br>" );
140  case REPORTER::RPT_INFO:
141  return wxString( "<font color=\"gray\" size=2>" ) + _( "<b>Info: </b>" ) + aLine.message + wxString( "</font><br>" );
143  return wxString( "<font color=\"darkgreen\" size=2>" ) + aLine.message + wxString( "</font><br>" );
144  default:
145  return wxString( "<font size=2>" ) + aLine.message + wxString( "</font><br>" );
146  }
147 }
bool m_showAll
show all messages flag (overrides m_severities)
int m_severities
message severities to display (mask)
wxString WX_HTML_REPORT_PANEL::generatePlainText ( const REPORT_LINE aLine)
private

Definition at line 150 of file wx_html_report_panel.cpp.

References WX_HTML_REPORT_PANEL::REPORT_LINE::message, REPORTER::RPT_ERROR, REPORTER::RPT_INFO, REPORTER::RPT_WARNING, and WX_HTML_REPORT_PANEL::REPORT_LINE::severity.

Referenced by onBtnSaveToFile().

151 {
152  switch( aLine.severity )
153  {
154  case REPORTER::RPT_ERROR:
155  return _( "Error: " ) + aLine.message + wxT( "\n" );
157  return _( "Warning: " ) + aLine.message + wxT( "\n" );
158  case REPORTER::RPT_INFO:
159  return _( "Info: " ) + aLine.message + wxT( "\n" );
160  default:
161  return aLine.message + wxT( "\n" );
162  }
163 }
int WX_HTML_REPORT_PANEL::GetVisibleSeverities ( )

>

Returns
the visible severity filter.

If the m_showAll option is set, the mask is < 0

Definition at line 299 of file wx_html_report_panel.cpp.

References m_severities, and m_showAll.

Referenced by DIALOG_NETLIST::~DIALOG_NETLIST().

300 {
301  return m_showAll ? m_severities | 0x80000000 : m_severities & ~0x80000000;
302 }
bool m_showAll
show all messages flag (overrides m_severities)
int m_severities
message severities to display (mask)
void WX_HTML_REPORT_PANEL::MsgPanelSetMinSize ( const wxSize &  aMinSize)

Set the min size of the area which displays html messages:

Definition at line 48 of file wx_html_report_panel.cpp.

References WX_HTML_REPORT_PANEL_BASE::m_htmlView.

Referenced by DIALOG_NETLIST::DIALOG_NETLIST().

49 {
50  m_htmlView->SetMinSize( aMinSize );
51  GetSizer()->SetSizeHints( this );
52 }
void WX_HTML_REPORT_PANEL::onBtnSaveToFile ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from WX_HTML_REPORT_PANEL_BASE.

Definition at line 236 of file wx_html_report_panel.cpp.

References generatePlainText(), m_report, and TextWildcard.

237 {
238  wxFileName fn( "./report.txt" );
239 
240  wxFileDialog dlg( this, _( "Save report to file" ), fn.GetPath(), fn.GetName(),
241  TextWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
242 
243  if( dlg.ShowModal() != wxID_OK )
244  return;
245 
246  fn = dlg.GetPath();
247 
248  if( fn.GetExt().IsEmpty() )
249  fn.SetExt( wxT( "txt" ) );
250 
251  wxFile f( fn.GetFullPath(), wxFile::write );
252 
253  if( !f.IsOpened() )
254  {
255  wxString msg;
256 
257  msg.Printf( _( "Cannot write report to file '%s'." ),
258  fn.GetFullPath().GetData() );
259  wxMessageBox( msg, _( "File save error" ), wxOK | wxICON_ERROR, this );
260  return;
261  }
262 
263  for( REPORT_LINE l : m_report )
264  {
265  f.Write( generatePlainText( l ) );
266  }
267 
268  f.Close();
269 }
wxString generatePlainText(const REPORT_LINE &aLine)
const wxString TextWildcard
REPORT_LINES m_report
copy of the report, stored for filtering
void WX_HTML_REPORT_PANEL::onCheckBoxShowActions ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from WX_HTML_REPORT_PANEL_BASE.

Definition at line 225 of file wx_html_report_panel.cpp.

References m_severities, refreshView(), and REPORTER::RPT_ACTION.

226 {
227  if ( event.IsChecked() )
229  else
230  m_severities &= ~REPORTER::RPT_ACTION;
231 
232  refreshView();
233 }
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
int m_severities
message severities to display (mask)
void WX_HTML_REPORT_PANEL::onCheckBoxShowAll ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from WX_HTML_REPORT_PANEL_BASE.

Definition at line 166 of file wx_html_report_panel.cpp.

References m_showAll, refreshView(), and syncCheckboxes().

167 {
168  if ( event.IsChecked() )
169  m_showAll = true;
170  else
171  m_showAll = false;
172 
173  syncCheckboxes();
174  refreshView();
175 }
bool m_showAll
show all messages flag (overrides m_severities)
void WX_HTML_REPORT_PANEL::onCheckBoxShowErrors ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from WX_HTML_REPORT_PANEL_BASE.

Definition at line 203 of file wx_html_report_panel.cpp.

References m_severities, refreshView(), and REPORTER::RPT_ERROR.

204 {
205  if ( event.IsChecked() )
207  else
208  m_severities &= ~REPORTER::RPT_ERROR;
209 
210  refreshView();
211 }
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
int m_severities
message severities to display (mask)
void WX_HTML_REPORT_PANEL::onCheckBoxShowInfos ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from WX_HTML_REPORT_PANEL_BASE.

Definition at line 214 of file wx_html_report_panel.cpp.

References m_severities, refreshView(), and REPORTER::RPT_INFO.

215 {
216  if ( event.IsChecked() )
218  else
219  m_severities &= ~REPORTER::RPT_INFO;
220 
221  refreshView();
222 }
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
int m_severities
message severities to display (mask)
void WX_HTML_REPORT_PANEL::onCheckBoxShowWarnings ( wxCommandEvent &  event)
overrideprivatevirtual

Reimplemented from WX_HTML_REPORT_PANEL_BASE.

Definition at line 192 of file wx_html_report_panel.cpp.

References m_severities, refreshView(), and REPORTER::RPT_WARNING.

193 {
194  if ( event.IsChecked() )
196  else
197  m_severities &= ~REPORTER::RPT_WARNING;
198 
199  refreshView();
200 }
Class REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:61
int m_severities
message severities to display (mask)
void WX_HTML_REPORT_PANEL::refreshView ( )
private

Definition at line 102 of file wx_html_report_panel.cpp.

References addHeader(), generateHtml(), WX_HTML_REPORT_PANEL_BASE::m_htmlView, m_report, and scrollToBottom().

Referenced by onCheckBoxShowActions(), onCheckBoxShowAll(), onCheckBoxShowErrors(), onCheckBoxShowInfos(), and onCheckBoxShowWarnings().

103 {
104  wxString html;
105 
106  for( REPORT_LINE l : m_report )
107  {
108  html += generateHtml( l );
109  }
110 
111  m_htmlView->SetPage( addHeader( html ) );
112  scrollToBottom();
113 }
wxString addHeader(const wxString &aBody)
REPORT_LINES m_report
copy of the report, stored for filtering
wxString generateHtml(const REPORT_LINE &aLine)
void WX_HTML_REPORT_PANEL::Report ( const wxString &  aText,
REPORTER::SEVERITY  aSeverity 
)

reports a string directly.

Definition at line 61 of file wx_html_report_panel.cpp.

References generateHtml(), m_html, WX_HTML_REPORT_PANEL_BASE::m_htmlView, m_lazyUpdate, m_report, WX_HTML_REPORT_PANEL::REPORT_LINE::message, scrollToBottom(), and WX_HTML_REPORT_PANEL::REPORT_LINE::severity.

Referenced by WX_HTML_PANEL_REPORTER::Report().

62 {
63  REPORT_LINE line;
64  line.message = aText;
65  line.severity = aSeverity;
66 
67  m_report.push_back( line );
68 
69  m_html += generateHtml( line );
70 
71  if( !m_lazyUpdate )
72  {
73  m_htmlView->AppendToPage( generateHtml( line ) );
75  }
76 }
REPORT_LINES m_report
copy of the report, stored for filtering
wxString generateHtml(const REPORT_LINE &aLine)
void WX_HTML_REPORT_PANEL::scrollToBottom ( )
private

Definition at line 92 of file wx_html_report_panel.cpp.

References WX_HTML_REPORT_PANEL_BASE::m_htmlView.

Referenced by Flush(), refreshView(), and Report().

93 {
94  int x, y, xUnit, yUnit;
95 
96  m_htmlView->GetVirtualSize( &x, &y );
97  m_htmlView->GetScrollPixelsPerUnit( &xUnit, &yUnit );
98  m_htmlView->Scroll( 0, y / yUnit );
99 }
void WX_HTML_REPORT_PANEL::SetLabel ( const wxString &  aLabel)
override

sets the frame label

Definition at line 279 of file wx_html_report_panel.cpp.

References WX_HTML_REPORT_PANEL_BASE::m_box.

Referenced by DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB(), and DIALOG_UPDATE_PCB::OnUpdateClick().

280 {
281  m_box->GetStaticBox()->SetLabel( aLabel );
282 }
void WX_HTML_REPORT_PANEL::SetLazyUpdate ( bool  aLazyUpdate)

Sets the lasy update.

If this mode is on, messages are stored but the display

is not updated (Updating display can be very time consumming if there are many messages) A call to Flush() will be needed after build the report

Definition at line 79 of file wx_html_report_panel.cpp.

References m_lazyUpdate.

Referenced by DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB(), and DIALOG_NETLIST::OnReadNetlistFileClick().

80 {
81  m_lazyUpdate = aLazyUpdate;
82 }
void WX_HTML_REPORT_PANEL::SetVisibleSeverities ( int  aSeverities)

Set the visible severity filter.

if aSeverities < 0 the m_showAll option is set

Definition at line 285 of file wx_html_report_panel.cpp.

References m_severities, m_showAll, and syncCheckboxes().

Referenced by DIALOG_NETLIST::DIALOG_NETLIST(), and DIALOG_UPDATE_PCB::DIALOG_UPDATE_PCB().

286 {
287  if( aSeverities < 0 )
288  m_showAll = true;
289  else
290  {
291  m_showAll = false;
292  m_severities = aSeverities;
293  }
294 
295  syncCheckboxes();
296 }
bool m_showAll
show all messages flag (overrides m_severities)
int m_severities
message severities to display (mask)
void WX_HTML_REPORT_PANEL::syncCheckboxes ( )
private

Definition at line 178 of file wx_html_report_panel.cpp.

References WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowActions, WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowAll, WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowErrors, WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowInfos, WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowWarnings, m_severities, m_showAll, REPORTER::RPT_ACTION, REPORTER::RPT_ERROR, REPORTER::RPT_INFO, and REPORTER::RPT_WARNING.

Referenced by onCheckBoxShowAll(), SetVisibleSeverities(), and WX_HTML_REPORT_PANEL().

179 {
180  m_checkBoxShowAll->SetValue( m_showAll );
181  m_checkBoxShowWarnings->Enable( !m_showAll );
183  m_checkBoxShowErrors->Enable( !m_showAll );
185  m_checkBoxShowInfos->Enable( !m_showAll );
187  m_checkBoxShowActions->Enable( !m_showAll );
189 }
bool m_showAll
show all messages flag (overrides m_severities)
int m_severities
message severities to display (mask)

Member Data Documentation

wxStaticBoxSizer* WX_HTML_REPORT_PANEL_BASE::m_box
protectedinherited
wxButton* WX_HTML_REPORT_PANEL_BASE::m_btnSaveReportToFile
protectedinherited
wxCheckBox* WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowActions
protectedinherited
wxCheckBox* WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowAll
protectedinherited
wxCheckBox* WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowErrors
protectedinherited
wxCheckBox* WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowInfos
protectedinherited
wxCheckBox* WX_HTML_REPORT_PANEL_BASE::m_checkBoxShowWarnings
protectedinherited
wxString WX_HTML_REPORT_PANEL::m_html
private

Definition at line 117 of file wx_html_report_panel.h.

Referenced by Clear(), Flush(), and Report().

wxHtmlWindow* WX_HTML_REPORT_PANEL_BASE::m_htmlView
protectedinherited
bool WX_HTML_REPORT_PANEL::m_lazyUpdate
private

Definition at line 119 of file wx_html_report_panel.h.

Referenced by Report(), and SetLazyUpdate().

REPORT_LINES WX_HTML_REPORT_PANEL::m_report
private

copy of the report, stored for filtering

Definition at line 106 of file wx_html_report_panel.h.

Referenced by Clear(), onBtnSaveToFile(), refreshView(), and Report().

WX_HTML_PANEL_REPORTER WX_HTML_REPORT_PANEL::m_reporter
private

the reporter

Definition at line 109 of file wx_html_report_panel.h.

Referenced by Reporter().

int WX_HTML_REPORT_PANEL::m_severities
private
bool WX_HTML_REPORT_PANEL::m_showAll
private

show all messages flag (overrides m_severities)

Definition at line 115 of file wx_html_report_panel.h.

Referenced by generateHtml(), GetVisibleSeverities(), onCheckBoxShowAll(), SetVisibleSeverities(), and syncCheckboxes().

wxStaticText* WX_HTML_REPORT_PANEL_BASE::m_staticText3
protectedinherited

The documentation for this class was generated from the following files: