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.

93 lines
3.1 KiB

  1. /*
  2. * This program source code file is part of KiCad, a free EDA CAD application.
  3. *
  4. * Copyright (C) 2019 CERN
  5. * Copyright (C) 2019-2022 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 SCH_NAVIGATE_TOOL_H
  25. #define SCH_NAVIGATE_TOOL_H
  26. #include <sch_base_frame.h>
  27. #include <tools/ee_tool_base.h>
  28. #include <status_popup.h>
  29. class SCH_EDIT_FRAME;
  30. /**
  31. * Handle actions specific to the schematic editor.
  32. */
  33. class SCH_NAVIGATE_TOOL : public wxEvtHandler, public EE_TOOL_BASE<SCH_EDIT_FRAME>
  34. {
  35. public:
  36. SCH_NAVIGATE_TOOL() : EE_TOOL_BASE<SCH_EDIT_FRAME>( "eeschema.NavigateTool" ) {}
  37. ~SCH_NAVIGATE_TOOL() { }
  38. ///< Reset navigation history. Must be done when schematic changes
  39. void ResetHistory();
  40. ///< Remove deleted pages from history. Must be done when schematic
  41. // hierarchy changes.
  42. void CleanHistory();
  43. ///< Enter sheet provided in aEvent
  44. int ChangeSheet( const TOOL_EVENT& aEvent );
  45. ///< Enter selected sheet
  46. int EnterSheet( const TOOL_EVENT& aEvent );
  47. ///< Return to parent sheet. Synonymous with Up
  48. int LeaveSheet( const TOOL_EVENT& aEvent );
  49. ///< Navigate up in sheet hierarchy
  50. int Up( const TOOL_EVENT& aEvent );
  51. ///< Navigate forward in sheet history
  52. int Forward( const TOOL_EVENT& aEvent );
  53. ///< Navigate back in sheet history
  54. int Back( const TOOL_EVENT& aEvent );
  55. ///< Navigate to previous sheet by numeric sheet number
  56. int Previous( const TOOL_EVENT& aEvent );
  57. ///< Navigate to next sheet by numeric sheet number
  58. int Next( const TOOL_EVENT& aEvent );
  59. void HypertextCommand( const wxString& href );
  60. bool CanGoBack();
  61. bool CanGoForward();
  62. bool CanGoUp();
  63. bool CanGoPrevious();
  64. bool CanGoNext();
  65. public:
  66. static wxString g_BackLink;
  67. private:
  68. ///< Set up handlers for various events.
  69. void setTransitions() override;
  70. ///< Clear history after this nav index and pushes aPath to history
  71. void pushToHistory( SCH_SHEET_PATH aPath );
  72. ///< Change current sheet to aPath and handle history, zooming, etc.
  73. void changeSheet( SCH_SHEET_PATH aPath );
  74. private:
  75. std::list<SCH_SHEET_PATH> m_navHistory;
  76. std::list<SCH_SHEET_PATH>::iterator m_navIndex;
  77. };
  78. #endif // SCH_NAVIGATE_TOOL_H