34 #include <wx/clipbrd.h> 152 auto state = std::make_unique<TOOL_STATE>( *
this );
203 m_viewControls( nullptr ),
205 m_settings( nullptr ),
206 m_warpMouseAfterContextMenu( true ),
207 m_menuActive( false ),
209 m_activeState( nullptr )
217 std::map<TOOL_BASE*, TOOL_STATE*>::iterator it, it_end;
221 delete it->second->cofunc;
233 wxT(
"Adding two tools with the same name may result in unexpected behavior.") );
235 wxT(
"Adding two tools with the same ID may result in unexpected behavior.") );
237 wxT(
"Adding two tools of the same type may result in unexpected behavior.") );
286 wxASSERT_MSG(
false,
wxString::Format(
"Could not find action %s.", aActionName ) );
301 return wxGetMousePosition();
310 return wxGetMousePosition();
316 bool handled =
false;
324 event.SetParameter( aParam );
353 modifiers |= wxGetKeyState( WXK_SHIFT ) ?
MD_SHIFT : 0;
354 modifiers |= wxGetKeyState( WXK_CONTROL ) ?
MD_CTRL : 0;
355 modifiers |= wxGetKeyState( WXK_ALT ) ?
MD_ALT : 0;
389 wxASSERT( aTool !=
nullptr );
404 wxASSERT( aTool !=
nullptr );
408 wxASSERT_MSG(
false, wxT(
"You cannot run unregistered tools" ) );
418 static_cast<TOOL_INTERACTIVE*>( aTool )->resetTransitions();
453 for(
auto id : tmpList )
479 wxLogTrace(
kicadTraceToolStack, wxT(
"TOOL_MANAGER::ShutdownTool - no tool with name %s" ),
486 wxASSERT( aTool !=
nullptr );
492 TOOL_MANAGER::ID_LIST::iterator it = std::find(
m_activeTools.begin(),
498 if( st && st->pendingWait )
502 st->pendingWait =
false;
503 st->waitEvents.clear();
508 wxT(
"TOOL_MANAGER::ShutdownTool - Shutting down tool %s" ),
509 st->theTool->GetName() );
512 bool end = !st->cofunc->Resume();
524 std::map<TOOL_ID, TOOL_STATE*>::const_iterator it =
m_toolIdIndex.find( aId );
527 return it->second->theTool;
535 std::map<std::string, TOOL_STATE*>::const_iterator it =
m_toolNameIndex.find( aName );
538 return it->second->theTool;
560 tool->
Reset( aReason );
563 static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();
607 if( tool == aToolId )
664 bool handled =
false;
666 wxLogTrace(
kicadTraceToolStack, wxT(
"TOOL_MANAGER::dispatchInternal - received event: %s" ),
675 bool increment =
true;
702 wxT(
"TOOL_MANAGER::dispatchInternal - Waking tool %s for event: %s" ),
718 wxT(
"TOOL_MANAGER::dispatchInternal - tool %s stopped passing event: %s" ),
732 bool finished =
false;
740 if( tr.first.Matches( aEvent ) )
742 auto func_copy = tr.second;
762 wxT(
"TOOL_MANAGER::dispatchInternal - Running tool %s for event: %s" ),
787 wxLogTrace(
kicadTraceToolStack, wxT(
"TOOL_MANAGER::dispatchInternal - %s handle event: %s" ),
788 ( handled ? wxT(
"Did" ) : wxT(
"Did not" ) ), aEvent.
Format() );
805 wxLogTrace(
kicadTraceToolStack, wxT(
"TOOL_MANAGER::dispatchActivation - Received event: %s" ),
817 wxT(
"TOOL_MANAGER::dispatchActivation - Running tool %s for event: %s" ),
818 tool->second->theTool->GetName(), aEvent.
Format() );
820 runTool( tool->second->theTool );
865 if( vc.m_forceCursorPosition )
875 std::unique_ptr<ACTION_MENU> menu( m->
Clone() );
880 if( wxWindow* frame = dynamic_cast<wxWindow*>(
m_frame ) )
881 frame->PopupMenu( menu.get() );
884 if( menu->GetSelected() < 0 )
944 static_cast<TOOL_INTERACTIVE*>( tool )->resetTransitions();
964 #if defined( __WXMAC__ ) 965 wxTheApp->ProcessPendingEvents();
989 if( wxTheClipboard->Open() )
992 wxTheClipboard->SetData(
new wxTextDataObject( wxString( aTextUTF8.c_str(),
995 wxTheClipboard->Flush();
996 wxTheClipboard->Close();
1011 if( wxTheClipboard->Open() )
1013 if( wxTheClipboard->IsSupported( wxDF_TEXT )
1014 || wxTheClipboard->IsSupported( wxDF_UNICODETEXT ) )
1016 wxTextDataObject data;
1017 wxTheClipboard->GetData( data );
1021 result = data.GetText().utf8_str();
1024 wxTheClipboard->Close();
1034 return active->vcSettings;
1042 static int currentId;
1156 wxLogTrace(
kicadTraceToolStack, wxT(
"TOOL_MANAGER::processEvent - %s handle event: %s" ),
1157 ( handled ? wxT(
"Did" ) : wxT(
"Did not" ) ), aEvent.
Format() );
1178 return !it->second->idle;
void RunMainStack(std::function< void()> func)
Run a functor inside the application main stack context.
void Reset()
Flag determining the cursor visibility.
virtual VECTOR2D GetMousePosition(bool aWorldCoordinates=true) const =0
Return the current mouse pointer position.
const std::map< std::string, TOOL_ACTION * > & GetActions() const
Get a list of currently-registered actions mapped by their name.
bool Call(ArgType aArg)
Start execution of a coroutine, passing args as its arguments.
void ApplySettings(const VC_SETTINGS &aSettings)
Load new settings from program common settings.
VECTOR2D m_forcedPosition
Is the forced cursor position enabled.
void UpdateHotKeys(bool aFullUpdate)
Optionally read the hotkey config files and then rebuilds the internal hotkey maps.
Manage TOOL_ACTION objects.
TOOL_ACTION * FindAction(const std::string &aActionName) const
Find an action with a given name (if there is one available).
const VC_SETTINGS & GetSettings() const
Apply VIEW_CONTROLS settings from an object.
virtual void UpdateStatusBar()
Update the status bar information.
bool RunHotKey(int aHotKey) const
Run an action associated with a hotkey (if there is one available).
APP_SETTINGS_BASE is a settings class that should be derived for each standalone KiCad application.
bool m_forceCursorPosition
Should the cursor be locked within the parent window area.
int GetHotKey(const TOOL_ACTION &aAction) const
Return the hot key associated with a given action or 0 if there is none.
Base window classes and related definitions.
Structure to keep VIEW_CONTROLS settings for easy store/restore operations.
An interface for classes handling user events controlling the view behavior such as zooming,...
wxLogTrace helper definitions.
virtual void ForceCursorPosition(bool aEnabled, const VECTOR2D &aPosition=VECTOR2D(0, 0))
Place the cursor immediately at a given point.
bool Resume()
Resume execution of a previously yielded coroutine.
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.
The base frame for deriving all KiCad main window classes.
A base class for most all the KiCad significant classes used in schematics and boards.
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
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.
VECTOR2D GetCursorPosition() const
Return the current cursor position in world coordinates.
void KiYield()
Stop execution of the coroutine and returns control to the caller.