You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

61 lines
1.5 KiB

15 years ago
15 years ago
  1. /*****************************************************************/
  2. /* class_DCodeSelectionbox.cpp: class for displaying DCodes list */
  3. /*****************************************************************/
  4. #include "fctsys.h"
  5. #include "appl_wxstruct.h"
  6. #include "wxstruct.h"
  7. #include "common.h"
  8. #include "class_drawpanel.h"
  9. #include "gerbview.h"
  10. #include "class_DCodeSelectionbox.h"
  11. /*******************************************/
  12. /* Helper class for displaying DCodes list */
  13. /*******************************************/
  14. DCODE_SELECTION_BOX::DCODE_SELECTION_BOX( WinEDA_Toolbar* aParent, wxWindowID aId,
  15. const wxPoint& aLocation, const wxSize& aSize,
  16. const wxArrayString& aChoices ) :
  17. wxComboBox( aParent, aId, wxEmptyString, aLocation, aSize, aChoices, wxCB_READONLY )
  18. {
  19. m_dcodeList = &aChoices;
  20. }
  21. DCODE_SELECTION_BOX::~DCODE_SELECTION_BOX()
  22. {
  23. }
  24. int DCODE_SELECTION_BOX::GetSelectedDCodeId()
  25. {
  26. int ii = GetSelection();
  27. if( ii > 0 )
  28. {
  29. wxString msg = (*m_dcodeList)[ii].AfterFirst( wxChar( ' ' ) );
  30. long id;
  31. msg.ToLong(&id);
  32. return id;
  33. }
  34. return -1;
  35. }
  36. /* SetDCodeSelection
  37. * aDCodeId = the DCode Id to select or -1 to select "no dcode"
  38. */
  39. void DCODE_SELECTION_BOX::SetDCodeSelection( int aDCodeId )
  40. {
  41. if( aDCodeId > LAST_DCODE )
  42. aDCodeId = LAST_DCODE;
  43. int index = 0;
  44. if( aDCodeId >= FIRST_DCODE )
  45. index = aDCodeId - FIRST_DCODE + 1;
  46. SetSelection(index);
  47. }