]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/buttonContainerSettings.cxx
55e595e0a3fd1d43d4d035d39b86d0913366dd20
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaPanelButtonContainer / buttonContainerSettings.cxx
1 /***************************************************************
2  * Name:      buttonContainerSettings.cxx
3  * Purpose:   It is the ButtonGroupSettings
4  * Author:    Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * Modified:  2011-05-09
6  * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/)
7  * License:
8  **************************************************************/
9 #include "buttonContainerSettings.h"
10 #include <iostream>
11
12 namespace creaPanelButtonContainer
13 {
14
15         ButtonContainerSettings::ButtonContainerSettings( )
16         {
17         }
18         ButtonContainerSettings::~ButtonContainerSettings( )
19         {
20         }
21         ButtonGroupMap
22         ButtonContainerSettings::GetButtonGroupContainer( )
23         {
24                 return m_ButtonGroupContainer;
25         }
26
27         KeyMapList
28         ButtonContainerSettings::GetGroupNameList( )
29         {
30                 return m_GroupNameList;
31         }
32
33         //GetButtonPanel returns the panel asociated to de buttonAction
34         PanelButton
35         ButtonContainerSettings::GetPanelButton( const std::string &buttonName )
36         {
37                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
38                     != this->m_GroupNameList.end( ); ++it )
39                 {
40                         ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
41                         for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
42                         {
43                                 if ( ( *it1 )->first->first.compare( buttonName ) == 0 )
44                                 {
45                                         return ( ( *it1 )->second->second );
46                                 }//fi
47                         }//rof
48                 }//rof
49                 return ( NULL );
50         }
51         ButtonGroupSettings*
52         ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor )
53         {
54                 ButtonGroupSettings* settings = new ButtonGroupSettings( );
55                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
56                     != this->m_GroupNameList.end( ); ++it )
57                 {
58                         ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ];
59                         for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 )
60                         {
61                                 settings->CreateGroup( *it );
62                                 settings->AddButton( ( *it ), ( *it1 )->first->first,
63                                     ( *it1 )->first->second, ( *it1 )->second->first, functor );
64                         }//rof
65                 }//rof
66                 return ( settings );
67         }
68         void
69         ButtonContainerSettings::SetButtonGroupContainer(
70             ButtonGroupMap m_ButtonGroupContainer )
71         {
72                 this->m_ButtonGroupContainer = m_ButtonGroupContainer;
73         }
74
75         void
76         ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList )
77         {
78                 this->m_GroupNameList = m_GroupNameList;
79         }
80
81         void
82         ButtonContainerSettings::AddButton( const std::string & groupName,
83             const std::string buttonName, const std::string iconpath,
84             const std::string buttonDescription, PanelButton panel )
85         {
86                 //builds the button information
87                 ButtonPair* pair = new ButtonPair( new ButtonInfo( buttonName, iconpath ),
88                     new ActionButton( buttonDescription, panel ) );
89                 panel->Show( false );
90                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
91                     != this->m_GroupNameList.end( ); ++it )
92                 {
93                         if ( ( *it ).compare( groupName ) == 0 )
94                         {
95                                 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
96                                 return;
97                         }//fi
98                 }//rof
99                 //if the group doesn't exist it creates a new groupName
100                 this->m_GroupNameList.push_back( groupName );
101                 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
102         }
103 }//ecapseman
104