KiCad PCB EDA Suite
FOOTPRINTS_LISTBOX Class Reference

#include <listview_classes.h>

Inheritance diagram for FOOTPRINTS_LISTBOX:
ITEMS_LISTBOX_BASE

Public Types

enum  FP_FILTER_T {
  UNFILTERED_FP_LIST = 0, FILTERING_BY_COMPONENT_KEYWORD = 0x0001, FILTERING_BY_PIN_COUNT = 0x0002, FILTERING_BY_LIBRARY = 0x0004,
  FILTERING_BY_NAME = 0x0008
}
 

Public Member Functions

 FOOTPRINTS_LISTBOX (CVPCB_MAINFRAME *parent, wxWindowID id, const wxPoint &loc, const wxSize &size)
 
 ~FOOTPRINTS_LISTBOX ()
 
int GetCount ()
 
void SetSelection (int index, bool State=true)
 
void SetString (unsigned linecount, const wxString &text)
 
void AppendLine (const wxString &text)
 
void SetFootprints (FOOTPRINT_LIST &aList, const wxString &aLibName, COMPONENT *aComponent, const wxString &aFootPrintFilterPattern, int aFilterType)
 Function SetFootprints populates the wxListCtrl with the footprints from aList that meet the filter criteria defined by aFilterType. More...
 
wxString GetSelectedFootprint ()
 
wxString OnGetItemText (long item, long column) const override
 Function OnGetItemText this overloaded function MUST be provided for the wxLC_VIRTUAL mode because real data is not handled by ITEMS_LISTBOX_BASE. More...
 
void OnLeftClick (wxListEvent &event)
 
void OnLeftDClick (wxListEvent &event)
 
void OnChar (wxKeyEvent &event)
 
int GetSelection ()
 
void DeselectAll ()
 Removes all selection in lists which can have more than one item selected. More...
 
virtual CVPCB_MAINFRAMEGetParent () const
 
void UpdateWidth (int aLine=-1)
 

Private Attributes

wxArrayString m_footprintList
 

Detailed Description

Definition at line 87 of file listview_classes.h.

Member Enumeration Documentation

Enumerator
UNFILTERED_FP_LIST 
FILTERING_BY_COMPONENT_KEYWORD 
FILTERING_BY_PIN_COUNT 
FILTERING_BY_LIBRARY 
FILTERING_BY_NAME 

Definition at line 94 of file listview_classes.h.

Constructor & Destructor Documentation

FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX ( CVPCB_MAINFRAME parent,
wxWindowID  id,
const wxPoint loc,
const wxSize &  size 
)

Definition at line 40 of file class_footprints_listbox.cpp.

42  :
43  ITEMS_LISTBOX_BASE( parent, id, loc, size, wxLC_SINGLE_SEL )
44 {
45 }
ITEMS_LISTBOX_BASE(CVPCB_MAINFRAME *aParent, wxWindowID aId, const wxPoint &aLocation, const wxSize &aSize, long aStyle=0)
Definition: listboxes.cpp:44
FOOTPRINTS_LISTBOX::~FOOTPRINTS_LISTBOX ( )

Definition at line 48 of file class_footprints_listbox.cpp.

49 {
50 }

Member Function Documentation

void FOOTPRINTS_LISTBOX::AppendLine ( const wxString &  text)

Definition at line 89 of file class_footprints_listbox.cpp.

References m_footprintList, and ITEMS_LISTBOX_BASE::UpdateWidth().

90 {
91  m_footprintList.Add( text );
92  int lines = m_footprintList.Count();
93  SetItemCount( lines );
94  UpdateWidth( lines - 1 );
95 }
void UpdateWidth(int aLine=-1)
Definition: listboxes.cpp:58
wxArrayString m_footprintList
void ITEMS_LISTBOX_BASE::DeselectAll ( )
inherited

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

Definition at line 112 of file listboxes.cpp.

Referenced by CVPCB_MAINFRAME::DelAssociations(), CVPCB_MAINFRAME::ToFirstNA(), and CVPCB_MAINFRAME::ToPreviousNA().

113 {
114  for( int i = 0; i < GetItemCount(); i++ )
115  Select( i, false );
116 }
int FOOTPRINTS_LISTBOX::GetCount ( )

Definition at line 53 of file class_footprints_listbox.cpp.

References m_footprintList.

Referenced by CVPCB_MAINFRAME::DisplayStatus(), CVPCB_MAINFRAME::refreshAfterComponentSearch(), and SetSelection().

54 {
55  return m_footprintList.Count();
56 }
wxArrayString m_footprintList
CVPCB_MAINFRAME * ITEMS_LISTBOX_BASE::GetParent ( ) const
virtualinherited

Definition at line 119 of file listboxes.cpp.

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

120 {
121  return (CVPCB_MAINFRAME*) wxListView::GetParent();
122 }
The CvPcb application main window.
wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint ( )

Definition at line 72 of file class_footprints_listbox.cpp.

References m_footprintList.

Referenced by CVPCB_MAINFRAME::GetSelectedFootprint(), and OnLeftDClick().

73 {
74  wxString footprintName;
75  int ii = GetFirstSelected();
76 
77  if( ii >= 0 )
78  {
79  wxString msg = m_footprintList[ii];
80  msg.Trim( true );
81  msg.Trim( false );
82  footprintName = msg.AfterFirst( wxChar( ' ' ) );
83  }
84 
85  return footprintName;
86 }
wxArrayString m_footprintList
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 105 of file listboxes.cpp.

Referenced by CVPCB_MAINFRAME::GetSelectedComponent(), CVPCB_MAINFRAME::refreshAfterComponentSearch(), CVPCB_MAINFRAME::SendMessageToEESCHEMA(), SetFootprints(), and LIBRARY_LISTBOX::SetLibraryList().

106 {
107  return GetFirstSelected();
108 }
void FOOTPRINTS_LISTBOX::OnChar ( wxKeyEvent &  event)

Definition at line 254 of file class_footprints_listbox.cpp.

References CVPCB_MAINFRAME::ChangeFocus(), ITEMS_LISTBOX_BASE::GetParent(), m_footprintList, and SetSelection().

255 {
256  int key = event.GetKeyCode();
257 
258  switch( key )
259  {
260  case WXK_TAB:
261  case WXK_RIGHT:
262  case WXK_NUMPAD_RIGHT:
263  GetParent()->ChangeFocus( true );
264  return;
265 
266  case WXK_LEFT:
267  case WXK_NUMPAD_LEFT:
268  GetParent()->ChangeFocus( false );
269  return;
270 
271  case WXK_HOME:
272  case WXK_END:
273  case WXK_UP:
274  case WXK_DOWN:
275  case WXK_PAGEUP:
276  case WXK_PAGEDOWN:
277  event.Skip();
278  return;
279 
280  default:
281  break;
282  }
283 
284  // Search for an item name starting by the key code:
285  key = toupper( key );
286 
287  for( unsigned ii = 0; ii < m_footprintList.GetCount(); ii++ )
288  {
289  wxString text = m_footprintList.Item( ii );
290 
291  // Search for the start char of the footprint name. Skip the line number.
292  text.Trim( false ); // Remove leading spaces in line
293  unsigned jj = 0;
294 
295  for( ; jj < text.Len(); jj++ )
296  {
297  // skip line number
298  if( text[jj] == ' ' )
299  break;
300  }
301 
302  for( ; jj < text.Len(); jj++ )
303  { // skip blanks
304  if( text[jj] != ' ' )
305  break;
306  }
307 
308  int start_char = toupper( text[jj] );
309 
310  if( key == start_char )
311  {
312  SetSelection( ii, true ); // Ensure visible
313  break;
314  }
315  }
316 
317  event.Skip();
318 }
void ChangeFocus(bool aMoveRight)
wxArrayString m_footprintList
void SetSelection(int index, bool State=true)
virtual CVPCB_MAINFRAME * GetParent() const
Definition: listboxes.cpp:119
wxString FOOTPRINTS_LISTBOX::OnGetItemText ( long  item,
long  column 
) const
override

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

Definition at line 98 of file class_footprints_listbox.cpp.

References m_footprintList.

Referenced by CVPCB_MAINFRAME::refreshAfterComponentSearch().

99 {
100  if( item < 0 || item >= (long)m_footprintList.GetCount() )
101  return wxEmptyString;
102 
103  return m_footprintList.Item( item );
104 }
wxArrayString m_footprintList
void FOOTPRINTS_LISTBOX::OnLeftClick ( wxListEvent &  event)

Definition at line 224 of file class_footprints_listbox.cpp.

225 {
226  if( m_footprintList.IsEmpty() )
227  return;
228 
229  // On some plateforms (OSX) the focus is lost when the viewers (fp and 3D viewers)
230  // are opened and refreshed when a new footprint is selected.
231  // If the listbox has the focus before selecting a new footprint, it will be forced
232  // after selection.
233  bool hasFocus = HasFocus();
234 
235  // If the footprint view window is displayed, update the footprint.
236  if( GetParent()->GetFootprintViewerFrame() )
238 
240 
241  if( hasFocus )
242  SetFocus();
243 }
void CreateScreenCmp()
Create or Update the frame showing the current highlighted footprint and (if showed) the 3D display f...
wxArrayString m_footprintList
virtual CVPCB_MAINFRAME * GetParent() const
Definition: listboxes.cpp:119
void DisplayStatus()
Function DisplayStatus updates the information displayed on the status bar at bottom of the main fram...
void FOOTPRINTS_LISTBOX::OnLeftDClick ( wxListEvent &  event)

Definition at line 246 of file class_footprints_listbox.cpp.

References ITEMS_LISTBOX_BASE::GetParent(), GetSelectedFootprint(), and CVPCB_MAINFRAME::SetNewPkg().

247 {
248  wxString footprintName = GetSelectedFootprint();
249 
250  GetParent()->SetNewPkg( footprintName );
251 }
void SetNewPkg(const wxString &aFootprintName)
Function SetNewPkg links the footprint to the current selected component and selects the next compone...
virtual CVPCB_MAINFRAME * GetParent() const
Definition: listboxes.cpp:119
void FOOTPRINTS_LISTBOX::SetFootprints ( FOOTPRINT_LIST aList,
const wxString &  aLibName,
COMPONENT aComponent,
const wxString &  aFootPrintFilterPattern,
int  aFilterType 
)

Function SetFootprints populates the wxListCtrl with the footprints from aList that meet the filter criteria defined by aFilterType.

Parameters
aListis a FOOTPRINT_LIST item containing the footprints.
aLibNameis wxString containing the name of the selected library. Can be wxEmptyString.
aComponentis the COMPONENT used by the filtering criteria. Can be NULL.
aFootPrintFilterPattern= a filter used to filter list by names
aFilterTypedefines the criteria to filter aList.

Definition at line 127 of file class_footprints_listbox.cpp.

References EDA_PATTERN_NOT_FOUND, FILTERING_BY_COMPONENT_KEYWORD, FILTERING_BY_LIBRARY, FILTERING_BY_NAME, FILTERING_BY_PIN_COUNT, EDA_PATTERN_MATCH_WILDCARD::Find(), GetChars(), FOOTPRINT_LIST::GetCount(), FOOTPRINT_INFO::GetFootprintName(), FOOTPRINT_LIST::GetItem(), COMPONENT::GetNetCount(), FOOTPRINT_INFO::GetNickname(), ITEMS_LISTBOX_BASE::GetSelection(), FOOTPRINT_INFO::GetUniquePadCount(), FOOTPRINT_INFO::InLibrary(), m_footprintList, COMPONENT::MatchesFootprintFilters(), EDA_PATTERN_MATCH_WILDCARD::SetPattern(), SetSelection(), UNFILTERED_FP_LIST, and ITEMS_LISTBOX_BASE::UpdateWidth().

Referenced by CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX(), and CVPCB_MAINFRAME::OnSelectComponent().

131 {
132  wxArrayString newList;
133  wxString msg;
134  wxString oldSelection;
135 
136  EDA_PATTERN_MATCH_WILDCARD patternFilter;
137  patternFilter.SetPattern( aFootPrintFilterPattern.Lower() ); // Use case insensitive search
138 
139  if( GetSelection() >= 0 && GetSelection() < (int)m_footprintList.GetCount() )
140  oldSelection = m_footprintList[ GetSelection() ];
141 
142  for( unsigned ii = 0; ii < aList.GetCount(); ii++ )
143  {
144  if( aFilterType == UNFILTERED_FP_LIST )
145  {
146  msg.Printf( wxT( "%3d %s:%s" ), int( newList.GetCount() + 1 ),
147  GetChars( aList.GetItem( ii ).GetNickname() ),
148  GetChars( aList.GetItem( ii ).GetFootprintName() ) );
149  newList.Add( msg );
150  continue;
151  }
152 
153  // Filter footprints by selected library
154  if( (aFilterType & FILTERING_BY_LIBRARY) && !aLibName.IsEmpty()
155  && !aList.GetItem( ii ).InLibrary( aLibName ) )
156  continue;
157 
158  // Filter footprints by symbol fp-filters
159  if( (aFilterType & FILTERING_BY_COMPONENT_KEYWORD) && aComponent
160  && !aComponent->MatchesFootprintFilters( aList.GetItem( ii ).GetNickname(), aList.GetItem( ii ).GetFootprintName() ) )
161  continue;
162 
163  // Filter footprints by symbol pin-count
164  if( (aFilterType & FILTERING_BY_PIN_COUNT) && aComponent
165  && aComponent->GetNetCount() != aList.GetItem( ii ).GetUniquePadCount() )
166  continue;
167 
168  // Filter footprints by text-input
169  if( (aFilterType & FILTERING_BY_NAME ) && !aFootPrintFilterPattern.IsEmpty() )
170  {
171  wxString currname = "";
172 
173  // If the search string contains a ':' character,
174  // include the library name in the search string
175  // e.g. LibName:FootprintName
176  if( aFootPrintFilterPattern.Contains( ":" ) )
177  {
178  currname = aList.GetItem( ii ).GetNickname().Lower() + ":";
179  }
180 
181  currname += aList.GetItem( ii ).GetFootprintName().Lower();
182 
183  if( patternFilter.Find( currname ) == EDA_PATTERN_NOT_FOUND )
184  {
185  continue;
186  }
187  }
188 
189  msg.Printf( wxT( "%3d %s:%s" ), int( newList.GetCount() + 1 ),
190  GetChars( aList.GetItem( ii ).GetNickname() ),
191  GetChars( aList.GetItem( ii ).GetFootprintName() ) );
192  newList.Add( msg );
193  }
194 
195  if( newList == m_footprintList )
196  return;
197 
198  m_footprintList = newList;
199 
200  int selection = m_footprintList.Index( oldSelection );
201 
202  if( selection == wxNOT_FOUND )
203  selection = 0;
204 
205  DeleteAllItems();
206 
207  if( m_footprintList.GetCount() )
208  {
209  SetItemCount( m_footprintList.GetCount() );
210  SetSelection( selection, true );
211  RefreshItems( 0L, m_footprintList.GetCount()-1 );
212  UpdateWidth();
213  }
214 }
const wxString & GetFootprintName() const
virtual bool SetPattern(const wxString &aPattern) override
Set the pattern against which candidates will be matched.
unsigned GetCount() const
Function GetCount.
FOOTPRINT_INFO & GetItem(unsigned aIdx)
Function GetItem.
void UpdateWidth(int aLine=-1)
Definition: listboxes.cpp:58
bool InLibrary(const wxString &aLibrary) const
Function InLibrary tests if the FOOTPRINT_INFO object was loaded from aLibrary.
wxArrayString m_footprintList
bool MatchesFootprintFilters(const wxString &aLibraryName, const wxString &aFootprintName) const
Function MatchesFootprintFilters.
Definition: pcb_netlist.cpp:76
static const int EDA_PATTERN_NOT_FOUND
void SetSelection(int index, bool State=true)
static const wxChar * GetChars(const wxString &s)
Function GetChars returns a wxChar* to the actual wxChar* data within a wxString, and is helpful for ...
Definition: macros.h:92
unsigned GetUniquePadCount()
virtual int Find(const wxString &aCandidate) const override
Return the location of a match iff a given candidate string matches the set pattern.
const wxString & GetNickname() const
unsigned GetNetCount() const
Definition: pcb_netlist.h:135
void FOOTPRINTS_LISTBOX::SetSelection ( int  index,
bool  State = true 
)

Definition at line 107 of file class_footprints_listbox.cpp.

References GetCount(), and Refresh().

Referenced by OnChar(), CVPCB_MAINFRAME::refreshAfterComponentSearch(), and SetFootprints().

108 {
109  if( index >= GetCount() )
110  index = GetCount() - 1;
111 
112  if( (index >= 0) && (GetCount() > 0) )
113  {
114 #ifndef __WXMAC__
115  Select( index, State );
116 #endif
117 
118  EnsureVisible( index );
119 
120 #ifdef __WXMAC__
121  Refresh();
122 #endif
123  }
124 }
void Refresh()
void FOOTPRINTS_LISTBOX::SetString ( unsigned  linecount,
const wxString &  text 
)

Definition at line 59 of file class_footprints_listbox.cpp.

References m_footprintList, and ITEMS_LISTBOX_BASE::UpdateWidth().

60 {
61  unsigned count = m_footprintList.Count();
62  if( count > 0 )
63  {
64  if( linecount >= count )
65  linecount = count - 1;
66  m_footprintList[linecount] = text;
67  }
68  UpdateWidth( linecount );
69 }
void UpdateWidth(int aLine=-1)
Definition: listboxes.cpp:58
wxArrayString m_footprintList
void ITEMS_LISTBOX_BASE::UpdateWidth ( int  aLine = -1)
inherited

Definition at line 58 of file listboxes.cpp.

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

Referenced by AppendLine(), LIBRARY_LISTBOX::AppendLine(), COMPONENTS_LISTBOX::AppendLine(), CVPCB_MAINFRAME::BuildCmpListBox(), SetFootprints(), LIBRARY_LISTBOX::SetLibraryList(), SetString(), LIBRARY_LISTBOX::SetString(), and COMPONENTS_LISTBOX::SetString().

59 {
60  // Less than zero: recalculate width of all items.
61  if( aLine < 0 )
62  {
63  columnWidth = 0;
64  for( int ii = 0; ii < GetItemCount(); ii++ )
65  {
66  UpdateLineWidth( (unsigned)ii );
67  }
68  }
69 
70  // Zero or above: update from a single line.
71  else
72  {
73  if( aLine < GetItemCount() )
74  UpdateLineWidth( (unsigned)aLine );
75  }
76 }
void UpdateLineWidth(unsigned aLine)
Definition: listboxes.cpp:84

Member Data Documentation

wxArrayString FOOTPRINTS_LISTBOX::m_footprintList
private

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