From a7017a8ade695bd14a4c7ee70b197d63b5e76765 Mon Sep 17 00:00:00 2001 From: espinosa Date: Mon, 26 Jan 2015 23:38:26 +0100 Subject: [PATCH] #2516 creaMaracasVisu Feature New Normal - creaPanelButtonContainer ListPanel with events 2 --- .../creaButtonContainer/view/listWx.cxx | 40 ++++++++++++++----- .../widgets/creaButtonContainer/view/listWx.h | 13 ++++-- .../buttonContainerSettings.h | 3 +- .../creaPanelButtonContainer.cxx | 28 ++++++------- 4 files changed, 57 insertions(+), 27 deletions(-) diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.cxx index 5de552c..1ec058d 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.cxx @@ -32,25 +32,39 @@ namespace creaButtonContainer namespace view { // ---------------------------------------------------------------------------------- - ListWx::ListWx( wxWindow* parent, wxWindowID id,ItemsMap iMap , TFunctor* functor ): wxListCtrl(parent,id) + ListWx::ListWx( wxWindow* parent, wxWindowID id,ItemsMap iMap , TFunctor* functor ): + wxPanel(parent,id) { std::cout<< "MLER | ListWx::ListWx()" << std::endl; this->m_itemsMap = iMap; this->functor = functor; - int i = 0; + + wxFlexGridSizer* sizer = new wxFlexGridSizer(1); + sizer->Add( new wxStaticText(this,-1, _("Lista"))); + sizer->AddGrowableCol(0); + this->SetSizer(sizer); + + listBox = new wxListBox(this,-1); + + std::cout << "is ListBox"<< listBox->GetId()<< std::endl; + // this->Connect( -1,wxEVT_COMMAND_CHOICE_SELECTED, + // (wxObjectEventFunction) (void (wxPanel::*)(wxEvent&))(&ListWx::ListEvent) ); + this->Connect(wxEVT_COMMAND_LISTBOX_DOUBLECLICKED, + wxCommandEventHandler(ListWx::ListEvent)); + 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++; + listBox->Append( wxString(key.c_str(), wxConvUTF8)); + } + sizer->Add(listBox,1,wxGROW); + + } // ---------------------------------------------------------------------------------- @@ -59,14 +73,22 @@ namespace creaButtonContainer } void - ListWx::ListEvent( wxListEvent& event ) + ListWx::ListEvent( wxCommandEvent& event ) { try { std::cout<< "MLER | ListWx::ListEvent( wxListEvent& event )" << std::endl; - wxString itemNom = event.GetItem().GetText(); + // wxString itemNom = this->GetString(this->GetSelection()); + + // std::string itemNomC = std::string(itemNom.mb_str()); + + //this->functor->Call(itemNomC); + + int iSelection; + iSelection = listBox->GetSelection(); + wxString itemNom = listBox->GetString(iSelection); std::string itemNomC = std::string(itemNom.mb_str()); this->functor->Call(itemNomC); diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.h index 7f30549..7f0478a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.h @@ -32,7 +32,10 @@ #include #include #include -#include +//#include +#include +#include +#include #include @@ -49,7 +52,7 @@ namespace creaButtonContainer namespace view { - class ListWx : public wxListCtrl + class ListWx : public wxPanel { public: @@ -69,11 +72,15 @@ namespace creaButtonContainer GetID( ); void - ListEvent( wxListEvent& event ); + ListEvent( wxCommandEvent& event ); // ---------------------------------------------------------------------------------- private: ItemsMap m_itemsMap; //! ItemsMap; - public: + + public: // ---------------------------------------------------------------------------------- /*! @fn ButtonContainerSettings( ); * @brief This is the default constructor. diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx index 7139fd1..d721264 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx @@ -50,7 +50,7 @@ namespace creaPanelButtonContainer std::cout<< "MLER | creaPanelButtonContainer:: PanelButtonContainer() " << std::endl; this->m_ButtonContainerSettings = bcSettings; - this->m_ButtonPanel = new wxPanel( this ); + //Class that manages the event!!! //EED 20/01/2012 @@ -61,33 +61,33 @@ namespace creaPanelButtonContainer TConcreteFunctor* lFunctor = new TConcreteFunctor( this, &PanelButtonContainer::GenericListEvent ); //MLER - this->m_ListPanel = new wxPanel(this); + //Using AuiManager to Manage the Panels + this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT ); + if(type == 0) { + this->m_ButtonPanel = new wxPanel( this ); std::cout << "tipo 0; new ButtonContainerPanel"<m_ButtonContainerPanel = new ButtonContainerPanel( this, this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ),type ); + + this->m_AuiManager->AddPane( this->m_ButtonContainerPanel,wxAuiPaneInfo( ).Name( _T("ButtonContainerPanel") ).Caption(_("ButtonContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) ); + this->m_AuiManager->AddPane(this->m_ButtonPanel, wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("ButtonPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) ); } else if( type == 1) { + this->m_ListPanel = new wxPanel(this); std::cout << "tipo 1; new LIstWx"<mylist = new ListWx(this->m_ListPanel, -1,this->m_ButtonContainerSettings->GetItemsMap(), lFunctor); + this->mylist = new ListWx(this, -1,this->m_ButtonContainerSettings->GetItemsMap(), lFunctor); + + this->m_AuiManager->AddPane( this->mylist,wxAuiPaneInfo( ).Name( _T("ListContainerPanel") ).Caption(_("ListContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) ); + this->m_AuiManager->AddPane(this->m_ListPanel, wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption( _("ListPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) ); }//MLER - //Using AuiManager to Manage the Panels - this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT ); + //CartoButtonPanel Management - if(type == 0) - this->m_AuiManager->AddPane(this->m_ButtonContainerPanel, wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("Panel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) ); - else if(type == 1) - this->m_AuiManager->AddPane(this->m_ListPanel, wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption( _("Panel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) ); - //CartoButtonPanel Management - if(type == 0) - this->m_AuiManager->AddPane( this->m_ButtonContainerPanel,wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption(_("ListPanel") ). CaptionVisible( false ).CloseButton(false ).Center( ).Resizable( true ) ); - else if(type ==1) - {this->m_AuiManager->AddPane( this->m_ListPanel,wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption(_("ListPanel") ). CaptionVisible( false ).CloseButton(false ).Center( ).Resizable( true ) );} this->m_AuiManager->Update( ); } // ---------------------------------------------------------------------------------- -- 2.45.0