Commit b1a19b12 authored by Maciej Suminski's avatar Maciej Suminski
Browse files

Setting proper tool for submenus of CONTEXT_MENU class.

parent 3ef78c66
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -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<CONTEXT_MENU*>( item->GetSubMenu() );
            menu->setTool( aTool );
        }
    }
}


void CONTEXT_MENU::copyItem( const wxMenuItem* aSource, wxMenuItem* aDest ) const
{
    assert( !aSource->IsSubMenu() );    // it does not transfer submenus
+3 −6
Original line number Diff line number Diff line
@@ -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<OPT_TOOL_EVENT(const wxEvent& aEvent)> m_customHandler;

    friend class TOOL_INTERACTIVE;
};

#endif