2013-08-07 09:20:12 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
2015-04-30 08:46:05 +00:00
|
|
|
* Copyright (C) 2013-2015 CERN
|
2013-08-07 09:20:12 +00:00
|
|
|
* @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
|
2015-04-30 08:46:05 +00:00
|
|
|
* @author Maciej Suminski <maciej.suminski@cern.ch>
|
2013-08-07 09:20:12 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2013-08-02 14:46:53 +00:00
|
|
|
#include <tool/tool_event.h>
|
|
|
|
#include <tool/tool_manager.h>
|
|
|
|
#include <tool/tool_interactive.h>
|
|
|
|
#include <tool/context_menu.h>
|
2015-04-02 14:09:48 +00:00
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
#include <boost/bind.hpp>
|
2013-09-26 12:09:18 +00:00
|
|
|
#include <cassert>
|
2013-08-02 14:46:53 +00:00
|
|
|
|
2013-09-26 12:09:18 +00:00
|
|
|
CONTEXT_MENU::CONTEXT_MENU() :
|
2015-04-30 08:46:05 +00:00
|
|
|
m_titleSet( false ), m_selected( -1 ), m_tool( NULL ), m_parent( NULL ), m_icon( NULL ),
|
|
|
|
m_menu_handler( CONTEXT_MENU::menuHandlerStub ),
|
|
|
|
m_update_handler( CONTEXT_MENU::updateHandlerStub )
|
2013-08-02 14:46:53 +00:00
|
|
|
{
|
2014-05-13 09:22:51 +00:00
|
|
|
setupEvents();
|
2013-08-02 14:46:53 +00:00
|
|
|
}
|
|
|
|
|
2013-08-07 09:20:12 +00:00
|
|
|
|
2015-04-30 08:46:04 +00:00
|
|
|
CONTEXT_MENU::CONTEXT_MENU( const CONTEXT_MENU& aMenu )
|
2013-08-02 14:46:53 +00:00
|
|
|
{
|
2015-04-02 14:09:48 +00:00
|
|
|
copyFrom( aMenu );
|
2014-05-13 09:22:51 +00:00
|
|
|
setupEvents();
|
2014-05-13 09:22:51 +00:00
|
|
|
}
|
2013-09-26 16:38:58 +00:00
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
|
2015-04-30 08:46:05 +00:00
|
|
|
CONTEXT_MENU::~CONTEXT_MENU()
|
|
|
|
{
|
|
|
|
// Set parent to NULL to prevent submenus from unregistering from a notexisting object
|
|
|
|
for( std::list<CONTEXT_MENU*>::iterator it = m_submenus.begin(); it != m_submenus.end(); ++it )
|
|
|
|
(*it)->m_parent = NULL;
|
|
|
|
|
|
|
|
if( m_parent )
|
|
|
|
m_parent->m_submenus.remove( this );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-07-09 13:10:32 +00:00
|
|
|
CONTEXT_MENU& CONTEXT_MENU::operator=( const CONTEXT_MENU& aMenu )
|
|
|
|
{
|
|
|
|
Clear();
|
2015-04-02 14:09:48 +00:00
|
|
|
copyFrom( aMenu );
|
2014-07-09 13:10:32 +00:00
|
|
|
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
void CONTEXT_MENU::setupEvents()
|
|
|
|
{
|
2015-01-25 18:11:02 +00:00
|
|
|
Connect( wxEVT_MENU_HIGHLIGHT, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
|
|
|
|
Connect( wxEVT_COMMAND_MENU_SELECTED, wxMenuEventHandler( CONTEXT_MENU::onMenuEvent ), NULL, this );
|
2013-08-02 14:46:53 +00:00
|
|
|
}
|
|
|
|
|
2013-08-07 09:20:12 +00:00
|
|
|
|
2013-08-02 14:46:53 +00:00
|
|
|
void CONTEXT_MENU::SetTitle( const wxString& aTitle )
|
|
|
|
{
|
2013-09-27 14:23:43 +00:00
|
|
|
// TODO handle an empty string (remove title and separator)
|
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
// Unfortunately wxMenu::SetTitle() does nothing.. (at least wxGTK)
|
|
|
|
|
2013-10-14 11:43:57 +00:00
|
|
|
if( m_titleSet )
|
|
|
|
{
|
2014-05-13 09:22:51 +00:00
|
|
|
FindItemByPosition( 0 )->SetItemLabel( aTitle );
|
2013-10-14 11:43:57 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-05-13 09:22:51 +00:00
|
|
|
InsertSeparator( 0 );
|
2015-02-06 21:01:57 +00:00
|
|
|
Insert( 0, new wxMenuItem( this, wxID_NONE, aTitle, wxEmptyString, wxITEM_NORMAL ) );
|
2013-09-26 12:09:18 +00:00
|
|
|
m_titleSet = true;
|
2013-10-14 11:43:57 +00:00
|
|
|
}
|
2013-08-02 14:46:53 +00:00
|
|
|
}
|
|
|
|
|
2013-08-07 09:20:12 +00:00
|
|
|
|
2015-04-30 08:46:04 +00:00
|
|
|
wxMenuItem* CONTEXT_MENU::Add( const wxString& aLabel, int aId, const BITMAP_OPAQUE* aIcon )
|
2013-09-26 12:09:18 +00:00
|
|
|
{
|
2013-09-27 14:23:43 +00:00
|
|
|
#ifdef DEBUG
|
2014-05-13 09:22:51 +00:00
|
|
|
if( FindItem( aId ) != NULL )
|
2013-09-27 14:23:43 +00:00
|
|
|
wxLogWarning( wxT( "Adding more than one menu entry with the same ID may result in"
|
|
|
|
"undefined behaviour" ) );
|
|
|
|
#endif
|
2015-04-30 08:46:05 +00:00
|
|
|
|
2015-04-02 14:09:48 +00:00
|
|
|
wxMenuItem* item = new wxMenuItem( this, aId, aLabel, wxEmptyString, wxITEM_NORMAL );
|
|
|
|
|
|
|
|
if( aIcon )
|
|
|
|
item->SetBitmap( KiBitmap( aIcon ) );
|
|
|
|
|
2015-04-30 08:46:04 +00:00
|
|
|
return Append( item );
|
2013-09-26 12:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-30 08:46:04 +00:00
|
|
|
wxMenuItem* CONTEXT_MENU::Add( const TOOL_ACTION& aAction )
|
2013-08-02 14:46:53 +00:00
|
|
|
{
|
2015-04-30 08:46:04 +00:00
|
|
|
/// ID numbers for tool actions need to have a value higher than ACTION_ID
|
2015-04-02 14:09:48 +00:00
|
|
|
const BITMAP_OPAQUE* icon = aAction.GetIcon();
|
2013-09-26 16:38:58 +00:00
|
|
|
|
2015-05-05 18:39:42 +00:00
|
|
|
wxMenuItem* item = new wxMenuItem( this, getMenuId( aAction ), aAction.GetMenuItem(),
|
2015-04-30 08:46:04 +00:00
|
|
|
aAction.GetDescription(), wxITEM_NORMAL );
|
2013-09-26 16:38:58 +00:00
|
|
|
|
2015-04-02 14:09:48 +00:00
|
|
|
if( icon )
|
|
|
|
item->SetBitmap( KiBitmap( icon ) );
|
|
|
|
|
2015-05-05 18:39:42 +00:00
|
|
|
m_toolActions[getMenuId( aAction )] = &aAction;
|
2015-04-30 08:46:04 +00:00
|
|
|
|
|
|
|
return Append( item );
|
2013-08-02 14:46:53 +00:00
|
|
|
}
|
|
|
|
|
2013-08-07 09:20:12 +00:00
|
|
|
|
2015-04-30 08:46:04 +00:00
|
|
|
std::list<wxMenuItem*> CONTEXT_MENU::Add( CONTEXT_MENU* aMenu, const wxString& aLabel, bool aExpand )
|
2015-04-02 14:09:48 +00:00
|
|
|
{
|
2015-04-30 08:46:04 +00:00
|
|
|
std::list<wxMenuItem*> items;
|
2015-07-24 07:42:46 +00:00
|
|
|
CONTEXT_MENU* menuCopy = new CONTEXT_MENU( *aMenu );
|
|
|
|
m_submenus.push_back( menuCopy );
|
|
|
|
menuCopy->m_parent = this;
|
2015-04-30 08:46:04 +00:00
|
|
|
|
|
|
|
if( aExpand )
|
2015-04-02 14:09:48 +00:00
|
|
|
{
|
2015-04-30 08:46:07 +00:00
|
|
|
for( int i = 0; i < (int) aMenu->GetMenuItemCount(); ++i )
|
2015-04-30 08:46:04 +00:00
|
|
|
{
|
|
|
|
wxMenuItem* item = aMenu->FindItemByPosition( i );
|
|
|
|
items.push_back( appendCopy( item ) );
|
|
|
|
}
|
2015-04-02 14:09:48 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-30 08:46:04 +00:00
|
|
|
if( aMenu->m_icon )
|
|
|
|
{
|
|
|
|
wxMenuItem* newItem = new wxMenuItem( this, -1, aLabel, wxEmptyString, wxITEM_NORMAL );
|
|
|
|
newItem->SetBitmap( KiBitmap( aMenu->m_icon ) );
|
2015-07-24 07:42:46 +00:00
|
|
|
newItem->SetSubMenu( menuCopy );
|
2015-04-30 08:46:04 +00:00
|
|
|
items.push_back( Append( newItem ) );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-07-24 07:42:46 +00:00
|
|
|
items.push_back( AppendSubMenu( menuCopy, aLabel ) );
|
2015-04-30 08:46:04 +00:00
|
|
|
}
|
2015-04-02 14:09:48 +00:00
|
|
|
}
|
2015-04-30 08:46:04 +00:00
|
|
|
|
|
|
|
return items;
|
2015-04-02 14:09:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-08-02 14:46:53 +00:00
|
|
|
void CONTEXT_MENU::Clear()
|
|
|
|
{
|
2013-10-14 11:43:57 +00:00
|
|
|
m_titleSet = false;
|
2013-09-26 12:09:18 +00:00
|
|
|
|
2015-04-30 08:46:07 +00:00
|
|
|
for( int i = GetMenuItemCount() - 1; i >= 0; --i )
|
|
|
|
Destroy( FindItemByPosition( i ) );
|
|
|
|
|
2013-10-14 11:43:57 +00:00
|
|
|
m_toolActions.clear();
|
2015-04-30 08:46:05 +00:00
|
|
|
m_submenus.clear();
|
|
|
|
m_parent = NULL;
|
2014-07-09 13:10:32 +00:00
|
|
|
|
|
|
|
assert( GetMenuItemCount() == 0 );
|
2013-09-26 12:09:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-30 08:46:05 +00:00
|
|
|
void CONTEXT_MENU::UpdateAll()
|
|
|
|
{
|
2015-07-30 11:49:35 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
m_update_handler();
|
|
|
|
}
|
|
|
|
catch( std::exception& e )
|
|
|
|
{
|
|
|
|
std::cerr << "CONTEXT_MENU error running update handler: " << e.what() << std::endl;
|
|
|
|
}
|
|
|
|
|
2015-07-30 11:49:35 +00:00
|
|
|
if( m_tool )
|
|
|
|
updateHotKeys();
|
2015-04-30 08:46:05 +00:00
|
|
|
|
|
|
|
runOnSubmenus( boost::bind( &CONTEXT_MENU::UpdateAll, _1 ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-08-03 09:53:58 +00:00
|
|
|
void CONTEXT_MENU::SetTool( TOOL_INTERACTIVE* aTool )
|
|
|
|
{
|
|
|
|
m_tool = aTool;
|
|
|
|
|
|
|
|
runOnSubmenus( boost::bind( &CONTEXT_MENU::SetTool, _1, aTool ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-06-19 15:32:33 +00:00
|
|
|
TOOL_MANAGER* CONTEXT_MENU::getToolManager()
|
|
|
|
{
|
|
|
|
assert( m_tool );
|
|
|
|
return m_tool->GetManager();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-05-05 18:39:42 +00:00
|
|
|
void CONTEXT_MENU::updateHotKeys()
|
|
|
|
{
|
2015-07-28 08:29:00 +00:00
|
|
|
TOOL_MANAGER* toolMgr = getToolManager();
|
|
|
|
|
2015-05-05 18:39:42 +00:00
|
|
|
for( std::map<int, const TOOL_ACTION*>::const_iterator it = m_toolActions.begin();
|
|
|
|
it != m_toolActions.end(); ++it )
|
|
|
|
{
|
|
|
|
int id = it->first;
|
|
|
|
const TOOL_ACTION& action = *it->second;
|
2015-07-28 08:29:00 +00:00
|
|
|
int key = toolMgr->GetHotKey( action ) & ~MD_MODIFIER_MASK;
|
2015-05-05 18:39:42 +00:00
|
|
|
|
2015-07-28 08:29:00 +00:00
|
|
|
if( key )
|
2015-05-05 18:39:42 +00:00
|
|
|
{
|
2015-07-28 08:29:00 +00:00
|
|
|
int mod = toolMgr->GetHotKey( action ) & MD_MODIFIER_MASK;
|
2015-07-07 16:37:00 +00:00
|
|
|
int flags = 0;
|
2015-05-05 18:39:42 +00:00
|
|
|
wxMenuItem* item = FindChildItem( id );
|
|
|
|
|
|
|
|
if( item )
|
|
|
|
{
|
2015-07-07 16:37:00 +00:00
|
|
|
flags |= ( mod & MD_ALT ) ? wxACCEL_ALT : 0;
|
|
|
|
flags |= ( mod & MD_CTRL ) ? wxACCEL_CTRL : 0;
|
|
|
|
flags |= ( mod & MD_SHIFT ) ? wxACCEL_SHIFT : 0;
|
|
|
|
|
|
|
|
if( !flags )
|
|
|
|
flags = wxACCEL_NORMAL;
|
2015-05-05 18:39:42 +00:00
|
|
|
|
|
|
|
wxAcceleratorEntry accel( flags, key, id, item );
|
|
|
|
item->SetAccel( &accel );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-25 18:11:02 +00:00
|
|
|
void CONTEXT_MENU::onMenuEvent( wxMenuEvent& aEvent )
|
2013-09-26 12:09:18 +00:00
|
|
|
{
|
2014-05-13 09:22:51 +00:00
|
|
|
OPT_TOOL_EVENT evt;
|
|
|
|
|
2013-09-26 12:09:18 +00:00
|
|
|
wxEventType type = aEvent.GetEventType();
|
|
|
|
|
2013-09-27 16:51:21 +00:00
|
|
|
// When the currently chosen item in the menu is changed, an update event is issued.
|
|
|
|
// For example, the selection tool can use this to dynamically highlight the current item
|
|
|
|
// from selection clarification popup.
|
2013-09-26 12:09:18 +00:00
|
|
|
if( type == wxEVT_MENU_HIGHLIGHT )
|
2013-10-14 18:40:36 +00:00
|
|
|
evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_UPDATE, aEvent.GetId() );
|
2013-09-27 14:23:43 +00:00
|
|
|
|
2013-09-27 16:51:21 +00:00
|
|
|
// One of menu entries was selected..
|
2013-09-26 12:09:18 +00:00
|
|
|
else if( type == wxEVT_COMMAND_MENU_SELECTED )
|
2013-09-26 16:38:58 +00:00
|
|
|
{
|
2013-11-29 15:45:39 +00:00
|
|
|
// Store the selected position
|
2014-05-13 09:22:51 +00:00
|
|
|
m_selected = aEvent.GetId();
|
2013-11-29 15:45:39 +00:00
|
|
|
|
2013-09-27 16:51:21 +00:00
|
|
|
// Check if there is a TOOL_ACTION for the given ID
|
2014-05-13 09:22:51 +00:00
|
|
|
if( m_toolActions.count( aEvent.GetId() ) == 1 )
|
2013-09-26 16:38:58 +00:00
|
|
|
{
|
2014-05-13 09:22:51 +00:00
|
|
|
evt = m_toolActions[aEvent.GetId()]->MakeEvent();
|
2013-09-26 16:38:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-04-30 08:46:05 +00:00
|
|
|
runEventHandlers( aEvent, evt );
|
|
|
|
|
|
|
|
// Under Linux, every submenu can have a separate event handler, under
|
|
|
|
// Windows all submenus are handled by the main menu.
|
2015-01-25 18:11:02 +00:00
|
|
|
#ifdef __WINDOWS__
|
2015-02-11 10:10:53 +00:00
|
|
|
if( !evt )
|
|
|
|
{
|
2015-01-25 18:11:02 +00:00
|
|
|
// Try to find the submenu which holds the selected item
|
2015-02-10 23:23:45 +00:00
|
|
|
wxMenu* menu = NULL;
|
2015-01-25 18:11:02 +00:00
|
|
|
FindItem( m_selected, &menu );
|
|
|
|
|
2015-02-10 23:23:45 +00:00
|
|
|
if( menu && menu != this )
|
2015-01-25 18:11:02 +00:00
|
|
|
{
|
|
|
|
menu->ProcessEvent( aEvent );
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
2015-02-10 23:23:45 +00:00
|
|
|
#endif
|
2014-05-13 09:22:51 +00:00
|
|
|
|
2014-05-13 09:22:51 +00:00
|
|
|
// Handling non-action menu entries (e.g. items in clarification list)
|
|
|
|
if( !evt )
|
2014-05-13 09:22:51 +00:00
|
|
|
evt = TOOL_EVENT( TC_COMMAND, TA_CONTEXT_MENU_CHOICE, aEvent.GetId() );
|
2013-09-26 16:38:58 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-26 12:09:18 +00:00
|
|
|
|
2014-05-14 14:29:53 +00:00
|
|
|
assert( m_tool ); // without tool & tool manager we cannot handle events
|
|
|
|
|
2013-09-27 16:51:21 +00:00
|
|
|
// forward the action/update event to the TOOL_MANAGER
|
2014-05-14 14:29:53 +00:00
|
|
|
if( evt && m_tool )
|
|
|
|
m_tool->GetManager()->ProcessEvent( *evt );
|
2014-05-13 09:22:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-30 08:46:05 +00:00
|
|
|
void CONTEXT_MENU::runEventHandlers( const wxMenuEvent& aMenuEvent, OPT_TOOL_EVENT& aToolEvent )
|
|
|
|
{
|
|
|
|
aToolEvent = m_menu_handler( aMenuEvent );
|
|
|
|
|
|
|
|
if( !aToolEvent )
|
|
|
|
runOnSubmenus( boost::bind( &CONTEXT_MENU::runEventHandlers, _1, aMenuEvent, aToolEvent ) );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CONTEXT_MENU::runOnSubmenus( boost::function<void(CONTEXT_MENU*)> aFunction )
|
|
|
|
{
|
2015-08-15 14:00:33 +00:00
|
|
|
try
|
|
|
|
{
|
|
|
|
std::for_each( m_submenus.begin(), m_submenus.end(), aFunction );
|
|
|
|
}
|
|
|
|
catch( std::exception& e )
|
|
|
|
{
|
|
|
|
std::cerr << "CONTEXT_MENU runOnSubmenus error: " << e.what() << std::endl;
|
|
|
|
}
|
2014-05-31 14:04:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-04-30 08:46:04 +00:00
|
|
|
wxMenuItem* CONTEXT_MENU::appendCopy( const wxMenuItem* aSource )
|
2014-05-13 09:22:51 +00:00
|
|
|
{
|
2015-04-30 08:46:04 +00:00
|
|
|
wxMenuItem* newItem = new wxMenuItem( this, aSource->GetId(), aSource->GetItemLabel(),
|
|
|
|
aSource->GetHelp(), aSource->GetKind() );
|
|
|
|
|
|
|
|
if( aSource->GetKind() == wxITEM_NORMAL )
|
|
|
|
newItem->SetBitmap( aSource->GetBitmap() );
|
|
|
|
|
|
|
|
if( aSource->IsSubMenu() )
|
|
|
|
{
|
|
|
|
#ifdef DEBUG
|
|
|
|
// Submenus of a CONTEXT_MENU are supposed to be CONTEXT_MENUs as well
|
|
|
|
assert( dynamic_cast<CONTEXT_MENU*>( aSource->GetSubMenu() ) );
|
|
|
|
#endif
|
|
|
|
|
|
|
|
CONTEXT_MENU* menu = new CONTEXT_MENU( static_cast<const CONTEXT_MENU&>( *aSource->GetSubMenu() ) );
|
|
|
|
newItem->SetSubMenu( menu );
|
|
|
|
Append( newItem );
|
|
|
|
|
2015-04-30 08:46:05 +00:00
|
|
|
m_submenus.push_back( menu );
|
|
|
|
menu->m_parent = this;
|
2015-04-30 08:46:04 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Append( newItem );
|
|
|
|
newItem->SetKind( aSource->GetKind() );
|
|
|
|
newItem->SetHelp( aSource->GetHelp() );
|
|
|
|
newItem->Enable( aSource->IsEnabled() );
|
2014-05-13 09:22:51 +00:00
|
|
|
|
2015-04-30 08:46:04 +00:00
|
|
|
if( aSource->IsCheckable() )
|
|
|
|
newItem->Check( aSource->IsChecked() );
|
|
|
|
}
|
2014-05-13 09:22:51 +00:00
|
|
|
|
2015-04-30 08:46:04 +00:00
|
|
|
return newItem;
|
2015-04-02 14:09:48 +00:00
|
|
|
}
|
2014-05-13 09:22:51 +00:00
|
|
|
|
2015-04-02 14:09:48 +00:00
|
|
|
|
|
|
|
void CONTEXT_MENU::copyFrom( const CONTEXT_MENU& aMenu )
|
|
|
|
{
|
|
|
|
m_icon = aMenu.m_icon;
|
2015-04-30 08:46:04 +00:00
|
|
|
m_titleSet = aMenu.m_titleSet;
|
|
|
|
m_selected = -1; // aMenu.m_selected;
|
|
|
|
m_tool = aMenu.m_tool;
|
|
|
|
m_toolActions = aMenu.m_toolActions;
|
2015-04-30 08:46:05 +00:00
|
|
|
m_parent = NULL; // aMenu.m_parent;
|
|
|
|
m_menu_handler = aMenu.m_menu_handler;
|
|
|
|
m_update_handler = aMenu.m_update_handler;
|
2015-04-02 14:09:48 +00:00
|
|
|
|
|
|
|
// Copy all the menu entries
|
2015-04-30 08:46:07 +00:00
|
|
|
for( int i = 0; i < (int) aMenu.GetMenuItemCount(); ++i )
|
2015-04-02 14:09:48 +00:00
|
|
|
{
|
|
|
|
wxMenuItem* item = aMenu.FindItemByPosition( i );
|
2015-04-30 08:46:04 +00:00
|
|
|
appendCopy( item );
|
2015-04-02 14:09:48 +00:00
|
|
|
}
|
2013-08-07 09:20:12 +00:00
|
|
|
}
|
2015-04-30 08:46:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
OPT_TOOL_EVENT CONTEXT_MENU::menuHandlerStub( const wxMenuEvent& )
|
|
|
|
{
|
2015-07-30 11:49:35 +00:00
|
|
|
return boost::none;
|
2015-04-30 08:46:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void CONTEXT_MENU::updateHandlerStub()
|
|
|
|
{
|
|
|
|
}
|