2 * @file buttonContainerController.cxx
3 * @brief This contains the ButtonContainerController class implementation
4 * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
8 #include "buttonContainerController.h"
10 namespace creaButtonContainer
14 // ----------------------------------------------------------------------------------
15 ButtonContainerController::ButtonContainerController( BCPanel* panel )
17 this->m_BCPanel = panel;
19 // ----------------------------------------------------------------------------------
20 ButtonContainerController::~ButtonContainerController( )
23 // ----------------------------------------------------------------------------------
25 ButtonContainerController::AddEvents( )
29 //Adding ButtonManagerEvents
30 for( GroupManagerList::iterator it =
31 this->m_BCPanel->m_GroupManagerList.begin( ); it
32 != this->m_BCPanel->m_GroupManagerList.end( ); ++it )
36 wxEVT_COMMAND_BUTTON_CLICKED,
37 (wxObjectEventFunction) &ButtonContainerController::ButtonExpEvent );
41 for( ButtonGroupList::iterator it =
42 this->m_BCPanel->m_ButtonGroupList.begin( ); it
43 != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
45 KeyList keylist = ( *it )->GetButtonIdContainer( );
46 for( KeyList::iterator it2 = keylist.begin( ); it2 != keylist.end( ); ++it2 )
48 this->Connect( ( *it2 ), wxEVT_COMMAND_BUTTON_CLICKED,
49 (wxObjectEventFunction) &ButtonContainerController::ButtonEvent );
53 catch ( const std::exception& e )
55 std::cerr << "ButtonContainerController::AddEvents( ) exception: "
56 << e.what( ) << std::endl;
59 // ----------------------------------------------------------------------------------
61 ButtonContainerController::ButtonExpEvent( wxCommandEvent& event )
63 long id = event.GetId( );
66 //changing the button label when its clicked and then hide the buttons of the group.
67 if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
70 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
72 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( false );
74 else if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
77 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
79 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( true );
81 this->m_BCPanel->FitSizer( );
83 catch ( const std::exception& e )
86 << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: "
87 << e.what( ) << std::endl;
90 // ----------------------------------------------------------------------------------
92 ButtonContainerController::ButtonEvent( wxCommandEvent& event )
96 for( ButtonGroupList::iterator it =
97 this->m_BCPanel->m_ButtonGroupList.begin( ); it
98 != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
100 if ( ( *it )->GetButton( event.GetId( ) ) != NULL )
102 ( *it )->GetButton( event.GetId( ) )->Execute( );
106 catch ( const std::exception& e )
109 << "ButtonContainerController::ButtonEvent( wxCommandEvent& event ) exception: "
110 << e.what( ) << std::endl;
113 // ----------------------------------------------------------------------------------