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 )
64 ButtonGroupSettings* settings = NULL;
67 settings = new ButtonGroupSettings( );
68 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
69 != this->m_GroupNameList.end( ); ++it )
71 ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
72 for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
74 settings->AddButton( ( *it ), ( *it1 )->first->first,
75 ( *it1 )->first->second, ( *it1 )->second->first, functor );
79 catch ( std::exception& e )
82 << "ButtonContainerSettings::GetPanelButton( const StringType &buttonName ) "
83 << "exception: " << e.what( ) << std::endl;
87 // ----------------------------------------------------------------------------------
89 ButtonContainerSettings::SetButtonGroupContainer(
90 ButtonGroupMap m_ButtonGroupContainer )
92 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
94 // ----------------------------------------------------------------------------------
96 ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
98 this->m_GroupNameList = m_GroupNameList;
100 // ----------------------------------------------------------------------------------
102 ButtonContainerSettings::AddButton( const StringType & groupName,
103 const StringType &buttonName, const StringType &iconpath,
104 const StringType &buttonDescription, PanelButton panel )
108 //builds the button information
109 //I don't know the try catch doesn't work!!
112 std::cerr << "ButtonContainerSettings::AddButton"
113 << "exception: NULL Pointer in panel " << std::endl;
116 panel->Show( false );
117 ButtonPair* pair = new ButtonPair(
118 new ButtonInfo( buttonName, iconpath ),
119 new ActionButton( buttonDescription, panel ) );
120 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
121 != this->m_GroupNameList.end( ); ++it )
123 if ( ( *it ).compare( groupName ) == 0 )
125 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
129 this->m_GroupNameList.push_back( groupName );
130 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
132 catch ( const std::exception& e )
135 << "ButtonContainerSettings::AddButton( const StringType & groupName,"
136 << "const StringType &buttonName, const StringType &iconpath,"
137 << "const StringType &buttonDescription, PanelButton panel ) "
138 << "exception: " << e.what( ) << std::endl;
141 // ----------------------------------------------------------------------------------
143 ButtonContainerSettings::AddButton( BCPSettingsStruct* info )
147 //builds the button information
148 //I don't know the try catch doesn't work!!
149 if ( info->panel == NULL )
151 std::cerr << "ButtonContainerSettings::AddButton"
152 << "exception: NULL Pointer in panel " << std::endl;
155 info->panel->Show( false );
156 ButtonPair* pair = new ButtonPair(
157 new ButtonInfo( info->buttonName, info->iconpath ),
158 new ActionButton( info->buttonDescription, info->panel ) );
159 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
160 != this->m_GroupNameList.end( ); ++it )
162 if ( ( *it ).compare( info->groupName ) == 0 )
164 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
168 this->m_GroupNameList.push_back( info->groupName );
169 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
171 catch ( const std::exception& e )
174 << "ButtonContainerSettings::AddButton( BCPSettingsStruct* info )"
175 << "exception: " << e.what( ) << std::endl;
179 // ----------------------------------------------------------------------------------
181 ButtonContainerSettings::AddButtons( BCStructVectorType infoList )
185 for( BCStructVectorType::iterator it = infoList.begin( ); it
186 != infoList.end( ); ++it )
188 this->AddButton( *it );
191 catch ( std::exception& e )
194 << "ButtonContainerSettings::AddButtons( BCStructVectorType infoList )"
195 << "exception: " << e.what( ) << std::endl;
198 // ----------------------------------------------------------------------------------