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