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,
55 wxAUI_MGR_DEFAULT | wxFULL_REPAINT_ON_RESIZE);
59 //Class that manages the event!!!
61 TConcreteFunctor* functor = new TConcreteFunctor(this,
62 &PanelButtonContainer::GenericButtonEvent);
63 //end of the event definition
64 this->m_EventPanel = new wxPanel(this);
65 this->m_ButtonContainerPanel = new ButtonContainerPanel(this,
66 this->m_ButtonContainerSettings->GetButtonGroupSettings(functor));
68 this->m_AuiManager->AddPane(this->m_EventPanel,
69 wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
70 true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
73 this->m_AuiManager->AddPane(this->m_ButtonContainerPanel,
74 wxAuiPaneInfo().Name(_T("ButtonContainerPanel")).DefaultPane().Caption(
75 _("ButtonContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
76 false).Center().Resizable(true));
81 TConcreteFunctor* lFunctor = new TConcreteFunctor(this,
82 &PanelButtonContainer::GenericListEvent);
84 this->m_EventPanel = new wxPanel(this);
85 std::cout << "tipo 1; new LIstWx" << std::endl;
87 this->m_ListWxPanel = new ListWx(this, -1,
88 this->m_ButtonContainerSettings->GetItemsVector(), lFunctor);
91 this->m_AuiManager->AddPane(this->m_EventPanel,
92 wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
93 true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
96 this->m_AuiManager->AddPane(this->m_ListWxPanel,
97 wxAuiPaneInfo().Name(_T("ListContainerPanel")).DefaultPane().Caption(
98 _("ListContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
99 false).Center().Resizable(true));
103 TConcreteFunctor* lFunctor = new TConcreteFunctor(this,
104 &PanelButtonContainer::GenericListEvent);
106 this->m_EventPanel = new wxPanel(this);
108 this->m_PanelUp = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize,
109 wxTAB_TRAVERSAL, _T("ListConfigContainerPanel"));
110 wxGridBagSizer* mainSizer = new wxGridBagSizer(0, 0);
111 mainSizer->AddGrowableCol(1);
112 mainSizer->AddGrowableRow(0);
116 this->m_ListWxPanel = new ListWx(this->m_PanelUp, -1,
117 this->m_ButtonContainerSettings->GetItemsVector(), lFunctor);
118 this->m_ListWxPanel->Show(false);
120 this->m_CurrentWxPanel = new ListWx(this->m_PanelUp, -1, lFunctor);
122 mainSizer->Add(this->m_ListWxPanel, wxGBPosition(0, 0), wxDefaultSpan,
123 wxALL | wxEXPAND | wxALIGN_CENTER_HORIZONTAL
124 | wxALIGN_CENTER_VERTICAL, 5);
125 mainSizer->Add(this->m_CurrentWxPanel, wxGBPosition(0, 1), wxDefaultSpan,
126 wxALL | wxEXPAND | wxALIGN_CENTER_HORIZONTAL
127 | wxALIGN_CENTER_VERTICAL, 5);
129 this->m_ConfigButton = new wxBitmapButton(this->m_PanelUp, -1,
130 wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW,
131 wxDefaultValidator, _T("Config"));
133 mainSizer->Add(this->m_ConfigButton, wxGBPosition(1, 2), wxDefaultSpan,
134 wxALL | wxALIGN_CENTER_HORIZONTAL | wxALIGN_CENTER_VERTICAL, 5);
138 this->m_PanelUp->SetSizer(mainSizer);
139 mainSizer->Fit(this->m_PanelUp);
140 mainSizer->SetSizeHints(this->m_PanelUp);
143 this->m_AuiManager->AddPane(this->m_EventPanel,
144 wxAuiPaneInfo().Name(_T("EventPanel")).Caption(_("EventPanel")).CaptionVisible(
145 true).MinimizeButton().MaximizeButton().CloseButton(false).Center().Resizable(
148 this->m_AuiManager->AddPane(this->m_PanelUp,
149 wxAuiPaneInfo().Name(_T("ListContainerPanel")).DefaultPane().Caption(
150 _("ListContainerPanel")).PinButton().CaptionVisible(true).CloseButton(
151 false).Center().Resizable(true));
153 this->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
154 wxCommandEventHandler(PanelButtonContainer::OnConfigButton));
160 this->m_AuiManager->Update();
162 // ----------------------------------------------------------------------------------
163 PanelButtonContainer::~PanelButtonContainer()
166 // ----------------------------------------------------------------------------------
167 void PanelButtonContainer::UpdatePanel(const std::string &buttonName)
171 //Hiding the last CartoSettingsPanel
172 this->m_EventPanel->Show(false);
173 //Finding the CartoSettingsPanel of the ButtonClicket
174 this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelButton(
176 //changing the parent of the panel!
177 if (this->m_EventPanel->GetParent() != this)
179 this->m_EventPanel->Reparent(this);
182 this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
183 //Updating the manager
184 this->m_AuiManager->Update();
186 catch (const std::exception& e)
189 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
190 << "exception: " << e.what() << std::endl;
191 std::cout << "Maybe the panel of the button is NULL" << std::endl;
195 // ----------------------------------------------------------------------------------
196 void PanelButtonContainer::GenericButtonEvent(const std::string &buttonName)
198 this->UpdatePanel(buttonName);
201 // ----------------------------------------------------------------------------------
203 void PanelButtonContainer::GenericListEvent(const std::string &buttonName)
205 this->UpdateListPanel(buttonName);
208 // ----------------------------------------------------------------------------------
209 void PanelButtonContainer::UpdateListPanel(const std::string &buttonName)
213 this->m_EventPanel->Show(false);
214 this->m_EventPanel = this->m_ButtonContainerSettings->GetPanelList(
217 if (this->m_EventPanel->GetParent() != this)
219 this->m_EventPanel->Reparent(this);
222 this->m_AuiManager->GetPane(_T("EventPanel")).window = this->m_EventPanel;
223 //Updating the manager
224 this->m_AuiManager->Update();
226 } catch (const std::exception& e)
229 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
230 << "exception: " << e.what() << std::endl;
231 std::cout << "Maybe the panel of the list is NULL" << std::endl;
236 // ----------------------------------------------------------------------------------
237 void PanelButtonContainer::OnConfigButton(wxCommandEvent& event)
240 this->m_ListConfigDialog = new ListConfigDialog(this, -1, _("Config"),
241 this->m_ListWxPanel, this->m_CurrentWxPanel);
243 std::cout << "Button Event" << std::endl;
245 this->m_ListConfigDialog->ShowModal(); //Show Dialog
246 this->m_CurrentWxPanel->Reparent(this->m_PanelUp);
247 this->m_CurrentWxPanel->Show(true);
248 this->m_CurrentWxPanel->SetFunctorEnabled(true);
249 this->m_CurrentWxPanel->Update();
250 this->m_ListWxPanel->Show(false);
251 this->m_EventPanel->Show(false);
252 this->m_AuiManager->Update();
255 // ----------------------------------------------------------------------------------