KiCad PCB EDA Suite
INFOBAR_REPORTER Class Reference

A wrapper for reporting to a WX_INFOBAR UI element. More...

#include <reporter.h>

Inheritance diagram for INFOBAR_REPORTER:
REPORTER

Public Types

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

Public Member Functions

 INFOBAR_REPORTER (WX_INFOBAR *aInfoBar)
 
virtual ~INFOBAR_REPORTER ()
 
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 Finalize ()
 Update the infobar with the reported text. More...
 
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)
 
virtual EDA_UNITS GetUnits () const
 

Private Attributes

bool m_messageSet
 
WX_INFOBARm_infoBar
 
std::unique_ptr< wxString > m_message
 
SEVERITY m_severity
 

Detailed Description

A wrapper for reporting to a WX_INFOBAR UI element.

The infobar is not updated until the Finalize() method is called. That method will queue either a show message or a dismiss event for the infobar - so this reporter is safe to use inside a paint event without causing an infinite paint event loop.

No action is taken if no message is given to the reporter.

Definition at line 315 of file reporter.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

◆ INFOBAR_REPORTER()

INFOBAR_REPORTER::INFOBAR_REPORTER ( WX_INFOBAR aInfoBar)
inline

Definition at line 318 of file reporter.h.

319  : REPORTER(),
320  m_messageSet( false ),
321  m_infoBar( aInfoBar ),
323  {
324  }
A pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:70
SEVERITY m_severity
Definition: reporter.h:342
WX_INFOBAR * m_infoBar
Definition: reporter.h:340

◆ ~INFOBAR_REPORTER()

INFOBAR_REPORTER::~INFOBAR_REPORTER ( )
virtual

Definition at line 204 of file reporter.cpp.

205 {
206 }

Member Function Documentation

◆ Finalize()

void INFOBAR_REPORTER::Finalize ( )

Update the infobar with the reported text.

Definition at line 225 of file reporter.cpp.

226 {
227  // Don't do anything if no message was ever given
228  if( !m_infoBar || !m_messageSet )
229  return;
230 
231  // Short circuit if the message is empty and it is already hidden
232  if( !HasMessage() && !m_infoBar->IsShown() )
233  return;
234 
235  int icon = wxICON_NONE;
236 
237  switch( m_severity )
238  {
239  case RPT_SEVERITY_UNDEFINED: icon = wxICON_INFORMATION; break;
240  case RPT_SEVERITY_INFO: icon = wxICON_INFORMATION; break;
241  case RPT_SEVERITY_EXCLUSION: icon = wxICON_WARNING; break;
242  case RPT_SEVERITY_ACTION: icon = wxICON_WARNING; break;
243  case RPT_SEVERITY_WARNING: icon = wxICON_WARNING; break;
244  case RPT_SEVERITY_ERROR: icon = wxICON_ERROR; break;
245  case RPT_SEVERITY_IGNORE: icon = wxICON_INFORMATION; break;
246  }
247 
248  if( m_message->EndsWith( "\n" ) )
249  *m_message = m_message->Left( m_message->Length() - 1 );
250 
251  if( HasMessage() )
253  else
255 }
bool HasMessage() const override
Returns true if the reporter client is non-empty.
Definition: reporter.cpp:219
SEVERITY m_severity
Definition: reporter.h:342
void QueueShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION)
Send the infobar an event telling it to show a message.
Definition: infobar.cpp:109
void QueueDismiss()
Send the infobar an event telling it to hide itself.
Definition: infobar.cpp:120
WX_INFOBAR * m_infoBar
Definition: reporter.h:340
std::unique_ptr< wxString > m_message
Definition: reporter.h:341

References HasMessage(), m_infoBar, m_message, m_messageSet, m_severity, WX_INFOBAR::QueueDismiss(), WX_INFOBAR::QueueShowMessage(), RPT_SEVERITY_ACTION, RPT_SEVERITY_ERROR, RPT_SEVERITY_EXCLUSION, RPT_SEVERITY_IGNORE, RPT_SEVERITY_INFO, RPT_SEVERITY_UNDEFINED, and RPT_SEVERITY_WARNING.

Referenced by EDA_3D_CANVAS::DoRePaint(), and DISPLAY_FOOTPRINTS_FRAME::InitDisplay().

◆ GetUnits()

virtual EDA_UNITS REPORTER::GetUnits ( ) const
inlinevirtualinherited

Reimplemented in WX_HTML_REPORT_BOX.

Definition at line 123 of file reporter.h.

124  {
125  return EDA_UNITS::MILLIMETRES;
126  }

References MILLIMETRES.

Referenced by BOARD_INSPECTION_TOOL::reportClearance().

◆ HasMessage()

bool INFOBAR_REPORTER::HasMessage ( ) const
overridevirtual

Returns true if the reporter client is non-empty.

Implements REPORTER.

Definition at line 219 of file reporter.cpp.

220 {
221  return m_message && !m_message->IsEmpty();
222 }
std::unique_ptr< wxString > m_message
Definition: reporter.h:341

References m_message.

Referenced by Finalize().

◆ 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 & 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().

◆ Report() [2/2]

REPORTER & INFOBAR_REPORTER::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 209 of file reporter.cpp.

210 {
211  m_message.reset( new wxString( aText ) );
212  m_severity = aSeverity;
213  m_messageSet = true;
214 
215  return *this;
216 }
SEVERITY m_severity
Definition: reporter.h:342
std::unique_ptr< wxString > m_message
Definition: reporter.h:341

References m_message, m_messageSet, and m_severity.

Referenced by EDA_3D_CANVAS::DoRePaint().

◆ 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()

Member Data Documentation

◆ m_infoBar

WX_INFOBAR* INFOBAR_REPORTER::m_infoBar
private

Definition at line 340 of file reporter.h.

Referenced by Finalize().

◆ m_message

std::unique_ptr<wxString> INFOBAR_REPORTER::m_message
private

Definition at line 341 of file reporter.h.

Referenced by Finalize(), HasMessage(), and Report().

◆ m_messageSet

bool INFOBAR_REPORTER::m_messageSet
private

Definition at line 339 of file reporter.h.

Referenced by Finalize(), and Report().

◆ m_severity

SEVERITY INFOBAR_REPORTER::m_severity
private

Definition at line 342 of file reporter.h.

Referenced by Finalize(), and Report().


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