KiCad PCB EDA Suite
DCODE_SELECTION_BOX Class Reference

Helper to display a DCode list and select a DCode id. More...

#include <dcode_selection_box.h>

Inheritance diagram for DCODE_SELECTION_BOX:

Public Member Functions

 DCODE_SELECTION_BOX (wxAuiToolBar *aParent, wxWindowID aId, const wxPoint &aLocation, const wxSize &aSize, const wxArrayString *aChoices=nullptr)
 
 ~DCODE_SELECTION_BOX ()
 
int GetSelectedDCodeId ()
 
void SetDCodeSelection (int aDCodeId)
 
void AppendDCodeList (const wxArrayString &aChoices)
 

Detailed Description

Helper to display a DCode list and select a DCode id.

Definition at line 39 of file dcode_selection_box.h.

Constructor & Destructor Documentation

◆ DCODE_SELECTION_BOX()

DCODE_SELECTION_BOX::DCODE_SELECTION_BOX ( wxAuiToolBar *  aParent,
wxWindowID  aId,
const wxPoint &  aLocation,
const wxSize &  aSize,
const wxArrayString *  aChoices = nullptr 
)

Definition at line 31 of file dcode_selection_box.cpp.

33  :
34  wxComboBox( aParent, aId, wxEmptyString, aLocation, aSize, 0, nullptr, wxCB_READONLY )
35 {
36  if( aChoices )
37  // Append aChoices here is by far faster than use aChoices inside
38  // the wxComboBox constructor
39  Append( *aChoices );
40 }

◆ ~DCODE_SELECTION_BOX()

DCODE_SELECTION_BOX::~DCODE_SELECTION_BOX ( )

Definition at line 43 of file dcode_selection_box.cpp.

44 {
45 }

Member Function Documentation

◆ AppendDCodeList()

void DCODE_SELECTION_BOX::AppendDCodeList ( const wxArrayString &  aChoices)
Parameters
aChoicesis the DCode Id list to add to the combo box.

Definition at line 87 of file dcode_selection_box.cpp.

88 {
89  Append( aChoices );
90 }

Referenced by GERBVIEW_FRAME::updateDCodeSelectBox().

◆ GetSelectedDCodeId()

int DCODE_SELECTION_BOX::GetSelectedDCodeId ( )
Returns
the current selected DCode Id or 0 if no dcode

Definition at line 48 of file dcode_selection_box.cpp.

49 {
50  int ii = GetSelection();
51 
52  if( ii > 0 )
53  {
54  // in strings displayed by the combo box, the dcode number
55  // is the second word. get it:
56  wxString msg = GetString( ii ).AfterFirst( ' ' ).BeforeFirst( ' ' );
57  long id;
58 
59  if( msg.ToLong( &id ) )
60  return id;
61  }
62 
63  return 0;
64 }

Referenced by GERBER_LAYER_WIDGET::OnLayerSelect(), GERBVIEW_FRAME::OnSelectActiveDCode(), GERBVIEW_FRAME::OnSelectActiveLayer(), and GERBVIEW_FRAME::OnUpdateSelectDCode().

◆ SetDCodeSelection()

void DCODE_SELECTION_BOX::SetDCodeSelection ( int  aDCodeId)
Parameters
aDCodeIdis the DCode Id to select or <= 0 to select "no dcode".

Definition at line 67 of file dcode_selection_box.cpp.

68 {
69  wxString msg;
70 
71  for( unsigned index = 1; index < GetCount(); ++index )
72  {
73  msg = GetString( index ).AfterFirst( ' ' ).BeforeFirst( ' ' );
74  long id;
75 
76  if( msg.ToLong(&id) && id == aDCodeId )
77  {
78  SetSelection( index );
79  return;
80  }
81  }
82 
83  SetSelection( 0 );
84 }

Referenced by GERBVIEW_FRAME::OnUpdateSelectDCode(), and GERBVIEW_FRAME::syncLayerBox().


The documentation for this class was generated from the following files: