]> Creatis software - creaMaracasVisu.git/blob
23feb3e1534987a2b929499142042159ebfef691
[creaMaracasVisu.git] /
1 /*# ---------------------------------------------------------------------
2  #
3  # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4  #                        pour la Sant�)
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
8  #
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.
15  #
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
20  #  liability.
21  #
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  # ------------------------------------------------------------------------ */
25
26 /*!
27  * @file creaPanelButtonContainer.h
28  * @brief implements PanelButtonContainer class
29  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
30  * @date  2011-06-02
31  */
32
33 #include "creaPanelButtonContainer.h"
34
35 namespace creaPanelButtonContainer
36 {
37         BEGIN_EVENT_TABLE(PanelButtonContainer,wxPanel)
38 //EVT_LIST_ITEM_SELECTED(-1, ListWx::ListEvent)
39
40 //(*EventTable(ButtonContainerPanel)
41 //*)
42         END_EVENT_TABLE()
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"))
50         {
51                 this->m_ButtonContainerSettings = bcSettings;
52
53                 //Using AuiManager to Manage the Panels
54                 this->m_AuiManager = new wxAuiManager(this, wxAUI_MGR_DEFAULT);
55
56                 if (type == 0)
57                 {
58                         //Class that manages the event!!!
59                         //EED 20/01/2012
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));
66                         //Bottom Panel
67                         this->m_AuiManager->AddPane(this->m_EventPanel,
68                                         wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
69                                                         true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
70                                                         true));
71                         //Top Panel
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));
76                 }
77                 else if (type == 1)
78                 {
79                         TConcreteFunctor* lFunctor = new TConcreteFunctor(this,
80                                         &PanelButtonContainer::GenericListEvent);
81
82                         this->m_EventPanel = new wxPanel(this);
83                         std::cout << "tipo 1; new LIstWx" << std::endl;
84
85                         this->m_ListWxPanel = new ListWx(this, -1,
86                                         this->m_ButtonContainerSettings->GetItemsVector(), lFunctor);
87
88                         //Bottom Panel
89                         this->m_AuiManager->AddPane(this->m_EventPanel,
90                                         wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
91                                                         true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
92                                                         true));
93                         //Top Panel
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));
98                 }
99                 else if(type == 2)
100                 {
101
102                 }
103
104
105                 //MLER
106
107                 this->m_AuiManager->Update();
108         }
109 // ----------------------------------------------------------------------------------
110         PanelButtonContainer::~PanelButtonContainer()
111         {
112         }
113 // ----------------------------------------------------------------------------------
114         void PanelButtonContainer::UpdatePanel(const std::string &buttonName)
115         {
116                 try
117                 {
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(
122                                         buttonName);
123                         //changing the parent of the panel!
124                         if (this->m_EventPanel->GetParent() != this)
125                         {
126                                 this->m_EventPanel->Reparent(this);
127                         }       //fi
128                                 //Panel Management
129                         this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
130                         //Updating the manager
131                         this->m_AuiManager->Update();
132                 }                       //yrt
133                 catch (const std::exception& e)
134                 {
135                         std::cerr
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;
139                         exit(1);
140                 }                       //hctac
141         }
142 // ----------------------------------------------------------------------------------
143         void PanelButtonContainer::GenericButtonEvent(const std::string &buttonName)
144         {
145                 this->UpdatePanel(buttonName);
146         }
147
148         // ----------------------------------------------------------------------------------
149         //MLER
150         void PanelButtonContainer::GenericListEvent(const std::string &buttonName)
151         {
152                 this->UpdateListPanel(buttonName);
153         }
154
155         // ----------------------------------------------------------------------------------
156         void PanelButtonContainer::UpdateListPanel(const std::string &buttonName)
157         {
158                 try
159                 {
160                         this->m_EventPanel->Show(false);
161                         this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelList(
162                                         buttonName);
163
164                         if (this->m_EventPanel->GetParent() != this)
165                         {
166                                 this->m_EventPanel->Reparent(this);
167                         }       //fi
168                                 //Panel Management
169                         this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
170                         //Updating the manager
171                         this->m_AuiManager->Update();
172
173                 } catch (const std::exception& e)
174                 {
175                         std::cerr
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;
179                         exit(1);
180                 }                                                       //hctac
181         }
182
183 // ----------------------------------------------------------------------------------
184
185 }//ecapseman
186