40#include <wx/stc/stc.h>
41#include <wx/settings.h>
49 const wxEventType& aUpEvent,
const wxEventType& aDblClickEvent ) :
98 wxMouseState mouseState = wxGetMouseState();
103 return mouseState.LeftIsDown();
106 return mouseState.MiddleIsDown();
109 return mouseState.RightIsDown();
112 return mouseState.Aux1IsDown();
115 return mouseState.Aux2IsDown();
118 wxFAIL_MSG( wxT(
"unknown button" ) );
126 m_toolMgr( aToolMgr ),
127 m_currentMenu( nullptr )
136 wxEVT_LEFT_UP, wxEVT_LEFT_DCLICK ) );
138 wxEVT_RIGHT_UP, wxEVT_RIGHT_DCLICK ) );
140 wxEVT_MIDDLE_UP, wxEVT_MIDDLE_DCLICK ) );
142 wxEVT_AUX1_UP, wxEVT_AUX1_DCLICK ) );
144 wxEVT_AUX2_UP, wxEVT_AUX2_DCLICK ) );
173 wxEventType type = aEvent.GetEventType();
174 std::optional<TOOL_EVENT> evt;
175 bool isClick =
false;
179 bool up =
false,
down =
false;
195 int args = st->
button | mods;
276 const std::vector<enum wxKeyCode> special_keys =
278 WXK_PAGEUP, WXK_PAGEDOWN,
279 WXK_NUMPAD_PAGEUP, WXK_NUMPAD_PAGEDOWN
291 static std::vector<enum wxKeyCode> special_keys =
293 WXK_CONTROL, WXK_RAW_CONTROL, WXK_SHIFT, WXK_ALT
302 return type == wxEVT_LEFT_DOWN || type == wxEVT_LEFT_UP || type == wxEVT_LEFT_DCLICK
303 || type == wxEVT_MIDDLE_DOWN || type == wxEVT_MIDDLE_UP || type == wxEVT_MIDDLE_DCLICK
304 || type == wxEVT_RIGHT_DOWN || type == wxEVT_RIGHT_UP || type == wxEVT_RIGHT_DCLICK
305 || type == wxEVT_AUX1_DOWN || type == wxEVT_AUX1_UP || type == wxEVT_AUX1_DCLICK
306 || type == wxEVT_AUX2_DOWN || type == wxEVT_AUX2_UP || type == wxEVT_AUX2_DCLICK;
326 case WXK_NUMPAD_UP:
return WXK_UP;
327 case WXK_NUMPAD_DOWN:
return WXK_DOWN;
328 case WXK_NUMPAD_LEFT:
return WXK_LEFT;
329 case WXK_NUMPAD_RIGHT:
return WXK_RIGHT;
330 case WXK_NUMPAD_PAGEUP:
return WXK_PAGEUP;
331 case WXK_NUMPAD_PAGEDOWN:
return WXK_PAGEDOWN;
341 std::optional<TOOL_EVENT> evt;
342 int key = aKeyEvent->GetKeyCode();
343 int unicode_key = aKeyEvent->GetUnicodeKey();
358 if( aKeyEvent->GetEventType() == wxEVT_CHAR_HOOK )
375 if( unicode_key >=
'A' && unicode_key <=
'Z' && key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
379 if( key >= WXK_CONTROL_A && key <= WXK_CONTROL_Z )
391 switch( aKeyEvent->GetRawKeyCode() )
393 case 0x12: key =
'1';
break;
394 case 0x13: key =
'2';
break;
395 case 0x14: key =
'3';
break;
396 case 0x15: key =
'4';
break;
397 case 0x16: key =
'6';
break;
398 case 0x17: key =
'5';
break;
399 case 0x18: key =
'=';
break;
400 case 0x19: key =
'9';
break;
401 case 0x1A: key =
'7';
break;
402 case 0x1B: key =
'-';
break;
403 case 0x1C: key =
'8';
break;
404 case 0x1D: key =
'0';
break;
410 if( key == WXK_ESCAPE )
422 bool buttonEvents =
false;
424 std::optional<TOOL_EVENT> evt;
425 bool keyIsEscape =
false;
426 bool keyIsSpecial =
false;
427 wxWindow* focus = wxWindow::FindFocus();
434 wxEventType type = aEvent.GetEventType();
440 if( focus ==
nullptr )
444#if defined( _WIN32 ) || defined( __WXGTK__ )
452 holderWindow->SetFocus();
467 if( type == wxEVT_MOTION || type == wxEVT_MOUSEWHEEL ||
468 type == wxEVT_MAGNIFY ||
474 wxMouseEvent* me =
static_cast<wxMouseEvent*
>( &aEvent );
489 for(
unsigned int i = 0; i <
m_buttons.size(); i++ )
494 if( !buttonEvents && motion )
497 evt->SetMousePosition( pos );
503 if( !evt && me->GetWheelRotation() != 0 )
506 evt->SetParameter<
int>( me->GetWheelRotation() );
509 else if( type == wxEVT_CHAR_HOOK || type == wxEVT_CHAR )
511 wxKeyEvent* ke =
static_cast<wxKeyEvent*
>( &aEvent );
519 if( type == wxEVT_CHAR_HOOK && ke->GetModifiers() == wxMOD_SHIFT )
525 keyIsEscape = ( ke->GetKeyCode() == WXK_ESCAPE );
538 else if( ke->GetModifiers() == wxMOD_CONTROL && ke->GetKeyCode() ==
'C' )
547 else if( type == wxEVT_MENU_OPEN || type == wxEVT_MENU_CLOSE || type == wxEVT_MENU_HIGHLIGHT )
549 wxMenuEvent* tmp =
dynamic_cast<wxMenuEvent*
>( &aEvent );
559 wxMenuEvent& menuEvent = *tmp;
561#if wxCHECK_VERSION( 3, 2, 0 )
564 currentMenu->OnMenuEvent( menuEvent );
580 if( type == wxEVT_MENU_OPEN )
587 else if( type == wxEVT_MENU_HIGHLIGHT )
592 else if( type == wxEVT_MENU_CLOSE )
604 bool handled =
false;
608 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_DISPATCHER::DispatchWxEvent %s" ), evt->Format() );
612 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_DISPATCHER::DispatchWxEvent - Handled: %s %s" ),
613 ( handled ? wxS(
"true" ) : wxS(
"false" ) ), evt->Format() );
630 if( !evt || type == wxEVT_LEFT_DOWN )
638 if( ( type == wxEVT_CHAR || type == wxEVT_CHAR_HOOK )
646 wxLogTrace(
kicadTraceToolStack,
"TOOL_DISPATCHER::DispatchWxEvent - Wx event skipped: %s",
647 ( 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.