KiCad PCB EDA Suite
FOOTPRINTS_LISTBOX Class Reference

#include <listboxes.h>

Inheritance diagram for FOOTPRINTS_LISTBOX:
ITEMS_LISTBOX_BASE

Public Types

enum  FP_FILTER_T : int {
  UNFILTERED_FP_LIST = 0, FILTERING_BY_COMPONENT_KEYWORD = 0x0001, FILTERING_BY_PIN_COUNT = 0x0002, FILTERING_BY_LIBRARY = 0x0004,
  FILTERING_BY_NAME = 0x0008
}
 Filter setting constants. More...
 

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 listboxes.h.

Member Enumeration Documentation

Filter setting constants.

The filter type is a bitwise OR of these flags, and only footprints matching all selected filter types are shown.

Enumerator
UNFILTERED_FP_LIST 
FILTERING_BY_COMPONENT_KEYWORD 
FILTERING_BY_PIN_COUNT 
FILTERING_BY_LIBRARY 
FILTERING_BY_NAME 

Definition at line 98 of file listboxes.h.

Constructor & Destructor Documentation

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

Definition at line 41 of file footprints_listbox.cpp.

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

Definition at line 49 of file footprints_listbox.cpp.

50 {
51 }

Member Function Documentation

void FOOTPRINTS_LISTBOX::AppendLine ( const wxString &  text)

Definition at line 90 of file footprints_listbox.cpp.

References m_footprintList, and ITEMS_LISTBOX_BASE::UpdateWidth().

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

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

Definition at line 111 of file listbox_base.cpp.

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

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

Definition at line 54 of file footprints_listbox.cpp.

References m_footprintList.

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

55 {
56  return m_footprintList.Count();
57 }
wxArrayString m_footprintList
Definition: listboxes.h:90
CVPCB_MAINFRAME * ITEMS_LISTBOX_BASE::GetParent ( ) const
virtualinherited

Definition at line 118 of file listbox_base.cpp.

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

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

Definition at line 73 of file footprints_listbox.cpp.

References m_footprintList.

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

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

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

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

Definition at line 222 of file footprints_listbox.cpp.

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

Referenced by SetFootprints().

223 {
224  int key = event.GetKeyCode();
225 
226  switch( key )
227  {
228  case WXK_TAB:
229  case WXK_RIGHT:
230  case WXK_NUMPAD_RIGHT:
231  GetParent()->ChangeFocus( true );
232  return;
233 
234  case WXK_LEFT:
235  case WXK_NUMPAD_LEFT:
236  GetParent()->ChangeFocus( false );
237  return;
238 
239  case WXK_HOME:
240  case WXK_END:
241  case WXK_UP:
242  case WXK_DOWN:
243  case WXK_PAGEUP:
244  case WXK_PAGEDOWN:
245  event.Skip();
246  return;
247 
248  default:
249  break;
250  }
251 
252  // Search for an item name starting by the key code:
253  key = toupper( key );
254 
255  for( unsigned ii = 0; ii < m_footprintList.GetCount(); ii++ )
256  {
257  wxString text = m_footprintList.Item( ii );
258 
259  // Search for the start char of the footprint name. Skip the line number.
260  text.Trim( false ); // Remove leading spaces in line
261  unsigned jj = 0;
262 
263  for( ; jj < text.Len(); jj++ )
264  {
265  // skip line number
266  if( text[jj] == ' ' )
267  break;
268  }
269 
270  for( ; jj < text.Len(); jj++ )
271  { // skip blanks
272  if( text[jj] != ' ' )
273  break;
274  }
275 
276  int start_char = toupper( text[jj] );
277 
278  if( key == start_char )
279  {
280  SetSelection( ii, true ); // Ensure visible
281  break;
282  }
283  }
284 
285  event.Skip();
286 }
void ChangeFocus(bool aMoveRight)
wxArrayString m_footprintList
Definition: listboxes.h:90
void SetSelection(int index, bool State=true)
virtual CVPCB_MAINFRAME * GetParent() const
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 99 of file footprints_listbox.cpp.

References m_footprintList.

Referenced by CVPCB_MAINFRAME::refreshAfterComponentSearch().

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

Definition at line 192 of file footprints_listbox.cpp.

References CVPCB_MAINFRAME::CreateScreenCmp(), CVPCB_MAINFRAME::DisplayStatus(), ITEMS_LISTBOX_BASE::GetParent(), and m_footprintList.

Referenced by SetFootprints().

193 {
194  if( m_footprintList.IsEmpty() )
195  return;
196 
197  // On some plateforms (OSX) the focus is lost when the viewers (fp and 3D viewers)
198  // are opened and refreshed when a new footprint is selected.
199  // If the listbox has the focus before selecting a new footprint, it will be forced
200  // after selection.
201  bool hasFocus = HasFocus();
202 
203  // If the footprint view window is displayed, update the footprint.
204  if( GetParent()->GetFootprintViewerFrame() )
206 
208 
209  if( hasFocus )
210  SetFocus();
211 }
void CreateScreenCmp()
Create or Update the frame showing the current highlighted footprint and (if showed) the 3D display f...
wxArrayString m_footprintList
Definition: listboxes.h:90
virtual CVPCB_MAINFRAME * GetParent() const
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 214 of file footprints_listbox.cpp.

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

Referenced by SetFootprints().

215 {
216  wxString footprintName = GetSelectedFootprint();
217 
218  GetParent()->SetNewPkg( footprintName );
219 }
void SetNewPkg(const wxString &aFootprintName)
Function SetNewPkg set the footprint name for all selected components in component list and selects t...
virtual CVPCB_MAINFRAME * GetParent() const
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 128 of file footprints_listbox.cpp.

References FOOTPRINT_FILTER::FilterByFootprintFilters(), FOOTPRINT_FILTER::FilterByLibrary(), FOOTPRINT_FILTER::FilterByPattern(), FOOTPRINT_FILTER::FilterByPinCount(), FILTERING_BY_COMPONENT_KEYWORD, FILTERING_BY_LIBRARY, FILTERING_BY_NAME, FILTERING_BY_PIN_COUNT, GetChars(), COMPONENT::GetFootprintFilters(), COMPONENT::GetNetCount(), ITEMS_LISTBOX_BASE::GetSelection(), ID_CVPCB_FOOTPRINT_LIST, m_footprintList, OnChar(), OnLeftClick(), OnLeftDClick(), SetSelection(), and ITEMS_LISTBOX_BASE::UpdateWidth().

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

132 {
133  wxArrayString newList;
134  wxString msg;
135  wxString oldSelection;
136 
137  FOOTPRINT_FILTER filter( aList );
138 
139  if( aFilterType & FILTERING_BY_COMPONENT_KEYWORD && aComponent )
140  filter.FilterByFootprintFilters( aComponent->GetFootprintFilters() );
141 
142  if( aFilterType & FILTERING_BY_PIN_COUNT && aComponent )
143  filter.FilterByPinCount( aComponent->GetNetCount() );
144 
145  if( aFilterType & FILTERING_BY_LIBRARY )
146  filter.FilterByLibrary( aLibName );
147 
148  if( aFilterType & FILTERING_BY_NAME )
149  filter.FilterByPattern( aFootPrintFilterPattern );
150 
151  if( GetSelection() >= 0 && GetSelection() < (int)m_footprintList.GetCount() )
152  oldSelection = m_footprintList[ GetSelection() ];
153 
154  for( auto& i: filter )
155  {
156  msg.Printf( "%3d %s:%s", int( newList.GetCount() + 1 ),
157  GetChars( i.GetNickname() ),
158  GetChars( i.GetFootprintName() ) );
159  newList.Add( msg );
160  }
161 
162  if( newList == m_footprintList )
163  return;
164 
165  m_footprintList = newList;
166 
167  int selection = m_footprintList.Index( oldSelection );
168 
169  if( selection == wxNOT_FOUND )
170  selection = 0;
171 
172  wxWindowUpdateLocker freeze( this );
173  DeleteAllItems();
174 
175  if( m_footprintList.GetCount() )
176  {
177  SetItemCount( m_footprintList.GetCount() );
178  SetSelection( selection, true );
179  RefreshItems( 0L, m_footprintList.GetCount()-1 );
180  UpdateWidth();
181  }
182 }
const wxArrayString & GetFootprintFilters() const
Definition: pcb_netlist.h:175
void UpdateWidth(int aLine=-1)
wxArrayString m_footprintList
Definition: listboxes.h:90
Footprint display filter.
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 GetNetCount() const
Definition: pcb_netlist.h:135
void FOOTPRINTS_LISTBOX::SetSelection ( int  index,
bool  State = true 
)

Definition at line 108 of file footprints_listbox.cpp.

References GetCount(), and Refresh().

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

109 {
110  if( index >= GetCount() )
111  index = GetCount() - 1;
112 
113  if( (index >= 0) && (GetCount() > 0) )
114  {
115 #ifndef __WXMAC__
116  Select( index, State );
117 #endif
118 
119  EnsureVisible( index );
120 
121 #ifdef __WXMAC__
122  Refresh();
123 #endif
124  }
125 }
void Refresh()
Update the board display after modifying it bu a python script (note: it is automatically called by a...
void FOOTPRINTS_LISTBOX::SetString ( unsigned  linecount,
const wxString &  text 
)

Definition at line 60 of file footprints_listbox.cpp.

References m_footprintList, and ITEMS_LISTBOX_BASE::UpdateWidth().

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

Definition at line 57 of file listbox_base.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().

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

Member Data Documentation

wxArrayString FOOTPRINTS_LISTBOX::m_footprintList
private

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