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;
53 this->m_ButtonPanel = new wxPanel( this );
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 this->m_ListPanel = new wxPanel(this);
68 std::cout << "tipo 0; new ButtonContainerPanel"<<std::endl;
69 this->m_ButtonContainerPanel = new ButtonContainerPanel( this, this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ),type );
73 std::cout << "tipo 1; new LIstWx"<<std::endl;
74 this->mylist = new ListWx(this->m_ListPanel, -1,this->m_ButtonContainerSettings->GetItemsMap(), lFunctor);
78 //Using AuiManager to Manage the Panels
79 this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
82 this->m_AuiManager->AddPane(this->m_ButtonContainerPanel, wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("Panel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
84 this->m_AuiManager->AddPane(this->m_ListPanel, wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption( _("Panel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
86 //CartoButtonPanel Management
88 this->m_AuiManager->AddPane( this->m_ButtonContainerPanel,wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption(_("ListPanel") ). CaptionVisible( false ).CloseButton(false ).Center( ).Resizable( true ) );
90 {this->m_AuiManager->AddPane( this->m_ListPanel,wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption(_("ListPanel") ). CaptionVisible( false ).CloseButton(false ).Center( ).Resizable( true ) );}
91 this->m_AuiManager->Update( );
93 // ----------------------------------------------------------------------------------
94 PanelButtonContainer::~PanelButtonContainer( )
97 // ----------------------------------------------------------------------------------
99 PanelButtonContainer::UpdatePanel( const std::string &buttonName )
103 std::cout<< "MLER | creaPanelButtonContainer:: UpdatePanel() " << std::endl;
105 //Hiding the last CartoSettingsPanel
106 this->m_ButtonPanel->Show( false );
107 //Finding the CartoSettingsPanel of the ButtonClicket
108 this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton(buttonName );
109 std::cout<< buttonName << "---testEvento 2 "<<std::endl;
110 //changing the parent of the panel!
111 if ( this->m_ButtonPanel->GetParent( ) != this )
113 this->m_ButtonPanel->Reparent( this );
116 this->m_AuiManager->GetPane( _T("ButtonPanel") ).window = this->m_ButtonPanel;
117 //Updating the manager
118 this->m_AuiManager->Update( );
120 catch ( const std::exception& e )
123 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
124 << "exception: " << e.what( ) << std::endl;
125 std::cout << "Maybe the panel of the button is NULL" << std::endl;
129 // ----------------------------------------------------------------------------------
131 PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
133 std::cout<< "MLER | creaPanelButtonContainer:: GenericButtonEvent() " << std::endl;
134 std::cout<< buttonName << "---testEvento 1 "<<std::endl;
135 this->UpdatePanel( buttonName );
137 // ----------------------------------------------------------------------------------
140 PanelButtonContainer::UpdateListPanel( const std::string &buttonName )
144 std::cout<< "MLER | creaPanelButtonContainer:: UpdateListPanel() " << std::endl;
145 std::cout<< buttonName << " --- test 2 "<<std::endl;
147 this->m_ListPanel->Show( false );
149 this->m_ListPanel = this->m_ButtonContainerSettings->GetPanelList(buttonName );
151 if ( this->m_ListPanel->GetParent( ) != this )
153 this->m_ListPanel->Reparent( this );
156 this->m_AuiManager->GetPane( _T("ListPanel") ).window = this->m_ListPanel;
157 //Updating the manager
158 this->m_AuiManager->Update( );
160 }catch( const std::exception& e )
163 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
164 << "exception: " << e.what( ) << std::endl;
165 std::cout << "Maybe the panel of the list is NULL" << std::endl;
171 PanelButtonContainer::GenericListEvent( const std::string &buttonName )
173 std::cout<< "MLER | creaPanelButtonContainer:: GenericListEvent() " << std::endl;
174 std::cout<< buttonName << " --- test 3 "<<std::endl;
175 this->UpdateListPanel( buttonName );