From: Diego Caceres Date: Tue, 17 May 2011 15:45:53 +0000 (+0000) Subject: creaButtonContainer: exceptions added, doxygen documentation added :) X-Git-Tag: v1.0.4~119 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=ae196719490130990cdde501c982c3370b46b21c;p=creaMaracasVisu.git creaButtonContainer: exceptions added, doxygen documentation added :) --- 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 diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.h index cfda8ef..260f44b 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.h @@ -1,70 +1,126 @@ -/*************************************************************** +/************************************************************************************//*! * Name: @file buttonContainerController.h - * Purpose: @brief This fhile contains the ButtonContainerController Class + * Purpose: @brief This contains the ButtonContainerController class * 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: - **************************************************************/ + ***************************************************************************************/ #ifndef BUTTONCONTAINERCONTROLLER_H_ #define BUTTONCONTAINERCONTROLLER_H_ +//! @include #include +//! @include +#include +//! @include +#include + +//! @include "buttonContainerPanel.h" #include "buttonContainerPanel.h" -///@namespace +//! @namespace namespace creaButtonContainer { - ///@namespace + //! @namespace namespace view { //Predefinition of ButtonContainerPanel FriendClass!! - ///@class ButtonContainerPanel buttonContainerPanel.h "buttonContainerPanel.h" + //! @class ButtonContainerPanel buttonContainerPanel.h "buttonContainerPanel.h" + class ButtonContainerPanel; } - ///@namespace + //! @namespace namespace controller { - /*!@class ButtonContainerController buttonContainerController.h "buttonContainerController.h" - * @brief This class contains the ButtonContainerPanel controller - * This class describes the panel and button events. - */ + /*! @class ButtonContainerController buttonContainerController.h "buttonContainerController.h" + * @brief This class contains the ButtonContainerPanel controller + * This class describes button events. + */ class ButtonContainerController : public wxEvtHandler { public: - ///@typedef creaButtonContainer::view::ButtonGroup ButtonGroup - ///@typedef typedef creaButtonContainer::view::GroupManager GroupManager; - ///@typedef std::list< ButtonGroup* > ButtonGroupList; - ///@typedef std::map< long, GroupManager* > GroupManagerList; - ///@typedef wxFlexGridSizer Sizer; - ///@typedef std::list< long > KeyList; - ///@typedef creaButtonContainer::model::ContainerSettings ButtonGroupSettings; - ///@typedef creaButtonContainer::view::ButtonContainerPanel BCPanel; - //typedef definition + //typedef definitions + /*! @typedef creaButtonContainer::view::ButtonGroup ButtonGroup + * @brief Defines the ButtonGroup type + */ typedef creaButtonContainer::view::ButtonGroup ButtonGroup; + // ---------------------------------------------------------------------------------- + /*! @typedef typedef creaButtonContainer::view::GroupManager GroupManager + * @brief Defines the GroupManager type + */ typedef creaButtonContainer::view::GroupManager GroupManager; + // ---------------------------------------------------------------------------------- + /*! @typedef std::list< ButtonGroup* > ButtonGroupList + * @brief Defines the ButtonGroupList type + */ typedef std::list< ButtonGroup* > ButtonGroupList; + // ---------------------------------------------------------------------------------- + /*! @typedef std::map< long, GroupManager* > GroupManagerList + * @brief Defines the GroupManagerList type + */ typedef std::map< long, GroupManager* > GroupManagerList; + // ---------------------------------------------------------------------------------- + /*! @typedef wxFlexGridSizer Sizer + * @brief Defines the Sizer type + */ typedef wxFlexGridSizer Sizer; + // ---------------------------------------------------------------------------------- + /*! @typedef std::list< long > KeyList + * @brief Defines the KeyList type + */ typedef std::list< long > KeyList; + // ---------------------------------------------------------------------------------- + /*! @typedef creaButtonContainer::model::ContainerSettings ButtonGroupSettings + * @brief Defines the ButtonGroupSettings type + */ typedef creaButtonContainer::model::ContainerSettings ButtonGroupSettings; + // ---------------------------------------------------------------------------------- + /*! @typedef creaButtonContainer::view::ButtonContainerPanel BCPanel + * @brief Defines the BCPanel type + */ typedef creaButtonContainer::view::ButtonContainerPanel BCPanel; //end of typedef definition public: - ///!The Parameterized Constructor + /*! @fn ButtonContainerController::ButtonContainerController( BCPanel* ) + * @brief This is the Parameterized constructor. + * @param BCPanel* + */ ButtonContainerController( BCPanel* ); + // ---------------------------------------------------------------------------------- + /*! @fn virtual ButtonContainerController::~ButtonContainerController( ) + * @brief This is the destructor. + */ virtual ~ButtonContainerController( ); + // ---------------------------------------------------------------------------------- + /*! @fn void ButtonContainerController::AddEvents( ) + * @brief This function connect every buttonEvent to the view. + * @exception std::bad_alloc + */ void AddEvents( ); + // ---------------------------------------------------------------------------------- + /*! @fn void ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) + * @brief This function is the button group "+" "-" event. + * @exception std::bad_alloc + * @param event Button action event. + */ void ButtonExpEvent( wxCommandEvent& event ); + // ---------------------------------------------------------------------------------- + /*! @fn void ButtonContainerController::ButtonEvent( wxCommandEvent& event ) + * @brief This function calls the events of the buttonContainer buttons + * @exception std::bad_alloc + * @param event Button action event. + */ void ButtonEvent( wxCommandEvent& event ); + // ---------------------------------------------------------------------------------- private: - BCPanel* m_BCPanel; + BCPanel* m_BCPanel; //! namespace creaButtonContainer { + //! @namespace namespace model { + // ---------------------------------------------------------------------------------- ButtonGroupFactory::ButtonGroupFactory( ) { } + // ---------------------------------------------------------------------------------- ButtonGroupFactory::~ButtonGroupFactory( ) { } - ButtonGroupContainer + // ---------------------------------------------------------------------------------- + ButtonGroupFactory::ButtonGroupContainer ButtonGroupFactory::CreateButtonGroupContainer( wxWindow* parent, ButtonGroupModel* settings ) { ButtonGroupContainer groupView; - ButtonGroupMap map = settings->GetButtonGroupContainer( ); - for( ButtonGroupMap::iterator it = map.begin( ); it != map.end( ); ++it ) + try { - wxString groupNameAux( ( *it ).first.c_str( ), wxConvUTF8 ); - wxStaticText* wxGroupName = new wxStaticText( parent, -1, groupNameAux, - wxDefaultPosition, wxDefaultSize, 0, _T("GroupText") ); - ButtonGroup* group = new ButtonGroup( wxGroupName, - this->GetButtons( parent, ( *it ).second ) ); - groupView.push_back( group ); + ButtonGroupMap map = settings->GetButtonGroupContainer( ); + for( ButtonGroupMap::iterator it = map.begin( ); it != map.end( ); ++it ) + { + wxString groupNameAux( ( *it ).first.c_str( ), wxConvUTF8 ); + wxStaticText* wxGroupName = new wxStaticText( parent, -1, + groupNameAux, wxDefaultPosition, wxDefaultSize, 0, + _T( "GroupText" ) ); + ButtonGroup* group = new ButtonGroup( wxGroupName, + this->GetButtons( parent, ( *it ).second ) ); + groupView.push_back( group ); + } + } + catch ( std::exception& e ) + { + std::cerr + << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: " + << e.what( ) << std::endl; } return ( groupView ); } - ButtonContainer + // ---------------------------------------------------------------------------------- + ButtonGroupFactory::ButtonContainer ButtonGroupFactory::GetButtons( wxWindow* parent, ButtonList buttonModel ) { ButtonContainer buttonList; - for( ButtonList::iterator it = buttonModel.begin( ); it - != buttonModel.end( ); ++it ) + try + { + for( ButtonList::iterator it = buttonModel.begin( ); it + != buttonModel.end( ); ++it ) + { + long id = wxNewId( ); + buttonList[ id ] = new Button( parent, id, *it ); + } + return ( buttonList ); + } + catch ( std::exception& e ) { - long id = wxNewId( ); - buttonList[ id ] = new Button( parent, id, *it ); + std::cerr + << "ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) exception: " + << e.what( ) << std::endl; } - return ( buttonList ); } + // ---------------------------------------------------------------------------------- }//ecapseman }//ecapseman diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/buttonGroupFactory.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/buttonGroupFactory.h index 1dd7389..6160910 100644 --- a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/buttonGroupFactory.h +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/buttonGroupFactory.h @@ -1,69 +1,107 @@ -/*************************************************************** - * Name: @file ButtonGroupFactory.h - * Purpose: @brief This contains ButtonGroupFactory Class +/************************************************************************************//*! + * Name: @file buttonGroupFactory.h + * Purpose: @brief This contains ButtonGroupFactory class * 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: - **************************************************************/ + ***************************************************************************************/ #ifndef BUTTONGROUPFACTORY_H #define BUTTONGROUPFACTORY_H +//! @include #include +//! @include #include +//! @include #include +//! @include +#include +//! @include +#include +//! @include "system.h" #include "system.h" +//! @include "button.h" #include "button.h" +//! @include "buttonGroup.h" #include "buttonGroup.h" +//! @include "containerSettings.h" #include "containerSettings.h" +//! @include "functor.h" #include "functor.h" -///@namespace +//! @namespace namespace creaButtonContainer { - ///@namespace + //! @namespace namespace model { - //typedef - typedef creaButtonContainer::view::Button Button; - typedef creaButtonContainer::view::ButtonGroup ButtonGroup; - typedef creaButtonContainer::model::ContainerSettings ButtonGroupModel; - typedef std::list< ButtonGroup* > ButtonGroupContainer; - typedef std::map< long, Button* > ButtonContainer; - /// @class ButtonGroupFactory - /// @brief This class is the factory of a group of wxButtons + //! @class ButtonGroupFactory + //! @brief This class is the factory of a group of wxButtons. + + /*! @class ButtonGroupFactory buttonGroupFactory.h "buttonGroupFactory.h" + * @brief This class contains the ButtonContainer factory. + * This class describes the factory of the ButtonContainer using design patterns. + */ class ButtonGroupFactory { public: - //Constructors: - /*! - * @brief This is the default constructor. + //typedef definition + /*! @typedef creaButtonContainer::view::Button Button; + * @brief Defines the Button type. + */ + typedef creaButtonContainer::view::Button Button; + // ---------------------------------------------------------------------------------- + /*! @typedef creaButtonContainer::view::ButtonGroup ButtonGroup; + * @brief Defines the ButtonGroup type. + */ + typedef creaButtonContainer::view::ButtonGroup ButtonGroup; + // ---------------------------------------------------------------------------------- + /*! @typedef creaButtonContainer::model::ContainerSettings ButtonGroupModel; + * @brief Defines the ButtonGroupModel type. + */ + typedef creaButtonContainer::model::ContainerSettings ButtonGroupModel; + // ---------------------------------------------------------------------------------- + /*! @typedef std::list< ButtonGroup* > ButtonGroupContainer; + * @brief Defines the ButtonGroupContainer type. + */ + typedef std::list< ButtonGroup* > ButtonGroupContainer; + // ---------------------------------------------------------------------------------- + /*! @typedef std::map< long, Button* > ButtonContainer; + * @brief Defines the ButtonContainer type. + */ + typedef std::map< long, Button* > ButtonContainer; + // ---------------------------------------------------------------------------------- + public: + /*! @fn ButtonGroupFactory::ButtonGroupFactory( ) + * @brief This is the default constructor. */ ButtonGroupFactory( ); - //Destructors: - /*! - * @brief this is the destructor. + // ------------------------------------------------------------------------------- + /*! @fn virtual ButtonGroupFactory::~ButtonGroupFactory( ) + * @brief This is the destructor. */ virtual ~ButtonGroupFactory( ); - //Functions: - /*! + /*! @fn ButtonGroupContainer ButtonGroupFactory::CreateButtonGroupContainer( wxWindow* parent, ButtonGroupModel* settings ); * @brief This function allows to create the ButtonGroupContainer. - * @param the wxWindow* parent to be attached. - * @param The Container settings. - * @return The wx button group container. + * @param parent the wxWindow* parent to be attached. + * @param settings The Container settings. + * @exception std::bad_alloc + * @return ButtonGroupContainer The wx button group container. */ ButtonGroupContainer CreateButtonGroupContainer( wxWindow* parent, ButtonGroupModel* settings ); private: - /*! - * @brief This function allows to create a wx button container for a group. - * @param the wxWindow* parent to be attached. - * @param The button list with its own information. - * @return The wx button container. + /*! @fn ButtonContainer ButtonGroupFactory::GetButtons( wxWindow* parent, ButtonList buttonModel ); + * @brief This function allows to create a wx button container for a group. + * @param parent the wxWindow* parent to be attached. + * @param buttonModel The button list with its own information. + * @exception std::bad_alloc + * @return ButtonContainer The wx button container. */ ButtonContainer GetButtons( wxWindow* parent, ButtonList buttonModel );