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.

137 lines
4.9 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2004-2010 Jean-Pierre Charras, jp.charras at wanadoo.fr
  5. * Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
  6. * Copyright (C) 2010 KiCad Developers, see change_log.txt for contributors.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License
  10. * as published by the Free Software Foundation; either version 2
  11. * of the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, you may find one here:
  20. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  21. * or you may search the http://www.gnu.org website for the version 2 license,
  22. * or you may write to the Free Software Foundation, Inc.,
  23. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  24. */
  25. /************************************************************/
  26. /* class_gerber_layer_widget.h : header for the layers manager */
  27. /************************************************************/
  28. #ifndef GERBER_LAYER_WIDGET_H
  29. #define GERBER_LAYER_WIDGET_H
  30. #include <layer_widget.h>
  31. /**
  32. * GERBER_LAYER_WIDGET
  33. * is here to implement the abtract functions of LAYER_WIDGET so they
  34. * may be tied into the GERBVIEW_FRAME's data and so we can add a popup
  35. * menu which is specific to Pcbnew's needs.
  36. */
  37. class GERBER_LAYER_WIDGET : public LAYER_WIDGET
  38. {
  39. GERBVIEW_FRAME* myframe;
  40. bool m_alwaysShowActiveLayer; // If true: Only shows the current active layer
  41. // even if it is changed
  42. /**
  43. * Function OnRightDownLayers
  44. * puts up a popup menu for the layer panel.
  45. */
  46. void onRightDownLayers( wxMouseEvent& event );
  47. void onPopupSelection( wxCommandEvent& event );
  48. /// this is for the popup menu, the right click handler has to be installed
  49. /// on every child control within the layer panel.
  50. void installRightLayerClickHandler();
  51. /**
  52. * Virtual Function useAlternateBitmap
  53. * @return true if bitmaps shown in Render layer list
  54. * are alternate bitmaps, or false if they are "normal" bitmaps
  55. */
  56. virtual bool useAlternateBitmap(int aRow) override;
  57. GERBER_FILE_IMAGE_LIST* GetImagesList();
  58. public:
  59. /**
  60. * Constructor
  61. * @param aParent : the parent frame
  62. * @param aFocusOwner : the window that has the keyboard focus.
  63. */
  64. GERBER_LAYER_WIDGET( GERBVIEW_FRAME* aParent, wxWindow* aFocusOwner );
  65. void ReFill();
  66. /**
  67. * Function ReFillRender
  68. * Rebuild Render for instance after the config is read
  69. */
  70. void ReFillRender();
  71. //-----<implement LAYER_WIDGET abstract callback functions>-----------
  72. void OnLayerRightClick( wxMenu& aMenu ) override;
  73. void OnLayerColorChange( int aLayer, COLOR4D aColor ) override;
  74. bool OnLayerSelect( int aLayer ) override;
  75. void OnLayerVisible( int aLayer, bool isVisible, bool isFinal ) override;
  76. void OnRenderColorChange( int aId, COLOR4D aColor ) override;
  77. void OnRenderEnable( int aId, bool isEnabled ) override;
  78. /**
  79. * Function SetLayersManagerTabsText
  80. * Update the layer manager tabs labels
  81. * Useful when changing Language or to set labels to a non default value
  82. */
  83. void SetLayersManagerTabsText( );
  84. //-----</implement LAYER_WIDGET abstract callback functions>----------
  85. /**
  86. * Function OnLayerSelected
  87. * ensure the active layer is visible, and other layers not visible
  88. * when m_alwaysShowActiveLayer is true
  89. * Otherwise do nothing.
  90. * @return true m_alwaysShowActiveLayer is true and the canvas is refreshed,
  91. * and false if do nothing
  92. */
  93. bool OnLayerSelected(); // postprocess after an active layer selection
  94. // ensure active layer visible if
  95. // m_alwaysShowActiveCopperLayer is true;
  96. /**
  97. * Function addRightClickMenuItems
  98. * add menu items to a menu that should be shown when right-clicking
  99. * the Gerber layer widget.
  100. * @param aMenu is the menu to modify: menuitems will be added to aMenu
  101. */
  102. void AddRightClickMenuItems( wxMenu* aMenu );
  103. protected:
  104. // popup menu ids. in layer manager
  105. enum LAYER_MANAGER
  106. {
  107. ID_LAYER_MANAGER_START = LAYER_WIDGET::ID_LAST_VALUE,
  108. ID_SHOW_ALL_LAYERS = ID_LAYER_MANAGER_START,
  109. ID_SHOW_NO_LAYERS,
  110. ID_SHOW_NO_LAYERS_BUT_ACTIVE,
  111. ID_ALWAYS_SHOW_NO_LAYERS_BUT_ACTIVE,
  112. ID_SORT_GBR_LAYERS,
  113. ID_LAYER_MANAGER_END = ID_SORT_GBR_LAYERS,
  114. };
  115. };
  116. #endif // GERBER_LAYER_WIDGET_H