fw4spl
fwGui::registrar::MenuRegistrar Class Reference

Defines the menu registrar for IHM. More...

#include <MenuRegistrar.hpp>

+ Inheritance diagram for fwGui::registrar::MenuRegistrar:
+ Collaboration diagram for fwGui::registrar::MenuRegistrar:

Public Types

typedef std::vector< ::fwGui::IMenuItemCallback::sptr > CallbacksType
 
- Public Types inherited from fwGui::GuiBaseObject
typedef ::fwGui::factory::Key Key
 

Public Member Functions

virtual bool isA (const std::string &type) const override
 
FWGUI_API MenuRegistrar (const std::string &sid)
 Constructor.
 
virtual FWGUI_API ~MenuRegistrar ()
 Destructor. Do nothing.
 
virtual FWGUI_API::fwGui::container::fwMenu::sptr getParent ()
 Return the parent container.
 
virtual FWGUI_API::fwGui::container::fwMenuItem::sptr getFwMenuItem (std::string actionSid, std::vector< ::fwGui::container::fwMenuItem::sptr > menuItems)
 Return the fwMenuItem associated with the actionSid. More...
 
virtual FWGUI_API void initialize (::fwRuntime::ConfigurationElement::sptr configuration)
 Initialize registry managers. More...
 
virtual FWGUI_API void manage (std::vector< ::fwGui::container::fwMenuItem::sptr > menuItems)
 manages action service associated with menuItem of menu. More...
 
virtual FWGUI_API void manage (std::vector< ::fwGui::container::fwMenu::sptr > menus)
 manages menu service associated with fwMenu of menu. More...
 
virtual FWGUI_API void unmanage ()
 Stopping menu items manager. All services managed in local menu items will be stopped.
 
virtual FWGUI_API void onItemAction ()
 This method is called when an action is clicked.
 
virtual CallbacksType getCallbacks ()
 Returns callbacks associate with menu items.
 
- Public Member Functions inherited from fwGui::GuiBaseObject
- Public Member Functions inherited from fwCore::BaseObject

Static Public Member Functions

static bool isTypeOf (const std::string &type)
 
- Static Public Member Functions inherited from fwGui::GuiBaseObject
static bool isTypeOf (const std::string &type)
 
static const std::string & classname ()
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 
- Static Public Member Functions inherited from fwCore::BaseObject
static bool isTypeOf (const std::string &type)
 
static const std::string & leafClassname ()
 return object's classname without its namespace, i.e. BaseObject
 
static const std::string & classname ()
 return object's classname without its namespace, i.e. BaseObject
 

Protected Types

typedef ::fwRuntime::ConfigurationElement::sptr ConfigurationType
 
typedef std::map< std::string, std::pair< unsigned int, bool > > SIDMenuMapType
 

Protected Attributes

SIDMenuMapType m_actionSids
 All menu services ID (sid) managed is associated with pair containing: an action's position in the menu and boolean describing if is started by the manager.
 
SIDMenuMapType m_menuSids
 All toolBar services ID managed and associated with pair containing: menu's index vector and boolean describing if is started by the manager.
 
std::string m_sid
 Main service ID associate with this MenuRegistrar.
 
CallbacksType m_callbacks
 Callback associate with menu items.
 

Friends

template<class , class , class >
class ::fwTools::ClassFactory
 
class ::fwTools::Factory
 

Demangling methods

virtual const std::string & getLeafClassname () const override
 return object's classname without its namespace, i.e. BaseObject
 
virtual const std::string & getClassname () const override
 return full object's classname with its namespace, i.e. fwCore::BaseObject
 
static const std::string & leafClassname ()
 return object's classname without its namespace, i.e. BaseObject
 
static const std::string & classname ()
 return object's classname without its namespace, i.e. BaseObject
 

Additional Inherited Members

- Protected Member Functions inherited from fwGui::GuiBaseObject
 GuiBaseObject ()
 
virtual ~GuiBaseObject ()
 

Detailed Description

Defines the menu registrar for IHM.

Date
2009-2010.

Definition at line 31 of file MenuRegistrar.hpp.

Member Function Documentation

fwGui::container::fwMenuItem::sptr fwGui::registrar::MenuRegistrar::getFwMenuItem ( std::string  actionSid,
std::vector< ::fwGui::container::fwMenuItem::sptr >  menuItems 
)
virtual

Return the fwMenuItem associated with the actionSid.

Parameters
actionSidsid of the action service
menuItemsvector containing the fwMenuItem manages by this registrar.

Definition at line 46 of file MenuRegistrar.cpp.

References m_actionSids, and SLM_ASSERT.

void fwGui::registrar::MenuRegistrar::initialize ( ::fwRuntime::ConfigurationElement::sptr  configuration)
virtual

Initialize registry managers.

Example of configuration

1 <service uid="myMenu" type="::fwGui::IMenuSrv" impl="::gui::aspect::SDefaultMenu" autoConnect="no" >
2  <gui>
3  <layout>
4  <menuItem name="My item 1" shortcut="1" style="check" />
5  <separator />
6  <menuItem name="My item 2" shortcut="2" style="radio" />
7  <menuItem name="My item 3" shortcut="3" style="radio" />
8  <separator />
9  <menu name="My menu" />
10  <separator />
11  <menuItem name="Quit" shortcut="Ctrl+Q" specialAction="QUIT" />
12  </layout>
13  </gui>
14  <registry>
15  <menuItem sid="item1" start="yes" />
16  <menuItem sid="item2" start="no" />
17  <menuItem sid="item3" start="no" />
18  <menu sid="mymenu" start="yes" />
19  <menuItem sid="actionQuit" start="no" />
20  </registry>
21 </service>

This method analyzes the registry section of the configuration.

  • <menuItem sid="item1" start="no" /> : define the service of the menuItem to add in the menu.
    • sid (mandatory): the service identifier.
    • start = {yes| no} (default value no): indicate if the service must be started by the menu service.

Definition at line 56 of file MenuRegistrar.cpp.

References m_actionSids, m_callbacks, m_menuSids, OSLM_ASSERT, and SLM_ASSERT.

void fwGui::registrar::MenuRegistrar::manage ( std::vector< ::fwGui::container::fwMenuItem::sptr >  menuItems)
virtual

manages action service associated with menuItem of menu.

Register the menuItem containers for the associated services. Start the services if start=yes.

If a menuItem has attribut start="no", the associated action won't be started and the menuItem will be disabled. If a menuItem has attribut start="yes", two possibilities:

  • the associated action has attribut executable="false" then the menuItem will be disabled.
  • the associated action has attribut executable="true" then the menuItem will be enabled.
    If an action manages by menuItems in a toolbar and/or in the menuBar has its attribut executable="false", the associated menuItems will be disabled in toolbar and in menuBar.
Warning
If the action is present in different toolbars and menus it must be started only one time.
Precondition
MenuRegistrar must be initialized before.
sub menu items must be instanced before.

Definition at line 123 of file MenuRegistrar.cpp.

References fwGui::GuiRegistry::actionServiceStarting(), fwGui::GuiRegistry::actionServiceStopping(), fwTools::fwID::exist(), fwServices::get(), m_actionSids, m_sid, OSLM_ASSERT, and fwGui::GuiRegistry::registerActionSIDToParentSID().

+ Here is the call graph for this function:

void fwGui::registrar::MenuRegistrar::manage ( std::vector< ::fwGui::container::fwMenu::sptr >  menus)
virtual

manages menu service associated with fwMenu of menu.

If a menuItem has attribut start="no", the associated menu won't be started. If a menuItem has attribut start="yes", the associated menu will be started

Precondition
MenuRegistrar must be initialized before.
sub menu items must be instanced before.

Definition at line 156 of file MenuRegistrar.cpp.

References fwTools::fwID::exist(), m_menuSids, OSLM_ASSERT, and fwGui::GuiRegistry::registerSIDMenu().

+ Here is the call graph for this function:


The documentation for this class was generated from the following files: