]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/creaPanelButtonContainer.cxx
d7212643309df2ef6e71cfefff67d49e74eab739
[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                 //EVT_LIST_ITEM_SELECTED(-1, ListWx::ListEvent)
40
41         //(*EventTable(ButtonContainerPanel)
42         //*)
43         END_EVENT_TABLE()
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") )
49         {
50                 std::cout<< "MLER | creaPanelButtonContainer:: PanelButtonContainer() " << std::endl;
51
52                 this->m_ButtonContainerSettings = bcSettings;
53
54
55                 //Class that manages the event!!!
56         //EED 20/01/2012
57                 TConcreteFunctor* functor = new TConcreteFunctor( this, &PanelButtonContainer::GenericButtonEvent );
58 //              TConcreteFunctor* functor = new TConcreteFunctor( this->m_ButtonPanel, &PanelButtonContainer::GenericButtonEvent );
59                 //end of the event definition
60
61                 TConcreteFunctor* lFunctor = new TConcreteFunctor( this, &PanelButtonContainer::GenericListEvent );
62                 //MLER
63
64                 //Using AuiManager to Manage the Panels
65                 this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
66
67
68                 if(type == 0)
69                 {
70                         this->m_ButtonPanel = new wxPanel( this );
71                         std::cout << "tipo 0; new ButtonContainerPanel"<<std::endl;
72                         this->m_ButtonContainerPanel = new ButtonContainerPanel( this, this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ),type );
73
74                         this->m_AuiManager->AddPane( this->m_ButtonContainerPanel,wxAuiPaneInfo( ).Name( _T("ButtonContainerPanel") ).Caption(_("ButtonContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) );
75                         this->m_AuiManager->AddPane(this->m_ButtonPanel, wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("ButtonPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
76                 }
77                 else if( type == 1)
78                 {
79                         this->m_ListPanel = new wxPanel(this);
80                         std::cout << "tipo 1; new LIstWx"<<std::endl;
81                         this->mylist = new ListWx(this, -1,this->m_ButtonContainerSettings->GetItemsMap(), lFunctor);
82
83                         this->m_AuiManager->AddPane( this->mylist,wxAuiPaneInfo( ).Name( _T("ListContainerPanel") ).Caption(_("ListContainerPanel") ). CaptionVisible( true ).CloseButton(false ).Center( ).Resizable( true ) );
84                         this->m_AuiManager->AddPane(this->m_ListPanel, wxAuiPaneInfo( ).Name( _T("ListPanel") ).Caption( _("ListPanel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
85                 }//MLER
86
87
88                 //CartoButtonPanel Management
89
90
91                 this->m_AuiManager->Update( );
92         }
93         // ----------------------------------------------------------------------------------
94         PanelButtonContainer::~PanelButtonContainer( )
95         {
96         }
97         // ----------------------------------------------------------------------------------
98         void
99         PanelButtonContainer::UpdatePanel( const std::string &buttonName )
100         {
101                 try
102                 {
103                         std::cout<< "MLER | creaPanelButtonContainer:: UpdatePanel() " << std::endl;
104
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 )
112                         {
113                                 this->m_ButtonPanel->Reparent( this );
114                         }//fi
115                         //Panel Management
116                         this->m_AuiManager->GetPane( _T("ButtonPanel") ).window = this->m_ButtonPanel;
117                         //Updating the manager
118                         this->m_AuiManager->Update( );
119                 }//yrt
120                 catch ( const std::exception& e )
121                 {
122                         std::cerr
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;
126                         exit( 1 );
127                 }//hctac
128         }
129         // ----------------------------------------------------------------------------------
130         void
131         PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
132         {
133                 std::cout<< "MLER | creaPanelButtonContainer:: GenericButtonEvent() " << std::endl;
134                 std::cout<< buttonName << "---testEvento 1 "<<std::endl;
135                 this->UpdatePanel( buttonName );
136         }
137 // ----------------------------------------------------------------------------------
138
139         void
140         PanelButtonContainer::UpdateListPanel( const std::string &buttonName )
141         {
142                 try{
143
144                         std::cout<< "MLER | creaPanelButtonContainer:: UpdateListPanel() " << std::endl;
145                         std::cout<< buttonName << " --- test 2 "<<std::endl;
146
147                         this->m_ListPanel->Show( false );
148
149                         this->m_ListPanel = this->m_ButtonContainerSettings->GetPanelList(buttonName );
150
151                         if ( this->m_ListPanel->GetParent( ) != this )
152                         {
153                                 this->m_ListPanel->Reparent( this );
154                         }//fi
155                                                 //Panel Management
156                         this->m_AuiManager->GetPane( _T("ListPanel") ).window = this->m_ListPanel;
157                                                 //Updating the manager
158                         this->m_AuiManager->Update( );
159
160                 }catch( const std::exception& e )
161                 {
162                         std::cerr
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;
166                         exit( 1 );
167                 }//hctac
168         }
169
170         void
171         PanelButtonContainer::GenericListEvent( const std::string &buttonName )
172         {
173                 std::cout<< "MLER | creaPanelButtonContainer:: GenericListEvent() " << std::endl;
174                 std::cout<< buttonName << " --- test 3 "<<std::endl;
175                 this->UpdateListPanel( buttonName );
176         }
177
178
179 }//ecapseman
180
181