KiCad PCB EDA Suite
Loading...
Searching...
No Matches
TOOL_ACTION Class Reference

Represent a single user action. More...

#include <tool_action.h>

Inheritance diagram for TOOL_ACTION:
PSEUDO_ACTION

Public Member Functions

 TOOL_ACTION (const TOOL_ACTION_ARGS &aArgs)
 
 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)
 
 ~TOOL_ACTION ()
 
 TOOL_ACTION (const TOOL_ACTION &)=delete
 
TOOL_ACTIONoperator= (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 GetDefaultHotKeyAlt () const
 
int GetHotKey () const
 Return the hotkey keycode which initiates the action. More...
 
int GetHotKeyAlt () const
 
void SetHotKey (int aKeycode, int aKeycodeAlt=0)
 
int GetId () const
 Return the unique id of the TOOL_ACTION object. More...
 
bool HasCustomUIId () const
 Return true if this action has a custom UI ID set. More...
 
int GetUIId () const
 
TOOL_EVENT MakeEvent () const
 Return the event associated with the action (i.e. More...
 
wxString GetMenuLabel () const
 Return the translated label for the action. More...
 
wxString GetMenuItem () const
 
wxString GetTooltip (bool aIncludeHotkey=true) const
 
wxString GetButtonTooltip () const
 
wxString GetDescription () const
 
wxString GetFriendlyName () const
 Return the translated user-friendly name of the action. More...
 
TOOL_ACTION_SCOPE GetScope () const
 
template<typename T >
GetParam () const
 Return a non-standard parameter assigned to the action. More...
 
const std::optional< TOOL_ACTION_GROUPGetActionGroup () 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...
 
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
 
std::optional< TOOL_ACTION_GROUPm_group
 
const int m_defaultHotKey
 
const int m_defaultHotKeyAlt
 
int m_hotKey
 
int m_hotKeyAlt
 
const std::string m_legacyName
 
wxString m_friendlyName
 
std::optional< wxString > m_menuLabel
 
wxString m_tooltip
 
std::optional< wxString > m_description
 
BITMAPS m_icon
 
int m_id
 
std::optional< int > m_uiid
 
TOOL_ACTION_FLAGS m_flags
 
std::any 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...
 

Detailed Description

Represent a single user action.

For instance:

  • changing layer to top by pressing PgUp
  • running the DRC from the menu and so on, and so forth....

Action class groups all necessary properties of an action, including explanation, icons, hotkeys, menu items, etc.

Definition at line 268 of file tool_action.h.

Constructor & Destructor Documentation

◆ TOOL_ACTION() [1/4]

◆ TOOL_ACTION() [2/4]

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 
)

Definition at line 39 of file tool_action.cpp.

References ACTION_MANAGER::GetActionList(), and SetHotKey().

◆ ~TOOL_ACTION()

TOOL_ACTION::~TOOL_ACTION ( )

Definition at line 110 of file tool_action.cpp.

References ACTION_MANAGER::GetActionList().

◆ TOOL_ACTION() [3/4]

TOOL_ACTION::TOOL_ACTION ( const TOOL_ACTION )
delete

◆ TOOL_ACTION() [4/4]

TOOL_ACTION::TOOL_ACTION ( )
protected

Definition at line 60 of file tool_action.cpp.

References SetHotKey().

Member Function Documentation

◆ GetActionGroup()

const std::optional< TOOL_ACTION_GROUP > TOOL_ACTION::GetActionGroup ( ) const
inline

Definition at line 392 of file tool_action.h.

References m_group.

◆ GetBaseUIId()

static int TOOL_ACTION::GetBaseUIId ( )
inlinestatic

◆ GetButtonTooltip()

wxString TOOL_ACTION::GetButtonTooltip ( ) const

◆ GetDefaultHotKey()

int TOOL_ACTION::GetDefaultHotKey ( ) const
inline

Return the default hotkey (if any) for the action.

Definition at line 307 of file tool_action.h.

References m_defaultHotKey.

◆ GetDefaultHotKeyAlt()

int TOOL_ACTION::GetDefaultHotKeyAlt ( ) const
inline

Definition at line 308 of file tool_action.h.

References m_defaultHotKeyAlt.

◆ GetDescription()

◆ GetFriendlyName()

wxString TOOL_ACTION::GetFriendlyName ( ) const

◆ GetHotKey()

◆ GetHotKeyAlt()

int TOOL_ACTION::GetHotKeyAlt ( ) const
inline

Definition at line 314 of file tool_action.h.

References m_hotKeyAlt.

Referenced by ACTION_MANAGER::UpdateHotKeys().

◆ GetIcon()

◆ GetId()

int TOOL_ACTION::GetId ( ) const
inline

Return the unique id of the TOOL_ACTION object.

It is valid only after registering the TOOL_ACTION by ACTION_MANAGER.

Returns
The unique identification number. If the number is negative, then it is not valid.

Definition at line 324 of file tool_action.h.

References m_id.

Referenced by CONDITIONAL_MENU::AddCheckItem(), CONDITIONAL_MENU::AddItem(), ACTION_MANAGER::GetCondition(), ACTION_MANAGER::GetHotKey(), APPEARANCE_CONTROLS::onNetclassContextMenu(), ACTION_MANAGER::SetConditions(), and ACTION_MANAGER::UpdateHotKeys().

◆ GetMenuItem()

wxString TOOL_ACTION::GetMenuItem ( ) const

Definition at line 157 of file tool_action.cpp.

References AddHotkeyName(), GetMenuLabel(), IS_HOTKEY, and m_hotKey.

Referenced by ACTION_MENU::Add().

◆ GetMenuLabel()

wxString TOOL_ACTION::GetMenuLabel ( ) const

◆ GetName()

◆ GetParam()

template<typename T >
T TOOL_ACTION::GetParam ( ) const
inline

Return a non-standard parameter assigned to the action.

Definition at line 372 of file tool_action.h.

References m_param, and name.

◆ GetScope()

TOOL_ACTION_SCOPE TOOL_ACTION::GetScope ( ) const
inline

Definition at line 366 of file tool_action.h.

References m_scope.

Referenced by HOTKEY_STORE::CheckKeyConflicts().

◆ GetToolName()

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 208 of file tool_action.cpp.

References m_name.

Referenced by HOTKEY_STORE::CheckKeyConflicts(), NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), and NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages().

◆ GetTooltip()

wxString TOOL_ACTION::GetTooltip ( bool  aIncludeHotkey = true) const

◆ GetUIId()

◆ HasCustomUIId()

bool TOOL_ACTION::HasCustomUIId ( ) const
inline

Return true if this action has a custom UI ID set.

Definition at line 329 of file tool_action.h.

References m_uiid.

Referenced by ACTION_MANAGER::RegisterAction().

◆ IsActivation()

bool TOOL_ACTION::IsActivation ( ) const
inline

Return true if the action is intended to activate a tool.

Definition at line 404 of file tool_action.h.

References AF_ACTIVATE, and m_flags.

Referenced by MakeEvent().

◆ IsNotification()

bool TOOL_ACTION::IsNotification ( ) const
inline

Return true if the action is a notification.

Definition at line 412 of file tool_action.h.

References AF_NOTIFY, and m_flags.

Referenced by MakeEvent().

◆ MakeEvent()

◆ operator!=()

bool TOOL_ACTION::operator!= ( const TOOL_ACTION aRhs) const
inline

Definition at line 289 of file tool_action.h.

References m_id.

◆ operator=()

TOOL_ACTION & TOOL_ACTION::operator= ( const TOOL_ACTION )
delete

◆ operator==()

bool TOOL_ACTION::operator== ( const TOOL_ACTION aRhs) const
inline

Definition at line 284 of file tool_action.h.

References m_id.

◆ SetHotKey()

void TOOL_ACTION::SetHotKey ( int  aKeycode,
int  aKeycodeAlt = 0 
)

Definition at line 201 of file tool_action.cpp.

References m_hotKey, and m_hotKeyAlt.

Referenced by ACTION_MANAGER::processHotKey(), HOTKEY_STORE::SaveAllHotkeys(), and TOOL_ACTION().

Friends And Related Function Documentation

◆ ACTION_MANAGER

friend class ACTION_MANAGER
friend

Base ID to use inside the user interface system to offset the action IDs.

Definition at line 430 of file tool_action.h.

Member Data Documentation

◆ ACTION_BASE_UI_ID

constexpr int TOOL_ACTION::ACTION_BASE_UI_ID = 20000
staticconstexprprotected

Name of the action (convention is "app.tool.actionName")

Definition at line 433 of file tool_action.h.

Referenced by GetBaseUIId(), and GetUIId().

◆ m_defaultHotKey

const int TOOL_ACTION::m_defaultHotKey
protected

Definition at line 441 of file tool_action.h.

Referenced by GetDefaultHotKey(), and ACTION_MANAGER::processHotKey().

◆ m_defaultHotKeyAlt

const int TOOL_ACTION::m_defaultHotKeyAlt
protected

Definition at line 442 of file tool_action.h.

Referenced by GetDefaultHotKeyAlt().

◆ m_description

std::optional<wxString> TOOL_ACTION::m_description
protected

Definition at line 450 of file tool_action.h.

Referenced by GetDescription(), and TOOL_ACTION().

◆ m_flags

TOOL_ACTION_FLAGS TOOL_ACTION::m_flags
protected

Definition at line 457 of file tool_action.h.

Referenced by IsActivation(), and IsNotification().

◆ m_friendlyName

wxString TOOL_ACTION::m_friendlyName
protected

Definition at line 447 of file tool_action.h.

Referenced by GetFriendlyName(), and PSEUDO_ACTION::PSEUDO_ACTION().

◆ m_group

std::optional<TOOL_ACTION_GROUP> TOOL_ACTION::m_group
protected

Definition at line 439 of file tool_action.h.

Referenced by GetActionGroup(), MakeEvent(), and TOOL_ACTION().

◆ m_hotKey

int TOOL_ACTION::m_hotKey
protected

◆ m_hotKeyAlt

int TOOL_ACTION::m_hotKeyAlt
protected

Definition at line 444 of file tool_action.h.

Referenced by GetHotKeyAlt(), PSEUDO_ACTION::PSEUDO_ACTION(), and SetHotKey().

◆ m_icon

BITMAPS TOOL_ACTION::m_icon
protected

Definition at line 452 of file tool_action.h.

Referenced by GetIcon().

◆ m_id

int TOOL_ACTION::m_id
protected

Definition at line 454 of file tool_action.h.

Referenced by GetId(), GetUIId(), operator!=(), and operator==().

◆ m_legacyName

const std::string TOOL_ACTION::m_legacyName
protected

Definition at line 445 of file tool_action.h.

Referenced by ACTION_MANAGER::processHotKey().

◆ m_menuLabel

std::optional<wxString> TOOL_ACTION::m_menuLabel
protected

Definition at line 448 of file tool_action.h.

Referenced by GetMenuLabel(), and TOOL_ACTION().

◆ m_name

std::string TOOL_ACTION::m_name
protected

◆ m_param

std::any TOOL_ACTION::m_param
protected

Definition at line 458 of file tool_action.h.

Referenced by GetParam(), MakeEvent(), and TOOL_ACTION().

◆ m_scope

TOOL_ACTION_SCOPE TOOL_ACTION::m_scope
protected

Definition at line 437 of file tool_action.h.

Referenced by GetScope(), and MakeEvent().

◆ m_tooltip

wxString TOOL_ACTION::m_tooltip
protected

Definition at line 449 of file tool_action.h.

Referenced by GetTooltip().

◆ m_uiid

std::optional<int> TOOL_ACTION::m_uiid
protected

Definition at line 455 of file tool_action.h.

Referenced by GetUIId(), HasCustomUIId(), and TOOL_ACTION().


The documentation for this class was generated from the following files: