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"
36 namespace creaPanelButtonContainer
38 BEGIN_EVENT_TABLE(PanelButtonContainer,wxPanel)
39 //EVT_LIST_ITEM_SELECTED(-1, ListWx::ListEvent)
41 //(*EventTable(ButtonContainerPanel)
44 // ----------------------------------------------------------------------------------
45 typedef creaButtonContainer::model::TConcreteFunctor< PanelButtonContainer > TConcreteFunctor;
46 // ----------------------------------------------------------------------------------
47 PanelButtonContainer::PanelButtonContainer( wxWindow* parent, ButtonContainerSettings* bcSettings, int type )
48 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer") )
50 std::cout<< "MLER | creaPanelButtonContainer:: PanelButtonContainer() " << std::endl;
52 this->m_ButtonContainerSettings = bcSettings;
55 //Class that manages the event!!!
57 TConcreteFunctor* functor = new TConcreteFunctor( this, &PanelButtonContainer::GenericButtonEvent );
58 // TConcreteFunctor* functor = new TConcreteFunctor( this->m_ButtonPanel, &PanelButtonContainer::GenericButtonEvent );
59 //end of the event definition
61 TConcreteFunctor* lFunctor = new TConcreteFunctor( this, &PanelButtonContainer::GenericListEvent );
64 //Using AuiManager to Manage the Panels
65 this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
70 this->m_ButtonPanel = new wxPanel( this );
71 std::cout << "tipo 0; new ButtonContainerPanel"<<std::endl;
72 this->m_ButtonContainerPanel = new ButtonContainerPanel( this, this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ) );
74 this->m_AuiManager->AddPane( this->m_ButtonContainerPanel,wxAuiPaneInfo( ).Name( _T("ButtonContainerPanel") ).Caption(_("ButtonContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) );
75 this->m_AuiManager->AddPane(this->m_ButtonPanel, wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("ButtonPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
79 this->m_ListPanel = new wxPanel(this);
80 std::cout << "tipo 1; new LIstWx"<<std::endl;
81 this->mylist = new ListWx(this, -1,this->m_ButtonContainerSettings->GetItemsMap(), lFunctor);
83 this->m_AuiManager->AddPane( this->mylist,wxAuiPaneInfo( ).Name( _T("ListContainerPanel") ).Caption(_("ListContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) );
84 this->m_AuiManager->AddPane(this->m_ListPanel, wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption( _("ListPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
89 this->m_ListPanel = new wxPanel(this);
91 panelUp = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ListConfigContainerPanel"));
92 wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL);
95 wxBoxSizer* listSizer = new wxBoxSizer(wxVERTICAL);
97 this->mylist = new ListWx(panelUp,-1,this->m_ButtonContainerSettings->GetItemsMap(),lFunctor);
98 this->mylist->Show(false);
100 this->myConfiglist = new ListWx(panelUp,-1, empty,lFunctor);
101 listSizer->Add(this->myConfiglist,0,wxEXPAND);
102 listSizer->Add(this->mylist,0,wxEXPAND);
103 mainSizer->Add(listSizer,0,wxEXPAND|wxALL,7);
106 wxBoxSizer* buttonSizer = new wxBoxSizer(wxVERTICAL);
108 button = new wxButton(panelUp, -1, _("Configurar"),
109 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Configurar"));
111 buttonSizer->Add(button,0,wxEXPAND);
112 mainSizer->Add(buttonSizer,0,wxEXPAND|wxALL,14);
115 panelUp->SetSizer(mainSizer);
117 this->m_AuiManager->AddPane( panelUp,wxAuiPaneInfo( ).Name( _T("ListConfigContainerPanel") ).Caption(_("ListConfigContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) );
118 this->m_AuiManager->AddPane(this->m_ListPanel, wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption( _("ListPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
124 this->m_AuiManager->Update( );
125 //m_listConfigPanel = new ListConfigPanel(this,1,_("Configuracion"),mylist);
127 this->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
128 wxCommandEventHandler(PanelButtonContainer::ButtonEvent));
131 // ----------------------------------------------------------------------------------
132 PanelButtonContainer::~PanelButtonContainer( )
135 // ----------------------------------------------------------------------------------
137 PanelButtonContainer::UpdatePanel( const std::string &buttonName )
141 std::cout<< "MLER | creaPanelButtonContainer:: UpdatePanel() " << std::endl;
143 //Hiding the last CartoSettingsPanel
144 this->m_ButtonPanel->Show( false );
145 //Finding the CartoSettingsPanel of the ButtonClicket
146 this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton(buttonName );
147 std::cout<< buttonName << "---testEvento 2 "<<std::endl;
148 //changing the parent of the panel!
149 if ( this->m_ButtonPanel->GetParent( ) != this )
151 this->m_ButtonPanel->Reparent( this );
154 this->m_AuiManager->GetPane( _T("ButtonPanel") ).window = this->m_ButtonPanel;
155 //Updating the manager
156 this->m_AuiManager->Update( );
158 catch ( const std::exception& e )
161 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
162 << "exception: " << e.what( ) << std::endl;
163 std::cout << "Maybe the panel of the button is NULL" << std::endl;
167 // ----------------------------------------------------------------------------------
169 PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
171 std::cout<< "MLER | creaPanelButtonContainer:: GenericButtonEvent() " << std::endl;
172 std::cout<< buttonName << "---testEvento 1 "<<std::endl;
173 this->UpdatePanel( buttonName );
175 // ----------------------------------------------------------------------------------
178 PanelButtonContainer::UpdateListPanel( const std::string &buttonName )
182 std::cout<< "MLER | creaPanelButtonContainer:: UpdateListPanel() " << std::endl;
183 std::cout<< buttonName << " --- test 2 "<<std::endl;
185 this->m_ListPanel->Show( false );
187 this->m_ListPanel = this->m_ButtonContainerSettings->GetPanelList(buttonName );
189 if ( this->m_ListPanel->GetParent( ) != this )
191 this->m_ListPanel->Reparent( this );
194 this->m_AuiManager->GetPane( _T("ListPanel") ).window = this->m_ListPanel;
195 //Updating the manager
196 this->m_AuiManager->Update( );
198 }catch( const std::exception& e )
201 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
202 << "exception: " << e.what( ) << std::endl;
203 std::cout << "Maybe the panel of the list is NULL" << std::endl;
209 PanelButtonContainer::GenericListEvent( const std::string &buttonName )
211 std::cout<< "MLER | creaPanelButtonContainer:: GenericListEvent() " << std::endl;
212 std::cout<< buttonName << " --- test 3 "<<std::endl;
213 this->UpdateListPanel( buttonName );
217 PanelButtonContainer::ButtonEvent ( wxCommandEvent& event )
220 m_listConfigPanel = new ListConfigPanel(this,-1,_("Configuracion"), mylist, myConfiglist);
222 std::cout<< "BUtton Event"<<std::endl;
224 m_listConfigPanel->ShowModal();
225 this->myConfiglist->Reparent(panelUp);
226 this->myConfiglist->Show(true);
227 this->myConfiglist->SetFunctorEnabled(true);
228 this->myConfiglist->Update();
229 this->m_AuiManager->Update( );
230 this->m_ListPanel->Show(false);