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

Define the structure of a toolbar with buttons that invoke ACTIONs. More...

#include <action_toolbar.h>

Inheritance diagram for ACTION_TOOLBAR:

Public Member Functions

 ACTION_TOOLBAR (EDA_BASE_FRAME *parent, wxWindowID id=wxID_ANY, const wxPoint &pos=wxDefaultPosition, const wxSize &size=wxDefaultSize, long style=wxAUI_TB_DEFAULT_STYLE)
 
virtual ~ACTION_TOOLBAR ()
 
void SetAuiManager (wxAuiManager *aManager)
 Set the AUI manager that this toolbar belongs to.
 
void SetToolManager (TOOL_MANAGER *aManager)
 
void Add (const TOOL_ACTION &aAction)
 Add a TOOL_ACTION-based button to the toolbar.
 
void Add (const TOOL_ACTION &aAction, bool aIsToggleEntry, bool aIsCancellable=false)
 Add a TOOL_ACTION-based button to the toolbar.
 
void AddButton (const TOOL_ACTION &aAction)
 Add a large button such as used in the KiCad Manager Frame's launch bar.
 
void AddScaledSeparator (wxWindow *aWindow)
 Add a separator that introduces space on either side to not squash the tools when scaled.
 
void Add (wxControl *aControl, const wxString &aLabel=wxEmptyString)
 Add a control to the toolbar.
 
void AddToolContextMenu (const TOOL_ACTION &aAction, std::unique_ptr< ACTION_MENU > aMenu)
 Add a context menu to a specific tool item on the toolbar.
 
void AddGroup (std::unique_ptr< ACTION_GROUP > aGroup)
 Add a set of actions to a toolbar as a group.
 
void SelectAction (ACTION_GROUP *aGroup, const TOOL_ACTION &aAction)
 Select an action inside a group.
 
void SelectAction (const TOOL_ACTION &aAction)
 Select the given action in whatever group contains it and update that group's icon.
 
void ApplyConfiguration (const TOOLBAR_CONFIGURATION &aConfig)
 Replace the contents of this toolbar with the configuration given in aConfig.
 
void UpdateControlWidths ()
 Update the width of all wxControl tools on thsi toolbar.
 
void UpdateControlWidth (int aID)
 Update the toolbar item width of a control using its best size.
 
void ClearToolbar ()
 Clear the toolbar and remove all associated menus.
 
void SetToolBitmap (const TOOL_ACTION &aAction, const wxBitmapBundle &aBitmap)
 Updates the bitmap of a particular tool.
 
void Toggle (const TOOL_ACTION &aAction, bool aState)
 Apply the default toggle action.
 
void Toggle (const TOOL_ACTION &aAction, bool aEnabled, bool aChecked)
 
bool KiRealize ()
 Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.
 
void RefreshBitmaps ()
 Reload all the bitmaps for the tools (e.g.
 

Static Public Member Functions

static std::list< ACTION_TOOLBAR_CONTROL * > & GetAllCustomControls ()
 Get the list of custom controls that could be used on toolbars.
 
static std::list< ACTION_TOOLBAR_CONTROL * > GetCustomControlList (FRAME_T aContext)
 Get the list of custom controls that could be used on a particular frame type.
 

Static Public Attributes

static constexpr bool TOGGLE = true
 
static constexpr bool CANCEL = true
 

Protected Member Functions

void doSelectAction (ACTION_GROUP *aGroup, const TOOL_ACTION &aAction)
 Update a group toolbar item to look like a specific action.
 
void popupPalette (wxAuiToolBarItem *aItem)
 Popup the ACTION_TOOLBAR_PALETTE associated with the ACTION_GROUP of the given toolbar item.
 
void onMouseClick (wxMouseEvent &aEvent)
 Handler for when a drag event occurs on an item.
 
void onItemDrag (wxAuiToolBarEvent &aEvent)
 The default tool event handler.
 
void onToolEvent (wxAuiToolBarEvent &aEvent)
 Handle a right-click on a menu item.
 
void onRightClick (wxAuiToolBarEvent &aEvent)
 Handle the button select inside the palette.
 
void onPaletteEvent (wxCommandEvent &aEvent)
 Handle the palette timer triggering.
 
void onTimerDone (wxTimerEvent &aEvent)
 
void onThemeChanged (wxSysColourChangedEvent &aEvent)
 Render the triangle in the lower-right corner that represents that an action palette is available for an item.
 
void OnCustomRender (wxDC &aDc, const wxAuiToolBarItem &aItem, const wxRect &aRect) override
 
void DoSetToolTipText (const wxString &aTip) override
 

Protected Attributes

EDA_BASE_FRAMEm_parent
 
wxTimer * m_paletteTimer
 
wxAuiManager * m_auiManager
 
TOOL_MANAGERm_toolManager
 
ACTION_TOOLBAR_PALETTEm_palette
 
std::map< int, bool > m_toolKinds
 
std::map< int, bool > m_toolCancellable
 
std::map< int, const TOOL_ACTION * > m_toolActions
 
std::vector< int > m_controlIDs
 IDs for all the control items in this toolbar.
 
std::map< int, std::unique_ptr< ACTION_GROUP > > m_actionGroups
 
std::map< int, std::unique_ptr< ACTION_MENU > > m_toolMenus
 

Detailed Description

Define the structure of a toolbar with buttons that invoke ACTIONs.

Definition at line 197 of file action_toolbar.h.

Constructor & Destructor Documentation

◆ ACTION_TOOLBAR()

ACTION_TOOLBAR::ACTION_TOOLBAR ( EDA_BASE_FRAME * parent,
wxWindowID id = wxID_ANY,
const wxPoint & pos = wxDefaultPosition,
const wxSize & size = wxDefaultSize,
long style = wxAUI_TB_DEFAULT_STYLE )

◆ ~ACTION_TOOLBAR()

Member Function Documentation

◆ Add() [1/3]

void ACTION_TOOLBAR::Add ( const TOOL_ACTION & aAction)

Add a TOOL_ACTION-based button to the toolbar.

The toggle/cancel attributes are set using the attributes in the action.

After selecting the entry, a TOOL_EVENT command containing name of the action is sent.

Parameters
aActionis the action to add.

Definition at line 428 of file action_toolbar.cpp.

References Add(), CANCEL, TOOL_ACTION::CheckToolbarState(), TOOL_ACTION::GetName(), HIDDEN, and TOGGLE.

Referenced by Add(), and ApplyConfiguration().

◆ Add() [2/3]

void ACTION_TOOLBAR::Add ( const TOOL_ACTION & aAction,
bool aIsToggleEntry,
bool aIsCancellable = false )

Add a TOOL_ACTION-based button to the toolbar.

After selecting the entry, a TOOL_EVENT command containing name of the action is sent.

Parameters
aActionis the action to add.
aIsToggleEntrymakes the toolbar item a toggle entry when true.
aIsCancellablewhen true, cancels the tool if clicked when tool is active.

Definition at line 440 of file action_toolbar.cpp.

References TOOL_ACTION::GetButtonTooltip(), PGM_BASE::GetCommonSettings(), TOOL_ACTION::GetIcon(), TOOL_ACTION::GetUIId(), KiBitmapBundleDef(), KiDisabledBitmapBundleDef(), COMMON_SETTINGS::m_Appearance, m_toolActions, m_toolCancellable, m_toolKinds, Pgm(), and COMMON_SETTINGS::APPEARANCE::toolbar_icon_size.

◆ Add() [3/3]

void ACTION_TOOLBAR::Add ( wxControl * aControl,
const wxString & aLabel = wxEmptyString )

Add a control to the toolbar.

Definition at line 490 of file action_toolbar.cpp.

References m_controlIDs.

◆ AddButton()

void ACTION_TOOLBAR::AddButton ( const TOOL_ACTION & aAction)

◆ AddGroup()

void ACTION_TOOLBAR::AddGroup ( std::unique_ptr< ACTION_GROUP > aGroup)

Add a set of actions to a toolbar as a group.

One action from the group will be displayed at a time.

This toolbar gets ownership of the group object, and will delete it when the ClearToolbar() function is called.

Parameters
aGroupis the group to add. The first action in the group will be the first shown on the toolbar.

Definition at line 506 of file action_toolbar.cpp.

References doSelectAction(), PGM_BASE::GetCommonSettings(), TOOL_ACTION::GetIcon(), KiBitmapBundleDef(), KiDisabledBitmapBundleDef(), m_actionGroups, COMMON_SETTINGS::m_Appearance, m_toolActions, m_toolKinds, Pgm(), TOGGLE, and COMMON_SETTINGS::APPEARANCE::toolbar_icon_size.

Referenced by ApplyConfiguration().

◆ AddScaledSeparator()

void ACTION_TOOLBAR::AddScaledSeparator ( wxWindow * aWindow)

Add a separator that introduces space on either side to not squash the tools when scaled.

Parameters
aWindowis the window to get the scaling factor of

Definition at line 476 of file action_toolbar.cpp.

References KiIconScale(), and scale.

Referenced by PCB_EDIT_FRAME::addActionPluginTools(), and ApplyConfiguration().

◆ AddToolContextMenu()

void ACTION_TOOLBAR::AddToolContextMenu ( const TOOL_ACTION & aAction,
std::unique_ptr< ACTION_MENU > aMenu )

Add a context menu to a specific tool item on the toolbar.

This toolbar gets ownership of the menu object, and will delete it when the ClearToolbar() function is called.

Parameters
aActionis the action to get the menu
aMenuis the context menu

Definition at line 498 of file action_toolbar.cpp.

References TOOL_ACTION::GetUIId(), and m_toolMenus.

Referenced by ApplyConfiguration().

◆ ApplyConfiguration()

◆ ClearToolbar()

void ACTION_TOOLBAR::ClearToolbar ( )

Clear the toolbar and remove all associated menus.

Definition at line 659 of file action_toolbar.cpp.

References m_actionGroups, m_controlIDs, m_parent, m_toolActions, m_toolCancellable, m_toolKinds, and m_toolMenus.

Referenced by ApplyConfiguration().

◆ doSelectAction()

void ACTION_TOOLBAR::doSelectAction ( ACTION_GROUP * aGroup,
const TOOL_ACTION & aAction )
protected

◆ DoSetToolTipText()

void ACTION_TOOLBAR::DoSetToolTipText ( const wxString & aTip)
overrideprotected

Definition at line 417 of file action_toolbar.cpp.

◆ GetAllCustomControls()

static std::list< ACTION_TOOLBAR_CONTROL * > & ACTION_TOOLBAR::GetAllCustomControls ( )
inlinestatic

Get the list of custom controls that could be used on toolbars.

Definition at line 354 of file action_toolbar.h.

Referenced by ACTION_TOOLBAR_CONTROL::ACTION_TOOLBAR_CONTROL(), and GetCustomControlList().

◆ GetCustomControlList()

std::list< ACTION_TOOLBAR_CONTROL * > ACTION_TOOLBAR::GetCustomControlList ( FRAME_T aContext)
static

Get the list of custom controls that could be used on a particular frame type.

Definition at line 274 of file action_toolbar.cpp.

References GetAllCustomControls().

Referenced by PCB::IFACE::CreateKiWindow().

◆ KiRealize()

bool ACTION_TOOLBAR::KiRealize ( )

Use this over Realize() to avoid a rendering glitch with fixed orientation toolbars.

The standard Realize() draws both horizontal and vertical to determine sizing However with many icons, potato PCs, etc, you can actually see that double draw This custom function avoids the double draw if the HORIZONTAL or VERTICAL toolbar properties are set.

Definition at line 1051 of file action_toolbar.cpp.

References Refresh().

Referenced by ApplyConfiguration().

◆ OnCustomRender()

void ACTION_TOOLBAR::OnCustomRender ( wxDC & aDc,
const wxAuiToolBarItem & aItem,
const wxRect & aRect )
overrideprotected

Definition at line 1014 of file action_toolbar.cpp.

References KiROUND(), and m_actionGroups.

◆ onItemDrag()

void ACTION_TOOLBAR::onItemDrag ( wxAuiToolBarEvent & aEvent)
protected

The default tool event handler.

Definition at line 827 of file action_toolbar.cpp.

References m_actionGroups, and popupPalette().

Referenced by ACTION_TOOLBAR(), and ~ACTION_TOOLBAR().

◆ onMouseClick()

void ACTION_TOOLBAR::onMouseClick ( wxMouseEvent & aEvent)
protected

Handler for when a drag event occurs on an item.

Definition at line 799 of file action_toolbar.cpp.

References m_actionGroups, m_palette, m_paletteTimer, and PALETTE_OPEN_DELAY.

Referenced by ACTION_TOOLBAR(), and ~ACTION_TOOLBAR().

◆ onPaletteEvent()

void ACTION_TOOLBAR::onPaletteEvent ( wxCommandEvent & aEvent)
protected

Handle the palette timer triggering.

Definition at line 860 of file action_toolbar.cpp.

References doSelectAction(), group, m_palette, m_toolManager, TOOL_ACTION::MakeEvent(), and TOOL_EVENT::SetHasPosition().

Referenced by popupPalette().

◆ onRightClick()

void ACTION_TOOLBAR::onRightClick ( wxAuiToolBarEvent & aEvent)
protected

Handle the button select inside the palette.

Definition at line 755 of file action_toolbar.cpp.

References m_toolActions, m_toolMenus, and ACTION_MENU::UpdateAll().

Referenced by ACTION_TOOLBAR(), and ~ACTION_TOOLBAR().

◆ onThemeChanged()

void ACTION_TOOLBAR::onThemeChanged ( wxSysColourChangedEvent & aEvent)
protected

Render the triangle in the lower-right corner that represents that an action palette is available for an item.

Definition at line 1100 of file action_toolbar.cpp.

References GetBitmapStore(), RefreshBitmaps(), and BITMAP_STORE::ThemeChanged().

Referenced by ACTION_TOOLBAR(), and ~ACTION_TOOLBAR().

◆ onTimerDone()

void ACTION_TOOLBAR::onTimerDone ( wxTimerEvent & aEvent)
protected

Definition at line 848 of file action_toolbar.cpp.

References KIPLATFORM::UI::GetMousePosition(), and popupPalette().

Referenced by ACTION_TOOLBAR(), and ~ACTION_TOOLBAR().

◆ onToolEvent()

void ACTION_TOOLBAR::onToolEvent ( wxAuiToolBarEvent & aEvent)
protected

Handle a right-click on a menu item.

Definition at line 718 of file action_toolbar.cpp.

References TOOL_ACTION::GetBaseUIId(), m_toolActions, m_toolCancellable, and m_toolManager.

Referenced by ACTION_TOOLBAR(), and ~ACTION_TOOLBAR().

◆ popupPalette()

void ACTION_TOOLBAR::popupPalette ( wxAuiToolBarItem * aItem)
protected

Popup the ACTION_TOOLBAR_PALETTE associated with the ACTION_GROUP of the given toolbar item.

Handler for a mouse up/down event

Definition at line 896 of file action_toolbar.cpp.

References BUTTON_BORDER, TOOL_ACTION::GetUIId(), group, m_actionGroups, m_auiManager, m_palette, m_paletteTimer, m_toolManager, onPaletteEvent(), and PALETTE_BORDER.

Referenced by onItemDrag(), and onTimerDone().

◆ RefreshBitmaps()

void ACTION_TOOLBAR::RefreshBitmaps ( )

Reload all the bitmaps for the tools (e.g.

when switching icon themes)

Definition at line 1109 of file action_toolbar.cpp.

References PGM_BASE::GetCommonSettings(), KiBitmapBundleDef(), KiDisabledBitmapBundleDef(), COMMON_SETTINGS::m_Appearance, m_toolActions, Pgm(), Refresh(), and COMMON_SETTINGS::APPEARANCE::toolbar_icon_size.

Referenced by onThemeChanged().

◆ SelectAction() [1/2]

void ACTION_TOOLBAR::SelectAction ( ACTION_GROUP * aGroup,
const TOOL_ACTION & aAction )

Select an action inside a group.

Parameters
aGroupis the group that contains the action
aActionis the action inside the group

Definition at line 537 of file action_toolbar.cpp.

References doSelectAction(), and ACTION_GROUP::m_actions.

◆ SelectAction() [2/2]

void ACTION_TOOLBAR::SelectAction ( const TOOL_ACTION & aAction)

Select the given action in whatever group contains it and update that group's icon.

If the action is not part of any group on this toolbar, this is a no-op.

Definition at line 551 of file action_toolbar.cpp.

References doSelectAction(), group, and m_actionGroups.

◆ SetAuiManager()

void ACTION_TOOLBAR::SetAuiManager ( wxAuiManager * aManager)
inline

Set the AUI manager that this toolbar belongs to.

Parameters
aManageris the AUI manager

Definition at line 211 of file action_toolbar.h.

References m_auiManager.

◆ SetToolBitmap()

void ACTION_TOOLBAR::SetToolBitmap ( const TOOL_ACTION & aAction,
const wxBitmapBundle & aBitmap )

Updates the bitmap of a particular tool.

Not icon-based because we use it for the custom-drawn layer pair bitmap.

Definition at line 681 of file action_toolbar.cpp.

References TOOL_ACTION::GetUIId(), and KIPLATFORM::UI::IsDarkTheme().

◆ SetToolManager()

void ACTION_TOOLBAR::SetToolManager ( TOOL_MANAGER * aManager)
inline

Definition at line 213 of file action_toolbar.h.

References m_toolManager.

◆ Toggle() [1/2]

void ACTION_TOOLBAR::Toggle ( const TOOL_ACTION & aAction,
bool aEnabled,
bool aChecked )

Definition at line 709 of file action_toolbar.cpp.

References TOOL_ACTION::GetUIId().

◆ Toggle() [2/2]

void ACTION_TOOLBAR::Toggle ( const TOOL_ACTION & aAction,
bool aState )

Apply the default toggle action.

For checked items this is check/uncheck; for non-checked items it's enable/disable.

Definition at line 698 of file action_toolbar.cpp.

References TOOL_ACTION::GetUIId(), and m_toolKinds.

◆ UpdateControlWidth()

void ACTION_TOOLBAR::UpdateControlWidth ( int aID)

Update the toolbar item width of a control using its best size.

Parameters
aIDis the ID of the toolbar item to update the width for

Definition at line 624 of file action_toolbar.cpp.

Referenced by UpdateControlWidths().

◆ UpdateControlWidths()

void ACTION_TOOLBAR::UpdateControlWidths ( )

Update the width of all wxControl tools on thsi toolbar.

Definition at line 617 of file action_toolbar.cpp.

References m_controlIDs, and UpdateControlWidth().

Member Data Documentation

◆ CANCEL

bool ACTION_TOOLBAR::CANCEL = true
staticconstexpr

Definition at line 366 of file action_toolbar.h.

◆ m_actionGroups

std::map<int, std::unique_ptr<ACTION_GROUP> > ACTION_TOOLBAR::m_actionGroups
protected

◆ m_auiManager

wxAuiManager* ACTION_TOOLBAR::m_auiManager
protected

Definition at line 413 of file action_toolbar.h.

Referenced by ACTION_TOOLBAR(), popupPalette(), and SetAuiManager().

◆ m_controlIDs

std::vector<int> ACTION_TOOLBAR::m_controlIDs
protected

IDs for all the control items in this toolbar.

Definition at line 422 of file action_toolbar.h.

Referenced by Add(), ClearToolbar(), and UpdateControlWidths().

◆ m_palette

ACTION_TOOLBAR_PALETTE* ACTION_TOOLBAR::m_palette
protected

Definition at line 415 of file action_toolbar.h.

Referenced by ACTION_TOOLBAR(), onMouseClick(), onPaletteEvent(), and popupPalette().

◆ m_paletteTimer

wxTimer* ACTION_TOOLBAR::m_paletteTimer
protected

Definition at line 411 of file action_toolbar.h.

Referenced by ACTION_TOOLBAR(), onMouseClick(), popupPalette(), and ~ACTION_TOOLBAR().

◆ m_parent

EDA_BASE_FRAME* ACTION_TOOLBAR::m_parent
protected

Definition at line 410 of file action_toolbar.h.

Referenced by ACTION_TOOLBAR(), and ClearToolbar().

◆ m_toolActions

std::map<int, const TOOL_ACTION*> ACTION_TOOLBAR::m_toolActions
protected

◆ m_toolCancellable

std::map<int, bool> ACTION_TOOLBAR::m_toolCancellable
protected

Definition at line 418 of file action_toolbar.h.

Referenced by Add(), ClearToolbar(), onToolEvent(), and ~ACTION_TOOLBAR().

◆ m_toolKinds

std::map<int, bool> ACTION_TOOLBAR::m_toolKinds
protected

Definition at line 417 of file action_toolbar.h.

Referenced by Add(), AddButton(), AddGroup(), ClearToolbar(), Toggle(), and ~ACTION_TOOLBAR().

◆ m_toolManager

TOOL_MANAGER* ACTION_TOOLBAR::m_toolManager
protected

◆ m_toolMenus

std::map<int, std::unique_ptr<ACTION_MENU> > ACTION_TOOLBAR::m_toolMenus
protected

Definition at line 425 of file action_toolbar.h.

Referenced by AddToolContextMenu(), ClearToolbar(), onRightClick(), and ~ACTION_TOOLBAR().

◆ TOGGLE

bool ACTION_TOOLBAR::TOGGLE = true
staticconstexpr

Definition at line 365 of file action_toolbar.h.


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