KiCad PCB EDA Suite
WX_HTML_REPORT_BOX Class Reference

A slimmed down version of WX_HTML_REPORT_PANEL. More...

#include <wx_html_report_box.h>

Inheritance diagram for WX_HTML_REPORT_BOX:
HTML_WINDOW REPORTER

Public Types

enum  LOCATION { LOC_HEAD = 0, LOC_BODY, LOC_TAIL }
 Location where the message is to be reported. More...
 

Public Member Functions

 WX_HTML_REPORT_BOX (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxSize(500, 300), long style=wxTAB_TRAVERSAL)
 
REPORTERReport (const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
 Report a string with a given severity. More...
 
bool HasMessage () const override
 Returns true if the reporter client is non-empty. More...
 
void SetUnits (EDA_UNITS aUnits)
 
EDA_UNITS GetUnits () const override
 
void SetImmediateMode ()
 In immediate mode, messages are flushed as they are added. More...
 
void Flush ()
 Build the HTML messages page. More...
 
void Clear ()
 Delete the stored messages. More...
 
bool SetPage (const wxString &aSource) override
 
bool AppendToPage (const wxString &aSource)
 
void ThemeChanged ()
 
REPORTERReport (const char *aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
 
virtual REPORTERReportTail (const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
 Places the report at the end of the list, for objects that support report ordering. More...
 
virtual REPORTERReportHead (const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)
 Places the report at the beginning of the list for objects that support ordering. More...
 
REPORTERoperator<< (const wxString &aText)
 

Private Member Functions

void onThemeChanged (wxSysColourChangedEvent &aEvent)
 
wxString addHeader (const wxString &aBody)
 
wxString generateHtml (const wxString &aLine)
 

Private Attributes

EDA_UNITS m_units
 
bool m_immediateMode
 copy of the report, stored for filtering More...
 
std::vector< wxString > m_messages
 

Detailed Description

A slimmed down version of WX_HTML_REPORT_PANEL.

Definition at line 31 of file wx_html_report_box.h.

Member Enumeration Documentation

◆ LOCATION

enum REPORTER::LOCATION
inherited

Location where the message is to be reported.

LOC_HEAD messages are printed before all others (typically intro messages) LOC_BODY messages are printed in the middle LOC_TAIL messages are printed after all others (typically status messages)

Enumerator
LOC_HEAD 
LOC_BODY 
LOC_TAIL 

Definition at line 79 of file reporter.h.

79  {
80  LOC_HEAD = 0,
81  LOC_BODY,
82  LOC_TAIL
83  };

Constructor & Destructor Documentation

◆ WX_HTML_REPORT_BOX()

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

Definition at line 28 of file wx_html_report_box.cpp.

29  :
30  HTML_WINDOW( parent, id, pos, size, style ),
32 {
33  Flush();
34 
35  Bind( wxEVT_SYS_COLOUR_CHANGED,
36  wxSysColourChangedEventHandler( WX_HTML_REPORT_BOX::onThemeChanged ), this );
37 }
void Flush()
Build the HTML messages page.
bool m_immediateMode
copy of the report, stored for filtering
HTML_WINDOW(wxWindow *aParent, wxWindowID aId=wxID_ANY, const wxPoint &aPos=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=wxHW_DEFAULT_STYLE, const wxString &aName="htmlWindow")
Definition: html_window.cpp:29
void onThemeChanged(wxSysColourChangedEvent &aEvent)

References Flush(), MILLIMETRES, and onThemeChanged().

Member Function Documentation

◆ addHeader()

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

◆ AppendToPage()

bool HTML_WINDOW::AppendToPage ( const wxString &  aSource)
inherited

◆ Clear()

void WX_HTML_REPORT_BOX::Clear ( )

Delete the stored messages.

Definition at line 94 of file wx_html_report_box.cpp.

95 {
96  m_messages.clear();
97 }
std::vector< wxString > m_messages

References m_messages.

Referenced by PANEL_SETUP_RULES::OnCompile(), DIALOG_DRC::OnRunDRCClick(), and DIALOG_ERC::OnRunERCClick().

◆ Flush()

void WX_HTML_REPORT_BOX::Flush ( )

Build the HTML messages page.

Call it if the immediate mode is not activated to be able to display them

Definition at line 64 of file wx_html_report_box.cpp.

65 {
66  wxString html;
67 
68  for( const wxString& line : m_messages )
69  html += generateHtml( line );
70 
71  SetPage( html );
72 }
std::vector< wxString > m_messages
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38
wxString generateHtml(const wxString &aLine)

References generateHtml(), m_messages, and HTML_WINDOW::SetPage().

Referenced by SCH_EDIT_FRAME::importFile(), PANEL_SETUP_RULES::OnCompile(), DIALOG_DRC::OnRunDRCClick(), onThemeChanged(), Report(), and WX_HTML_REPORT_BOX().

◆ generateHtml()

wxString WX_HTML_REPORT_BOX::generateHtml ( const wxString &  aLine)
private

Definition at line 75 of file wx_html_report_box.cpp.

76 {
77  // wxWidgets default linespacing is about 110% of font-height (which is way too small),
78  // and the default paragraph spacing is about 200% (which is too big). The heading,
79  // bullet lists, etc. line spacing is fine.
80  //
81  // And of course they provide no way to set it, which leaves us with very few options.
82  // Fortunately we know we're dealing mostly with single lines in the reporter so we apply
83  // an egregious hack and enforce a minimum linespacing by inserting an invisible img
84  // element with appropriate height
85 
86  wxFont font = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
87  int additionalLineSpacing = KiROUND( font.GetPixelSize().y * 0.6 );
88 
89  return wxString::Format( wxT( "<img align=texttop height=%d width=0 src=#>%s<br>" ),
90  additionalLineSpacing, aLine );
91 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:73

References Format(), and KiROUND().

Referenced by Flush().

◆ GetUnits()

EDA_UNITS WX_HTML_REPORT_BOX::GetUnits ( ) const
inlineoverridevirtual

Reimplemented from REPORTER.

Definition at line 43 of file wx_html_report_box.h.

43 { return m_units; }

References m_units.

◆ HasMessage()

bool WX_HTML_REPORT_BOX::HasMessage ( ) const
inlineoverridevirtual

Returns true if the reporter client is non-empty.

Implements REPORTER.

Definition at line 40 of file wx_html_report_box.h.

40 { return !m_messages.empty(); }
std::vector< wxString > m_messages

References m_messages.

Referenced by SCH_EDIT_FRAME::importFile().

◆ onThemeChanged()

void WX_HTML_REPORT_BOX::onThemeChanged ( wxSysColourChangedEvent &  aEvent)
private

Definition at line 40 of file wx_html_report_box.cpp.

41 {
42  Flush();
43 
44  aEvent.Skip();
45 }
void Flush()
Build the HTML messages page.

References Flush().

Referenced by WX_HTML_REPORT_BOX().

◆ operator<<()

REPORTER& REPORTER::operator<< ( const wxString &  aText)
inlineinherited

Definition at line 116 of file reporter.h.

116 { return Report( aText ); }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.

References REPORTER::Report().

◆ Report() [1/2]

REPORTER & WX_HTML_REPORT_BOX::Report ( const wxString &  aText,
SEVERITY  aSeverity = RPT_SEVERITY_UNDEFINED 
)
overridevirtual

Report a string with a given severity.

Parameters
aTextis the string to report.
aSeverityis an indicator ( RPT_UNDEFINED, RPT_INFO, RPT_WARNING, RPT_ERROR, RPT_ACTION ) used to filter and format messages

Implements REPORTER.

Definition at line 48 of file wx_html_report_box.cpp.

49 {
50  m_messages.push_back( aText );
51 
52  if( m_immediateMode )
53  {
54  Flush();
55  int px, py, x, y;
56  GetScrollPixelsPerUnit( &px, &py );
57  GetVirtualSize( &x, &y );
58  Scroll( -1, y * py );
59  }
60 
61  return *this;
62 }
void Flush()
Build the HTML messages page.
std::vector< wxString > m_messages
bool m_immediateMode
copy of the report, stored for filtering

References Flush(), m_immediateMode, and m_messages.

Referenced by DIALOG_DRC::AdvancePhase(), PANEL_SETUP_RULES::OnCompile(), DIALOG_DRC::OnRunDRCClick(), DIALOG_ERC::OnRunERCClick(), DIALOG_ERC::OnSaveReport(), DIALOG_DRC::OnSaveReport(), DIALOG_ERC::Report(), and DIALOG_PCM_PROGRESS::Report().

◆ Report() [2/2]

REPORTER & REPORTER::Report ( const char *  aText,
SEVERITY  aSeverity = RPT_SEVERITY_UNDEFINED 
)
inherited

Definition at line 36 of file reporter.cpp.

37 {
38  Report( FROM_UTF8( aText ) );
39  return *this;
40 }
static wxString FROM_UTF8(const char *cstring)
Convert a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:110
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.

References FROM_UTF8(), and REPORTER::Report().

◆ ReportHead()

virtual REPORTER& REPORTER::ReportHead ( const wxString &  aText,
SEVERITY  aSeverity = RPT_SEVERITY_UNDEFINED 
)
inlinevirtualinherited

Places the report at the beginning of the list for objects that support ordering.

Reimplemented in WX_HTML_PANEL_REPORTER.

Definition at line 108 of file reporter.h.

110  {
111  return Report( aText, aSeverity );
112  }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Report a string with a given severity.

References REPORTER::Report().

Referenced by BACK_ANNOTATE::applyChangelist(), BACK_ANNOTATE::getPcbModulesFromString(), DIALOG_NETLIST::loadNetlist(), DIALOG_ERC::OnRunERCClick(), BACK_ANNOTATE::processNetNameChange(), and SCH_EDIT_FRAME::WriteNetListFile().

◆ ReportTail()

◆ SetImmediateMode()

void WX_HTML_REPORT_BOX::SetImmediateMode ( )
inline

In immediate mode, messages are flushed as they are added.

Required for progress-related reports, but can be very slow for larger reports.

Definition at line 49 of file wx_html_report_box.h.

49 { m_immediateMode = true; }
bool m_immediateMode
copy of the report, stored for filtering

References m_immediateMode.

Referenced by DIALOG_DRC::DIALOG_DRC(), DIALOG_ERC::DIALOG_ERC(), and DIALOG_PCM_PROGRESS::DIALOG_PCM_PROGRESS().

◆ SetPage()

bool HTML_WINDOW::SetPage ( const wxString &  aSource)
overrideinherited

Definition at line 38 of file html_window.cpp.

39 {
40  m_pageSource = aSource;
41 
42  wxColour fgColor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
43  wxColour bgColor = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW );
44  wxColour linkColor = wxSystemSettings::GetColour( wxSYS_COLOUR_HOTLIGHT );
45 
46  wxString html = wxString::Format( wxT( "<html>\n<body text='%s' bgcolor='%s' link='%s'>\n" ),
47  fgColor.GetAsString( wxC2S_HTML_SYNTAX ),
48  bgColor.GetAsString( wxC2S_HTML_SYNTAX ),
49  linkColor.GetAsString( wxC2S_HTML_SYNTAX ) );
50  html.Append( aSource );
51  html.Append( wxT( "\n</body>\n</html>" ) );
52 
53  return wxHtmlWindow::SetPage( html );
54 }
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200
wxString m_pageSource
Definition: html_window.h:51

References Format(), and HTML_WINDOW::m_pageSource.

Referenced by HTML_WINDOW::AppendToPage(), DIALOG_ABOUT::createNotebookHtmlPage(), DIALOG_FP_PLUGIN_OPTIONS::DIALOG_FP_PLUGIN_OPTIONS(), DIALOG_TEMPLATE_SELECTOR::DIALOG_TEMPLATE_SELECTOR(), Flush(), WX_HTML_REPORT_PANEL::Flush(), PANEL_TRACK_WIDTH::LoadSettings(), DIALOG_FP_PLUGIN_OPTIONS::onListBoxItemSelected(), LIB_TREE::onPreselect(), HTML_MESSAGE_BOX::reload(), PANEL_ATTENUATORS::SetAttenuator(), DIALOG_DISPLAY_HTML_TEXT::SetPage(), HTML_WINDOW::ThemeChanged(), PANEL_ATTENUATORS::TransfAttenuatorDataToPanel(), and PANEL_ATTENUATORS::TransfAttenuatorResultsToPanel().

◆ SetUnits()

void WX_HTML_REPORT_BOX::SetUnits ( EDA_UNITS  aUnits)
inline

Definition at line 42 of file wx_html_report_box.h.

42 { m_units = aUnits; }

References m_units.

Referenced by DIALOG_CONSTRAINTS_REPORTER::AddPage().

◆ ThemeChanged()

void HTML_WINDOW::ThemeChanged ( )
inherited

Definition at line 63 of file html_window.cpp.

64 {
66 }
bool SetPage(const wxString &aSource) override
Definition: html_window.cpp:38
wxString m_pageSource
Definition: html_window.h:51

References HTML_WINDOW::m_pageSource, and HTML_WINDOW::SetPage().

Referenced by HTML_WINDOW::onThemeChanged(), PANEL_TRACK_WIDTH::ThemeChanged(), and PANEL_ATTENUATORS::ThemeChanged().

Member Data Documentation

◆ m_immediateMode

bool WX_HTML_REPORT_BOX::m_immediateMode
private

copy of the report, stored for filtering

Definition at line 72 of file wx_html_report_box.h.

Referenced by Report(), and SetImmediateMode().

◆ m_messages

std::vector<wxString> WX_HTML_REPORT_BOX::m_messages
private

Definition at line 75 of file wx_html_report_box.h.

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

◆ m_units

EDA_UNITS WX_HTML_REPORT_BOX::m_units
private

Definition at line 68 of file wx_html_report_box.h.

Referenced by GetUnits(), and SetUnits().


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