]> Creatis software - creaMaracasVisu.git/blob
70a5a6973533dc796852dbf26fcdd1e3614f325c
[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, std::string type )
45                 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer") )
46         {
47                 std::cout<< std::endl << " MLER creaPanelButtonContainer.cxx / PanelButtonContainer() " << std::endl;
48
49                 this->m_ButtonContainerSettings = bcSettings;
50                 this->m_ButtonPanel = new wxPanel( this );
51
52                 //Class that manages the event!!!
53         //EED 20/01/2012
54                 TConcreteFunctor* functor = new TConcreteFunctor( this, &PanelButtonContainer::GenericButtonEvent );
55 //              TConcreteFunctor* functor = new TConcreteFunctor( this->m_ButtonPanel, &PanelButtonContainer::GenericButtonEvent );
56                 //end of the event definition
57
58                 this->m_ButtonContainerPanel = new ButtonContainerPanel( this, this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ),type );
59
60                 //Using AuiManager to Manage the Panels
61                 this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
62
63                 this->m_AuiManager->AddPane(this->m_ButtonPanel, wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("Panel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
64                 //CartoButtonPanel Management
65                 this->m_AuiManager->AddPane( this->m_ButtonContainerPanel,wxAuiPaneInfo( ).Name( _T("creaButtonContainer") ).Caption(_("creaButtonContainer") ). CaptionVisible( false ).CloseButton(false ).Center( ).Resizable( true ) );
66                 this->m_AuiManager->Update( );
67         }
68         // ----------------------------------------------------------------------------------
69         PanelButtonContainer::~PanelButtonContainer( )
70         {
71         }
72         // ----------------------------------------------------------------------------------
73         void
74         PanelButtonContainer::UpdatePanel( const std::string &buttonName )
75         {
76                 try
77                 {
78                         //Hiding the last CartoSettingsPanel
79                         this->m_ButtonPanel->Show( false );
80                         //Finding the CartoSettingsPanel of the ButtonClicket
81                         this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton(buttonName );
82                         //changing the parent of the panel!
83                         if ( this->m_ButtonPanel->GetParent( ) != this )
84                         {
85                                 this->m_ButtonPanel->Reparent( this );
86                         }//fi
87                         //CartoSettingsPanel Management
88                         this->m_AuiManager->GetPane( _T("ButtonPanel") ).window = this->m_ButtonPanel;
89                         //Updating the manager
90                         this->m_AuiManager->Update( );
91                 }//yrt
92                 catch ( const std::exception& e )
93                 {
94                         std::cerr
95                             << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
96                             << "exception: " << e.what( ) << std::endl;
97                         std::cout << "Maybe the panel of the button is NULL" << std::endl;
98                         exit( 1 );
99                 }//hctac
100         }
101         // ----------------------------------------------------------------------------------
102         void
103         PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
104         {
105                 this->UpdatePanel( buttonName );
106         }
107 // ----------------------------------------------------------------------------------
108 }//ecapseman
109
110