--- /dev/null
+/*# ---------------------------------------------------------------------
+ #
+ # 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();
+ }
+ }
+}
//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)
{
//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
}
// ----------------------------------------------------------------------------------
+ void
+ PanelButtonContainer::OnConfigButton ( wxCommandEvent& event )
+ {
+
+ this->m_ListConfigDialog = new ListConfigDialog(this,-1,_("Config"), this->m_ListWxPanel, this->m_CurrentWxPanel);
+
+ std::cout<< "Button Event"<<std::endl;
+
+ this->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