2 * @file buttonContainerSettings.cxx
3 * @brief Implements the ButtonContainerSettings class.
4 * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
8 #include "buttonContainerSettings.h"
10 namespace creaPanelButtonContainer
12 // ----------------------------------------------------------------------------------
13 ButtonContainerSettings::ButtonContainerSettings( )
16 // ----------------------------------------------------------------------------------
17 ButtonContainerSettings::~ButtonContainerSettings( )
20 // ----------------------------------------------------------------------------------
21 ButtonContainerSettings::ButtonGroupMap
22 ButtonContainerSettings::GetButtonGroupContainer( )
24 return m_ButtonGroupContainer;
26 // ----------------------------------------------------------------------------------
27 ButtonContainerSettings::KeyMapList
28 ButtonContainerSettings::GetGroupNameList( )
30 return m_GroupNameList;
32 // ----------------------------------------------------------------------------------
33 //GetButtonPanel returns the panel associated to the buttonAction
34 ButtonContainerSettings::PanelButton
35 ButtonContainerSettings::GetPanelButton( const StringType &buttonName )
39 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
40 != this->m_GroupNameList.end( ); ++it )
42 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
43 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
45 if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
47 return ( ( *it1 )->second->second );
52 catch ( std::exception& e )
55 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
56 << "exception: " << e.what( ) << std::endl;
60 // ----------------------------------------------------------------------------------
61 ButtonContainerSettings::ButtonGroupSettings*
62 ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
66 ButtonGroupSettings* settings = new ButtonGroupSettings( );
67 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
68 != this->m_GroupNameList.end( ); ++it )
70 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
71 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
73 settings->AddButton( ( *it ), ( *it1 )->first->first,
74 ( *it1 )->first->second, ( *it1 )->second->first, functor );
79 catch ( std::exception& e )
82 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
83 << "exception: " << e.what( ) << std::endl;
86 // ----------------------------------------------------------------------------------
88 ButtonContainerSettings::SetButtonGroupContainer(
89 ButtonGroupMap m_ButtonGroupContainer )
91 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
93 // ----------------------------------------------------------------------------------
95 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
97 this->m_GroupNameList = m_GroupNameList;
99 // ----------------------------------------------------------------------------------
101 ButtonContainerSettings::AddButton( const StringType & groupName,
102 const StringType &buttonName, const StringType &iconpath,
103 const StringType &buttonDescription, PanelButton panel )
107 //builds the button information
108 //I don't know the try catch doesn't work!!
111 std::cerr << "ButtonContainerSettings::AddButton"
112 << "exception: NULL Pointer in panel " << std::endl;
115 panel->Show( false );
116 ButtonPair* pair = new ButtonPair(
117 new ButtonInfo( buttonName, iconpath ),
118 new ActionButton( buttonDescription, panel ) );
119 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
120 != this->m_GroupNameList.end( ); ++it )
122 if ( ( *it ).compare( groupName ) == 0 )
124 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
128 this->m_GroupNameList.push_back( groupName );
129 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
131 catch ( const std::exception& e )
134 << "ButtonContainerSettings::AddButton( const StringType & groupName,"
135 << "const StringType &buttonName, const StringType &iconpath,"
136 << "const StringType &buttonDescription, PanelButton panel ) "
137 << "exception: " << e.what( ) << std::endl;
140 // ----------------------------------------------------------------------------------
142 ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
146 //builds the button information
147 //I don't know the try catch doesn't work!!
148 if ( info->panel == NULL )
150 std::cerr << "ButtonContainerSettings::AddButton"
151 << "exception: NULL Pointer in panel " << std::endl;
154 info->panel->Show( false );
155 ButtonPair* pair = new ButtonPair(
156 new ButtonInfo( info->buttonName, info->iconpath ),
157 new ActionButton( info->buttonDescription, info->panel ) );
158 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
159 != this->m_GroupNameList.end( ); ++it )
161 if ( ( *it ).compare( info->groupName ) == 0 )
163 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
167 this->m_GroupNameList.push_back( info->groupName );
168 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
170 catch ( const std::exception& e )
173 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
174 << "exception: " << e.what( ) << std::endl;
178 // ----------------------------------------------------------------------------------
180 ButtonContainerSettings::AddButtons( BCStructVectorType infoList )
184 for( BCStructVectorType::iterator it = infoList.begin( ); it
185 != infoList.end( ); ++it )
187 this->AddButton( *it );
190 catch ( std::exception& e )
193 << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
194 << "exception: " << e.what( ) << std::endl;
197 // ----------------------------------------------------------------------------------