KiCad PCB EDA Suite
listboxes.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, you may find one here:
18  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19  * or you may search the http://www.gnu.org website for the version 2 license,
20  * or you may write to the Free Software Foundation, Inc.,
21  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22  */
23 
24 #ifndef LISTBOXES_H
25 #define LISTBOXES_H
26 
27 #include <wx/listctrl.h>
28 #include <footprint_filter.h>
29 
30 /* Forward declarations of all top-level window classes. */
31 class CVPCB_MAINFRAME;
32 class COMPONENT;
33 class FOOTPRINT_LIST;
34 
35 #define LISTBOX_STYLE ( wxBORDER_NONE | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL | \
36  wxVSCROLL | wxHSCROLL )
37 
41 class ITEMS_LISTBOX_BASE : public wxListView
42 {
43 public:
44  ITEMS_LISTBOX_BASE( CVPCB_MAINFRAME* aParent, wxWindowID aId,
45  const wxPoint& aLocation = wxDefaultPosition,
46  const wxSize& aSize = wxDefaultSize, long aStyle = 0 );
47 
49 
54  int GetSelection();
55 
59  void DeselectAll();
60 
61  virtual CVPCB_MAINFRAME* GetParent() const;
62 
70  void UpdateWidth( int aLine = -1 );
71 
72 private:
78  void UpdateLineWidth( unsigned aLine );
79 
81 };
82 
83 
85 {
86 public:
91  enum FP_FILTER_T: int
92  {
97  };
98 
99  FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
101 
102  int GetCount();
103  void SetSelection( int index, bool State = true );
104  void SetSelectedFootprint( const LIB_ID& aFPID );
105  void SetString( unsigned linecount, const wxString& text );
106  void AppendLine( const wxString& text );
107 
119  void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName, COMPONENT* aComponent,
120  const wxString& aFootPrintFilterPattern, int aFilterType );
121 
122  wxString GetSelectedFootprint();
123 
128  wxString OnGetItemText( long item, long column ) const override;
129 
130  // Events functions:
131  void OnLeftClick( wxListEvent& event );
132  void OnLeftDClick( wxListEvent& event );
133  void OnChar( wxKeyEvent& event );
134 
136 
137 private:
138  wxArrayString m_footprintList;
139 };
140 
141 
143 {
144 public:
145  LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
147 
148  int GetCount();
149  void SetSelection( int index, bool State = true );
150  void SetString( unsigned linecount, const wxString& text );
151  void AppendLine( const wxString& text );
152  void SetLibraryList( const wxArrayString& aList );
153 
154  wxString GetSelectedLibrary();
155  wxString OnGetItemText( long item, long column ) const override;
156 
157  void OnSelectLibrary( wxListEvent& event );
158 
170  void OnChar( wxKeyEvent& event );
171 
173 
174 private:
175  wxArrayString m_libraryList;
176 };
177 
178 
180 {
181 public:
182  SYMBOLS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
183 
185 
186  void Clear();
187  int GetCount();
188 
193  wxString OnGetItemText( long item, long column ) const override;
194 
195  /*
196  * Enable or disable an item
197  */
198  void SetSelection( int index, bool State = true );
199  void SetString( unsigned linecount, const wxString& text );
200  void AppendLine( const wxString& text );
201 
202  // Events functions:
203 
215  void OnChar( wxKeyEvent& event );
216 
217  void OnSelectComponent( wxListEvent& event );
218 
220 
221 public:
222  wxArrayString m_SymbolList;
223 };
224 
225 
226 #endif //#ifndef LISTBOXES_H
void SetLibraryList(const wxArrayString &aList)
void OnChar(wxKeyEvent &event)
void AppendLine(const wxString &text)
void AppendLine(const wxString &text)
void OnSelectComponent(wxListEvent &event)
void SetSelectedFootprint(const LIB_ID &aFPID)
void SetSelection(int index, bool State=true)
void DeselectAll()
Remove all selection in lists which can have more than one item selected.
void SetString(unsigned linecount, const wxString &text)
void OnLeftDClick(wxListEvent &event)
void OnChar(wxKeyEvent &event)
Called on a key press.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
void SetString(unsigned linecount, const wxString &text)
Base class to display symbol and footprint lists.
Definition: listboxes.h:41
wxString OnGetItemText(long item, long column) const override
void OnSelectLibrary(wxListEvent &event)
wxString OnGetItemText(long item, long column) const override
This overloaded function MUST be provided for the wxLC_VIRTUAL mode because real data is not handled ...
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:91
void UpdateWidth(int aLine=-1)
Update the width of the column based on its contents.
wxArrayString m_footprintList
Definition: listboxes.h:138
void SetString(unsigned linecount, const wxString &text)
wxArrayString m_SymbolList
Definition: listboxes.h:222
wxString GetSelectedLibrary()
SYMBOLS_LISTBOX(CVPCB_MAINFRAME *parent, wxWindowID id)
wxString OnGetItemText(long item, long column) const override
This overloaded function MUST be provided for the wxLC_VIRTUAL mode because real data is not handled ...
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:84
void SetSelection(int index, bool State=true)
FOOTPRINTS_LISTBOX(CVPCB_MAINFRAME *parent, wxWindowID id)
void AppendLine(const wxString &text)
void UpdateLineWidth(unsigned aLine)
Calculate the width of the given line, and increase the column width if needed.
ITEMS_LISTBOX_BASE(CVPCB_MAINFRAME *aParent, wxWindowID aId, const wxPoint &aLocation=wxDefaultPosition, const wxSize &aSize=wxDefaultSize, long aStyle=0)
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
LIBRARY_LISTBOX(CVPCB_MAINFRAME *parent, wxWindowID id)
wxArrayString m_libraryList
Definition: listboxes.h:175
void SetSelection(int index, bool State=true)
void OnChar(wxKeyEvent &event)
Called on a key press.
void SetFootprints(FOOTPRINT_LIST &aList, const wxString &aLibName, COMPONENT *aComponent, const wxString &aFootPrintFilterPattern, int aFilterType)
Populate the wxListCtrl with the footprints from aList that meet the filter criteria defined by aFilt...
void OnLeftClick(wxListEvent &event)
The CvPcb application main window.
virtual CVPCB_MAINFRAME * GetParent() const