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, bool aIsToggleEntry=false, 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 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 (ACTION_GROUP *aGroup, bool aIsToggleEntry=false)
 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 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 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::map< int, 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 183 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()

ACTION_TOOLBAR::~ACTION_TOOLBAR ( )
virtual

Member Function Documentation

◆ Add()

void ACTION_TOOLBAR::Add ( const TOOL_ACTION aAction,
bool  aIsToggleEntry = false,
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 226 of file action_toolbar.cpp.

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

Referenced by PCB_EDIT_FRAME::ReCreateAuxiliaryToolbar(), KICAD_MANAGER_FRAME::RecreateBaseHToolbar(), CVPCB_MAINFRAME::ReCreateHToolbar(), SIMULATOR_FRAME::ReCreateHToolbar(), DISPLAY_FOOTPRINTS_FRAME::ReCreateHToolbar(), SCH_EDIT_FRAME::ReCreateHToolbar(), SYMBOL_EDIT_FRAME::ReCreateHToolbar(), SYMBOL_VIEWER_FRAME::ReCreateHToolbar(), GERBVIEW_FRAME::ReCreateHToolbar(), PL_EDITOR_FRAME::ReCreateHToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateHToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateHToolbar(), FOOTPRINT_WIZARD_FRAME::ReCreateHToolbar(), PCB_EDIT_FRAME::ReCreateHToolbar(), EDA_3D_VIEWER_FRAME::ReCreateMainToolbar(), DISPLAY_FOOTPRINTS_FRAME::ReCreateOptToolbar(), SCH_EDIT_FRAME::ReCreateOptToolbar(), SYMBOL_EDIT_FRAME::ReCreateOptToolbar(), GERBVIEW_FRAME::ReCreateOptToolbar(), PL_EDITOR_FRAME::ReCreateOptToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar(), FOOTPRINT_VIEWER_FRAME::ReCreateOptToolbar(), PCB_EDIT_FRAME::ReCreateOptToolbar(), SCH_EDIT_FRAME::ReCreateVToolbar(), SYMBOL_EDIT_FRAME::ReCreateVToolbar(), PL_EDITOR_FRAME::ReCreateVToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateVToolbar(), and PCB_EDIT_FRAME::ReCreateVToolbar().

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

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

◆ AddGroup()

void ACTION_TOOLBAR::AddGroup ( ACTION_GROUP aGroup,
bool  aIsToggleEntry = false 
)

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

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

Parameters
aGroupis the group to add. The first action in the group will be the first shown on the toolbar.
aIsToggleEntrymakes the toolbar item a toggle entry when true

Definition at line 280 of file action_toolbar.cpp.

References doSelectAction(), ACTION_GROUP::GetDefaultAction(), TOOL_ACTION::GetIcon(), ACTION_GROUP::GetUIId(), KiBitmapBundle(), KiDisabledBitmapBundle(), m_actionGroups, m_toolActions, and m_toolKinds.

Referenced by FOOTPRINT_EDIT_FRAME::ReCreateVToolbar(), and PCB_EDIT_FRAME::ReCreateVToolbar().

◆ AddScaledSeparator()

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

References TOOL_ACTION::GetUIId(), and m_toolMenus.

Referenced by SCH_EDIT_FRAME::ReCreateOptToolbar(), SYMBOL_EDIT_FRAME::ReCreateOptToolbar(), PL_EDITOR_FRAME::ReCreateOptToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateOptToolbar(), PCB_EDIT_FRAME::ReCreateOptToolbar(), FOOTPRINT_EDIT_FRAME::ReCreateVToolbar(), and PCB_EDIT_FRAME::ReCreateVToolbar().

◆ ClearToolbar()

◆ doSelectAction()

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

◆ KiRealize()

◆ OnCustomRender()

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

Definition at line 735 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 545 of file action_toolbar.cpp.

References m_actionGroups, and popupPalette().

Referenced by ACTION_TOOLBAR().

◆ onMouseClick()

void ACTION_TOOLBAR::onMouseClick ( wxMouseEvent &  aEvent)
protected

Handler for when a drag event occurs on an item.

Definition at line 517 of file action_toolbar.cpp.

References m_actionGroups, m_palette, m_paletteTimer, and PALETTE_OPEN_DELAY.

Referenced by 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 829 of file action_toolbar.cpp.

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

Referenced by ACTION_TOOLBAR().

◆ onTimerDone()

void ACTION_TOOLBAR::onTimerDone ( wxTimerEvent &  aEvent)
protected

Definition at line 566 of file action_toolbar.cpp.

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

Referenced by 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 473 of file action_toolbar.cpp.

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

Referenced by ACTION_TOOLBAR().

◆ popupPalette()

◆ RefreshBitmaps()

void ACTION_TOOLBAR::RefreshBitmaps ( )

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

when switching icon themes)

Definition at line 838 of file action_toolbar.cpp.

References KiBitmapBundle(), KiDisabledBitmapBundle(), m_toolActions, 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 303 of file action_toolbar.cpp.

References doSelectAction(), and ACTION_GROUP::m_actions.

◆ SetAuiManager()

◆ 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 400 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 199 of file action_toolbar.h.

References m_toolManager.

Referenced by SIMULATOR_FRAME::ReCreateHToolbar().

◆ Toggle() [1/2]

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

Definition at line 427 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 416 of file action_toolbar.cpp.

References TOOL_ACTION::GetUIId(), and m_toolKinds.

◆ UpdateControlWidth()

Member Data Documentation

◆ CANCEL

◆ m_actionGroups

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

◆ m_auiManager

wxAuiManager* ACTION_TOOLBAR::m_auiManager
protected

Definition at line 345 of file action_toolbar.h.

Referenced by popupPalette(), and SetAuiManager().

◆ m_palette

ACTION_TOOLBAR_PALETTE* ACTION_TOOLBAR::m_palette
protected

Definition at line 347 of file action_toolbar.h.

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

◆ m_paletteTimer

wxTimer* ACTION_TOOLBAR::m_paletteTimer
protected

Definition at line 343 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 350 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 349 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


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