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.

100 lines
3.8 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2012-2015 Jean-Pierre Charras, jean-pierre.charras@ujf-grenoble.fr
  5. * Copyright (C) 1992-2015 KiCad Developers, see AUTHORS.txt for contributors.
  6. *
  7. * This program is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU General Public License
  9. * as published by the Free Software Foundation; either version 2
  10. * of the License, or (at your option) any later version.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, you may find one here:
  19. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  20. * or you may search the http://www.gnu.org website for the version 2 license,
  21. * or you may write to the Free Software Foundation, Inc.,
  22. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  23. */
  24. #ifndef PCB_LAYER_BOX_SELECTOR_H
  25. #define PCB_LAYER_BOX_SELECTOR_H
  26. #include <widgets/layer_box_selector.h>
  27. class PCB_BASE_FRAME;
  28. /**
  29. * Class to display a pcb layer list in a wxBitmapComboBox.
  30. */
  31. class PCB_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
  32. {
  33. PCB_BASE_FRAME* m_boardFrame;
  34. LSET m_layerMaskDisable; // A mask to remove some (not allowed) layers
  35. // from layer list
  36. bool m_showNotEnabledBrdlayers; // true to list all allowed layers
  37. // (with not activated layers flagged)
  38. public:
  39. // If you are thinking the constructor is a bit curious,
  40. // just remember it is used by automatically generated by wxFormBuilder files,
  41. // and it should mimic the wxBitmapComboBox constructor.
  42. // Therefore, value, style are not yet used,
  43. // but they are here for compatibility
  44. PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id,
  45. const wxString& value = wxEmptyString,
  46. const wxPoint& pos = wxDefaultPosition,
  47. const wxSize& size = wxDefaultSize,
  48. int n = 0, const wxString choices[] = NULL, int style = 0 ) :
  49. LAYER_BOX_SELECTOR( parent, id, pos, size, n, choices )
  50. {
  51. m_boardFrame = NULL;
  52. m_showNotEnabledBrdlayers = false;
  53. }
  54. // Accessors
  55. // SetBoardFrame should be called after creating a PCB_LAYER_BOX_SELECTOR
  56. // It is not passed through the constructor because when using wxFormBuilder
  57. // we should use a constructor compatible with a wxBitmapComboBox
  58. void SetBoardFrame( PCB_BASE_FRAME* aFrame ) { m_boardFrame = aFrame; };
  59. // SetLayerSet allows disableing some layers, which are not
  60. // shown in list
  61. void SetNotAllowedLayerSet( LSET aMask ) { m_layerMaskDisable = aMask; }
  62. // Reload the Layers names and bitmaps
  63. // Virtual function
  64. void Resync() override;
  65. // Allow (or not) the layers not activated for the current board to be shown
  66. // in layer selector. Not actavated layers are flagged
  67. // ( "(not activated)" added to the layer name )
  68. void ShowNonActivatedLayers( bool aShow )
  69. {
  70. m_showNotEnabledBrdlayers = aShow;
  71. }
  72. private:
  73. // Returns a color index from the layer id
  74. // Virtual function
  75. COLOR4D GetLayerColor( LAYER_NUM aLayer ) const override;
  76. // Returns true if the layer id is enabled (i.e. is it should be displayed)
  77. // Virtual function
  78. bool IsLayerEnabled( LAYER_NUM aLayer ) const override;
  79. // Returns the name of the layer id
  80. // Virtual function
  81. wxString GetLayerName( LAYER_NUM aLayer ) const override;
  82. LSET getEnabledLayers() const;
  83. };
  84. #endif // PCB_LAYER_BOX_SELECTOR_H