1 /***************************************************************
2 * Name: buttonContainerSettings.cxx
3 * Purpose: It is the ButtonGroupSettings
4 * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
6 * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/)
8 **************************************************************/
9 #include "buttonContainerSettings.h"
12 namespace creaPanelButtonContainer
15 ButtonContainerSettings::ButtonContainerSettings( )
18 ButtonContainerSettings::~ButtonContainerSettings( )
22 ButtonContainerSettings::GetButtonGroupContainer( )
24 return m_ButtonGroupContainer;
28 ButtonContainerSettings::GetGroupNameList( )
30 return m_GroupNameList;
33 //GetButtonPanel returns the panel asociated to de buttonAction
35 ButtonContainerSettings::GetPanelButton( const std::string &buttonName )
37 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
38 != this->m_GroupNameList.end( ); ++it )
40 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
41 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
43 if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
45 return ( ( *it1 )->second->second );
52 ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
54 ButtonGroupSettings* settings = new ButtonGroupSettings( );
55 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
56 != this->m_GroupNameList.end( ); ++it )
58 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
59 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
61 settings->CreateGroup( *it );
62 settings->AddButton( ( *it ), ( *it1 )->first->first,
63 ( *it1 )->first->second, ( *it1 )->second->first, functor );
69 ButtonContainerSettings::SetButtonGroupContainer(
70 ButtonGroupMap m_ButtonGroupContainer )
72 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
76 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
78 this->m_GroupNameList = m_GroupNameList;
82 ButtonContainerSettings::AddButton( const std::string & groupName,
83 const std::string buttonName, const std::string iconpath,
84 const std::string buttonDescription, PanelButton panel )
86 //builds the button information
87 ButtonPair* pair = new ButtonPair( new ButtonInfo( buttonName, iconpath ),
88 new ActionButton( buttonDescription, panel ) );
90 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
91 != this->m_GroupNameList.end( ); ++it )
93 if ( ( *it ).compare( groupName ) == 0 )
95 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
99 //if the group doesn't exist it creates a new groupName
100 this->m_GroupNameList.push_back( groupName );
101 this->m_ButtonGroupContainer[ groupName ].push_back( pair );