KiCad PCB EDA Suite
listview_classes.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-2017 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 CVSTRUCT_H
29 #define CVSTRUCT_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 ( wxSUNKEN_BORDER | 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  {
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 SetString( unsigned linecount, const wxString& text );
114  void AppendLine( const wxString& text );
115 
128  void SetFootprints( FOOTPRINT_LIST& aList, const wxString& aLibName,
129  COMPONENT* aComponent, const wxString &aFootPrintFilterPattern, int aFilterType );
130 
131  wxString GetSelectedFootprint();
132 
138  wxString OnGetItemText( long item, long column ) const override;
139 
140  // Events functions:
141  void OnLeftClick( wxListEvent& event );
142  void OnLeftDClick( wxListEvent& event );
143  void OnChar( wxKeyEvent& event );
144 
145  DECLARE_EVENT_TABLE()
146 };
147 
148 
149 /******************************************/
150 /* ListBox showing the list of library */
151 /******************************************/
153 {
154  wxArrayString m_libraryList;
155 
156 public:
157  LIBRARY_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
158  const wxPoint& loc, const wxSize& size );
160 
161  int GetCount();
162  void SetSelection( int index, bool State = true );
163  void SetString( unsigned linecount, const wxString& text );
164  void AppendLine( const wxString& text );
165  void SetLibraryList( const wxArrayString& aList );
166 
167  wxString GetSelectedLibrary();
168  wxString OnGetItemText( long item, long column ) const override;
169 
170  // Events functions:
171  void OnLeftClick( wxListEvent& event );
172 
173  void OnSelectLibrary( wxListEvent& event );
174 
187  void OnChar( wxKeyEvent& event );
188 
189  DECLARE_EVENT_TABLE()
190 };
191 
192 
193 /****************************************************/
194 /* ListBox showing the list of schematic components */
195 /****************************************************/
197 {
198 public:
199  wxArrayString m_ComponentList;
200 
201 public:
202 
203  COMPONENTS_LISTBOX( CVPCB_MAINFRAME* parent, wxWindowID id,
204  const wxPoint& loc, const wxSize& size );
205 
207 
208  void Clear();
209  int GetCount();
210 
216  wxString OnGetItemText( long item, long column ) const override;
217 
218  /*
219  * Enable or disable an item
220  */
221  void SetSelection( int index, bool State = true );
222  void SetString( unsigned linecount, const wxString& text );
223  void AppendLine( const wxString& text );
224 
225  // Events functions:
226 
239  void OnChar( wxKeyEvent& event );
240 
241  void OnSelectComponent( wxListEvent& event );
242 
243  DECLARE_EVENT_TABLE()
244 };
245 
246 
247 #endif //#ifndef CVSTRUCT_H
ITEMS_LISTBOX_BASE(CVPCB_MAINFRAME *aParent, wxWindowID aId, const wxPoint &aLocation, const wxSize &aSize, long aStyle=0)
Definition: listboxes.cpp:44
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, and for "ascii" keys, select the first component that the name starts by the letter.
void DeselectAll()
Removes all selection in lists which can have more than one item selected.
Definition: listboxes.cpp:112
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, and for "ascii" keys, select the first footprint that the name starts by the letter.
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.
void UpdateWidth(int aLine=-1)
Definition: listboxes.cpp:58
LIBRARY_LISTBOX(CVPCB_MAINFRAME *parent, wxWindowID id, const wxPoint &loc, const wxSize &size)
wxArrayString m_footprintList
void SetString(unsigned linecount, const wxString &text)
wxString OnGetItemText(long item, long column) const override
Function OnGetItemText this overloaded function MUST be provided for the wxLC_VIRTUAL mode because re...
COMPONENTS_LISTBOX(CVPCB_MAINFRAME *parent, wxWindowID id, const wxPoint &loc, const wxSize &size)
Class COMPONENT is used to store components and all of their related information found in a netlist...
Definition: pcb_netlist.h:83
void SetSelection(int index, bool State=true)
void AppendLine(const wxString &text)
wxArrayString m_ComponentList
void UpdateLineWidth(unsigned aLine)
Definition: listboxes.cpp:84
Holds a list of FOOTPRINT_INFO objects, along with a list of IO_ERRORs or PARSE_ERRORs that were thro...
wxArrayString m_libraryList
void SetSelection(int index, bool State=true)
void SetString(unsigned linecount, const wxString &text)
FOOTPRINTS_LISTBOX(CVPCB_MAINFRAME *parent, wxWindowID id, const wxPoint &loc, const wxSize &size)
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...
virtual CVPCB_MAINFRAME * GetParent() const
Definition: listboxes.cpp:119
void OnLeftClick(wxListEvent &event)
void OnSelectComponent(wxListEvent &event)
The CvPcb application main window.
void OnLeftClick(wxListEvent &event)