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  {
101  };
102 
103  FOOTPRINTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
105 
106  int GetCount();
107  void SetSelection( int index, bool State = true );
108  void SetSelectedFootprint( const LIB_ID& aFPID );
109  void SetString( unsigned linecount, const wxString& text );
110  void AppendLine( const wxString& text );
111 
124  void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName, COMPONENT* aComponent,
125  const wxString &aFootPrintFilterPattern, int aFilterType );
126 
127  wxString GetSelectedFootprint();
128 
134  wxString OnGetItemText( long item, long column ) const override;
135 
136  // Events functions:
137  void OnLeftClick( wxListEvent& event );
138  void OnLeftDClick( wxListEvent& event );
139  void OnChar( wxKeyEvent& event );
140 
141  DECLARE_EVENT_TABLE()
142 };
143 
144 
145 /******************************************/
146 /* ListBox showing the list of library */
147 /******************************************/
149 {
150  wxArrayString m_libraryList;
151 
152 public:
153  LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
155 
156  int GetCount();
157  void SetSelection( int index, bool State = true );
158  void SetString( unsigned linecount, const wxString& text );
159  void AppendLine( const wxString& text );
160  void SetLibraryList( const wxArrayString& aList );
161 
162  wxString GetSelectedLibrary();
163  wxString OnGetItemText( long item, long column ) const override;
164 
165  // Events functions:
166  void OnLeftClick( wxListEvent& event );
167 
168  void OnSelectLibrary( wxListEvent& event );
169 
182  void OnChar( wxKeyEvent& event );
183 
184  DECLARE_EVENT_TABLE()
185 };
186 
187 
188 /****************************************************/
189 /* ListBox showing the list of schematic components */
190 /****************************************************/
192 {
193 public:
194  wxArrayString m_ComponentList;
195 
196 public:
197 
198  COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id );
199 
201 
202  void Clear();
203  int GetCount();
204 
210  wxString OnGetItemText( long item, long column ) const override;
211 
212  /*
213  * Enable or disable an item
214  */
215  void SetSelection( int index, bool State = true );
216  void SetString( unsigned linecount, const wxString& text );
217  void AppendLine( const wxString& text );
218 
219  // Events functions:
220 
233  void OnChar( wxKeyEvent& event );
234 
235  void OnSelectComponent( wxListEvent& event );
236 
237  DECLARE_EVENT_TABLE()
238 };
239 
240 
241 #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...
COMPONENT is used to store components and all of their related information found in a netlist.
Definition: pcb_netlist.h:80
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:194
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:150
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)