]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/containerSettings.cxx
#2497 creaMaracasVisu Feature New Normal - In container button add the list option
[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 //EED-MLER
76 /*
77
78                 ListGroupMap
79                 ContainerSettings::GetListGroupContainer( )
80                 {
81                         return ( this->m_ListGroupContainer );
82                 }
83
84                 void
85                 ContainerSettings::SetListGroupContainer( ListGroupMap lstContainer )
86                 {
87                         this->m_ListGroupContainer = lstContainer;
88                 }
89 */
90
91                 // ----------------------------------------------------------------------------------
92
93                 // ----------------------------------------------------------------------------------
94                 void
95                 ContainerSettings::AddButton( const StringType & groupName,
96                     const StringType &buttonName, const wxBitmap &icon,
97                     const StringType &buttonDescription, FunctionEventType event )
98                 {
99                         std::cout<< std::endl<<"MLER CLASS : ContainerSettings" << std::endl;
100                         std::cout<< std::endl<<"MLER ContainerSettings // AddButton "<<std::endl;
101
102
103                         ButtonPair* pair = new ButtonPair(
104                             new ButtonInfo( buttonName, icon ),
105                             new ButtonAction( buttonDescription, event ) );
106                         try
107                         {
108                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
109                                     != this->m_GroupNameList.end( ); ++it )
110                                 {
111                                         if ( ( *it ).compare( groupName ) == 0 )
112                                         {
113                                                 std::cout<<"MLER ContainerSettings // AddButton : it "<<*it <<std::endl;
114
115                                                 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
116                                                 return;
117                                         }//fi
118                                 }//rof
119                                 this->m_GroupNameList.push_back( groupName );
120                                 this->m_ButtonGroupContainer[ groupName ].push_back( pair );
121                         }//yrt
122                         catch ( const std::exception& e )
123                         {
124                                 std::cerr
125                                     << "ContainerSettings::AddButton( const std::string & groupName,"
126                                     << "const std::string buttonName, const std::string iconpath,"
127                                     << "const std::string buttonDescription, FunctionEventType event ) exception: "
128                                     << e.what( ) << std::endl;
129                         }//hctac
130                 }
131                 // ----------------------------------------------------------------------------------
132                 void
133                 ContainerSettings::AddButton( BCSettingsStruct* info )
134                 {
135                         ButtonPair* pair = new ButtonPair(
136                             new ButtonInfo( info->buttonName, info->icon ),
137                             new ButtonAction( info->buttonDescription, info->eventFunction ) );
138                         try
139                         {
140                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
141                                     != this->m_GroupNameList.end( ); ++it )
142                                 {
143                                         if ( ( *it ).compare( info->groupName ) == 0 )
144                                         {
145                                                 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
146                                                 return;
147                                         }//fi
148                                 }//rof
149                                 this->m_GroupNameList.push_back( info->groupName );
150                                 this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
151                         }//yrt
152                         catch ( const std::exception& e )
153                         {
154                                 std::cerr
155                                     << "void ContainerSettings::AddButton( BCSettingsStruct* info ) "
156                                     << "exception: " << e.what( ) << std::endl;
157                         }//hctac
158                 }
159                 // ----------------------------------------------------------------------------------
160                 void
161                 ContainerSettings::AddButtons( BCStructVectorType infoList )
162                 {
163                         try
164                         {
165                                 for( BCStructVectorType::iterator it = infoList.begin( ); it
166                                     != infoList.end( ); ++it )
167                                 {
168                                         this->AddButton( *it );
169                                 }//rof
170                         }//yrt
171                         catch ( const std::exception& e )
172                         {
173                                 std::cerr
174                                     << "ContainerSettings::AddButtons( BCStructVectorType infoList ) "
175                                     << "exception: " << e.what( ) << std::endl;
176                         }//hctac
177                 }
178
179 //EED-MLER
180 /*
181                 void
182                 ContainerSettings::AddItems(BCStructVectorType infoList)
183                 {
184                         try
185                         {
186                                 for( BCStructVectorType::iterator it = infoList.begin( ); it
187                                     != infoList.end( ); ++it )
188                                 {
189                                         this->AddItem(*it);
190                                 }//rof
191                         }//yrt
192                         catch ( const std::exception& e )
193                         {
194                                 std::cerr
195                             << "ContainerSettings::AddButtons( BCStructVectorType infoList ) "
196                             << "exception: " << e.what( ) << std::endl;
197                         }//hctac
198                 }
199
200
201                 //-----------------------------------------------------------------------------------
202                         void
203                                 ContainerSettings::AddItem(const StringType & groupName)
204                                 {
205
206                                 //Es importante hacer un test, recibiendo como parametro la info de un item.
207
208
209                                         wxListItem* item;
210                                         item->SetId(1);
211                                         item->SetText(wxT("monica"));
212
213                                         creaButtonContainer::view::ListWx l;
214                                         l.setItems(item);
215
216
217                                         try
218                                         {
219                                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( );
220                                                          it!= this->m_GroupNameList.end( ); ++it )
221                                                 {
222                                                         if(( *it ).compare( groupName ) == 0 )
223                                                         {
224                                                                 this->m_ListGroupContainer[ groupName ].push_back(l);
225                                                                 return;
226                                                         }
227                                                 }
228                                                 this->m_GroupNameList.push_back( groupName );
229                                                 this->m_ListGroupContainer[ groupName ].push_back( l );
230                                         }
231                                         catch ( const std::exception& e )
232                                         {
233                                                 std::cerr
234                                                 << "ContainerSettings::AddButton( const std::string & groupName,"
235                                                 << "const std::string buttonName, const std::string iconpath,"
236                                                 << "const std::string buttonDescription, FunctionEventType event ) exception: "
237                                                 << e.what( ) << std::endl;
238                                         }//hctac
239                                 }
240
241
242                                 void
243                                 ContainerSettings::AddItem( BCSettingsStruct* info )
244                                 {
245                                         wxListItem* item;
246
247                                         wxString myString((info->buttonName).c_str(),wxConvUTF8);
248                                         item->SetText(myString);
249
250                                         creaButtonContainer::view::ListWx l;
251                                         l.setItems(item);
252
253                                         try
254                                         {
255                                                 for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
256                                                         != this->m_GroupNameList.end( ); ++it )
257                                                 {
258                                                         if ( ( *it ).compare( info->groupName ) == 0 )
259                                                         {
260                                                                 this->m_ListGroupContainer[ info->groupName ].push_back( l );
261                                                                 return;
262                                                         }//fi
263                                                 }//rof
264                                                 this->m_GroupNameList.push_back( info->groupName );
265                                                 this->m_ListGroupContainer[ info->groupName ].push_back( l );
266                                         }
267                                         catch (const std::exception& e)
268                                         {
269                                                 std::cerr
270                                                 << "void ContainerSettings::AddItem( BCSettingsStruct* info ) "
271                                                 << "exception: " << e.what( ) << std::endl;
272                                         }
273
274                                 }
275
276 */
277
278         // ----------------------------------------------------------------------------------
279         }//ecapseman
280 }//ecapseman