KiCad PCB EDA Suite
tools_holder.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2020 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 
24 #ifndef TOOL_HOLDER_H
25 #define TOOL_HOLDER_H
26 
27 #include <vector>
28 #include <fctsys.h>
29 #include <common.h>
30 #include <tool/tool_action.h>
31 
32 
33 class TOOL_MANAGER;
34 class TOOL_DISPATCHER;
35 class ACTIONS;
36 
37 
38 /*
39  * Class TOOLS_HOLDER
40  * A mix-in class which allows its owner to hold a set of tools from the tool framework.
41  *
42  * This is just the framework; the owner is responsible for registering individual tools,
43  * creating the dispatcher, etc.
44  */
46 {
47 protected:
51 
52  std::vector<std::string> m_toolStack; // Stack of user-level "tools". This is NOT a
53  // stack of TOOL instances, because somewhat
54  // confusingly most TOOLs implement more than one
55  // user-level tool. A user-level tool actually
56  // equates to an ACTION handler, so this stack
57  // stores ACTION names.
58 
59  bool m_immediateActions; // Preference for immediate actions. If false,
60  // the first invocation of a hotkey will just
61  // select the relevant tool rather than executing
62  // the tool's action.
63  bool m_dragSelects; // Prefer selection to dragging.
64  bool m_moveWarpsCursor; // cursor is warped to move/drag origin
65 
66 public:
67  TOOLS_HOLDER();
68 
69  virtual ~TOOLS_HOLDER() { }
70 
75 
81  virtual void PushTool( const std::string& actionName );
82  virtual void PopTool( const std::string& actionName );
83 
84  bool ToolStackIsEmpty() { return m_toolStack.empty(); }
85 
86  std::string CurrentToolName() const;
87  bool IsCurrentTool( const TOOL_ACTION& aAction ) const;
88 
89  virtual void DisplayToolMsg( const wxString& msg ) {};
90 
95  bool GetDoImmediateActions() const { return m_immediateActions; }
96 
101  bool GetDragSelects() const { return m_dragSelects; }
102 
107  bool GetMoveWarpsCursor() const { return m_moveWarpsCursor; }
108 
113  virtual void CommonSettingsChanged( bool aEnvVarsChanged );
114 
118  virtual wxWindow* GetToolCanvas() const = 0;
119  virtual void RefreshCanvas() { }
120 
121  virtual wxString ConfigBaseName() { return wxEmptyString; }
122 };
123 
124 #endif // TOOL_HOLDER_H
bool IsCurrentTool(const TOOL_ACTION &aAction) const
virtual ~TOOLS_HOLDER()
Definition: tools_holder.h:69
virtual void RefreshCanvas()
Definition: tools_holder.h:119
virtual void PushTool(const std::string &actionName)
NB: the definition of "tool" is different at the user level.
virtual void DisplayToolMsg(const wxString &msg)
Definition: tools_holder.h:89
virtual wxString ConfigBaseName()
Definition: tools_holder.h:121
bool m_dragSelects
Definition: tools_holder.h:63
bool m_immediateActions
Definition: tools_holder.h:59
virtual void CommonSettingsChanged(bool aEnvVarsChanged)
Notification event that some of the common (suite-wide) settings have changed.
TOOL_MANAGER.
Definition: tool_manager.h:51
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
virtual void PopTool(const std::string &actionName)
ACTIONS * m_actions
Definition: tools_holder.h:49
bool m_moveWarpsCursor
Definition: tools_holder.h:64
bool ToolStackIsEmpty()
Definition: tools_holder.h:84
bool GetDragSelects() const
Indicates that a drag should draw a selection rectangle, even when started over an item.
Definition: tools_holder.h:101
std::string CurrentToolName() const
bool GetDoImmediateActions() const
Indicates that hotkeys should perform an immediate action even if another tool is currently active.
Definition: tools_holder.h:95
TOOL_DISPATCHER * m_toolDispatcher
Definition: tools_holder.h:50
TOOL_DISPATCHER.
TOOL_MANAGER * m_toolManager
Definition: tools_holder.h:48
std::vector< std::string > m_toolStack
Definition: tools_holder.h:52
TOOL_ACTION.
Definition: tool_action.h:46
The common library.
bool GetMoveWarpsCursor() const
Indicates that a move operation should warp the mouse pointer to the origin of the move object.
Definition: tools_holder.h:107
ACTIONS.
Definition: actions.h:43
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:74