Formatting.

This commit is contained in:
Jeff Young 2024-05-15 10:32:40 +01:00
parent ea4ade7350
commit fa78c24a16
3 changed files with 19 additions and 38 deletions

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -30,29 +30,25 @@
#include <cvpcb_id.h>
#include <cvpcb_mainframe.h>
#include <listboxes.h>
#include <tools/cvpcb_actions.h>
FOOTPRINTS_LISTBOX::FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ) :
ITEMS_LISTBOX_BASE( parent, id, wxDefaultPosition, wxDefaultSize, wxLC_SINGLE_SEL|wxNO_BORDER )
{
}
FOOTPRINTS_LISTBOX::~FOOTPRINTS_LISTBOX()
ITEMS_LISTBOX_BASE( parent, id, wxDefaultPosition, wxDefaultSize,
wxLC_SINGLE_SEL | wxNO_BORDER )
{
}
int FOOTPRINTS_LISTBOX::GetCount()
{
return m_footprintList.Count();
return (int) m_footprintList.Count();
}
void FOOTPRINTS_LISTBOX::SetString( unsigned linecount, const wxString& text )
{
unsigned count = m_footprintList.Count();
if( count > 0 )
{
if( linecount >= count )
@ -60,6 +56,7 @@ void FOOTPRINTS_LISTBOX::SetString( unsigned linecount, const wxString& text )
m_footprintList[linecount] = text;
}
UpdateWidth( linecount );
}
@ -81,15 +78,6 @@ wxString FOOTPRINTS_LISTBOX::GetSelectedFootprint()
}
void FOOTPRINTS_LISTBOX::AppendLine( const wxString& text )
{
m_footprintList.Add( text );
int lines = m_footprintList.Count();
SetItemCount( lines );
UpdateWidth( lines - 1 );
}
wxString FOOTPRINTS_LISTBOX::OnGetItemText( long item, long column ) const
{
if( item < 0 || item >= (long)m_footprintList.GetCount() )
@ -104,7 +92,7 @@ void FOOTPRINTS_LISTBOX::SetSelection( int aIndex, bool aState )
if( aIndex >= GetCount() )
aIndex = GetCount() - 1;
if(( aIndex >= 0) && ( GetCount() > 0) )
if( aIndex >= 0 && GetCount() > 0)
{
Select( aIndex, aState );
EnsureVisible( aIndex );
@ -249,7 +237,8 @@ void FOOTPRINTS_LISTBOX::OnChar( wxKeyEvent& event )
}
for( ; jj < text.Len(); jj++ )
{ // skip blanks
{
// skip blanks
if( text[jj] != ' ' )
break;
}

View File

@ -1,7 +1,7 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
@ -21,15 +21,9 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
/**
* @file library_listbox.cpp
* class to display used library and selecting it
*/
#include <trace_helpers.h>
#include <cvpcb_mainframe.h>
#include <listboxes.h>
#include <cvpcb_id.h>
#include <wx/log.h>
#include "lib_tree_model_adapter.h"
@ -40,25 +34,21 @@
/***************************************/
LIBRARY_LISTBOX::LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id ) :
ITEMS_LISTBOX_BASE( parent, id, wxDefaultPosition, wxDefaultSize, wxLC_SINGLE_SEL )
{
}
LIBRARY_LISTBOX::~LIBRARY_LISTBOX()
ITEMS_LISTBOX_BASE( parent, id, wxDefaultPosition, wxDefaultSize, wxLC_SINGLE_SEL )
{
}
int LIBRARY_LISTBOX::GetCount()
{
return m_libraryList.Count();
return (int) m_libraryList.Count();
}
void LIBRARY_LISTBOX::SetString( unsigned linecount, const wxString& text )
{
unsigned count = m_libraryList.Count();
if( count > 0 )
{
if( linecount >= count )
@ -129,11 +119,13 @@ void LIBRARY_LISTBOX::Finish()
}
}
void LIBRARY_LISTBOX::ClearList()
{
m_libraryList.clear();
}
BEGIN_EVENT_TABLE( LIBRARY_LISTBOX, ITEMS_LISTBOX_BASE )
EVT_CHAR( LIBRARY_LISTBOX::OnChar )
EVT_LIST_ITEM_SELECTED( ID_CVPCB_LIBRARY_LIST, LIBRARY_LISTBOX::OnSelectLibrary )
@ -180,7 +172,8 @@ void LIBRARY_LISTBOX::OnChar( wxKeyEvent& event )
}
for( ; jj < text.Len(); jj++ )
{ // skip blanks
{
// skip blanks
if( text[jj] != ' ' )
break;
}

View File

@ -98,13 +98,12 @@ public:
};
FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
~FOOTPRINTS_LISTBOX();
~FOOTPRINTS_LISTBOX() override {};
int GetCount();
void SetSelection( int aIndex, bool aState = true );
void SetSelectedFootprint( const LIB_ID& aFPID );
void SetString( unsigned linecount, const wxString& text );
void AppendLine( const wxString& text );
/**
* Populate the wxListCtrl with the footprints from \a aList that meet the filter
@ -144,7 +143,7 @@ class LIBRARY_LISTBOX : public ITEMS_LISTBOX_BASE
{
public:
LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
~LIBRARY_LISTBOX();
~LIBRARY_LISTBOX() override {};
int GetCount();
void SetSelection( int index, bool State = true );