kicad/gerbview/class_DCodeSelectionbox.cpp

65 lines
1.6 KiB
C++
Raw Normal View History

/*****************************************************************/
/* class_DCodeSelectionbox.cpp: class for displaying DCodes list */
/*****************************************************************/
#include "fctsys.h"
#include "appl_wxstruct.h"
#include "wxstruct.h"
#include "common.h"
#include "class_drawpanel.h"
#include "gerbview.h"
#include "class_DCodeSelectionbox.h"
2010-12-18 08:59:04 +00:00
/*******************************************/
/* Helper class for displaying DCodes list */
/*******************************************/
2011-04-13 19:30:27 +00:00
DCODE_SELECTION_BOX::DCODE_SELECTION_BOX( EDA_TOOLBAR* aParent, wxWindowID aId,
const wxPoint& aLocation, const wxSize& aSize,
const wxArrayString& aChoices ) :
2010-12-19 08:02:02 +00:00
wxComboBox( aParent, aId, wxEmptyString, aLocation, aSize, 0, NULL, wxCB_READONLY )
{
m_dcodeList = &aChoices;
2010-12-19 08:02:02 +00:00
// Append aChoices here is by far faster than use aChoices inside
// the wxComboBox constructor
Append(aChoices);
}
DCODE_SELECTION_BOX::~DCODE_SELECTION_BOX()
{
}
int DCODE_SELECTION_BOX::GetSelectedDCodeId()
{
int ii = GetSelection();
if( ii > 0 )
{
wxString msg = (*m_dcodeList)[ii].AfterFirst( wxChar( ' ' ) );
long id;
msg.ToLong(&id);
return id;
}
return -1;
}
/* SetDCodeSelection
* aDCodeId = the DCode Id to select or -1 to select "no dcode"
*/
void DCODE_SELECTION_BOX::SetDCodeSelection( int aDCodeId )
{
if( aDCodeId > LAST_DCODE )
aDCodeId = LAST_DCODE;
int index = 0;
if( aDCodeId >= FIRST_DCODE )
index = aDCodeId - FIRST_DCODE + 1;
SetSelection(index);
}