KiCad PCB EDA Suite
TRACK_WIDTH_MENU Class Reference
Inheritance diagram for TRACK_WIDTH_MENU:
ACTION_MENU

Public Member Functions

 TRACK_WIDTH_MENU (PCB_EDIT_FRAME &aFrame)
 
void SetTitle (const wxString &aTitle) override
 Set title for the menu. More...
 
void DisplayTitle (bool aDisplay=true)
 Decide whether a title for a pop up menu should be displayed. More...
 
void SetIcon (BITMAPS aIcon)
 Assign an icon for the entry. More...
 
wxMenuItem * Add (const wxString &aLabel, int aId, BITMAPS aIcon)
 Add a wxWidgets-style entry to the menu. More...
 
wxMenuItem * Add (const wxString &aLabel, const wxString &aToolTip, int aId, BITMAPS aIcon, bool aIsCheckmarkEntry=false)
 
wxMenuItem * Add (const TOOL_ACTION &aAction, bool aIsCheckmarkEntry=false, const wxString &aOverrideLabel=wxEmptyString)
 Add an entry to the menu based on the TOOL_ACTION object. More...
 
wxMenuItem * Add (ACTION_MENU *aMenu)
 Add an action menu as a submenu. More...
 
void AddClose (const wxString &aAppname="")
 Add a standard close item to the menu with the accelerator key CTRL-W. More...
 
void AddQuitOrClose (KIFACE_BASE *aKiface, wxString aAppname="")
 Add either a standard Quit or Close item to the menu. More...
 
void Clear ()
 Remove all the entries from the menu (as well as its title). More...
 
bool HasEnabledItems () const
 Returns true if the menu has any enabled items. More...
 
int GetSelected () const
 Return the position of selected item. More...
 
void UpdateAll ()
 Run update handlers for the menu and its submenus. More...
 
virtual void UpdateTitle ()
 Used by some menus to just-in-time translate their titles. More...
 
void ClearDirty ()
 Clear the dirty flag on the menu and all descendants. More...
 
void SetDirty ()
 
void SetTool (TOOL_INTERACTIVE *aTool)
 Set a tool that is the creator of the menu. More...
 
ACTION_MENUClone () const
 Create a deep, recursive copy of this ACTION_MENU. More...
 
void OnMenuEvent (wxMenuEvent &aEvent)
 
void OnIdle (wxIdleEvent &event)
 
virtual bool PassHelpTextToHandler ()
 

Static Public Attributes

static constexpr bool NORMAL = false
 
static constexpr bool CHECK = true
 

Protected Member Functions

ACTION_MENUcreate () const override
 < Return an instance of this class. It has to be overridden in inheriting classes. More...
 
void update () override
 Update menu state stub. More...
 
OPT_TOOL_EVENT eventHandler (const wxMenuEvent &aEvent) override
 Event handler stub. More...
 
TOOL_MANAGERgetToolManager () const
 
void copyFrom (const ACTION_MENU &aMenu)
 Copy another menus data to this instance. More...
 
wxMenuItem * appendCopy (const wxMenuItem *aSource)
 Append a copy of wxMenuItem. More...
 
void setupEvents ()
 Update hot key settings for TOOL_ACTIONs in this menu. More...
 
void updateHotKeys ()
 Traverse the submenus tree looking for a submenu capable of handling a particular menu event. More...
 
void runEventHandlers (const wxMenuEvent &aMenuEvent, OPT_TOOL_EVENT &aToolEvent)
 Run a function on the menu and all its submenus. More...
 
void runOnSubmenus (std::function< void(ACTION_MENU *)> aFunction)
 Check if any of submenus contains a TOOL_ACTION with a specific ID. More...
 
OPT_TOOL_EVENT findToolAction (int aId)
 

Protected Attributes

bool m_isForcedPosition
 
wxPoint m_forcedPosition
 
bool m_dirty
 
bool m_titleDisplayed
 
bool m_isContextMenu
 Menu title. More...
 
wxString m_title
 Optional icon. More...
 
BITMAPS m_icon
 Stores the id number of selected item. More...
 
int m_selected
 Creator of the menu. More...
 
TOOL_INTERACTIVEm_tool
 Associates tool actions with menu item IDs. Non-owning. More...
 
std::map< int, const TOOL_ACTION * > m_toolActions
 List of submenus. More...
 
std::list< ACTION_MENU * > m_submenus
 

Private Attributes

PCB_EDIT_FRAMEm_frame
 

Detailed Description

Definition at line 192 of file router_tool.cpp.

Constructor & Destructor Documentation

◆ TRACK_WIDTH_MENU()

TRACK_WIDTH_MENU::TRACK_WIDTH_MENU ( PCB_EDIT_FRAME aFrame)
inline

Definition at line 195 of file router_tool.cpp.

195 :
196 ACTION_MENU( true ),
197 m_frame( aFrame )
198 {
200 SetTitle( _( "Select Track/Via Width" ) );
201 }
@ width_track_via
ACTION_MENU(bool isContextMenu, TOOL_INTERACTIVE *aTool=nullptr)
< Default constructor
Definition: action_menu.cpp:47
void SetTitle(const wxString &aTitle) override
Set title for the menu.
Definition: action_menu.cpp:87
void SetIcon(BITMAPS aIcon)
Assign an icon for the entry.
Definition: action_menu.cpp:73
PCB_EDIT_FRAME & m_frame
#define _(s)

References _, ACTION_MENU::SetIcon(), ACTION_MENU::SetTitle(), and width_track_via.

Referenced by create().

Member Function Documentation

◆ Add() [1/4]

wxMenuItem * ACTION_MENU::Add ( ACTION_MENU aMenu)
inherited

Add an action menu as a submenu.

The difference between this function and wxMenu::AppendSubMenu() is the capability to handle icons.

Parameters
aMenuis the submenu to be added. This should be a new instance (use Clone()) if required as the menu is destructed after use.

Definition at line 184 of file action_menu.cpp.

185{
186 m_submenus.push_back( aMenu );
187
188 wxASSERT_MSG( !aMenu->m_title.IsEmpty(), "Set a title for ACTION_MENU using SetTitle()" );
189
190 if( !!aMenu->m_icon )
191 {
192 wxMenuItem* newItem = new wxMenuItem( this, -1, aMenu->m_title );
193 AddBitmapToMenuItem( newItem, KiBitmap( aMenu->m_icon ) );
194 newItem->SetSubMenu( aMenu );
195 return Append( newItem );
196 }
197 else
198 {
199 return AppendSubMenu( aMenu, aMenu->m_title );
200 }
201}
wxBitmap KiBitmap(BITMAPS aBitmap, int aHeightTag)
Construct a wxBitmap from an image identifier Returns the image from the active theme if the image ha...
Definition: bitmap.cpp:105
void AddBitmapToMenuItem(wxMenuItem *aMenu, const wxBitmap &aImage)
Add a bitmap to a menuitem.
Definition: bitmap.cpp:251
wxString m_title
Optional icon.
Definition: action_menu.h:257
std::list< ACTION_MENU * > m_submenus
Definition: action_menu.h:272
BITMAPS m_icon
Stores the id number of selected item.
Definition: action_menu.h:260

References AddBitmapToMenuItem(), KiBitmap(), ACTION_MENU::m_icon, ACTION_MENU::m_submenus, and ACTION_MENU::m_title.

◆ Add() [2/4]

wxMenuItem * ACTION_MENU::Add ( const TOOL_ACTION aAction,
bool  aIsCheckmarkEntry = false,
const wxString &  aOverrideLabel = wxEmptyString 
)
inherited

Add an entry to the menu based on the TOOL_ACTION object.

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

Parameters
aActionis the action to be added to menu entry.
aIsCheckmarkEntryis true to indicate a check menu entry, false for normal menu entry
aOverrideLabelis the label to show in the menu (overriding the action's menu text) when non-empty

ID numbers for tool actions are assigned above ACTION_BASE_UI_ID inside TOOL_EVENT

Definition at line 163 of file action_menu.cpp.

165{
167 BITMAPS icon = aAction.GetIcon();
168
169 // Allow the label to be overridden at point of use
170 wxString menuLabel = aOverrideLabel.IsEmpty() ? aAction.GetMenuItem() : aOverrideLabel;
171
172 wxMenuItem* item = new wxMenuItem( this, aAction.GetUIId(), menuLabel,
173 aAction.GetDescription(),
174 aIsCheckmarkEntry ? wxITEM_CHECK : wxITEM_NORMAL );
175 if( !!icon )
176 AddBitmapToMenuItem( item, KiBitmap( icon ) );
177
178 m_toolActions[aAction.GetUIId()] = &aAction;
179
180 return Append( item );
181}
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
std::map< int, const TOOL_ACTION * > m_toolActions
List of submenus.
Definition: action_menu.h:269
const BITMAPS GetIcon() const
Return an icon associated with the action.
Definition: tool_action.h:192
wxString GetDescription(bool aIncludeHotkey=true) const
Definition: tool_action.cpp:97
wxString GetMenuItem() const
Definition: tool_action.cpp:89
int GetUIId() const
Definition: tool_action.h:130

References AddBitmapToMenuItem(), TOOL_ACTION::GetDescription(), TOOL_ACTION::GetIcon(), TOOL_ACTION::GetMenuItem(), TOOL_ACTION::GetUIId(), KiBitmap(), and ACTION_MENU::m_toolActions.

◆ Add() [3/4]

wxMenuItem * ACTION_MENU::Add ( const wxString &  aLabel,
const wxString &  aToolTip,
int  aId,
BITMAPS  aIcon,
bool  aIsCheckmarkEntry = false 
)
inherited

Definition at line 148 of file action_menu.cpp.

150{
151 wxASSERT_MSG( FindItem( aId ) == nullptr, "Duplicate menu IDs!" );
152
153 wxMenuItem* item = new wxMenuItem( this, aId, aLabel, aTooltip,
154 aIsCheckmarkEntry ? wxITEM_CHECK : wxITEM_NORMAL );
155
156 if( !!aIcon )
157 AddBitmapToMenuItem( item, KiBitmap( aIcon ) );
158
159 return Append( item );
160}

References AddBitmapToMenuItem(), and KiBitmap().

◆ Add() [4/4]

wxMenuItem * ACTION_MENU::Add ( const wxString &  aLabel,
int  aId,
BITMAPS  aIcon 
)
inherited

◆ AddClose()

void ACTION_MENU::AddClose ( const wxString &  aAppname = "")
inherited

Add a standard close item to the menu with the accelerator key CTRL-W.

Emits the wxID_CLOSE event.

Parameters
aAppnameis the application name to append to the tooltip.

Definition at line 204 of file action_menu.cpp.

205{
206#ifdef __WINDOWS__
207 Add( _( "Close" ),
208 wxString::Format( _( "Close %s" ), aAppname ),
209 wxID_CLOSE,
211#else
212 Add( _( "Close" ) + "\tCtrl+W",
213 wxString::Format( _( "Close %s" ), aAppname ),
214 wxID_CLOSE,
216#endif
217}
wxMenuItem * Add(const wxString &aLabel, int aId, BITMAPS aIcon)
Add a wxWidgets-style entry to the menu.
#define _(s)
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 _, ACTION_MENU::Add(), exit, and Format().

Referenced by ACTION_MENU::AddQuitOrClose(), EDA_3D_VIEWER_FRAME::CreateMenuBar(), CVPCB_MAINFRAME::ReCreateMenuBar(), SYMBOL_EDIT_FRAME::ReCreateMenuBar(), SYMBOL_VIEWER_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), and FOOTPRINT_VIEWER_FRAME::ReCreateMenuBar().

◆ AddQuitOrClose()

void ACTION_MENU::AddQuitOrClose ( KIFACE_BASE aKiface,
wxString  aAppname = "" 
)
inherited

Add either a standard Quit or Close item to the menu.

If aKiface is NULL or in single-instance then quit (wxID_QUIT) is used, otherwise close (wxID_CLOSE) is used.

Parameters
aAppnameis the application name to append to the tooltip.

Definition at line 220 of file action_menu.cpp.

221{
222 if( !aKiface || aKiface->IsSingle() ) // not when under a project mgr
223 {
224 // Don't use ACTIONS::quit; wxWidgets moves this on OSX and expects to find it via
225 // wxID_EXIT
226 Add( _( "Quit" ) + "\tCtrl+Q",
227 wxString::Format( _( "Quit %s" ), aAppname ),
228 wxID_EXIT,
230 }
231 else
232 {
233 AddClose( aAppname );
234 }
235}
void AddClose(const wxString &aAppname="")
Add a standard close item to the menu with the accelerator key CTRL-W.
bool IsSingle() const
Is this KIFACE running under single_top?
Definition: kiface_base.h:105

References _, ACTION_MENU::Add(), ACTION_MENU::AddClose(), exit, Format(), and KIFACE_BASE::IsSingle().

Referenced by SCH_EDIT_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), and PCB_EDIT_FRAME::ReCreateMenuBar().

◆ appendCopy()

wxMenuItem * ACTION_MENU::appendCopy ( const wxMenuItem *  aSource)
protectedinherited

Append a copy of wxMenuItem.

Initialize handlers for events.

Definition at line 639 of file action_menu.cpp.

640{
641 wxMenuItem* newItem = new wxMenuItem( this, aSource->GetId(), aSource->GetItemLabel(),
642 aSource->GetHelp(), aSource->GetKind() );
643
644 // Add the source bitmap if it is not the wxNullBitmap
645 // On Windows, for Checkable Menu items, adding a bitmap adds also
646 // our predefined checked alternate bitmap
647 // On other OS, wxITEM_CHECK and wxITEM_RADIO Menu items do not use custom bitmaps.
648#if defined( _WIN32 )
649 // On Windows, AddBitmapToMenuItem() uses the unchecked bitmap for wxITEM_CHECK and
650 // wxITEM_RADIO menuitems and autoamtically adds a checked bitmap.
651 // For other menuitrms, use the "checked" bitmap.
652 bool use_checked_bm = ( aSource->GetKind() == wxITEM_CHECK ||
653 aSource->GetKind() == wxITEM_RADIO ) ? false : true;
654 const wxBitmap& src_bitmap = aSource->GetBitmap( use_checked_bm );
655#else
656 const wxBitmap& src_bitmap = aSource->GetBitmap();
657#endif
658
659 if( src_bitmap.IsOk() && src_bitmap.GetHeight() > 1 ) // a null bitmap has a 0 size
660 AddBitmapToMenuItem( newItem, src_bitmap );
661
662 if( aSource->IsSubMenu() )
663 {
664 ACTION_MENU* menu = dynamic_cast<ACTION_MENU*>( aSource->GetSubMenu() );
665 wxASSERT_MSG( menu, "Submenus are expected to be a ACTION_MENU" );
666
667 if( menu )
668 {
669 ACTION_MENU* menuCopy = menu->Clone();
670 newItem->SetSubMenu( menuCopy );
671 m_submenus.push_back( menuCopy );
672 }
673 }
674
675 // wxMenuItem has to be added before enabling/disabling or checking
676 Append( newItem );
677
678 if( aSource->IsCheckable() )
679 newItem->Check( aSource->IsChecked() );
680
681 newItem->Enable( aSource->IsEnabled() );
682
683 return newItem;
684}
Defines the structure of a menu based on ACTIONs.
Definition: action_menu.h:49
ACTION_MENU * Clone() const
Create a deep, recursive copy of this ACTION_MENU.

References AddBitmapToMenuItem(), ACTION_MENU::Clone(), and ACTION_MENU::m_submenus.

Referenced by ACTION_MENU::copyFrom().

◆ Clear()

void ACTION_MENU::Clear ( )
inherited

Remove all the entries from the menu (as well as its title).

It leaves the menu in the initial state.

Definition at line 238 of file action_menu.cpp.

239{
240 m_titleDisplayed = false;
241
242 for( int i = GetMenuItemCount() - 1; i >= 0; --i )
243 Destroy( FindItemByPosition( i ) );
244
245 m_toolActions.clear();
246 m_submenus.clear();
247
248 wxASSERT( GetMenuItemCount() == 0 );
249}
bool m_titleDisplayed
Definition: action_menu.h:253

References ACTION_MENU::m_submenus, ACTION_MENU::m_titleDisplayed, and ACTION_MENU::m_toolActions.

Referenced by ACTION_MENU::Clone(), CONDITIONAL_MENU::Evaluate(), SYMBOL_UNIT_MENU::update(), BUS_UNFOLD_MENU::update(), HIGHLIGHT_MENU::update(), ZOOM_MENU::update(), update(), DIFF_PAIR_MENU::update(), and VIA_SIZE_MENU::update().

◆ ClearDirty()

void ACTION_MENU::ClearDirty ( )
inherited

Clear the dirty flag on the menu and all descendants.

Definition at line 281 of file action_menu.cpp.

282{
283 m_dirty = false;
284 runOnSubmenus( std::bind( &ACTION_MENU::ClearDirty, _1 ) );
285}
void ClearDirty()
Clear the dirty flag on the menu and all descendants.
void runOnSubmenus(std::function< void(ACTION_MENU *)> aFunction)
Check if any of submenus contains a TOOL_ACTION with a specific ID.

References ACTION_MENU::ClearDirty(), ACTION_MENU::m_dirty, and ACTION_MENU::runOnSubmenus().

Referenced by ACTION_MENU::ClearDirty(), and TOOL_MENU::ShowContextMenu().

◆ Clone()

ACTION_MENU * ACTION_MENU::Clone ( ) const
inherited

Create a deep, recursive copy of this ACTION_MENU.

Definition at line 302 of file action_menu.cpp.

303{
304 ACTION_MENU* clone = create();
305 clone->Clear();
306 clone->copyFrom( *this );
307 return clone;
308}
virtual ACTION_MENU * create() const
< Return an instance of this class. It has to be overridden in inheriting classes.
void Clear()
Remove all the entries from the menu (as well as its title).
void copyFrom(const ACTION_MENU &aMenu)
Copy another menus data to this instance.

References ACTION_MENU::Clear(), ACTION_MENU::copyFrom(), and ACTION_MENU::create().

Referenced by ACTION_MENU::appendCopy(), TOOL_MANAGER::DispatchContextMenu(), SCH_EDIT_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), and PCB_EDIT_FRAME::ReCreateMenuBar().

◆ copyFrom()

void ACTION_MENU::copyFrom ( const ACTION_MENU aMenu)
protectedinherited

Copy another menus data to this instance.

Old entries are preserved and ones form aMenu are copied.

Definition at line 621 of file action_menu.cpp.

622{
623 m_icon = aMenu.m_icon;
624 m_title = aMenu.m_title;
626 m_selected = -1; // aMenu.m_selected;
627 m_tool = aMenu.m_tool;
629
630 // Copy all menu entries
631 for( int i = 0; i < (int) aMenu.GetMenuItemCount(); ++i )
632 {
633 wxMenuItem* item = aMenu.FindItemByPosition( i );
634 appendCopy( item );
635 }
636}
wxMenuItem * appendCopy(const wxMenuItem *aSource)
Append a copy of wxMenuItem.
int m_selected
Creator of the menu.
Definition: action_menu.h:263
TOOL_INTERACTIVE * m_tool
Associates tool actions with menu item IDs. Non-owning.
Definition: action_menu.h:266

References ACTION_MENU::appendCopy(), ACTION_MENU::m_icon, ACTION_MENU::m_selected, ACTION_MENU::m_title, ACTION_MENU::m_titleDisplayed, ACTION_MENU::m_tool, and ACTION_MENU::m_toolActions.

Referenced by ACTION_MENU::Clone().

◆ create()

ACTION_MENU * TRACK_WIDTH_MENU::create ( ) const
inlineoverrideprotectedvirtual

< Return an instance of this class. It has to be overridden in inheriting classes.

Returns an instance of TOOL_MANAGER class.

Reimplemented from ACTION_MENU.

Definition at line 204 of file router_tool.cpp.

205 {
206 return new TRACK_WIDTH_MENU( m_frame );
207 }
TRACK_WIDTH_MENU(PCB_EDIT_FRAME &aFrame)

References m_frame, and TRACK_WIDTH_MENU().

◆ DisplayTitle()

void ACTION_MENU::DisplayTitle ( bool  aDisplay = true)
inherited

Decide whether a title for a pop up menu should be displayed.

Definition at line 98 of file action_menu.cpp.

99{
100 if( ( !aDisplay || m_title.IsEmpty() ) && m_titleDisplayed )
101 {
102 // Destroy the menu entry keeping the title..
103 wxMenuItem* item = FindItemByPosition( 0 );
104 wxASSERT( item->GetItemLabelText() == GetTitle() );
105 Destroy( item );
106 // ..and separator
107 item = FindItemByPosition( 0 );
108 wxASSERT( item->IsSeparator() );
109 Destroy( item );
110 m_titleDisplayed = false;
111 }
112
113 else if( aDisplay && !m_title.IsEmpty() )
114 {
115 if( m_titleDisplayed )
116 {
117 // Simply update the title
118 FindItemByPosition( 0 )->SetItemLabel( m_title );
119 }
120 else
121 {
122 // Add a separator and a menu entry to display the title
123 InsertSeparator( 0 );
124 Insert( 0, new wxMenuItem( this, wxID_NONE, m_title, wxEmptyString, wxITEM_NORMAL ) );
125
126 if( !!m_icon )
127 AddBitmapToMenuItem( FindItemByPosition( 0 ), KiBitmap( m_icon ) );
128
129 m_titleDisplayed = true;
130 }
131 }
132}

References AddBitmapToMenuItem(), KiBitmap(), ACTION_MENU::m_icon, ACTION_MENU::m_title, and ACTION_MENU::m_titleDisplayed.

Referenced by SELECTION_TOOL::doSelectionMenu(), and ACTION_MENU::SetTitle().

◆ eventHandler()

OPT_TOOL_EVENT TRACK_WIDTH_MENU::eventHandler ( const wxMenuEvent &  )
inlineoverrideprotectedvirtual

Event handler stub.

It should be used if you want to generate a TOOL_EVENT from a wxMenuEvent. It will be called when a menu entry is clicked.

Reimplemented from ACTION_MENU.

Definition at line 278 of file router_tool.cpp.

279 {
281 int id = aEvent.GetId();
282
283 // On Windows, this handler can be called with an event ID not existing in any
284 // menuitem, so only set flags when we have an ID match.
285
287 {
288 bds.UseCustomTrackViaSize( true );
289 bds.m_TempOverrideTrackWidth = true;
291 }
292 else if( id == ID_POPUP_PCB_SELECT_AUTO_WIDTH )
293 {
294 bds.UseCustomTrackViaSize( false );
295 bds.m_UseConnectedTrackWidth = true;
296 bds.m_TempOverrideTrackWidth = false;
297 }
299 {
300 bds.UseCustomTrackViaSize( false );
301 bds.m_UseConnectedTrackWidth = false;
302 bds.SetViaSizeIndex( 0 );
303 bds.SetTrackWidthIndex( 0 );
304 }
306 {
307 bds.UseCustomTrackViaSize( false );
309 }
311 {
312 bds.UseCustomTrackViaSize( false );
313 bds.m_TempOverrideTrackWidth = true;
315 }
316
318 }
Container for design settings for a BOARD object.
void UseCustomTrackViaSize(bool aEnabled)
Enables/disables custom track/via size settings.
void SetTrackWidthIndex(unsigned aIndex)
Set the current track width list index to aIndex.
void SetViaSizeIndex(unsigned aIndex)
Set the current via size list index to aIndex.
BOARD_DESIGN_SETTINGS & GetDesignSettings() const
Definition: board.cpp:643
static TOOL_ACTION trackViaSizeChanged
Definition: pcb_actions.h:338
BOARD * GetBoard() const
TOOL_MANAGER * GetToolManager() const
Return the MVC controller.
Definition: tools_holder.h:54
bool RunAction(const std::string &aActionName, bool aNow=false, T aParam=NULL)
Run the specified action.
Definition: tool_manager.h:142
@ ID_POPUP_PCB_SELECT_WIDTH1
Definition: pcbnew_id.h:29
@ ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES
Definition: pcbnew_id.h:28
@ ID_POPUP_PCB_SELECT_WIDTH16
Definition: pcbnew_id.h:44
@ ID_POPUP_PCB_SELECT_AUTO_WIDTH
Definition: pcbnew_id.h:27
@ ID_POPUP_PCB_SELECT_CUSTOM_WIDTH
Definition: pcbnew_id.h:26
@ ID_POPUP_PCB_SELECT_VIASIZE1
Definition: pcbnew_id.h:45
@ ID_POPUP_PCB_SELECT_VIASIZE16
Definition: pcbnew_id.h:60
static const TOOL_ACTION ACT_CustomTrackWidth("pcbnew.InteractiveRouter.CustomTrackViaSize", AS_CONTEXT, 'Q', LEGACY_HK_NAME("Custom Track/Via Size"), _("Custom Track/Via Size..."), _("Shows a dialog for changing the track width and via size."), BITMAPS::width_track)
std::optional< TOOL_EVENT > OPT_TOOL_EVENT
Definition: tool_event.h:557

References ACT_CustomTrackWidth, PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), TOOLS_HOLDER::GetToolManager(), ID_POPUP_PCB_SELECT_AUTO_WIDTH, ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_VIASIZE16, ID_POPUP_PCB_SELECT_WIDTH1, ID_POPUP_PCB_SELECT_WIDTH16, m_frame, BOARD_DESIGN_SETTINGS::m_TempOverrideTrackWidth, BOARD_DESIGN_SETTINGS::m_UseConnectedTrackWidth, TOOL_MANAGER::RunAction(), BOARD_DESIGN_SETTINGS::SetTrackWidthIndex(), BOARD_DESIGN_SETTINGS::SetViaSizeIndex(), PCB_ACTIONS::trackViaSizeChanged, and BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize().

◆ findToolAction()

OPT_TOOL_EVENT ACTION_MENU::findToolAction ( int  aId)
protectedinherited

Definition at line 596 of file action_menu.cpp.

597{
598 OPT_TOOL_EVENT evt;
599
600 auto findFunc =
601 [&]( ACTION_MENU* m )
602 {
603 if( evt )
604 return;
605
606 const auto it = m->m_toolActions.find( aId );
607
608 if( it != m->m_toolActions.end() )
609 evt = it->second->MakeEvent();
610 };
611
612 findFunc( this );
613
614 if( !evt )
615 runOnSubmenus( findFunc );
616
617 return evt;
618}

References ACTION_MENU::runOnSubmenus().

Referenced by ACTION_MENU::OnMenuEvent().

◆ GetSelected()

int ACTION_MENU::GetSelected ( ) const
inlineinherited

Return the position of selected item.

If the returned value is negative, that means that menu was dismissed.

Returns
The position of selected item in the action menu.

Definition at line 150 of file action_menu.h.

151 {
152 return m_selected;
153 }

References ACTION_MENU::m_selected.

◆ getToolManager()

TOOL_MANAGER * ACTION_MENU::getToolManager ( ) const
protectedinherited

Definition at line 323 of file action_menu.cpp.

324{
325 wxASSERT( m_tool );
326 return m_tool ? m_tool->GetManager() : nullptr;
327}
TOOL_MANAGER * GetManager() const
Return the instance of TOOL_MANAGER that takes care of the tool.
Definition: tool_base.h:143

References TOOL_BASE::GetManager(), and ACTION_MENU::m_tool.

Referenced by VIA_SIZE_MENU::eventHandler(), ACTION_MENU::OnMenuEvent(), SYMBOL_UNIT_MENU::update(), BUS_UNFOLD_MENU::update(), HIGHLIGHT_MENU::update(), VIA_SIZE_MENU::update(), GROUP_CONTEXT_MENU::update(), and ACTION_MENU::updateHotKeys().

◆ HasEnabledItems()

bool ACTION_MENU::HasEnabledItems ( ) const
inherited

Returns true if the menu has any enabled items.

Definition at line 252 of file action_menu.cpp.

253{
254 for( wxMenuItem* item : GetMenuItems() )
255 {
256 if( item->IsEnabled() && !item->IsSeparator() )
257 return true;
258 }
259
260 return false;
261}

◆ OnIdle()

void ACTION_MENU::OnIdle ( wxIdleEvent &  event)
inherited

Definition at line 379 of file action_menu.cpp.

380{
384}
static int g_last_menu_highlighted_id
static VECTOR2D g_menu_open_position

References g_last_menu_highlighted_id, g_menu_open_position, VECTOR2< T >::x, and VECTOR2< T >::y.

Referenced by ACTION_MENU::setupEvents().

◆ OnMenuEvent()

void ACTION_MENU::OnMenuEvent ( wxMenuEvent &  aEvent)
inherited

Definition at line 387 of file action_menu.cpp.

388{
389 OPT_TOOL_EVENT evt;
390 wxString menuText;
391 wxEventType type = aEvent.GetEventType();
392 wxWindow* focus = wxWindow::FindFocus();
393
394 if( type == wxEVT_MENU_OPEN )
395 {
396 if( m_dirty && m_tool )
398
399 wxMenu* parent = dynamic_cast<wxMenu*>( GetParent() );
400
401 // Don't update the position if this menu has a parent
402 if( !parent && m_tool )
404
406 }
407 else if( type == wxEVT_MENU_HIGHLIGHT )
408 {
409 if( aEvent.GetId() > 0 )
410 g_last_menu_highlighted_id = aEvent.GetId();
411
412 evt = TOOL_EVENT( TC_COMMAND, TA_CHOICE_MENU_UPDATE, aEvent.GetId() );
413 }
414 else if( type == wxEVT_COMMAND_MENU_SELECTED )
415 {
416 // Despite our attempts to catch the theft of text editor CHAR_HOOK and CHAR events
417 // in TOOL_DISPATCHER::DispatchWxEvent, wxWidgets sometimes converts those it knows
418 // about into menu commands without ever generating the appropriate CHAR_HOOK and CHAR
419 // events first.
420 if( dynamic_cast<wxTextEntry*>( focus )
421 || dynamic_cast<wxStyledTextCtrl*>( focus )
422 || dynamic_cast<wxListView*>( focus ) )
423 {
424 // Original key event has been lost, so we have to re-create it from the menu's
425 // wxAcceleratorEntry.
426 wxMenuItem* menuItem = FindItem( aEvent.GetId() );
427 wxAcceleratorEntry* acceleratorKey = menuItem ? menuItem->GetAccel() : nullptr;
428
429 if( acceleratorKey )
430 {
431 wxKeyEvent keyEvent( wxEVT_CHAR_HOOK );
432 keyEvent.m_keyCode = acceleratorKey->GetKeyCode();
433 keyEvent.m_controlDown = ( acceleratorKey->GetFlags() & wxMOD_CONTROL ) > 0;
434 keyEvent.m_shiftDown = ( acceleratorKey->GetFlags() & wxMOD_SHIFT ) > 0;
435 keyEvent.m_altDown = ( acceleratorKey->GetFlags() & wxMOD_ALT ) > 0;
436
437 if( auto ctrl = dynamic_cast<wxTextEntry*>( focus ) )
438 TEXTENTRY_TRICKS::OnCharHook( ctrl, keyEvent );
439 else
440 focus->HandleWindowEvent( keyEvent );
441
442 if( keyEvent.GetSkipped() )
443 {
444 keyEvent.SetEventType( wxEVT_CHAR );
445 focus->HandleWindowEvent( keyEvent );
446 }
447
448 // If the event was used as KEY event (not skipped) by the focused window,
449 // just finish.
450 // Otherwise this is actually a wxEVT_COMMAND_MENU_SELECTED, or the
451 // focused window is read only
452 if( !keyEvent.GetSkipped() )
453 return;
454 }
455 }
456
457 // Store the selected position, so it can be checked by the tools
458 m_selected = aEvent.GetId();
459
460 ACTION_MENU* parent = dynamic_cast<ACTION_MENU*>( GetParent() );
461
462 while( parent )
463 {
464 parent->m_selected = m_selected;
465 parent = dynamic_cast<ACTION_MENU*>( parent->GetParent() );
466 }
467
468 // Check if there is a TOOL_ACTION for the given ID
469 // Note that we also have to check the standard wxWidgets' cut/copy/paste IDs because
470 // we can't use our own IDs there without losing cut/copy/paste in places like search
471 // boxes in standard file dialogs.
472 if( m_selected == wxID_CUT || m_selected == wxID_COPY || m_selected == wxID_PASTE
474 {
475 evt = findToolAction( m_selected );
476 }
477
478 if( !evt )
479 {
480#ifdef __WINDOWS__
481 if( !evt )
482 {
483 // Try to find the submenu which holds the selected item
484 wxMenu* menu = nullptr;
485 FindItem( m_selected, &menu );
486
487 // This conditional compilation is probably not needed.
488 // It will be removed later, for the Kicad V 6.x version.
489 // But in "old" 3.0 version, the "&& menu != this" contition was added to avoid
490 // hang. This hang is no longer encountered in wxWidgets 3.0.4 version, and this
491 // condition is no longer needed. And in 3.1.2, we have to remove it, as
492 // "menu != this" never happens ("menu != this" always happens in 3.1.1 and older!).
493#if wxCHECK_VERSION( 3, 1, 2 )
494 if( menu )
495#else
496 if( menu && menu != this )
497#endif
498 {
499 ACTION_MENU* cxmenu = static_cast<ACTION_MENU*>( menu );
500 evt = cxmenu->eventHandler( aEvent );
501 }
502 }
503#else
504 if( !evt )
505 runEventHandlers( aEvent, evt );
506#endif
507
508 // Handling non-ACTION menu entries. Two ranges of ids are supported:
509 // between 0 and ID_CONTEXT_MENU_ID_MAX
510 // between ID_POPUP_MENU_START and ID_POPUP_MENU_END
511
512 #define ID_CONTEXT_MENU_ID_MAX wxID_LOWEST /* = 100 should be plenty */
513
514 if( !evt &&
517 {
518 ACTION_MENU* actionMenu = dynamic_cast<ACTION_MENU*>( GetParent() );
519
520 if( actionMenu && actionMenu->PassHelpTextToHandler() )
521 menuText = GetHelpString( aEvent.GetId() );
522 else
523 menuText = GetLabelText( aEvent.GetId() );
524
526 &menuText );
527 }
528 }
529 }
530
531 // forward the action/update event to the TOOL_MANAGER
532 // clients that don't supply a tool will have to check GetSelected() themselves
533 if( evt && m_tool )
534 {
535 wxLogTrace( kicadTraceToolStack, "ACTION_MENU::OnMenuEvent %s", evt->Format() );
536
537 // WARNING: if you're squeamish, look away.
538 // What follows is a series of egregious hacks necessitated by a lack of information from
539 // wxWidgets on where context-menu-commands and command-key-events originated.
540
541 // If it's a context menu then fetch the mouse position from our context-menu-position
542 // hack.
543 if( m_isContextMenu )
544 {
545 evt->SetMousePosition( g_menu_open_position );
546 }
547 // Otherwise, if g_last_menu_highlighted_id matches then it's a menubar menu event and has
548 // no position.
549 else if( g_last_menu_highlighted_id == aEvent.GetId() )
550 {
551 evt->SetHasPosition( false );
552 }
553 // Otherwise it's a command-key-event and we need to get the mouse position from the tool
554 // manager so that immediate actions work.
555 else
556 {
557 evt->SetMousePosition( getToolManager()->GetMousePosition() );
558 }
559
560 if( m_tool->GetManager() )
561 m_tool->GetManager()->ProcessEvent( *evt );
562 }
563 else
564 {
565 aEvent.Skip();
566 }
567}
#define ID_CONTEXT_MENU_ID_MAX
static TOOL_ACTION updateMenu
Definition: actions.h:171
TOOL_MANAGER * getToolManager() const
OPT_TOOL_EVENT findToolAction(int aId)
void runEventHandlers(const wxMenuEvent &aMenuEvent, OPT_TOOL_EVENT &aToolEvent)
Run a function on the menu and all its submenus.
bool m_isContextMenu
Menu title.
Definition: action_menu.h:254
virtual OPT_TOOL_EVENT eventHandler(const wxMenuEvent &)
Event handler stub.
Definition: action_menu.h:214
virtual bool PassHelpTextToHandler()
Definition: action_menu.h:186
static int GetBaseUIId()
Definition: tool_action.h:148
Generic, UI-independent tool event.
Definition: tool_event.h:156
bool ProcessEvent(const TOOL_EVENT &aEvent)
Propagate an event to tools that requested events of matching type(s).
VECTOR2D GetMousePosition() const
const wxChar *const kicadTraceToolStack
Flag to enable tracing of the tool handling stack.
@ ID_POPUP_MENU_START
Definition: id.h:190
@ ID_POPUP_MENU_END
Definition: id.h:193
static void OnCharHook(wxTextEntry *aTextEntry, wxKeyEvent &aEvent)
@ AS_GLOBAL
Global action (toolbar/main menu event, global shortcut)
Definition: tool_action.h:45
@ TA_CHOICE_MENU_CHOICE
Definition: tool_event.h:93
@ TA_CHOICE_MENU_UPDATE
Definition: tool_event.h:89
@ TC_COMMAND
Definition: tool_event.h:52

References AS_GLOBAL, ACTION_MENU::eventHandler(), ACTION_MENU::findToolAction(), g_last_menu_highlighted_id, g_menu_open_position, TOOL_ACTION::GetBaseUIId(), TOOL_BASE::GetManager(), TOOL_MANAGER::GetMousePosition(), ACTION_MENU::getToolManager(), ID_CONTEXT_MENU_ID_MAX, ID_POPUP_MENU_END, ID_POPUP_MENU_START, kicadTraceToolStack, ACTION_MENU::m_dirty, ACTION_MENU::m_isContextMenu, ACTION_MENU::m_selected, ACTION_MENU::m_tool, TEXTENTRY_TRICKS::OnCharHook(), ACTION_MENU::PassHelpTextToHandler(), TOOL_MANAGER::ProcessEvent(), TOOL_MANAGER::RunAction(), ACTION_MENU::runEventHandlers(), TA_CHOICE_MENU_CHOICE, TA_CHOICE_MENU_UPDATE, TC_COMMAND, and ACTIONS::updateMenu.

Referenced by TOOL_DISPATCHER::DispatchWxEvent(), and ACTION_MENU::setupEvents().

◆ PassHelpTextToHandler()

virtual bool ACTION_MENU::PassHelpTextToHandler ( )
inlinevirtualinherited

Reimplemented in BUS_UNFOLD_MENU.

Definition at line 186 of file action_menu.h.

186{ return false; }

Referenced by ACTION_MENU::OnMenuEvent().

◆ runEventHandlers()

void ACTION_MENU::runEventHandlers ( const wxMenuEvent &  aMenuEvent,
OPT_TOOL_EVENT aToolEvent 
)
protectedinherited

Run a function on the menu and all its submenus.

Definition at line 570 of file action_menu.cpp.

571{
572 aToolEvent = eventHandler( aMenuEvent );
573
574 if( !aToolEvent )
575 runOnSubmenus( std::bind( &ACTION_MENU::runEventHandlers, _1, aMenuEvent, aToolEvent ) );
576}

References ACTION_MENU::eventHandler(), ACTION_MENU::runEventHandlers(), and ACTION_MENU::runOnSubmenus().

Referenced by ACTION_MENU::OnMenuEvent(), and ACTION_MENU::runEventHandlers().

◆ runOnSubmenus()

void ACTION_MENU::runOnSubmenus ( std::function< void(ACTION_MENU *)>  aFunction)
protectedinherited

Check if any of submenus contains a TOOL_ACTION with a specific ID.

Definition at line 579 of file action_menu.cpp.

580{
581 try
582 {
583 std::for_each( m_submenus.begin(), m_submenus.end(),
584 [&]( ACTION_MENU* m )
585 {
586 aFunction( m );
587 m->runOnSubmenus( aFunction );
588 } );
589 }
590 catch( std::exception& )
591 {
592 }
593}

References ACTION_MENU::m_submenus.

Referenced by ACTION_MENU::ClearDirty(), CONDITIONAL_MENU::Evaluate(), ACTION_MENU::findToolAction(), CONDITIONAL_MENU::Resolve(), ACTION_MENU::runEventHandlers(), ACTION_MENU::SetDirty(), ACTION_MENU::SetTool(), and ACTION_MENU::UpdateAll().

◆ SetDirty()

void ACTION_MENU::SetDirty ( )
inherited

Definition at line 288 of file action_menu.cpp.

289{
290 m_dirty = true;
291 runOnSubmenus( std::bind( &ACTION_MENU::SetDirty, _1 ) );
292}
void SetDirty()

References ACTION_MENU::m_dirty, ACTION_MENU::runOnSubmenus(), and ACTION_MENU::SetDirty().

Referenced by ACTION_MENU::SetDirty(), and TOOL_MENU::ShowContextMenu().

◆ SetIcon()

◆ SetTitle()

void ACTION_MENU::SetTitle ( const wxString &  aTitle)
overrideinherited

Set title for the menu.

The title is shown as a text label shown on the top of the menu.

Parameters
aTitleis the new title.

Definition at line 87 of file action_menu.cpp.

88{
89 // Unfortunately wxMenu::SetTitle() does not work very well, so this is an alternative version
90 m_title = aTitle;
91
92 // Update the menu title
94 DisplayTitle( true );
95}
void DisplayTitle(bool aDisplay=true)
Decide whether a title for a pop up menu should be displayed.
Definition: action_menu.cpp:98

References ACTION_MENU::DisplayTitle(), ACTION_MENU::m_title, and ACTION_MENU::m_titleDisplayed.

Referenced by AddMenuLanguageList(), BUS_UNFOLD_MENU::BUS_UNFOLD_MENU(), EDA_3D_VIEWER_FRAME::CreateMenuBar(), DIFF_PAIR_MENU::DIFF_PAIR_MENU(), SELECTION_TOOL::doSelectionMenu(), GROUP_CONTEXT_MENU::GROUP_CONTEXT_MENU(), HIGHLIGHT_MENU::HIGHLIGHT_MENU(), SCH_EDIT_TOOL::Init(), LENGTH_TUNER_TOOL::Init(), ROUTER_TOOL::Init(), CONVERT_TOOL::Init(), ALIGN_DISTRIBUTE_TOOL::Init(), LOCK_CONTEXT_MENU::LOCK_CONTEXT_MENU(), NET_CONTEXT_MENU::NET_CONTEXT_MENU(), POSITIONING_TOOLS_MENU::POSITIONING_TOOLS_MENU(), SCH_EDIT_FRAME::ReCreateMenuBar(), SYMBOL_EDIT_FRAME::ReCreateMenuBar(), GERBVIEW_FRAME::ReCreateMenuBar(), KICAD_MANAGER_FRAME::ReCreateMenuBar(), PL_EDITOR_FRAME::ReCreateMenuBar(), FOOTPRINT_EDIT_FRAME::ReCreateMenuBar(), PCB_EDIT_FRAME::ReCreateMenuBar(), SELECT_MENU::SELECT_MENU(), SYMBOL_UNIT_MENU::SYMBOL_UNIT_MENU(), TRACK_WIDTH_MENU(), GRID_MENU::UpdateTitle(), ZOOM_MENU::UpdateTitle(), VIA_SIZE_MENU::VIA_SIZE_MENU(), and ZONE_CONTEXT_MENU::ZONE_CONTEXT_MENU().

◆ SetTool()

void ACTION_MENU::SetTool ( TOOL_INTERACTIVE aTool)
inherited

Set a tool that is the creator of the menu.

Parameters
aToolis the tool that created the menu.

Definition at line 295 of file action_menu.cpp.

296{
297 m_tool = aTool;
298 runOnSubmenus( std::bind( &ACTION_MENU::SetTool, _1, aTool ) );
299}
void SetTool(TOOL_INTERACTIVE *aTool)
Set a tool that is the creator of the menu.

References ACTION_MENU::m_tool, ACTION_MENU::runOnSubmenus(), and ACTION_MENU::SetTool().

Referenced by TOOL_INTERACTIVE::SetContextMenu(), ACTION_MENU::SetTool(), and SCH_LINE_WIRE_BUS_TOOL::UnfoldBus().

◆ setupEvents()

void ACTION_MENU::setupEvents ( )
protectedinherited

Update hot key settings for TOOL_ACTIONs in this menu.

Definition at line 79 of file action_menu.cpp.

80{
81 Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( ACTION_MENU::OnMenuEvent ), nullptr,
82 this );
83 Connect( wxEVT_IDLE, wxIdleEventHandler( ACTION_MENU::OnIdle ), nullptr, this );
84}
void OnMenuEvent(wxMenuEvent &aEvent)
void OnIdle(wxIdleEvent &event)

References ACTION_MENU::OnIdle(), and ACTION_MENU::OnMenuEvent().

Referenced by ACTION_MENU::ACTION_MENU().

◆ update()

void TRACK_WIDTH_MENU::update ( )
inlineoverrideprotectedvirtual

Update menu state stub.

It is called before a menu is shown, in order to update its state. Here you can tick current settings, enable/disable entries, etc.

Reimplemented from ACTION_MENU.

Definition at line 209 of file router_tool.cpp.

210 {
212 bool useIndex = !bds.m_UseConnectedTrackWidth &&
214 wxString msg;
215
216 Clear();
217
218 Append( ID_POPUP_PCB_SELECT_AUTO_WIDTH, _( "Use Starting Track Width" ),
219 _( "Route using the width of the starting track." ), wxITEM_CHECK );
222
223 Append( ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, _( "Use Net Class Values" ),
224 _( "Use track and via sizes from the net class" ), wxITEM_CHECK );
226 useIndex && bds.GetTrackWidthIndex() == 0 && bds.GetViaSizeIndex() == 0 );
227
228 Append( ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, _( "Use Custom Values..." ),
229 _( "Specify custom track and via sizes" ), wxITEM_CHECK );
231
232 AppendSeparator();
233
234 // Append the list of tracks & via sizes
235 for( unsigned i = 0; i < bds.m_TrackWidthList.size(); i++ )
236 {
237 int width = bds.m_TrackWidthList[i];
238
239 if( i == 0 )
240 msg = _( "Track netclass width" );
241 else
242 msg.Printf( _( "Track %s" ), m_frame.MessageTextFromValue( width ) );
243
244 int menuIdx = ID_POPUP_PCB_SELECT_WIDTH1 + i;
245 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
246 Check( menuIdx, useIndex && bds.GetTrackWidthIndex() == i );
247 }
248
249 AppendSeparator();
250
251 for( unsigned i = 0; i < bds.m_ViasDimensionsList.size(); i++ )
252 {
254
255 if( i == 0 )
256 msg = _( "Via netclass values" );
257 else
258 {
259 if( via.m_Drill > 0 )
260 {
261 msg.Printf( _("Via %s, hole %s" ),
262 m_frame.MessageTextFromValue( via.m_Diameter ),
263 m_frame.MessageTextFromValue( via.m_Drill ) );
264 }
265 else
266 {
267 msg.Printf( _( "Via %s" ),
268 m_frame.MessageTextFromValue( via.m_Diameter ) );
269 }
270 }
271
272 int menuIdx = ID_POPUP_PCB_SELECT_VIASIZE1 + i;
273 Append( menuIdx, msg, wxEmptyString, wxITEM_CHECK );
274 Check( menuIdx, useIndex && bds.GetViaSizeIndex() == i );
275 }
276 }
unsigned GetTrackWidthIndex() const
unsigned GetViaSizeIndex() const
std::vector< int > m_TrackWidthList
std::vector< VIA_DIMENSION > m_ViasDimensionsList
wxString MessageTextFromValue(double aValue, bool aAddUnitLabel=true, EDA_DATA_TYPE aType=EDA_DATA_TYPE::DISTANCE)
A lower-precision version of StringFromValue().
Container to handle a stock of specific vias each with unique diameter and drill sizes in the BOARD c...

References _, ACTION_MENU::Clear(), PCB_BASE_FRAME::GetBoard(), BOARD::GetDesignSettings(), BOARD_DESIGN_SETTINGS::GetTrackWidthIndex(), BOARD_DESIGN_SETTINGS::GetViaSizeIndex(), ID_POPUP_PCB_SELECT_AUTO_WIDTH, ID_POPUP_PCB_SELECT_CUSTOM_WIDTH, ID_POPUP_PCB_SELECT_USE_NETCLASS_VALUES, ID_POPUP_PCB_SELECT_VIASIZE1, ID_POPUP_PCB_SELECT_WIDTH1, m_frame, BOARD_DESIGN_SETTINGS::m_TrackWidthList, BOARD_DESIGN_SETTINGS::m_UseConnectedTrackWidth, BOARD_DESIGN_SETTINGS::m_ViasDimensionsList, UNITS_PROVIDER::MessageTextFromValue(), BOARD_DESIGN_SETTINGS::UseCustomTrackViaSize(), and via.

◆ UpdateAll()

void ACTION_MENU::UpdateAll ( )
inherited

Run update handlers for the menu and its submenus.

Definition at line 264 of file action_menu.cpp.

265{
266 try
267 {
268 update();
269 }
270 catch( std::exception& )
271 {
272 }
273
274 if( m_tool )
276
277 runOnSubmenus( std::bind( &ACTION_MENU::UpdateAll, _1 ) );
278}
void updateHotKeys()
Traverse the submenus tree looking for a submenu capable of handling a particular menu event.
virtual void update()
Update menu state stub.
Definition: action_menu.h:204
void UpdateAll()
Run update handlers for the menu and its submenus.

References ACTION_MENU::m_tool, ACTION_MENU::runOnSubmenus(), ACTION_MENU::update(), ACTION_MENU::UpdateAll(), and ACTION_MENU::updateHotKeys().

Referenced by ACTION_TOOLBAR::onToolRightClick(), CONDITIONAL_MENU::Resolve(), TOOL_MENU::ShowContextMenu(), ACTION_MENU::UpdateAll(), EDA_3D_CONTROLLER::UpdateMenu(), CVPCB_CONTROL::UpdateMenu(), CVPCB_FOOTPRINT_VIEWER_SELECTION_TOOL::UpdateMenu(), SELECTION_TOOL::UpdateMenu(), and KICAD_MANAGER_CONTROL::UpdateMenu().

◆ updateHotKeys()

void ACTION_MENU::updateHotKeys ( )
protectedinherited

Traverse the submenus tree looking for a submenu capable of handling a particular menu event.

In case it is handled, it is returned the aToolEvent parameter.

Definition at line 330 of file action_menu.cpp.

331{
332 TOOL_MANAGER* toolMgr = getToolManager();
333
334 for( std::pair<const int, const TOOL_ACTION*>& ii : m_toolActions )
335 {
336 int id = ii.first;
337 const TOOL_ACTION& action = *ii.second;
338 int key = toolMgr->GetHotKey( action ) & ~MD_MODIFIER_MASK;
339
340 if( key > 0 )
341 {
342 int mod = toolMgr->GetHotKey( action ) & MD_MODIFIER_MASK;
343 int flags = 0;
344 wxMenuItem* item = FindChildItem( id );
345
346 if( item )
347 {
348 flags |= ( mod & MD_ALT ) ? wxACCEL_ALT : 0;
349 flags |= ( mod & MD_CTRL ) ? wxACCEL_CTRL : 0;
350 flags |= ( mod & MD_SHIFT ) ? wxACCEL_SHIFT : 0;
351
352 if( !flags )
353 flags = wxACCEL_NORMAL;
354
355 wxAcceleratorEntry accel( flags, key, id, item );
356 item->SetAccel( &accel );
357 }
358 }
359 }
360}
Represent a single user action.
Definition: tool_action.h:68
Master controller class:
Definition: tool_manager.h:55
int GetHotKey(const TOOL_ACTION &aAction) const
@ MD_MODIFIER_MASK
Definition: tool_event.h:141
@ MD_ALT
Definition: tool_event.h:140
@ MD_CTRL
Definition: tool_event.h:139
@ MD_SHIFT
Definition: tool_event.h:138

References TOOL_MANAGER::GetHotKey(), ACTION_MENU::getToolManager(), ACTION_MENU::m_toolActions, MD_ALT, MD_CTRL, MD_MODIFIER_MASK, and MD_SHIFT.

Referenced by ACTION_MENU::UpdateAll().

◆ UpdateTitle()

virtual void ACTION_MENU::UpdateTitle ( )
inlinevirtualinherited

Used by some menus to just-in-time translate their titles.

Reimplemented in GRID_MENU, and ZOOM_MENU.

Definition at line 163 of file action_menu.h.

163{}

Member Data Documentation

◆ CHECK

◆ m_dirty

bool ACTION_MENU::m_dirty
protectedinherited

◆ m_forcedPosition

wxPoint ACTION_MENU::m_forcedPosition
protectedinherited

Definition at line 249 of file action_menu.h.

◆ m_frame

PCB_EDIT_FRAME& TRACK_WIDTH_MENU::m_frame
private

Definition at line 321 of file router_tool.cpp.

Referenced by create(), eventHandler(), and update().

◆ m_icon

BITMAPS ACTION_MENU::m_icon
protectedinherited

Stores the id number of selected item.

Definition at line 260 of file action_menu.h.

Referenced by ACTION_MENU::Add(), ACTION_MENU::copyFrom(), ACTION_MENU::DisplayTitle(), and ACTION_MENU::SetIcon().

◆ m_isContextMenu

bool ACTION_MENU::m_isContextMenu
protectedinherited

Menu title.

Definition at line 254 of file action_menu.h.

Referenced by ACTION_MENU::OnMenuEvent().

◆ m_isForcedPosition

bool ACTION_MENU::m_isForcedPosition
protectedinherited

Definition at line 248 of file action_menu.h.

◆ m_selected

int ACTION_MENU::m_selected
protectedinherited

Creator of the menu.

Definition at line 263 of file action_menu.h.

Referenced by ACTION_MENU::copyFrom(), ACTION_MENU::GetSelected(), and ACTION_MENU::OnMenuEvent().

◆ m_submenus

std::list<ACTION_MENU*> ACTION_MENU::m_submenus
protectedinherited

◆ m_title

wxString ACTION_MENU::m_title
protectedinherited

Optional icon.

Definition at line 257 of file action_menu.h.

Referenced by ACTION_MENU::Add(), ACTION_MENU::copyFrom(), ACTION_MENU::DisplayTitle(), and ACTION_MENU::SetTitle().

◆ m_titleDisplayed

bool ACTION_MENU::m_titleDisplayed
protectedinherited

◆ m_tool

TOOL_INTERACTIVE* ACTION_MENU::m_tool
protectedinherited

◆ m_toolActions

std::map<int, const TOOL_ACTION*> ACTION_MENU::m_toolActions
protectedinherited

List of submenus.

Definition at line 269 of file action_menu.h.

Referenced by ACTION_MENU::Add(), ACTION_MENU::Clear(), ACTION_MENU::copyFrom(), and ACTION_MENU::updateHotKeys().

◆ NORMAL

constexpr bool ACTION_MENU::NORMAL = false
staticconstexprinherited

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