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 ),
133 m_currentMenu( nullptr )
142 wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK ) );
144 wxEVT_RIGHT_UP, wxEVT_RIGHT_DCLICK ) );
146 wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DCLICK ) );
148 wxEVT_AUX1_UP, wxEVT_AUX1_DCLICK ) );
150 wxEVT_AUX2_UP, wxEVT_AUX2_DCLICK ) );
179 wxEventType type = aEvent.GetEventType();
180 std::optional<TOOL_EVENT> evt;
181 bool isClick =
false;
185 bool up =
false,
down =
false;
201 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
297 static std::vector<enum wxKeyCode> special_keys =
299 WXK_CONTROL, WXK_RAW_CONTROL, WXK_SHIFT, WXK_ALT
308 return type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP || type == wxEVT_LEFT_DCLICK
309 || type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_MIDDLE_DCLICK
310 || type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP || type == wxEVT_RIGHT_DCLICK
311 || type == wxEVT_AUX1_DOWN || type == wxEVT_AUX1_UP || type == wxEVT_AUX1_DCLICK
312 || type == wxEVT_AUX2_DOWN || type == wxEVT_AUX2_UP || type == wxEVT_AUX2_DCLICK;
332 case WXK_NUMPAD_UP:
return WXK_UP;
333 case WXK_NUMPAD_DOWN:
return WXK_DOWN;
334 case WXK_NUMPAD_LEFT:
return WXK_LEFT;
335 case WXK_NUMPAD_RIGHT:
return WXK_RIGHT;
336 case WXK_NUMPAD_PAGEUP:
return WXK_PAGEUP;
337 case WXK_NUMPAD_PAGEDOWN:
return WXK_PAGEDOWN;
347 std::optional<TOOL_EVENT> evt;
348 int key = aKeyEvent->GetKeyCode();
349 int unicode_key = aKeyEvent->GetUnicodeKey();
364 if( aKeyEvent->GetEventType() == wxEVT_CHAR_HOOK )
381 if( unicode_key >=
'A' && unicode_key <=
'Z' && key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
385 if( key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
397 switch( aKeyEvent->GetRawKeyCode() )
399 case 0x12: key =
'1';
break;
400 case 0x13: key =
'2';
break;
401 case 0x14: key =
'3';
break;
402 case 0x15: key =
'4';
break;
403 case 0x16: key =
'6';
break;
404 case 0x17: key =
'5';
break;
405 case 0x18: key =
'=';
break;
406 case 0x19: key =
'9';
break;
407 case 0x1A: key =
'7';
break;
408 case 0x1B: key =
'-';
break;
409 case 0x1C: key =
'8';
break;
410 case 0x1D: key =
'0';
break;
416 if( key == WXK_ESCAPE )
428 bool buttonEvents =
false;
430 std::optional<TOOL_EVENT> evt;
431 bool keyIsEscape =
false;
432 bool keyIsSpecial =
false;
433 wxWindow* focus = wxWindow::FindFocus();
440 wxEventType type = aEvent.GetEventType();
446 if( focus ==
nullptr )
450#if defined( _WIN32 ) || defined( __WXGTK__ )
458 holderWindow->SetFocus();
473 if( type == wxEVT_MOTION || type == wxEVT_MOUSEWHEEL ||
474 type == wxEVT_MAGNIFY ||
480 wxMouseEvent* me =
static_cast<wxMouseEvent*
>( &aEvent );
495 for(
unsigned int i = 0; i <
m_buttons.size(); i++ )
500 if( !buttonEvents && motion )
503 evt->SetMousePosition( pos );
512 if( !evt && me->GetWheelRotation() != 0 )
514 const unsigned modBits =
516 const bool shouldHandle = std::popcount( modBits ) > 1;
521 evt->SetParameter<
int>( me->GetWheelRotation() );
525 else if( type == wxEVT_CHAR_HOOK || type == wxEVT_CHAR )
527 wxKeyEvent* ke =
static_cast<wxKeyEvent*
>( &aEvent );
535 if( type == wxEVT_CHAR_HOOK && ke->GetModifiers() == wxMOD_SHIFT )
541 keyIsEscape = ( ke->GetKeyCode() == WXK_ESCAPE );
554 else if( ke->GetModifiers() == wxMOD_CONTROL && ke->GetKeyCode() ==
'C' )
563 else if( type == wxEVT_MENU_OPEN || type == wxEVT_MENU_CLOSE || type == wxEVT_MENU_HIGHLIGHT )
565 wxMenuEvent* tmp =
dynamic_cast<wxMenuEvent*
>( &aEvent );
575 wxMenuEvent& menuEvent = *tmp;
577#if wxCHECK_VERSION( 3, 2, 0 )
580 currentMenu->OnMenuEvent( menuEvent );
596 if( type == wxEVT_MENU_OPEN )
603 else if( type == wxEVT_MENU_HIGHLIGHT )
608 else if( type == wxEVT_MENU_CLOSE )
620 bool handled =
false;
624 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_DISPATCHER::DispatchWxEvent %s" ), evt->Format() );
628 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_DISPATCHER::DispatchWxEvent - Handled: %s %s" ),
629 ( handled ? wxS(
"true" ) : wxS(
"false" ) ), evt->Format() );
646 if( !evt || type == wxEVT_LEFT_DOWN )
654 if( ( type == wxEVT_CHAR || type == wxEVT_CHAR_HOOK )
662 wxLogTrace(
kicadTraceToolStack,
"TOOL_DISPATCHER::DispatchWxEvent - Wx event skipped: %s",
663 ( 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
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.