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 
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 
38 /*********************************************************************/
39 /* ListBox (base class) to display lists of components or footprints */
40 /*********************************************************************/
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 
63  /* Function UpdateWidth
64  *
65  * Update the width of the column based on its contents.
66  *
67  * @param aLine is the line to calculate the width from. If positive, the
68  * width will only be increased if needed. If negative, we start from
69  * scratch and all lines are considered, i.e., the column may be shrunk.
70  */
71  void UpdateWidth( int aLine = -1 );
72 
73 private:
74  void UpdateLineWidth( unsigned aLine );
75 
77 };
78 
79 
80 /******************************************/
81 /* ListBox showing the list of footprints */
82 /******************************************/
84 {
85 private:
86  wxArrayString m_footprintList;
87 
88 public:
89 
94  enum FP_FILTER_T: int
95  {
100  };
101 
102  FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
104 
105  int GetCount();
106  void SetSelection( int index, bool State = true );
107  void SetSelectedFootprint( const LIB_ID& aFPID );
108  void SetString( unsigned linecount, const wxString& text );
109  void AppendLine( const wxString& text );
110 
123  void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName, COMPONENT* aComponent,
124  const wxString &aFootPrintFilterPattern, int aFilterType );
125 
126  wxString GetSelectedFootprint();
127 
133  wxString OnGetItemText( long item, long column ) const override;
134 
135  // Events functions:
136  void OnLeftClick( wxListEvent& event );
137  void OnLeftDClick( wxListEvent& event );
138  void OnChar( wxKeyEvent& event );
139 
140  DECLARE_EVENT_TABLE()
141 };
142 
143 
144 /******************************************/
145 /* ListBox showing the list of library */
146 /******************************************/
148 {
149  wxArrayString m_libraryList;
150 
151 public:
152  LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
154 
155  int GetCount();
156  void SetSelection( int index, bool State = true );
157  void SetString( unsigned linecount, const wxString& text );
158  void AppendLine( const wxString& text );
159  void SetLibraryList( const wxArrayString& aList );
160 
161  wxString GetSelectedLibrary();
162  wxString OnGetItemText( long item, long column ) const override;
163 
164  // Events functions:
165  void OnLeftClick( wxListEvent& event );
166 
167  void OnSelectLibrary( wxListEvent& event );
168 
181  void OnChar( wxKeyEvent& event );
182 
183  DECLARE_EVENT_TABLE()
184 };
185 
186 
187 /****************************************************/
188 /* ListBox showing the list of schematic components */
189 /****************************************************/
191 {
192 public:
193  wxArrayString m_ComponentList;
194 
195 public:
196 
197  COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
198 
200 
201  void Clear();
202  int GetCount();
203 
209  wxString OnGetItemText( long item, long column ) const override;
210 
211  /*
212  * Enable or disable an item
213  */
214  void SetSelection( int index, bool State = true );
215  void SetString( unsigned linecount, const wxString& text );
216  void AppendLine( const wxString& text );
217 
218  // Events functions:
219 
232  void OnChar( wxKeyEvent& event );
233 
234  void OnSelectComponent( wxListEvent& event );
235 
236  DECLARE_EVENT_TABLE()
237 };
238 
239 
240 #endif //#ifndef LISTBOXES_H
void SetLibraryList(const wxArrayString &aList)
void OnChar(wxKeyEvent &event)
void AppendLine(const wxString &text)
void OnChar(wxKeyEvent &event)
Function OnChar called on a key pressed Call default handler for some special keys,...
void SetSelectedFootprint(const LIB_ID &aFPID)
void DeselectAll()
Removes all selection in lists which can have more than one item selected.
void SetSelection(int index, bool State=true)
void OnLeftDClick(wxListEvent &event)
void OnChar(wxKeyEvent &event)
Function OnChar called on a key pressed Call default handler for some special keys,...
A logical library item identifier and consists of various portions much like a URI.
Definition: lib_id.h:51
wxString OnGetItemText(long item, long column) const override
Function OnGetItemText this overloaded function MUST be provided for the wxLC_VIRTUAL mode because re...
void SetString(unsigned linecount, const wxString &text)
void AppendLine(const wxString &text)
wxString OnGetItemText(long item, long column) const override
void OnSelectLibrary(wxListEvent &event)
FP_FILTER_T
Filter setting constants.
Definition: listboxes.h:94
void UpdateWidth(int aLine=-1)
wxArrayString m_footprintList
Definition: listboxes.h:86
void SetString(unsigned linecount, const wxString &text)
wxString GetSelectedLibrary()
wxString OnGetItemText(long item, long column) const override
Function OnGetItemText this overloaded function MUST be provided for the wxLC_VIRTUAL mode because re...
Store all of the related footprint information found in a netlist.
Definition: pcb_netlist.h:83
void SetSelection(int index, bool State=true)
FOOTPRINTS_LISTBOX(CVPCB_MAINFRAME *parent, wxWindowID id)
void AppendLine(const wxString &text)
wxArrayString m_ComponentList
Definition: listboxes.h:193
void UpdateLineWidth(unsigned aLine)
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:149
void SetSelection(int index, bool State=true)
void SetString(unsigned linecount, const wxString &text)
void SetFootprints(FOOTPRINT_LIST &aList, const wxString &aLibName, COMPONENT *aComponent, const wxString &aFootPrintFilterPattern, int aFilterType)
Function SetFootprints populates the wxListCtrl with the footprints from aList that meet the filter c...
void OnLeftClick(wxListEvent &event)
void OnSelectComponent(wxListEvent &event)
The CvPcb application main window.
virtual CVPCB_MAINFRAME * GetParent() const
void OnLeftClick(wxListEvent &event)
COMPONENTS_LISTBOX(CVPCB_MAINFRAME *parent, wxWindowID id)