]> Creatis software - creaMaracasVisu.git/blob
251e5f769144d9126c870a7b0da41cb58db9af93
[creaMaracasVisu.git] /
1 /*# ---------------------------------------------------------------------
2 #
3 # Copyright (c) CREATIS (Centre de Recherche en Acquisition et Traitement de l'Image
4 #                        pour la Sant�)
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
8 #
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.
15 #
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
20 #  liability.
21 #
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 # ------------------------------------------------------------------------ */
25
26 /*!
27  * @file creaPanelButtonContainer.h
28  * @brief implements PanelButtonContainer class
29  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
30  * @date  2011-06-02
31  */
32
33 #include "creaPanelButtonContainer.h"
34
35 namespace creaPanelButtonContainer
36 {
37         BEGIN_EVENT_TABLE(PanelButtonContainer,wxPanel)
38         //(*EventTable(ButtonContainerPanel)
39         //*)
40         END_EVENT_TABLE()
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") )
46         {
47                 this->m_ButtonContainerSettings = bcSettings;
48                 this->m_ButtonPanel = new wxPanel( this );
49
50                 //Class that manages the event!!!
51         //EED 20/01/2012
52                 TConcreteFunctor* functor = new TConcreteFunctor( this, &PanelButtonContainer::GenericButtonEvent );
53 //              TConcreteFunctor* functor = new TConcreteFunctor( this->m_ButtonPanel, &PanelButtonContainer::GenericButtonEvent );
54                 //end of the event definition
55
56                 this->m_ButtonContainerPanel = new ButtonContainerPanel( this, this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ) );
57
58                 //Using AuiManager to Manage the Panels
59                 this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
60
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( );
65         }
66         // ----------------------------------------------------------------------------------
67         PanelButtonContainer::~PanelButtonContainer( )
68         {
69         }
70         // ----------------------------------------------------------------------------------
71         void
72         PanelButtonContainer::UpdatePanel( const std::string &buttonName )
73         {
74                 try
75                 {
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 )
82                         {
83                                 this->m_ButtonPanel->Reparent( this );
84                         }//fi
85                         //CartoSettingsPanel Management
86                         this->m_AuiManager->GetPane( _T("ButtonPanel") ).window = this->m_ButtonPanel;
87                         //Updating the manager
88                         this->m_AuiManager->Update( );
89                 }//yrt
90                 catch ( const std::exception& e )
91                 {
92                         std::cerr
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;
96                         exit( 1 );
97                 }//hctac
98         }
99         // ----------------------------------------------------------------------------------
100         void
101         PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
102         {
103                 this->UpdatePanel( buttonName );
104         }
105 // ----------------------------------------------------------------------------------
106 }//ecapseman
107
108