KiCad PCB EDA Suite
INFOBAR_REPORTER Class Reference

INFOBAR_REPORTER is 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)
 
REPORTERReport (const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED) override
 Function Report is a pure virtual function to override in the derived object. More...
 
bool HasMessage () const override
 Function HasMessage 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)
 Function ReportTail 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)
 Function ReportHead Places the report at the beginning of the list for objects that support ordering. More...
 
REPORTERoperator<< (const wxString &aText)
 
REPORTERoperator<< (const wxChar *aText)
 
REPORTERoperator<< (wxChar aChar)
 
REPORTERoperator<< (const char *aText)
 

Private Attributes

bool m_messageSet
 
WX_INFOBARm_infoBar
 
wxString m_message
 
SEVERITY m_severity
 

Detailed Description

INFOBAR_REPORTER is 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 287 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 73 of file reporter.h.

73  {
74  LOC_HEAD = 0,
75  LOC_BODY,
76  LOC_TAIL
77  };

Constructor & Destructor Documentation

◆ INFOBAR_REPORTER()

INFOBAR_REPORTER::INFOBAR_REPORTER ( WX_INFOBAR aInfoBar)
inline

Definition at line 296 of file reporter.h.

297  : REPORTER(),
298  m_messageSet( false ),
299  m_infoBar( aInfoBar ),
300  m_message( wxEmptyString ),
302  {
303  }
REPORTER is a pure virtual class used to derive REPORTER objects from.
Definition: reporter.h:64
SEVERITY m_severity
Definition: reporter.h:293
wxString m_message
Definition: reporter.h:292
WX_INFOBAR * m_infoBar
Definition: reporter.h:291

Member Function Documentation

◆ Finalize()

void INFOBAR_REPORTER::Finalize ( )

Update the infobar with the reported text.

Definition at line 179 of file reporter.cpp.

180 {
181  // Don't do anything if no message was ever given
182  if( !m_infoBar || !m_messageSet )
183  return;
184 
185  // Short circuit if the message is empty and it is already hidden
186  if( !HasMessage() && !m_infoBar->IsShown() )
187  return;
188 
189  int icon = wxICON_NONE;
190 
191  switch( m_severity )
192  {
193  case RPT_SEVERITY_UNDEFINED: icon = wxICON_INFORMATION; break;
194  case RPT_SEVERITY_INFO: icon = wxICON_INFORMATION; break;
195  case RPT_SEVERITY_EXCLUSION: icon = wxICON_WARNING; break;
196  case RPT_SEVERITY_ACTION: icon = wxICON_WARNING; break;
197  case RPT_SEVERITY_WARNING: icon = wxICON_WARNING; break;
198  case RPT_SEVERITY_ERROR: icon = wxICON_ERROR; break;
199  case RPT_SEVERITY_IGNORE: icon = wxICON_INFORMATION; break;
200  }
201 
202  if( HasMessage() )
204  else
206 }
bool HasMessage() const override
Function HasMessage Returns true if the reporter client is non-empty.
Definition: reporter.cpp:173
SEVERITY m_severity
Definition: reporter.h:293
wxString m_message
Definition: reporter.h:292
void QueueShowMessage(const wxString &aMessage, int aFlags=wxICON_INFORMATION)
Send the infobar an event telling it to show a message.
Definition: infobar.cpp:89
void QueueDismiss()
Send the infobar an event telling it to hide itself.
Definition: infobar.cpp:100
WX_INFOBAR * m_infoBar
Definition: reporter.h:291

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(), DISPLAY_FOOTPRINTS_FRAME::InitDisplay(), and SCH_EDIT_TOOL::RefreshSymbolFromLibrary().

◆ HasMessage()

bool INFOBAR_REPORTER::HasMessage ( ) const
overridevirtual

Function HasMessage Returns true if the reporter client is non-empty.

Implements REPORTER.

Definition at line 173 of file reporter.cpp.

174 {
175  return !m_message.IsEmpty();
176 }
wxString m_message
Definition: reporter.h:292

References m_message.

Referenced by Finalize(), and SCH_EDIT_TOOL::RefreshSymbolFromLibrary().

◆ operator<<() [1/4]

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

Definition at line 110 of file reporter.h.

110 { return Report( aText ); }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.

References REPORTER::Report().

◆ operator<<() [2/4]

REPORTER& REPORTER::operator<< ( const wxChar *  aText)
inlineinherited

Definition at line 111 of file reporter.h.

111 { return Report( wxString( aText ) ); }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.

References REPORTER::Report().

◆ operator<<() [3/4]

REPORTER& REPORTER::operator<< ( wxChar  aChar)
inlineinherited

Definition at line 112 of file reporter.h.

112 { return Report( wxString( aChar ) ); }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.

References REPORTER::Report().

◆ operator<<() [4/4]

REPORTER& REPORTER::operator<< ( const char *  aText)
inlineinherited

Definition at line 113 of file reporter.h.

113 { return Report( aText ); }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.

References REPORTER::Report().

◆ Report() [1/2]

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

Definition at line 33 of file reporter.cpp.

34 {
35  Report( FROM_UTF8( aText ) );
36  return *this;
37 }
static wxString FROM_UTF8(const char *cstring)
function FROM_UTF8 converts a UTF8 encoded C string to a wxString for all wxWidgets build modes.
Definition: macros.h:114
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.

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

◆ Report() [2/2]

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

Function Report is a pure virtual function to override in the derived object.

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 163 of file reporter.cpp.

164 {
165  m_message = aText;
166  m_severity = aSeverity;
167  m_messageSet = true;
168 
169  return *this;
170 }
SEVERITY m_severity
Definition: reporter.h:293
wxString m_message
Definition: reporter.h:292

References m_message, m_messageSet, and m_severity.

Referenced by SCH_EDIT_TOOL::RefreshSymbolFromLibrary().

◆ ReportHead()

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

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

Reimplemented in WX_HTML_PANEL_REPORTER.

Definition at line 103 of file reporter.h.

104  {
105  return Report( aText, aSeverity );
106  }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.

References REPORTER::Report().

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

◆ ReportTail()

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

Function ReportTail Places the report at the end of the list, for objects that support report ordering.

Reimplemented in WX_HTML_PANEL_REPORTER.

Definition at line 94 of file reporter.h.

95  {
96  return Report( aText, aSeverity );
97  }
virtual REPORTER & Report(const wxString &aText, SEVERITY aSeverity=RPT_SEVERITY_UNDEFINED)=0
Function Report is a pure virtual function to override in the derived object.

References REPORTER::Report().

Referenced by SCH_EDIT_FRAME::AnnotateComponents(), BACK_ANNOTATE::BackAnnotateSymbols(), BACK_ANNOTATE::checkForUnusedSymbols(), BACK_ANNOTATE::checkSharedSchematicErrors(), DIALOG_SYMBOL_REMAP::createProjectSymbolLibTable(), BACK_ANNOTATE::getChangeList(), GERBER_JOBFILE_READER::ReadGerberJobFile(), DIALOG_ERC::TestErc(), BOARD_NETLIST_UPDATER::UpdateNetlist(), SCH_SCREEN::UpdateSymbolLinks(), and SCH_EDIT_FRAME::WriteNetListFile().

Member Data Documentation

◆ m_infoBar

WX_INFOBAR* INFOBAR_REPORTER::m_infoBar
private

Definition at line 291 of file reporter.h.

Referenced by Finalize().

◆ m_message

wxString INFOBAR_REPORTER::m_message
private

Definition at line 292 of file reporter.h.

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

◆ m_messageSet

bool INFOBAR_REPORTER::m_messageSet
private

Definition at line 290 of file reporter.h.

Referenced by Finalize(), and Report().

◆ m_severity

SEVERITY INFOBAR_REPORTER::m_severity
private

Definition at line 293 of file reporter.h.

Referenced by Finalize(), and Report().


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