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 "cvpcb.h"
|
|
|
|
|
|
|
|
#include "id.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/******************************************************************************/
|
|
|
|
/* Basic class (from wxListView) for displaying component and footprint lists */
|
|
|
|
/* Not directly used: the 2 list boxes actually used are derived from it */
|
|
|
|
/******************************************************************************/
|
|
|
|
|
|
|
|
ListBoxBase::ListBoxBase( WinEDA_CvpcbFrame* parent,
|
|
|
|
wxWindowID id, const wxPoint& loc, const wxSize& size ) :
|
|
|
|
LIST_BOX_TYPE( parent, id, loc, size,
|
|
|
|
wxSUNKEN_BORDER | wxLC_NO_HEADER |
|
|
|
|
wxLC_SINGLE_SEL | wxLC_REPORT | wxLC_VIRTUAL )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
m_Parent = parent;
|
|
|
|
InsertColumn( 0, wxEmptyString );
|
|
|
|
SetColumnWidth( 0, wxLIST_AUTOSIZE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
ListBoxBase::~ListBoxBase()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void ListBoxBase::OnSize( wxSizeEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Ajust the column width to the entire available window width
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
wxSize size = GetClientSize();
|
|
|
|
int width = 0;
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// SetColumnWidth(0, wxLIST_AUTOSIZE );
|
|
|
|
// width = GetColumnWidth(0);
|
2007-10-29 08:22:45 +00:00
|
|
|
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
|
|
|
|
|
|
|
|
|
|
|
/*********************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
int ListBoxBase::GetSelection()
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Return an index for the selected item
|
|
|
|
{
|
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
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/***************************************/
|
|
|
|
/* ListBox handling the footprint list */
|
|
|
|
/***************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
FootprintListBox::FootprintListBox( WinEDA_CvpcbFrame* parent,
|
|
|
|
wxWindowID id, const wxPoint& loc, const wxSize& size,
|
|
|
|
int nbitems, wxString choice[] ) :
|
|
|
|
ListBoxBase( parent, id, loc, size )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-12-10 20:57:33 +00:00
|
|
|
m_ActiveFootprintList = NULL;
|
2007-10-29 08:22:45 +00:00
|
|
|
SetActiveFootprintList( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
FootprintListBox::~FootprintListBox()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/**********************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
int FootprintListBox::GetCount()
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Return number of items
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
return m_ActiveFootprintList->Count();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*****************************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void FootprintListBox::SetString( unsigned linecount, const wxString& text )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Change an item text
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
if( linecount >= m_ActiveFootprintList->Count() )
|
|
|
|
linecount = m_ActiveFootprintList->Count() - 1;
|
|
|
|
if( linecount >= 0 )
|
|
|
|
(*m_ActiveFootprintList)[linecount] = text;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
wxString FootprintListBox::GetSelectedFootprint()
|
2007-06-05 12:10:51 +00:00
|
|
|
/***************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Return an index for the selected item
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
wxString FootprintName;
|
|
|
|
int ii = GetFirstSelected();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
if( ii >= 0 )
|
|
|
|
{
|
|
|
|
wxString msg = (*m_ActiveFootprintList)[ii];
|
|
|
|
msg.Trim( TRUE ); msg.Trim( FALSE );
|
|
|
|
FootprintName = msg.AfterFirst( wxChar( ' ' ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
return FootprintName;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void FootprintListBox::AppendLine( const wxString& text )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Add an item at end of list
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
m_ActiveFootprintList->Add( text );
|
|
|
|
SetItemCount( m_ActiveFootprintList->Count() );
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
|
|
|
/*********************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
wxString FootprintListBox::OnGetItemText( long item, long column ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Overlayed function: MUST be provided in wxLC_VIRTUAL mode
|
2007-10-29 08:22:45 +00:00
|
|
|
* because real datas are not handled by ListBoxBase
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
return m_ActiveFootprintList->Item( item );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void FootprintListBox::SetSelection( unsigned index, bool State )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*****************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Enable or disable an item
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
if( (int) index >= GetCount() )
|
|
|
|
index = GetCount() - 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-17 20:18:04 +00:00
|
|
|
if ( (index >= 0) && (GetCount() > 0) )
|
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifndef __WXMAC__
|
2007-12-17 20:18:04 +00:00
|
|
|
Select( index, State );
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-12-17 20:18:04 +00:00
|
|
|
EnsureVisible( index );
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifdef __WXMAC__
|
2007-12-17 20:18:04 +00:00
|
|
|
Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-12-17 20:18:04 +00:00
|
|
|
}
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/**************************************************/
|
|
|
|
/* ListBox handling the schematic components list */
|
|
|
|
/**************************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
ListBoxCmp::ListBoxCmp( WinEDA_CvpcbFrame* parent, wxWindowID id,
|
|
|
|
const wxPoint& loc, const wxSize& size,
|
|
|
|
int nbitems, wxString choice[] ) :
|
|
|
|
ListBoxBase( parent, id, loc, size )
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
ListBoxCmp::~ListBoxCmp()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/* Build the events table for the schematic components list box
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
BEGIN_EVENT_TABLE( ListBoxCmp, LIST_BOX_TYPE )
|
|
|
|
EVT_SIZE( ListBoxBase::OnSize )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
/****************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void ListBoxCmp::Clear()
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Reset ALL datas
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
m_ComponentList.Clear();
|
|
|
|
SetItemCount( 0 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
int ListBoxCmp::GetCount()
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Return number of items
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
return m_ComponentList.Count();
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-10-29 08:22:45 +00:00
|
|
|
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void ListBoxCmp::SetString( unsigned linecount, const wxString& text )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Change an item text
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
if( linecount >= m_ComponentList.Count() )
|
|
|
|
linecount = m_ComponentList.Count() - 1;
|
|
|
|
if( linecount >= 0 )
|
|
|
|
m_ComponentList[linecount] = text;
|
2007-05-06 16:03:28 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void ListBoxCmp::AppendLine( const wxString& text )
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Add an item at end of list
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
m_ComponentList.Add( text );
|
|
|
|
SetItemCount( m_ComponentList.Count() );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/****************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
wxString ListBoxCmp::OnGetItemText( long item, long column ) const
|
2007-06-05 12:10:51 +00:00
|
|
|
/****************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/* Overlayed function: MUST be provided in wxLC_VIRTUAL mode
|
2007-10-29 08:22:45 +00:00
|
|
|
* because real datas are not handled by ListBoxBase
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
return m_ComponentList.Item( item );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void ListBoxCmp::SetSelection( unsigned index, bool State )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Enable or disable an item
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
if( (int) index >= GetCount() )
|
|
|
|
index = GetCount() - 1;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-12-17 20:18:04 +00:00
|
|
|
if ( (index >= 0) && (GetCount() > 0) )
|
|
|
|
{
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifndef __WXMAC__
|
2007-12-17 20:18:04 +00:00
|
|
|
Select( index, State );
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-12-17 20:18:04 +00:00
|
|
|
EnsureVisible( index );
|
2007-06-05 12:10:51 +00:00
|
|
|
#ifdef __WXMAC__
|
2007-12-17 20:18:04 +00:00
|
|
|
Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
#endif
|
2007-12-17 20:18:04 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_CvpcbFrame::BuildCmpListBox()
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************/
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/* Create or update the schematic components list.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
int ii;
|
|
|
|
STORECMP* Composant;
|
|
|
|
wxString msg;
|
|
|
|
wxSize size( 10, 10 );
|
|
|
|
|
|
|
|
if( m_ListCmp == NULL )
|
|
|
|
{
|
|
|
|
m_ListCmp = new ListBoxCmp( this, ID_CVPCB_COMPONENT_LIST,
|
|
|
|
wxDefaultPosition, size,
|
|
|
|
0, NULL );
|
|
|
|
m_ListCmp->SetBackgroundColour( wxColour( 225, 255, 255 ) );
|
|
|
|
m_ListCmp->SetForegroundColour( wxColour( 0, 0, 0 ) );
|
|
|
|
m_ListCmp->SetFont( *g_FixedFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_ListCmp->m_ComponentList.Clear();
|
|
|
|
Composant = g_BaseListeCmp;
|
|
|
|
for( ii = 1; Composant != NULL; Composant = Composant->Pnext, ii++ )
|
|
|
|
{
|
|
|
|
msg.Printf( CMP_FORMAT, ii,
|
|
|
|
Composant->m_Reference.GetData(), Composant->m_Valeur.GetData(),
|
|
|
|
Composant->m_Module.GetData() );
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/**********************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void WinEDA_CvpcbFrame::BuildFootprintListBox()
|
2007-10-29 08:22:45 +00:00
|
|
|
/**********************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/* Create or update the footprint list.
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
wxString msg;
|
|
|
|
wxSize size( 10, 10 );
|
|
|
|
|
|
|
|
if( m_FootprintList == NULL )
|
|
|
|
{
|
|
|
|
m_FootprintList = new FootprintListBox( this, ID_CVPCB_FOOTPRINT_LIST,
|
|
|
|
wxDefaultPosition, size,
|
|
|
|
0, NULL );
|
|
|
|
m_FootprintList->SetBackgroundColour( wxColour( 225, 255, 225 ) );
|
|
|
|
m_FootprintList->SetForegroundColour( wxColour( 0, 0, 0 ) );
|
|
|
|
m_FootprintList->SetFont( *g_FixedFont );
|
|
|
|
}
|
|
|
|
|
|
|
|
m_FootprintList->SetFootprintFullList();
|
|
|
|
|
|
|
|
msg.Printf( _( "Footprints: %d" ), m_FootprintList->GetCount() );
|
|
|
|
SetStatusText( msg, 2 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/************************************************/
|
2007-09-13 11:55:46 +00:00
|
|
|
void FootprintListBox::SetFootprintFullList()
|
2007-06-05 12:10:51 +00:00
|
|
|
/************************************************/
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
STOREMOD* FootprintItem;
|
|
|
|
wxString msg;
|
|
|
|
int OldSelection = GetSelection();
|
|
|
|
|
|
|
|
m_FullFootprintList.Clear();
|
|
|
|
FootprintItem = g_BaseListePkg;
|
|
|
|
|
|
|
|
for( int ii = 1; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext, ii++ )
|
|
|
|
{
|
|
|
|
msg.Printf( wxT( "%3d %s" ), ii, FootprintItem->m_Module.GetData() );
|
|
|
|
m_FullFootprintList.Add( msg );
|
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
SetActiveFootprintList( TRUE );
|
|
|
|
|
|
|
|
if( (GetCount() == 0) || (OldSelection < 0) || ( OldSelection >= GetCount() ) )
|
|
|
|
SetSelection( 0, TRUE );
|
|
|
|
Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**********************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void FootprintListBox::SetFootprintFilteredList( STORECMP* Component )
|
2007-06-05 12:10:51 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
STOREMOD* FootprintItem;
|
|
|
|
wxString msg;
|
|
|
|
int OldSelection = GetSelection();
|
|
|
|
bool HasItem = FALSE;
|
|
|
|
|
|
|
|
m_FilteredFootprintList.Clear();
|
|
|
|
FootprintItem = g_BaseListePkg;
|
|
|
|
|
|
|
|
int cmpnum = 1;
|
|
|
|
for( int ii = 0; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext, ii++ )
|
|
|
|
{
|
|
|
|
/* Search for matching footprints */
|
|
|
|
for( unsigned jj = 0; jj < Component->m_FootprintFilter.GetCount(); jj++ )
|
|
|
|
{
|
|
|
|
if( !FootprintItem->m_Module.Matches( Component->m_FootprintFilter[jj] ) )
|
|
|
|
continue;
|
|
|
|
msg.Printf( wxT( "%3d %s" ), cmpnum++, FootprintItem->m_Module.GetData() );
|
|
|
|
m_FilteredFootprintList.Add( msg );
|
|
|
|
HasItem = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( HasItem )
|
|
|
|
SetActiveFootprintList( FALSE );
|
|
|
|
else
|
|
|
|
SetActiveFootprintList( TRUE );
|
|
|
|
|
|
|
|
if( (GetCount() == 0) || ( OldSelection >= GetCount() ) )
|
|
|
|
SetSelection( 0, TRUE );
|
|
|
|
|
|
|
|
Refresh();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**************************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void FootprintListBox::SetActiveFootprintList( bool FullList, bool Redraw )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************************/
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/** Set the footprint list. We can have 2 footprint list:
|
|
|
|
* The full footprint list
|
|
|
|
* The filtered footprint list (if the current selected component has a filter for footprints)
|
|
|
|
* @param FullList true = full footprint list, false = filtered footprint list
|
|
|
|
* @param Redraw = true to redraw the window
|
|
|
|
*/
|
|
|
|
{
|
|
|
|
bool old_selection = m_UseFootprintFullList;
|
|
|
|
|
2007-10-30 20:40:08 +00:00
|
|
|
#ifdef __WINDOWS__
|
2007-10-29 08:22:45 +00:00
|
|
|
/* Workaround for a curious bug in wxWidgets:
|
|
|
|
* if we switch from a long list of footprints to a short list (a filtered footprint list),
|
|
|
|
* and if the selected item is near the end of the long list,
|
|
|
|
* the new list is not displayed from the top of the list box
|
|
|
|
*/
|
|
|
|
if ( m_ActiveFootprintList )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
bool new_selection;
|
|
|
|
if( FullList ) new_selection = TRUE;
|
|
|
|
else new_selection = FALSE;
|
|
|
|
if( new_selection != old_selection )
|
|
|
|
SetSelection( 0, TRUE );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
2007-10-30 20:40:08 +00:00
|
|
|
#endif
|
2007-10-29 08:22:45 +00:00
|
|
|
if( FullList )
|
|
|
|
{
|
|
|
|
m_UseFootprintFullList = TRUE;
|
|
|
|
m_ActiveFootprintList = &m_FullFootprintList;
|
|
|
|
SetItemCount( m_FullFootprintList.GetCount() );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
m_UseFootprintFullList = FALSE;
|
|
|
|
m_ActiveFootprintList = &m_FilteredFootprintList;
|
|
|
|
SetItemCount( m_FilteredFootprintList.GetCount() );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Redraw )
|
|
|
|
{
|
|
|
|
if( !m_UseFootprintFullList || (m_UseFootprintFullList != old_selection) )
|
|
|
|
{
|
|
|
|
Refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if( !m_UseFootprintFullList || (m_UseFootprintFullList != old_selection) )
|
|
|
|
{
|
|
|
|
m_Parent->SetStatusText( wxEmptyString, 0 );
|
|
|
|
m_Parent->SetStatusText( wxEmptyString, 1 );
|
|
|
|
}
|
|
|
|
|
|
|
|
wxString msg;
|
|
|
|
if( FullList )
|
|
|
|
msg.Printf( _( "Footprints (All): %d" ), m_ActiveFootprintList->GetCount() );
|
|
|
|
else
|
|
|
|
msg.Printf( _( "Footprints (filtered): %d" ), m_ActiveFootprintList->GetCount() );
|
|
|
|
m_Parent->SetStatusText( msg, 2 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
/**************************************/
|
|
|
|
/* Event table for the footprint list */
|
|
|
|
/**************************************/
|
|
|
|
|
|
|
|
BEGIN_EVENT_TABLE( FootprintListBox, LIST_BOX_TYPE )
|
|
|
|
EVT_SIZE( ListBoxBase::OnSize )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
END_EVENT_TABLE()
|
|
|
|
|
|
|
|
|
|
|
|
/********************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void FootprintListBox::OnLeftClick( wxListEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/********************************************************/
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
STOREMOD* Module;
|
|
|
|
wxString msg;
|
|
|
|
wxString FootprintName = GetSelectedFootprint();
|
|
|
|
|
|
|
|
Module = GetModuleDescrByName( FootprintName );
|
|
|
|
if( m_Parent->DrawFrame )
|
|
|
|
{
|
|
|
|
m_Parent->CreateScreenCmp(); /* refresh general */
|
|
|
|
}
|
|
|
|
|
|
|
|
if( Module )
|
|
|
|
msg = Module->m_Doc;
|
|
|
|
m_Parent->SetStatusText( msg, 0 );
|
|
|
|
|
|
|
|
msg = wxT( "KeyW: " );
|
|
|
|
if( Module )
|
|
|
|
msg += Module->m_KeyWord;
|
|
|
|
m_Parent->SetStatusText( msg, 1 );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/******************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
void FootprintListBox::OnLeftDClick( wxListEvent& event )
|
2007-06-05 12:10:51 +00:00
|
|
|
/******************************************************/
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
wxString FootprintName = GetSelectedFootprint();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
m_Parent->SetNewPkg( FootprintName );
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
2007-10-29 08:22:45 +00:00
|
|
|
STOREMOD* GetModuleDescrByName( const wxString& FootprintName )
|
2007-06-05 12:10:51 +00:00
|
|
|
/**************************************************************/
|
|
|
|
{
|
2007-10-29 08:22:45 +00:00
|
|
|
STOREMOD* FootprintItem = g_BaseListePkg;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-10-29 08:22:45 +00:00
|
|
|
for( ; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext )
|
|
|
|
{
|
|
|
|
if( FootprintItem->m_Module == FootprintName )
|
|
|
|
break; // found !
|
|
|
|
}
|
|
|
|
|
|
|
|
return FootprintItem;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|