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"
|
|
|
|
#include "id.h"
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "cvpcb.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "protos.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "cvstruct.h"
|
|
|
|
|
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
|
|
|
|
|
|
|
|
ITEMS_LISTBOX_BASE::ITEMS_LISTBOX_BASE( WinEDA_CvpcbFrame* aParent, wxWindowID aId,
|
|
|
|
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
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
WinEDA_CvpcbFrame* ITEMS_LISTBOX_BASE::GetParent()
|
2009-05-21 17:42:42 +00:00
|
|
|
{
|
|
|
|
return (WinEDA_CvpcbFrame*) wxListView::GetParent();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-05-06 11:55:36 +00:00
|
|
|
/*
|
|
|
|
* Create or update the schematic components list.
|
2007-10-29 08:22:45 +00:00
|
|
|
*/
|
2009-05-06 11:55:36 +00:00
|
|
|
void WinEDA_CvpcbFrame::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-08-20 11:44:06 +00:00
|
|
|
component.m_Reference.GetData(),
|
|
|
|
component.m_Value.GetData(),
|
|
|
|
component.m_Module.GetData() );
|
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
|
|
|
*/
|
2009-08-20 11:44:06 +00:00
|
|
|
void WinEDA_CvpcbFrame::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 );
|
2007-10-29 08:22:45 +00:00
|
|
|
|
|
|
|
msg.Printf( _( "Footprints: %d" ), m_FootprintList->GetCount() );
|
|
|
|
SetStatusText( msg, 2 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|