KiCad PCB EDA Suite
DRCLISTBOX Class Reference

Class DRCLISTBOX is used to display a DRC_ITEM_LIST. More...

#include <dialog_drclistbox.h>

Inheritance diagram for DRCLISTBOX:

Public Member Functions

 DRCLISTBOX (wxWindow *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=0, const wxString choices[]=NULL, int unused=0)
 
 ~DRCLISTBOX ()
 
void SetList (EDA_UNITS_T aUnits, DRC_ITEM_LIST *aList)
 Function SetList sets the DRC_ITEM_LIST for this listbox. More...
 
const DRC_ITEMGetItem (int aIndex)
 Function GetItem returns a requested DRC_ITEM* or NULL. More...
 
wxString OnGetItem (size_t n) const override
 Function OnGetItem returns the html text associated with the DRC_ITEM given by index 'n'. More...
 
wxString OnGetItemMarkup (size_t n) const override
 Function OnGetItem returns the html text associated with the given index 'n'. More...
 
void DeleteItem (int aIndex)
 Function DeleteElement will delete one of the items in the list. More...
 
void DeleteAllItems ()
 Function DeleteAllItems deletes all items in the list. More...
 

Private Attributes

EDA_UNITS_T m_units
 
DRC_ITEM_LISTm_list
 wxHtmlListBox does not own the list, I do More...
 

Detailed Description

Class DRCLISTBOX is used to display a DRC_ITEM_LIST.

Definition at line 177 of file dialog_drclistbox.h.

Constructor & Destructor Documentation

◆ DRCLISTBOX()

DRCLISTBOX::DRCLISTBOX ( wxWindow *  parent,
wxWindowID  id = wxID_ANY,
const wxPoint &  pos = wxDefaultPosition,
const wxSize &  size = wxDefaultSize,
long  style = 0,
const wxString  choices[] = NULL,
int  unused = 0 
)
inline

Definition at line 184 of file dialog_drclistbox.h.

187  : wxHtmlListBox( parent, id, pos, size, style )
188  {
190  m_list = 0;
191  }
EDA_UNITS_T m_units
DRC_ITEM_LIST * m_list
wxHtmlListBox does not own the list, I do

References m_list, m_units, and MILLIMETRES.

◆ ~DRCLISTBOX()

DRCLISTBOX::~DRCLISTBOX ( )
inline

Definition at line 194 of file dialog_drclistbox.h.

195  {
196  delete m_list; // I own it, I destroy it.
197  }
DRC_ITEM_LIST * m_list
wxHtmlListBox does not own the list, I do

References m_list.

Member Function Documentation

◆ DeleteAllItems()

void DRCLISTBOX::DeleteAllItems ( )
inline

Function DeleteAllItems deletes all items in the list.

Definition at line 295 of file dialog_drclistbox.h.

296  {
297  if( m_list )
298  {
300  SetItemCount(0);
301  SetSelection( -1 ); // -1 is no selection
302  Refresh();
303  }
304  }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
DRC_ITEM_LIST * m_list
wxHtmlListBox does not own the list, I do
virtual void DeleteAllItems()=0
Function DeleteAllItems removes and deletes all the items in the list.

References DRC_ITEM_LIST::DeleteAllItems(), m_list, and Refresh().

Referenced by DIALOG_DRC_CONTROL::DelDRCMarkers().

◆ DeleteItem()

void DRCLISTBOX::DeleteItem ( int  aIndex)
inline

Function DeleteElement will delete one of the items in the list.

Parameters
aIndexThe index into the list to delete.

Definition at line 273 of file dialog_drclistbox.h.

274  {
275  if( m_list )
276  {
277  int selection = GetSelection();
278 
279  m_list->DeleteItem( aIndex );
280  int count = m_list->GetCount();
281  SetItemCount( count );
282 
283  // if old selection >= new count
284  if( selection >= count )
285  SetSelection( count-1 ); // -1 is "no selection"
286  Refresh();
287  }
288  }
virtual void DeleteItem(int aIndex)=0
Function DeleteAllItems removes and deletes desired item from the list.
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
DRC_ITEM_LIST * m_list
wxHtmlListBox does not own the list, I do
virtual int GetCount()=0
Function GetCount returns the number of items in the list.

References DRC_ITEM_LIST::DeleteItem(), DRC_ITEM_LIST::GetCount(), m_list, and Refresh().

Referenced by DIALOG_DRC_CONTROL::OnDeleteOneClick().

◆ GetItem()

◆ OnGetItem()

wxString DRCLISTBOX::OnGetItem ( size_t  n) const
inlineoverride

Function OnGetItem returns the html text associated with the DRC_ITEM given by index 'n'.

Parameters
nAn index into the list.
Returns
wxString - the simple html text to show in the listbox.

Definition at line 238 of file dialog_drclistbox.h.

239  {
240  if( m_list )
241  {
242  const DRC_ITEM* item = m_list->GetItem( (int) n );
243  if( item )
244  {
245  wxColour color = wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOWTEXT );
246 
247  return wxString::Format( wxT( "<font color='%s'>%s</font>" ),
248  color.GetAsString( wxC2S_HTML_SYNTAX ),
249  item->ShowHtml( m_units ) );
250  }
251  }
252  return wxString();
253  }
Class DRC_ITEM is a holder for a DRC (in Pcbnew) or ERC (in Eeschema) error item.
Definition: drc_item.h:48
virtual const DRC_ITEM * GetItem(int aIndex)=0
Function GetItem retrieves a DRC_ITEM by pointer.
int color
Definition: DXF_plotter.cpp:62
EDA_UNITS_T m_units
DRC_ITEM_LIST * m_list
wxHtmlListBox does not own the list, I do
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, CPTREE &aTree)
Function Format outputs a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:205
wxString ShowHtml(EDA_UNITS_T aUnits) const
Function ShowHtml translates this object into a fragment of HTML suitable for the wxWidget's wxHtmlLi...
Definition: drc_item.cpp:184

References color, Format(), DRC_ITEM_LIST::GetItem(), m_list, m_units, and DRC_ITEM::ShowHtml().

Referenced by OnGetItemMarkup().

◆ OnGetItemMarkup()

wxString DRCLISTBOX::OnGetItemMarkup ( size_t  n) const
inlineoverride

Function OnGetItem returns the html text associated with the given index 'n'.

Parameters
nAn index into the list.
Returns
wxString - the simple html text to show in the listbox.

Definition at line 262 of file dialog_drclistbox.h.

263  {
264  return OnGetItem( n );
265  }
wxString OnGetItem(size_t n) const override
Function OnGetItem returns the html text associated with the DRC_ITEM given by index 'n'.

References OnGetItem().

◆ SetList()

void DRCLISTBOX::SetList ( EDA_UNITS_T  aUnits,
DRC_ITEM_LIST aList 
)
inline

Function SetList sets the DRC_ITEM_LIST for this listbox.

Ownership of the DRC_ITEM_LIST is transfered to this DRCLISTBOX.

Parameters
aListThe DRC_ITEM_LIST* containing the DRC_ITEMs which will be displayed in the wxHtmlListBox

Definition at line 207 of file dialog_drclistbox.h.

208  {
209  delete m_list;
210 
211  m_units = aUnits;
212  m_list = aList;
213  SetItemCount( aList->GetCount() );
214  Refresh();
215  }
void Refresh()
Update the board display after modifying it by a python script (note: it is automatically called by a...
EDA_UNITS_T m_units
DRC_ITEM_LIST * m_list
wxHtmlListBox does not own the list, I do
virtual int GetCount()=0
Function GetCount returns the number of items in the list.

References DRC_ITEM_LIST::GetCount(), m_list, m_units, and Refresh().

Referenced by DIALOG_CLEANUP_TRACKS_AND_VIAS::doCleanup(), and DRC::updatePointers().

Member Data Documentation

◆ m_list

DRC_ITEM_LIST* DRCLISTBOX::m_list
private

wxHtmlListBox does not own the list, I do

Definition at line 181 of file dialog_drclistbox.h.

Referenced by DeleteAllItems(), DeleteItem(), DRCLISTBOX(), GetItem(), OnGetItem(), SetList(), and ~DRCLISTBOX().

◆ m_units

EDA_UNITS_T DRCLISTBOX::m_units
private

Definition at line 180 of file dialog_drclistbox.h.

Referenced by DRCLISTBOX(), OnGetItem(), and SetList().


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