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 # ------------------------------------------------------------------------ */
27 * @file creaPanelButtonContainer.h
28 * @brief implements PanelButtonContainer class
29 * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
33 #include "creaPanelButtonContainer.h"
35 namespace creaPanelButtonContainer
37 BEGIN_EVENT_TABLE(PanelButtonContainer,wxPanel)
38 //EVT_LIST_ITEM_SELECTED(-1, ListWx::ListEvent)
40 //(*EventTable(ButtonContainerPanel)
43 // ----------------------------------------------------------------------------------
44 typedef creaButtonContainer::model::TConcreteFunctor< PanelButtonContainer > TConcreteFunctor;
45 // ----------------------------------------------------------------------------------
46 PanelButtonContainer::PanelButtonContainer(wxWindow* parent,
47 ButtonContainerSettings* bcSettings, int type)
48 : wxPanel(parent, -1, wxDefaultPosition, wxDefaultSize,
49 wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer"))
51 this->m_ButtonContainerSettings = bcSettings;
53 //Using AuiManager to Manage the Panels
54 this->m_AuiManager = new wxAuiManager(this, wxAUI_MGR_DEFAULT);
58 //Class that manages the event!!!
60 TConcreteFunctor* functor = new TConcreteFunctor(this,
61 &PanelButtonContainer::GenericButtonEvent);
62 //end of the event definition
63 this->m_EventPanel = new wxPanel(this);
64 this->m_ButtonContainerPanel = new ButtonContainerPanel(this,
65 this->m_ButtonContainerSettings->GetButtonGroupSettings(functor));
67 this->m_AuiManager->AddPane(this->m_EventPanel,
68 wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
69 true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
72 this->m_AuiManager->AddPane(this->m_ButtonContainerPanel,
73 wxAuiPaneInfo().Name(_T("ButtonContainerPanel")).DefaultPane().Caption(
74 _("ButtonContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
75 false).Center().Resizable(true));
79 TConcreteFunctor* lFunctor = new TConcreteFunctor(this,
80 &PanelButtonContainer::GenericListEvent);
82 this->m_EventPanel = new wxPanel(this);
83 std::cout << "tipo 1; new LIstWx" << std::endl;
85 this->m_ListWxPanel = new ListWx(this, -1,
86 this->m_ButtonContainerSettings->GetItemsVector(), lFunctor);
89 this->m_AuiManager->AddPane(this->m_EventPanel,
90 wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
91 true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
94 this->m_AuiManager->AddPane(this->m_ListWxPanel,
95 wxAuiPaneInfo().Name(_T("ListContainerPanel")).DefaultPane().Caption(
96 _("ListContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
97 false).Center().Resizable(true));
101 TConcreteFunctor* lFunctor = new TConcreteFunctor(this,
102 &PanelButtonContainer::GenericListEvent);
104 this->m_EventPanel = new wxPanel(this);
106 this->m_PanelUp = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
107 wxTAB_TRAVERSAL, _T("ListConfigContainerPanel"));
108 wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL);
111 wxBoxSizer* listSizer = new wxBoxSizer(wxVERTICAL);
114 this->m_ListWxPanel = new ListWx(this->m_PanelUp, -1,
115 this->m_ButtonContainerSettings->GetItemsVector(), lFunctor);
116 this->m_ListWxPanel->Show(false);
118 this->m_CurrentWxPanel = new ListWx(this->m_PanelUp, -1, lFunctor);
119 listSizer->Add(this->m_CurrentWxPanel, 0, wxEXPAND);
120 listSizer->Add(this->m_ListWxPanel, 0, wxEXPAND);
121 mainSizer->Add(listSizer, 0, wxEXPAND | wxALL, 7);
124 //todo change button to bitmap
125 wxBoxSizer* buttonSizer = new wxBoxSizer(wxVERTICAL);
127 this->m_ConfigButton = new wxButton(this->m_PanelUp, -1, _("Configurar"), wxDefaultPosition,
128 wxDefaultSize, 0, wxDefaultValidator, _("Configurar"));
130 buttonSizer->Add(this->m_ConfigButton, 0, wxEXPAND);
131 mainSizer->Add(buttonSizer, 0, wxEXPAND | wxALL, 14);
134 this->m_PanelUp->SetSizer(mainSizer);
137 this->m_AuiManager->AddPane(this->m_EventPanel,
138 wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
139 true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
142 this->m_AuiManager->AddPane(this->m_PanelUp,
143 wxAuiPaneInfo().Name(_T("ListContainerPanel")).DefaultPane().Caption(
144 _("ListContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
145 false).Center().Resizable(true));
147 this->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
148 wxCommandEventHandler(PanelButtonContainer::OnConfigButton));
154 this->m_AuiManager->Update();
156 // ----------------------------------------------------------------------------------
157 PanelButtonContainer::~PanelButtonContainer()
160 // ----------------------------------------------------------------------------------
161 void PanelButtonContainer::UpdatePanel(const std::string &buttonName)
165 //Hiding the last CartoSettingsPanel
166 this->m_EventPanel->Show(false);
167 //Finding the CartoSettingsPanel of the ButtonClicket
168 this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelButton(
170 //changing the parent of the panel!
171 if (this->m_EventPanel->GetParent() != this)
173 this->m_EventPanel->Reparent(this);
176 this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
177 //Updating the manager
178 this->m_AuiManager->Update();
180 catch (const std::exception& e)
183 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
184 << "exception: " << e.what() << std::endl;
185 std::cout << "Maybe the panel of the button is NULL" << std::endl;
189 // ----------------------------------------------------------------------------------
190 void PanelButtonContainer::GenericButtonEvent(const std::string &buttonName)
192 this->UpdatePanel(buttonName);
195 // ----------------------------------------------------------------------------------
197 void PanelButtonContainer::GenericListEvent(const std::string &buttonName)
199 this->UpdateListPanel(buttonName);
202 // ----------------------------------------------------------------------------------
203 void PanelButtonContainer::UpdateListPanel(const std::string &buttonName)
207 this->m_EventPanel->Show(false);
208 this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelList(
211 if (this->m_EventPanel->GetParent() != this)
213 this->m_EventPanel->Reparent(this);
216 this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
217 //Updating the manager
218 this->m_AuiManager->Update();
220 } catch (const std::exception& e)
223 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
224 << "exception: " << e.what() << std::endl;
225 std::cout << "Maybe the panel of the list is NULL" << std::endl;
230 // ----------------------------------------------------------------------------------
232 PanelButtonContainer::OnConfigButton ( wxCommandEvent& event )
235 this->m_ListConfigDialog = new ListConfigDialog(this,-1,_("Config"), this->m_ListWxPanel, this->m_CurrentWxPanel);
237 std::cout<< "Button Event"<<std::endl;
239 this->m_ListConfigDialog->ShowModal();//Show Dialog
240 this->m_CurrentWxPanel->Reparent(this->m_PanelUp);
241 this->m_CurrentWxPanel->Show(true);
242 this->m_CurrentWxPanel->SetFunctorEnabled(true);
243 this->m_CurrentWxPanel->Update();
244 this->m_AuiManager->Update( );
245 this->m_EventPanel->Show(false);
247 // ----------------------------------------------------------------------------------