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 : 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 listview_classes.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 listview_classes.h.

Constructor & Destructor Documentation

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

Definition at line 42 of file class_footprints_listbox.cpp.

44  :
45  ITEMS_LISTBOX_BASE( parent, id, loc, size, wxLC_SINGLE_SEL )
46 {
47 }
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 50 of file class_footprints_listbox.cpp.

51 {
52 }

Member Function Documentation

void FOOTPRINTS_LISTBOX::AppendLine ( const wxString &  text)

Definition at line 91 of file class_footprints_listbox.cpp.

References m_footprintList, and ITEMS_LISTBOX_BASE::UpdateWidth().

92 {
93  m_footprintList.Add( text );
94  int lines = m_footprintList.Count();
95  SetItemCount( lines );
96  UpdateWidth( lines - 1 );
97 }
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 55 of file class_footprints_listbox.cpp.

References m_footprintList.

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

56 {
57  return m_footprintList.Count();
58 }
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 74 of file class_footprints_listbox.cpp.

References m_footprintList.

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

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

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

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

References m_footprintList.

Referenced by CVPCB_MAINFRAME::refreshAfterComponentSearch().

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

Definition at line 193 of file class_footprints_listbox.cpp.

194 {
195  if( m_footprintList.IsEmpty() )
196  return;
197 
198  // On some plateforms (OSX) the focus is lost when the viewers (fp and 3D viewers)
199  // are opened and refreshed when a new footprint is selected.
200  // If the listbox has the focus before selecting a new footprint, it will be forced
201  // after selection.
202  bool hasFocus = HasFocus();
203 
204  // If the footprint view window is displayed, update the footprint.
205  if( GetParent()->GetFootprintViewerFrame() )
207 
209 
210  if( hasFocus )
211  SetFocus();
212 }
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 215 of file class_footprints_listbox.cpp.

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

216 {
217  wxString footprintName = GetSelectedFootprint();
218 
219  GetParent()->SetNewPkg( footprintName );
220 }
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
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 129 of file class_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(), m_footprintList, SetSelection(), and ITEMS_LISTBOX_BASE::UpdateWidth().

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

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

References GetCount(), and Refresh().

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

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

Definition at line 61 of file class_footprints_listbox.cpp.

References m_footprintList, and ITEMS_LISTBOX_BASE::UpdateWidth().

62 {
63  unsigned count = m_footprintList.Count();
64  if( count > 0 )
65  {
66  if( linecount >= count )
67  linecount = count - 1;
68  m_footprintList[linecount] = text;
69  }
70  UpdateWidth( linecount );
71 }
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: