diff --git a/common/tool/context_menu.cpp b/common/tool/context_menu.cpp index b6277e16a7..e68473dd6c 100644 --- a/common/tool/context_menu.cpp +++ b/common/tool/context_menu.cpp @@ -193,6 +193,23 @@ void CONTEXT_MENU::onMenuEvent( wxEvent& aEvent ) } +void CONTEXT_MENU::setTool( TOOL_INTERACTIVE* aTool ) +{ + m_tool = aTool; + + for( unsigned i = 0; i < GetMenuItemCount(); ++i ) + { + wxMenuItem* item = FindItemByPosition( i ); + + if( item->IsSubMenu() ) + { + CONTEXT_MENU* menu = static_cast( item->GetSubMenu() ); + menu->setTool( aTool ); + } + } +} + + void CONTEXT_MENU::copyItem( const wxMenuItem* aSource, wxMenuItem* aDest ) const { assert( !aSource->IsSubMenu() ); // it does not transfer submenus diff --git a/include/tool/context_menu.h b/include/tool/context_menu.h index 9090702f8c..e50ef207c2 100644 --- a/include/tool/context_menu.h +++ b/include/tool/context_menu.h @@ -115,17 +115,12 @@ private: ///> Event handler. void onMenuEvent( wxEvent& aEvent ); - friend class TOOL_INTERACTIVE; - /** * Function setTool() * Sets a tool that is the creator of the menu. * @param aTool is the tool that created the menu. */ - void setTool( TOOL_INTERACTIVE* aTool ) - { - m_tool = aTool; - } + void setTool( TOOL_INTERACTIVE* aTool ); ///> Flag indicating that the menu title was set up. bool m_titleSet; @@ -147,6 +142,8 @@ private: /// Custom events handler, allows to translate wxEvents to TOOL_EVENTs. boost::function m_customHandler; + + friend class TOOL_INTERACTIVE; }; #endif