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 (C) 2020-2024 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 <
tool/selection.h
>
29
#include <
settings/common_settings.h
>
30
31
struct
ACTION_CONDITIONS
;
32
33
class
ACTIONS
;
34
class
TOOL_ACTION
;
35
class
TOOL_DISPATCHER
;
36
class
TOOL_EVENT
;
37
class
TOOL_MANAGER
;
38
39
/*
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
*/
45
class
TOOLS_HOLDER
46
{
47
public
:
48
TOOLS_HOLDER
();
49
50
virtual
~TOOLS_HOLDER
() { }
51
55
TOOL_MANAGER
*
GetToolManager
()
const
{
return
m_toolManager
; }
56
57
TOOL_DISPATCHER
*
GetToolDispatcher
()
const
{
return
m_toolDispatcher
; }
58
66
virtual
void
RegisterUIUpdateHandler
(
const
TOOL_ACTION
& aAction,
67
const
ACTION_CONDITIONS
& aConditions );
68
75
virtual
void
RegisterUIUpdateHandler
(
int
aID,
const
ACTION_CONDITIONS
& aConditions )
76
{}
77
83
virtual
void
UnregisterUIUpdateHandler
(
const
TOOL_ACTION
& aAction );
84
90
virtual
void
UnregisterUIUpdateHandler
(
int
aID )
91
{}
92
98
virtual
SELECTION
&
GetCurrentSelection
()
99
{
100
return
m_dummySelection
;
101
}
102
116
virtual
void
PushTool
(
const
TOOL_EVENT
& aEvent );
117
123
virtual
void
PopTool
(
const
TOOL_EVENT
& aEvent );
124
125
bool
ToolStackIsEmpty
() {
return
m_toolStack
.empty(); }
126
127
std::string
CurrentToolName
()
const
;
128
bool
IsCurrentTool
(
const
TOOL_ACTION
& aAction )
const
;
129
130
virtual
void
DisplayToolMsg
(
const
wxString& msg ) {};
131
132
virtual
void
ShowChangedLanguage
();
133
138
bool
GetDoImmediateActions
()
const
{
return
m_immediateActions
; }
139
144
MOUSE_DRAG_ACTION
GetDragAction
()
const
{
return
m_dragAction
; }
145
150
bool
GetMoveWarpsCursor
()
const
{
return
m_moveWarpsCursor
; }
151
156
virtual
void
CommonSettingsChanged
(
bool
aEnvVarsChanged,
bool
aTextVarsChanged );
157
161
virtual
wxWindow*
GetToolCanvas
()
const
= 0;
162
virtual
void
RefreshCanvas
() { }
163
164
virtual
wxString
ConfigBaseName
() {
return
wxEmptyString; }
165
166
protected
:
167
TOOL_MANAGER
*
m_toolManager
;
168
ACTIONS
*
m_actions
;
169
TOOL_DISPATCHER
*
m_toolDispatcher
;
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
ACTIONS
Gather all the actions that are shared by tools.
Definition:
actions.h:41
SELECTION
Definition:
selection.h:39
TOOLS_HOLDER
Definition:
tools_holder.h:46
TOOLS_HOLDER::GetToolCanvas
virtual wxWindow * GetToolCanvas() const =0
Canvas access.
TOOLS_HOLDER::GetToolDispatcher
TOOL_DISPATCHER * GetToolDispatcher() const
Definition:
tools_holder.h:57
TOOLS_HOLDER::m_toolManager
TOOL_MANAGER * m_toolManager
Definition:
tools_holder.h:167
TOOLS_HOLDER::m_immediateActions
bool m_immediateActions
Definition:
tools_holder.h:180
TOOLS_HOLDER::RegisterUIUpdateHandler
virtual void RegisterUIUpdateHandler(int aID, const ACTION_CONDITIONS &aConditions)
Register a UI update handler for the control with ID aID.
Definition:
tools_holder.h:75
TOOLS_HOLDER::UnregisterUIUpdateHandler
virtual void UnregisterUIUpdateHandler(int aID)
Unregister a UI handler for a given ID that was registered using RegisterUIUpdateHandler.
Definition:
tools_holder.h:90
TOOLS_HOLDER::CurrentToolName
std::string CurrentToolName() const
Definition:
tools_holder.cpp:122
TOOLS_HOLDER::TOOLS_HOLDER
TOOLS_HOLDER()
Definition:
tools_holder.cpp:33
TOOLS_HOLDER::m_moveWarpsCursor
bool m_moveWarpsCursor
Definition:
tools_holder.h:186
TOOLS_HOLDER::ShowChangedLanguage
virtual void ShowChangedLanguage()
Definition:
tools_holder.cpp:140
TOOLS_HOLDER::GetDragAction
MOUSE_DRAG_ACTION GetDragAction() const
Indicates whether a drag should draw a selection rectangle or drag selected (or unselected) objects.
Definition:
tools_holder.h:144
TOOLS_HOLDER::m_dummySelection
SELECTION m_dummySelection
Definition:
tools_holder.h:171
TOOLS_HOLDER::PopTool
virtual void PopTool(const TOOL_EVENT &aEvent)
Pops a tool from the stack.
Definition:
tools_holder.cpp:77
TOOLS_HOLDER::m_toolDispatcher
TOOL_DISPATCHER * m_toolDispatcher
Definition:
tools_holder.h:169
TOOLS_HOLDER::~TOOLS_HOLDER
virtual ~TOOLS_HOLDER()
Definition:
tools_holder.h:50
TOOLS_HOLDER::m_dragAction
MOUSE_DRAG_ACTION m_dragAction
Definition:
tools_holder.h:184
TOOLS_HOLDER::GetMoveWarpsCursor
bool GetMoveWarpsCursor() const
Indicate that a move operation should warp the mouse pointer to the origin of the move object.
Definition:
tools_holder.h:150
TOOLS_HOLDER::PushTool
virtual void PushTool(const TOOL_EVENT &aEvent)
NB: the definition of "tool" is different at the user level.
Definition:
tools_holder.cpp:56
TOOLS_HOLDER::ConfigBaseName
virtual wxString ConfigBaseName()
Definition:
tools_holder.h:164
TOOLS_HOLDER::ToolStackIsEmpty
bool ToolStackIsEmpty()
Definition:
tools_holder.h:125
TOOLS_HOLDER::RegisterUIUpdateHandler
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...
Definition:
tools_holder.cpp:42
TOOLS_HOLDER::GetDoImmediateActions
bool GetDoImmediateActions() const
Indicate that hotkeys should perform an immediate action even if another tool is currently active.
Definition:
tools_holder.h:138
TOOLS_HOLDER::GetToolManager
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition:
tools_holder.h:55
TOOLS_HOLDER::m_toolStack
std::vector< std::string > m_toolStack
Definition:
tools_holder.h:173
TOOLS_HOLDER::GetCurrentSelection
virtual SELECTION & GetCurrentSelection()
Get the current selection from the canvas area.
Definition:
tools_holder.h:98
TOOLS_HOLDER::UnregisterUIUpdateHandler
virtual void UnregisterUIUpdateHandler(const TOOL_ACTION &aAction)
Unregister a UI handler for an action that was registered using RegisterUIUpdateHandler.
Definition:
tools_holder.cpp:49
TOOLS_HOLDER::CommonSettingsChanged
virtual void CommonSettingsChanged(bool aEnvVarsChanged, bool aTextVarsChanged)
Notification event that some of the common (suite-wide) settings have changed.
Definition:
tools_holder.cpp:153
TOOLS_HOLDER::RefreshCanvas
virtual void RefreshCanvas()
Definition:
tools_holder.h:162
TOOLS_HOLDER::m_actions
ACTIONS * m_actions
Definition:
tools_holder.h:168
TOOLS_HOLDER::IsCurrentTool
bool IsCurrentTool(const TOOL_ACTION &aAction) const
Definition:
tools_holder.cpp:131
TOOLS_HOLDER::DisplayToolMsg
virtual void DisplayToolMsg(const wxString &msg)
Definition:
tools_holder.h:130
TOOL_ACTION
Represent a single user action.
Definition:
tool_action.h:269
TOOL_DISPATCHER
Definition:
tool_dispatcher.h:53
TOOL_EVENT
Generic, UI-independent tool event.
Definition:
tool_event.h:167
TOOL_MANAGER
Master controller class:
Definition:
tool_manager.h:62
common_settings.h
MOUSE_DRAG_ACTION
MOUSE_DRAG_ACTION
Definition:
common_settings.h:29
selection.h
ACTION_CONDITIONS
Functors that can be used to figure out how the action controls should be displayed in the UI and if ...
Definition:
action_manager.h:49
src
include
tool
tools_holder.h
Generated on Thu Nov 21 2024 00:06:43 for KiCad PCB EDA Suite by
1.9.6