KiCad PCB EDA Suite
DCODE_SELECTION_BOX Class Reference

#include <class_DCodeSelectionbox.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=NULL)
 
 ~DCODE_SELECTION_BOX ()
 
int GetSelectedDCodeId ()
 Function GetSelectedDCodeId. More...
 
void SetDCodeSelection (int aDCodeId)
 Function SetDCodeSelection. More...
 
void AppendDCodeList (const wxArrayString &aChoices)
 Function AppendDCodeList. More...
 

Detailed Description

Definition at line 36 of file class_DCodeSelectionbox.h.

Constructor & Destructor Documentation

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

Definition at line 36 of file class_DCodeSelectionbox.cpp.

38  :
39  wxComboBox( aParent, aId, wxEmptyString, aLocation, aSize, 0, NULL, wxCB_READONLY )
40 {
41  if( aChoices )
42  // Append aChoices here is by far faster than use aChoices inside
43  // the wxComboBox constructor
44  Append( *aChoices );
45 }
DCODE_SELECTION_BOX::~DCODE_SELECTION_BOX ( )

Definition at line 48 of file class_DCodeSelectionbox.cpp.

49 {
50 }

Member Function Documentation

void DCODE_SELECTION_BOX::AppendDCodeList ( const wxArrayString &  aChoices)

Function AppendDCodeList.

Parameters
aChoices= the DCode Id list to add to the combo box

Definition at line 95 of file class_DCodeSelectionbox.cpp.

Referenced by GERBVIEW_FRAME::updateDCodeSelectBox().

96 {
97  Append( aChoices );
98 }
int DCODE_SELECTION_BOX::GetSelectedDCodeId ( )

Function GetSelectedDCodeId.

Returns
the current selected DCode Id or 0 if no dcode

Definition at line 53 of file class_DCodeSelectionbox.cpp.

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

54 {
55  int ii = GetSelection();
56 
57  if( ii > 0 )
58  {
59  // in strings displayed by the combo box, the dcode number
60  // is the second word. get it:
61  wxString msg = GetString( ii ).AfterFirst( ' ' ).BeforeFirst( ' ' );
62  long id;
63 
64  if( msg.ToLong(&id) )
65  return id;
66  }
67 
68  return 0;
69 }
void DCODE_SELECTION_BOX::SetDCodeSelection ( int  aDCodeId)

Function SetDCodeSelection.

Parameters
aDCodeId= the DCode Id to select or <= 0 to select "no dcode"

Definition at line 75 of file class_DCodeSelectionbox.cpp.

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

76 {
77  wxString msg;
78 
79  for( unsigned index = 1; index < GetCount(); ++index )
80  {
81  msg = GetString( index ).AfterFirst( ' ' ).BeforeFirst( ' ' );
82  long id;
83 
84  if( msg.ToLong(&id) && id == aDCodeId )
85  {
86  SetSelection( index );
87  return;
88  }
89  }
90 
91  SetSelection( 0 );
92 }

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