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 ) );
88 /*this->m_ListPanel = new wxPanel(this);
89 std::cout << "tipo 2; new LIstWx"<<std::endl;
90 this->mylist = new ListWx(this, -1,this->m_ButtonContainerSettings->GetItemsMap(), lFunctor);
91 this->mylist->Show(false);
93 this->myConfiglist = new ListWx(this,-1, empty,lFunctor);
95 wxPanel* panelButton = new wxPanel(this);
96 wxBoxSizer* buttonSizer = new wxBoxSizer(wxHORIZONTAL);
97 button = new wxButton(panelButton, -1, _("Configurar"),
98 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Configurar"));
99 buttonSizer->Add(button,0,wxEXPAND);
100 panelButton->SetSizer(buttonSizer);
102 this->m_AuiManager->AddPane( panelButton,wxAuiPaneInfo( ).Name( _T("ListConfigContainerPanel") ).Caption(_("ListConfigContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) );
104 this->m_AuiManager->AddPane( this->myConfiglist,wxAuiPaneInfo( ).Name( _T("ListContainerPanel") ).Caption(_("ListContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) );
106 this->m_AuiManager->AddPane(this->m_ListPanel, wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption( _("ListPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
109 this->m_ListPanel = new wxPanel(this);
111 panelUp = new wxPanel(this, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL, _T("ListConfigContainerPanel"));
112 wxBoxSizer* mainSizer = new wxBoxSizer(wxHORIZONTAL);
115 wxBoxSizer* listSizer = new wxBoxSizer(wxVERTICAL);
117 this->mylist = new ListWx(panelUp,-1,this->m_ButtonContainerSettings->GetItemsMap(),lFunctor);
118 this->mylist->Show(false);
120 this->myConfiglist = new ListWx(panelUp,-1, empty,lFunctor);
121 listSizer->Add(this->myConfiglist,0,wxEXPAND);
122 listSizer->Add(this->mylist,0,wxEXPAND);
123 mainSizer->Add(listSizer,0,wxEXPAND|wxALL,7);
126 wxBoxSizer* buttonSizer = new wxBoxSizer(wxVERTICAL);
128 button = new wxButton(panelUp, -1, _("Configurar"),
129 wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _("Configurar"));
131 buttonSizer->Add(button,0,wxEXPAND);
132 mainSizer->Add(buttonSizer,0,wxEXPAND|wxALL,14);
135 panelUp->SetSizer(mainSizer);
137 this->m_AuiManager->AddPane( panelUp,wxAuiPaneInfo( ).Name( _T("ListConfigContainerPanel") ).Caption(_("ListConfigContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) );
138 this->m_AuiManager->AddPane(this->m_ListPanel, wxAuiPaneInfo( ).Name( _T("ListConfigPanel") ).Caption( _("ListConfigPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
143 this->m_AuiManager->Update( );
144 //m_listConfigPanel = new ListConfigPanel(this,1,_("Configuracion"),mylist);
146 this->Connect(wxEVT_COMMAND_BUTTON_CLICKED,
147 wxCommandEventHandler(PanelButtonContainer::ButtonEvent));
150 // ----------------------------------------------------------------------------------
151 PanelButtonContainer::~PanelButtonContainer( )
154 // ----------------------------------------------------------------------------------
156 PanelButtonContainer::UpdatePanel( const std::string &buttonName )
160 std::cout<< "MLER | creaPanelButtonContainer:: UpdatePanel() " << std::endl;
162 //Hiding the last CartoSettingsPanel
163 this->m_ButtonPanel->Show( false );
164 //Finding the CartoSettingsPanel of the ButtonClicket
165 this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton(buttonName );
166 std::cout<< buttonName << "---testEvento 2 "<<std::endl;
167 //changing the parent of the panel!
168 if ( this->m_ButtonPanel->GetParent( ) != this )
170 this->m_ButtonPanel->Reparent( this );
173 this->m_AuiManager->GetPane( _T("ButtonPanel") ).window = this->m_ButtonPanel;
174 //Updating the manager
175 this->m_AuiManager->Update( );
177 catch ( const std::exception& e )
180 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
181 << "exception: " << e.what( ) << std::endl;
182 std::cout << "Maybe the panel of the button is NULL" << std::endl;
186 // ----------------------------------------------------------------------------------
188 PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
190 std::cout<< "MLER | creaPanelButtonContainer:: GenericButtonEvent() " << std::endl;
191 std::cout<< buttonName << "---testEvento 1 "<<std::endl;
192 this->UpdatePanel( buttonName );
194 // ----------------------------------------------------------------------------------
197 PanelButtonContainer::UpdateListPanel( const std::string &buttonName )
201 std::cout<< "MLER | creaPanelButtonContainer:: UpdateListPanel() " << std::endl;
202 std::cout<< buttonName << " --- test 2 "<<std::endl;
204 this->m_ListPanel->Show( false );
206 this->m_ListPanel = this->m_ButtonContainerSettings->GetPanelList(buttonName );
208 if ( this->m_ListPanel->GetParent( ) != this )
210 this->m_ListPanel->Reparent( this );
213 this->m_AuiManager->GetPane( _T("ListPanel") ).window = this->m_ListPanel;
214 //Updating the manager
215 this->m_AuiManager->Update( );
217 }catch( const std::exception& e )
220 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
221 << "exception: " << e.what( ) << std::endl;
222 std::cout << "Maybe the panel of the list is NULL" << std::endl;
228 PanelButtonContainer::GenericListEvent( const std::string &buttonName )
230 std::cout<< "MLER | creaPanelButtonContainer:: GenericListEvent() " << std::endl;
231 std::cout<< buttonName << " --- test 3 "<<std::endl;
232 this->UpdateListPanel( buttonName );
236 PanelButtonContainer::ButtonEvent ( wxCommandEvent& event )
239 m_listConfigPanel = new ListConfigPanel(this,-1,_("Configuracion"), mylist, myConfiglist);
241 std::cout<< "BUtton Event"<<std::endl;
243 if ( m_listConfigPanel->ShowModal() == 1 )
245 this->myConfiglist->Reparent(panelUp);
246 this->myConfiglist->Show(true);
247 this->myConfiglist->SetFunctorEnabled(true);
248 this->panelUp->Update();
249 this->m_AuiManager->Update( );