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 //(*EventTable(ButtonContainerPanel)
41 // ----------------------------------------------------------------------------------
42 typedef creaButtonContainer::model::TConcreteFunctor< PanelButtonContainer > TConcreteFunctor;
43 // ----------------------------------------------------------------------------------
44 PanelButtonContainer::PanelButtonContainer( wxWindow* parent, ButtonContainerSettings* bcSettings )
45 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer") )
47 this->m_ButtonContainerSettings = bcSettings;
48 this->m_ButtonPanel = new wxPanel( this );
50 //Class that manages the event!!!
52 TConcreteFunctor* functor = new TConcreteFunctor( this, &PanelButtonContainer::GenericButtonEvent );
53 // TConcreteFunctor* functor = new TConcreteFunctor( this->m_ButtonPanel, &PanelButtonContainer::GenericButtonEvent );
54 //end of the event definition
56 this->m_ButtonContainerPanel = new ButtonContainerPanel( this, this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ) );
58 //Using AuiManager to Manage the Panels
59 this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
61 this->m_AuiManager->AddPane(this->m_ButtonPanel, wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("Panel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
62 //CartoButtonPanel Management
63 this->m_AuiManager->AddPane( this->m_ButtonContainerPanel,wxAuiPaneInfo( ).Name( _T("creaButtonContainer") ).Caption(_("creaButtonContainer") ). CaptionVisible( false ).CloseButton(false ).Center( ).Resizable( true ) );
64 this->m_AuiManager->Update( );
66 // ----------------------------------------------------------------------------------
67 PanelButtonContainer::~PanelButtonContainer( )
70 // ----------------------------------------------------------------------------------
72 PanelButtonContainer::UpdatePanel( const std::string &buttonName )
76 //Hiding the last CartoSettingsPanel
77 this->m_ButtonPanel->Show( false );
78 //Finding the CartoSettingsPanel of the ButtonClicket
79 this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton(buttonName );
80 //changing the parent of the panel!
81 if ( this->m_ButtonPanel->GetParent( ) != this )
83 this->m_ButtonPanel->Reparent( this );
85 //CartoSettingsPanel Management
86 this->m_AuiManager->GetPane( _T("ButtonPanel") ).window = this->m_ButtonPanel;
87 //Updating the manager
88 this->m_AuiManager->Update( );
90 catch ( const std::exception& e )
93 << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
94 << "exception: " << e.what( ) << std::endl;
95 std::cout << "Maybe the panel of the button is NULL" << std::endl;
99 // ----------------------------------------------------------------------------------
101 PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
103 this->UpdatePanel( buttonName );
105 // ----------------------------------------------------------------------------------