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( )
22 delete this->m_BCPanel;
24 // ----------------------------------------------------------------------------------
26 ButtonContainerController::AddEvents( )
30 //Adding ButtonManagerEvents
31 for( GroupManagerList::iterator it =
32 this->m_BCPanel->m_GroupManagerList.begin( ); it
33 != this->m_BCPanel->m_GroupManagerList.end( ); ++it )
37 wxEVT_COMMAND_BUTTON_CLICKED,
38 (wxObjectEventFunction) &ButtonContainerController::ButtonExpEvent );
42 for( ButtonGroupList::iterator it =
43 this->m_BCPanel->m_ButtonGroupList.begin( ); it
44 != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
46 KeyList keylist = ( *it )->GetButtonIdContainer( );
47 for( KeyList::iterator it2 = keylist.begin( ); it2 != keylist.end( ); ++it2 )
49 this->Connect( ( *it2 ), wxEVT_COMMAND_BUTTON_CLICKED,
50 (wxObjectEventFunction) &ButtonContainerController::ButtonEvent );
54 catch ( std::exception& e )
57 << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: "
58 << e.what( ) << std::endl;
61 // ----------------------------------------------------------------------------------
63 ButtonContainerController::ButtonExpEvent( wxCommandEvent& event )
65 long id = event.GetId( );
68 if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
71 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
73 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( false );
75 else if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
78 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
80 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( true );
82 this->m_BCPanel->FitSizer( );
84 catch ( std::exception& e )
86 std::cerr << "ButtonContainerController::AddEvents( ) 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 )
101 ( *it )->GetButton( event.GetId( ) )->Execute( );
105 catch ( std::exception& e )
108 << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: "
109 << e.what( ) << std::endl;
112 // ----------------------------------------------------------------------------------