diff --git a/common/tool/conditional_menu.cpp b/common/tool/conditional_menu.cpp index ac67972d55..28347bb41e 100644 --- a/common/tool/conditional_menu.cpp +++ b/common/tool/conditional_menu.cpp @@ -29,15 +29,15 @@ #include -CONDITIONAL_MENU::CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ) : - ACTION_MENU( isContextMenu, aTool ) +CONDITIONAL_MENU::CONDITIONAL_MENU( TOOL_INTERACTIVE* aTool ) : + ACTION_MENU( true, aTool ) { } ACTION_MENU* CONDITIONAL_MENU::create() const { - CONDITIONAL_MENU* clone = new CONDITIONAL_MENU( m_isContextMenu, m_tool ); + CONDITIONAL_MENU* clone = new CONDITIONAL_MENU( m_tool ); clone->m_entries = m_entries; return clone; } @@ -137,7 +137,7 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection ) continue; } - if( m_isContextMenu && !result ) + if( !result ) continue; switch( entry.Type() ) @@ -153,15 +153,6 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection ) break; case ENTRY::WXITEM: -#ifdef __WXMAC__ - // Instantiate the Preferences item only on the first Resolve(); after that - // wxWidgets will have moved it to the Application menu - if( entry.wxItem()->GetId() == wxID_PREFERENCES ) - { - if( &aSelection != &g_resolveDummySelection ) - continue; - } -#endif menuItem = new wxMenuItem( this, entry.wxItem()->GetId(), entry.wxItem()->GetItemLabel(), @@ -188,14 +179,6 @@ void CONDITIONAL_MENU::Evaluate( SELECTION& aSelection ) wxASSERT( false ); break; } - - if( menuItem ) - { - if( entry.IsCheckmarkEntry() ) - menuItem->Check( result ); - else - menuItem->Enable( result ); - } } // Recursively call Evaluate on all the submenus that are CONDITIONAL_MENUs to ensure diff --git a/common/tool/tool_menu.cpp b/common/tool/tool_menu.cpp index 487b0d56f7..651dca319d 100644 --- a/common/tool/tool_menu.cpp +++ b/common/tool/tool_menu.cpp @@ -32,7 +32,7 @@ TOOL_MENU::TOOL_MENU( TOOL_INTERACTIVE& aTool ) : - m_menu( true, &aTool ), + m_menu( &aTool ), m_tool( aTool ) { } diff --git a/include/tool/conditional_menu.h b/include/tool/conditional_menu.h index 340bf8ca25..1b2ec86d7c 100644 --- a/include/tool/conditional_menu.h +++ b/include/tool/conditional_menu.h @@ -41,16 +41,15 @@ public: ///> Constant to indicate that we do not care about an ENTRY location in the menu. static const int ANY_ORDER = -1; - CONDITIONAL_MENU( bool isContextMenu, TOOL_INTERACTIVE* aTool ); + CONDITIONAL_MENU( TOOL_INTERACTIVE* aTool ); ACTION_MENU* create() const override; /** - * Function AddItem() - * * Adds a menu entry to run a TOOL_ACTION on selected items. + * * @param aAction is a menu entry to be added. - * @param aCondition is a condition that has to be fulfilled to enable the menu entry. + * @param aCondition is a condition that has to be fulfilled to show the menu entry in the menu. * @param aOrder determines location of the added item, higher numbers are put on the bottom. * You may use ANY_ORDER here if you think it does not matter. */ @@ -61,11 +60,13 @@ public: const SELECTION_CONDITION& aCondition, int aOrder = ANY_ORDER ); /** - * Function AddCheckItem() - * * Adds a checked menu entry to run a TOOL_ACTION on selected items. + * + * The condition for checking the menu entry should be supplied through a ACTION_CONDITION + * registered with the ACTION_MANAGER. + * * @param aAction is a menu entry to be added. - * @param aCondition is a condition that has to be fulfilled to check the menu entry. + * @param aCondition is a condition that has to be fulfilled to show the menu entry in the menu. * @param aOrder determines location of the added item, higher numbers are put on the bottom. * You may use ANY_ORDER here if you think it does not matter. */ @@ -76,14 +77,13 @@ public: const SELECTION_CONDITION& aCondition, int aOrder = ANY_ORDER ); /** - * Function AddMenu() - * * Adds a submenu to the menu. CONDITIONAL_MENU takes ownership of the added menu, so it will * be freed when the CONDITIONAL_MENU object is destroyed. + * * @param aMenu is the submenu to be added. * @param aExpand determines if the added submenu items should be added as individual items * or as a submenu. - * @param aCondition is a condition that has to be fulfilled to enable the submenu entry. + * @param aCondition is a condition that has to be fulfilled to show the submenu entry in the menu. * @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. */ @@ -92,23 +92,18 @@ public: int aOrder = ANY_ORDER ); /** - * Function AddSeparator() - * * Adds a separator to the menu. + * * @param aOrder determines location of the separator, higher numbers are put on the bottom. */ void AddSeparator( int aOrder = ANY_ORDER ); /** - * Function Evaluate() - * * Updates the contents of the menu based on the supplied conditions. */ void Evaluate( SELECTION& aSelection ); /** - * Function Resolve() - * * Updates the initial contents so that wxWidgets doesn't get its knickers tied in a knot * over the menu being empty (mainly an issue on GTK, but also on OSX with the preferences * and quit menu items).