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.

96 lines
2.9 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2011-2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 1992-2021 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 LAYER_BOX_SELECTOR_H
  25. #define LAYER_BOX_SELECTOR_H
  26. #include <wx/bmpcbox.h>
  27. #include <gal/color4d.h>
  28. #include <layer_ids.h>
  29. using KIGFX::COLOR4D;
  30. /**
  31. * Base class to build a layer list.
  32. */
  33. class LAYER_SELECTOR
  34. {
  35. public:
  36. LAYER_SELECTOR();
  37. virtual ~LAYER_SELECTOR()
  38. {
  39. }
  40. bool SetLayersHotkeys( bool value );
  41. // Fill the layer bitmap aLayerbmp with the layer color
  42. static void DrawColorSwatch( wxBitmap& aLayerbmp, const COLOR4D& aBackground,
  43. const COLOR4D& aColor );
  44. protected:
  45. // Return a color index from the layer id
  46. virtual COLOR4D getLayerColor( int aLayer ) const = 0;
  47. // Return the name of the layer id
  48. virtual wxString getLayerName( int aLayer ) const = 0;
  49. // Return true if the layer id is enabled (i.e. is it should be displayed)
  50. virtual bool isLayerEnabled( int aLayer ) const = 0;
  51. bool m_layerhotkeys;
  52. };
  53. /*
  54. * Display a layer list in a wxBitmapComboBox.
  55. */
  56. class LAYER_BOX_SELECTOR : public wxBitmapComboBox, public LAYER_SELECTOR
  57. {
  58. public:
  59. LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition,
  60. const wxSize& size = wxDefaultSize, int n = 0,
  61. const wxString choices[] = nullptr );
  62. LAYER_BOX_SELECTOR( wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size,
  63. const wxArrayString& choices );
  64. ~LAYER_BOX_SELECTOR() override;
  65. int GetLayerSelection() const;
  66. int SetLayerSelection( int layer );
  67. // Reload the Layers
  68. // Virtual pure function because GerbView uses its own functions in a derived class
  69. virtual void Resync() = 0;
  70. // Reload the Layers bitmaps colors
  71. void ResyncBitmapOnly();
  72. private:
  73. void onKeyDown( wxKeyEvent& aEvent );
  74. };
  75. #endif // LAYER_BOX_SELECTOR_H