2011-09-23 13:57:12 +00:00
|
|
|
/**
|
|
|
|
* @file listboxes.cpp
|
|
|
|
* @brief Implementation of class for displaying footprint list and component lists.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <macros.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <cvpcb.h>
|
|
|
|
#include <cvpcb_mainframe.h>
|
|
|
|
#include <cvstruct.h>
|
|
|
|
#include <cvpcb_id.h>
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
/******************************************************************************
|
|
|
|
* Basic class (from wxListView) to display component and footprint lists
|
|
|
|
* Not directly used: the 2 list boxes actually used are derived from it
|
|
|
|
******************************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
ITEMS_LISTBOX_BASE::ITEMS_LISTBOX_BASE( CVPCB_MAINFRAME* aParent, wxWindowID aId,
|
2012-09-26 15:36:48 +00:00
|
|
|
const wxPoint& aLocation, const wxSize& aSize,
|
|
|
|
long aStyle) :
|
|
|
|
wxListView( aParent, aId, aLocation, aSize, LISTB_STYLE | aStyle )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
InsertColumn( 0, wxEmptyString );
|
|
|
|
SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
ITEMS_LISTBOX_BASE::~ITEMS_LISTBOX_BASE()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
/*
|
|
|
|
* Adjust the column width to the entire available window width
|
|
|
|
*/
|
2009-08-20 11:44:06 +00:00
|
|
|
void ITEMS_LISTBOX_BASE::OnSize( wxSizeEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
wxSize size = GetClientSize();
|
|
|
|
int width = 0;
|
|
|
|
|
2012-09-22 11:29:30 +00:00
|
|
|
SetColumnWidth( 0, std::max( width, size.x ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
event.Skip();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
/*
|
|
|
|
* Return an index for the selected item
|
|
|
|
*/
|
2009-08-20 11:44:06 +00:00
|
|
|
int ITEMS_LISTBOX_BASE::GetSelection()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
return GetFirstSelected();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME* ITEMS_LISTBOX_BASE::GetParent()
|
2009-05-21 17:42:42 +00:00
|
|
|
{
|
2011-02-05 16:15:48 +00:00
|
|
|
return (CVPCB_MAINFRAME*) wxListView::GetParent();
|
2009-05-21 17:42:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
/*
|
|
|
|
* Create or update the schematic components list.
|
2007-10-29 08:22:45 +00:00
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::BuildCmpListBox()
|
2007-10-29 08:22:45 +00:00
|
|
|
{
|
2009-08-20 11:44:06 +00:00
|
|
|
wxString msg;
|
|
|
|
wxSize size( 10, 10 );
|
|
|
|
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
2007-10-29 08:22:45 +00:00
|
|
|
|
|
|
|
if( m_ListCmp == NULL )
|
|
|
|
{
|
2009-08-20 11:44:06 +00:00
|
|
|
m_ListCmp = new COMPONENTS_LISTBOX( this, ID_CVPCB_COMPONENT_LIST,
|
|
|
|
wxDefaultPosition, size,
|
|
|
|
0, NULL );
|
2007-10-29 08:22:45 +00:00
|
|
|
m_ListCmp->SetBackgroundColour( wxColour( 225, 255, 255 ) );
|
|
|
|
m_ListCmp->SetForegroundColour( wxColour( 0, 0, 0 ) );
|
2009-04-23 15:02:18 +00:00
|
|
|
m_ListCmp->SetFont( wxFont( guiFont.GetPointSize(),
|
|
|
|
wxFONTFAMILY_MODERN,
|
|
|
|
wxFONTSTYLE_NORMAL,
|
|
|
|
wxFONTWEIGHT_NORMAL ) );
|
2007-10-29 08:22:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
m_ListCmp->m_ComponentList.Clear();
|
2009-04-23 15:02:18 +00:00
|
|
|
|
2012-02-01 19:49:37 +00:00
|
|
|
BOOST_FOREACH( COMPONENT_INFO & component, m_components ) {
|
2009-04-23 15:02:18 +00:00
|
|
|
msg.Printf( CMP_FORMAT, m_ListCmp->GetCount() + 1,
|
2009-10-25 15:54:00 +00:00
|
|
|
GetChars(component.m_Reference),
|
|
|
|
GetChars(component.m_Value),
|
2012-02-01 19:49:37 +00:00
|
|
|
GetChars(component.m_Footprint) );
|
2007-10-29 08:22:45 +00:00
|
|
|
m_ListCmp->m_ComponentList.Add( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ListCmp->SetItemCount( m_ListCmp->m_ComponentList.Count() );
|
2012-01-22 17:20:22 +00:00
|
|
|
m_ListCmp->SetSelection( 0, true );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
/*
|
|
|
|
* Create or update the footprint list.
|
2007-10-29 08:22:45 +00:00
|
|
|
*/
|
2011-02-05 16:15:48 +00:00
|
|
|
void CVPCB_MAINFRAME::BuildFOOTPRINTS_LISTBOX()
|
2007-10-29 08:22:45 +00:00
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
wxSize size( 10, 10 );
|
2009-04-23 15:02:18 +00:00
|
|
|
wxFont guiFont = wxSystemSettings::GetFont( wxSYS_DEFAULT_GUI_FONT );
|
2007-10-29 08:22:45 +00:00
|
|
|
|
|
|
|
if( m_FootprintList == NULL )
|
|
|
|
{
|
2009-08-20 11:44:06 +00:00
|
|
|
m_FootprintList = new FOOTPRINTS_LISTBOX( this, ID_CVPCB_FOOTPRINT_LIST,
|
|
|
|
wxDefaultPosition, size,
|
|
|
|
0, NULL );
|
2007-10-29 08:22:45 +00:00
|
|
|
m_FootprintList->SetBackgroundColour( wxColour( 225, 255, 225 ) );
|
|
|
|
m_FootprintList->SetForegroundColour( wxColour( 0, 0, 0 ) );
|
2009-04-23 15:02:18 +00:00
|
|
|
m_FootprintList->SetFont( wxFont( guiFont.GetPointSize(),
|
|
|
|
wxFONTFAMILY_MODERN,
|
|
|
|
wxFONTSTYLE_NORMAL,
|
|
|
|
wxFONTWEIGHT_NORMAL ) );
|
2007-10-29 08:22:45 +00:00
|
|
|
}
|
|
|
|
|
2009-04-23 15:02:18 +00:00
|
|
|
m_FootprintList->SetFootprintFullList( m_footprints );
|
2010-11-07 20:06:07 +00:00
|
|
|
DisplayStatus();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|