KiCad PCB EDA Suite
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
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 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 wxBitmap &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 * > & GetCustomControlList ()
 Get the list of custom controls that could be used on toolbars.
 

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 onToolRightClick (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
 

Protected Attributes

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 354 of file action_toolbar.cpp.

References Add(), TOOL_ACTION::CheckToolbarState(), and TOOL_ACTION::GetName().

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 366 of file action_toolbar.cpp.

References TOOL_ACTION::GetButtonTooltip(), TOOL_ACTION::GetIcon(), TOOL_ACTION::GetUIId(), KiBitmapBundle(), KiDisabledBitmapBundle(), m_toolActions, m_toolCancellable, m_toolKinds, and Pgm().

◆ Add() [3/3]

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

Add a control to the toolbar.

Definition at line 416 of file action_toolbar.cpp.

References m_controlIDs.

◆ AddButton()

void ACTION_TOOLBAR::AddButton ( const TOOL_ACTION aAction)

Add a large button such as used in the KiCad Manager Frame's launch bar.

Parameters
aAction

Definition at line 387 of file action_toolbar.cpp.

References TOOL_ACTION::GetButtonTooltip(), TOOL_ACTION::GetIcon(), TOOL_ACTION::GetUIId(), KiBitmapBundle(), KiDisabledBitmapBundle(), m_toolActions, m_toolKinds, and Pgm().

◆ 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 433 of file action_toolbar.cpp.

References doSelectAction(), TOOL_ACTION::GetIcon(), KiBitmapBundle(), KiDisabledBitmapBundle(), m_actionGroups, m_toolActions, m_toolKinds, and Pgm().

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 402 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 424 of file action_toolbar.cpp.

References TOOL_ACTION::GetUIId(), and m_toolMenus.

◆ ApplyConfiguration()

void ACTION_TOOLBAR::ApplyConfiguration ( const TOOLBAR_CONFIGURATION aConfig)

Replace the contents of this toolbar with the configuration given in aConfig.

Parameters
aConfigis the configuration to apply to the toolbar

Definition at line 261 of file action_toolbar.cpp.

References Add(), AddGroup(), AddScaledSeparator(), ClearToolbar(), ACTION_MANAGER::FindAction(), TOOL_MANAGER::GetActionManager(), EDA_BASE_FRAME::GetCustomToolbarControlFactory(), TOOLBAR_CONFIGURATION::GetToolbarItems(), KiRealize(), m_toolManager, and tools.

Referenced by EDA_BASE_FRAME::RecreateToolbars().

◆ ClearToolbar()

void ACTION_TOOLBAR::ClearToolbar ( )

Clear the toolbar and remove all associated menus.

Definition at line 565 of file action_toolbar.cpp.

References m_actionGroups, 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

◆ GetCustomControlList()

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

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

Definition at line 348 of file action_toolbar.h.

Referenced by ACTION_TOOLBAR_CONTROL::ACTION_TOOLBAR_CONTROL(), and 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 952 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 915 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 725 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 697 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

◆ 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 1009 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 746 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

◆ onToolRightClick()

void ACTION_TOOLBAR::onToolRightClick ( wxAuiToolBarEvent &  aEvent)
protected

Handle the button select inside the palette.

Definition at line 652 of file action_toolbar.cpp.

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

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

◆ popupPalette()

◆ RefreshBitmaps()

void ACTION_TOOLBAR::RefreshBitmaps ( )

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

when switching icon themes)

Definition at line 1018 of file action_toolbar.cpp.

References KiBitmapBundle(), KiDisabledBitmapBundle(), m_toolActions, Pgm(), and Refresh().

Referenced by onThemeChanged().

◆ SelectAction()

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 465 of file action_toolbar.cpp.

References doSelectAction(), and ACTION_GROUP::m_actions.

◆ 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.

Referenced by EDA_BASE_FRAME::RecreateToolbars().

◆ SetToolBitmap()

void ACTION_TOOLBAR::SetToolBitmap ( const TOOL_ACTION aAction,
const wxBitmap &  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 579 of file action_toolbar.cpp.

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

Referenced by PCB_EDIT_FRAME::PrepareLayerIndicator().

◆ 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 606 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 595 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 529 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 522 of file action_toolbar.cpp.

References m_controlIDs, and UpdateControlWidth().

Referenced by EDA_BASE_FRAME::UpdateToolbarControlSizes().

Member Data Documentation

◆ CANCEL

constexpr bool ACTION_TOOLBAR::CANCEL = true
staticconstexpr

Definition at line 355 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 399 of file action_toolbar.h.

Referenced by 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 408 of file action_toolbar.h.

Referenced by Add(), and UpdateControlWidths().

◆ m_palette

ACTION_TOOLBAR_PALETTE* ACTION_TOOLBAR::m_palette
protected

Definition at line 401 of file action_toolbar.h.

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

◆ m_paletteTimer

wxTimer* ACTION_TOOLBAR::m_paletteTimer
protected

Definition at line 397 of file action_toolbar.h.

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

◆ 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 404 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 403 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

◆ TOGGLE

constexpr bool ACTION_TOOLBAR::TOGGLE = true
staticconstexpr

Definition at line 354 of file action_toolbar.h.


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