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.

88 lines
3.8 KiB

4 years ago
  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 The 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 <memory>
  27. #include <lset.h>
  28. #include <widgets/layer_box_selector.h>
  29. class PCB_BASE_FRAME;
  30. class PCB_LAYER_PRESENTATION;
  31. /**
  32. * Class to display a pcb layer list in a wxBitmapComboBox.
  33. */
  34. class PCB_LAYER_BOX_SELECTOR : public LAYER_BOX_SELECTOR
  35. {
  36. public:
  37. // If you are thinking the constructor is a bit curious, just remember it is automatically
  38. // generated when used in wxFormBuilder files, and so must have the same signature as the
  39. // wxBitmapComboBox constructor. In particular, value and style are not used by this class.
  40. PCB_LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, const wxString& value = wxEmptyString,
  41. const wxPoint& pos = wxDefaultPosition,
  42. const wxSize& size = wxDefaultSize, int n = 0,
  43. const wxString choices[] = nullptr, int style = 0 );
  44. // SetBoardFrame should be called after creating a PCB_LAYER_BOX_SELECTOR. It is not passed
  45. // through the constructor because it must have the same signature as wxBitmapComboBox for
  46. // use with wxFormBuilder.
  47. void SetBoardFrame( PCB_BASE_FRAME* aFrame );
  48. // SetLayerSet allows disabling some layers, which are not shown in list
  49. void SetNotAllowedLayerSet( LSET aMask ) { m_layerMaskDisable = aMask; }
  50. // If the UNDEFINED_LAYER should be selectable, give it a name here. Usually either
  51. // INDETERMINATE_STATE or INDETERMINATE_ACTION.
  52. void SetUndefinedLayerName( const wxString& aName ) { m_undefinedLayerName = aName; }
  53. // Reload the Layers names and bitmaps
  54. void Resync() override;
  55. // Allow (or not) the layers not activated for the current board to be shown in layer
  56. // selector. Not activated layers have their names appended with "(not activated)".
  57. void ShowNonActivatedLayers( bool aShow ) { m_showNotEnabledBrdlayers = aShow; }
  58. private:
  59. // Returns true if the layer id is enabled (i.e. if it should be displayed)
  60. bool isLayerEnabled( int aLayer ) const override;
  61. LSET getEnabledLayers() const;
  62. PCB_BASE_FRAME* m_boardFrame;
  63. LSET m_layerMaskDisable; // A mask to remove some (not allowed) layers
  64. // from layer list
  65. bool m_showNotEnabledBrdlayers; // true to list all allowed layers
  66. // (with not activated layers flagged)
  67. wxString m_undefinedLayerName; // if not empty add an item with this name which sets
  68. // the layer to UNDEFINED_LAYER
  69. std::unique_ptr<PCB_LAYER_PRESENTATION> m_layerPresentation;
  70. };
  71. #endif // PCB_LAYER_BOX_SELECTOR_H