KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef TOOL_HOLDER_H
21#define TOOL_HOLDER_H
22
23#include <vector>
24#include <tool/selection.h>
25#include <mouse_drag_action.h>
26
28
29class ACTIONS;
30class TOOL_ACTION;
31class TOOL_DISPATCHER;
32class TOOL_EVENT;
33class TOOL_MANAGER;
34
35/*
36 * A mix-in class which allows its owner to hold a set of tools from the tool framework.
37 *
38 * This is just the framework; the owner is responsible for registering individual tools,
39 * creating the dispatcher, etc.
40 */
42{
43public:
45
46 virtual ~TOOLS_HOLDER() { }
47
52
54
62 virtual void RegisterUIUpdateHandler( const TOOL_ACTION& aAction,
63 const ACTION_CONDITIONS& aConditions );
64
71 virtual void RegisterUIUpdateHandler( int aID, const ACTION_CONDITIONS& aConditions )
72 {}
73
79 virtual void UnregisterUIUpdateHandler( const TOOL_ACTION& aAction );
80
86 virtual void UnregisterUIUpdateHandler( int aID )
87 {}
88
95 {
96 return m_dummySelection;
97 }
98
106
112 virtual void PushTool( const TOOL_EVENT& aEvent );
113
119 virtual void PopTool( const TOOL_EVENT& aEvent );
120
121 bool ToolStackIsEmpty() { return m_toolStack.empty(); }
122
123 std::string CurrentToolName() const;
124 bool IsCurrentTool( const TOOL_ACTION& aAction ) const;
125
126 virtual void DisplayToolMsg( const wxString& msg ) {};
127
128 virtual void ShowChangedLanguage();
129
135
141
146 bool GetMoveWarpsCursor() const { return m_moveWarpsCursor; }
147
148#define ENVVARS_CHANGED 0x0001
149#define TEXTVARS_CHANGED 0x0002
150#define HOTKEYS_CHANGED 0x0004
151
156 virtual void CommonSettingsChanged( int aFlags = 0 );
157
161 virtual wxWindow* GetToolCanvas() const = 0;
162 virtual void RefreshCanvas() { }
163
164 virtual wxString ConfigBaseName() { return wxEmptyString; }
165
166protected:
170
171 SELECTION m_dummySelection; // Empty dummy selection
172
173 std::vector<std::string> m_toolStack; // Stack of user-level "tools". This is NOT a
174 // stack of TOOL instances, because somewhat
175 // confusingly most TOOLs implement more than one
176 // user-level tool. A user-level tool actually
177 // equates to an ACTION handler, so this stack
178 // stores ACTION names.
179
180 bool m_immediateActions; // Preference for immediate actions. If false,
181 // the first invocation of a hotkey will just
182 // select the relevant tool rather than executing
183 // the tool's action.
184 MOUSE_DRAG_ACTION m_dragAction; // DRAG_ANY/DRAG_SELECTED/SELECT.
185
186 bool m_moveWarpsCursor; // cursor is warped to move/drag origin
187};
188
189#endif // TOOL_HOLDER_H
Gather all the actions that are shared by tools.
Definition actions.h:44
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
virtual void CommonSettingsChanged(int aFlags=0)
Notification event that some of the common (suite-wide) settings have changed.
TOOL_DISPATCHER * GetToolDispatcher() const
TOOL_MANAGER * m_toolManager
bool m_immediateActions
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions)
Register a UI update handler for the control with ID aID.
virtual void UnregisterUIUpdateHandler(int aID)
Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler.
std::string CurrentToolName() const
bool m_moveWarpsCursor
virtual void ShowChangedLanguage()
MOUSE_DRAG_ACTION GetDragAction() const
Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects.
SELECTION m_dummySelection
virtual void PopTool(const TOOL_EVENT &aEvent)
Pops a tool from the stack.
TOOL_DISPATCHER * m_toolDispatcher
virtual ~TOOLS_HOLDER()
MOUSE_DRAG_ACTION m_dragAction
bool GetMoveWarpsCursor() const
Indicate that a move operation should warp the mouse pointer to the origin of the move object.
virtual void PushTool(const TOOL_EVENT &aEvent)
NB: the definition of "tool" is different at the user level.
virtual wxString ConfigBaseName()
bool ToolStackIsEmpty()
virtual void RegisterUIUpdateHandler(const TOOL_ACTION &aAction, const ACTION_CONDITIONS &aConditions)
Register an action's update conditions with the UI layer to allow the UI to appropriately display the...
bool GetDoImmediateActions() const
Indicate that hotkeys should perform an immediate action even if another tool is currently active.
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
std::vector< std::string > m_toolStack
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
virtual void UnregisterUIUpdateHandler(const TOOL_ACTION &aAction)
Unregister a UI handler for an action that was registered using RegisterUIUpdateHandler.
virtual void RefreshCanvas()
ACTIONS * m_actions
bool IsCurrentTool(const TOOL_ACTION &aAction) const
virtual void DisplayToolMsg(const wxString &msg)
Represent a single user action.
Generic, UI-independent tool event.
Definition tool_event.h:167
Master controller class:
MOUSE_DRAG_ACTION
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...