32#include <wx/stc/stc.h>
33#include <wx/settings.h>
55 const wxEventType& aUpEvent,
const wxEventType& aDblClickEvent ) :
104 wxMouseState mouseState = wxGetMouseState();
109 return mouseState.LeftIsDown();
112 return mouseState.MiddleIsDown();
115 return mouseState.RightIsDown();
118 return mouseState.Aux1IsDown();
121 return mouseState.Aux2IsDown();
124 wxFAIL_MSG( wxT(
"unknown button" ) );
132 m_toolMgr( aToolMgr )
141 wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK ) );
143 wxEVT_RIGHT_UP, wxEVT_RIGHT_DCLICK ) );
145 wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DCLICK ) );
147 wxEVT_AUX1_UP, wxEVT_AUX1_DCLICK ) );
149 wxEVT_AUX2_UP, wxEVT_AUX2_DCLICK ) );
178 wxEventType type = aEvent.GetEventType();
179 std::optional<TOOL_EVENT> evt;
180 bool isClick =
false;
184 bool up =
false,
down =
false;
200 int args = st->
button | mods;
282 const std::vector<enum wxKeyCode> special_keys =
284 WXK_PAGEUP, WXK_PAGEDOWN,
285 WXK_NUMPAD_PAGEUP, WXK_NUMPAD_PAGEDOWN
298 static std::vector<enum wxKeyCode> special_keys =
300 WXK_CONTROL, WXK_RAW_CONTROL, WXK_SHIFT, WXK_ALT
309 return type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP || type == wxEVT_LEFT_DCLICK
310 || type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_MIDDLE_DCLICK
311 || type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP || type == wxEVT_RIGHT_DCLICK
312 || type == wxEVT_AUX1_DOWN || type == wxEVT_AUX1_UP || type == wxEVT_AUX1_DCLICK
313 || type == wxEVT_AUX2_DOWN || type == wxEVT_AUX2_UP || type == wxEVT_AUX2_DCLICK;
335 case WXK_NUMPAD_UP:
return WXK_UP;
336 case WXK_NUMPAD_DOWN:
return WXK_DOWN;
337 case WXK_NUMPAD_LEFT:
return WXK_LEFT;
338 case WXK_NUMPAD_RIGHT:
return WXK_RIGHT;
339 case WXK_NUMPAD_PAGEUP:
return WXK_PAGEUP;
340 case WXK_NUMPAD_PAGEDOWN:
return WXK_PAGEDOWN;
350 std::optional<TOOL_EVENT> evt;
351 int key = aKeyEvent->GetKeyCode();
352 int unicode_key = aKeyEvent->GetUnicodeKey();
367 if( aKeyEvent->GetEventType() == wxEVT_CHAR_HOOK )
384 if( unicode_key >=
'A' && unicode_key <=
'Z' && key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
388 if( key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
400 switch( aKeyEvent->GetRawKeyCode() )
402 case 0x12: key =
'1';
break;
403 case 0x13: key =
'2';
break;
404 case 0x14: key =
'3';
break;
405 case 0x15: key =
'4';
break;
406 case 0x16: key =
'6';
break;
407 case 0x17: key =
'5';
break;
408 case 0x18: key =
'=';
break;
409 case 0x19: key =
'9';
break;
410 case 0x1A: key =
'7';
break;
411 case 0x1B: key =
'-';
break;
412 case 0x1C: key =
'8';
break;
413 case 0x1D: key =
'0';
break;
419 if( key == WXK_ESCAPE )
431 bool buttonEvents =
false;
433 std::optional<TOOL_EVENT> evt;
434 bool keyIsEscape =
false;
435 bool keyIsSpecial =
false;
436 wxWindow* focus = wxWindow::FindFocus();
443 wxEventType type = aEvent.GetEventType();
449 if( focus ==
nullptr )
453#if defined( _WIN32 ) || defined( __WXGTK__ )
461 holderWindow->SetFocus();
476 if( type == wxEVT_MOTION || type == wxEVT_MOUSEWHEEL ||
477 type == wxEVT_MAGNIFY ||
483 wxMouseEvent* me =
static_cast<wxMouseEvent*
>( &aEvent );
498 for(
unsigned int i = 0; i <
m_buttons.size(); i++ )
503 if( !buttonEvents && motion )
506 evt->SetMousePosition( pos );
515 if( !evt && me->GetWheelRotation() != 0 )
517 const unsigned modBits =
519 const bool shouldHandle = std::popcount( modBits ) > 1;
524 evt->SetParameter<
int>( me->GetWheelRotation() );
528 else if( type == wxEVT_CHAR_HOOK || type == wxEVT_CHAR )
530 wxKeyEvent* ke =
static_cast<wxKeyEvent*
>( &aEvent );
538 if( type == wxEVT_CHAR_HOOK && ke->GetModifiers() == wxMOD_SHIFT )
544 keyIsEscape = ( ke->GetKeyCode() == WXK_ESCAPE );
557 else if( ke->GetModifiers() == wxMOD_CONTROL && ke->GetKeyCode() ==
'C' )
566 else if( type == wxEVT_MENU_OPEN || type == wxEVT_MENU_CLOSE || type == wxEVT_MENU_HIGHLIGHT )
568 wxMenuEvent* tmp =
dynamic_cast<wxMenuEvent*
>( &aEvent );
578 wxMenuEvent& menuEvent = *tmp;
580#if wxCHECK_VERSION( 3, 2, 0 )
583 currentMenu->OnMenuEvent( menuEvent );
601 if( type == wxEVT_MENU_OPEN )
603 currentMenu =
dynamic_cast<ACTION_MENU*
>( menuEvent.GetMenu() );
608 else if( type == wxEVT_MENU_HIGHLIGHT )
613 else if( type == wxEVT_MENU_CLOSE )
618 currentMenu =
nullptr;
625 bool handled =
false;
635 wxS(
"TOOL_DISPATCHER::DispatchWxEvent - Handled: %s %s" ),
636 ( handled ? wxS(
"true" ) : wxS(
"false" ) ), evt->Format() );
653 if( !evt || type == wxEVT_LEFT_DOWN )
661 if( ( type == wxEVT_CHAR || type == wxEVT_CHAR_HOOK )
669 wxLogTrace(
kicadTraceToolStack,
"TOOL_DISPATCHER::DispatchWxEvent - Wx event skipped: %s",
670 ( aEvent.GetSkipped() ?
"true" :
"false" ) );
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
static const wxEventType EVT_REFRESH_MOUSE
Event that forces mouse move event in the dispatcher (eg.
const wxChar *const kicadTraceKeyEvent
Flag to enable wxKeyEvent debug tracing.
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
void ignore_unused(const T &)
This file contains miscellaneous commonly used macros and functions.
KICOMMON_API bool IsInputControlFocused(wxWindow *aFocus=nullptr)
Check if a input control has focus.
KICOMMON_API bool IsInputControlEditable(wxWindow *aControl)
Check if a input control has focus.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
wxString dump(const wxArrayString &aArray)
Debug helper for printing wxArrayString contents.
wxLogTrace helper definitions.
WX_VIEW_CONTROLS class definition.