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-2018 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 
28 #ifndef LISTBOXES_H
29 #define LISTBOXES_H
30 
31 #include <wx/listctrl.h>
32 #include <footprint_filter.h>
33 
34 /* Forward declarations of all top-level window classes. */
35 class CVPCB_MAINFRAME;
36 class COMPONENT;
37 class FOOTPRINT_LIST;
38 
39 #define LISTBOX_STYLE ( wxBORDER_NONE | wxLC_NO_HEADER | wxLC_REPORT | wxLC_VIRTUAL | \
40  wxVSCROLL | wxHSCROLL )
41 
42 /*********************************************************************/
43 /* ListBox (base class) to display lists of components or footprints */
44 /*********************************************************************/
45 class ITEMS_LISTBOX_BASE : public wxListView
46 {
47 public:
48  ITEMS_LISTBOX_BASE( CVPCB_MAINFRAME* aParent, wxWindowID aId,
49  const wxPoint& aLocation, const wxSize& aSize,
50  long aStyle = 0 );
51 
53 
58  int GetSelection();
59 
63  void DeselectAll();
64 
65  virtual CVPCB_MAINFRAME* GetParent() const;
66 
67  /* Function UpdateWidth
68  *
69  * Update the width of the column based on its contents.
70  *
71  * @param aLine is the line to calculate the width from. If positive, the
72  * width will only be increased if needed. If negative, we start from
73  * scratch and all lines are considered, i.e., the column may be shrunk.
74  */
75  void UpdateWidth( int aLine = -1 );
76 
77 private:
78  void UpdateLineWidth( unsigned aLine );
79 
81 };
82 
83 
84 /******************************************/
85 /* ListBox showing the list of footprints */
86 /******************************************/
88 {
89 private:
90  wxArrayString m_footprintList;
91 
92 public:
93 
98  enum FP_FILTER_T: int
99  {
100  UNFILTERED_FP_LIST = 0,
101  FILTERING_BY_COMPONENT_KEYWORD = 0x0001,
102  FILTERING_BY_PIN_COUNT = 0x0002,
103  FILTERING_BY_LIBRARY = 0x0004,
104  FILTERING_BY_NAME = 0x0008
105  };
106 
107  FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
108  const wxPoint& loc, const wxSize& size );
110 
111  int GetCount();
112  void SetSelection( int index, bool State = true );
113  void SetSelectedFootprint( const LIB_ID& aFPID );
114  void SetString( unsigned linecount, const wxString& text );
115  void AppendLine( const wxString& text );
116 
129  void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName,
130  COMPONENT* aComponent, const wxString &aFootPrintFilterPattern, int aFilterType );
131 
132  wxString GetSelectedFootprint();
133 
139  wxString OnGetItemText( long item, long column ) const override;
140 
141  // Events functions:
142  void OnLeftClick( wxListEvent& event );
143  void OnLeftDClick( wxListEvent& event );
144  void OnChar( wxKeyEvent& event );
145 
146  DECLARE_EVENT_TABLE()
147 };
148 
149 
150 /******************************************/
151 /* ListBox showing the list of library */
152 /******************************************/
154 {
155  wxArrayString m_libraryList;
156 
157 public:
158  LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
159  const wxPoint& loc, const wxSize& size );
160  ~LIBRARY_LISTBOX();
161 
162  int GetCount();
163  void SetSelection( int index, bool State = true );
164  void SetString( unsigned linecount, const wxString& text );
165  void AppendLine( const wxString& text );
166  void SetLibraryList( const wxArrayString& aList );
167 
168  wxString GetSelectedLibrary();
169  wxString OnGetItemText( long item, long column ) const override;
170 
171  // Events functions:
172  void OnLeftClick( wxListEvent& event );
173 
174  void OnSelectLibrary( wxListEvent& event );
175 
188  void OnChar( wxKeyEvent& event );
189 
190  DECLARE_EVENT_TABLE()
191 };
192 
193 
194 /****************************************************/
195 /* ListBox showing the list of schematic components */
196 /****************************************************/
198 {
199 public:
200  wxArrayString m_ComponentList;
201 
202 public:
203 
204  COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
205  const wxPoint& loc, const wxSize& size );
206 
208 
209  void Clear();
210  int GetCount();
211 
217  wxString OnGetItemText( long item, long column ) const override;
218 
219  /*
220  * Enable or disable an item
221  */
222  void SetSelection( int index, bool State = true );
223  void SetString( unsigned linecount, const wxString& text );
224  void AppendLine( const wxString& text );
225 
226  // Events functions:
227 
240  void OnChar( wxKeyEvent& event );
241 
242  void OnSelectComponent( wxListEvent& event );
243 
244  DECLARE_EVENT_TABLE()
245 };
246 
247 
248 #endif //#ifndef LISTBOXES_H
ITEMS_LISTBOX_BASE(CVPCB_MAINFRAME *aParent, wxWindowID aId, const wxPoint &aLocation, const wxSize &aSize, long aStyle=0)
void DeselectAll()
Removes all selection in lists which can have more than one item selected.
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:98
void UpdateWidth(int aLine=-1)
wxArrayString m_footprintList
Definition: listboxes.h:90
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
wxArrayString m_ComponentList
Definition: listboxes.h:200
void UpdateLineWidth(unsigned aLine)
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
wxArrayString m_libraryList
Definition: listboxes.h:155
virtual CVPCB_MAINFRAME * GetParent() const
The CvPcb application main window.