KiCad PCB EDA Suite
Loading...
Searching...
No Matches
dcode_selection_box.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) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
5
* Copyright The KiCad Developers, see AUTHORS.TXT for contributors.
6
*
7
* This program is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU General Public License
9
* as published by the Free Software Foundation; either version 2
10
* of the License, or (at your option) any later version.
11
*
12
* This program is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
* GNU General Public License for more details.
16
*
17
* You should have received a copy of the GNU General Public License
18
* along with this program. If not, see <https://www.gnu.org/licenses/>.
19
*/
20
21
#include <wx/aui/aui.h>
22
#include <
dcode.h
>
23
24
#include "
dcode_selection_box.h
"
25
26
27
DCODE_SELECTION_BOX::DCODE_SELECTION_BOX
( wxAuiToolBar* aParent, wxWindowID aId,
28
const
wxPoint& aLocation,
const
wxSize& aSize,
29
const
wxArrayString* aChoices ) :
30
wxComboBox( aParent, aId, wxEmptyString, aLocation, aSize, 0, nullptr, wxCB_READONLY )
31
{
32
if
( aChoices )
33
// Append aChoices here is by far faster than use aChoices inside
34
// the wxComboBox constructor
35
Append( *aChoices );
36
}
37
38
39
DCODE_SELECTION_BOX::~DCODE_SELECTION_BOX
()
40
{
41
}
42
43
44
int
DCODE_SELECTION_BOX::GetSelectedDCodeId
()
45
{
46
int
ii = GetSelection();
47
48
if
( ii > 0 )
49
{
50
// in strings displayed by the combo box, the dcode number
51
// is the second word. get it:
52
wxString msg = GetString( ii ).AfterFirst(
' '
).BeforeFirst(
' '
);
53
long
id;
54
55
if
( msg.ToLong( &
id
) )
56
return
id;
57
}
58
59
return
0;
60
}
61
62
63
void
DCODE_SELECTION_BOX::SetDCodeSelection
(
int
aDCodeId )
64
{
65
wxString msg;
66
67
for
(
unsigned
index
= 1;
index
< GetCount(); ++
index
)
68
{
69
msg = GetString(
index
).AfterFirst(
' '
).BeforeFirst(
' '
);
70
long
id;
71
72
if
( msg.ToLong(&
id
) &&
id
== aDCodeId )
73
{
74
SetSelection(
index
);
75
return
;
76
}
77
}
78
79
SetSelection( 0 );
80
}
81
82
83
void
DCODE_SELECTION_BOX::AppendDCodeList
(
const
wxArrayString& aChoices )
84
{
85
Append( aChoices );
86
}
index
int index
Definition
DXF_plotter.cpp:62
DCODE_SELECTION_BOX::SetDCodeSelection
void SetDCodeSelection(int aDCodeId)
Definition
dcode_selection_box.cpp:63
DCODE_SELECTION_BOX::GetSelectedDCodeId
int GetSelectedDCodeId()
Definition
dcode_selection_box.cpp:44
DCODE_SELECTION_BOX::~DCODE_SELECTION_BOX
~DCODE_SELECTION_BOX()
Definition
dcode_selection_box.cpp:39
DCODE_SELECTION_BOX::AppendDCodeList
void AppendDCodeList(const wxArrayString &aChoices)
Definition
dcode_selection_box.cpp:83
DCODE_SELECTION_BOX::DCODE_SELECTION_BOX
DCODE_SELECTION_BOX(wxAuiToolBar *aParent, wxWindowID aId, const wxPoint &aLocation, const wxSize &aSize, const wxArrayString *aChoices=nullptr)
Definition
dcode_selection_box.cpp:27
dcode.h
dcode_selection_box.h
src
gerbview
widgets
dcode_selection_box.cpp
Generated on Fri Jun 26 2026 00:05:36 for KiCad PCB EDA Suite by
1.13.2