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
3.4 KiB

  1. /*
  2. * This program source code file is part of KICAD, a free EDA CAD application.
  3. *
  4. * Copyright The KiCad Developers, see AUTHORS.txt for contributors.
  5. *
  6. * This program is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU General Public License
  8. * as published by the Free Software Foundation; either version 2
  9. * of the License, or (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, you may find one here:
  18. * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
  19. * or you may search the http://www.gnu.org website for the version 2 license,
  20. * or you may write to the Free Software Foundation, Inc.,
  21. * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
  22. */
  23. #ifndef PANEL_TOOLBAR_CUSTOMIZATION_H_
  24. #define PANEL_TOOLBAR_CUSTOMIZATION_H_
  25. #include <dialogs/panel_toolbar_customization_base.h>
  26. #include <tool/action_toolbar.h>
  27. #include <tool/ui/toolbar_configuration.h>
  28. #include <wx/bmpbndl.h>
  29. class wxImageList;
  30. class APP_SETTINGS_BASE;
  31. class TOOL_ACTION;
  32. class PANEL_TOOLBAR_CUSTOMIZATION : public PANEL_TOOLBAR_CUSTOMIZATION_BASE
  33. {
  34. public:
  35. PANEL_TOOLBAR_CUSTOMIZATION( wxWindow* aParent, APP_SETTINGS_BASE* aCfg, TOOLBAR_SETTINGS* aTbSettings,
  36. std::vector<TOOL_ACTION*> aTools,
  37. std::vector<ACTION_TOOLBAR_CONTROL*> aControls );
  38. ~PANEL_TOOLBAR_CUSTOMIZATION();
  39. void ResetPanel() override;
  40. bool TransferDataFromWindow() override;
  41. bool TransferDataToWindow() override;
  42. protected:
  43. std::optional<TOOLBAR_CONFIGURATION> parseToolbarTree();
  44. void populateToolbarTree();
  45. void populateActions();
  46. void enableCustomControls( bool enable );
  47. void enableToolbarControls( bool enable );
  48. void onGroupPress( wxCommandEvent& aEvent );
  49. void onSpacerPress( wxCommandEvent& aEvent );
  50. void onSeparatorPress( wxCommandEvent& aEvent );
  51. // From the base class
  52. void onCustomizeTbCb( wxCommandEvent& event ) override;
  53. void onToolDelete( wxCommandEvent& event ) override;
  54. void onToolMoveUp( wxCommandEvent& event ) override;
  55. void onToolMoveDown( wxCommandEvent& event ) override;
  56. void onBtnAddAction( wxCommandEvent& event ) override;
  57. void onTreeBeginLabelEdit( wxTreeEvent& event ) override;
  58. void onTreeEndLabelEdit( wxTreeEvent& event ) override;
  59. void onTbChoiceSelect( wxCommandEvent& event ) override;
  60. protected:
  61. wxImageList* m_actionImageList;
  62. wxVector<wxBitmapBundle> m_actionImageBundleVector;
  63. std::map<std::string, int> m_actionImageListMap;
  64. // Actual settings for the frame
  65. APP_SETTINGS_BASE* m_appSettings;
  66. TOOLBAR_SETTINGS* m_appTbSettings;
  67. // The toolbar currently being viewed
  68. TOOLBAR_LOC m_currentToolbar;
  69. // Shadow copy of the toolbar configurations used to store the changes in the dialog
  70. std::map<TOOLBAR_LOC, TOOLBAR_CONFIGURATION> m_toolbars;
  71. std::map<std::string, TOOL_ACTION*> m_availableTools;
  72. std::map<std::string, ACTION_TOOLBAR_CONTROL*> m_availableControls;
  73. };
  74. #endif /* PANEL_TOOLBAR_CUSTOMIZATION_H_ */