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.

87 lines
2.7 KiB

  1. /**
  2. * @file gbr_layer_box_selector.cpp
  3. * @brief a derived class of LAYER_BOX_SELECTOR to handle the layer box selector
  4. * in GerbView
  5. */
  6. /*
  7. * This program source code file is part of KiCad, a free EDA CAD application.
  8. *
  9. * Copyright (C) 1992-2016 Jean-Pierre Charras <jp.charras at wanadoo.fr>
  10. * Copyright (C) 2012 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  11. * Copyright (C) 1992-2016 KiCad Developers, see change_log.txt for contributors.
  12. *
  13. * This program is free software; you can redistribute it and/or
  14. * modify it under the terms of the GNU General Public License
  15. * as published by the Free Software Foundation; either version 2
  16. * of the License, or (at your option) any later version.
  17. *
  18. * This program is distributed in the hope that it will be useful,
  19. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  21. * GNU General Public License for more details.
  22. *
  23. * You should have received a copy of the GNU General Public License
  24. * along with this program; if not, you may find one here:
  25. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  26. * or you may search the http://www.gnu.org website for the version 2 license,
  27. * or you may write to the Free Software Foundation, Inc.,
  28. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  29. */
  30. #include <common.h>
  31. #include <gerbview_frame.h>
  32. #include <gerber_file_image_list.h>
  33. #include <gbr_layer_box_selector.h>
  34. void GBR_LAYER_BOX_SELECTOR::Resync()
  35. {
  36. #define BM_SIZE 14
  37. Freeze();
  38. Clear();
  39. GERBER_FILE_IMAGE_LIST& images = GERBER_FILE_IMAGE_LIST::GetImagesList();
  40. for( unsigned layerid = 0; layerid < images.ImagesMaxCount(); ++layerid )
  41. {
  42. wxBitmap layerbmp( BM_SIZE, BM_SIZE );
  43. wxString layername;
  44. if( !IsLayerEnabled( layerid ) )
  45. continue;
  46. // Prepare Bitmap
  47. SetBitmapLayer( layerbmp, layerid );
  48. layername = GetLayerName( layerid );
  49. Append( layername, layerbmp, (void*)(intptr_t) layerid );
  50. }
  51. // Ensure the width of the widget is enough to show the text and the icon
  52. SetMinSize( wxSize( -1, -1 ) );
  53. int minwidth = GetBestSize().x + BM_SIZE + 10;
  54. SetMinSize( wxSize( minwidth, -1 ) );
  55. Thaw();
  56. }
  57. // Returns a color index from the layer id
  58. COLOR4D GBR_LAYER_BOX_SELECTOR::GetLayerColor( int aLayer ) const
  59. {
  60. GERBVIEW_FRAME* frame = (GERBVIEW_FRAME*) GetParent()->GetParent();
  61. return frame->GetLayerColor( GERBER_DRAW_LAYER( aLayer ) );
  62. }
  63. // Returns the name of the layer id
  64. wxString GBR_LAYER_BOX_SELECTOR::GetLayerName( int aLayer ) const
  65. {
  66. GERBER_FILE_IMAGE_LIST& images = GERBER_FILE_IMAGE_LIST::GetImagesList();
  67. wxString name = images.GetDisplayName( aLayer );
  68. return name;
  69. }