]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/containerSettings.cxx
6779dd399e7f0545cb93954256e472a8b68dd715
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / model / containerSettings.cxx
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
8 #
9 #  This software is governed by the CeCILL-B license under French law and
10 #  abiding by the rules of distribution of free software. You can  use,
11 #  modify and/ or redistribute the software under the terms of the CeCILL-B
12 #  license as circulated by CEA, CNRS and INRIA at the following URL
13 #  http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 #  or in the file LICENSE.txt.
15 #
16 #  As a counterpart to the access to the source code and  rights to copy,
17 #  modify and redistribute granted by the license, users are provided only
18 #  with a limited warranty  and the software's author,  the holder of the
19 #  economic rights,  and the successive licensors  have only  limited
20 #  liability.
21 #
22 #  The fact that you are presently reading this means that you have had
23 #  knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
25
26 /*!
27  * @file containerSettings.cxx
28  * @brief Implements the ContainerSettings class.
29  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
30  * @date  2011-06-02
31  */
32
33 #include "containerSettings.h"
34
35 namespace creaButtonContainer
36 {
37         namespace model
38         {
39                 // ----------------------------------------------------------------------------------
40                 ContainerSettings::ContainerSettings( )
41                 {
42                 }
43                 // ----------------------------------------------------------------------------------
44                 ContainerSettings::~ContainerSettings( )
45                 {
46                 }
47                 
48                 // ----------------------------------------------------------------------------------
49                 ButtonGroupMap
50                 ContainerSettings::GetButtonGroupContainer( )
51                 {
52                         return ( this->m_ButtonGroupContainer );
53                 }
54                 // ----------------------------------------------------------------------------------
55                 KeyMapList
56                 ContainerSettings::GetGroupNameList( )
57                 {
58                         return ( this->m_GroupNameList );
59                 }
60                 
61                 // ----------------------------------------------------------------------------------
62                 void
63                 ContainerSettings::SetButtonGroupContainer(ButtonGroupMap bgContainer)
64                 {
65                         this->m_ButtonGroupContainer = bgContainer;
66                 }
67                 // ----------------------------------------------------------------------------------
68                 void
69                 ContainerSettings::SetGroupNameList( KeyMapList gNameList )
70                 {
71                         this->m_GroupNameList = gNameList;
72                 }
73                 
74                 // ----------------------------------------------------------------------------------
75
76                 ListGroupMap
77                 ContainerSettings::GetListGroupContainer( )
78                 {
79                         return ( this->m_ListGroupContainer );
80                 }
81
82                 void
83                 ContainerSettings::SetListGroupContainer( ListGroupMap lstContainer )
84                 {
85                         this->m_ListGroupContainer = lstContainer;
86                 }
87
88                 // ----------------------------------------------------------------------------------
89
90                 // ----------------------------------------------------------------------------------
91                 void
92                 ContainerSettings::AddButton( const StringType & groupName,
93                     const StringType &buttonName, const wxBitmap &icon,
94                     const StringType &buttonDescription, FunctionEventType event )
95                 {
96                         std::cout<< std::endl<<"MLER CLASS : ContainerSettings" << std::endl;
97                         std::cout<< std::endl<<"MLER ContainerSettings // AddButton "<<std::endl;
98
99
100                         ButtonPair* pair = new ButtonPair(
101                             new ButtonInfo( buttonName, icon ),
102                             new ButtonAction( buttonDescription, event ) );
103                         try
104                         {
105                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
106                                     != this->m_GroupNameList.end( ); ++it )
107                                 {
108                                         if ( ( *it ).compare( groupName ) == 0 )
109                                         {
110                                                 std::cout<<"MLER ContainerSettings // AddButton : it "<<*it <<std::endl;
111
112                                                 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
113                                                 return;
114                                         }//fi
115                                 }//rof
116                                 this->m_GroupNameList.push_back( groupName );
117                                 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
118                         }//yrt
119                         catch ( const std::exception& e )
120                         {
121                                 std::cerr
122                                     << "ContainerSettings::AddButton( const std::string & groupName,"
123                                     << "const std::string buttonName, const std::string iconpath,"
124                                     << "const std::string buttonDescription, FunctionEventType event ) exception: "
125                                     << e.what( ) << std::endl;
126                         }//hctac
127                 }
128                 // ----------------------------------------------------------------------------------
129                 void
130                 ContainerSettings::AddButton( BCSettingsStruct* info )
131                 {
132                         ButtonPair* pair = new ButtonPair(
133                             new ButtonInfo( info->buttonName, info->icon ),
134                             new ButtonAction( info->buttonDescription, info->eventFunction ) );
135                         try
136                         {
137                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
138                                     != this->m_GroupNameList.end( ); ++it )
139                                 {
140                                         if ( ( *it ).compare( info->groupName ) == 0 )
141                                         {
142                                                 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
143                                                 return;
144                                         }//fi
145                                 }//rof
146                                 this->m_GroupNameList.push_back( info->groupName );
147                                 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
148                         }//yrt
149                         catch ( const std::exception& e )
150                         {
151                                 std::cerr
152                                     << "void ContainerSettings::AddButton( BCSettingsStruct* info ) "
153                                     << "exception: " << e.what( ) << std::endl;
154                         }//hctac
155                 }
156                 // ----------------------------------------------------------------------------------
157                 void
158                 ContainerSettings::AddButtons( BCStructVectorType infoList )
159                 {
160                         try
161                         {
162                                 for( BCStructVectorType::iterator it = infoList.begin( ); it
163                                     != infoList.end( ); ++it )
164                                 {
165                                         this->AddButton( *it );
166                                 }//rof
167                         }//yrt
168                         catch ( const std::exception& e )
169                         {
170                                 std::cerr
171                                     << "ContainerSettings::AddButtons( BCStructVectorType infoList ) "
172                                     << "exception: " << e.what( ) << std::endl;
173                         }//hctac
174                 }
175
176                 void
177                 ContainerSettings::AddItems(BCStructVectorType infoList)
178                 {
179                         try
180                         {
181                                 for( BCStructVectorType::iterator it = infoList.begin( ); it
182                                     != infoList.end( ); ++it )
183                                 {
184                                         this->AddItem(*it);
185                                 }//rof
186                         }//yrt
187                         catch ( const std::exception& e )
188                         {
189                                 std::cerr
190                             << "ContainerSettings::AddButtons( BCStructVectorType infoList ) "
191                             << "exception: " << e.what( ) << std::endl;
192                         }//hctac
193                 }
194                 //-----------------------------------------------------------------------------------
195                         void
196                                 ContainerSettings::AddItem(const StringType & groupName)
197                                 {
198
199                                 //Es importante hacer un test, recibiendo como parametro la info de un item.
200
201
202                                         wxListItem* item;
203                                         item->SetId(1);
204                                         item->SetText(wxT("monica"));
205
206                                         creaButtonContainer::view::ListWx l;
207                                         l.setItems(item);
208
209
210                                         try
211                                         {
212                                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( );
213                                                          it!= this->m_GroupNameList.end( ); ++it )
214                                                 {
215                                                         if(( *it ).compare( groupName ) == 0 )
216                                                         {
217                                                                 this->m_ListGroupContainer[ groupName ].push_back(l);
218                                                                 return;
219                                                         }
220                                                 }
221                                                 this->m_GroupNameList.push_back( groupName );
222                                                 this->m_ListGroupContainer[ groupName ].push_back( l );
223                                         }
224                                         catch ( const std::exception& e )
225                                         {
226                                                 std::cerr
227                                                 << "ContainerSettings::AddButton( const std::string & groupName,"
228                                                 << "const std::string buttonName, const std::string iconpath,"
229                                                 << "const std::string buttonDescription, FunctionEventType event ) exception: "
230                                                 << e.what( ) << std::endl;
231                                         }//hctac
232                                 }
233
234
235                                 void
236                                 ContainerSettings::AddItem( BCSettingsStruct* info )
237                                 {
238                                         wxListItem* item;
239
240                                         wxString myString((info->buttonName).c_str(),wxConvUTF8);
241                                         item->SetText(myString);
242
243                                         creaButtonContainer::view::ListWx l;
244                                         l.setItems(item);
245
246                                         try
247                                         {
248                                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
249                                                         != this->m_GroupNameList.end( ); ++it )
250                                                 {
251                                                         if ( ( *it ).compare( info->groupName ) == 0 )
252                                                         {
253                                                                 this->m_ListGroupContainer[ info->groupName ].push_back( l );
254                                                                 return;
255                                                         }//fi
256                                                 }//rof
257                                                 this->m_GroupNameList.push_back( info->groupName );
258                                                 this->m_ListGroupContainer[ info->groupName ].push_back( l );
259                                         }
260                                         catch (const std::exception& e)
261                                         {
262                                                 std::cerr
263                                                 << "void ContainerSettings::AddItem( BCSettingsStruct* info ) "
264                                                 << "exception: " << e.what( ) << std::endl;
265                                         }
266
267                                 }
268
269
270
271         // ----------------------------------------------------------------------------------
272         }//ecapseman
273 }//ecapseman