2007-06-05 12:10:51 +00:00
|
|
|
/*************************************************************************/
|
|
|
|
/* listboxes.cpp: class for displaying footprint list and component list */
|
|
|
|
/*************************************************************************/
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "wxstruct.h"
|
|
|
|
#include "common.h"
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "cvpcb.h"
|
2011-02-05 16:15:48 +00:00
|
|
|
#include "cvpcb_mainframe.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "cvstruct.h"
|
2010-11-07 20:06:07 +00:00
|
|
|
#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
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
#define LISTB_STYLE wxSUNKEN_BORDER | wxLC_NO_HEADER | \
|
|
|
|
wxLC_SINGLE_SEL | wxLC_REPORT | wxLC_VIRTUAL
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
ITEMS_LISTBOX_BASE::ITEMS_LISTBOX_BASE( CVPCB_MAINFRAME* aParent, wxWindowID aId,
|
2009-08-20 11:44:06 +00:00
|
|
|
const wxPoint& aLocation, const wxSize& aSize ) :
|
|
|
|
wxListView( aParent, aId, aLocation, aSize, LISTB_STYLE )
|
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;
|
|
|
|
|
|
|
|
SetColumnWidth( 0, 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
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
BOOST_FOREACH( COMPONENT & 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),
|
|
|
|
GetChars(component.m_Module) );
|
2007-10-29 08:22:45 +00:00
|
|
|
m_ListCmp->m_ComponentList.Add( msg );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ListCmp->SetItemCount( m_ListCmp->m_ComponentList.Count() );
|
|
|
|
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
|
|
|
}
|