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.

70 lines
2.2 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2015 Simon Richter <Simon.Richter@hogyros.de>
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. /**
  24. * @file pin_shape_combobox.cpp
  25. * @brief ComboBox widget for pin shape
  26. */
  27. #include "pin_shape_combobox.h"
  28. #include <bitmaps.h>
  29. #include <lib_pin.h>
  30. PinShapeComboBox::PinShapeComboBox( wxWindow* parent,
  31. wxWindowID id,
  32. const wxString& value,
  33. const wxPoint& pos,
  34. const wxSize& size,
  35. int n,
  36. const wxString choices[],
  37. long style,
  38. const wxValidator& validator,
  39. const wxString& name ) :
  40. wxBitmapComboBox( parent, id, value, pos, size, n, choices, style, validator, name )
  41. {
  42. for( unsigned ii = 0; ii < GRAPHIC_PINSHAPES_TOTAL; ++ii )
  43. {
  44. GRAPHIC_PINSHAPE shape = static_cast<GRAPHIC_PINSHAPE>( ii );
  45. wxString text = PinShapeGetText( shape );
  46. BITMAPS bitmap = PinShapeGetBitmap( shape );
  47. if( bitmap == BITMAPS::INVALID_BITMAP )
  48. Append( text );
  49. else
  50. Insert( text, KiBitmap( bitmap ), ii );
  51. }
  52. }
  53. GRAPHIC_PINSHAPE PinShapeComboBox::GetPinShapeSelection()
  54. {
  55. return static_cast<GRAPHIC_PINSHAPE>( GetSelection() );
  56. }
  57. void PinShapeComboBox::SetSelection( GRAPHIC_PINSHAPE aShape )
  58. {
  59. wxBitmapComboBox::SetSelection( static_cast<int>( aShape ) );
  60. }