# ------------------------------------------------------------------------ */
+
#include "listWx.h"
namespace creaButtonContainer
namespace view
{
// ----------------------------------------------------------------------------------
- ListWx::ListWx( wxWindow* parent, long id, ButtonPair* pair )
+ ListWx::ListWx( wxWindow* parent, wxWindowID id,ItemsMap iMap , TFunctor* functor ): wxListCtrl(parent,id)
{
- this->m_ButtonPair = pair;
- StringType wXbuttonName = this->m_ButtonPair->first->first;
- BitmapType wXicon = this->m_ButtonPair->first->second;
- StringType wXdescription = this->m_ButtonPair->second->first;
- wxString buttonName( wXbuttonName.c_str( ), wxConvUTF8 );
- wxString description( wXdescription.c_str( ), wxConvUTF8 );
- //creating the button.
- //this->Create( parent, id,
- // wXicon,
- //wxDefaultPosition, wxDefaultSize,wxBU_AUTODRAW, wxDefaultValidator,
- //buttonName );
- this->Create( parent, id,
- wxDefaultPosition, wxDefaultSize,wxLC_LIST, wxDefaultValidator,
- buttonName );
- this->SetToolTip( description );
-
-
- long index = this->InsertItem(0, _("John Smith"));
- this->SetItem(index, 1, _("jsmith"));
-
- index = this->InsertItem(1, _("Monica"));
- this->SetItem(index, 1, _("monica"));
- index = this->InsertItem(2, _("Momo"));
- this->SetItem(index, 2, _("momo"));
+ std::cout<< "MLER | ListWx::ListWx()" << std::endl;
+ this->m_itemsMap = iMap;
+ this->functor = functor;
+ int i = 0;
+ for (ItemsMap::iterator it=this->m_itemsMap.begin(); it!=this->m_itemsMap.end(); ++it)
+ {
+ std::string key = it->first;
+ long index = this->InsertItem(i, wxString(key.c_str(), wxConvUTF8));
+ std::cout << "index" << index << std::endl;
+ this->Connect( -1, wxEVT_COMMAND_LIST_ITEM_SELECTED,
+ wxListEventHandler(ListWx::ListEvent) );
+ i++;
+ }
}
// ----------------------------------------------------------------------------------
{
}
- // ----------------------------------------------------------------------------------
- StringType
- ListWx::GetButtonName( )
+ void
+ ListWx::ListEvent( wxListEvent& event )
{
- return ( this->m_ButtonPair->first->first );
- }
+ try
+ {
+ std::cout<< "MLER | ListWx::ListEvent( wxListEvent& event )" << std::endl;
- // ----------------------------------------------------------------------------------
- BitmapType
- ListWx::GetIcon( )
- {
- return ( this->m_ButtonPair->first->second );
- }
+ wxString itemNom = event.GetItem().GetText();
- // ----------------------------------------------------------------------------------
- /*StringType
- Button::GetIconPath( )
- {
- return ( this->m_ButtonPair->first->second );
- }*/
+ std::string itemNomC = std::string(itemNom.mb_str());
- // ----------------------------------------------------------------------------------
- StringType
- ListWx::GetDescription( )
- {
- return ( this->m_ButtonPair->second->first );
- }
+ this->functor->Call(itemNomC);
+ std::cout<<"mmmmmmmmmmmmmmmmmmmmmmm"<<std::endl;
- // ----------------------------------------------------------------------------------
- void
- ListWx::Execute( )
- {
- try
- {
- TFunctor* vTable[ ] =
- { this->m_ButtonPair->second->second };
- vTable[ 0 ]->Call( this->m_ButtonPair->first->first );
}//yrt
catch ( const std::exception& e )
{
- std::cerr << "Button::Execute( ) exception: " << e.what( ) << std::endl;
+ std::cerr
+ << "ButtonContainerController::ButtonEvent( wxCommandEvent& event ) exception: "
+ << e.what( ) << std::endl;
}//hctac
}
// ----------------------------------------------------------------------------------
}//ecapseman
}//ecapseman
+
+