KiCad PCB EDA Suite
ITEMS_LISTBOX_BASE Class Reference

#include <listview_classes.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 listview_classes.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 44 of file listboxes.cpp.

46  :
47  wxListView( aParent, aId, aLocation, aSize, LISTBOX_STYLE | aStyle ), columnWidth(0)
48 {
49  InsertColumn( 0, wxEmptyString );
50 }
#define LISTBOX_STYLE
ITEMS_LISTBOX_BASE::~ITEMS_LISTBOX_BASE ( )

Definition at line 53 of file listboxes.cpp.

54 {
55 }

Member Function Documentation

void ITEMS_LISTBOX_BASE::DeselectAll ( )

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 }
CVPCB_MAINFRAME * ITEMS_LISTBOX_BASE::GetParent ( ) const
virtual

Definition at line 119 of file listboxes.cpp.

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

120 {
121  return (CVPCB_MAINFRAME*) wxListView::GetParent();
122 }
The CvPcb application main window.
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 105 of file listboxes.cpp.

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

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

Definition at line 84 of file listboxes.cpp.

References columnWidth.

Referenced by UpdateWidth().

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

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

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

int ITEMS_LISTBOX_BASE::columnWidth
private

Definition at line 80 of file listview_classes.h.

Referenced by UpdateLineWidth(), and UpdateWidth().


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