KiCad PCB EDA Suite
SYMBOLS_LISTBOX Class Reference

#include <listboxes.h>

Inheritance diagram for SYMBOLS_LISTBOX:
ITEMS_LISTBOX_BASE

Public Member Functions

 SYMBOLS_LISTBOX (CVPCB_MAINFRAME *parent, wxWindowID id)
 
 ~SYMBOLS_LISTBOX ()
 
void Clear ()
 
int GetCount ()
 
wxString OnGetItemText (long item, long column) const override
 This overloaded function MUST be provided for the wxLC_VIRTUAL mode because real data is not handled by ITEMS_LISTBOX_BASE. More...
 
void SetSelection (int index, bool State=true)
 
void SetString (unsigned linecount, const wxString &text)
 
void AppendLine (const wxString &text)
 
void OnChar (wxKeyEvent &event)
 Called on a key press. More...
 
void OnSelectComponent (wxListEvent &event)
 
 DECLARE_EVENT_TABLE ()
 
int GetSelection ()
 
void DeselectAll ()
 Remove all selection in lists which can have more than one item selected. More...
 
virtual CVPCB_MAINFRAMEGetParent () const
 
void UpdateWidth (int aLine=-1)
 Update the width of the column based on its contents. More...
 

Public Attributes

wxArrayString m_SymbolList
 

Detailed Description

Definition at line 179 of file listboxes.h.

Constructor & Destructor Documentation

◆ SYMBOLS_LISTBOX()

SYMBOLS_LISTBOX::SYMBOLS_LISTBOX ( CVPCB_MAINFRAME parent,
wxWindowID  id 
)

Definition at line 36 of file symbols_listbox.cpp.

36  :
37  ITEMS_LISTBOX_BASE( parent, id )
38 {
39 }
ITEMS_LISTBOX_BASE(CVPCB_MAINFRAME *aParent, wxWindowID aId, const wxPoint &aLocation=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=0)

◆ ~SYMBOLS_LISTBOX()

SYMBOLS_LISTBOX::~SYMBOLS_LISTBOX ( )

Definition at line 42 of file symbols_listbox.cpp.

43 {
44 }

Member Function Documentation

◆ AppendLine()

void SYMBOLS_LISTBOX::AppendLine ( const wxString &  text)

Definition at line 79 of file symbols_listbox.cpp.

80 {
81  m_SymbolList.Add( text );
82  int lines = m_SymbolList.Count();
83  SetItemCount( lines );
84  UpdateWidth( lines - 1 );
85 }
void UpdateWidth(int aLine=-1)
Update the width of the column based on its contents.
wxArrayString m_SymbolList
Definition: listboxes.h:222

References m_SymbolList, text, and ITEMS_LISTBOX_BASE::UpdateWidth().

Referenced by CVPCB_MAINFRAME::ReadNetListAndFpFiles().

◆ Clear()

void SYMBOLS_LISTBOX::Clear ( )

Definition at line 53 of file symbols_listbox.cpp.

54 {
55  m_SymbolList.Clear();
56  SetItemCount( 0 );
57 }
wxArrayString m_SymbolList
Definition: listboxes.h:222

References Clear().

Referenced by Clear(), and CVPCB_MAINFRAME::ReadNetListAndFpFiles().

◆ DECLARE_EVENT_TABLE()

SYMBOLS_LISTBOX::DECLARE_EVENT_TABLE ( )

◆ DeselectAll()

void ITEMS_LISTBOX_BASE::DeselectAll ( )
inherited

Remove all selection in lists which can have more than one item selected.

Definition at line 94 of file listbox_base.cpp.

95 {
96  for( int i = 0; i < GetItemCount(); i++ )
97  Select( i, false );
98 }

Referenced by FOOTPRINTS_LISTBOX::SetFootprints(), and CVPCB_MAINFRAME::SetSelectedComponent().

◆ GetCount()

int SYMBOLS_LISTBOX::GetCount ( )

◆ GetParent()

CVPCB_MAINFRAME * ITEMS_LISTBOX_BASE::GetParent ( void  ) const
virtualinherited

Definition at line 101 of file listbox_base.cpp.

102 {
103  return (CVPCB_MAINFRAME*) wxListView::GetParent();
104 }
The CvPcb application main window.

Referenced by FOOTPRINTS_LISTBOX::OnLeftDClick(), OnSelectComponent(), and LIBRARY_LISTBOX::OnSelectLibrary().

◆ GetSelection()

int ITEMS_LISTBOX_BASE::GetSelection ( )
inherited
Returns
the index of the selected item in lists allowing only one item selected and the index of the first selected item in lists allowing many selection

Definition at line 88 of file listbox_base.cpp.

89 {
90  return GetFirstSelected();
91 }

Referenced by CVPCB_MAINFRAME::GetSelectedComponent(), CVPCB_MAINFRAME::OnSelectComponent(), CVPCB_MAINFRAME::refreshAfterSymbolSearch(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), FOOTPRINTS_LISTBOX::SetFootprints(), and LIBRARY_LISTBOX::SetLibraryList().

◆ OnChar()

void SYMBOLS_LISTBOX::OnChar ( wxKeyEvent &  event)

Called on a key press.

Call default handler for some special keys, and for "ASCII" keys, select the first component that the name starts by the letter.

This is the default behavior of a listbox, but because we use virtual lists, the listbox does not know anything to what is displayed, we must handle this behavior here. Furthermore the reference of components is not at the beginning of displayed lines (the first word is the line number).

Definition at line 111 of file symbols_listbox.cpp.

112 {
113  wxLogTrace( kicadTraceKeyEvent, "SYMBOLS_LISTBOX::OnChar %s", dump( event ) );
114 
115  int key = event.GetKeyCode();
116 
117  switch( key )
118  {
119  case WXK_HOME:
120  case WXK_END:
121  case WXK_UP:
122  case WXK_DOWN:
123  case WXK_PAGEUP:
124  case WXK_PAGEDOWN:
125  event.Skip();
126  return;
127 
128 
129  default:
130  break;
131  }
132 
133  // Search for an item name starting by the key code:
134  key = toupper( key );
135 
136  for( unsigned ii = 0; ii < m_SymbolList.GetCount(); ii++ )
137  {
138  wxString text = m_SymbolList.Item( ii );
139 
140  // Search for the start char of the footprint name. Skip the line number.
141  text.Trim( false ); // Remove leading spaces in line
142  unsigned jj = 0;
143 
144  for( ; jj < text.Len(); jj++ )
145  { // skip line number
146  if( text[jj] == ' ' )
147  break;
148  }
149 
150  for( ; jj < text.Len(); jj++ )
151  { // skip blanks
152  if( text[jj] != ' ' )
153  break;
154  }
155 
156  int start_char = toupper( text[jj] );
157 
158  if( key == start_char )
159  {
160  SetSelection( (int) ii, true ); // Ensure visible
161  break;
162  }
163  }
164 
165  event.Skip();
166 }
void SetSelection(int index, bool State=true)
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
wxArrayString m_SymbolList
Definition: listboxes.h:222
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.

References dump(), kicadTraceKeyEvent, m_SymbolList, SetSelection(), and text.

◆ OnGetItemText()

wxString SYMBOLS_LISTBOX::OnGetItemText ( long  item,
long  column 
) const
override

This overloaded function MUST be provided for the wxLC_VIRTUAL mode because real data is not handled by ITEMS_LISTBOX_BASE.

Definition at line 88 of file symbols_listbox.cpp.

89 {
90  return m_SymbolList.Item( item );
91 }
wxArrayString m_SymbolList
Definition: listboxes.h:222

References m_SymbolList.

◆ OnSelectComponent()

void SYMBOLS_LISTBOX::OnSelectComponent ( wxListEvent &  event)

Definition at line 169 of file symbols_listbox.cpp.

170 {
171  SetFocus();
172  GetParent()->OnSelectComponent( event );
173 }
void OnSelectComponent(wxListEvent &event)
Called when clicking on a component in component list window:
virtual CVPCB_MAINFRAME * GetParent() const

References ITEMS_LISTBOX_BASE::GetParent(), and CVPCB_MAINFRAME::OnSelectComponent().

◆ SetSelection()

void SYMBOLS_LISTBOX::SetSelection ( int  index,
bool  State = true 
)

Definition at line 94 of file symbols_listbox.cpp.

95 {
96  if( index >= GetCount() )
97  index = GetCount() - 1;
98 
99  if( (index >= 0) && (GetCount() > 0) )
100  {
101  Select( index, State );
102  EnsureVisible( index );
103 
104 #ifdef __WXMAC__
105  Update();
106 #endif
107  }
108 }

References GetCount().

Referenced by CVPCB_MAINFRAME::BuildSymbolsListBox(), OnChar(), CVPCB_MAINFRAME::ReadNetListAndFpFiles(), and CVPCB_MAINFRAME::SetSelectedComponent().

◆ SetString()

void SYMBOLS_LISTBOX::SetString ( unsigned  linecount,
const wxString &  text 
)

Definition at line 66 of file symbols_listbox.cpp.

67 {
68  if( linecount >= m_SymbolList.Count() )
69  linecount = m_SymbolList.Count() - 1;
70 
71  if( m_SymbolList.Count() > 0 )
72  {
73  m_SymbolList[linecount] = text;
74  UpdateWidth( linecount );
75  }
76 }
void UpdateWidth(int aLine=-1)
Update the width of the column based on its contents.
wxArrayString m_SymbolList
Definition: listboxes.h:222

References m_SymbolList, text, and ITEMS_LISTBOX_BASE::UpdateWidth().

Referenced by CVPCB_MAINFRAME::AssociateFootprint().

◆ UpdateWidth()

void ITEMS_LISTBOX_BASE::UpdateWidth ( int  aLine = -1)
inherited

Update the width of the column based on its contents.

Parameters
aLineis the line to calculate the width from. If positive, the width will only be increased if needed. If negative, we start from scratch and all lines are considered, i.e., the column may be shrunk.

Definition at line 49 of file listbox_base.cpp.

50 {
51  // Less than zero: recalculate width of all items.
52  if( aLine < 0 )
53  {
54  columnWidth = 0;
55  for( int ii = 0; ii < GetItemCount(); ii++ )
56  {
57  UpdateLineWidth( (unsigned)ii );
58  }
59  }
60 
61  // Zero or above: update from a single line.
62  else
63  {
64  if( aLine < GetItemCount() )
65  UpdateLineWidth( (unsigned)aLine );
66  }
67 }
void UpdateLineWidth(unsigned aLine)
Calculate the width of the given line, and increase the column width if needed.

References ITEMS_LISTBOX_BASE::columnWidth, and ITEMS_LISTBOX_BASE::UpdateLineWidth().

Referenced by FOOTPRINTS_LISTBOX::AppendLine(), LIBRARY_LISTBOX::AppendLine(), AppendLine(), CVPCB_MAINFRAME::BuildSymbolsListBox(), FOOTPRINTS_LISTBOX::SetFootprints(), LIBRARY_LISTBOX::SetLibraryList(), FOOTPRINTS_LISTBOX::SetString(), LIBRARY_LISTBOX::SetString(), and SetString().

Member Data Documentation

◆ m_SymbolList

wxArrayString SYMBOLS_LISTBOX::m_SymbolList

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