KiCad PCB EDA Suite
ITEMS_LISTBOX_BASE Class Reference

#include <listboxes.h>

Inheritance diagram for ITEMS_LISTBOX_BASE:
COMPONENTS_LISTBOX FOOTPRINTS_LISTBOX LIBRARY_LISTBOX

Public Member Functions

 ITEMS_LISTBOX_BASE (CVPCB_MAINFRAME *aParent, wxWindowID aId, const wxPoint &aLocation=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=0)
 
 ~ITEMS_LISTBOX_BASE ()
 
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 Member Functions

void UpdateLineWidth (unsigned aLine)
 

Private Attributes

int columnWidth
 

Detailed Description

Definition at line 41 of file listboxes.h.

Constructor & Destructor Documentation

◆ ITEMS_LISTBOX_BASE()

ITEMS_LISTBOX_BASE::ITEMS_LISTBOX_BASE ( CVPCB_MAINFRAME aParent,
wxWindowID  aId,
const wxPoint aLocation = wxDefaultPosition,
const wxSize &  aSize = wxDefaultSize,
long  aStyle = 0 
)

Definition at line 38 of file listbox_base.cpp.

40  :
41  wxListView( aParent, aId, aLocation, aSize, LISTBOX_STYLE | aStyle ),
42  columnWidth( 0 )
43 {
44  InsertColumn( 0, wxEmptyString );
45 }
#define LISTBOX_STYLE
Definition: listboxes.h:35

◆ ~ITEMS_LISTBOX_BASE()

ITEMS_LISTBOX_BASE::~ITEMS_LISTBOX_BASE ( )

Definition at line 48 of file listbox_base.cpp.

49 {
50 }

Member Function Documentation

◆ DeselectAll()

void ITEMS_LISTBOX_BASE::DeselectAll ( )

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

Definition at line 107 of file listbox_base.cpp.

108 {
109  for( int i = 0; i < GetItemCount(); i++ )
110  Select( i, false );
111 }

Referenced by CVPCB_MAINFRAME::SetSelectedComponent().

◆ GetParent()

CVPCB_MAINFRAME * ITEMS_LISTBOX_BASE::GetParent ( void  ) const
virtual

Definition at line 114 of file listbox_base.cpp.

115 {
116  return (CVPCB_MAINFRAME*) wxListView::GetParent();
117 }
The CvPcb application main window.

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

◆ GetSelection()

int ITEMS_LISTBOX_BASE::GetSelection ( )
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 100 of file listbox_base.cpp.

101 {
102  return GetFirstSelected();
103 }

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

◆ UpdateLineWidth()

void ITEMS_LISTBOX_BASE::UpdateLineWidth ( unsigned  aLine)
private

Definition at line 79 of file listbox_base.cpp.

80 {
81  wxClientDC dc( this );
82  wxCoord w;
83  int newWidth = 10; // Value of AUTOSIZE_COL_MARGIN from wxWidgets source.
84 
85  dc.SetFont( GetFont() );
86  dc.GetTextExtent( GetItemText( aLine, 0 ) + " ", &w, NULL );
87  newWidth += w;
88 
89  if( newWidth > columnWidth )
90  {
91  columnWidth = newWidth;
92  SetColumnWidth( 0, columnWidth );
93  }
94 }
#define NULL

References columnWidth, and NULL.

Referenced by UpdateWidth().

◆ UpdateWidth()

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

Definition at line 53 of file listbox_base.cpp.

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

References columnWidth, and UpdateLineWidth().

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

Member Data Documentation

◆ columnWidth

int ITEMS_LISTBOX_BASE::columnWidth
private

Definition at line 76 of file listboxes.h.

Referenced by UpdateLineWidth(), and UpdateWidth().


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