2009-02-04 15:25:03 +00:00
|
|
|
/****************************/
|
2009-08-27 11:41:56 +00:00
|
|
|
/* EESchema - database.cpp */
|
2009-02-04 15:25:03 +00:00
|
|
|
/****************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
/* Routine de selection d'un composant en librairie
|
2009-02-04 15:25:03 +00:00
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "gr_basic.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "eda_doc.h"
|
|
|
|
#include "kicad_string.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "program.h"
|
|
|
|
#include "libcmp.h"
|
|
|
|
#include "general.h"
|
|
|
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2009-02-04 15:25:03 +00:00
|
|
|
* Routine de selection du nom d'un composant en librairie pour chargement,
|
|
|
|
* Keys pointe la liste des mots cles de filtrage
|
|
|
|
* Si Keys = "", recherche des composants qui correspondent
|
|
|
|
* au masque BufName( avec * et ? )
|
|
|
|
*
|
|
|
|
* Retourne
|
|
|
|
* TRUE si composant selectionne
|
|
|
|
* FALSE si commande annulee
|
|
|
|
* place le nom du composant a charger, selectionne a partir d'une liste dans
|
|
|
|
* BufName
|
|
|
|
*/
|
2009-08-27 11:41:56 +00:00
|
|
|
wxString DataBaseGetName( WinEDA_DrawFrame* frame, wxString& Keys,
|
|
|
|
wxString& BufName )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-08-27 11:41:56 +00:00
|
|
|
LibraryStruct* Lib;
|
|
|
|
wxArrayString nameList;
|
|
|
|
wxString msg;
|
2009-02-04 15:25:03 +00:00
|
|
|
|
|
|
|
BufName.MakeUpper();
|
|
|
|
Keys.MakeUpper();
|
|
|
|
|
|
|
|
/* Examen de la liste des librairies pour comptage */
|
2009-08-27 11:41:56 +00:00
|
|
|
for( Lib = g_LibraryList; Lib != NULL; Lib = Lib->m_Pnext )
|
2009-02-04 15:25:03 +00:00
|
|
|
{
|
2009-08-27 11:41:56 +00:00
|
|
|
Lib->SearchEntryNames( nameList, BufName, Keys );
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
if( nameList.IsEmpty() )
|
2009-02-04 15:25:03 +00:00
|
|
|
{
|
2009-08-27 11:41:56 +00:00
|
|
|
msg = _( "No components found matching " );
|
|
|
|
if( !BufName.IsEmpty() )
|
2009-02-04 15:25:03 +00:00
|
|
|
{
|
2009-08-27 11:41:56 +00:00
|
|
|
msg += _( "name search criteria <" ) + BufName + wxT( "> " );
|
2009-02-04 15:25:03 +00:00
|
|
|
if( !Keys.IsEmpty() )
|
2009-08-27 11:41:56 +00:00
|
|
|
msg += _( "and " );
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
if( !Keys.IsEmpty() )
|
|
|
|
msg += _( "key search criteria <" ) + Keys + wxT( "> " );
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
DisplayError( frame, msg );
|
|
|
|
|
|
|
|
return wxEmptyString;
|
2009-02-04 15:25:03 +00:00
|
|
|
}
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
wxSingleChoiceDialog dlg( frame, wxEmptyString, _( "Select Component" ),
|
|
|
|
nameList );
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
if( dlg.ShowModal() == wxID_CANCEL || dlg.GetStringSelection().IsEmpty() )
|
|
|
|
return wxEmptyString;
|
|
|
|
|
|
|
|
return dlg.GetStringSelection();
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
void DisplayCmpDoc( wxString& Name )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-09-02 18:12:45 +00:00
|
|
|
LibCmpEntry* CmpEntry = NULL;
|
|
|
|
LibraryStruct* Lib = g_LibraryList;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
while( Lib != NULL && CmpEntry == NULL )
|
|
|
|
{
|
|
|
|
CmpEntry = Lib->FindEntry( Name );
|
|
|
|
Lib = Lib->m_Pnext;
|
|
|
|
}
|
2009-08-27 11:41:56 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
if( CmpEntry == NULL )
|
|
|
|
return;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-09-02 18:12:45 +00:00
|
|
|
wxLogDebug( wxT( "Selected component <%s>, m_Doc: <%s>, m_KeyWord: <%s>." ),
|
|
|
|
(const wxChar*) Name, (const wxChar*) CmpEntry->m_Doc,
|
|
|
|
(const wxChar*) CmpEntry->m_KeyWord );
|
|
|
|
|
2009-08-27 11:41:56 +00:00
|
|
|
Name = wxT( "Description: " ) + CmpEntry->m_Doc;
|
|
|
|
Name += wxT( "\nKey Words: " ) + CmpEntry->m_KeyWord;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|