]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/containerSettings.cxx
a4e18f90bf721e50f352799816b8ee3c2ff186f0
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / model / containerSettings.cxx
1 /*!
2  * @file containerSettings.cxx
3  * @brief Implements the ContainerSettings class.
4  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * @date  2011-05-24
6  */
7
8 #include "containerSettings.h"
9
10 namespace creaButtonContainer
11 {
12         namespace model
13         {
14                 // ----------------------------------------------------------------------------------
15                 ContainerSettings::ContainerSettings( )
16                 {
17                 }
18                 // ----------------------------------------------------------------------------------
19                 ContainerSettings::~ContainerSettings( )
20                 {
21                 }
22                 // ----------------------------------------------------------------------------------
23                 ButtonGroupMap
24                 ContainerSettings::GetButtonGroupContainer( )
25                 {
26                         return this->m_ButtonGroupContainer;
27                 }
28                 // ----------------------------------------------------------------------------------
29                 KeyMapList
30                 ContainerSettings::GetGroupNameList( )
31                 {
32                         return this->m_GroupNameList;
33                 }
34                 // ----------------------------------------------------------------------------------
35                 void
36                 ContainerSettings::SetButtonGroupContainer( ButtonGroupMap bgContainer )
37                 {
38                         this->m_ButtonGroupContainer = bgContainer;
39                 }
40                 // ----------------------------------------------------------------------------------
41                 void
42                 ContainerSettings::SetGroupNameList( KeyMapList gNameList )
43                 {
44                         this->m_GroupNameList = gNameList;
45                 }
46                 // ----------------------------------------------------------------------------------
47                 void
48                 ContainerSettings::AddButton( const std::string & groupName,
49                     const std::string buttonName, const std::string iconpath,
50                     const std::string buttonDescription, FunctionEventType event )
51                 {
52                         try
53                         {
54                                 ButtonPair* pair = new ButtonPair(
55                                     new ButtonInfo( buttonName, iconpath ),
56                                     new ButtonAction( buttonDescription, event ) );
57                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
58                                     != this->m_GroupNameList.end( ); ++it )
59                                 {
60                                         if ( ( *it ).compare( groupName ) == 0 )
61                                         {
62                                                 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
63                                                 return;
64                                         }//fi
65                                 }//rof
66                                 this->m_GroupNameList.push_back( groupName );
67                                 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
68                         }//yrt
69                         catch ( const std::exception& e )
70                         {
71                                 std::cerr
72                                     << "ContainerSettings::AddButton( const std::string & groupName,"
73                                     << "const std::string buttonName, const std::string iconpath,"
74                                     << "const std::string buttonDescription, FunctionEventType event ) exception: "
75                                     << e.what( ) << std::endl;
76                         }//hctac
77                 }
78                 // ----------------------------------------------------------------------------------
79                 void
80                 ContainerSettings::AddButton( BCSettingsStruct* info )
81                 {
82                         try
83                         {
84                                 ButtonPair* pair = new ButtonPair(
85                                     new ButtonInfo( info->buttonName, info->iconpath ),
86                                     new ButtonAction( info->buttonDescription, info->eventFunction ) );
87                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
88                                     != this->m_GroupNameList.end( ); ++it )
89                                 {
90                                         if ( ( *it ).compare( info->groupName ) == 0 )
91                                         {
92                                                 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
93                                                 return;
94                                         }//fi
95                                 }//rof
96                                 this->m_GroupNameList.push_back( info->groupName );
97                                 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
98                         }//yrt
99                         catch ( const std::exception& e )
100                         {
101                                 std::cerr
102                                     << "void ContainerSettings::AddButton( BCSettingsStruct* info ) "
103                                     << "exception: " << e.what( ) << std::endl;
104                         }//hctac
105                 }
106                 // ----------------------------------------------------------------------------------
107                 void
108                 ContainerSettings::AddButtons( BCStructVectorType infoList )
109                 {
110                         try
111                         {
112                                 for( BCStructVectorType::iterator it = infoList.begin( ); it
113                                     != infoList.end( ); ++it )
114                                 {
115                                         this->AddButton( *it );
116                                 }//rof
117                         }//yrt
118                         catch ( const std::exception& e )
119                         {
120                                 std::cerr
121                                     << "ContainerSettings::AddButtons( BCStructVectorType infoList ) "
122                                     << "exception: " << e.what( ) << std::endl;
123                         }//hctac
124                 }
125         // ----------------------------------------------------------------------------------
126         }//ecapseman
127 }//ecapseman