Commit d5d16186 authored by CHARRAS's avatar CHARRAS

listboxes.cpp problem solved (see change_log)

parent 7eff222c
...@@ -4,6 +4,14 @@ Started 2007-June-11 ...@@ -4,6 +4,14 @@ Started 2007-June-11
Please add newer entries at the top, list the date and your name with Please add newer entries at the top, list the date and your name with
email address. email address.
2007-Oct-29 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================
+cvpcb: listboxes.cpp problem solved: 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
2007-Oct-27 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr> 2007-Oct-27 UPDATE Jean-Pierre Charras <jean-pierre.charras@inpg.fr>
================================================================================ ================================================================================
+ all: + all:
......
...@@ -54,21 +54,21 @@ ...@@ -54,21 +54,21 @@
* The real font size will be computed at run time */ * The real font size will be computed at run time */
/*****************************/ /**************************/
/* Constructeur de WinEDA_App */ /* WinEDA_App Constructor */
/*****************************/ /**************************/
WinEDA_App::WinEDA_App() WinEDA_App::WinEDA_App()
{ {
m_Checker = NULL; m_Checker = NULL;
m_MainFrame = NULL; m_MainFrame = NULL;
m_PcbFrame = NULL; m_PcbFrame = NULL;
m_ModuleEditFrame = NULL; // Edition des modules m_ModuleEditFrame = NULL; // Frame for footprint edition
m_SchematicFrame = NULL; // Edition des Schemas m_SchematicFrame = NULL; // Frame for schematic edition
m_LibeditFrame = NULL; // Edition des composants m_LibeditFrame = NULL; // Frame for component edition
m_ViewlibFrame = NULL; // Visualisation des composants m_ViewlibFrame = NULL; // Frame for browsing component libraries
m_CvpcbFrame = NULL; m_CvpcbFrame = NULL;
m_GerberFrame = NULL; // ecran de visualisation GERBER m_GerberFrame = NULL; // Frame for the gerber viewer GERBVIEW
m_LastProjectMaxCount = 10; m_LastProjectMaxCount = 10;
m_HtmlCtrl = NULL; m_HtmlCtrl = NULL;
...@@ -83,15 +83,15 @@ WinEDA_App::WinEDA_App() ...@@ -83,15 +83,15 @@ WinEDA_App::WinEDA_App()
} }
/*****************************/ /*************************/
/* Destructeur de WinEDA_App */ /* WinEDA_App Destructor */
/*****************************/ /*************************/
WinEDA_App::~WinEDA_App() WinEDA_App::~WinEDA_App()
{ {
SaveSettings(); SaveSettings();
/* delete data non directement geree par wxAppl */ /* delete user datas */
delete g_Prj_Config; delete g_Prj_Config;
delete m_EDA_Config; delete m_EDA_Config;
delete m_EDA_CommonConfig; delete m_EDA_CommonConfig;
...@@ -116,10 +116,12 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -116,10 +116,12 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
ident = name + wxT( "-" ) + wxGetUserId(); ident = name + wxT( "-" ) + wxGetUserId();
m_Checker = new wxSingleInstanceChecker( ident ); m_Checker = new wxSingleInstanceChecker( ident );
/* Init environnement /* Init kicad environment
* (KICAD definit le chemin de kicad ex: set KICAD=d:\kicad) */ * the environment variable KICAD (if exists) gives the kicad path:
* something like set KICAD=d:\kicad
*/
m_Env_Defined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv ); m_Env_Defined = wxGetEnv( wxT( "KICAD" ), &m_KicadEnv );
if( m_Env_Defined ) // m_KicadEnv doit finir par "/" ou "\" if( m_Env_Defined ) // ensure m_KicadEnv ends by "/"
{ {
m_KicadEnv.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); m_KicadEnv.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP );
if( m_KicadEnv.Last() != '/' ) if( m_KicadEnv.Last() != '/' )
...@@ -129,13 +131,13 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -129,13 +131,13 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
/* Prepare On Line Help */ /* Prepare On Line Help */
m_HelpFileName = name + wxT( ".html" ); m_HelpFileName = name + wxT( ".html" );
// Init parametres pour configuration // Init parameters for configuration
SetVendorName( wxT( "kicad" ) ); SetVendorName( wxT( "kicad" ) );
SetAppName( name ); SetAppName( name );
m_EDA_Config = new wxConfig( name ); m_EDA_Config = new wxConfig( name );
m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) ); m_EDA_CommonConfig = new wxConfig( wxT( "kicad_common" ) );
/* Creation des fontes utiles */ /* Create the fontes used in dialogs and messages */
g_StdFontPointSize = FONT_DEFAULT_SIZE; g_StdFontPointSize = FONT_DEFAULT_SIZE;
g_MsgFontPointSize = FONT_DEFAULT_SIZE; g_MsgFontPointSize = FONT_DEFAULT_SIZE;
g_DialogFontPointSize = FONT_DEFAULT_SIZE; g_DialogFontPointSize = FONT_DEFAULT_SIZE;
...@@ -155,12 +157,12 @@ void WinEDA_App::InitEDA_Appl( const wxString& name ) ...@@ -155,12 +157,12 @@ void WinEDA_App::InitEDA_Appl( const wxString& name )
wxImage::AddHandler( new wxJPEGHandler ); wxImage::AddHandler( new wxJPEGHandler );
wxFileSystem::AddHandler( new wxZipFSHandler ); wxFileSystem::AddHandler( new wxZipFSHandler );
// Analyse command line & init binary path // Analyse the command line & init binary path
SetBinDir(); SetBinDir();
ReadPdfBrowserInfos(); ReadPdfBrowserInfos();
// Internationalisation: chargement du Dictionnaire de kicad // Internationalisation: loading the kicad suitable Dictionnary
m_EDA_CommonConfig->Read( wxT( "Language" ), &m_LanguageId, wxLANGUAGE_DEFAULT ); m_EDA_CommonConfig->Read( wxT( "Language" ), &m_LanguageId, wxLANGUAGE_DEFAULT );
bool succes = SetLanguage( TRUE ); bool succes = SetLanguage( TRUE );
...@@ -262,7 +264,7 @@ bool WinEDA_App::SetBinDir() ...@@ -262,7 +264,7 @@ bool WinEDA_App::SetBinDir()
void WinEDA_App::GetSettings() void WinEDA_App::GetSettings()
/*********************************/ /*********************************/
/* Lit les infos utiles sauvees lors de la derniere utilisation du logiciel /* Get the last setup used (fontes, files opened...)
*/ */
{ {
wxString Line, Ident; wxString Line, Ident;
...@@ -639,8 +641,11 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu ) ...@@ -639,8 +641,11 @@ wxMenu* WinEDA_App::SetLanguageList( wxMenu* MasterMenu )
} }
/**********************/
int WinEDA_App::OnRun() int WinEDA_App::OnRun()
/* Run init scripts */ /**********************/
/* Run init scripts
*/
{ {
#ifdef KICAD_PYTHON #ifdef KICAD_PYTHON
PyHandler::GetInstance()->RunScripts(); PyHandler::GetInstance()->RunScripts();
......
...@@ -141,7 +141,7 @@ void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H, ...@@ -141,7 +141,7 @@ void WinEDA_MsgPanel::Affiche_1_Parametre( int pos_X, const wxString& texte_H,
} }
void WinEDA_MsgPanel::showItem( wxWindowDC& dc, const MsgItem& aItem ) void WinEDA_MsgPanel::showItem( wxDC& dc, const MsgItem& aItem )
{ {
int color = aItem.m_Color; int color = aItem.m_Color;
......
...@@ -12,38 +12,40 @@ ...@@ -12,38 +12,40 @@
#include "protos.h" #include "protos.h"
/************************************************************************/ /******************************************************************************/
/* Class (from wxListView) for displaying component and footprint lists */ /* 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): ListBoxBase::ListBoxBase( WinEDA_CvpcbFrame* parent,
LIST_BOX_TYPE(parent, id, loc, size, wxWindowID id, const wxPoint& loc, const wxSize& size ) :
LIST_BOX_TYPE( parent, id, loc, size,
wxSUNKEN_BORDER | wxLC_NO_HEADER | wxSUNKEN_BORDER | wxLC_NO_HEADER |
wxLC_SINGLE_SEL|wxLC_REPORT | wxLC_VIRTUAL) wxLC_SINGLE_SEL | wxLC_REPORT | wxLC_VIRTUAL )
{ {
m_Parent = parent; m_Parent = parent;
InsertColumn(0, wxEmptyString); InsertColumn( 0, wxEmptyString );
SetColumnWidth(0, wxLIST_AUTOSIZE ); SetColumnWidth( 0, wxLIST_AUTOSIZE );
} }
ListBoxBase::~ListBoxBase() ListBoxBase::~ListBoxBase()
{ {
} }
/************************************************/ /************************************************/
void ListBoxBase::OnSize(wxSizeEvent& event) void ListBoxBase::OnSize( wxSizeEvent& event )
/************************************************/ /************************************************/
// Ajust the column width to the entire available window width // Ajust the column width to the entire available window width
{ {
wxSize size = GetClientSize(); wxSize size = GetClientSize();
int width = 0; int width = 0;
// SetColumnWidth(0, wxLIST_AUTOSIZE ); // SetColumnWidth(0, wxLIST_AUTOSIZE );
// width = GetColumnWidth(0); // width = GetColumnWidth(0);
SetColumnWidth(0, MAX(width, size.x) ); SetColumnWidth( 0, MAX( width, size.x ) );
event.Skip(); event.Skip();
} }
...@@ -52,26 +54,26 @@ int width = 0; ...@@ -52,26 +54,26 @@ int width = 0;
/*********************************/ /*********************************/
int ListBoxBase::GetSelection() int ListBoxBase::GetSelection()
/*********************************/ /*********************************/
// Return an index for the selected item // Return an index for the selected item
{ {
return GetFirstSelected(); return GetFirstSelected();
} }
/************************************************************/ /***************************************/
/* ListBox derivee pour l'affichage de la liste des Modules */ /* ListBox handling the footprint list */
/************************************************************/ /***************************************/
FootprintListBox::FootprintListBox(WinEDA_CvpcbFrame * parent, FootprintListBox::FootprintListBox( WinEDA_CvpcbFrame* parent,
wxWindowID id, const wxPoint& loc, const wxSize& size, wxWindowID id, const wxPoint& loc, const wxSize& size,
int nbitems, wxString choice[]): int nbitems, wxString choice[] ) :
ListBoxBase(parent, id, loc, size) ListBoxBase( parent, id, loc, size )
{ {
SetActiveFootprintList(TRUE); SetActiveFootprintList( TRUE );
} }
FootprintListBox::~FootprintListBox() FootprintListBox::~FootprintListBox()
{ {
} }
...@@ -80,6 +82,7 @@ FootprintListBox::~FootprintListBox() ...@@ -80,6 +82,7 @@ FootprintListBox::~FootprintListBox()
/**********************************/ /**********************************/
int FootprintListBox::GetCount() int FootprintListBox::GetCount()
/**********************************/ /**********************************/
// Return number of items // Return number of items
{ {
return m_ActiveFootprintList->Count(); return m_ActiveFootprintList->Count();
...@@ -87,28 +90,32 @@ int FootprintListBox::GetCount() ...@@ -87,28 +90,32 @@ int FootprintListBox::GetCount()
/*****************************************************************************/ /*****************************************************************************/
void FootprintListBox::SetString(unsigned linecount, const wxString & text) void FootprintListBox::SetString( unsigned linecount, const wxString& text )
/*****************************************************************************/ /*****************************************************************************/
// Change an item text // Change an item text
{ {
if (linecount >= m_ActiveFootprintList->Count()) if( linecount >= m_ActiveFootprintList->Count() )
linecount = m_ActiveFootprintList->Count()-1; linecount = m_ActiveFootprintList->Count() - 1;
if ( linecount >= 0 ) (*m_ActiveFootprintList)[linecount] = text; if( linecount >= 0 )
(*m_ActiveFootprintList)[linecount] = text;
} }
/***************************************************/ /***************************************************/
wxString FootprintListBox::GetSelectedFootprint() wxString FootprintListBox::GetSelectedFootprint()
/***************************************************/ /***************************************************/
// Return an index for the selected item // Return an index for the selected item
{ {
wxString FootprintName; wxString FootprintName;
int ii = GetFirstSelected(); int ii = GetFirstSelected();
if ( ii >= 0 ) if( ii >= 0 )
{ {
wxString msg = (*m_ActiveFootprintList)[ii]; wxString msg = (*m_ActiveFootprintList)[ii];
msg.Trim(TRUE); msg.Trim(FALSE); msg.Trim( TRUE ); msg.Trim( FALSE );
FootprintName = msg.AfterFirst(wxChar(' ')); FootprintName = msg.AfterFirst( wxChar( ' ' ) );
} }
return FootprintName; return FootprintName;
...@@ -116,199 +123,210 @@ int ii = GetFirstSelected(); ...@@ -116,199 +123,210 @@ int ii = GetFirstSelected();
/*********************************************************/ /*********************************************************/
void FootprintListBox::AppendLine(const wxString & text) void FootprintListBox::AppendLine( const wxString& text )
/*********************************************************/ /*********************************************************/
// Add an item at end of list // Add an item at end of list
{ {
m_ActiveFootprintList->Add(text); m_ActiveFootprintList->Add( text );
SetItemCount(m_ActiveFootprintList->Count() ); SetItemCount( m_ActiveFootprintList->Count() );
} }
/*********************************************************************/ /*********************************************************************/
wxString FootprintListBox::OnGetItemText(long item, long column) const wxString FootprintListBox::OnGetItemText( long item, long column ) const
/*********************************************************************/ /*********************************************************************/
/* Overlayed function: MUST be provided in wxLC_VIRTUAL mode /* Overlayed function: MUST be provided in wxLC_VIRTUAL mode
because real datas are not handled by ListBoxBase * because real datas are not handled by ListBoxBase
*/ */
{ {
return m_ActiveFootprintList->Item(item); return m_ActiveFootprintList->Item( item );
} }
/*****************************************************************/ /*****************************************************************/
void FootprintListBox::SetSelection(unsigned index, bool State) void FootprintListBox::SetSelection( unsigned index, bool State )
/*****************************************************************/ /*****************************************************************/
// Enable or disable an item // Enable or disable an item
{ {
if ( (int) index >= GetCount() ) index = GetCount()-1; if( (int) index >= GetCount() )
index = GetCount() - 1;
#ifndef __WXMAC__ #ifndef __WXMAC__
Select(index, State); Select( index, State );
#endif #endif
EnsureVisible(index); EnsureVisible( index );
#ifdef __WXMAC__ #ifdef __WXMAC__
Refresh(); Refresh();
#endif #endif
} }
/***************************************************************/ /**************************************************/
/* ListBox derivee pour l'affichage de la liste des Composants */ /* ListBox handling the schematic components list */
/***************************************************************/ /**************************************************/
ListBoxCmp::ListBoxCmp(WinEDA_CvpcbFrame * parent, wxWindowID id, ListBoxCmp::ListBoxCmp( WinEDA_CvpcbFrame* parent, wxWindowID id,
const wxPoint& loc, const wxSize& size, const wxPoint& loc, const wxSize& size,
int nbitems, wxString choice[]): int nbitems, wxString choice[] ) :
ListBoxBase(parent, id, loc, size) ListBoxBase( parent, id, loc, size )
{ {
} }
ListBoxCmp::~ListBoxCmp() ListBoxCmp::~ListBoxCmp()
{ {
} }
/* Build the events table for the schematic components list box
*/
/***********************************************************************/ BEGIN_EVENT_TABLE( ListBoxCmp, LIST_BOX_TYPE )
/* Construction de la table des evenements pour la fenetre des composants */ EVT_SIZE( ListBoxBase::OnSize )
/***********************************************************************/
BEGIN_EVENT_TABLE(ListBoxCmp, LIST_BOX_TYPE)
EVT_SIZE( ListBoxBase::OnSize)
END_EVENT_TABLE() END_EVENT_TABLE()
/****************************/ /****************************/
void ListBoxCmp::Clear() void ListBoxCmp::Clear()
/****************************/ /****************************/
// Reset ALL datas // Reset ALL datas
{ {
m_ComponentList.Clear(); m_ComponentList.Clear();
SetItemCount(0); SetItemCount( 0 );
} }
/******************************/ /******************************/
int ListBoxCmp::GetCount() int ListBoxCmp::GetCount()
/******************************/ /******************************/
// Return number of items // Return number of items
{ {
return m_ComponentList.Count(); return m_ComponentList.Count();
} }
/********************************************************************/ /********************************************************************/
void ListBoxCmp::SetString(unsigned linecount, const wxString & text) void ListBoxCmp::SetString( unsigned linecount, const wxString& text )
/********************************************************************/ /********************************************************************/
// Change an item text // Change an item text
{ {
if (linecount >= m_ComponentList.Count()) if( linecount >= m_ComponentList.Count() )
linecount = m_ComponentList.Count()-1; linecount = m_ComponentList.Count() - 1;
if ( linecount >= 0 ) m_ComponentList[linecount] = text; if( linecount >= 0 )
m_ComponentList[linecount] = text;
} }
/****************************************************/ /****************************************************/
void ListBoxCmp::AppendLine(const wxString & text) void ListBoxCmp::AppendLine( const wxString& text )
/****************************************************/ /****************************************************/
// Add an item at end of list // Add an item at end of list
{ {
m_ComponentList.Add(text); m_ComponentList.Add( text );
SetItemCount(m_ComponentList.Count() ); SetItemCount( m_ComponentList.Count() );
} }
/****************************************************************/ /****************************************************************/
wxString ListBoxCmp::OnGetItemText(long item, long column) const wxString ListBoxCmp::OnGetItemText( long item, long column ) const
/****************************************************************/ /****************************************************************/
/* Overlayed function: MUST be provided in wxLC_VIRTUAL mode /* Overlayed function: MUST be provided in wxLC_VIRTUAL mode
because real datas are not handled by ListBoxBase * because real datas are not handled by ListBoxBase
*/ */
{ {
return m_ComponentList.Item(item); return m_ComponentList.Item( item );
} }
/********************************************************/ /********************************************************/
void ListBoxCmp::SetSelection(unsigned index, bool State) void ListBoxCmp::SetSelection( unsigned index, bool State )
/*********************************************************/ /*********************************************************/
// Enable or disable an item // Enable or disable an item
{ {
if ( (int) index >= GetCount() ) index = GetCount()-1; if( (int) index >= GetCount() )
index = GetCount() - 1;
#ifndef __WXMAC__ #ifndef __WXMAC__
Select(index, State); Select( index, State );
#endif #endif
EnsureVisible(index); EnsureVisible( index );
#ifdef __WXMAC__ #ifdef __WXMAC__
Refresh(); Refresh();
#endif #endif
} }
/********************************************/ /********************************************/
void WinEDA_CvpcbFrame::BuildCmpListBox() void WinEDA_CvpcbFrame::BuildCmpListBox()
/********************************************/ /********************************************/
/* Construit la fenetre d'affichage de la liste des composant.
dimx et dimy sont les dimensions de la surface totale d'affichage /* Create or update the schematic components list.
et non les dims de la fenetre des Cmp */
Si la fenetre d'affichage a deja ete creee, il y a seulement
mise a jour de la liste
*/
{ {
int ii; int ii;
STORECMP * Composant; STORECMP* Composant;
wxString msg; wxString msg;
wxSize size(10,10); wxSize size( 10, 10 );
if( m_ListCmp == NULL ) if( m_ListCmp == NULL )
{ {
m_ListCmp = new ListBoxCmp(this, ID_CVPCB_COMPONENT_LIST, m_ListCmp = new ListBoxCmp( this, ID_CVPCB_COMPONENT_LIST,
wxDefaultPosition, size, wxDefaultPosition, size,
0, NULL); 0, NULL );
m_ListCmp->SetBackgroundColour(wxColour(225,255,255)); m_ListCmp->SetBackgroundColour( wxColour( 225, 255, 255 ) );
m_ListCmp->SetForegroundColour(wxColour(0,0,0)); m_ListCmp->SetForegroundColour( wxColour( 0, 0, 0 ) );
m_ListCmp->SetFont(*g_FixedFont); m_ListCmp->SetFont( *g_FixedFont );
} }
m_ListCmp->m_ComponentList.Clear(); m_ListCmp->m_ComponentList.Clear();
Composant = g_BaseListeCmp; Composant = g_BaseListeCmp;
for (ii = 1 ; Composant != NULL; Composant = Composant->Pnext, ii++ ) for( ii = 1; Composant != NULL; Composant = Composant->Pnext, ii++ )
{ {
msg.Printf(CMP_FORMAT ,ii, msg.Printf( CMP_FORMAT, ii,
Composant->m_Reference.GetData(), Composant->m_Valeur.GetData(), Composant->m_Reference.GetData(), Composant->m_Valeur.GetData(),
Composant->m_Module.GetData()); Composant->m_Module.GetData() );
m_ListCmp->m_ComponentList.Add(msg); m_ListCmp->m_ComponentList.Add( msg );
} }
m_ListCmp->SetItemCount(m_ListCmp->m_ComponentList.Count() );
m_ListCmp->SetSelection(0, TRUE); m_ListCmp->SetItemCount( m_ListCmp->m_ComponentList.Count() );
m_ListCmp->SetSelection( 0, TRUE );
} }
/*************************************************************/ /**********************************************/
void WinEDA_CvpcbFrame::BuildFootprintListBox() void WinEDA_CvpcbFrame::BuildFootprintListBox()
/*************************************************************/ /**********************************************/
/* Construit la fenetre d'affichage de la liste des Modules.
dimx et dimy sont les dimensions de la surface totale d'affichage /* Create or update the footprint list.
et non les dims de la fenetre des Modules */
Si la fenetre d'affichage a deja ete creee, il y a seulement
mise a jour de la liste
*/
{ {
wxString msg; wxString msg;
wxSize size(10,10); wxSize size( 10, 10 );
if( m_FootprintList == NULL ) if( m_FootprintList == NULL )
{ {
m_FootprintList = new FootprintListBox(this, ID_CVPCB_FOOTPRINT_LIST, m_FootprintList = new FootprintListBox( this, ID_CVPCB_FOOTPRINT_LIST,
wxDefaultPosition, size, wxDefaultPosition, size,
0, NULL); 0, NULL );
m_FootprintList->SetBackgroundColour(wxColour(225,255,225)); m_FootprintList->SetBackgroundColour( wxColour( 225, 255, 225 ) );
m_FootprintList->SetForegroundColour(wxColour(0,0,0)); m_FootprintList->SetForegroundColour( wxColour( 0, 0, 0 ) );
m_FootprintList->SetFont(*g_FixedFont); m_FootprintList->SetFont( *g_FixedFont );
} }
m_FootprintList->SetFootprintFullList(); m_FootprintList->SetFootprintFullList();
msg.Printf(_("Footprints: %d"), m_FootprintList->GetCount()); msg.Printf( _( "Footprints: %d" ), m_FootprintList->GetCount() );
SetStatusText(msg,2); SetStatusText( msg, 2 );
} }
...@@ -316,157 +334,184 @@ wxSize size(10,10); ...@@ -316,157 +334,184 @@ wxSize size(10,10);
void FootprintListBox::SetFootprintFullList() void FootprintListBox::SetFootprintFullList()
/************************************************/ /************************************************/
{ {
STOREMOD * FootprintItem; STOREMOD* FootprintItem;
wxString msg; wxString msg;
int OldSelection = GetSelection(); int OldSelection = GetSelection();
m_FullFootprintList.Clear(); m_FullFootprintList.Clear();
FootprintItem = g_BaseListePkg; FootprintItem = g_BaseListePkg;
for ( int ii = 1; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext, ii++ ) for( int ii = 1; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext, ii++ )
{ {
msg.Printf( wxT("%3d %s"), ii, FootprintItem->m_Module.GetData()); msg.Printf( wxT( "%3d %s" ), ii, FootprintItem->m_Module.GetData() );
m_FullFootprintList.Add(msg); m_FullFootprintList.Add( msg );
} }
SetActiveFootprintList(TRUE); SetActiveFootprintList( TRUE );
if ( (GetCount() == 0) || (OldSelection < 0) || ( OldSelection >= GetCount() ) ) if( (GetCount() == 0) || (OldSelection < 0) || ( OldSelection >= GetCount() ) )
SetSelection(0, TRUE); SetSelection( 0, TRUE );
Refresh(); Refresh();
} }
/**********************************************************************/ /**********************************************************************/
void FootprintListBox::SetFootprintFilteredList(STORECMP * Component) void FootprintListBox::SetFootprintFilteredList( STORECMP* Component )
/*********************************************************************/ /*********************************************************************/
{ {
STOREMOD * FootprintItem; STOREMOD* FootprintItem;
wxString msg; wxString msg;
int OldSelection = GetSelection(); int OldSelection = GetSelection();
bool HasItem = FALSE; bool HasItem = FALSE;
m_FilteredFootprintList.Clear(); m_FilteredFootprintList.Clear();
FootprintItem = g_BaseListePkg; FootprintItem = g_BaseListePkg;
int cmpnum = 1; int cmpnum = 1;
for ( int ii = 0; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext, ii++ ) for( int ii = 0; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext, ii++ )
{ {
/* Search for matching footprints */ /* Search for matching footprints */
for ( unsigned jj = 0; jj < Component->m_FootprintFilter.GetCount(); jj ++ ) for( unsigned jj = 0; jj < Component->m_FootprintFilter.GetCount(); jj++ )
{ {
if ( ! FootprintItem->m_Module.Matches(Component->m_FootprintFilter[jj]) ) if( !FootprintItem->m_Module.Matches( Component->m_FootprintFilter[jj] ) )
continue; continue;
msg.Printf( wxT("%3d %s"), cmpnum++, FootprintItem->m_Module.GetData()); msg.Printf( wxT( "%3d %s" ), cmpnum++, FootprintItem->m_Module.GetData() );
m_FilteredFootprintList.Add(msg); m_FilteredFootprintList.Add( msg );
HasItem = TRUE; HasItem = TRUE;
} }
} }
if( HasItem )
SetActiveFootprintList( FALSE );
else
SetActiveFootprintList( TRUE );
if ( HasItem ) SetActiveFootprintList(FALSE); if( (GetCount() == 0) || ( OldSelection >= GetCount() ) )
else SetActiveFootprintList(TRUE); SetSelection( 0, TRUE );
if ( (GetCount() == 0) || ( OldSelection >= GetCount() ) )
SetSelection(0, TRUE);
Refresh(); Refresh();
} }
/**************************************************************************/ /**************************************************************************/
void FootprintListBox::SetActiveFootprintList(bool FullList, bool Redraw) void FootprintListBox::SetActiveFootprintList( bool FullList, bool Redraw )
/**************************************************************************/ /**************************************************************************/
/** 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; bool old_selection = m_UseFootprintFullList;
/* 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 )
{
bool new_selection;
if( FullList ) new_selection = TRUE;
else new_selection = FALSE;
if( new_selection != old_selection )
SetSelection( 0, TRUE );
}
if ( FullList ) if( FullList )
{ {
m_UseFootprintFullList = TRUE; m_UseFootprintFullList = TRUE;
m_ActiveFootprintList = &m_FullFootprintList; m_ActiveFootprintList = &m_FullFootprintList;
SetItemCount(m_FullFootprintList.GetCount() ); SetItemCount( m_FullFootprintList.GetCount() );
} }
else else
{ {
m_UseFootprintFullList = FALSE; m_UseFootprintFullList = FALSE;
m_ActiveFootprintList = &m_FilteredFootprintList; m_ActiveFootprintList = &m_FilteredFootprintList;
SetItemCount(m_FilteredFootprintList.GetCount() ); SetItemCount( m_FilteredFootprintList.GetCount() );
} }
if ( Redraw ) if( Redraw )
{ {
if ( ! m_UseFootprintFullList || (m_UseFootprintFullList != old_selection) ) if( !m_UseFootprintFullList || (m_UseFootprintFullList != old_selection) )
{ {
Refresh(); Refresh();
} }
} }
if ( ! m_UseFootprintFullList || (m_UseFootprintFullList != old_selection) ) if( !m_UseFootprintFullList || (m_UseFootprintFullList != old_selection) )
{ {
m_Parent->SetStatusText(wxEmptyString,0); m_Parent->SetStatusText( wxEmptyString, 0 );
m_Parent->SetStatusText(wxEmptyString,1); m_Parent->SetStatusText( wxEmptyString, 1 );
} }
wxString msg; wxString msg;
if ( FullList ) if( FullList )
msg.Printf(_("Footprints (All): %d"), m_ActiveFootprintList->GetCount()); msg.Printf( _( "Footprints (All): %d" ), m_ActiveFootprintList->GetCount() );
else else
msg.Printf(_("Footprints (filtered): %d"), m_ActiveFootprintList->GetCount()); msg.Printf( _( "Footprints (filtered): %d" ), m_ActiveFootprintList->GetCount() );
m_Parent->SetStatusText(msg,2); m_Parent->SetStatusText( msg, 2 );
} }
/***********************************************************************/
/* Construction de la table des evenements pour la fenetre des modules */
/***********************************************************************/
BEGIN_EVENT_TABLE(FootprintListBox, LIST_BOX_TYPE) /**************************************/
EVT_SIZE( ListBoxBase::OnSize) /* Event table for the footprint list */
/**************************************/
BEGIN_EVENT_TABLE( FootprintListBox, LIST_BOX_TYPE )
EVT_SIZE( ListBoxBase::OnSize )
END_EVENT_TABLE() END_EVENT_TABLE()
/********************************************************/ /********************************************************/
void FootprintListBox::OnLeftClick(wxListEvent & event) void FootprintListBox::OnLeftClick( wxListEvent& event )
/********************************************************/ /********************************************************/
{ {
STOREMOD * Module; STOREMOD* Module;
wxString msg; wxString msg;
wxString FootprintName = GetSelectedFootprint(); wxString FootprintName = GetSelectedFootprint();
Module = GetModuleDescrByName(FootprintName); Module = GetModuleDescrByName( FootprintName );
if( m_Parent->DrawFrame ) if( m_Parent->DrawFrame )
{ {
m_Parent->CreateScreenCmp(); /* refresh general */ m_Parent->CreateScreenCmp(); /* refresh general */
} }
if ( Module ) msg = Module->m_Doc; if( Module )
m_Parent->SetStatusText(msg,0); msg = Module->m_Doc;
m_Parent->SetStatusText( msg, 0 );
msg = wxT("KeyW: "); msg = wxT( "KeyW: " );
if( Module ) msg += Module->m_KeyWord; if( Module )
m_Parent->SetStatusText(msg, 1); msg += Module->m_KeyWord;
m_Parent->SetStatusText( msg, 1 );
} }
/******************************************************/ /******************************************************/
void FootprintListBox::OnLeftDClick(wxListEvent & event) void FootprintListBox::OnLeftDClick( wxListEvent& event )
/******************************************************/ /******************************************************/
{ {
wxString FootprintName = GetSelectedFootprint(); wxString FootprintName = GetSelectedFootprint();
m_Parent->SetNewPkg(FootprintName); m_Parent->SetNewPkg( FootprintName );
} }
/**************************************************************/ /**************************************************************/
STOREMOD * GetModuleDescrByName(const wxString & FootprintName) STOREMOD* GetModuleDescrByName( const wxString& FootprintName )
/**************************************************************/ /**************************************************************/
{ {
STOREMOD * FootprintItem = g_BaseListePkg; STOREMOD* FootprintItem = g_BaseListePkg;
for ( ; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext ) for( ; FootprintItem != NULL; FootprintItem = FootprintItem->Pnext )
{ {
if( FootprintItem->m_Module == FootprintName) if( FootprintItem->m_Module == FootprintName )
break; // found ! break; // found !
} }
return FootprintItem; return FootprintItem;
} }
...@@ -1409,7 +1409,7 @@ class WinEDA_MsgPanel : public wxPanel ...@@ -1409,7 +1409,7 @@ class WinEDA_MsgPanel : public wxPanel
protected: protected:
std::vector<MsgItem> m_Items; std::vector<MsgItem> m_Items;
void showItem( wxWindowDC& dc, const MsgItem& aItem ); void showItem( wxDC& dc, const MsgItem& aItem );
public: public:
WinEDA_DrawFrame* m_Parent; WinEDA_DrawFrame* m_Parent;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment