1 /*# ---------------------------------------------------------------------
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
5 # Authors : Eduardo Davila, Frederic Cervenansky, Claire Mouton
6 # Previous Authors : Laurent Guigues, Jean-Pierre Roux
7 # CreaTools website : www.creatis.insa-lyon.fr/site/fr/creatools_accueil
9 # This software is governed by the CeCILL-B license under French law and
10 # abiding by the rules of distribution of free software. You can use,
11 # modify and/ or redistribute the software under the terms of the CeCILL-B
12 # license as circulated by CEA, CNRS and INRIA at the following URL
13 # http://www.cecill.info/licences/Licence_CeCILL-B_V1-en.html
14 # or in the file LICENSE.txt.
16 # As a counterpart to the access to the source code and rights to copy,
17 # modify and redistribute granted by the license, users are provided only
18 # with a limited warranty and the software's author, the holder of the
19 # economic rights, and the successive licensors have only limited
22 # The fact that you are presently reading this means that you have had
23 # knowledge of the CeCILL-B license and that you accept its terms.
24 # ------------------------------------------------------------------------ */
26 #include "listConfigDialog.h"
28 namespace creaButtonContainer
33 ListConfigDialog::ListConfigDialog(wxWindow* parent, wxWindowID id,
34 const wxString& title, ListWx* modelList, ListWx* currentList)
35 : wxDialog(parent, id, title)
37 std::cout << "MLER | ListConfigPanel::ListConfigPanel()" << std::endl;
39 this->m_OriginalListWx = modelList;
40 this->m_OriginalListWx->Reparent(this);
41 this->m_OriginalListWx->Show(true);
42 this->m_OriginalListWx->SetFunctorEnabled(false);
43 //this->m_OriginalListWx->FillList();
45 this->m_CurrentListWx = currentList;
46 this->m_CurrentListWx->Reparent(this);
47 this->m_CurrentListWx->SetFunctorEnabled(false);
48 this->m_CurrentListWx->Show(true);
49 //this->m_CurrentListWx->FillList();
51 wxFlexGridSizer* sizer = new wxFlexGridSizer(2, 1, 0, 0);
52 this->SetSizer(sizer);
54 wxBoxSizer* sizerUp = new wxBoxSizer(wxHORIZONTAL);
56 sizerUp->Add(this->m_OriginalListWx, 0, wxEXPAND);
59 wxPanel* panel2 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
60 wxTAB_TRAVERSAL, _T("Panel 2"));
61 wxBoxSizer* sizerList2 = new wxBoxSizer(wxVERTICAL);
63 buttonAdd = new wxButton(panel2, 1, _(">"), wxDefaultPosition,
64 wxDefaultSize, 0, wxDefaultValidator, _T("Add"));
65 sizerList2->Add(buttonAdd, 0, wxEXPAND);
67 buttonDel = new wxButton(panel2, 2, _("<"), wxDefaultPosition,
68 wxDefaultSize, 0, wxDefaultValidator, _T("Delete"));
69 sizerList2->Add(buttonDel, 0, wxEXPAND);
71 panel2->SetSizer(sizerList2);
72 sizerList2->Fit(panel2);
73 sizerList2->SetSizeHints(panel2);
75 sizerUp->Add(panel2, 0, wxEXPAND);
79 sizerUp->Add(this->m_CurrentListWx, 0, wxEXPAND);
82 wxPanel* panel5 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
83 wxTAB_TRAVERSAL, _T("Panel 5"));
84 wxBoxSizer* sizerList4 = new wxBoxSizer(wxVERTICAL);
86 upButton = new wxButton(panel5, 3, _("/\\"), wxDefaultPosition,
87 wxDefaultSize, 0, wxDefaultValidator, _T("upButton"));
88 sizerList4->Add(upButton, 0, wxEXPAND);
90 downButton = new wxButton(panel5, 4, _("V"), wxDefaultPosition,
91 wxDefaultSize, 0, wxDefaultValidator, _T("downButton"));
92 sizerList4->Add(downButton, 0, wxEXPAND);
94 panel5->SetSizer(sizerList4);
95 sizerList4->Fit(panel5);
96 sizerList4->SetSizeHints(panel5);
97 sizerUp->Add(panel5, 0, wxEXPAND);
100 wxBoxSizer* sizerBotones = new wxBoxSizer(wxHORIZONTAL);
101 wxPanel* panel4 = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
102 wxTAB_TRAVERSAL, _T("Panel 4"));
104 okButton = new wxButton(panel4, 5, _("Ok"), wxPoint(0, 8), wxDefaultSize,
105 0, wxDefaultValidator, _T("Ok"));
106 cancelButton = new wxButton(panel4, 6, _("Cancel"), wxPoint(88, 8),
107 wxDefaultSize, 0, wxDefaultValidator, _T("Cancel"));
109 sizerBotones->Add(panel4, 0, wxEXPAND);
111 sizer->Add(sizerUp, 0, wxEXPAND);
112 sizer->Add(sizerBotones, 1, wxALL | wxALIGN_CENTER_HORIZONTAL);
114 //---------------------------------------------------------------------------------------------
118 Connect(6, wxEVT_COMMAND_BUTTON_CLICKED,
119 (wxObjectEventFunction) & ListConfigDialog::OnCancel);
121 //EventoSeleccionarLista
122 //Connect(wxEVT_COMMAND_LISTBOX_SELECTED,wxCommandEventHandler(ListConfigPanel::ListItemEvent));
125 Connect(1, wxEVT_COMMAND_BUTTON_CLICKED,
126 (wxObjectEventFunction) & ListConfigDialog::OnAdd);
129 Connect(5, wxEVT_COMMAND_BUTTON_CLICKED,
130 (wxObjectEventFunction) & ListConfigDialog::OnOk);
133 Connect(2, wxEVT_COMMAND_BUTTON_CLICKED,
134 (wxObjectEventFunction) & ListConfigDialog::OnDelete);
137 Connect(3, wxEVT_COMMAND_BUTTON_CLICKED,
138 (wxObjectEventFunction) & ListConfigDialog::OnMoveUp);
141 Connect(4, wxEVT_COMMAND_BUTTON_CLICKED,
142 (wxObjectEventFunction) & ListConfigDialog::OnMoveDown);
146 ListConfigDialog::~ListConfigDialog()
151 void ListConfigDialog::OnAdd(wxCommandEvent& event)
153 wxString itSelect = m_OriginalListWx->GetListBox()->GetStringSelection();
155 std::cout << "Count = " << this->m_CurrentListWx->GetListBox()->GetCount()
157 if (!itSelect.IsEmpty())
159 int v = this->m_CurrentListWx->GetListBox()->FindString(itSelect);
162 this->m_CurrentListWx->GetListBox()->Append(itSelect);
163 this->m_CurrentListWx->GetListBox()->Update();
168 void ListConfigDialog::OnDelete(wxCommandEvent& event)
170 wxString itSelect = m_CurrentListWx->GetListBox()->GetStringSelection();
172 if (!itSelect.IsEmpty())
174 int v = this->m_CurrentListWx->GetListBox()->FindString(itSelect);
177 this->m_CurrentListWx->GetListBox()->Delete(v);
178 this->m_CurrentListWx->GetListBox()->Update();
182 void ListConfigDialog::OnMoveUp(wxCommandEvent& event)
184 wxString itSelect = m_CurrentListWx->GetListBox()->GetStringSelection();
186 if (!itSelect.IsEmpty())
188 int v = this->m_CurrentListWx->GetListBox()->FindString(itSelect);
191 this->m_CurrentListWx->GetListBox()->Delete(v);
192 this->m_CurrentListWx->GetListBox()->Insert(itSelect, v - 1);
193 this->m_CurrentListWx->GetListBox()->Update();
198 void ListConfigDialog::OnMoveDown(wxCommandEvent& event)
200 wxString itSelect = m_CurrentListWx->GetListBox()->GetStringSelection();
202 if (!itSelect.IsEmpty())
204 int v = this->m_CurrentListWx->GetListBox()->FindString(itSelect);
205 std::cout << "Count = "
206 << this->m_CurrentListWx->GetListBox()->GetCount() << std::endl;
207 if ((v < this->m_CurrentListWx->GetListBox()->GetCount() - 1)
210 this->m_CurrentListWx->GetListBox()->Delete(v);
211 this->m_CurrentListWx->GetListBox()->Insert(itSelect, v + 1);
212 this->m_CurrentListWx->GetListBox()->Update();
217 void ListConfigDialog::OnOk(wxCommandEvent& event)
221 void ListConfigDialog::OnCancel(wxCommandEvent& event)