From ecf68d834a4193f68661d9d73ea1e6652fb83f20 Mon Sep 17 00:00:00 2001 From: espinosa Date: Sat, 31 Jan 2015 19:48:09 +0100 Subject: [PATCH] #2516 creaMaracasVisu Feature New Normal - creaPanelButtonContainer ListPanel with events 2 --- .../view/listConfigDialog.cxx | 226 ++++++++++++++++++ .../view/listConfigDialog.h} | 50 +++- .../creaButtonContainer/view/listWx.cxx | 23 +- .../widgets/creaButtonContainer/view/listWx.h | 4 + .../creaPanelButtonContainer.cxx | 76 +++++- .../creaPanelButtonContainer.h | 16 +- .../listConfigPanel.cxx | 31 --- 7 files changed, 377 insertions(+), 49 deletions(-) create mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listConfigDialog.cxx rename lib/maracasVisuLib/src/interface/wxWindows/widgets/{creaPanelButtonContainer/listConfigPanel.h => creaButtonContainer/view/listConfigDialog.h} (58%) delete mode 100644 lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.cxx diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listConfigDialog.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listConfigDialog.cxx new file mode 100644 index 0000000..2aa24d1 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listConfigDialog.cxx @@ -0,0 +1,226 @@ +/*# --------------------------------------------------------------------- + # + # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image + # pour la Sant�) + # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton + # Previous Authors : Laurent Guigues, Jean-Pierre Roux + # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil + # + # This software is governed by the CeCILL-B license under French law and + # abiding by the rules of distribution of free software. You can use, + # modify and/ or redistribute the software under the terms of the CeCILL-B + # license as circulated by CEA, CNRS and INRIA at the following URL + # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html + # or in the file LICENSE.txt. + # + # As a counterpart to the access to the source code and rights to copy, + # modify and redistribute granted by the license, users are provided only + # with a limited warranty and the software's author, the holder of the + # economic rights, and the successive licensors have only limited + # liability. + # + # The fact that you are presently reading this means that you have had + # knowledge of the CeCILL-B license and that you accept its terms. + # ------------------------------------------------------------------------ */ + +#include "listConfigDialog.h" + +namespace creaButtonContainer +{ + + namespace view + { + ListConfigDialog::ListConfigDialog(wxWindow* parent, wxWindowID id, + const wxString& title, ListWx* modelList, ListWx* currentList) + : wxDialog(parent, id, title) + { + std::cout << "MLER | ListConfigPanel::ListConfigPanel()" << std::endl; + + this->m_OriginalListWx = modelList; + this->m_OriginalListWx->Reparent(this); + this->m_OriginalListWx->Show(true); + this->m_OriginalListWx->SetFunctorEnabled(false); + //this->m_OriginalListWx->FillList(); + + this->m_CurrentListWx = currentList; + this->m_CurrentListWx->Reparent(this); + this->m_CurrentListWx->SetFunctorEnabled(false); + this->m_CurrentListWx->Show(true); + //this->m_CurrentListWx->FillList(); + + wxFlexGridSizer* sizer = new wxFlexGridSizer(2, 1, 0, 0); + this->SetSizer(sizer); + + wxBoxSizer* sizerUp = new wxBoxSizer(wxHORIZONTAL); + + sizerUp->Add(this->m_OriginalListWx, 0, wxEXPAND); + //======== + + wxPanel* panel2 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL, _T("Panel 2")); + wxBoxSizer* sizerList2 = new wxBoxSizer(wxVERTICAL); + + buttonAdd = new wxButton(panel2, 1, _(">"), wxDefaultPosition, + wxDefaultSize, 0, wxDefaultValidator, _T("Add")); + sizerList2->Add(buttonAdd, 0, wxEXPAND); + + buttonDel = new wxButton(panel2, 2, _("<"), wxDefaultPosition, + wxDefaultSize, 0, wxDefaultValidator, _T("Delete")); + sizerList2->Add(buttonDel, 0, wxEXPAND); + + panel2->SetSizer(sizerList2); + sizerList2->Fit(panel2); + sizerList2->SetSizeHints(panel2); + + sizerUp->Add(panel2, 0, wxEXPAND); + + //======== + + sizerUp->Add(this->m_CurrentListWx, 0, wxEXPAND); + + //======= + wxPanel* panel5 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL, _T("Panel 5")); + wxBoxSizer* sizerList4 = new wxBoxSizer(wxVERTICAL); + + upButton = new wxButton(panel5, 3, _("/\\"), wxDefaultPosition, + wxDefaultSize, 0, wxDefaultValidator, _T("upButton")); + sizerList4->Add(upButton, 0, wxEXPAND); + + downButton = new wxButton(panel5, 4, _("V"), wxDefaultPosition, + wxDefaultSize, 0, wxDefaultValidator, _T("downButton")); + sizerList4->Add(downButton, 0, wxEXPAND); + + panel5->SetSizer(sizerList4); + sizerList4->Fit(panel5); + sizerList4->SetSizeHints(panel5); + sizerUp->Add(panel5, 0, wxEXPAND); + + //======== + wxBoxSizer* sizerBotones = new wxBoxSizer(wxHORIZONTAL); + wxPanel* panel4 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL, _T("Panel 4")); + + okButton = new wxButton(panel4, 5, _("Ok"), wxPoint(0, 8), wxDefaultSize, + 0, wxDefaultValidator, _T("Ok")); + cancelButton = new wxButton(panel4, 6, _("Cancel"), wxPoint(88, 8), + wxDefaultSize, 0, wxDefaultValidator, _T("Cancel")); + + sizerBotones->Add(panel4, 0, wxEXPAND); + + sizer->Add(sizerUp, 0, wxEXPAND); + sizer->Add(sizerBotones, 1, wxALL | wxALIGN_CENTER_HORIZONTAL); + + //--------------------------------------------------------------------------------------------- + // Manejo de Eventos + + //Evento Cancel + Connect(6, wxEVT_COMMAND_BUTTON_CLICKED, + (wxObjectEventFunction) & ListConfigDialog::OnCancel); + + //EventoSeleccionarLista + //Connect(wxEVT_COMMAND_LISTBOX_SELECTED,wxCommandEventHandler(ListConfigPanel::ListItemEvent)); + + //EventoAdd + Connect(1, wxEVT_COMMAND_BUTTON_CLICKED, + (wxObjectEventFunction) & ListConfigDialog::OnAdd); + + //EventoOk + Connect(5, wxEVT_COMMAND_BUTTON_CLICKED, + (wxObjectEventFunction) & ListConfigDialog::OnOk); + + //EventoDelete + Connect(2, wxEVT_COMMAND_BUTTON_CLICKED, + (wxObjectEventFunction) & ListConfigDialog::OnDelete); + + //EventoUp + Connect(3, wxEVT_COMMAND_BUTTON_CLICKED, + (wxObjectEventFunction) & ListConfigDialog::OnMoveUp); + + //EventoUp + Connect(4, wxEVT_COMMAND_BUTTON_CLICKED, + (wxObjectEventFunction) & ListConfigDialog::OnMoveDown); + + } + + ListConfigDialog::~ListConfigDialog() + { + + } + + void ListConfigDialog::OnAdd(wxCommandEvent& event) + { + wxString itSelect = m_OriginalListWx->GetListBox()->GetStringSelection(); + int v; + std::cout << "Count = " << this->m_CurrentListWx->GetListBox()->GetCount() + << std::endl; + if (!itSelect.IsEmpty()) + { + int v = this->m_CurrentListWx->GetListBox()->FindString(itSelect); + if (v == -1) + { + this->m_CurrentListWx->GetListBox()->Append(itSelect); + this->m_CurrentListWx->GetListBox()->Update(); + } + } + + } + void ListConfigDialog::OnDelete(wxCommandEvent& event) + { + wxString itSelect = m_CurrentListWx->GetListBox()->GetStringSelection(); + + if (!itSelect.IsEmpty()) + { + int v = this->m_CurrentListWx->GetListBox()->FindString(itSelect); + if (v != -1) + { + this->m_CurrentListWx->GetListBox()->Delete(v); + this->m_CurrentListWx->GetListBox()->Update(); + } + } + } + void ListConfigDialog::OnMoveUp(wxCommandEvent& event) + { + wxString itSelect = m_CurrentListWx->GetListBox()->GetStringSelection(); + + if (!itSelect.IsEmpty()) + { + int v = this->m_CurrentListWx->GetListBox()->FindString(itSelect); + if (v > 0) + { + this->m_CurrentListWx->GetListBox()->Delete(v); + this->m_CurrentListWx->GetListBox()->Insert(itSelect, v - 1); + this->m_CurrentListWx->GetListBox()->Update(); + } + } + + } + void ListConfigDialog::OnMoveDown(wxCommandEvent& event) + { + wxString itSelect = m_CurrentListWx->GetListBox()->GetStringSelection(); + + if (!itSelect.IsEmpty()) + { + int v = this->m_CurrentListWx->GetListBox()->FindString(itSelect); + std::cout << "Count = " + << this->m_CurrentListWx->GetListBox()->GetCount() << std::endl; + if ((v < this->m_CurrentListWx->GetListBox()->GetCount() - 1) + && (v != -1)) + { + this->m_CurrentListWx->GetListBox()->Delete(v); + this->m_CurrentListWx->GetListBox()->Insert(itSelect, v + 1); + this->m_CurrentListWx->GetListBox()->Update(); + } + } + + } + void ListConfigDialog::OnOk(wxCommandEvent& event) + { + this->EndModal(1); + } + void ListConfigDialog::OnCancel(wxCommandEvent& event) + { + Close(); + } + } +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listConfigDialog.h similarity index 58% rename from lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.h rename to lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listConfigDialog.h index 6e7a5ed..d45403a 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/listConfigPanel.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listConfigDialog.h @@ -23,8 +23,8 @@ # knowledge of the CeCILL-B license and that you accept its terms. # ------------------------------------------------------------------------ */ -#ifndef LISTCONFIGPANEL_H -#define LISTCONFIGPANEL_H +#ifndef LISTCONFIGDIALOG_H +#define LISTCONFIGDIALOG_H #include #include @@ -36,13 +36,51 @@ #include "functor.h" #include "listWx.h" -namespace creaPanelButtonContainer +namespace creaButtonContainer { - class ListConfigPanel: public wxDialog + namespace view { - }; + class ListConfigDialog: public wxDialog + { + public: + + typedef creaButtonContainer::model::TFunctor TFunctor; + typedef creaButtonContainer::view::ListWx ListWx; + + public: + + ListConfigDialog(wxWindow* parent, wxWindowID id, const wxString& title, + ListWx* modelList, ListWx* currentList); + ~ListConfigDialog(); + + void + OnAdd(wxCommandEvent& event); + void + OnDelete(wxCommandEvent& event); + void + OnMoveUp(wxCommandEvent& event); + void + OnMoveDown(wxCommandEvent& event); + void + OnOk(wxCommandEvent& event); + void + OnCancel(wxCommandEvent& event); + + private: + //todo change it to wxBitmap + wxButton* buttonAdd; + wxButton* buttonDel; + wxButton* okButton; + wxButton* cancelButton; + wxButton* upButton; + wxButton* downButton; + // + ListWx* m_OriginalListWx; // Original list + ListWx* m_CurrentListWx; //Configurable list + }; + } } -#endif // LISTCONFIGPANEL_H +#endif // LISTCONFIGDIALOGL_H 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 411644c..80def4e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.cxx @@ -58,13 +58,27 @@ namespace creaButtonContainer } } - sizer->Add(this->m_ListBox,1,wxGROW); + sizer->Add(this->m_ListBox, 1, wxGROW); } // ---------------------------------------------------------------------------------- ListWx::ListWx(wxWindow* parent, wxWindowID id, TFunctor* functor) + : wxPanel(parent, id) { + this->m_Functor = functor; + + wxBoxSizer* sizer = new wxBoxSizer(wxHORIZONTAL); + + this->SetSizer(sizer); + + this->m_ListBox = new wxListBox(this, -1); + this->m_FunctorEnabled = true; + + this->Connect(wxEVT_COMMAND_LISTBOX_SELECTED, + wxCommandEventHandler(ListWx::ListEvent)); + + sizer->Add(this->m_ListBox, 1, wxGROW); } // ---------------------------------------------------------------------------------- @@ -116,6 +130,13 @@ namespace creaButtonContainer return this->m_FunctorEnabled; } + // ---------------------------------------------------------------------------------- + wxListBox* + ListWx::GetListBox() const + { + return this->m_ListBox; + } + } //ecapseman } //ecapseman 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 4b682c8..e2ea60e 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/listWx.h @@ -72,6 +72,10 @@ namespace creaButtonContainer bool IsFunctorEnabled() const; + wxListBox* + GetListBox() const; + + private: wxListBox* m_ListBox; diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx index 23feb3e..a7a0fc1 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx @@ -71,8 +71,8 @@ namespace creaPanelButtonContainer //Top Panel this->m_AuiManager->AddPane(this->m_ButtonContainerPanel, wxAuiPaneInfo().Name(_T("ButtonContainerPanel")).DefaultPane().Caption( - _("ButtonContainerPanel")).PinButton().CaptionVisible( - true).CloseButton(false).Center().Resizable(true)); + _("ButtonContainerPanel")).PinButton().CaptionVisible(true).CloseButton( + false).Center().Resizable(true)); } else if (type == 1) { @@ -93,14 +93,61 @@ namespace creaPanelButtonContainer //Top Panel this->m_AuiManager->AddPane(this->m_ListWxPanel, wxAuiPaneInfo().Name(_T("ListContainerPanel")).DefaultPane().Caption( - _("ListContainerPanel")).PinButton().CaptionVisible( - true).CloseButton(false).Center().Resizable(true)); + _("ListContainerPanel")).PinButton().CaptionVisible(true).CloseButton( + false).Center().Resizable(true)); } - else if(type == 2) + else if (type == 2) { + TConcreteFunctor* lFunctor = new TConcreteFunctor(this, + &PanelButtonContainer::GenericListEvent); - } + this->m_EventPanel = new wxPanel(this); + + this->m_PanelUp = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, + wxTAB_TRAVERSAL, _T("ListConfigContainerPanel")); + wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL); + + //======= + wxBoxSizer* listSizer = new wxBoxSizer(wxVERTICAL); + + //Original List + this->m_ListWxPanel = new ListWx(this->m_PanelUp, -1, + this->m_ButtonContainerSettings->GetItemsVector(), lFunctor); + this->m_ListWxPanel->Show(false); + //Configurable list + this->m_CurrentWxPanel = new ListWx(this->m_PanelUp, -1, lFunctor); + listSizer->Add(this->m_CurrentWxPanel, 0, wxEXPAND); + listSizer->Add(this->m_ListWxPanel, 0, wxEXPAND); + mainSizer->Add(listSizer, 0, wxEXPAND | wxALL, 7); + //======= + //todo change button to bitmap + wxBoxSizer* buttonSizer = new wxBoxSizer(wxVERTICAL); + + this->m_ConfigButton = new wxButton(this->m_PanelUp, -1, _("Configurar"), wxDefaultPosition, + wxDefaultSize, 0, wxDefaultValidator, _("Configurar")); + + buttonSizer->Add(this->m_ConfigButton, 0, wxEXPAND); + mainSizer->Add(buttonSizer, 0, wxEXPAND | wxALL, 14); + //======= + + this->m_PanelUp->SetSizer(mainSizer); + + //Bottom Panel + this->m_AuiManager->AddPane(this->m_EventPanel, + wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible( + true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable( + true)); + //Top Panel + this->m_AuiManager->AddPane(this->m_PanelUp, + wxAuiPaneInfo().Name(_T("ListContainerPanel")).DefaultPane().Caption( + _("ListContainerPanel")).PinButton().CaptionVisible(true).CloseButton( + false).Center().Resizable(true)); + + this->Connect(wxEVT_COMMAND_BUTTON_CLICKED, + wxCommandEventHandler(PanelButtonContainer::OnConfigButton)); + + } //MLER @@ -181,6 +228,23 @@ namespace creaPanelButtonContainer } // ---------------------------------------------------------------------------------- + void + PanelButtonContainer::OnConfigButton ( wxCommandEvent& event ) + { + + this->m_ListConfigDialog = new ListConfigDialog(this,-1,_("Config"), this->m_ListWxPanel, this->m_CurrentWxPanel); + + std::cout<< "Button Event"<m_ListConfigDialog->ShowModal();//Show Dialog + this->m_CurrentWxPanel->Reparent(this->m_PanelUp); + this->m_CurrentWxPanel->Show(true); + this->m_CurrentWxPanel->SetFunctorEnabled(true); + this->m_CurrentWxPanel->Update(); + this->m_AuiManager->Update( ); + this->m_EventPanel->Show(false); + } + // ---------------------------------------------------------------------------------- }//ecapseman diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.h index c7e5c09..096cedd 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.h @@ -38,12 +38,12 @@ #include #include +#include "listConfigDialog.h" #include "containerSettings.h" #include "buttonContainerPanel.h" #include "buttonContainerSettings.h" #include "functor.h" #include "listWx.h" -#include "listConfigPanel.h" /*! @namespace * @brief Contains the creaPanelButtonContainer library included in creaMaracasVisu. @@ -74,10 +74,10 @@ namespace creaPanelButtonContainer * This class inherits from wxPanel and contains a wxListBox */ typedef creaButtonContainer::view::ListWx ListWx; - /*! typedef creaPanelButtonContainer::ListConfigPanel ListConfigPanel; + /*! typedef creaPanelButtonContainer::ListConfigDialog ListConfigDialog; * @brief Defines a ListConfigPanel to configure */ - typedef creaPanelButtonContainer::ListConfigPanel ListConfigPanel; + typedef creaButtonContainer::view::ListConfigDialog ListConfigDialog; //End MLER // ---------------------------------------------------------------------------------- @@ -120,6 +120,8 @@ namespace creaPanelButtonContainer void UpdateListPanel(const std::string &buttonName); + void + OnConfigButton(wxCommandEvent& event); // ---------------------------------------------------------------------------------- private: @@ -132,8 +134,12 @@ namespace creaPanelButtonContainer //MLER ListWx* m_ListWxPanel; - - DECLARE_EVENT_TABLE() + ListConfigDialog* m_ListConfigDialog; + // + wxPanel* m_PanelUp; + ListWx* m_CurrentWxPanel; + //todo change to bitmap + wxButton* m_ConfigButton;DECLARE_EVENT_TABLE() //!