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 buttonContainerController.cxx
28 * @brief This contains the ButtonContainerController class implementation
29 * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
33 #include "buttonContainerController.h"
35 namespace creaButtonContainer
39 // ----------------------------------------------------------------------------------
40 ButtonContainerController::ButtonContainerController( BCPanel* panel )
42 std::cout<< "MLER | ButtonContainerController::ButtonContainerController( BCPanel* panel )" << std::endl;
43 this->m_BCPanel = panel;
45 // ----------------------------------------------------------------------------------
46 ButtonContainerController::~ButtonContainerController( )
49 // ----------------------------------------------------------------------------------
51 ButtonContainerController::AddEvents( )
55 std::cout<< "MLER | ButtonContainerController:: AddEvents( )" << std::endl;
56 //Adding ButtonManagerEvents
57 for( GroupManagerList::iterator it =
58 this->m_BCPanel->m_GroupManagerList.begin( ); it
59 != this->m_BCPanel->m_GroupManagerList.end( ); ++it )
63 wxEVT_COMMAND_BUTTON_CLICKED,
64 (wxObjectEventFunction) &ButtonContainerController::ButtonExpEvent );
68 for( ButtonGroupList::iterator it =
69 this->m_BCPanel->m_ButtonGroupList.begin( ); it
70 != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
72 KeyList keylist = ( *it )->GetButtonIdContainer( );
73 for( KeyList::iterator it2 = keylist.begin( ); it2 != keylist.end( ); ++it2 )
75 this->Connect( ( *it2 ), wxEVT_COMMAND_BUTTON_CLICKED,
76 (wxObjectEventFunction) &ButtonContainerController::ButtonEvent );
80 catch ( const std::exception& e )
82 std::cerr << "ButtonContainerController::AddEvents( ) exception: "
83 << e.what( ) << std::endl;
86 // ----------------------------------------------------------------------------------
88 ButtonContainerController::ButtonExpEvent( wxCommandEvent& event )
90 long id = event.GetId( );
91 std::cout<< "MLER | ButtonContainerController:: ButtonExpEvent( wxCommandEvent& event )" << std::endl;
95 //changing the button label when its clicked and then hide the buttons of the group.
96 if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
99 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
101 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( false );
103 else if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
106 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
108 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( true );
110 this->m_BCPanel->FitSizer( );
112 catch ( const std::exception& e )
115 << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: "
116 << e.what( ) << std::endl;
119 // ----------------------------------------------------------------------------------
121 ButtonContainerController::ButtonEvent( wxCommandEvent& event )
123 std::cout<< "MLER | ButtonContainerController:: ButtonEvent( wxCommandEvent& event )" << std::endl;
126 for( ButtonGroupList::iterator it =
127 this->m_BCPanel->m_ButtonGroupList.begin( ); it
128 != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
130 if ( ( *it )->GetButton( event.GetId( ) ) != NULL )
132 ( *it )->GetButton( event.GetId( ) )->Execute( );
136 catch ( const std::exception& e )
139 << "ButtonContainerController::ButtonEvent( wxCommandEvent& event ) exception: "
140 << e.what( ) << std::endl;
143 // ----------------------------------------------------------------------------------