2013-04-25 16:29:35 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2018-01-28 08:51:28 +00:00
|
|
|
* Copyright (C) 1992-2018 KiCad Developers, see AUTHORS.txt for contributors.
|
2013-04-25 16:29:35 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2018-01-28 08:51:28 +00:00
|
|
|
* @file listboxes.h
|
2013-04-25 16:29:35 +00:00
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2018-01-28 08:51:28 +00:00
|
|
|
#ifndef LISTBOXES_H
|
|
|
|
#define LISTBOXES_H
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <wx/listctrl.h>
|
2017-03-23 00:59:25 +00:00
|
|
|
#include <footprint_filter.h>
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
/* Forward declarations of all top-level window classes. */
|
2011-02-05 16:15:48 +00:00
|
|
|
class CVPCB_MAINFRAME;
|
2013-04-25 16:29:35 +00:00
|
|
|
class COMPONENT;
|
2013-05-31 17:33:46 +00:00
|
|
|
class FOOTPRINT_LIST;
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2018-08-02 17:00:41 +00:00
|
|
|
#define LISTBOX_STYLE ( wxBORDER_SIMPLE | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL | \
|
2015-06-05 13:46:05 +00:00
|
|
|
wxVSCROLL | wxHSCROLL )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
/*********************************************************************/
|
|
|
|
/* ListBox (base class) to display lists of components or footprints */
|
|
|
|
/*********************************************************************/
|
|
|
|
class ITEMS_LISTBOX_BASE : public wxListView
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2011-02-05 16:15:48 +00:00
|
|
|
ITEMS_LISTBOX_BASE( CVPCB_MAINFRAME* aParent, wxWindowID aId,
|
2012-09-26 15:36:48 +00:00
|
|
|
const wxPoint& aLocation, const wxSize& aSize,
|
2015-06-05 13:46:05 +00:00
|
|
|
long aStyle = 0 );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
~ITEMS_LISTBOX_BASE();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2015-07-01 10:55:41 +00:00
|
|
|
/**
|
|
|
|
* @return the index of the selected item in lists allowing only one item selected
|
|
|
|
* and the index of the first selected item in lists allowing many selection
|
|
|
|
*/
|
2013-06-06 15:37:48 +00:00
|
|
|
int GetSelection();
|
2009-05-21 17:42:42 +00:00
|
|
|
|
2015-07-01 10:55:41 +00:00
|
|
|
/**
|
|
|
|
* Removes all selection in lists which can have more than one item selected
|
|
|
|
*/
|
|
|
|
void DeselectAll();
|
|
|
|
|
2014-05-04 17:08:36 +00:00
|
|
|
virtual CVPCB_MAINFRAME* GetParent() const;
|
2014-11-12 10:46:40 +00:00
|
|
|
|
|
|
|
/* Function UpdateWidth
|
|
|
|
*
|
|
|
|
* Update the width of the column based on its contents.
|
|
|
|
*
|
|
|
|
* @param aLine is the line to calculate the width from. If positive, the
|
|
|
|
* width will only be increased if needed. If negative, we start from
|
|
|
|
* scratch and all lines are considered, i.e., the column may be shrunk.
|
|
|
|
*/
|
|
|
|
void UpdateWidth( int aLine = -1 );
|
|
|
|
|
|
|
|
private:
|
|
|
|
void UpdateLineWidth( unsigned aLine );
|
|
|
|
|
|
|
|
int columnWidth;
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
/******************************************/
|
|
|
|
/* ListBox showing the list of footprints */
|
|
|
|
/******************************************/
|
|
|
|
class FOOTPRINTS_LISTBOX : public ITEMS_LISTBOX_BASE
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
private:
|
2013-06-06 15:37:48 +00:00
|
|
|
wxArrayString m_footprintList;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
public:
|
2017-03-23 00:59:25 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Filter setting constants. The filter type is a bitwise OR of these flags,
|
|
|
|
* and only footprints matching all selected filter types are shown.
|
|
|
|
*/
|
|
|
|
enum FP_FILTER_T: int
|
2013-06-06 15:37:48 +00:00
|
|
|
{
|
2016-02-25 09:52:29 +00:00
|
|
|
UNFILTERED_FP_LIST = 0,
|
|
|
|
FILTERING_BY_COMPONENT_KEYWORD = 0x0001,
|
|
|
|
FILTERING_BY_PIN_COUNT = 0x0002,
|
|
|
|
FILTERING_BY_LIBRARY = 0x0004,
|
|
|
|
FILTERING_BY_NAME = 0x0008
|
2013-06-06 15:37:48 +00:00
|
|
|
};
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
|
2013-06-06 15:37:48 +00:00
|
|
|
const wxPoint& loc, const wxSize& size );
|
2009-08-20 11:44:06 +00:00
|
|
|
~FOOTPRINTS_LISTBOX();
|
|
|
|
|
|
|
|
int GetCount();
|
2014-06-04 17:34:23 +00:00
|
|
|
void SetSelection( int index, bool State = true );
|
2009-08-20 11:44:06 +00:00
|
|
|
void SetString( unsigned linecount, const wxString& text );
|
|
|
|
void AppendLine( const wxString& text );
|
2013-04-25 16:29:35 +00:00
|
|
|
|
|
|
|
/**
|
2013-06-06 15:37:48 +00:00
|
|
|
* Function SetFootprints
|
|
|
|
* populates the wxListCtrl with the footprints from \a aList that meet the filter
|
|
|
|
* criteria defined by \a aFilterType.
|
|
|
|
*
|
|
|
|
* @param aList is a #FOOTPRINT_LIST item containing the footprints.
|
|
|
|
* @param aLibName is wxString containing the name of the selected library. Can be
|
|
|
|
* wxEmptyString.
|
|
|
|
* @param aComponent is the #COMPONENT used by the filtering criteria. Can be NULL.
|
2016-02-25 13:57:59 +00:00
|
|
|
* @param aFootPrintFilterPattern = a filter used to filter list by names
|
2013-06-06 15:37:48 +00:00
|
|
|
* @param aFilterType defines the criteria to filter \a aList.
|
2013-04-25 16:29:35 +00:00
|
|
|
*/
|
2013-06-06 15:37:48 +00:00
|
|
|
void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName,
|
2016-02-25 13:57:59 +00:00
|
|
|
COMPONENT* aComponent, const wxString &aFootPrintFilterPattern, int aFilterType );
|
2009-08-20 11:44:06 +00:00
|
|
|
|
|
|
|
wxString GetSelectedFootprint();
|
2013-06-06 15:37:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnGetItemText
|
|
|
|
* this overloaded function MUST be provided for the wxLC_VIRTUAL mode
|
|
|
|
* because real data is not handled by ITEMS_LISTBOX_BASE
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString OnGetItemText( long item, long column ) const override;
|
2009-08-20 11:44:06 +00:00
|
|
|
|
|
|
|
// Events functions:
|
|
|
|
void OnLeftClick( wxListEvent& event );
|
|
|
|
void OnLeftDClick( wxListEvent& event );
|
2013-05-31 17:33:46 +00:00
|
|
|
void OnChar( wxKeyEvent& event );
|
2013-04-25 16:29:35 +00:00
|
|
|
|
2013-05-31 17:33:46 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
|
|
|
};
|
|
|
|
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2013-05-31 17:33:46 +00:00
|
|
|
/******************************************/
|
|
|
|
/* ListBox showing the list of library */
|
|
|
|
/******************************************/
|
|
|
|
class LIBRARY_LISTBOX : public ITEMS_LISTBOX_BASE
|
|
|
|
{
|
2013-06-06 15:37:48 +00:00
|
|
|
wxArrayString m_libraryList;
|
2013-05-31 17:33:46 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
|
2013-06-06 15:37:48 +00:00
|
|
|
const wxPoint& loc, const wxSize& size );
|
2013-05-31 17:33:46 +00:00
|
|
|
~LIBRARY_LISTBOX();
|
|
|
|
|
|
|
|
int GetCount();
|
2014-06-04 17:34:23 +00:00
|
|
|
void SetSelection( int index, bool State = true );
|
2013-05-31 17:33:46 +00:00
|
|
|
void SetString( unsigned linecount, const wxString& text );
|
|
|
|
void AppendLine( const wxString& text );
|
2013-06-06 15:37:48 +00:00
|
|
|
void SetLibraryList( const wxArrayString& aList );
|
2013-05-31 17:33:46 +00:00
|
|
|
|
|
|
|
wxString GetSelectedLibrary();
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString OnGetItemText( long item, long column ) const override;
|
2013-05-31 17:33:46 +00:00
|
|
|
|
|
|
|
// Events functions:
|
|
|
|
void OnLeftClick( wxListEvent& event );
|
2013-06-06 15:37:48 +00:00
|
|
|
|
|
|
|
void OnSelectLibrary( wxListEvent& event );
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnChar
|
|
|
|
* called on a key pressed
|
|
|
|
* Call default handler for some special keys,
|
|
|
|
* and for "ascii" keys, select the first footprint
|
|
|
|
* that the name starts by the letter.
|
|
|
|
* This is the defaut behaviour of a listbox, but because we use
|
|
|
|
* virtual lists, the listbox does not know anything to what is displayed,
|
|
|
|
* we must handle this behaviour here.
|
|
|
|
* Furthermore the footprint name is not at the beginning of
|
|
|
|
* displayed lines (the first word is the line number)
|
|
|
|
*/
|
2009-08-20 11:44:06 +00:00
|
|
|
void OnChar( wxKeyEvent& event );
|
2008-04-17 16:25:29 +00:00
|
|
|
|
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
2013-06-06 15:37:48 +00:00
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
/****************************************************/
|
|
|
|
/* ListBox showing the list of schematic components */
|
|
|
|
/****************************************************/
|
|
|
|
class COMPONENTS_LISTBOX : public ITEMS_LISTBOX_BASE
|
2007-05-06 16:03:28 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-04-17 16:25:29 +00:00
|
|
|
wxArrayString m_ComponentList;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
public:
|
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
|
2013-06-06 15:37:48 +00:00
|
|
|
const wxPoint& loc, const wxSize& size );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
~COMPONENTS_LISTBOX();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-08-20 11:44:06 +00:00
|
|
|
void Clear();
|
|
|
|
int GetCount();
|
2013-06-06 15:37:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnGetItemText
|
|
|
|
* this overloaded function MUST be provided for the wxLC_VIRTUAL mode
|
|
|
|
* because real data is not handled by ITEMS_LISTBOX_BASE
|
|
|
|
*/
|
2016-09-24 18:53:15 +00:00
|
|
|
wxString OnGetItemText( long item, long column ) const override;
|
2013-06-06 15:37:48 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Enable or disable an item
|
|
|
|
*/
|
2014-06-04 17:34:23 +00:00
|
|
|
void SetSelection( int index, bool State = true );
|
2009-08-20 11:44:06 +00:00
|
|
|
void SetString( unsigned linecount, const wxString& text );
|
|
|
|
void AppendLine( const wxString& text );
|
|
|
|
|
|
|
|
// Events functions:
|
2013-06-06 15:37:48 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Function OnChar
|
|
|
|
* called on a key pressed
|
|
|
|
* Call default handler for some special keys,
|
|
|
|
* and for "ascii" keys, select the first component
|
|
|
|
* that the name starts by the letter.
|
|
|
|
* This is the default behavior of a listbox, but because we use
|
|
|
|
* virtual lists, the listbox does not know anything to what is displayed,
|
|
|
|
* we must handle this behavior here.
|
|
|
|
* Furthermore the reference of components is not at the beginning of
|
|
|
|
* displayed lines (the first word is the line number)
|
|
|
|
*/
|
2009-08-20 11:44:06 +00:00
|
|
|
void OnChar( wxKeyEvent& event );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-06-06 15:37:48 +00:00
|
|
|
void OnSelectComponent( wxListEvent& event );
|
|
|
|
|
2008-04-17 16:25:29 +00:00
|
|
|
DECLARE_EVENT_TABLE()
|
2007-05-06 16:03:28 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2018-01-28 08:51:28 +00:00
|
|
|
#endif //#ifndef LISTBOXES_H
|