/*# --------------------------------------------------------------------- # # 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(); } } }