コード例 #1
0
ファイル: viewlibs.cpp プロジェクト: james-sakalaukus/kicad
void LIB_VIEW_FRAME::ViewOneLibraryContent( CMP_LIBRARY* Lib, int Flag )
{
    int        NumOfParts = 0;
    LIB_ALIAS* LibEntry;
    wxString   CmpName;

    if( Lib )
        NumOfParts = Lib->GetCount();

    if( NumOfParts == 0 )
    {
        DisplayError( this, wxT( "No library or library is empty!" ) );
        return;
    }

    if( Lib == NULL )
        return;

    if( Flag == NEW_PART )
    {
        DisplayComponentsNamesInLib( this, Lib, CmpName, m_entryName );
    }

    if( Flag == NEXT_PART )
    {
        LibEntry = Lib->GetNextEntry( m_entryName );

        if( LibEntry )
            CmpName = LibEntry->GetName();
    }

    if( Flag == PREVIOUS_PART )
    {
        LibEntry = Lib->GetPreviousEntry( m_entryName );

        if( LibEntry )
            CmpName = LibEntry->GetName();
    }

    m_unit    = 1;
    m_convert = 1;

    LibEntry = Lib->FindEntry( CmpName );
    m_entryName = CmpName;
    DisplayLibInfos();
    Zoom_Automatique( false );
    m_canvas->Refresh( );

    if( m_CmpList )
    {
        int id = m_CmpList->FindString( m_entryName.GetData() );
        if( id >= 0 )
            m_CmpList->SetSelection( id );
    }
    ReCreateHToolbar();
}
コード例 #2
0
void WinEDA_ViewlibFrame::ViewOneLibraryContent(LibraryStruct *Lib, int Flag)
{
int NumOfParts = 0;
EDA_LibComponentStruct *LibEntry, * PreviousLibEntry;
wxString CmpName;
wxClientDC dc(DrawPanel);


	DrawPanel->PrepareGraphicContext(&dc);

	if (Lib) NumOfParts = Lib->m_NumOfParts;

	if (NumOfParts == 0)
		{
		DisplayError(this, wxT("No Library or Library is empty!"));
		return;
		}

	if ( Lib == NULL ) return;

	PQCompFunc((PQCompFuncType) LibraryEntryCompare);
	LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE);

	if( Flag == NEW_PART )
		{
		DisplayComponentsNamesInLib(this, Lib, CmpName, g_CurrentViewComponentName);
		}

	if( Flag == NEXT_PART )
		{
		LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE);
		while ( LibEntry )
			{
			if( LibEntry->m_Name.m_Text == g_CurrentViewComponentName )
				{
				LibEntry = (EDA_LibComponentStruct *)
					PQNext(Lib->m_Entries, LibEntry, NULL);
				break;
				}
			LibEntry = (EDA_LibComponentStruct *)
					PQNext(Lib->m_Entries, LibEntry, NULL);
			}
		if(LibEntry == NULL)
				LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE);
		if( LibEntry ) CmpName = LibEntry->m_Name.m_Text;
		}

	if( Flag == PREVIOUS_PART )
		{
		PreviousLibEntry = NULL;
		LibEntry = (EDA_LibComponentStruct *) PQFirst(&Lib->m_Entries, FALSE);
		while ( LibEntry )
			{
			if( LibEntry->m_Name.m_Text == g_CurrentViewComponentName )
				{
				if( PreviousLibEntry ) break;
				/* else : pointage sur 1er element :
				balayage de la liste et Previous pointera dernier element */
				}

			PreviousLibEntry = LibEntry;
			LibEntry = (EDA_LibComponentStruct *)
					PQNext(Lib->m_Entries, LibEntry, NULL);
			}
		if( PreviousLibEntry )
			CmpName = PreviousLibEntry->m_Name.m_Text;
		}

	g_ViewUnit = 1;
	g_ViewConvert = 1;

	LibEntry = FindLibPart(CmpName,Lib->m_Name, FIND_ALIAS);
	g_CurrentViewComponentName = CmpName;
	DisplayLibInfos();
	Zoom_Automatique(FALSE);
	RedrawActiveWindow(&dc, TRUE);

	if ( m_CmpList )
		{
		int id = m_CmpList->FindString(g_CurrentViewComponentName.GetData());
		if ( id >= 0 ) m_CmpList->SetSelection(id);
		}
	ReCreateHToolbar();
}