+/***************************************************************
+ * Name: buttonContainerSettings.cxx
+ * Purpose: It is the ButtonGroupSettings
+ * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
+ * Modified: 2011-05-09
+ * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/)
+ * License:
+ **************************************************************/
+#include "buttonContainerSettings.h"
+#include <iostream>
+
+namespace creaPanelButtonContainer
+{
+
+ ButtonContainerSettings::ButtonContainerSettings( )
+ {
+ }
+ ButtonContainerSettings::~ButtonContainerSettings( )
+ {
+ }
+ ButtonGroupMap
+ ButtonContainerSettings::GetButtonGroupContainer( )
+ {
+ return m_ButtonGroupContainer;
+ }
+
+ KeyMapList
+ ButtonContainerSettings::GetGroupNameList( )
+ {
+ return m_GroupNameList;
+ }
+
+ //GetButtonPanel returns the panel asociated to de buttonAction
+ PanelButton
+ ButtonContainerSettings::GetPanelButton( const std::string &buttonName )
+ {
+ for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
+ != this->m_GroupNameList.end( ); ++it )
+ {
+ ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
+ for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
+ {
+ if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
+ {
+ return ( ( *it1 )->second->second );
+ }//fi
+ }//rof
+ }//rof
+ return ( NULL );
+ }
+ ButtonGroupSettings*
+ ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
+ {
+ ButtonGroupSettings* settings = new ButtonGroupSettings( );
+ for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
+ != this->m_GroupNameList.end( ); ++it )
+ {
+ ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
+ for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
+ {
+ settings->CreateGroup( *it );
+ settings->AddButton( ( *it ), ( *it1 )->first->first,
+ ( *it1 )->first->second, ( *it1 )->second->first, functor );
+ }//rof
+ }//rof
+ return ( settings );
+ }
+ void
+ ButtonContainerSettings::SetButtonGroupContainer(
+ ButtonGroupMap m_ButtonGroupContainer )
+ {
+ this->m_ButtonGroupContainer = m_ButtonGroupContainer;
+ }
+
+ void
+ ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
+ {
+ this->m_GroupNameList = m_GroupNameList;
+ }
+
+ void
+ ButtonContainerSettings::CreateGroup( const std::string & groupName )
+ {
+ this->m_GroupNameList.push_back( groupName );
+ }
+ void
+ ButtonContainerSettings::AddButton( const std::string & groupName,
+ const std::string buttonName, const std::string iconpath,
+ const std::string buttonDescription, PanelButton panel )
+ {
+ for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
+ != this->m_GroupNameList.end( ); ++it )
+ {
+ if ( ( *it ).compare( groupName ) == 0 )
+ {
+ panel->Show( false );
+ ButtonPair* pair = new ButtonPair(
+ new ButtonInfo( buttonName, iconpath ),
+ new ActionButton( buttonDescription, panel ) );
+ this->m_ButtonGroupContainer[ groupName ].push_back( pair );
+ return;
+ }//fi
+ }//rof
+ }
+}//ecapseman
+