KiCad PCB EDA Suite
PSEUDO_ACTION Class Reference
Inheritance diagram for PSEUDO_ACTION:
TOOL_ACTION

Public Member Functions

 PSEUDO_ACTION (const wxString &aLabel, int aHotKey)
 
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 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...
 

Detailed Description

Definition at line 32 of file hotkey_store.cpp.

Constructor & Destructor Documentation

◆ PSEUDO_ACTION()

PSEUDO_ACTION::PSEUDO_ACTION ( const wxString &  aLabel,
int  aHotKey 
)
inline

Definition at line 35 of file hotkey_store.cpp.

36 {
37 m_label = aLabel;
38 m_hotKey = aHotKey;
39 }
wxString m_label
Definition: tool_action.h:213

References TOOL_ACTION::m_hotKey, and TOOL_ACTION::m_label.

Member Function Documentation

◆ GetBaseUIId()

static int TOOL_ACTION::GetBaseUIId ( )
inlinestaticinherited

Definition at line 148 of file tool_action.h.

148{ return ACTION_BASE_UI_ID; }
static constexpr int ACTION_BASE_UI_ID
Name of the action (convention is "app.tool.actionName")
Definition: tool_action.h:203

References TOOL_ACTION::ACTION_BASE_UI_ID.

Referenced by ACTION_GROUP::GetUIId(), ACTION_MENU::OnMenuEvent(), and ACTION_TOOLBAR::onToolEvent().

◆ GetDefaultHotKey()

int TOOL_ACTION::GetDefaultHotKey ( ) const
inlineinherited

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

Definition at line 106 of file tool_action.h.

106{ return m_defaultHotKey; }
const int m_defaultHotKey
Definition: tool_action.h:209

References TOOL_ACTION::m_defaultHotKey.

◆ GetDescription()

wxString TOOL_ACTION::GetDescription ( bool  aIncludeHotkey = true) const
inherited

Definition at line 97 of file tool_action.cpp.

98{
99 wxString tooltip = wxGetTranslation( m_tooltip );
100
101 if( aIncludeHotkey && GetHotKey() )
102 tooltip += wxString::Format( wxT( " (%s)" ), KeyNameFromKeyCode( GetHotKey() ) );
103
104 return tooltip;
105}
wxString m_tooltip
Definition: tool_action.h:214
int GetHotKey() const
Return the hotkey keycode which initiates the action.
Definition: tool_action.h:111
wxString KeyNameFromKeyCode(int aKeycode, bool *aIsFound)
Return the key name from the key code.
void Format(OUTPUTFORMATTER *out, int aNestLevel, int aCtl, const CPTREE &aTree)
Output a PTREE into s-expression format via an OUTPUTFORMATTER derivative.
Definition: ptree.cpp:200

References Format(), TOOL_ACTION::GetHotKey(), KeyNameFromKeyCode(), and TOOL_ACTION::m_tooltip.

Referenced by ACTION_MENU::Add(), ACTION_TOOLBAR::Add(), ACTION_TOOLBAR_PALETTE::AddAction(), ACTION_TOOLBAR::AddButton(), PANEL_KICAD_LAUNCHER::CreateLaunchers(), ACTION_TOOLBAR::doSelectAction(), NL_3D_VIEWER_PLUGIN_IMPL::exportCommandsAndImages(), NL_SCHEMATIC_PLUGIN_IMPL::exportCommandsAndImages(), and NL_PCBNEW_PLUGIN_IMPL::exportCommandsAndImages().

◆ GetHotKey()

int TOOL_ACTION::GetHotKey ( ) const
inlineinherited

◆ GetIcon()

◆ GetId()

int TOOL_ACTION::GetId ( ) const
inlineinherited

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 121 of file tool_action.h.

121{ return m_id; }

References TOOL_ACTION::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_MANAGER::SetConditions(), and ACTION_MANAGER::UpdateHotKeys().

◆ GetLabel()

◆ GetMenuItem()

wxString TOOL_ACTION::GetMenuItem ( ) const
inherited

Definition at line 89 of file tool_action.cpp.

90{
91 wxString label = wxGetTranslation( m_label );
92 label.Replace( "&", "&&" );
93 return AddHotkeyName( label, m_hotKey, IS_HOTKEY );
94}
wxString AddHotkeyName(const wxString &aText, int aHotKey, HOTKEY_ACTION_TYPE aStyle)
@ IS_HOTKEY
Definition: hotkeys_basic.h:77

References AddHotkeyName(), IS_HOTKEY, TOOL_ACTION::m_hotKey, and TOOL_ACTION::m_label.

Referenced by ACTION_MENU::Add().

◆ GetName()

◆ GetParam()

void * TOOL_ACTION::GetParam ( ) const
inlineinherited

Definition at line 162 of file tool_action.h.

162{ return m_param; }
void * m_param
Definition: tool_action.h:220

References TOOL_ACTION::m_param.

◆ GetScope()

TOOL_ACTION_SCOPE TOOL_ACTION::GetScope ( ) const
inlineinherited

Definition at line 160 of file tool_action.h.

160{ return m_scope; }
TOOL_ACTION_SCOPE m_scope
Definition: tool_action.h:207

References TOOL_ACTION::m_scope.

Referenced by HOTKEY_STORE::CheckKeyConflicts().

◆ GetToolName()

std::string TOOL_ACTION::GetToolName ( ) const
inherited

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

115{
116 int dotCount = std::count( m_name.begin(), m_name.end(), '.' );
117
118 switch( dotCount )
119 {
120 case 0:
121 assert( false ); // Invalid action name format
122 return "";
123
124 case 1:
125 return m_name;
126
127 case 2:
128 return m_name.substr( 0, m_name.rfind( '.' ) );
129
130 default:
131 assert( false ); // TODO not implemented
132 return "";
133 }
134}

References TOOL_ACTION::m_name.

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

◆ GetUIId()

int TOOL_ACTION::GetUIId ( ) const
inlineinherited

Definition at line 130 of file tool_action.h.

131 {
132 // Hack for wxWidgets' use in stuff like search controls in standard file dialogs. If
133 // it doesn't find these specific IDs somewhere in the menus then it won't enable
134 // cut/copy/paste.
135 if( m_param == (void*) wxID_CUT )
136 return wxID_CUT;
137 else if( m_param == (void*) wxID_COPY )
138 return wxID_COPY;
139 else if( m_param == (void*) wxID_PASTE )
140 return wxID_PASTE;
141
142 return m_id + ACTION_BASE_UI_ID;
143 }

References TOOL_ACTION::ACTION_BASE_UI_ID, TOOL_ACTION::m_id, and TOOL_ACTION::m_param.

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(), EDA_BASE_FRAME::HandleUpdateUIEvent(), ACTION_TOOLBAR::popupPalette(), TOOLS_HOLDER::RegisterUIUpdateHandler(), ACTION_TOOLBAR::SetToolBitmap(), ACTION_TOOLBAR::Toggle(), and TOOLS_HOLDER::UnregisterUIUpdateHandler().

◆ IsActivation()

bool TOOL_ACTION::IsActivation ( ) const
inlineinherited

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

Definition at line 174 of file tool_action.h.

175 {
176 return m_flags & AF_ACTIVATE;
177 }
TOOL_ACTION_FLAGS m_flags
Definition: tool_action.h:219
@ AF_ACTIVATE
Action activates a tool.
Definition: tool_action.h:52

References AF_ACTIVATE, and TOOL_ACTION::m_flags.

Referenced by TOOL_ACTION::MakeEvent().

◆ IsNotification()

bool TOOL_ACTION::IsNotification ( ) const
inlineinherited

Return true if the action is a notification.

Definition at line 182 of file tool_action.h.

183 {
184 return m_flags & AF_NOTIFY;
185 }
@ AF_NOTIFY
Action is a notification (it is by default passed to all tools)
Definition: tool_action.h:53

References AF_NOTIFY, and TOOL_ACTION::m_flags.

Referenced by TOOL_ACTION::MakeEvent().

◆ MakeEvent()

TOOL_EVENT TOOL_ACTION::MakeEvent ( ) const
inherited

Return the event associated with the action (i.e.

the event that will be sent after activating the action).

Definition at line 72 of file tool_action.cpp.

73{
74 if( IsActivation() )
76 else if( IsNotification() )
78 else
80}
bool IsActivation() const
Return true if the action is intended to activate a tool.
Definition: tool_action.h:174
bool IsNotification() const
Return true if the action is a notification.
Definition: tool_action.h:182
Generic, UI-independent tool event.
Definition: tool_event.h:155
@ TA_ACTIVATE
Definition: tool_event.h:109
@ TA_ACTION
Definition: tool_event.h:106
@ TA_NONE
Definition: tool_event.h:60
@ TC_COMMAND
Definition: tool_event.h:51
@ TC_MESSAGE
Definition: tool_event.h:52

References TOOL_ACTION::IsActivation(), TOOL_ACTION::IsNotification(), TOOL_ACTION::m_name, TOOL_ACTION::m_param, TOOL_ACTION::m_scope, TA_ACTION, TA_ACTIVATE, TA_NONE, TC_COMMAND, and TC_MESSAGE.

Referenced by EE_SELECTION_TOOL::autostartEvent(), PANEL_KICAD_LAUNCHER::CreateLaunchers(), EDIT_TOOL::Duplicate(), TOOL_EVENT::IsAction(), EE_SELECTION_TOOL::Main(), ACTION_TOOLBAR::onPaletteEvent(), TOOLS_HOLDER::PopTool(), TOOL_MANAGER::RunAction(), ROUTER_TOOL::setTransitions(), and BOARD_EDITOR_CONTROL::setTransitions().

◆ operator!=()

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

Definition at line 88 of file tool_action.h.

89 {
90 return m_id != aRhs.m_id;
91 }

References TOOL_ACTION::m_id.

◆ operator==()

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

Definition at line 83 of file tool_action.h.

84 {
85 return m_id == aRhs.m_id;
86 }

References TOOL_ACTION::m_id.

◆ SetHotKey()

void TOOL_ACTION::SetHotKey ( int  aKeycode)
inherited

Definition at line 108 of file tool_action.cpp.

109{
110 m_hotKey = aKeycode;
111}

References TOOL_ACTION::m_hotKey.

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

Member Data Documentation

◆ ACTION_BASE_UI_ID

constexpr int TOOL_ACTION::ACTION_BASE_UI_ID = 20000
staticconstexprprotectedinherited

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

Definition at line 203 of file tool_action.h.

Referenced by TOOL_ACTION::GetBaseUIId(), and TOOL_ACTION::GetUIId().

◆ m_defaultHotKey

const int TOOL_ACTION::m_defaultHotKey
protectedinherited

Definition at line 209 of file tool_action.h.

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

◆ m_flags

TOOL_ACTION_FLAGS TOOL_ACTION::m_flags
protectedinherited

Definition at line 219 of file tool_action.h.

Referenced by TOOL_ACTION::IsActivation(), and TOOL_ACTION::IsNotification().

◆ m_hotKey

int TOOL_ACTION::m_hotKey
protectedinherited

◆ m_icon

BITMAPS TOOL_ACTION::m_icon
protectedinherited

Definition at line 215 of file tool_action.h.

Referenced by TOOL_ACTION::GetIcon().

◆ m_id

int TOOL_ACTION::m_id
protectedinherited

◆ m_label

wxString TOOL_ACTION::m_label
protectedinherited

Definition at line 213 of file tool_action.h.

Referenced by TOOL_ACTION::GetLabel(), TOOL_ACTION::GetMenuItem(), and PSEUDO_ACTION().

◆ m_legacyName

const std::string TOOL_ACTION::m_legacyName
protectedinherited

Definition at line 211 of file tool_action.h.

Referenced by ACTION_MANAGER::processHotKey().

◆ m_name

std::string TOOL_ACTION::m_name
protectedinherited

◆ m_param

void* TOOL_ACTION::m_param
protectedinherited

◆ m_scope

TOOL_ACTION_SCOPE TOOL_ACTION::m_scope
protectedinherited

Definition at line 207 of file tool_action.h.

Referenced by TOOL_ACTION::GetScope(), and TOOL_ACTION::MakeEvent().

◆ m_tooltip

wxString TOOL_ACTION::m_tooltip
protectedinherited

Definition at line 214 of file tool_action.h.

Referenced by TOOL_ACTION::GetDescription().


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