1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
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
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.
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
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 # ------------------------------------------------------------------------ */
30 namespace creaButtonContainer
35 ListWx::ListWx( wxWindow* parent, wxWindowID id,ItemsMap iMap , TFunctor* functor ):
39 std::cout<< "MLER | ListWx::ListWx()" << std::endl;
40 this->m_itemsMap = iMap;
42 this->functor = functor;
44 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
45 sizer->Add( new wxStaticText(this,-1, _("Lista")));
46 sizer->AddGrowableCol(0);
47 this->SetSizer(sizer);
49 listBox = new wxListBox(this,-1);
51 std::cout << "is ListBox"<< listBox->GetId()<< std::endl;
52 // this->Connect( -1,wxEVT_COMMAND_CHOICE_SELECTED,
53 // (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))(&ListWx::ListEvent) );
54 //this->Connect(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
55 // wxCommandEventHandler(ListWx::ListEvent));
57 this->Connect(wxEVT_COMMAND_LISTBOX_SELECTED,
58 wxCommandEventHandler(ListWx::ListEvent));
63 sizer->Add(listBox,1,wxGROW);
68 // ----------------------------------------------------------------------------------
70 ListWx::ListWx( wxWindow* parent, wxWindowID id, ItemsMap iMap,TFunctor* functor,
71 std::string c) : wxPanel(parent,id)
73 std::cout<< "MLER | ListWx::ListWx" << std::endl;
75 this->m_itemsMap = iMap;
76 this->functor = functor;
78 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
80 sizer->Add( new wxStaticText(this,-1, _("Lista Configurable")));
81 sizer->AddGrowableCol(0);
82 this->SetSizer(sizer);
84 listBox = new wxListBox(this,-1);
86 std::cout << "is ListBox"<< listBox->GetId()<< std::endl;
88 button = new wxButton(this, 1, _("Configurar"),
89 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxString(c.c_str(), wxConvUTF8));
91 sizer->Add(listBox,1,wxGROW);
92 sizer->Add(button,2,wxGROW);
94 // m_listConfigPanel = new ListConfigPanel(this,1,_("Configuracion"),m_itemsMap);
95 m_listConfig = new ListConfig(m_itemsMap);
97 //wxEVT_COMMAND_LISTBOX_SELECTED
98 this->Connect(wxEVT_COMMAND_LISTBOX_SELECTED,
99 wxCommandEventHandler(ListWx::ListEvent));
105 // ----------------------------------------------------------------------------------
110 // ----------------------------------------------------------------------------------
115 this->listBox->Clear();
116 std::cout<<"clear"<<std::endl;
117 for (ItemsMap::iterator it=this->m_itemsMap.begin(); it!=this->m_itemsMap.end(); ++it)
119 std::string key = it->first;
120 int v = listBox->FindString(wxString(key.c_str(), wxConvUTF8));
122 listBox->Append( wxString(key.c_str(), wxConvUTF8));
127 // ----------------------------------------------------------------------------------
130 ListWx::ListEvent( wxCommandEvent& event )
132 if(!this->IsFunctorEnabled())
136 std::cout<< "MLER | ListWx::ListEvent( wxListEvent& event )" << std::endl;
138 // wxString itemNom = this->GetString(this->GetSelection());
140 // std::string itemNomC = std::string(itemNom.mb_str());
142 //this->functor->Call(itemNomC);
145 iSelection = listBox->GetSelection();
147 wxString itemNom = listBox->GetString(iSelection);
148 std::string itemNomC = std::string(itemNom.mb_str());
150 this->functor->Call(itemNomC);
151 std::cout<<"mmmmmmmmmmmmmmmmmmmmmmm"<<std::endl;
155 catch ( const std::exception& e )
158 << "ButtonContainerController::ButtonEvent( wxCommandEvent& event ) exception: "
159 << e.what( ) << std::endl;
162 // ----------------------------------------------------------------------------------
167 ListWx::GetItemsMap()
172 void ListWx::SetFunctorEnabled(const bool& enabled)
174 m_functorEnabled = enabled;
177 bool ListWx::IsFunctorEnabled() const
179 return m_functorEnabled;
183 ListWx::GetWxListFunctor()
185 return this->functor;
188 void ListWx::AddItemToMap(std::string key, wxPanel* panel)
190 this->m_itemsMap[key] = panel;
194 ListWx::GetListBox() const
196 return this->listBox;
200 void ListWx::DeleteItemFromMap(std::string key)
202 std::cout<< "MLER | ListConfig::DelFinalItems(std::string name)" << std::endl;
203 ItemsMap::iterator it1;
205 //if(m_finalItems.empty())
206 std::cout<<"name item -----test A"<< key <<std::endl;
207 if(!this->m_itemsMap.empty())
209 for(ItemsMap::iterator it= this->m_itemsMap.begin(); it!=this->m_itemsMap.end();++it)
211 if((it->first).compare(key) == 0 )
213 std::cout << "Item a borrar: "<< key << std::endl;
214 it1 = m_itemsMap.find(key);
215 m_itemsMap.erase(it1);
220 std::cout<< "si borre tengo --- test 2 "<< m_itemsMap.size() << std::endl;