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, const wxSize &aSize, 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 45 of file listboxes.h.

Constructor & Destructor Documentation

◆ ITEMS_LISTBOX_BASE()

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

Definition at line 38 of file listbox_base.cpp.

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

◆ ~ITEMS_LISTBOX_BASE()

ITEMS_LISTBOX_BASE::~ITEMS_LISTBOX_BASE ( )

Definition at line 47 of file listbox_base.cpp.

48 {
49 }

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 106 of file listbox_base.cpp.

107 {
108  for( int i = 0; i < GetItemCount(); i++ )
109  Select( i, false );
110 }
size_t i
Definition: json11.cpp:597

References i.

Referenced by CVPCB_MAINFRAME::SetSelectedComponent().

◆ GetParent()

CVPCB_MAINFRAME * ITEMS_LISTBOX_BASE::GetParent ( ) const
virtual

Definition at line 113 of file listbox_base.cpp.

114 {
115  return (CVPCB_MAINFRAME*) wxListView::GetParent();
116 }
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 99 of file listbox_base.cpp.

100 {
101  return GetFirstSelected();
102 }

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 78 of file listbox_base.cpp.

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

References columnWidth.

Referenced by UpdateWidth().

◆ UpdateWidth()

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

Definition at line 52 of file listbox_base.cpp.

53 {
54  // Less than zero: recalculate width of all items.
55  if( aLine < 0 )
56  {
57  columnWidth = 0;
58  for( int ii = 0; ii < GetItemCount(); ii++ )
59  {
60  UpdateLineWidth( (unsigned)ii );
61  }
62  }
63 
64  // Zero or above: update from a single line.
65  else
66  {
67  if( aLine < GetItemCount() )
68  UpdateLineWidth( (unsigned)aLine );
69  }
70 }
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 80 of file listboxes.h.

Referenced by UpdateLineWidth(), and UpdateWidth().


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