X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=blobdiff_plain;ds=inline;f=lib%2FmaracasVisuLib%2Fsrc%2Finterface%2FwxWindows%2Fwidgets%2FcreaButtonContainer%2Fcontroller%2FbuttonContainerController.cxx;h=ecbf950d05cbfb2d2f6731bc98a33577ee104114;hb=ae196719490130990cdde501c982c3370b46b21c;hp=efb7af679fb1c7179cfee975ad9906eeafe65a8f;hpb=4b092ee0b1bcda4d298e5ffc3b58b599e273db20;p=creaMaracasVisu.git diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.cxx index efb7af6..ecbf950 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.cxx +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.cxx @@ -1,74 +1,101 @@ -/*************************************************************** - * Name: @file buttonContainerController.h - * Purpose: @brief This contains ContainerSettings class +/************************************************************************************//*! + * Name: @file buttonContainerController.cxx + * Purpose: @brief This contains the ButtonContainerController class implementation * Author: @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) - * Modified: 2011-05-09 - * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * Modified: 2011-05-17 + * Copyright: * License: - **************************************************************/ + ***************************************************************************************/ +//! @include "buttonContainerController.h" #include "buttonContainerController.h" -using namespace std; +//! @namespace namespace creaButtonContainer { + //! @namespace namespace controller { + // ---------------------------------------------------------------------------------- ButtonContainerController::ButtonContainerController( BCPanel* panel ) { this->m_BCPanel = panel; } + // ---------------------------------------------------------------------------------- ButtonContainerController::~ButtonContainerController( ) { } + // ---------------------------------------------------------------------------------- void ButtonContainerController::AddEvents( ) { - //Adding ButtonManagerEvents - for( GroupManagerList::iterator it = - this->m_BCPanel->m_GroupManagerList.begin( ); it - != this->m_BCPanel->m_GroupManagerList.end( ); ++it ) + try { - this->Connect( ( *it ).first, wxEVT_COMMAND_BUTTON_CLICKED, - (wxObjectEventFunction) &ButtonContainerController::ButtonExpEvent ); - }//rof + //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 ) + //Adding ButtonEvents + for( ButtonGroupList::iterator it = + this->m_BCPanel->m_ButtonGroupList.begin( ); it + != this->m_BCPanel->m_ButtonGroupList.end( ); ++it ) { - this->Connect( ( *it2 ), wxEVT_COMMAND_BUTTON_CLICKED, - (wxObjectEventFunction) &ButtonContainerController::ButtonEvent ); + 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 - }//rof + } + catch ( std::exception& e ) + { + std::cerr + << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: " + << e.what( ) << std::endl; + } } - // ------------------------------------------------------------------- + // ---------------------------------------------------------------------------------- void ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) { long id = event.GetId( ); - - if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp( - _("+") ) == 0 ) + try { - this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel( - _("-") ); - this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( false ); + 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 ); + } + 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 ); + } + this->m_BCPanel->FitSizer( ); } - else if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp( - _("-") ) == 0 ) + catch ( std::exception& e ) { - this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel( - _("+") ); - this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( true ); + std::cerr << "ButtonContainerController::AddEvents( ) exception: " + << e.what( ) << std::endl; } - this->m_BCPanel->FitSizer( ); } - // ------------------------------------------------------------------- + // ---------------------------------------------------------------------------------- void ButtonContainerController::ButtonEvent( wxCommandEvent& event ) { @@ -76,10 +103,19 @@ namespace creaButtonContainer this->m_BCPanel->m_ButtonGroupList.begin( ); it != this->m_BCPanel->m_ButtonGroupList.end( ); ++it ) { - if ( ( *it )->GetButton( event.GetId( ) ) != NULL ) + try + { ( *it )->GetButton( event.GetId( ) )->Execute( ); + } + catch ( std::exception& e ) + { + std::cerr + << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: " + << e.what( ) << std::endl; + } } } + // ---------------------------------------------------------------------------------- }//ecapsename }//ecapsename