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->AddButton( ( *it ), ( *it1 )->first->first,
62 ( *it1 )->first->second, ( *it1 )->second->first, functor );
68 ButtonContainerSettings::SetButtonGroupContainer(
69 ButtonGroupMap m_ButtonGroupContainer )
71 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
75 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
77 this->m_GroupNameList = m_GroupNameList;
81 ButtonContainerSettings::AddButton( const std::string & groupName,
82 const std::string &buttonName, const std::string &iconpath,
83 const std::string &buttonDescription, PanelButton panel )
85 //builds the button information
87 ButtonPair* pair = new ButtonPair( new ButtonInfo( buttonName, iconpath ),
88 new ActionButton( buttonDescription, panel ) );
89 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
90 != this->m_GroupNameList.end( ); ++it )
92 if ( ( *it ).compare( groupName ) == 0 )
94 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
98 this->m_GroupNameList.push_back( groupName );
99 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
103 ButtonContainerSettings::AddButton( BCSettingsStruct* info )
105 //builds the button information
106 info->panel->Show( false );
107 ButtonPair* pair = new ButtonPair(
108 new ButtonInfo( info->buttonName, info->iconpath ),
109 new ActionButton( info->buttonDescription, info->panel ) );
110 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
111 != this->m_GroupNameList.end( ); ++it )
113 if ( ( *it ).compare( info->groupName ) == 0 )
115 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
119 this->m_GroupNameList.push_back( info->groupName );
120 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
124 ButtonContainerSettings::AddButtons( BCStructVectorType infoList )
126 for( BCStructVectorType::iterator it = infoList.begin( ); it
127 != infoList.end( ); ++it )
129 this->AddButton( *it );