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 this->m_BCPanel = panel;
44 // ----------------------------------------------------------------------------------
45 ButtonContainerController::~ButtonContainerController( )
48 // ----------------------------------------------------------------------------------
50 ButtonContainerController::AddEvents( )
54 //Adding ButtonManagerEvents
55 for( GroupManagerList::iterator it =
56 this->m_BCPanel->m_GroupManagerList.begin( ); it
57 != this->m_BCPanel->m_GroupManagerList.end( ); ++it )
61 wxEVT_COMMAND_BUTTON_CLICKED,
62 (wxObjectEventFunction) &ButtonContainerController::ButtonExpEvent );
66 for( ButtonGroupList::iterator it =
67 this->m_BCPanel->m_ButtonGroupList.begin( ); it
68 != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
70 KeyList keylist = ( *it )->GetButtonIdContainer( );
71 for( KeyList::iterator it2 = keylist.begin( ); it2 != keylist.end( ); ++it2 )
73 this->Connect( ( *it2 ), wxEVT_COMMAND_BUTTON_CLICKED,
74 (wxObjectEventFunction) &ButtonContainerController::ButtonEvent );
78 catch ( const std::exception& e )
80 std::cerr << "ButtonContainerController::AddEvents( ) exception: "
81 << e.what( ) << std::endl;
84 // ----------------------------------------------------------------------------------
86 ButtonContainerController::ButtonExpEvent( wxCommandEvent& event )
88 long id = event.GetId( );
91 //changing the button label when its clicked and then hide the buttons of the group.
92 if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
95 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
97 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( false );
99 else if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
102 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
104 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( true );
106 this->m_BCPanel->FitSizer( );
108 catch ( const std::exception& e )
111 << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: "
112 << e.what( ) << std::endl;
115 // ----------------------------------------------------------------------------------
117 ButtonContainerController::ButtonEvent( wxCommandEvent& event )
121 for( ButtonGroupList::iterator it =
122 this->m_BCPanel->m_ButtonGroupList.begin( ); it
123 != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
125 if ( ( *it )->GetButton( event.GetId( ) ) != NULL )
127 ( *it )->GetButton( event.GetId( ) )->Execute( );
131 catch ( const std::exception& e )
134 << "ButtonContainerController::ButtonEvent( wxCommandEvent& event ) exception: "
135 << e.what( ) << std::endl;
138 // ----------------------------------------------------------------------------------