KiCad PCB EDA Suite
Loading...
Searching...
No Matches
wx_listbox.cpp
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 The 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 3
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, see <https://www.gnu.org/licenses/>.
18 */
19
20#include <widgets/wx_listbox.h>
22
23/*
24 * A specialization of wxListBox with support for pinned items.
25 */
26
27
29{
30 wxString str = wxListBox::GetStringSelection();
31
32 if( str.StartsWith( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() ) )
33 str = str.substr( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol().length() );
34
35 return str;
36}
37
38
39bool WX_LISTBOX::SetStringSelection( const wxString& s )
40{
41 if( wxListBox::SetStringSelection( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + s ) )
42 return true;
43
44 return wxListBox::SetStringSelection( s );
45}
46
47
48bool WX_LISTBOX::SetStringSelection( const wxString& s, bool select )
49{
50 if( wxListBox::SetStringSelection( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + s, select ) )
51 return true;
52
53 return wxListBox::SetStringSelection( s, select );
54}
55
56
57wxString WX_LISTBOX::GetBaseString( int n ) const
58{
59 wxString str = wxListBox::GetString( n );
60
61 if( str.StartsWith( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() ) )
62 str = str.substr( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol().length() );
63
64 return str;
65}
66
67
68int WX_LISTBOX::FindString( const wxString& s, bool bCase ) const
69{
70 int retVal = wxListBox::FindString( LIB_TREE_MODEL_ADAPTER::GetPinningSymbol() + s, bCase );
71
72 if( retVal == wxNOT_FOUND )
73 retVal = wxListBox::FindString( s, bCase );
74
75 return retVal;
76}
static const wxString GetPinningSymbol()
wxString GetBaseString(int n) const
int FindString(const wxString &s, bool bCase=false) const override
wxString GetStringSelection() const override
bool SetStringSelection(const wxString &s) override