34#include <wx/clipbrd.h>
159 auto state = std::make_unique<TOOL_STATE>( *
this );
210 m_viewControls( nullptr ),
212 m_settings( nullptr ),
213 m_warpMouseAfterContextMenu( true ),
214 m_menuActive( false ),
216 m_activeState( nullptr ),
217 m_shuttingDown( false )
225 std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end;
229 delete it->second->cofunc;
241 wxT(
"Adding two tools with the same name may result in unexpected behavior.") );
243 wxT(
"Adding two tools with the same ID may result in unexpected behavior.") );
245 wxT(
"Adding two tools of the same type may result in unexpected behavior.") );
294 wxASSERT_MSG(
false,
wxString::Format(
"Could not find action %s.", aActionName ) );
327 bool handled =
false;
335 event.SetParameter( aParam );
400 wxASSERT( aTool !=
nullptr );
415 wxASSERT( aTool !=
nullptr );
419 wxASSERT_MSG(
false, wxT(
"You cannot run unregistered tools" ) );
468 for(
auto id : tmpList )
476 for(
auto id : tmpList )
502 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_MANAGER::ShutdownTool - no tool with name %s" ),
509 wxASSERT( aTool !=
nullptr );
515 TOOL_MANAGER::ID_LIST::iterator it = std::find(
m_activeTools.begin(),
531 wxS(
"TOOL_MANAGER::ShutdownTool - Shutting down tool %s" ),
547 std::map<TOOL_ID, TOOL_STATE*>::const_iterator it =
m_toolIdIndex.find( aId );
550 return it->second->theTool;
558 std::map<std::string, TOOL_STATE*>::const_iterator it =
m_toolNameIndex.find( aName );
561 return it->second->theTool;
584 tool->
Reset( aReason );
631 if( tool == aToolId )
688 bool handled =
false;
690 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_MANAGER::dispatchInternal - received event: %s" ),
699 bool increment =
true;
726 wxS(
"TOOL_MANAGER::dispatchInternal - Waking tool %s for event: %s" ),
742 wxS(
"TOOL_MANAGER::dispatchInternal - tool %s stopped passing event: %s" ),
756 bool finished =
false;
764 if( tr.first.Matches( aEvent ) )
766 auto func_copy = tr.second;
786 wxS(
"TOOL_MANAGER::dispatchInternal - Running tool %s for event: %s" ),
812 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_MANAGER::dispatchInternal - %s handle event: %s" ),
813 ( handled ? wxS(
"Did" ) : wxS(
"Did not" ) ), aEvent.
Format() );
830 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_MANAGER::dispatchActivation - Received event: %s" ),
840 wxS(
"TOOL_MANAGER::dispatchActivation - Running tool %s for event: %s" ),
841 tool->second->theTool->GetName(), aEvent.
Format() );
843 runTool( tool->second->theTool );
883 for(
const std::pair<const TOOL_ID, TOOL_STATE*>& idState :
m_toolIdIndex )
888 if( vc.m_forceCursorPosition )
898 std::unique_ptr<ACTION_MENU> menu( m->
Clone() );
903 if( wxWindow* frame =
dynamic_cast<wxWindow*
>(
m_frame ) )
904 frame->PopupMenu( menu.get() );
907 if( menu->GetSelected() < 0 )
992#if defined( __WXMAC__ )
993 wxTheApp->ProcessPendingEvents();
1017 if( wxTheClipboard->Open() )
1020 wxTheClipboard->SetData(
new wxTextDataObject( wxString( aTextUTF8.c_str(),
1023 wxTheClipboard->Flush();
1024 wxTheClipboard->Close();
1039 if( wxTheClipboard->Open() )
1041 if( wxTheClipboard->IsSupported( wxDF_TEXT )
1042 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
1044 wxTextDataObject data;
1045 wxTheClipboard->GetData( data );
1049 result = data.GetText().utf8_str();
1052 wxTheClipboard->Close();
1062 return active->vcSettings;
1070 static int currentId;
1115 it->second = std::nullopt;
1121 std::optional<VECTOR2D>
cursor = it->second;
1184 wxLogTrace(
kicadTraceToolStack, wxS(
"TOOL_MANAGER::processEvent - %s handle event: %s" ),
1185 ( handled ?
"Did" :
"Did not" ), aEvent.
Format() );
1206 return !it->second->idle;
Manage TOOL_ACTION objects.
bool RunHotKey(int aHotKey) const
Run an action associated with a hotkey (if there is one available).
TOOL_ACTION * FindAction(const std::string &aActionName) const
Find an action with a given name (if there is one available).
int GetHotKey(const TOOL_ACTION &aAction) const
Return the hot key associated with a given action or 0 if there is none.
void UpdateHotKeys(bool aFullUpdate)
Optionally read the hotkey config files and then rebuilds the internal hotkey maps.
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
bool Call(ArgType aArg)
Start execution of a coroutine, passing args as its arguments.
void KiYield()
Stop execution of the coroutine and returns control to the caller.
bool Resume()
Resume execution of a previously yielded coroutine.
void RunMainStack(std::function< void()> func)
Run a functor inside the application main stack context.
The base frame for deriving all KiCad main window classes.
virtual void UpdateStatusBar()
Update the status bar information.
A base class for most all the KiCad significant classes used in schematics and boards.
An interface for classes handling user events controlling the view behavior such as zooming,...
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
void ApplySettings(const VC_SETTINGS &aSettings)
Load new settings from program common settings.
const VC_SETTINGS & GetSettings() const
Apply VIEW_CONTROLS settings from an object.
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
bool IsDirty() const
Return true if any of the VIEW layers needs to be refreshened.
Base window classes and related definitions.
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
bool contains(const _Container &__container, _Value __value)
Returns true if the container contains the given value.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
VECTOR2D m_forcedPosition
Is the forced cursor position enabled.
void Reset()
Flag determining the cursor visibility.
bool m_forceCursorPosition
Should the cursor be locked within the parent window area.
wxLogTrace helper definitions.
VECTOR2D ToVECTOR2D(const wxPoint &aPoint)