![]() |
KiCad PCB EDA Suite
|
Represent a single user action. More...
#include <tool_action.h>
Public Member Functions | |
TOOL_ACTION (const std::string &aName, TOOL_ACTION_SCOPE aScope=AS_CONTEXT, int aDefaultHotKey=0, const std::string &aLegacyHotKeyName="", const wxString &aMenuText=wxEmptyString, const wxString &aTooltip=wxEmptyString, BITMAPS aIcon=static_cast< BITMAPS >(0), TOOL_ACTION_FLAGS aFlags=AF_NONE, void *aParam=nullptr) | |
~TOOL_ACTION () | |
TOOL_ACTION (const TOOL_ACTION &)=delete | |
TOOL_ACTION & | operator= (const TOOL_ACTION &)=delete |
bool | operator== (const TOOL_ACTION &aRhs) const |
bool | operator!= (const TOOL_ACTION &aRhs) const |
const std::string & | GetName () const |
Return name of the action. More... | |
int | GetDefaultHotKey () const |
Return the default hotkey (if any) for the action. More... | |
int | GetHotKey () const |
Return the hotkey keycode which initiates the action. More... | |
void | SetHotKey (int aKeycode) |
int | GetId () const |
Return the unique id of the TOOL_ACTION object. More... | |
int | GetUIId () const |
TOOL_EVENT | MakeEvent () const |
Return the event associated with the action (i.e. More... | |
wxString | GetLabel () const |
wxString | GetMenuItem () const |
wxString | GetDescription (bool aIncludeHotkey=true) const |
TOOL_ACTION_SCOPE | GetScope () const |
void * | GetParam () const |
std::string | GetToolName () const |
Return name of the tool associated with the action. More... | |
bool | IsActivation () const |
Return true if the action is intended to activate a tool. More... | |
bool | IsNotification () const |
Return true if the action is a notification. More... | |
const BITMAPS | GetIcon () const |
Return an icon associated with the action. More... | |
Static Public Member Functions | |
static int | GetBaseUIId () |
Protected Member Functions | |
TOOL_ACTION () | |
Protected Attributes | |
std::string | m_name |
TOOL_ACTION_SCOPE | m_scope |
const int | m_defaultHotKey |
int | m_hotKey |
const std::string | m_legacyName |
wxString | m_label |
wxString | m_tooltip |
BITMAPS | m_icon |
int | m_id |
TOOL_ACTION_FLAGS | m_flags |
void * | m_param |
Static Protected Attributes | |
static constexpr int | ACTION_BASE_UI_ID = 20000 |
Name of the action (convention is "app.tool.actionName") More... | |
Friends | |
class | ACTION_MANAGER |
Base ID to use inside the user interface system to offset the action IDs. More... | |
Represent a single user action.
For instance:
Action class groups all necessary properties of an action, including explanation, icons, hotkeys, menu items, etc.
Definition at line 49 of file tool_action.h.
TOOL_ACTION::TOOL_ACTION | ( | const std::string & | aName, |
TOOL_ACTION_SCOPE | aScope = AS_CONTEXT , |
||
int | aDefaultHotKey = 0 , |
||
const std::string & | aLegacyHotKeyName = "" , |
||
const wxString & | aMenuText = wxEmptyString , |
||
const wxString & | aTooltip = wxEmptyString , |
||
BITMAPS | aIcon = static_cast<BITMAPS>( 0 ) , |
||
TOOL_ACTION_FLAGS | aFlags = AF_NONE , |
||
void * | aParam = nullptr |
||
) |
Definition at line 32 of file tool_action.cpp.
References ACTION_MANAGER::GetActionList(), and SetHotKey().
TOOL_ACTION::~TOOL_ACTION | ( | ) |
Definition at line 64 of file tool_action.cpp.
References ACTION_MANAGER::GetActionList().
|
delete |
|
protected |
Definition at line 52 of file tool_action.cpp.
References INVALID_BITMAP, and SetHotKey().
|
inlinestatic |
Definition at line 117 of file tool_action.h.
References ACTION_BASE_UI_ID.
Referenced by ACTION_GROUP::GetUIId(), ACTION_MENU::OnMenuEvent(), and ACTION_TOOLBAR::onToolEvent().
|
inline |
Return the default hotkey (if any) for the action.
Definition at line 88 of file tool_action.h.
References m_defaultHotKey.
wxString TOOL_ACTION::GetDescription | ( | bool | aIncludeHotkey = true | ) | const |
Definition at line 84 of file tool_action.cpp.
References Format(), GetHotKey(), KeyNameFromKeyCode(), and m_tooltip.
Referenced by ACTION_MENU::Add(), ACTION_TOOLBAR::Add(), ACTION_TOOLBAR_PALETTE::AddAction(), PANEL_KICAD_LAUNCHER::CreateLaunchers(), and ACTION_TOOLBAR::doSelectAction().
|
inline |
Return the hotkey keycode which initiates the action.
Definition at line 93 of file tool_action.h.
References m_hotKey.
Referenced by GetDescription(), PCB_LAYER_BOX_SELECTOR::Resync(), DIALOG_GRID_SETTINGS::TransferDataToWindow(), and ACTION_MANAGER::UpdateHotKeys().
|
inline |
Return an icon associated with the action.
It is used in context menu.
Definition at line 169 of file tool_action.h.
References m_icon.
Referenced by ACTION_MENU::Add(), ACTION_TOOLBAR::Add(), ACTION_TOOLBAR_PALETTE::AddAction(), ACTION_TOOLBAR::AddButton(), ACTION_TOOLBAR::AddGroup(), and ACTION_TOOLBAR::doSelectAction().
|
inline |
Return the unique id of the TOOL_ACTION object.
It is valid only after registering the TOOL_ACTION by ACTION_MANAGER.
Definition at line 103 of file tool_action.h.
References m_id.
Referenced by CONDITIONAL_MENU::AddCheckItem(), CONDITIONAL_MENU::AddItem(), ACTION_MANAGER::GetCondition(), ACTION_MANAGER::GetHotKey(), TOOL_EVENT::IsCancelInteractive(), TOOL_EVENT::IsPointEditor(), APPEARANCE_CONTROLS::onNetclassContextMenu(), ACTION_TOOLBAR::SelectAction(), ACTION_MANAGER::SetConditions(), ACTION_GROUP::SetDefaultAction(), and ACTION_MANAGER::UpdateHotKeys().
wxString TOOL_ACTION::GetLabel | ( | ) | const |
Definition at line 70 of file tool_action.cpp.
References m_label.
Referenced by PANEL_KICAD_LAUNCHER::CreateLaunchers(), TOOLS_HOLDER::PushTool(), and WIDGET_HOTKEY_LIST::resolveKeyConflicts().
wxString TOOL_ACTION::GetMenuItem | ( | ) | const |
Definition at line 76 of file tool_action.cpp.
References AddHotkeyName(), IS_HOTKEY, m_hotKey, and m_label.
Referenced by ACTION_MENU::Add().
|
inline |
Return name of the action.
It is the same one that is contained in TOOL_EVENT that is sent by activating the TOOL_ACTION. Convention is "app.tool.actionName".
Definition at line 83 of file tool_action.h.
References m_name.
Referenced by ACTION_TOOLBAR::AddButton(), ACTION_TOOLBAR::doSelectAction(), HOTKEY_STORE::GetAppName(), TOOL_EVENT::IsCancelInteractive(), TOOLS_HOLDER::IsCurrentTool(), ACTION_MANAGER::RegisterAction(), ACTION_MANAGER::RunHotKey(), and ACTION_MANAGER::SetConditions().
|
inline |
|
inline |
std::string TOOL_ACTION::GetToolName | ( | ) | const |
Return name of the tool associated with the action.
It is basically the action name stripped of the last part (e.g. for "pcbnew.InteractiveDrawing.drawCircle" it is "pcbnew.InteractiveDrawing").
Definition at line 101 of file tool_action.cpp.
References m_name.
|
inline |
Definition at line 112 of file tool_action.h.
References ACTION_BASE_UI_ID.
Referenced by ACTION_MENU::Add(), ACTION_TOOLBAR::Add(), ACTION_TOOLBAR_PALETTE::AddAction(), ACTION_TOOLBAR::AddButton(), ACTION_TOOLBAR::AddToolContextMenu(), ACTION_TOOLBAR_PALETTE::CheckAction(), ACTION_TOOLBAR_PALETTE::EnableAction(), ACTION_TOOLBAR::popupPalette(), TOOLS_HOLDER::RegisterUIUpdateHandler(), ACTION_TOOLBAR::SetToolBitmap(), ACTION_TOOLBAR::Toggle(), and TOOLS_HOLDER::UnregisterUIUpdateHandler().
|
inline |
Return true if the action is intended to activate a tool.
Definition at line 151 of file tool_action.h.
References AF_ACTIVATE.
Referenced by MakeEvent().
|
inline |
Return true if the action is a notification.
Definition at line 159 of file tool_action.h.
References AF_NOTIFY.
Referenced by MakeEvent().
|
inline |
Return the event associated with the action (i.e.
the event that will be sent after activating the action).
Definition at line 123 of file tool_action.h.
References IsActivation(), IsNotification(), TA_ACTION, TA_ACTIVATE, TA_NONE, TC_COMMAND, and TC_MESSAGE.
Referenced by PANEL_KICAD_LAUNCHER::CreateLaunchers(), EDIT_TOOL::Duplicate(), TOOL_EVENT::IsAction(), EE_SELECTION_TOOL::Main(), ACTION_TOOLBAR::onPaletteEvent(), DIALOG_SCH_FIND::OnReplace(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::RunAction(), ROUTER_TOOL::setTransitions(), and BOARD_EDITOR_CONTROL::setTransitions().
|
inline |
Definition at line 70 of file tool_action.h.
References m_id.
|
delete |
|
inline |
Definition at line 65 of file tool_action.h.
References m_id.
void TOOL_ACTION::SetHotKey | ( | int | aKeycode | ) |
Definition at line 95 of file tool_action.cpp.
References m_hotKey.
Referenced by ACTION_MANAGER::processHotKey(), HOTKEY_STORE::SaveAllHotkeys(), and TOOL_ACTION().
|
friend |
Base ID to use inside the user interface system to offset the action IDs.
Definition at line 177 of file tool_action.h.
|
staticprotected |
Name of the action (convention is "app.tool.actionName")
Definition at line 180 of file tool_action.h.
Referenced by GetBaseUIId(), and GetUIId().
|
protected |
Definition at line 186 of file tool_action.h.
Referenced by GetDefaultHotKey(), and ACTION_MANAGER::processHotKey().
|
protected |
Definition at line 196 of file tool_action.h.
|
protected |
Definition at line 187 of file tool_action.h.
Referenced by GESTURE_PSEUDO_ACTION::GESTURE_PSEUDO_ACTION(), GetHotKey(), GetMenuItem(), ACTION_MANAGER::processHotKey(), and SetHotKey().
|
protected |
Definition at line 192 of file tool_action.h.
Referenced by GetIcon().
|
protected |
Definition at line 194 of file tool_action.h.
Referenced by GetId(), operator!=(), and operator==().
|
protected |
Definition at line 190 of file tool_action.h.
Referenced by GESTURE_PSEUDO_ACTION::GESTURE_PSEUDO_ACTION(), GetLabel(), and GetMenuItem().
|
protected |
Definition at line 188 of file tool_action.h.
Referenced by ACTION_MANAGER::processHotKey().
|
protected |
Definition at line 183 of file tool_action.h.
Referenced by GetName(), GetToolName(), ACTION_MANAGER::processHotKey(), and ACTION_MANAGER::RegisterAction().
|
protected |
Definition at line 197 of file tool_action.h.
Referenced by GetParam().
|
protected |
Definition at line 184 of file tool_action.h.
Referenced by GetScope().
|
protected |
Definition at line 191 of file tool_action.h.
Referenced by GetDescription().