KiCad PCB EDA Suite
TOOL_EVENT Class Reference

Class TOOL_EVENT. More...

#include <tool_event.h>

Public Member Functions

const std::string Format () const
 Function Format() Returns information about event in form of a human-readable string. More...
 
 TOOL_EVENT (TOOL_EVENT_CATEGORY aCategory=TC_NONE, TOOL_ACTIONS aAction=TA_NONE, TOOL_ACTION_SCOPE aScope=AS_GLOBAL, void *aParameter=NULL)
 
 TOOL_EVENT (TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, int aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL, void *aParameter=NULL)
 
 TOOL_EVENT (TOOL_EVENT_CATEGORY aCategory, TOOL_ACTIONS aAction, const std::string &aExtraParam, TOOL_ACTION_SCOPE aScope=AS_GLOBAL, void *aParameter=NULL)
 
TOOL_EVENT_CATEGORY Category () const
 

Returns the category (eg. mouse/keyboard/action) of an event..

More...
 
TOOL_ACTIONS Action () const
 

Returns more specific information about the type of an event.

More...
 
bool HasPosition () const
 

Returns if it this event has a valid position (true for mouse events)

More...
 
const VECTOR2D Delta () const
 

Returns information about difference between current mouse cursor position and the place where dragging has started.

More...
 
const VECTOR2D Position () const
 

Returns mouse cursor position in world coordinates.

More...
 
const VECTOR2D DragOrigin () const
 

Returns the point where dragging has started.

More...
 
int Buttons () const
 

Returns information about mouse buttons state.

More...
 
bool IsClick (int aButtonMask=BUT_ANY) const
 
bool IsDblClick (int aButtonMask=BUT_ANY) const
 
bool IsDrag (int aButtonMask=BUT_ANY) const
 
bool IsMouseUp (int aButtonMask=BUT_ANY) const
 
bool IsMotion () const
 
bool IsCancel () const
 
bool IsActivate () const
 
bool IsUndoRedo () const
 
bool IsMenu () const
 
int Modifier (int aMask=MD_MODIFIER_MASK) const
 

Returns information about key modifiers state (Ctrl, Alt, etc.)

More...
 
int KeyCode () const
 
bool IsKeyPressed () const
 
bool Matches (const TOOL_EVENT &aEvent) const
 Function Matches() Tests whether two events match in terms of category & action or command. More...
 
bool IsAction (const TOOL_ACTION *aAction) const
 Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_ACTION. More...
 
template<typename T >
Parameter () const
 Function Parameter() Returns a non-standard parameter assigned to the event. More...
 
template<typename T >
void SetParameter (T aParam)
 Function SetParameter() Sets a non-standard parameter assigned to the event. More...
 
OPT< int > GetCommandId () const
 
OPT< std::string > GetCommandStr () const
 
void SetMousePosition (const VECTOR2D &aP)
 

Private Member Functions

void setMouseDragOrigin (const VECTOR2D &aP)
 
void setMouseDelta (const VECTOR2D &aP)
 
void setMouseButtons (int aButtons)
 
void setModifiers (int aMods)
 
VECTOR2D returnCheckedPosition (const VECTOR2D &aPos) const
 Ensure that the event is a type that has a position before returning a position, otherwise return a null-constructed position. More...
 

Private Attributes

TOOL_EVENT_CATEGORY m_category
 
TOOL_ACTIONS m_actions
 
TOOL_ACTION_SCOPE m_scope
 
VECTOR2D m_mouseDelta
 

Difference between mouse cursor position and the point where dragging event has started

More...
 
VECTOR2D m_mousePos
 

Current mouse cursor position

More...
 
VECTOR2D m_mouseDragOrigin
 

Point where dragging has started

More...
 
int m_mouseButtons
 

State of mouse buttons

More...
 
int m_keyCode
 

Stores code of pressed/released key

More...
 
int m_modifiers
 

State of key modifierts (Ctrl/Alt/etc.)

More...
 
void * m_param
 

Generic parameter used for passing non-standard data.

More...
 
OPT< int > m_commandId
 
OPT< std::string > m_commandStr
 

Friends

class TOOL_DISPATCHER
 

Detailed Description

Class TOOL_EVENT.

Generic, UI-independent tool event.

Definition at line 167 of file tool_event.h.

Constructor & Destructor Documentation

◆ TOOL_EVENT() [1/3]

TOOL_EVENT::TOOL_EVENT ( TOOL_EVENT_CATEGORY  aCategory = TC_NONE,
TOOL_ACTIONS  aAction = TA_NONE,
TOOL_ACTION_SCOPE  aScope = AS_GLOBAL,
void *  aParameter = NULL 
)
inline

Definition at line 178 of file tool_event.h.

179  :
180  m_category( aCategory ),
181  m_actions( aAction ),
182  m_scope( aScope ),
183  m_mouseButtons( 0 ),
184  m_keyCode( 0 ),
185  m_modifiers( 0 ),
186  m_param( aParameter ) {}
int m_modifiers
State of key modifierts (Ctrl/Alt/etc.)
Definition: tool_event.h:477
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471
int m_keyCode
Stores code of pressed/released key
Definition: tool_event.h:474
TOOL_ACTION_SCOPE m_scope
Definition: tool_event.h:458
void * m_param
Generic parameter used for passing non-standard data.
Definition: tool_event.h:480
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:456

◆ TOOL_EVENT() [2/3]

TOOL_EVENT::TOOL_EVENT ( TOOL_EVENT_CATEGORY  aCategory,
TOOL_ACTIONS  aAction,
int  aExtraParam,
TOOL_ACTION_SCOPE  aScope = AS_GLOBAL,
void *  aParameter = NULL 
)
inline

Definition at line 188 of file tool_event.h.

189  :
190  m_category( aCategory ),
191  m_actions( aAction ),
192  m_scope( aScope ),
193  m_mouseButtons( 0 ),
194  m_keyCode( 0 ),
195  m_modifiers( 0 ),
196  m_param( aParameter )
197  {
198  if( aCategory == TC_MOUSE )
199  {
200  setMouseButtons( aExtraParam & BUT_BUTTON_MASK );
201  }
202  else if( aCategory == TC_KEYBOARD )
203  {
204  m_keyCode = aExtraParam & ~MD_MODIFIER_MASK; // Filter out modifiers
205  }
206  else if( aCategory == TC_COMMAND )
207  {
208  m_commandId = aExtraParam;
209  }
210 
211  if( aCategory & ( TC_MOUSE | TC_KEYBOARD ) )
212  {
213  m_modifiers = aExtraParam & MD_MODIFIER_MASK;
214  }
215  }
void setMouseButtons(int aButtons)
Definition: tool_event.h:423
int m_modifiers
State of key modifierts (Ctrl/Alt/etc.)
Definition: tool_event.h:477
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471
int m_keyCode
Stores code of pressed/released key
Definition: tool_event.h:474
OPT< int > m_commandId
Definition: tool_event.h:482
TOOL_ACTION_SCOPE m_scope
Definition: tool_event.h:458
void * m_param
Generic parameter used for passing non-standard data.
Definition: tool_event.h:480
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:456

References BUT_BUTTON_MASK, m_commandId, m_keyCode, m_modifiers, MD_MODIFIER_MASK, setMouseButtons(), TC_COMMAND, TC_KEYBOARD, and TC_MOUSE.

◆ TOOL_EVENT() [3/3]

TOOL_EVENT::TOOL_EVENT ( TOOL_EVENT_CATEGORY  aCategory,
TOOL_ACTIONS  aAction,
const std::string &  aExtraParam,
TOOL_ACTION_SCOPE  aScope = AS_GLOBAL,
void *  aParameter = NULL 
)
inline

Definition at line 217 of file tool_event.h.

219  :
220  m_category( aCategory ),
221  m_actions( aAction ),
222  m_scope( aScope ),
223  m_mouseButtons( 0 ),
224  m_keyCode( 0 ),
225  m_modifiers( 0 ),
226  m_param( aParameter )
227  {
228  if( aCategory == TC_COMMAND || aCategory == TC_MESSAGE )
229  m_commandStr = aExtraParam;
230  }
int m_modifiers
State of key modifierts (Ctrl/Alt/etc.)
Definition: tool_event.h:477
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471
OPT< std::string > m_commandStr
Definition: tool_event.h:483
int m_keyCode
Stores code of pressed/released key
Definition: tool_event.h:474
TOOL_ACTION_SCOPE m_scope
Definition: tool_event.h:458
void * m_param
Generic parameter used for passing non-standard data.
Definition: tool_event.h:480
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:456

References m_commandStr, TC_COMMAND, and TC_MESSAGE.

Member Function Documentation

◆ Action()

TOOL_ACTIONS TOOL_EVENT::Action ( ) const
inline

Returns more specific information about the type of an event.

Definition at line 239 of file tool_event.h.

240  {
241  return m_actions;
242  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457

References m_actions.

Referenced by EDIT_TOOL::cutToClipboard(), and TOOL_MANAGER::dispatchStandardEvents().

◆ Buttons()

int TOOL_EVENT::Buttons ( ) const
inline

Returns information about mouse buttons state.

Definition at line 270 of file tool_event.h.

271  {
272  assert( m_category == TC_MOUSE ); // this should be used only with mouse events
273  return m_mouseButtons;
274  }
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:456

References m_category, m_mouseButtons, and TC_MOUSE.

◆ Category()

TOOL_EVENT_CATEGORY TOOL_EVENT::Category ( ) const
inline

Returns the category (eg. mouse/keyboard/action) of an event..

Definition at line 233 of file tool_event.h.

234  {
235  return m_category;
236  }
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:456

References m_category.

Referenced by EDIT_TOOL::cutToClipboard(), and TOOL_MANAGER::dispatchInternal().

◆ Delta()

const VECTOR2D TOOL_EVENT::Delta ( ) const
inline

Returns information about difference between current mouse cursor position and the place where dragging has started.

Definition at line 252 of file tool_event.h.

253  {
255  }
VECTOR2D returnCheckedPosition(const VECTOR2D &aPos) const
Ensure that the event is a type that has a position before returning a position, otherwise return a n...
Definition: tool_event.h:444
VECTOR2D m_mouseDelta
Difference between mouse cursor position and the point where dragging event has started
Definition: tool_event.h:462

References m_mouseDelta, and returnCheckedPosition().

◆ DragOrigin()

const VECTOR2D TOOL_EVENT::DragOrigin ( ) const
inline

Returns the point where dragging has started.

Definition at line 264 of file tool_event.h.

265  {
267  }
VECTOR2D returnCheckedPosition(const VECTOR2D &aPos) const
Ensure that the event is a type that has a position before returning a position, otherwise return a n...
Definition: tool_event.h:444
VECTOR2D m_mouseDragOrigin
Point where dragging has started
Definition: tool_event.h:468

References m_mouseDragOrigin, and returnCheckedPosition().

Referenced by EE_POINT_EDITOR::updateEditedPoint(), and POINT_EDITOR::updateEditedPoint().

◆ Format()

const std::string TOOL_EVENT::Format ( ) const

Function Format() Returns information about event in form of a human-readable string.

Returns
Event information.

Definition at line 60 of file tool_event.cpp.

61 {
62  std::string ev;
63 
64  const FlagString categories[] =
65  {
66  { TC_MOUSE, "mouse" },
67  { TC_KEYBOARD, "keyboard" },
68  { TC_COMMAND, "command" },
69  { TC_MESSAGE, "message" },
70  { TC_VIEW, "view" },
71  { 0, "" }
72  };
73 
74  const FlagString actions[] =
75  {
76  { TA_MOUSE_CLICK, "click" },
77  { TA_MOUSE_DBLCLICK, "double click" },
78  { TA_MOUSE_UP, "button-up" },
79  { TA_MOUSE_DOWN, "button-down" },
80  { TA_MOUSE_DRAG, "drag" },
81  { TA_MOUSE_MOTION, "motion" },
82  { TA_MOUSE_WHEEL, "wheel" },
83  { TA_KEY_PRESSED, "key-pressed" },
84  { TA_VIEW_REFRESH, "view-refresh" },
85  { TA_VIEW_ZOOM, "view-zoom" },
86  { TA_VIEW_PAN, "view-pan" },
87  { TA_VIEW_DIRTY, "view-dirty" },
88  { TA_CHANGE_LAYER, "change-layer" },
89  { TA_CANCEL_TOOL, "cancel-tool" },
90  { TA_CONTEXT_MENU_UPDATE, "context-menu-update" },
91  { TA_CONTEXT_MENU_CHOICE, "context-menu-choice" },
92  { TA_UNDO_REDO_PRE, "undo-redo-pre" },
93  { TA_UNDO_REDO_POST, "undo-redo-post" },
94  { TA_ACTION, "action" },
95  { TA_ACTIVATE, "activate" },
96  { 0, "" }
97  };
98 
99  const FlagString buttons[] =
100  {
101  { BUT_NONE, "none" },
102  { BUT_LEFT, "left" },
103  { BUT_RIGHT, "right" },
104  { BUT_MIDDLE, "middle" },
105  { 0, "" }
106  };
107 
108  const FlagString modifiers[] =
109  {
110  { MD_SHIFT, "shift" },
111  { MD_CTRL, "ctrl" },
112  { MD_ALT, "alt" },
113  { 0, "" }
114  };
115 
116  ev = "category: ";
117  ev += flag2string( m_category, categories );
118  ev += " action: ";
119  ev += flag2string( m_actions, actions );
120 
121  if( m_actions & TA_MOUSE )
122  {
123  ev += " btns: ";
124  ev += flag2string( m_mouseButtons, buttons );
125  }
126 
127  if( m_actions & TA_KEYBOARD )
128  {
129  char tmp[128];
130  sprintf( tmp, "key: %d", m_keyCode );
131  ev += tmp;
132  }
133 
134  if( m_actions & ( TA_MOUSE | TA_KEYBOARD ) )
135  {
136  ev += " mods: ";
137  ev += flag2string( m_modifiers, modifiers );
138  }
139 
140  if( m_commandId )
141  {
142  char tmp[128];
143  sprintf( tmp, "cmd-id: %d", *m_commandId );
144  ev += tmp;
145  }
146 
147  if( m_commandStr )
148  ev += "cmd-str: " + ( *m_commandStr );
149 
150  return ev;
151 }
int m_modifiers
State of key modifierts (Ctrl/Alt/etc.)
Definition: tool_event.h:477
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471
OPT< std::string > m_commandStr
Definition: tool_event.h:483
int m_keyCode
Stores code of pressed/released key
Definition: tool_event.h:474
OPT< int > m_commandId
Definition: tool_event.h:482
static const std::string flag2string(int aFlag, const FlagString *aExps)
Definition: tool_event.cpp:40
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:456

References BUT_LEFT, BUT_MIDDLE, BUT_NONE, BUT_RIGHT, flag2string(), m_actions, m_category, m_commandId, m_commandStr, m_keyCode, m_modifiers, m_mouseButtons, MD_ALT, MD_CTRL, MD_SHIFT, TA_ACTION, TA_ACTIVATE, TA_CANCEL_TOOL, TA_CHANGE_LAYER, TA_CONTEXT_MENU_CHOICE, TA_CONTEXT_MENU_UPDATE, TA_KEY_PRESSED, TA_KEYBOARD, TA_MOUSE, TA_MOUSE_CLICK, TA_MOUSE_DBLCLICK, TA_MOUSE_DOWN, TA_MOUSE_DRAG, TA_MOUSE_MOTION, TA_MOUSE_UP, TA_MOUSE_WHEEL, TA_UNDO_REDO_POST, TA_UNDO_REDO_PRE, TA_VIEW_DIRTY, TA_VIEW_PAN, TA_VIEW_REFRESH, TA_VIEW_ZOOM, TC_COMMAND, TC_KEYBOARD, TC_MESSAGE, TC_MOUSE, and TC_VIEW.

◆ GetCommandId()

OPT<int> TOOL_EVENT::GetCommandId ( ) const
inline

Definition at line 395 of file tool_event.h.

396  {
397  return m_commandId;
398  }
OPT< int > m_commandId
Definition: tool_event.h:482

References m_commandId.

◆ GetCommandStr()

OPT<std::string> TOOL_EVENT::GetCommandStr ( ) const
inline

Definition at line 400 of file tool_event.h.

401  {
402  return m_commandStr;
403  }
OPT< std::string > m_commandStr
Definition: tool_event.h:483

References m_commandStr.

Referenced by TOOL_MANAGER::dispatchActivation().

◆ HasPosition()

bool TOOL_EVENT::HasPosition ( ) const
inline

Returns if it this event has a valid position (true for mouse events)

Definition at line 245 of file tool_event.h.

246  {
247  return m_category == TC_MOUSE || m_category == TC_COMMAND;
248  }
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:456

References m_category, TC_COMMAND, and TC_MOUSE.

Referenced by returnCheckedPosition().

◆ IsAction()

bool TOOL_EVENT::IsAction ( const TOOL_ACTION aAction) const

Function IsAction() Tests if the event contains an action issued upon activation of the given TOOL_ACTION.

Parameters
aActionis the TOOL_ACTION to be checked against.
Returns
True if it matches the given TOOL_ACTION.

Definition at line 54 of file tool_event.cpp.

55 {
56  return Matches( aAction->MakeEvent() );
57 }
bool Matches(const TOOL_EVENT &aEvent) const
Function Matches() Tests whether two events match in terms of category & action or command.
Definition: tool_event.h:338
TOOL_EVENT MakeEvent() const
Function MakeEvent() Returns the event associated with the action (i.e.
Definition: tool_action.h:95

References TOOL_ACTION::MakeEvent(), and Matches().

Referenced by SCH_DRAWING_TOOLS::AddLabel(), SCH_EDIT_TOOL::ChangeShape(), SCH_EDIT_TOOL::ChangeTextType(), GERBVIEW_CONTROL::DisplayControl(), EDIT_TOOL::Drag(), LIB_DRAWING_TOOLS::DrawShape(), EDIT_TOOL::Duplicate(), SCH_EDIT_TOOL::EditField(), EDIT_TOOL::ExchangeFootprints(), GERBVIEW_CONTROL::HighlightControl(), PCB_EDITOR_CONTROL::HighlightNetCursor(), TOOL_EVT_UTILS::IsCancelInteractive(), TOOL_EVT_UTILS::IsRotateToolEvt(), SCH_MOVE_TOOL::Main(), LIB_EDIT_TOOL::Properties(), LIB_PIN_TOOL::PushPinProperties(), PCBNEW_CONTROL::ZoneDisplayMode(), COMMON_TOOLS::ZoomInOut(), and COMMON_TOOLS::ZoomInOutCenter().

◆ IsActivate()

bool TOOL_EVENT::IsActivate ( ) const
inline

Definition at line 300 of file tool_event.h.

301  {
302  return m_actions == TA_ACTIVATE;
303  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457

References m_actions, and TA_ACTIVATE.

Referenced by TOOL_MANAGER::dispatchActivation(), and TOOL_EVT_UTILS::IsCancelInteractive().

◆ IsCancel()

bool TOOL_EVENT::IsCancel ( ) const
inline

Definition at line 295 of file tool_event.h.

296  {
297  return m_actions == TA_CANCEL_TOOL;
298  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457

References m_actions, and TA_CANCEL_TOOL.

Referenced by TOOL_EVT_UTILS::IsCancelInteractive().

◆ IsClick()

bool TOOL_EVENT::IsClick ( int  aButtonMask = BUT_ANY) const

Definition at line 165 of file tool_event.cpp.

166 {
167  return m_actions == TA_MOUSE_CLICK && ( m_mouseButtons & aButtonMask ) == aButtonMask;
168 }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471

References m_actions, m_mouseButtons, and TA_MOUSE_CLICK.

Referenced by TOOL_MANAGER::dispatchContextMenu(), and PNS::TOOL_BASE::updateStartItem().

◆ IsDblClick()

bool TOOL_EVENT::IsDblClick ( int  aButtonMask = BUT_ANY) const

Definition at line 171 of file tool_event.cpp.

172 {
173  return m_actions == TA_MOUSE_DBLCLICK && ( m_mouseButtons & aButtonMask ) == aButtonMask;
174 }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471

References m_actions, m_mouseButtons, and TA_MOUSE_DBLCLICK.

◆ IsDrag()

bool TOOL_EVENT::IsDrag ( int  aButtonMask = BUT_ANY) const
inline

Definition at line 280 of file tool_event.h.

281  {
282  return m_actions == TA_MOUSE_DRAG && ( m_mouseButtons & aButtonMask ) == aButtonMask;
283  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471

References m_actions, m_mouseButtons, and TA_MOUSE_DRAG.

Referenced by EE_POINT_EDITOR::updateEditedPoint(), and POINT_EDITOR::updateEditedPoint().

◆ IsKeyPressed()

bool TOOL_EVENT::IsKeyPressed ( ) const
inline

Definition at line 326 of file tool_event.h.

327  {
328  return m_actions == TA_KEY_PRESSED;
329  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457

References m_actions, and TA_KEY_PRESSED.

Referenced by ROUTER_TOOL::handleCommonEvents().

◆ IsMenu()

bool TOOL_EVENT::IsMenu ( ) const
inline

Definition at line 310 of file tool_event.h.

311  {
312  return m_actions & TA_CONTEXT_MENU;
313  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457

References m_actions, and TA_CONTEXT_MENU.

Referenced by TOOL_MANAGER::dispatchInternal().

◆ IsMotion()

bool TOOL_EVENT::IsMotion ( ) const
inline

Definition at line 290 of file tool_event.h.

291  {
292  return m_actions == TA_MOUSE_MOTION;
293  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457

References m_actions, and TA_MOUSE_MOTION.

Referenced by EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), and PNS::TOOL_BASE::updateStartItem().

◆ IsMouseUp()

bool TOOL_EVENT::IsMouseUp ( int  aButtonMask = BUT_ANY) const
inline

Definition at line 285 of file tool_event.h.

286  {
287  return m_actions == TA_MOUSE_UP && ( m_mouseButtons & aButtonMask ) == aButtonMask;
288  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471

References m_actions, m_mouseButtons, and TA_MOUSE_UP.

◆ IsUndoRedo()

bool TOOL_EVENT::IsUndoRedo ( ) const
inline

Definition at line 305 of file tool_event.h.

306  {
308  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457

References m_actions, TA_UNDO_REDO_POST, and TA_UNDO_REDO_PRE.

◆ KeyCode()

int TOOL_EVENT::KeyCode ( ) const
inline

Definition at line 321 of file tool_event.h.

322  {
323  return m_keyCode;
324  }
int m_keyCode
Stores code of pressed/released key
Definition: tool_event.h:474

References m_keyCode.

Referenced by TOOL_MANAGER::dispatchStandardEvents(), and ROUTER_TOOL::handleCommonEvents().

◆ Matches()

bool TOOL_EVENT::Matches ( const TOOL_EVENT aEvent) const
inline

Function Matches() Tests whether two events match in terms of category & action or command.

Parameters
aEventis the event to test against.
Returns
True if two events match, false otherwise.

Definition at line 338 of file tool_event.h.

339  {
340  if( !( m_category & aEvent.m_category ) )
341  return false;
342 
344  {
345  if( (bool) m_commandStr && (bool) aEvent.m_commandStr )
346  return *m_commandStr == *aEvent.m_commandStr;
347 
348  if( (bool) m_commandId && (bool) aEvent.m_commandId )
349  return *m_commandId == *aEvent.m_commandId;
350  }
351 
352  // BUGFIX: TA_ANY should match EVERYTHING, even TA_NONE (for TC_MESSAGE)
353  if( m_actions == TA_ANY && aEvent.m_actions == TA_NONE && aEvent.m_category == TC_MESSAGE )
354  return true;
355 
356  // BUGFIX: This check must happen after the TC_COMMAND check because otherwise events of
357  // the form { TC_COMMAND, TA_NONE } will be incorrectly skipped
358  if( !( m_actions & aEvent.m_actions ) )
359  return false;
360 
361  return true;
362  }
TOOL_ACTIONS m_actions
Definition: tool_event.h:457
OPT< std::string > m_commandStr
Definition: tool_event.h:483
OPT< int > m_commandId
Definition: tool_event.h:482
TOOL_EVENT_CATEGORY m_category
Definition: tool_event.h:456

References m_actions, m_category, m_commandId, m_commandStr, TA_ANY, TA_NONE, TC_COMMAND, and TC_MESSAGE.

Referenced by IsAction(), TOOL_EVT_UTILS::IsSelectionEvent(), LIB_EDIT_TOOL::Mirror(), SCH_EDIT_TOOL::Mirror(), LIB_EDIT_TOOL::Rotate(), and SCH_EDIT_TOOL::Rotate().

◆ Modifier()

int TOOL_EVENT::Modifier ( int  aMask = MD_MODIFIER_MASK) const
inline

Returns information about key modifiers state (Ctrl, Alt, etc.)

Definition at line 316 of file tool_event.h.

317  {
318  return m_modifiers & aMask;
319  }
int m_modifiers
State of key modifierts (Ctrl/Alt/etc.)
Definition: tool_event.h:477

References m_modifiers.

Referenced by EE_POINT_EDITOR::addCorner(), SCH_EDIT_TOOL::BreakWire(), TOOL_MANAGER::dispatchStandardEvents(), SCH_EDITOR_CONTROL::HighlightNet(), EE_SELECTION_TOOL::SelectNode(), PNS::TOOL_BASE::updateEndItem(), and PNS::TOOL_BASE::updateStartItem().

◆ Parameter()

template<typename T >
T TOOL_EVENT::Parameter ( ) const
inline

Function Parameter() Returns a non-standard parameter assigned to the event.

Its meaning depends on the target tool.

Definition at line 378 of file tool_event.h.

379  {
380  return reinterpret_cast<T>( m_param );
381  }
void * m_param
Generic parameter used for passing non-standard data.
Definition: tool_event.h:480

References m_param.

Referenced by EE_SELECTION_TOOL::AddItemsToSel(), EE_SELECTION_TOOL::AddItemToSel(), MICROWAVE_TOOL::addMicrowaveFootprint(), PCB_EDITOR_CONTROL::CrossProbeSchToPcb(), COMMON_TOOLS::CursorControl(), SELECTION_TOOL::CursorSelection(), TOOL_EVT_UTILS::GetEventRotationAngle(), COMMON_TOOLS::GridPreset(), PCBNEW_CONTROL::GridSetOrigin(), PCB_EDITOR_CONTROL::HighlightNet(), ROUTER_TOOL::InlineDrag(), PCBNEW_CONTROL::LayerSwitch(), ROUTER_TOOL::onViaCommand(), COMMON_TOOLS::PanControl(), SCH_DRAWING_TOOLS::PlaceImage(), PCB_EDITOR_CONTROL::PlaceModule(), SCH_DRAWING_TOOLS::PlacePower(), SCH_DRAWING_TOOLS::PlaceSymbol(), EDIT_TOOL::Remove(), EE_SELECTION_TOOL::RemoveItemFromSel(), EE_SELECTION_TOOL::RemoveItemsFromSel(), EE_SELECTION_TOOL::SelectionMenu(), SELECTION_TOOL::SelectionMenu(), GERBVIEW_SELECTION_TOOL::SelectItem(), SELECTION_TOOL::SelectItem(), GERBVIEW_SELECTION_TOOL::SelectItems(), SELECTION_TOOL::SelectItems(), SELECTION_TOOL::selectSheetContents(), SCH_WIRE_BUS_TOOL::UnfoldBus(), GERBVIEW_SELECTION_TOOL::UnselectItem(), SELECTION_TOOL::UnselectItem(), GERBVIEW_SELECTION_TOOL::UnselectItems(), SELECTION_TOOL::UnselectItems(), EE_SELECTION_TOOL::UpdateMenu(), SELECTION_TOOL::UpdateMenu(), and COMMON_TOOLS::ZoomPreset().

◆ Position()

const VECTOR2D TOOL_EVENT::Position ( ) const
inline

Returns mouse cursor position in world coordinates.

Definition at line 258 of file tool_event.h.

259  {
261  }
VECTOR2D returnCheckedPosition(const VECTOR2D &aPos) const
Ensure that the event is a type that has a position before returning a position, otherwise return a n...
Definition: tool_event.h:444
VECTOR2D m_mousePos
Current mouse cursor position
Definition: tool_event.h:465

References m_mousePos, and returnCheckedPosition().

Referenced by EE_POINT_EDITOR::updateEditedPoint(), POINT_EDITOR::updateEditedPoint(), and PNS::TOOL_BASE::updateStartItem().

◆ returnCheckedPosition()

VECTOR2D TOOL_EVENT::returnCheckedPosition ( const VECTOR2D aPos) const
inlineprivate

Ensure that the event is a type that has a position before returning a position, otherwise return a null-constructed position.

Used to defend the position accessors from runtime access when the event does not have a valid position.

Parameters
aPosthe position to return if the event is valid
Returns
the checked position

Definition at line 444 of file tool_event.h.

445  {
446  #ifdef WX_COMPATIBILITY
447  wxCHECK_MSG( HasPosition(), VECTOR2D(),
448  "Attempted to get position from non-position event" );
449  #else
450  assert( HasPosition() );
451  #endif
452 
453  return aPos;
454  }
VECTOR2< double > VECTOR2D
Definition: vector2d.h:586
bool HasPosition() const
Returns if it this event has a valid position (true for mouse events)
Definition: tool_event.h:245

References HasPosition().

Referenced by Delta(), DragOrigin(), and Position().

◆ setModifiers()

void TOOL_EVENT::setModifiers ( int  aMods)
inlineprivate

Definition at line 429 of file tool_event.h.

430  {
431  assert( ( aMods & ~MD_MODIFIER_MASK ) == 0 );
432  m_modifiers = aMods;
433  }
int m_modifiers
State of key modifierts (Ctrl/Alt/etc.)
Definition: tool_event.h:477

References m_modifiers, and MD_MODIFIER_MASK.

◆ setMouseButtons()

void TOOL_EVENT::setMouseButtons ( int  aButtons)
inlineprivate

Definition at line 423 of file tool_event.h.

424  {
425  assert( ( aButtons & ~BUT_BUTTON_MASK ) == 0 );
426  m_mouseButtons = aButtons;
427  }
int m_mouseButtons
State of mouse buttons
Definition: tool_event.h:471

References BUT_BUTTON_MASK, and m_mouseButtons.

Referenced by TOOL_EVENT().

◆ setMouseDelta()

void TOOL_EVENT::setMouseDelta ( const VECTOR2D aP)
inlineprivate

Definition at line 418 of file tool_event.h.

419  {
420  m_mouseDelta = aP;
421  }
VECTOR2D m_mouseDelta
Difference between mouse cursor position and the point where dragging event has started
Definition: tool_event.h:462

References m_mouseDelta.

◆ setMouseDragOrigin()

void TOOL_EVENT::setMouseDragOrigin ( const VECTOR2D aP)
inlineprivate

Definition at line 413 of file tool_event.h.

414  {
415  m_mouseDragOrigin = aP;
416  }
VECTOR2D m_mouseDragOrigin
Point where dragging has started
Definition: tool_event.h:468

References m_mouseDragOrigin.

◆ SetMousePosition()

void TOOL_EVENT::SetMousePosition ( const VECTOR2D aP)
inline

Definition at line 405 of file tool_event.h.

406  {
407  m_mousePos = aP;
408  }
VECTOR2D m_mousePos
Current mouse cursor position
Definition: tool_event.h:465

References m_mousePos.

Referenced by COMMON_TOOLS::CursorControl().

◆ SetParameter()

template<typename T >
void TOOL_EVENT::SetParameter ( aParam)
inline

Function SetParameter() Sets a non-standard parameter assigned to the event.

Its meaning depends on the target tool.

Parameters
aParamis the new parameter.

Definition at line 390 of file tool_event.h.

391  {
392  m_param = (void*) aParam;
393  }
void * m_param
Generic parameter used for passing non-standard data.
Definition: tool_event.h:480

References m_param.

Referenced by EDIT_TOOL::cutToClipboard(), TOOL_MANAGER::dispatchContextMenu(), TOOL_MANAGER::RunAction(), and DIALOG_SET_GRID::TransferDataFromWindow().

Friends And Related Function Documentation

◆ TOOL_DISPATCHER

friend class TOOL_DISPATCHER
friend

Definition at line 411 of file tool_event.h.

Member Data Documentation

◆ m_actions

TOOL_ACTIONS TOOL_EVENT::m_actions
private

◆ m_category

TOOL_EVENT_CATEGORY TOOL_EVENT::m_category
private

Definition at line 456 of file tool_event.h.

Referenced by Buttons(), Category(), Format(), HasPosition(), and Matches().

◆ m_commandId

OPT<int> TOOL_EVENT::m_commandId
private

Definition at line 482 of file tool_event.h.

Referenced by Format(), GetCommandId(), Matches(), and TOOL_EVENT().

◆ m_commandStr

OPT<std::string> TOOL_EVENT::m_commandStr
private

Definition at line 483 of file tool_event.h.

Referenced by Format(), GetCommandStr(), Matches(), and TOOL_EVENT().

◆ m_keyCode

int TOOL_EVENT::m_keyCode
private

Stores code of pressed/released key

Definition at line 474 of file tool_event.h.

Referenced by Format(), KeyCode(), and TOOL_EVENT().

◆ m_modifiers

int TOOL_EVENT::m_modifiers
private

State of key modifierts (Ctrl/Alt/etc.)

Definition at line 477 of file tool_event.h.

Referenced by Format(), Modifier(), setModifiers(), and TOOL_EVENT().

◆ m_mouseButtons

int TOOL_EVENT::m_mouseButtons
private

State of mouse buttons

Definition at line 471 of file tool_event.h.

Referenced by Buttons(), Format(), IsClick(), IsDblClick(), IsDrag(), IsMouseUp(), and setMouseButtons().

◆ m_mouseDelta

VECTOR2D TOOL_EVENT::m_mouseDelta
private

Difference between mouse cursor position and the point where dragging event has started

Definition at line 462 of file tool_event.h.

Referenced by Delta(), and setMouseDelta().

◆ m_mouseDragOrigin

VECTOR2D TOOL_EVENT::m_mouseDragOrigin
private

Point where dragging has started

Definition at line 468 of file tool_event.h.

Referenced by DragOrigin(), and setMouseDragOrigin().

◆ m_mousePos

VECTOR2D TOOL_EVENT::m_mousePos
private

Current mouse cursor position

Definition at line 465 of file tool_event.h.

Referenced by Position(), and SetMousePosition().

◆ m_param

void* TOOL_EVENT::m_param
private

Generic parameter used for passing non-standard data.

Definition at line 480 of file tool_event.h.

Referenced by Parameter(), and SetParameter().

◆ m_scope

TOOL_ACTION_SCOPE TOOL_EVENT::m_scope
private

Definition at line 458 of file tool_event.h.


The documentation for this class was generated from the following files: