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);
50 m_functorEnabled = true;
52 std::cout << "is ListBox"<< listBox->GetId()<< std::endl;
53 // this->Connect( -1,wxEVT_COMMAND_CHOICE_SELECTED,
54 // (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))(&ListWx::ListEvent) );
55 //this->Connect(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED,
56 // wxCommandEventHandler(ListWx::ListEvent));
58 this->Connect(wxEVT_COMMAND_LISTBOX_SELECTED,
59 wxCommandEventHandler(ListWx::ListEvent));
64 sizer->Add(listBox,1,wxGROW);
69 // ----------------------------------------------------------------------------------
71 ListWx::ListWx( wxWindow* parent, wxWindowID id, ItemsMap iMap,TFunctor* functor,
72 std::string c) : wxPanel(parent,id)
74 std::cout<< "MLER | ListWx::ListWx" << std::endl;
76 this->m_itemsMap = iMap;
77 this->functor = functor;
79 wxFlexGridSizer* sizer = new wxFlexGridSizer(1);
81 sizer->Add( new wxStaticText(this,-1, _("Lista Configurable")));
82 sizer->AddGrowableCol(0);
83 this->SetSizer(sizer);
85 listBox = new wxListBox(this,-1);
87 std::cout << "is ListBox"<< listBox->GetId()<< std::endl;
89 button = new wxButton(this, 1, _("Configurar"),
90 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, wxString(c.c_str(), wxConvUTF8));
92 sizer->Add(listBox,1,wxGROW);
93 sizer->Add(button,2,wxGROW);
95 // m_listConfigPanel = new ListConfigPanel(this,1,_("Configuracion"),m_itemsMap);
96 m_listConfig = new ListConfig(m_itemsMap);
98 //wxEVT_COMMAND_LISTBOX_SELECTED
99 this->Connect(wxEVT_COMMAND_LISTBOX_SELECTED,
100 wxCommandEventHandler(ListWx::ListEvent));
106 // ----------------------------------------------------------------------------------
111 // ----------------------------------------------------------------------------------
116 this->listBox->Clear();
117 std::cout<<"clear"<<std::endl;
118 for (ItemsMap::iterator it=this->m_itemsMap.begin(); it!=this->m_itemsMap.end(); ++it)
120 std::string key = it->first;
121 int v = listBox->FindString(wxString(key.c_str(), wxConvUTF8));
123 listBox->Append( wxString(key.c_str(), wxConvUTF8));
128 // ----------------------------------------------------------------------------------
131 ListWx::ListEvent( wxCommandEvent& event )
133 if(!this->IsFunctorEnabled())
138 std::cout<< "MLER | ListWx::ListEvent( wxListEvent& event )" << std::endl;
141 iSelection = listBox->GetSelection();
143 wxString itemNom = listBox->GetString(iSelection);
144 std::string itemNomC = std::string(itemNom.mb_str());
146 this->functor->Call(itemNomC);
147 std::cout<<"mmmmmmmmmmmmmmmmmmmmmmm"<<std::endl;
151 catch ( const std::exception& e )
154 << "ButtonContainerController::ButtonEvent( wxCommandEvent& event ) exception: "
155 << e.what( ) << std::endl;
159 // ----------------------------------------------------------------------------------
164 ListWx::GetItemsMap()
169 void ListWx::SetFunctorEnabled(const bool& enabled)
171 m_functorEnabled = enabled;
174 bool ListWx::IsFunctorEnabled() const
176 return m_functorEnabled;
180 ListWx::GetWxListFunctor()
182 return this->functor;
185 void ListWx::AddItemToMap(std::string key, wxPanel* panel)
187 this->m_itemsMap[key] = panel;
191 ListWx::GetListBox() const
193 return this->listBox;
197 void ListWx::DeleteItemFromMap(std::string key)
199 std::cout<< "MLER | ListConfig::DelFinalItems(std::string name)" << std::endl;
200 ItemsMap::iterator it1;
202 //if(m_finalItems.empty())
203 std::cout<<"name item -----test A"<< key <<std::endl;
204 if(!this->m_itemsMap.empty())
206 for(ItemsMap::iterator it= this->m_itemsMap.begin(); it!=this->m_itemsMap.end();++it)
208 if((it->first).compare(key) == 0 )
210 std::cout << "Item a borrar: "<< key << std::endl;
211 it1 = m_itemsMap.find(key);
212 m_itemsMap.erase(it1);
217 std::cout<< "si borre tengo --- test 2 "<< m_itemsMap.size() << std::endl;