diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 30a480262b..c7f459b765 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -398,7 +398,7 @@ set( COMMON_SRCS tool/actions.cpp tool/common_tools.cpp tool/conditional_menu.cpp - tool/context_menu.cpp + tool/action_menu.cpp tool/edit_constraints.cpp tool/edit_points.cpp tool/grid_menu.cpp diff --git a/common/tool/context_menu.cpp b/common/tool/action_menu.cpp similarity index 80% rename from common/tool/context_menu.cpp rename to common/tool/action_menu.cpp index 97c822a56b..f26363abd0 100644 --- a/common/tool/context_menu.cpp +++ b/common/tool/action_menu.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include @@ -37,7 +37,7 @@ using namespace std::placeholders; -CONTEXT_MENU::CONTEXT_MENU() : +ACTION_MENU::ACTION_MENU() : m_Dirty( true ), m_titleDisplayed( false ), m_selected( -1 ), @@ -48,13 +48,13 @@ CONTEXT_MENU::CONTEXT_MENU() : } -CONTEXT_MENU::~CONTEXT_MENU() +ACTION_MENU::~ACTION_MENU() { // Set parent to NULL to prevent submenus from unregistering from a notexisting object for( auto menu : m_submenus ) menu->SetParent( nullptr ); - CONTEXT_MENU* parent = dynamic_cast( GetParent() ); + ACTION_MENU* parent = dynamic_cast( GetParent() ); if( parent ) parent->m_submenus.remove( this ); @@ -79,21 +79,21 @@ static void set_wxMenuIcon( wxMenuItem* aMenu, const BITMAP_OPAQUE* aIcon ) } -void CONTEXT_MENU::SetIcon( const BITMAP_OPAQUE* aIcon ) +void ACTION_MENU::SetIcon( const BITMAP_OPAQUE* aIcon ) { m_icon = aIcon; } -void CONTEXT_MENU::setupEvents() +void ACTION_MENU::setupEvents() { - Connect( wxEVT_MENU_OPEN, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); - Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); - Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this ); + Connect( wxEVT_MENU_OPEN, wxMenuEventHandler( ACTION_MENU::onMenuEvent ), NULL, this ); + Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( ACTION_MENU::onMenuEvent ), NULL, this ); + Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( ACTION_MENU::onMenuEvent ), NULL, this ); } -void CONTEXT_MENU::SetTitle( const wxString& aTitle ) +void ACTION_MENU::SetTitle( const wxString& aTitle ) { // Unfortunately wxMenu::SetTitle() does not work very well, so this is an alternative version m_title = aTitle; @@ -104,7 +104,7 @@ void CONTEXT_MENU::SetTitle( const wxString& aTitle ) } -void CONTEXT_MENU::DisplayTitle( bool aDisplay ) +void ACTION_MENU::DisplayTitle( bool aDisplay ) { if( ( !aDisplay || m_title.IsEmpty() ) && m_titleDisplayed ) { @@ -141,7 +141,7 @@ void CONTEXT_MENU::DisplayTitle( bool aDisplay ) } -wxMenuItem* CONTEXT_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPAQUE* aIcon ) +wxMenuItem* ACTION_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPAQUE* aIcon ) { #ifdef DEBUG if( FindItem( aId ) != NULL ) @@ -156,7 +156,7 @@ wxMenuItem* CONTEXT_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPA } -wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry ) +wxMenuItem* ACTION_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntry ) { /// ID numbers for tool actions need to have a value higher than ACTION_ID const BITMAP_OPAQUE* icon = aAction.GetIcon(); @@ -174,12 +174,12 @@ wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction, bool aIsCheckmarkEntr } -wxMenuItem* CONTEXT_MENU::Add( CONTEXT_MENU* aMenu ) +wxMenuItem* ACTION_MENU::Add( ACTION_MENU* aMenu ) { - CONTEXT_MENU* menuCopy = aMenu->Clone(); + ACTION_MENU* menuCopy = aMenu->Clone(); m_submenus.push_back( menuCopy ); - wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for CONTEXT_MENU using SetTitle()" ); + wxASSERT_MSG( !menuCopy->m_title.IsEmpty(), "Set a title for ACTION_MENU using SetTitle()" ); if( aMenu->m_icon ) { @@ -195,7 +195,7 @@ wxMenuItem* CONTEXT_MENU::Add( CONTEXT_MENU* aMenu ) } -void CONTEXT_MENU::Clear() +void ACTION_MENU::Clear() { m_titleDisplayed = false; @@ -209,7 +209,7 @@ void CONTEXT_MENU::Clear() } -bool CONTEXT_MENU::HasEnabledItems() const +bool ACTION_MENU::HasEnabledItems() const { bool hasEnabled = false; @@ -228,7 +228,7 @@ bool CONTEXT_MENU::HasEnabledItems() const } -void CONTEXT_MENU::UpdateAll() +void ACTION_MENU::UpdateAll() { try { @@ -236,35 +236,35 @@ void CONTEXT_MENU::UpdateAll() } catch( std::exception& e ) { - wxLogDebug( wxString::Format( "CONTEXT_MENU update handler exception: %s", e.what() ) ); + wxLogDebug( wxString::Format( "ACTION_MENU update handler exception: %s", e.what() ) ); } if( m_tool ) updateHotKeys(); - runOnSubmenus( std::bind( &CONTEXT_MENU::UpdateAll, _1 ) ); + runOnSubmenus( std::bind( &ACTION_MENU::UpdateAll, _1 ) ); } -void CONTEXT_MENU::SetTool( TOOL_INTERACTIVE* aTool ) +void ACTION_MENU::SetTool( TOOL_INTERACTIVE* aTool ) { m_tool = aTool; - runOnSubmenus( std::bind( &CONTEXT_MENU::SetTool, _1, aTool ) ); + runOnSubmenus( std::bind( &ACTION_MENU::SetTool, _1, aTool ) ); } -CONTEXT_MENU* CONTEXT_MENU::Clone() const +ACTION_MENU* ACTION_MENU::Clone() const { - CONTEXT_MENU* clone = create(); + ACTION_MENU* clone = create(); clone->Clear(); clone->copyFrom( *this ); return clone; } -CONTEXT_MENU* CONTEXT_MENU::create() const +ACTION_MENU* ACTION_MENU::create() const { - CONTEXT_MENU* menu = new CONTEXT_MENU(); + ACTION_MENU* menu = new ACTION_MENU(); wxASSERT_MSG( typeid( *this ) == typeid( *menu ), wxString::Format( "You need to override create() method for class %s", typeid(*this).name() ) ); @@ -273,14 +273,14 @@ CONTEXT_MENU* CONTEXT_MENU::create() const } -TOOL_MANAGER* CONTEXT_MENU::getToolManager() const +TOOL_MANAGER* ACTION_MENU::getToolManager() const { wxASSERT( m_tool ); return m_tool ? m_tool->GetManager() : nullptr; } -void CONTEXT_MENU::updateHotKeys() +void ACTION_MENU::updateHotKeys() { TOOL_MANAGER* toolMgr = getToolManager(); @@ -314,7 +314,7 @@ void CONTEXT_MENU::updateHotKeys() } -void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent ) +void ACTION_MENU::onMenuEvent( wxMenuEvent& aEvent ) { OPT_TOOL_EVENT evt; wxString menuText; @@ -340,12 +340,12 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent ) // Store the selected position, so it can be checked by the tools m_selected = aEvent.GetId(); - CONTEXT_MENU* parent = dynamic_cast( GetParent() ); + ACTION_MENU* parent = dynamic_cast( GetParent() ); while( parent ) { parent->m_selected = m_selected; - parent = dynamic_cast( parent->GetParent() ); + parent = dynamic_cast( parent->GetParent() ); } // Check if there is a TOOL_ACTION for the given ID @@ -373,7 +373,7 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent ) if( menu && menu != this ) #endif { - CONTEXT_MENU* cxmenu = static_cast( menu ); + ACTION_MENU* cxmenu = static_cast( menu ); evt = cxmenu->eventHandler( aEvent ); } } @@ -402,36 +402,36 @@ void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent ) } -void CONTEXT_MENU::runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent ) +void ACTION_MENU::runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent ) { aToolEvent = eventHandler( aMenuEvent ); if( !aToolEvent ) - runOnSubmenus( std::bind( &CONTEXT_MENU::runEventHandlers, _1, aMenuEvent, aToolEvent ) ); + runOnSubmenus( std::bind( &ACTION_MENU::runEventHandlers, _1, aMenuEvent, aToolEvent ) ); } -void CONTEXT_MENU::runOnSubmenus( std::function aFunction ) +void ACTION_MENU::runOnSubmenus( std::function aFunction ) { try { - std::for_each( m_submenus.begin(), m_submenus.end(), [&]( CONTEXT_MENU* m ) { + std::for_each( m_submenus.begin(), m_submenus.end(), [&]( ACTION_MENU* m ) { aFunction( m ); m->runOnSubmenus( aFunction ); } ); } catch( std::exception& e ) { - wxLogDebug( wxString::Format( "CONTEXT_MENU runOnSubmenus exception: %s", e.what() ) ); + wxLogDebug( wxString::Format( "ACTION_MENU runOnSubmenus exception: %s", e.what() ) ); } } -OPT_TOOL_EVENT CONTEXT_MENU::findToolAction( int aId ) +OPT_TOOL_EVENT ACTION_MENU::findToolAction( int aId ) { OPT_TOOL_EVENT evt; - auto findFunc = [&]( CONTEXT_MENU* m ) { + auto findFunc = [&]( ACTION_MENU* m ) { if( evt ) return; @@ -450,7 +450,7 @@ OPT_TOOL_EVENT CONTEXT_MENU::findToolAction( int aId ) } -void CONTEXT_MENU::copyFrom( const CONTEXT_MENU& aMenu ) +void ACTION_MENU::copyFrom( const ACTION_MENU& aMenu ) { m_icon = aMenu.m_icon; m_title = aMenu.m_title; @@ -468,7 +468,7 @@ void CONTEXT_MENU::copyFrom( const CONTEXT_MENU& aMenu ) } -wxMenuItem* CONTEXT_MENU::appendCopy( const wxMenuItem* aSource ) +wxMenuItem* ACTION_MENU::appendCopy( const wxMenuItem* aSource ) { wxMenuItem* newItem = new wxMenuItem( this, aSource->GetId(), aSource->GetItemLabel(), aSource->GetHelp(), aSource->GetKind() ); @@ -481,12 +481,12 @@ wxMenuItem* CONTEXT_MENU::appendCopy( const wxMenuItem* aSource ) if( aSource->IsSubMenu() ) { - CONTEXT_MENU* menu = dynamic_cast( aSource->GetSubMenu() ); - wxASSERT_MSG( menu, "Submenus are expected to be a CONTEXT_MENU" ); + ACTION_MENU* menu = dynamic_cast( aSource->GetSubMenu() ); + wxASSERT_MSG( menu, "Submenus are expected to be a ACTION_MENU" ); if( menu ) { - CONTEXT_MENU* menuCopy = menu->Clone(); + ACTION_MENU* menuCopy = menu->Clone(); newItem->SetSubMenu( menuCopy ); m_submenus.push_back( menuCopy ); } diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp index 55295b4ca7..9a5417f631 100644 --- a/common/tool/conditional_menu.cpp +++ b/common/tool/conditional_menu.cpp @@ -24,10 +24,10 @@ */ #include -#include +#include -CONTEXT_MENU* CONDITIONAL_MENU::create() const +ACTION_MENU* CONDITIONAL_MENU::create() const { CONDITIONAL_MENU* clone = new CONDITIONAL_MENU( m_isContextMenu, m_tool ); clone->m_entries = m_entries; @@ -51,7 +51,7 @@ void CONDITIONAL_MENU::AddCheckItem( const TOOL_ACTION& aAction, } -void CONDITIONAL_MENU::AddMenu( CONTEXT_MENU* aMenu, const SELECTION_CONDITION& aCondition, +void CONDITIONAL_MENU::AddMenu( ACTION_MENU* aMenu, const SELECTION_CONDITION& aCondition, int aOrder ) { addEntry( ENTRY( aMenu, aCondition, aOrder ) ); diff --git a/common/tool/tool_interactive.cpp b/common/tool/tool_interactive.cpp index 54dcae5e04..5264684d66 100644 --- a/common/tool/tool_interactive.cpp +++ b/common/tool/tool_interactive.cpp @@ -27,7 +27,7 @@ #include #include #include -#include +#include TOOL_INTERACTIVE::TOOL_INTERACTIVE( TOOL_ID aId, const std::string& aName ) : TOOL_BASE( INTERACTIVE, aId, aName ) @@ -71,7 +71,7 @@ void TOOL_INTERACTIVE::goInternal( TOOL_STATE_FUNC& aState, const TOOL_EVENT_LIS } -void TOOL_INTERACTIVE::SetContextMenu( CONTEXT_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger ) +void TOOL_INTERACTIVE::SetContextMenu( ACTION_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger ) { if( aMenu ) aMenu->SetTool( this ); diff --git a/common/tool/tool_manager.cpp b/common/tool/tool_manager.cpp index 5269a6c27f..e95bc83666 100644 --- a/common/tool/tool_manager.cpp +++ b/common/tool/tool_manager.cpp @@ -37,7 +37,7 @@ #include #include #include -#include +#include #include #include @@ -89,7 +89,7 @@ struct TOOL_MANAGER::TOOL_STATE bool pendingContextMenu; /// Context menu currently used by the tool - CONTEXT_MENU* contextMenu; + ACTION_MENU* contextMenu; /// Defines when the context menu is opened CONTEXT_MENU_TRIGGER contextMenuTrigger; @@ -671,7 +671,7 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent ) st->waitEvents = TOOL_EVENT( TC_ANY, TA_ANY ); // Store the menu pointer in case it is changed by the TOOL when handling menu events - CONTEXT_MENU* m = st->contextMenu; + ACTION_MENU* m = st->contextMenu; if( st->contextMenuTrigger == CMENU_NOW ) st->contextMenuTrigger = CMENU_OFF; @@ -695,7 +695,7 @@ void TOOL_MANAGER::dispatchContextMenu( const TOOL_EVENT& aEvent ) m_viewControls->ForceCursorPosition( true, m_menuCursor ); // Display a copy of menu - std::unique_ptr menu( m->Clone() ); + std::unique_ptr menu( m->Clone() ); m_menuOwner = toolId; m_menuActive = true; @@ -796,7 +796,7 @@ bool TOOL_MANAGER::ProcessEvent( const TOOL_EVENT& aEvent ) } -void TOOL_MANAGER::ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu, +void TOOL_MANAGER::ScheduleContextMenu( TOOL_BASE* aTool, ACTION_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger ) { TOOL_STATE* st = m_toolState[aTool]; diff --git a/common/tool/tool_menu.cpp b/common/tool/tool_menu.cpp index 1e4259e47f..09d5d2a96e 100644 --- a/common/tool/tool_menu.cpp +++ b/common/tool/tool_menu.cpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -49,7 +49,7 @@ CONDITIONAL_MENU& TOOL_MENU::GetMenu() } -void TOOL_MENU::AddSubMenu( std::shared_ptr aSubMenu ) +void TOOL_MENU::AddSubMenu( std::shared_ptr aSubMenu ) { // store a copy of the menu (keeps a reference) m_subMenus.push_back( std::move( aSubMenu ) ); diff --git a/cvpcb/tools/cvpcb_selection_tool.h b/cvpcb/tools/cvpcb_selection_tool.h index 57f0322a18..73fcff05bc 100644 --- a/cvpcb/tools/cvpcb_selection_tool.h +++ b/cvpcb/tools/cvpcb_selection_tool.h @@ -22,7 +22,7 @@ #include -#include +#include #include #include #include diff --git a/eeschema/libedit/lib_edit_frame.cpp b/eeschema/libedit/lib_edit_frame.cpp index 853fa98838..5d4c74976a 100644 --- a/eeschema/libedit/lib_edit_frame.cpp +++ b/eeschema/libedit/lib_edit_frame.cpp @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include #include #include @@ -586,7 +586,7 @@ void LIB_EDIT_FRAME::OnViewEntryDoc( wxCommandEvent& event ) if( part->GetAliasCount() > 1 ) { - CONTEXT_MENU popup; + ACTION_MENU popup; wxString msg; int id = 0; diff --git a/eeschema/tools/ee_selection_tool.cpp b/eeschema/tools/ee_selection_tool.cpp index dd81bf63e6..fb8a95ef29 100644 --- a/eeschema/tools/ee_selection_tool.cpp +++ b/eeschema/tools/ee_selection_tool.cpp @@ -277,7 +277,7 @@ void EE_SELECTION_TOOL::Reset( RESET_REASON aReason ) int EE_SELECTION_TOOL::UpdateMenu( const TOOL_EVENT& aEvent ) { - CONTEXT_MENU* actionMenu = aEvent.Parameter(); + ACTION_MENU* actionMenu = aEvent.Parameter(); CONDITIONAL_MENU* conditionalMenu = dynamic_cast( actionMenu ); if( conditionalMenu ) @@ -841,8 +841,8 @@ int EE_SELECTION_TOOL::SelectionMenu( const TOOL_EVENT& aEvent ) bool EE_SELECTION_TOOL::doSelectionMenu( EE_COLLECTOR* aCollector ) { - EDA_ITEM* current = nullptr; - CONTEXT_MENU menu; + EDA_ITEM* current = nullptr; + ACTION_MENU menu; int limit = std::min( MAX_SELECT_ITEM_IDS, aCollector->GetCount() ); diff --git a/eeschema/tools/ee_selection_tool.h b/eeschema/tools/ee_selection_tool.h index 2815dc415a..2c120a3a1c 100644 --- a/eeschema/tools/ee_selection_tool.h +++ b/eeschema/tools/ee_selection_tool.h @@ -25,7 +25,7 @@ #define KICAD_SCH_SELECTION_TOOL_H #include -#include +#include #include #include #include diff --git a/eeschema/tools/sch_edit_tool.cpp b/eeschema/tools/sch_edit_tool.cpp index 97e98f87ae..0ef62c197c 100644 --- a/eeschema/tools/sch_edit_tool.cpp +++ b/eeschema/tools/sch_edit_tool.cpp @@ -175,7 +175,7 @@ TOOL_ACTION EE_ACTIONS::breakBus( "eeschema.InteractiveEdit.breakBus", break_line_xpm ); -class SYMBOL_UNIT_MENU : public CONTEXT_MENU +class SYMBOL_UNIT_MENU : public ACTION_MENU { public: SYMBOL_UNIT_MENU() @@ -186,7 +186,7 @@ public: protected: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new SYMBOL_UNIT_MENU(); } diff --git a/eeschema/tools/sch_wire_bus_tool.cpp b/eeschema/tools/sch_wire_bus_tool.cpp index f7c05db4c3..61712619c4 100644 --- a/eeschema/tools/sch_wire_bus_tool.cpp +++ b/eeschema/tools/sch_wire_bus_tool.cpp @@ -95,7 +95,7 @@ TOOL_ACTION EE_ACTIONS::finishLine( "eeschema.WireBusDrawing.finishLine", checked_ok_xpm, AF_NONE ); -class BUS_UNFOLD_MENU : public CONTEXT_MENU +class BUS_UNFOLD_MENU : public ACTION_MENU { public: BUS_UNFOLD_MENU() : @@ -112,7 +112,7 @@ public: protected: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new BUS_UNFOLD_MENU(); } @@ -166,7 +166,7 @@ private: if( member->Type() == CONNECTION_BUS ) { - wxMenu* submenu = new CONTEXT_MENU; + wxMenu* submenu = new ACTION_MENU; AppendSubMenu( submenu, name ); for( const auto& sub_member : member->Members() ) diff --git a/gerbview/tools/gerbview_selection_tool.cpp b/gerbview/tools/gerbview_selection_tool.cpp index f8cb16fdb3..171fd00552 100644 --- a/gerbview/tools/gerbview_selection_tool.cpp +++ b/gerbview/tools/gerbview_selection_tool.cpp @@ -75,7 +75,7 @@ TOOL_ACTION GERBVIEW_ACTIONS::measureTool( "gerbview.InteractiveSelection.measur nullptr, AF_ACTIVATE ); -class HIGHLIGHT_MENU: public CONTEXT_MENU +class HIGHLIGHT_MENU: public ACTION_MENU { public: HIGHLIGHT_MENU() @@ -131,7 +131,7 @@ private: Add( GERBVIEW_ACTIONS::highlightClear ); } - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new HIGHLIGHT_MENU(); } @@ -606,7 +606,7 @@ EDA_ITEM* GERBVIEW_SELECTION_TOOL::disambiguationMenu( GERBER_COLLECTOR* aCollec { EDA_ITEM* current = NULL; KIGFX::VIEW_GROUP highlightGroup; - CONTEXT_MENU menu; + ACTION_MENU menu; highlightGroup.SetLayer( LAYER_SELECT_OVERLAY ); getView()->Add( &highlightGroup ); diff --git a/gerbview/tools/gerbview_selection_tool.h b/gerbview/tools/gerbview_selection_tool.h index b8b83fd7f6..7f78c5e66a 100644 --- a/gerbview/tools/gerbview_selection_tool.h +++ b/gerbview/tools/gerbview_selection_tool.h @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include diff --git a/include/tool/context_menu.h b/include/tool/action_menu.h similarity index 86% rename from include/tool/context_menu.h rename to include/tool/action_menu.h index 4ce761e827..240aea9bcf 100644 --- a/include/tool/context_menu.h +++ b/include/tool/action_menu.h @@ -36,25 +36,24 @@ class TOOL_INTERACTIVE; /** - * Class CONTEXT_MENU + * Class ACTION_MENU * - * Defines the structure of a context (usually right-click) popup menu - * for a given tool. + * Defines the structure of a menu based on ACTIONs. */ -class CONTEXT_MENU : public wxMenu +class ACTION_MENU : public wxMenu { public: ///> Default constructor - CONTEXT_MENU(); + ACTION_MENU(); - virtual ~CONTEXT_MENU(); + virtual ~ACTION_MENU(); - CONTEXT_MENU( const CONTEXT_MENU& aMenu ) = delete; - CONTEXT_MENU& operator=( const CONTEXT_MENU& aMenu ) = delete; + ACTION_MENU( const ACTION_MENU& aMenu ) = delete; + ACTION_MENU& operator=( const ACTION_MENU& aMenu ) = delete; /** * Function SetTitle() - * Sets title for the context menu. The title is shown as a text label shown on the top of + * Sets title for the menu. The title is shown as a text label shown on the top of * the menu. * @param aTitle is the new title. */ @@ -93,11 +92,11 @@ public: /** * Function Add() - * Adds a context menu as a submenu. The difference between this function and wxMenu::AppendSubMenu() - * is the capability to handle icons. + * Adds an action menu as a submenu. The difference between this function and + * wxMenu::AppendSubMenu() is the capability to handle icons. * @param aMenu is the submenu to be added. */ - wxMenuItem* Add( CONTEXT_MENU* aMenu ); + wxMenuItem* Add( ACTION_MENU* aMenu ); /** * Function Clear() @@ -117,7 +116,7 @@ public: * Function GetSelected() * Returns the position of selected item. If the returned value is negative, that means that * menu was dismissed. - * @return The position of selected item in the context menu. + * @return The position of selected item in the action menu. */ inline int GetSelected() const { @@ -138,9 +137,9 @@ public: void SetTool( TOOL_INTERACTIVE* aTool ); /** - * Creates a deep, recursive copy of this CONTEXT_MENU. + * Creates a deep, recursive copy of this ACTION_MENU. */ - CONTEXT_MENU* Clone() const; + ACTION_MENU* Clone() const; public: ///> Menu requires updating before display. @@ -148,7 +147,7 @@ public: protected: ///> Returns an instance of this class. It has to be overridden in inheriting classes. - virtual CONTEXT_MENU* create() const; + virtual ACTION_MENU* create() const; ///> Returns an instance of TOOL_MANAGER class. TOOL_MANAGER* getToolManager() const; @@ -180,7 +179,7 @@ protected: * Copies another menus data to this instance. Old entries are preserved, and ones form aMenu * are copied. */ - void copyFrom( const CONTEXT_MENU& aMenu ); + void copyFrom( const ACTION_MENU& aMenu ); protected: /** @@ -203,7 +202,7 @@ protected: void runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent ); ///> Runs a function on the menu and all its submenus. - void runOnSubmenus( std::function aFunction ); + void runOnSubmenus( std::function aFunction ); ///> Checks if any of submenus contains a TOOL_ACTION with a specific ID. OPT_TOOL_EVENT findToolAction( int aId ); @@ -227,7 +226,7 @@ protected: std::map m_toolActions; ///> List of submenus. - std::list m_submenus; + std::list m_submenus; ///> Optional icon const BITMAP_OPAQUE* m_icon; diff --git a/include/tool/conditional_menu.h b/include/tool/conditional_menu.h index 4ccca98cb4..8679936e27 100644 --- a/include/tool/conditional_menu.h +++ b/include/tool/conditional_menu.h @@ -26,7 +26,7 @@ #define CONDITIONAL_MENU_H #include -#include +#include #include #include @@ -36,7 +36,7 @@ class TOOL_ACTION; class TOOL_INTERACTIVE; -class CONDITIONAL_MENU : public CONTEXT_MENU +class CONDITIONAL_MENU : public ACTION_MENU { public: ///> Constant to indicate that we do not care about an ENTRY location in the menu. @@ -49,7 +49,7 @@ public: m_tool = aTool; } - CONTEXT_MENU* create() const override; + ACTION_MENU* create() const override; /** * Function AddItem() @@ -87,7 +87,7 @@ public: * @param aOrder determines location of the added menu, higher numbers are put on the bottom. * You may use ANY_ORDER here if you think it does not matter. */ - void AddMenu( CONTEXT_MENU* aMenu, + void AddMenu( ACTION_MENU* aMenu, const SELECTION_CONDITION& aCondition = SELECTION_CONDITIONS::ShowAlways, int aOrder = ANY_ORDER ); @@ -124,7 +124,7 @@ private: m_data.action = aAction; } - ENTRY( CONTEXT_MENU* aMenu, SELECTION_CONDITION aCondition, int aOrder ) : + ENTRY( ACTION_MENU* aMenu, SELECTION_CONDITION aCondition, int aOrder ) : m_type( MENU ), m_condition( aCondition ), m_order( aOrder ), @@ -160,7 +160,7 @@ private: return m_data.action; } - inline CONTEXT_MENU* Menu() const + inline ACTION_MENU* Menu() const { assert( m_type == MENU ); return m_data.menu; @@ -191,7 +191,7 @@ private: union { const TOOL_ACTION* action; - CONTEXT_MENU* menu; + ACTION_MENU* menu; } m_data; ///> Condition to be fulfilled to show the entry in menu. diff --git a/include/tool/grid_menu.h b/include/tool/grid_menu.h index 1067303ee1..ee03c6f76e 100644 --- a/include/tool/grid_menu.h +++ b/include/tool/grid_menu.h @@ -25,17 +25,17 @@ #ifndef GRID_MENU_H #define GRID_MENU_H -#include +#include class EDA_DRAW_FRAME; -class GRID_MENU : public CONTEXT_MENU +class GRID_MENU : public ACTION_MENU { public: GRID_MENU( EDA_DRAW_FRAME* aParent ); private: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new GRID_MENU( m_parent ); } diff --git a/include/tool/tool_interactive.h b/include/tool/tool_interactive.h index 4e23d0160a..beffec4910 100644 --- a/include/tool/tool_interactive.h +++ b/include/tool/tool_interactive.h @@ -31,7 +31,7 @@ #include #include -class CONTEXT_MENU; +class ACTION_MENU; class TOOL_INTERACTIVE : public TOOL_BASE { @@ -62,7 +62,7 @@ public: * @param aMenu is the menu to be assigned. * @param aTrigger determines conditions upon which the context menu is activated. */ - void SetContextMenu( CONTEXT_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger = CMENU_BUTTON ); + void SetContextMenu( ACTION_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger = CMENU_BUTTON ); /** * Function RunMainStack() diff --git a/include/tool/tool_manager.h b/include/tool/tool_manager.h index eef38c8d1d..ac3e6f1221 100644 --- a/include/tool/tool_manager.h +++ b/include/tool/tool_manager.h @@ -36,7 +36,7 @@ class TOOL_BASE; class ACTION_MANAGER; -class CONTEXT_MENU; +class ACTION_MENU; class wxWindow; /** @@ -347,7 +347,7 @@ public: * CMENU_OFF: menu is disabled. * May be called from a coroutine context. */ - void ScheduleContextMenu( TOOL_BASE* aTool, CONTEXT_MENU* aMenu, + void ScheduleContextMenu( TOOL_BASE* aTool, ACTION_MENU* aMenu, CONTEXT_MENU_TRIGGER aTrigger ); /** diff --git a/include/tool/tool_menu.h b/include/tool/tool_menu.h index 1e48e0be87..72ad8624fa 100644 --- a/include/tool/tool_menu.h +++ b/include/tool/tool_menu.h @@ -30,7 +30,7 @@ #include #include -class CONTEXT_MENU; +class ACTION_MENU; /** * Class TOOL_MENU @@ -87,14 +87,13 @@ public: * * @param aSubMenu: a sub menu to add */ - void AddSubMenu( std::shared_ptr aSubMenu ); + void AddSubMenu( std::shared_ptr aSubMenu ); /** * Function ShowContextMenu * - * Helper function to set and immediately show a CONTEXT_MENU - * based on the internal CONDITIONAL_MENU in concert with - * the given SELECTION + * Helper function to set and immediately show a CONDITIONAL_MENU + * in concert with the given SELECTION * * You don't have to use this function, if the caller has a * different way to show the menu, it can create one from @@ -162,7 +161,7 @@ private: /** * Lifetime-managing container of submenus */ - std::vector > m_subMenus; + std::vector > m_subMenus; }; #endif // TOOLS_TOOL_MENU__H_ diff --git a/include/tool/zoom_menu.h b/include/tool/zoom_menu.h index b637b28e14..bc807895fe 100644 --- a/include/tool/zoom_menu.h +++ b/include/tool/zoom_menu.h @@ -25,17 +25,17 @@ #ifndef ZOOM_MENU_H #define ZOOM_MENU_H -#include +#include class EDA_DRAW_FRAME; -class ZOOM_MENU : public CONTEXT_MENU +class ZOOM_MENU : public ACTION_MENU { public: ZOOM_MENU( EDA_DRAW_FRAME* aParent ); private: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new ZOOM_MENU( m_parent ); } diff --git a/pcbnew/router/length_tuner_tool.cpp b/pcbnew/router/length_tuner_tool.cpp index 207fa2b590..589fab1919 100644 --- a/pcbnew/router/length_tuner_tool.cpp +++ b/pcbnew/router/length_tuner_tool.cpp @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include #include @@ -86,7 +86,7 @@ LENGTH_TUNER_TOOL::LENGTH_TUNER_TOOL() : } -class TUNER_TOOL_MENU : public CONTEXT_MENU +class TUNER_TOOL_MENU : public ACTION_MENU { public: TUNER_TOOL_MENU() @@ -107,7 +107,7 @@ public: } private: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new TUNER_TOOL_MENU(); } diff --git a/pcbnew/router/pns_tool_base.cpp b/pcbnew/router/pns_tool_base.cpp index 266118c6ee..99ad5b279a 100644 --- a/pcbnew/router/pns_tool_base.cpp +++ b/pcbnew/router/pns_tool_base.cpp @@ -41,7 +41,7 @@ using namespace std::placeholders; #include #include -#include +#include #include #include diff --git a/pcbnew/router/router_tool.cpp b/pcbnew/router/router_tool.cpp index 76089e3300..aba08c7e0d 100644 --- a/pcbnew/router/router_tool.cpp +++ b/pcbnew/router/router_tool.cpp @@ -45,7 +45,7 @@ using namespace std::placeholders; #include #include -#include +#include #include #include #include @@ -205,7 +205,7 @@ ROUTER_TOOL::ROUTER_TOOL() : } -class TRACK_WIDTH_MENU: public CONTEXT_MENU +class TRACK_WIDTH_MENU: public ACTION_MENU { public: TRACK_WIDTH_MENU( PCB_EDIT_FRAME& aFrame ) : @@ -216,7 +216,7 @@ public: } protected: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new TRACK_WIDTH_MENU( m_frame ); } @@ -333,7 +333,7 @@ private: }; -class DIFF_PAIR_MENU: public CONTEXT_MENU +class DIFF_PAIR_MENU: public ACTION_MENU { public: DIFF_PAIR_MENU( PCB_EDIT_FRAME& aFrame ) : @@ -344,7 +344,7 @@ public: } protected: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new DIFF_PAIR_MENU( m_frame ); } @@ -423,7 +423,7 @@ private: }; -class ROUTER_TOOL_MENU : public CONTEXT_MENU +class ROUTER_TOOL_MENU : public ACTION_MENU { public: ROUTER_TOOL_MENU( PCB_EDIT_FRAME& aFrame, PNS::ROUTER_MODE aMode ) : @@ -467,7 +467,7 @@ public: } private: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new ROUTER_TOOL_MENU( m_frame, m_mode ); } diff --git a/pcbnew/tools/pad_tool.cpp b/pcbnew/tools/pad_tool.cpp index af289f2f7f..2bfd0058a1 100644 --- a/pcbnew/tools/pad_tool.cpp +++ b/pcbnew/tools/pad_tool.cpp @@ -61,7 +61,7 @@ TOOL_ACTION PCB_ACTIONS::pushPadSettings( push_pad_settings_xpm ); -class PAD_CONTEXT_MENU : public CONTEXT_MENU +class PAD_CONTEXT_MENU : public ACTION_MENU { public: @@ -88,7 +88,7 @@ public: protected: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new PAD_CONTEXT_MENU( m_editingFootprint, m_haveGlobalPadSettings ); } diff --git a/pcbnew/tools/pad_tool.h b/pcbnew/tools/pad_tool.h index f4e5d38fde..38958c87a5 100644 --- a/pcbnew/tools/pad_tool.h +++ b/pcbnew/tools/pad_tool.h @@ -27,7 +27,7 @@ #include -class CONTEXT_MENU; +class ACTION_MENU; /** * Class PAD_TOOL diff --git a/pcbnew/tools/pcb_editor_control.cpp b/pcbnew/tools/pcb_editor_control.cpp index d2e330a704..57d0956474 100644 --- a/pcbnew/tools/pcb_editor_control.cpp +++ b/pcbnew/tools/pcb_editor_control.cpp @@ -153,7 +153,7 @@ TOOL_ACTION PCB_ACTIONS::updateLocalRatsnest( "pcbnew.Control.updateLocalRatsnes AS_GLOBAL, 0, "", "" ); -class ZONE_CONTEXT_MENU : public CONTEXT_MENU +class ZONE_CONTEXT_MENU : public ACTION_MENU { public: ZONE_CONTEXT_MENU() @@ -176,7 +176,7 @@ public: protected: - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new ZONE_CONTEXT_MENU(); } @@ -212,7 +212,7 @@ private: }; -class LOCK_CONTEXT_MENU : public CONTEXT_MENU +class LOCK_CONTEXT_MENU : public ACTION_MENU { public: LOCK_CONTEXT_MENU() @@ -226,7 +226,7 @@ public: Add( PCB_ACTIONS::toggleLock ); } - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new LOCK_CONTEXT_MENU(); } diff --git a/pcbnew/tools/placement_tool.cpp b/pcbnew/tools/placement_tool.cpp index f96e5ecbd9..5144144998 100644 --- a/pcbnew/tools/placement_tool.cpp +++ b/pcbnew/tools/placement_tool.cpp @@ -101,7 +101,7 @@ bool ALIGN_DISTRIBUTE_TOOL::Init() m_frame = getEditFrame(); // Create a context menu and make it available through selection tool - m_placementMenu = new CONTEXT_MENU; + m_placementMenu = new ACTION_MENU; m_placementMenu->SetIcon( align_items_xpm ); m_placementMenu->SetTitle( _( "Align/Distribute" ) ); diff --git a/pcbnew/tools/placement_tool.h b/pcbnew/tools/placement_tool.h index 946e912766..deef4fb9a1 100644 --- a/pcbnew/tools/placement_tool.h +++ b/pcbnew/tools/placement_tool.h @@ -130,7 +130,7 @@ private: SELECTION_TOOL* m_selectionTool; - CONTEXT_MENU* m_placementMenu; + ACTION_MENU* m_placementMenu; PCB_BASE_FRAME* m_frame; diff --git a/pcbnew/tools/selection_tool.cpp b/pcbnew/tools/selection_tool.cpp index fad2032078..b3c4494362 100644 --- a/pcbnew/tools/selection_tool.cpp +++ b/pcbnew/tools/selection_tool.cpp @@ -140,7 +140,7 @@ TOOL_ACTION PCB_ACTIONS::filterSelection( "pcbnew.InteractiveSelection.FilterSel _( "Filter Selection..." ), _( "Filter the types of items in the selection" ), options_generic_xpm ); -class SELECT_MENU: public CONTEXT_MENU +class SELECT_MENU: public ACTION_MENU { public: SELECT_MENU() @@ -175,7 +175,7 @@ private: Enable( getMenuId( PCB_ACTIONS::selectSameSheet ), sheetSelEnabled ); } - CONTEXT_MENU* create() const override + ACTION_MENU* create() const override { return new SELECT_MENU(); } @@ -1441,7 +1441,7 @@ bool SELECTION_TOOL::doSelectionMenu( GENERAL_COLLECTOR* aCollector, const wxStr { BOARD_ITEM* current = nullptr; SELECTION highlightGroup; - CONTEXT_MENU menu; + ACTION_MENU menu; highlightGroup.SetLayer( LAYER_SELECT_OVERLAY ); getView()->Add( &highlightGroup ); diff --git a/pcbnew/tools/selection_tool.h b/pcbnew/tools/selection_tool.h index f53691db58..3b577cf637 100644 --- a/pcbnew/tools/selection_tool.h +++ b/pcbnew/tools/selection_tool.h @@ -31,7 +31,7 @@ #include #include -#include +#include #include #include