KiCad PCB EDA Suite
Loading...
Searching...
No Matches
drc_re_layers_selection_combo.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 (C) 2024 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
26
27
29 const std::vector<PCB_LAYER_ID>& aLayerIDs,
30 const std::function<wxString( PCB_LAYER_ID )>& aNameGetter ) :
31 wxComboCtrl( aParent, wxID_ANY )
32{
34 SetPopupControl( m_popup );
35
36 m_layerIDs = aLayerIDs;
37 m_nameGetter = aNameGetter;
38
39 m_popup->PopulateWithLayerIDs( m_layerIDs, m_nameGetter );
40
41 Bind( wxEVT_COMBOBOX_CLOSEUP, &DRC_RE_LAYER_SELECTION_COMBO::onPopupClose, this );
42 Bind( wxEVT_KEY_DOWN, &DRC_RE_LAYER_SELECTION_COMBO::onKeyDown, this );
43 Bind( wxEVT_LEFT_DOWN, &DRC_RE_LAYER_SELECTION_COMBO::onMouseClick, this );
44}
45
46
48{
49 Unbind( wxEVT_COMBOBOX_CLOSEUP, &DRC_RE_LAYER_SELECTION_COMBO::onPopupClose, this );
50 Unbind( wxEVT_KEY_DOWN, &DRC_RE_LAYER_SELECTION_COMBO::onKeyDown, this );
51 Unbind( wxEVT_LEFT_DOWN, &DRC_RE_LAYER_SELECTION_COMBO::onMouseClick, this );
52}
53
54
56{
57 return m_popup->GetSelectedItemsString();
58}
59
60
62{
63 return m_popup->GetSelectedLayers( m_layerIDs, m_nameGetter );
64}
65
66
68 const std::vector<PCB_LAYER_ID>& aSelectedLayers )
69{
70 m_popup->SetSelections( aSelectedLayers, m_nameGetter );
71
72 SetValue( m_popup->GetSelectedItemsString() );
73}
74
75
76void DRC_RE_LAYER_SELECTION_COMBO::onPopupClose( wxCommandEvent& aEvent )
77{
78 SetValue( m_popup->GetSelectedItemsString() );
79 aEvent.Skip();
80}
81
82
84{
85 aEvent.Skip( false );
86}
87
88
90{
91 if( !IsPopupShown() )
92 {
93 ShowPopup();
94 }
95
96 aEvent.Skip( false );
97}
std::vector< PCB_LAYER_ID > GetSelectedLayers()
DRC_RE_LAYER_SELECTION_CHOICE_POPUP * m_popup
void SetItemsSelected(const std::vector< PCB_LAYER_ID > &aSelectedLayers)
void onPopupClose(wxCommandEvent &aEvent)
DRC_RE_LAYER_SELECTION_COMBO(wxWindow *aParent, const std::vector< PCB_LAYER_ID > &aLayerIDs, const std::function< wxString(PCB_LAYER_ID)> &aNameGetter)
std::function< wxString(PCB_LAYER_ID)> m_nameGetter
PCB_LAYER_ID
A quick note on layer IDs:
Definition layer_ids.h:60