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(
75 true).CloseButton(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(
97 true).CloseButton(false).Center().Resizable(true));
107 this->m_AuiManager->Update();
109 // ----------------------------------------------------------------------------------
110 PanelButtonContainer::~PanelButtonContainer()
113 // ----------------------------------------------------------------------------------
114 void PanelButtonContainer::UpdatePanel(const std::string &buttonName)
118 //Hiding the last CartoSettingsPanel
119 this->m_EventPanel->Show(false);
120 //Finding the CartoSettingsPanel of the ButtonClicket
121 this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelButton(
123 //changing the parent of the panel!
124 if (this->m_EventPanel->GetParent() != this)
126 this->m_EventPanel->Reparent(this);
129 this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
130 //Updating the manager
131 this->m_AuiManager->Update();
133 catch (const std::exception& e)
136 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
137 << "exception: " << e.what() << std::endl;
138 std::cout << "Maybe the panel of the button is NULL" << std::endl;
142 // ----------------------------------------------------------------------------------
143 void PanelButtonContainer::GenericButtonEvent(const std::string &buttonName)
145 this->UpdatePanel(buttonName);
148 // ----------------------------------------------------------------------------------
150 void PanelButtonContainer::GenericListEvent(const std::string &buttonName)
152 this->UpdateListPanel(buttonName);
155 // ----------------------------------------------------------------------------------
156 void PanelButtonContainer::UpdateListPanel(const std::string &buttonName)
160 this->m_EventPanel->Show(false);
161 this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelList(
164 if (this->m_EventPanel->GetParent() != this)
166 this->m_EventPanel->Reparent(this);
169 this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
170 //Updating the manager
171 this->m_AuiManager->Update();
173 } catch (const std::exception& e)
176 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
177 << "exception: " << e.what() << std::endl;
178 std::cout << "Maybe the panel of the list is NULL" << std::endl;
183 // ----------------------------------------------------------------------------------