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 ( CVPCB_MAINFRAME aParent,
wxWindowID  aId,
const wxPoint aLocation,
const wxSize &  aSize,
long  aStyle = 0 
)

Definition at line 43 of file listbox_base.cpp.

45  :
46  wxListView( aParent, aId, aLocation, aSize, LISTBOX_STYLE | aStyle ), columnWidth(0)
47 {
48  InsertColumn( 0, wxEmptyString );
49 }
#define LISTBOX_STYLE
Definition: listboxes.h:39
ITEMS_LISTBOX_BASE::~ITEMS_LISTBOX_BASE ( )

Definition at line 52 of file listbox_base.cpp.

53 {
54 }

Member Function Documentation

void ITEMS_LISTBOX_BASE::DeselectAll ( )

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

Definition at line 111 of file listbox_base.cpp.

References i.

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 }
size_t i
Definition: json11.cpp:597
CVPCB_MAINFRAME * ITEMS_LISTBOX_BASE::GetParent ( ) const
virtual
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 104 of file listbox_base.cpp.

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

105 {
106  return GetFirstSelected();
107 }
void ITEMS_LISTBOX_BASE::UpdateLineWidth ( unsigned  aLine)
private

Definition at line 83 of file listbox_base.cpp.

References columnWidth.

Referenced by UpdateWidth().

84 {
85  wxClientDC dc( this );
86  wxCoord w;
87  int newWidth = 10; // Value of AUTOSIZE_COL_MARGIN from wxWidgets source.
88 
89  dc.SetFont( GetFont() );
90  dc.GetTextExtent( GetItemText( aLine, 0 ) + " ", &w, NULL );
91  newWidth += w;
92 
93  if( newWidth > columnWidth )
94  {
95  columnWidth = newWidth;
96  SetColumnWidth( 0, columnWidth );
97  }
98 }
void ITEMS_LISTBOX_BASE::UpdateWidth ( int  aLine = -1)

Definition at line 57 of file listbox_base.cpp.

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().

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

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: