/*! * @file buttonContainerController.cxx * @brief This contains the ButtonContainerController class implementation * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) * @date 2011-05-19 */ #include "buttonContainerController.h" namespace creaButtonContainer { namespace controller { // ---------------------------------------------------------------------------------- ButtonContainerController::ButtonContainerController( BCPanel* panel ) { this->m_BCPanel = panel; } // ---------------------------------------------------------------------------------- ButtonContainerController::~ButtonContainerController( ) { delete this->m_BCPanel; } // ---------------------------------------------------------------------------------- void ButtonContainerController::AddEvents( ) { try { //Adding ButtonManagerEvents for( GroupManagerList::iterator it = this->m_BCPanel->m_GroupManagerList.begin( ); it != this->m_BCPanel->m_GroupManagerList.end( ); ++it ) { this->Connect( ( *it ).first, wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &ButtonContainerController::ButtonExpEvent ); }//rof //Adding ButtonEvents for( ButtonGroupList::iterator it = this->m_BCPanel->m_ButtonGroupList.begin( ); it != this->m_BCPanel->m_ButtonGroupList.end( ); ++it ) { KeyList keylist = ( *it )->GetButtonIdContainer( ); for( KeyList::iterator it2 = keylist.begin( ); it2 != keylist.end( ); ++it2 ) { this->Connect( ( *it2 ), wxEVT_COMMAND_BUTTON_CLICKED, (wxObjectEventFunction) &ButtonContainerController::ButtonEvent ); }//rof }//rof }//yrt catch ( std::exception& e ) { std::cerr << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: " << e.what( ) << std::endl; }//hctac } // ---------------------------------------------------------------------------------- void ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) { long id = event.GetId( ); try { if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp( _( "+" ) ) == 0 ) { this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel( _( "-" ) ); this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( false ); }//fi else if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp( _( "-" ) ) == 0 ) { this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel( _( "+" ) ); this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( true ); }//fi esle this->m_BCPanel->FitSizer( ); }//yrt catch ( std::exception& e ) { std::cerr << "ButtonContainerController::AddEvents( ) exception: " << e.what( ) << std::endl; }//hctac } // ---------------------------------------------------------------------------------- void ButtonContainerController::ButtonEvent( wxCommandEvent& event ) { try { for( ButtonGroupList::iterator it = this->m_BCPanel->m_ButtonGroupList.begin( ); it != this->m_BCPanel->m_ButtonGroupList.end( ); ++it ) { ( *it )->GetButton( event.GetId( ) )->Execute( ); }//rof }//yrt catch ( std::exception& e ) { std::cerr << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: " << e.what( ) << std::endl; }//hctac } // ---------------------------------------------------------------------------------- }//ecapsename }//ecapsename