From: Diego Caceres Date: Mon, 9 May 2011 06:50:49 +0000 (+0000) Subject: Diego Caceres: creaButtonContainer and creaPanelButtonContainer has been added to... X-Git-Tag: v1.0.4~134 X-Git-Url: https://git.creatis.insa-lyon.fr/pubgit/?a=commitdiff_plain;h=f7634324fc5790ec510ad4f3db642c705dfb685e;p=creaMaracasVisu.git Diego Caceres: creaButtonContainer and creaPanelButtonContainer has been added to creaMaracasVisu project. --- diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/include/buttonContainerController.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/include/buttonContainerController.h new file mode 100644 index 0000000..cfda8ef --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/include/buttonContainerController.h @@ -0,0 +1,72 @@ +/*************************************************************** + * Name: @file buttonContainerController.h + * Purpose: @brief This fhile 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/) + * License: + **************************************************************/ + +#ifndef BUTTONCONTAINERCONTROLLER_H_ +#define BUTTONCONTAINERCONTROLLER_H_ + +#include +#include "buttonContainerPanel.h" + +///@namespace +namespace creaButtonContainer +{ + ///@namespace + namespace view + { + //Predefinition of ButtonContainerPanel FriendClass!! + ///@class ButtonContainerPanel buttonContainerPanel.h "buttonContainerPanel.h" + class ButtonContainerPanel; + } + ///@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 : 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 creaButtonContainer::view::ButtonGroup ButtonGroup; + 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; + //end of typedef definition + public: + ///!The Parameterized Constructor + ButtonContainerController( BCPanel* ); + virtual + ~ButtonContainerController( ); + void + AddEvents( ); + void + ButtonExpEvent( wxCommandEvent& event ); + void + ButtonEvent( wxCommandEvent& event ); + private: + BCPanel* m_BCPanel; + }; + }//ecapsename +}//ecapsename + +#endif //BUTTONCONTAINERCONTROLLER_H_ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/src/buttonContainerController.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/src/buttonContainerController.cxx new file mode 100644 index 0000000..efb7af6 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/src/buttonContainerController.cxx @@ -0,0 +1,85 @@ +/*************************************************************** + * Name: @file buttonContainerController.h + * Purpose: @brief This contains ContainerSettings 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/) + * License: + **************************************************************/ + +#include "buttonContainerController.h" +using namespace std; + +namespace creaButtonContainer +{ + 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 ) + { + 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 + } + // ------------------------------------------------------------------- + void + ButtonContainerController::ButtonExpEvent( wxCommandEvent& event ) + { + long id = event.GetId( ); + + 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( ); + } + // ------------------------------------------------------------------- + void + ButtonContainerController::ButtonEvent( wxCommandEvent& event ) + { + for( ButtonGroupList::iterator it = + this->m_BCPanel->m_ButtonGroupList.begin( ); it + != this->m_BCPanel->m_ButtonGroupList.end( ); ++it ) + { + if ( ( *it )->GetButton( event.GetId( ) ) != NULL ) + ( *it )->GetButton( event.GetId( ) )->Execute( ); + } + } + }//ecapsename +}//ecapsename + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/buttonGroupFactory.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/buttonGroupFactory.h new file mode 100644 index 0000000..1dd7389 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/buttonGroupFactory.h @@ -0,0 +1,74 @@ +/*************************************************************** + * 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/) + * License: + **************************************************************/ + +#ifndef BUTTONGROUPFACTORY_H +#define BUTTONGROUPFACTORY_H + +#include +#include +#include + +#include "system.h" +#include "button.h" +#include "buttonGroup.h" +#include "containerSettings.h" +#include "functor.h" + +///@namespace +namespace creaButtonContainer +{ + ///@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 + { + public: + //Constructors: + /*! + * @brief This is the default constructor. + */ + ButtonGroupFactory( ); + //Destructors: + /*! + * @brief this is the destructor. + */ + virtual + ~ButtonGroupFactory( ); + //Functions: + /*! + * @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. + */ + 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. + */ + ButtonContainer + GetButtons( wxWindow* parent, ButtonList buttonModel ); + }; + }//ecapseman +}//ecapseman + +#endif // CARTOBUTTONFACTORY_H diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/containerSettings.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/containerSettings.h new file mode 100644 index 0000000..1707176 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/containerSettings.h @@ -0,0 +1,97 @@ +/*************************************************************** + * Name: @file containerSettings.h + * Purpose: @brief This contains ContainerSettings 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/) + * License: + **************************************************************/ + +#ifndef BUTTONGROUPSETTINGS_H_ +#define BUTTONGROUPSETTINGS_H_ + +#include +#include +#include +#include "system.h" + +#include "functor.h" + +///@namespace +namespace creaButtonContainer +{ + ///@namespace + namespace model + { + /*! + * @class ContainerSettings + * @brief This class contains all information of groups and its buttons + */ + class ContainerSettings + { + public: + /*! + * @brief This is the default constructor + */ + ContainerSettings( ); + virtual + ~ContainerSettings( ); + /*! + * @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. + */ + ButtonGroupMap + GetButtonGroupContainer( ); + /*! + * @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. + */ + KeyMapList + GetGroupNameList( ); + /*! + * @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. + */ + void + SetButtonGroupContainer( ButtonGroupMap m_ButtonGroupContainer ); + /*! + * @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. + */ + void + SetGroupNameList( KeyMapList m_GroupNameList ); + /*! + * @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. + */ + void + CreateGroup( const std::string & groupName ); + /*! + * @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. + */ + void + AddButton( const std::string & groupName, const std::string buttonName, + const std::string iconpath, const std::string buttonDescription, + FunctionEventType event ); + + private: + ButtonGroupMap m_ButtonGroupContainer; + KeyMapList m_GroupNameList; + }; + } +} + +#endif /* BUTTONGROUPSETTINGS_H_ */ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/functor.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/functor.h new file mode 100644 index 0000000..3ec8df4 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/functor.h @@ -0,0 +1,62 @@ +/*************************************************************** + * Name: TFunctor + * Purpose: Call_Back Functions + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef TFUNCTOR_H_ +#define TFUNCTOR_H_ + +#include + +namespace creaButtonContainer +{ + namespace model + { + typedef std::string ButtonIDType; + // abstract base class + class TFunctor + { + public: + // two possible functions to call member function. virtual cause derived + // classes will use a pointer to an object and a pointer to a member function + // to make the function call + virtual void + operator()( const ButtonIDType &buttonName )=0; // call using operator + virtual void + Call( const ButtonIDType &buttonName )=0; + // call using function + }; + + // derived template class + template< typename TClass > + class TConcreteFunctor : public TFunctor + { + public: + // constructor - takes pointer to an object and pointer to a member and stores + // them in two private variables + TConcreteFunctor( TClass* _pt2Object, void + (TClass::*_fpt)( const ButtonIDType &buttonName ) ); + // override operator "()" // execute member function + virtual void + operator()( const ButtonIDType &buttonName ); + // override function "Call" // execute member function + virtual void + Call( const ButtonIDType &buttonName ); + private: + void + (TClass::*fpt)( const ButtonIDType &buttonName ); + // pointer to member function + TClass* pt2Object; + // pointer to object + }; + + }//ecapseman +}//ecapseman + +#include "functor.txx" + +#endif /* TFUNCTOR_H_ */ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/functor.txx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/functor.txx new file mode 100644 index 0000000..7445586 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/functor.txx @@ -0,0 +1,39 @@ +/*************************************************************** + * Name: TFunctor + * Purpose: Call_Back Functions + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +namespace creaButtonContainer +{ + namespace model + { + // constructor - takes pointer to an object and pointer to a member and stores + // them in two private variables + template< typename TClass > + TConcreteFunctor< TClass >::TConcreteFunctor( TClass* _pt2Object, void + (TClass::*_fpt)( const ButtonIDType &buttonName ) ) + { + pt2Object = _pt2Object; + fpt = _fpt; + } + // override operator "()" // execute member functions + template< typename TClass > + void + TConcreteFunctor< TClass >::operator()( const ButtonIDType &buttonName ) + { + ( *pt2Object.*fpt )( buttonName ); + } + // override function "Call" // execute member function + template< typename TClass > + void + TConcreteFunctor< TClass >::Call( const ButtonIDType &buttonName ) + { + ( *pt2Object.*fpt )( buttonName ); + } + }//ecapseman +}//ecapseman + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/system.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/system.h new file mode 100644 index 0000000..55beaf4 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/include/system.h @@ -0,0 +1,32 @@ +/*************************************************************** + * Name: TFunctor + * Purpose: Call_Back Functions + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef SYSTEM_H_ +#define SYSTEM_H_ + +#include +#include +#include +#include "functor.h" + +///@namespace +namespace creaButtonContainer +{ + typedef model::TFunctor* FunctionEventType; + //First is the button description, Second FunctionEventType + typedef std::pair< std::string, FunctionEventType > ActionButton; + //First is the ButtonName and Second is the ImageIconPath + typedef std::pair< std::string, std::string > ButtonInfo; + typedef std::pair< ButtonInfo*, ActionButton* > ButtonPair; + typedef std::list< std::string > KeyMapList; + typedef std::list< ButtonPair* > ButtonList; + typedef std::map< std::string, ButtonList > ButtonGroupMap; +} + +#endif /* SYSTEM_H_ */ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/src/buttonGroupFactory.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/src/buttonGroupFactory.cxx new file mode 100644 index 0000000..c06d5d4 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/src/buttonGroupFactory.cxx @@ -0,0 +1,53 @@ +/*************************************************************** + * Name: ButtonGroupFactory + * Purpose: Implements ButtonGroupFactory + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#include "buttonGroupFactory.h" + +namespace creaButtonContainer +{ + namespace model + { + ButtonGroupFactory::ButtonGroupFactory( ) + { + } + ButtonGroupFactory::~ButtonGroupFactory( ) + { + } + ButtonGroupContainer + ButtonGroupFactory::CreateButtonGroupContainer( wxWindow* parent, + ButtonGroupModel* settings ) + { + ButtonGroupContainer groupView; + 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 ); + } + return ( groupView ); + } + ButtonContainer + ButtonGroupFactory::GetButtons( wxWindow* parent, ButtonList buttonModel ) + { + ButtonContainer buttonList; + for( ButtonList::iterator it = buttonModel.begin( ); it + != buttonModel.end( ); ++it ) + { + long id = wxNewId( ); + buttonList[ id ] = new Button( parent, id, *it ); + } + return ( buttonList ); + } + }//ecapseman +}//ecapseman + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/src/containerSettings.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/src/containerSettings.cxx new file mode 100644 index 0000000..297ac43 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/src/containerSettings.cxx @@ -0,0 +1,71 @@ +/*************************************************************** + * Name: ButtonGroupSettings.cxx + * Purpose: It is the ButtonGroupSettings + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ +#include "containerSettings.h" + +namespace creaButtonContainer +{ + namespace model + { + + ContainerSettings::ContainerSettings( ) + { + } + + ContainerSettings::~ContainerSettings( ) + { + } + + ButtonGroupMap + ContainerSettings::GetButtonGroupContainer( ) + { + return m_ButtonGroupContainer; + } + + KeyMapList + ContainerSettings::GetGroupNameList( ) + { + return m_GroupNameList; + } + + void + ContainerSettings::SetButtonGroupContainer( + ButtonGroupMap m_ButtonGroupContainer ) + { + this->m_ButtonGroupContainer = m_ButtonGroupContainer; + } + + void + ContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList ) + { + this->m_GroupNameList = m_GroupNameList; + } + + void + ContainerSettings::CreateGroup( const std::string & groupName ) + { + this->m_GroupNameList.push_back( groupName ); + } + void + ContainerSettings::AddButton( const std::string & groupName, + const std::string buttonName, const std::string iconpath, + const std::string buttonDescription, FunctionEventType event ) + { + for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it + != this->m_GroupNameList.end( ); ++it ) + if ( ( *it ).compare( groupName ) == 0 ) + { + ButtonPair* pair = new ButtonPair( + new ButtonInfo( buttonName, iconpath ), + new ActionButton( buttonDescription, event ) ); + this->m_ButtonGroupContainer[ groupName ].push_back( pair ); + return; + } + } + } +} diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/button.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/button.h new file mode 100644 index 0000000..4ef2af9 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/button.h @@ -0,0 +1,57 @@ +/*************************************************************** + * Name: Button.h + * Purpose: Defines a Button + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef BUTTON_H +#define BUTTON_H + +#include +#include +#include +#include +#include "functor.h" +#include "system.h" + +using std::string; + +namespace creaButtonContainer +{ + namespace view + { + /** + Class Description: This class defines a wxBitmapButton. + **/ + class Button : public wxBitmapButton + { + public: + //Typedef definition + typedef creaButtonContainer::model::TFunctor TFunctor; + public: + //-------------------------------------------------------------------- + Button( wxWindow* parent, long id, ButtonPair* pair ); + virtual + ~Button( ); + //-------------------------------------------------------------------- + long + GetID( ); + string + GetButtonName( ); + string + GetIconPath( ); + string + GetDescription( ); + //-------------------------------------------------------------------- + void + Execute( ); + private: + ButtonPair* m_ButtonPair; + }; + }//ecapseman +}//ecapseman + +#endif // BUTTON_H diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonContainerPanel.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonContainerPanel.h new file mode 100644 index 0000000..b953cee --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonContainerPanel.h @@ -0,0 +1,74 @@ +/*************************************************************** + * Name: ButtonContainerPanel.h + * Purpose: Defines the main panel of the button container + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef BUTTONCONTAINERPANEL_H +#define BUTTONCONTAINERPANEL_H + +#include +#include +#include +#include +#include + +#include "buttonGroup.h" +#include "groupManager.h" +#include "buttonGroupFactory.h" +#include "containerSettings.h" +#include "buttonContainerController.h" + +namespace creaButtonContainer +{ + namespace controller + { + class ButtonContainerController; + } + namespace view + { + /** + Class Description: + **/ + class ButtonContainerPanel : public wxScrolledWindow + { + public: + //typedef definition + typedef creaButtonContainer::view::ButtonGroup ButtonGroup; + 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::model::ButtonGroupFactory + ButtonGroupFactory; + typedef creaButtonContainer::controller::ButtonContainerController + BCController; + //end of typedef definition + public: + ButtonContainerPanel( wxWindow* parent, ButtonGroupSettings* settings ); + virtual + ~ButtonContainerPanel( ); + void + SetGroupContainer( ButtonGroupList groupContainer ); + void + PanelInit( ); + void + FitSizer( ); + public: + friend class creaButtonContainer::controller::ButtonContainerController; + private: + GroupManagerList m_GroupManagerList; + ButtonGroupList m_ButtonGroupList; + BCController* m_ButtonCController; + Sizer* m_Sizer; + }; + }//ecapseman +}//ecapseman + +#endif // BUTTONCONTAINERPANEL_H diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonGroup.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonGroup.h new file mode 100644 index 0000000..920dfd2 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonGroup.h @@ -0,0 +1,53 @@ +/*************************************************************** + * Name: ButtonGroup.h + * Purpose: Defines a group of buttons in wxWidgets + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef BUTTONGROUP_H +#define BUTTONGROUP_H + +//Library Definition +#include +#include +#include + +#include "button.h" + +namespace creaButtonContainer +{ + namespace view + { + //Typedef definition + typedef creaButtonContainer::view::Button Button; + typedef std::map< long, Button* > ButtonContainer; + typedef std::list< long > IdButtonContainer; + + /** + Class Description: This class defines a ButtonGroup. + **/ + class ButtonGroup + { + public: + ButtonGroup( wxStaticText* groupName, ButtonContainer buttons ); + virtual + ~ButtonGroup( ); + Button* + GetButton( long id ); + ButtonContainer + GetButtonContainer( ); + IdButtonContainer + GetButtonIdContainer( ); + wxStaticText* + GetGroupName( ); + private: + wxStaticText* m_GroupName; + ButtonContainer m_Buttons; + }; + }//ecapseman +}//ecapseman + +#endif // BUTTONGROUP_H diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonManager.h new file mode 100644 index 0000000..848204c --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/buttonManager.h @@ -0,0 +1,55 @@ +/*************************************************************** + * Name: ButtonManager.h + * Purpose: Defines the button group container + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef CARTOBUTTONCONTAINER_H +#define CARTOBUTTONCONTAINER_H + +#include +#include +#include +#include +#include +#include "button.h" +#include "buttonGroup.h" + +namespace creaButtonContainer +{ + namespace view + { + /** + Class Description: + **/ + class ButtonManager : public wxFlexGridSizer + { + public: + typedef creaButtonContainer::view::Button Button; + typedef creaButtonContainer::view::ButtonGroup ButtonGroup; + typedef std::map< long, Button* > ButtonContainer; + public: + ButtonManager( ); + ButtonManager( ButtonGroup* buttonGroup ); + virtual + ~ButtonManager( ); + void + SetGroupName( wxStaticText* groupName ); + void + ShowButtonManager( ); + void + HideButtonManager( ); + private: + void + SetButtonManager( ButtonContainer buttonContainer ); + private: + wxStaticText* m_GroupName; + wxGridSizer* m_GridSizer; + }; + }//ecapseman +}//ecapseman + +#endif // CARTOBUTTONCONTAINER_H diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/groupManager.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/groupManager.h new file mode 100644 index 0000000..562da7a --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/include/groupManager.h @@ -0,0 +1,60 @@ +/*************************************************************** + * Name: GroupManager.h + * Purpose: Defines the Group Manager + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Created: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef GROUPMANAGER_H +#define GROUPMANAGER_H + +#include +#include +#include +#include +#include "buttonManager.h" +#include "buttonGroup.h" +#include + +namespace creaButtonContainer +{ + namespace view + { + typedef creaButtonContainer::view::ButtonGroup ButtonGroup; + typedef wxButton ExpansionButton; + /** + Class Description: + **/ + class GroupManager : public wxFlexGridSizer + { + public: + GroupManager( wxWindow* parent, ButtonGroup* buttonGroup ); + virtual + ~GroupManager( ); + //Getters and Setters + long + GetButtonID( ); + ExpansionButton* + GetButton( ); + ButtonManager* + GetButtonManager( ); + void + SetButtonID( long id ); + void + SetButton( ExpansionButton* button ); + void + SetButtonManager( ButtonManager* manager ); + void + HideSubPanel( bool hide ); + + private: + long m_IDExpButton; + ExpansionButton* m_ExpansionButton; + ButtonManager* m_ButtonManager; + }; + }//ecapseman +}//ecapseman + +#endif // GROUPMANAGER_H diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/button.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/button.cxx new file mode 100644 index 0000000..d936a53 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/button.cxx @@ -0,0 +1,66 @@ +/*************************************************************** + * Name: Button.CXX + * Purpose: Implements Button.h + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#include "button.h" +#include + +namespace creaButtonContainer +{ + namespace view + { + //-------------------------------------------------------------------- + Button::Button( wxWindow* parent, long id, ButtonPair* pair ) + { + this->m_ButtonPair = pair; + std::string wXbuttonName = this->m_ButtonPair->first->first; + std::string wXiconPath = this->m_ButtonPair->first->second; + std::string wXdescription = this->m_ButtonPair->second->first; + wxString buttonName( wXbuttonName.c_str( ), wxConvUTF8 ); + wxString imageIcon( wXiconPath.c_str( ), wxConvUTF8 ); + wxString description( wXdescription.c_str( ), wxConvUTF8 ); + this->Create( parent, id, + wxBitmap( wxImage( imageIcon, wxBITMAP_TYPE_ANY, -1 ) ), + wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW, wxDefaultValidator, + buttonName ); + this->SetToolTip( description ); + } + //-------------------------------------------------------------------- + Button::~Button( ) + { + } + //-------------------------------------------------------------------- + //-------------------------------------------------------------------- + string + Button::GetButtonName( ) + { + return( this->m_ButtonPair->first->first ); + } + //-------------------------------------------------------------------- + string + Button::GetIconPath( ) + { + return( this->m_ButtonPair->first->second ); + } + //-------------------------------------------------------------------- + string + Button::GetDescription( ) + { + return( this->m_ButtonPair->second->first ); + } + //-------------------------------------------------------------------- + void + Button::Execute( ) + { + std::cout << "ButtonAction: "<< this->m_ButtonPair->first->first <m_ButtonPair->second->second}; + vTable[0]->Call( this->m_ButtonPair->first->first ); + } + + }//ecapseman +}//ecapseman diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonContainerPanel.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonContainerPanel.cxx new file mode 100644 index 0000000..66fbbdd --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonContainerPanel.cxx @@ -0,0 +1,70 @@ +/*************************************************************** + * Name: ButtonContainerPanel.cxx + * Purpose: Implements ButtonContainerPanel.h + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ +#include "buttonContainerPanel.h" + +namespace creaButtonContainer +{ + namespace view + { + ButtonContainerPanel::ButtonContainerPanel( wxWindow* parent, + ButtonGroupSettings* settings ) : + wxScrolledWindow( + parent, + -1, + wxDefaultPosition, + wxSize( 400, 400 ), + wxTAB_TRAVERSAL | wxVSCROLL | wxHSCROLL + | wxFULL_REPAINT_ON_RESIZE, _T("creaButtonContainer") ) + { + ButtonGroupFactory factory; + this->SetGroupContainer( + factory.CreateButtonGroupContainer( this, settings ) ); + this->PanelInit( ); + this->m_ButtonCController = new BCController(this); + this->m_ButtonCController->AddEvents(); + this->SetEventHandler( this->m_ButtonCController ); + } + // ------------------------------------------------------------------- + ButtonContainerPanel::~ButtonContainerPanel( ) + { + } + // ------------------------------------------------------------------- + void + ButtonContainerPanel::SetGroupContainer( ButtonGroupList groupContainer ) + { + this->m_ButtonGroupList = groupContainer; + } + // ------------------------------------------------------------------- + void + ButtonContainerPanel::PanelInit( ) + { + this->m_Sizer = new Sizer( 0, 1, 0, 0 ); + for( ButtonGroupList::iterator it = this->m_ButtonGroupList.begin( ); it + != this->m_ButtonGroupList.end( ); ++it ) + { + GroupManager* manager = new GroupManager( this, *it ); + this->m_GroupManagerList[ manager->GetButtonID( ) ] = manager; + this->m_Sizer->Add( manager, 1, wxALL | wxALIGN_LEFT | wxALIGN_TOP, 5 ); + std::cout << "creaButtonContainer: New ButtonGroup Sizer Added" + << std::endl; + } + this->SetSizer( this->m_Sizer ); + this->FitSizer( ); + } + + // ------------------------------------------------------------------- + void + ButtonContainerPanel::FitSizer( ) + { + this->m_Sizer->Fit( this ); + this->m_Sizer->SetSizeHints( this ); + } + + }//ecapseman +}//ecapseman diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonGroup.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonGroup.cxx new file mode 100644 index 0000000..f6c7351 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonGroup.cxx @@ -0,0 +1,61 @@ +/*************************************************************** + * Name: ButtonGroup.cxx + * Purpose: Implements ButtonGroup.h + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#include "buttonGroup.h" + +namespace creaButtonContainer +{ + namespace view + { + /*typedef creaButtonContainer::view::Button Button; + typedef std::map< long, Button* > ButtonContainer; + typedef std::list< long > IdButtonContainer;*/ + //-------------------------------------------------- + ButtonGroup::ButtonGroup( wxStaticText* groupName, + ButtonContainer cartoButtons ) + { + this->m_GroupName = groupName; + this->m_Buttons = cartoButtons; + + } + //-------------------------------------------------- + ButtonGroup::~ButtonGroup( ) + { + } + //-------------------------------------------------- + ButtonContainer + ButtonGroup::GetButtonContainer( ) + { + return ( this->m_Buttons ); + } + //-------------------------------------------------- + wxStaticText* + ButtonGroup::GetGroupName( ) + { + return ( this->m_GroupName ); + } + //-------------------------------------------------- + IdButtonContainer + ButtonGroup::GetButtonIdContainer( ) + { + IdButtonContainer idContainer; + for( ButtonContainer::iterator it = this->m_Buttons.begin( ); it + != this->m_Buttons.end( ); ++it ) + idContainer.push_back( (*it).first ); + return ( idContainer ); + } + //-------------------------------------------------- + Button* + ButtonGroup::GetButton( long id ) + { + return( this->m_Buttons[id] ); + } + + }//ecapseman +}//ecapseman diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonManager.cxx new file mode 100644 index 0000000..83eda11 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/buttonManager.cxx @@ -0,0 +1,66 @@ +/*************************************************************** + * Name: ButtonManager.cxx + * Purpose: Implements ButtonManager.h + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#include "buttonManager.h" + +namespace creaButtonContainer +{ + namespace view + { + + ButtonManager::ButtonManager( ) : + wxFlexGridSizer( 0, 1, 0, 0 ) + { + } + // ------------------------------------------------------------------- + ButtonManager::ButtonManager( ButtonGroup* buttonGroup ) : + wxFlexGridSizer( 0, 1, 0, 0 ) + { + this->SetGroupName( buttonGroup->GetGroupName( ) ); + this->SetButtonManager( buttonGroup->GetButtonContainer( ) ); + } + // ------------------------------------------------------------------- + ButtonManager::~ButtonManager( ) + { + } + // ------------------------------------------------------------------- + void + ButtonManager::SetGroupName( wxStaticText* groupName ) + { + this->m_GroupName = groupName; + this->Add( this->m_GroupName, -1, wxALL | wxALIGN_LEFT | wxALIGN_TOP, 5 ); + } + // ------------------------------------------------------------------- + void + ButtonManager::SetButtonManager( ButtonContainer buttonContainer ) + { + if ( this->m_GroupName != NULL ) + { + this->m_GridSizer = new wxGridSizer( 0, 3, 0, 0 ); + for( ButtonContainer::iterator it = buttonContainer.begin( ); it + != buttonContainer.end( ); ++it ) + this->m_GridSizer->Add( (*it).second, -1, wxALL | wxALIGN_LEFT | wxALIGN_TOP, + 5 ); + this->Add( m_GridSizer, -1, wxALL | wxALIGN_LEFT | wxALIGN_TOP, 5 ); + } + } + // ------------------------------------------------------------------- + void + ButtonManager::ShowButtonManager( ) + { + this->Show( this->m_GridSizer, true, false ); + } + // ------------------------------------------------------------------- + void + ButtonManager::HideButtonManager( ) + { + this->Show( this->m_GridSizer, false, false ); + } + }//ecapseman +}//ecapseman diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/groupManager.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/groupManager.cxx new file mode 100644 index 0000000..3708bb0 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/src/groupManager.cxx @@ -0,0 +1,80 @@ +/*************************************************************** + * Name: GroupManager.cxx + * Purpose: Defines the Group Manager + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Created: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#include "groupManager.h" +#include + +namespace creaButtonContainer +{ + namespace view + { + // ------------------------------------------------------------------- + GroupManager::GroupManager( wxWindow* parent, ButtonGroup* buttonGroup ) : + wxFlexGridSizer( 1, 0, 0, 0 ) + { + this->m_IDExpButton = wxNewId( ); + this->m_ExpansionButton = new ExpansionButton( parent, + this->m_IDExpButton, _("-"), wxDefaultPosition, wxSize( 20, 20 ), 0, + wxDefaultValidator, _T("EXPBUTTON") ); + this->Add( m_ExpansionButton, 1, wxALL | wxALIGN_LEFT | wxALIGN_TOP, 5 ); + this->m_ButtonManager = new ButtonManager( buttonGroup ); + this->Add( this->m_ButtonManager, 1, wxALL | wxALIGN_LEFT | wxALIGN_TOP, 5 ); + } + // ------------------------------------------------------------------- + GroupManager::~GroupManager( ) + { + } + // ------------------------------------------------------------------- + long + GroupManager::GetButtonID( ) + { + return ( this->m_IDExpButton ); + } + // ------------------------------------------------------------------- + ExpansionButton* + GroupManager::GetButton( ) + { + return ( this->m_ExpansionButton ); + } + // ------------------------------------------------------------------- + ButtonManager* + GroupManager::GetButtonManager( ) + { + return ( this->m_ButtonManager ); + } + // ------------------------------------------------------------------- + void + GroupManager::SetButtonID( long id ) + { + this->m_IDExpButton = id; + } + // ------------------------------------------------------------------- + void + GroupManager::SetButton( ExpansionButton* button ) + { + this->m_ExpansionButton = button; + } + // ------------------------------------------------------------------- + void + GroupManager::SetButtonManager( ButtonManager* container ) + { + this->m_ButtonManager = container; + } + // ------------------------------------------------------------------- + void + GroupManager::HideSubPanel( bool hide ) + { + if ( hide == true ) + this->m_ButtonManager->HideButtonManager( ); + else + this->m_ButtonManager->ShowButtonManager( ); + } + // ------------------------------------------------------------------- + }//ecapseman +}//ecapseman diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/include/buttonContainerSettings.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/include/buttonContainerSettings.h new file mode 100644 index 0000000..dd24670 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/include/buttonContainerSettings.h @@ -0,0 +1,63 @@ +/*************************************************************** + * Name: buttonContainerSettings.h + * Purpose: It is the ButtonGroupSettings + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef BUTTONCONTAINERSETTINGS_H_ +#define BUTTONCONTAINERSETTINGS_H_ + +#include +#include +#include + +#include "containerSettings.h" +#include "functor.h" + +namespace creaPanelButtonContainer +{ + typedef creaButtonContainer::model::TFunctor TFunctor; + typedef creaButtonContainer::model::ContainerSettings ButtonGroupSettings; + typedef wxPanel* PanelButton; + //First is the button description, Second FunctionEventType + typedef std::pair< std::string, PanelButton > ActionButton; + //First is the ButtonName and Second is the ImageIconPath + typedef std::pair< std::string, std::string > ButtonInfo; + typedef std::pair< ButtonInfo*, ActionButton* > ButtonPair; + typedef std::list< std::string > KeyMapList; + typedef std::list< ButtonPair* > ButtonList; + typedef std::map< std::string, ButtonList > ButtonGroupMap; + class ButtonContainerSettings + { + public: + ButtonContainerSettings( ); + virtual + ~ButtonContainerSettings( ); + ButtonGroupMap + GetButtonGroupContainer( ); + KeyMapList + GetGroupNameList( ); + PanelButton + GetPanelButton( const std::string &buttonName ); + ButtonGroupSettings* + GetButtonGroupSettings( TFunctor* functor ); + void + SetButtonGroupContainer( ButtonGroupMap m_ButtonGroupContainer ); + void + SetGroupNameList( KeyMapList m_GroupNameList ); + void + CreateGroup( const std::string & groupName ); + void + AddButton( const std::string & groupName, const std::string buttonName, + const std::string iconpath, const std::string buttonDescription, + PanelButton event ); + + private: + ButtonGroupMap m_ButtonGroupContainer; + KeyMapList m_GroupNameList; + }; +}//ecapseman +#endif /* BUTTONCONTAINERSETTINGS_H_ */ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/include/creaPanelButtonContainer.h b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/include/creaPanelButtonContainer.h new file mode 100644 index 0000000..d49ac59 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/include/creaPanelButtonContainer.h @@ -0,0 +1,49 @@ +/*************************************************************** + * Name: pCartoGUIManager.h + * Purpose: Defines Application Frame + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#ifndef PANELBUTTONCONTAINER_H_ +#define PANELBUTTONCONTAINER_H_ + +#include +#include +#include + +#include "containerSettings.h" +#include "buttonContainerPanel.h" +#include "buttonContainerSettings.h" +#include "functor.h" + +namespace creaPanelButtonContainer +{ + + typedef creaPanelButtonContainer::ButtonContainerSettings + ButtonContainerSettings; + typedef creaButtonContainer::view::ButtonContainerPanel ButtonContainerPanel; + class PanelButtonContainer : public wxPanel + { + public: + PanelButtonContainer( wxWindow* parent, + ButtonContainerSettings* bcSettings ); + virtual + ~PanelButtonContainer( ); + void + UpdatePanel( const std::string &buttonName ); + void + GenericButtonEvent( const std::string &buttonName ); + private: + //Settings + ButtonContainerSettings* m_ButtonContainerSettings; + //Panel + ButtonContainerPanel* m_ButtonContainerPanel; + wxAuiManager* m_AuiManager; + wxPanel* m_ButtonPanel; + }; +}//ecapseman + +#endif // PANELBUTTONCONTAINER_H_ diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/src/buttonContainerSettings.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/src/buttonContainerSettings.cxx new file mode 100644 index 0000000..9f60e03 --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/src/buttonContainerSettings.cxx @@ -0,0 +1,106 @@ +/*************************************************************** + * Name: buttonContainerSettings.cxx + * Purpose: It is the ButtonGroupSettings + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ +#include "buttonContainerSettings.h" +#include + +namespace creaPanelButtonContainer +{ + + ButtonContainerSettings::ButtonContainerSettings( ) + { + } + ButtonContainerSettings::~ButtonContainerSettings( ) + { + } + ButtonGroupMap + ButtonContainerSettings::GetButtonGroupContainer( ) + { + return m_ButtonGroupContainer; + } + + KeyMapList + ButtonContainerSettings::GetGroupNameList( ) + { + return m_GroupNameList; + } + + //GetButtonPanel returns the panel asociated to de buttonAction + PanelButton + ButtonContainerSettings::GetPanelButton( const std::string &buttonName ) + { + for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it + != this->m_GroupNameList.end( ); ++it ) + { + ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ]; + for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 ) + { + if ( ( *it1 )->first->first.compare( buttonName ) == 0 ) + { + return ( ( *it1 )->second->second ); + }//fi + }//rof + }//rof + return ( NULL ); + } + ButtonGroupSettings* + ButtonContainerSettings::GetButtonGroupSettings( TFunctor* functor ) + { + ButtonGroupSettings* settings = new ButtonGroupSettings( ); + for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it + != this->m_GroupNameList.end( ); ++it ) + { + ButtonList list = this->m_ButtonGroupContainer[ ( *it ) ]; + for( ButtonList::iterator it1 = list.begin( ); it1 != list.end( ); ++it1 ) + { + settings->CreateGroup( *it ); + settings->AddButton( ( *it ), ( *it1 )->first->first, + ( *it1 )->first->second, ( *it1 )->second->first, functor ); + }//rof + }//rof + return ( settings ); + } + void + ButtonContainerSettings::SetButtonGroupContainer( + ButtonGroupMap m_ButtonGroupContainer ) + { + this->m_ButtonGroupContainer = m_ButtonGroupContainer; + } + + void + ButtonContainerSettings::SetGroupNameList( KeyMapList m_GroupNameList ) + { + this->m_GroupNameList = m_GroupNameList; + } + + void + ButtonContainerSettings::CreateGroup( const std::string & groupName ) + { + this->m_GroupNameList.push_back( groupName ); + } + void + ButtonContainerSettings::AddButton( const std::string & groupName, + const std::string buttonName, const std::string iconpath, + const std::string buttonDescription, PanelButton panel ) + { + for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it + != this->m_GroupNameList.end( ); ++it ) + { + if ( ( *it ).compare( groupName ) == 0 ) + { + panel->Show( false ); + ButtonPair* pair = new ButtonPair( + new ButtonInfo( buttonName, iconpath ), + new ActionButton( buttonDescription, panel ) ); + this->m_ButtonGroupContainer[ groupName ].push_back( pair ); + return; + }//fi + }//rof + } +}//ecapseman + diff --git a/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/src/creaPanelButtonContainer.cxx b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/src/creaPanelButtonContainer.cxx new file mode 100644 index 0000000..8bac02d --- /dev/null +++ b/lib/maracasVisuLib/src/interface/wxWindows/widgets/creaPanelButtonContainer/src/creaPanelButtonContainer.cxx @@ -0,0 +1,74 @@ +/*************************************************************** + * Name: CartoPanel.cxx + * Purpose: Code for Application Frame + * Author: Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr) + * Modified: 2011-05-09 + * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/) + * License: + **************************************************************/ + +#include "creaPanelButtonContainer.h" + +namespace creaPanelButtonContainer +{ + //-------------------------------------------------------------------------------- + typedef creaButtonContainer::model::TConcreteFunctor< PanelButtonContainer > + TConcreteFunctor; + + PanelButtonContainer::PanelButtonContainer( wxWindow* parent, + ButtonContainerSettings* bcSettings ) : + wxPanel( parent, -1, wxDefaultPosition, wxSize( 300, 700 ), + wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer") ) + { + this->m_ButtonContainerSettings = bcSettings; + this->m_ButtonPanel = new wxPanel( this ); + //Class that manages the cartobutton event!!! + TConcreteFunctor* functor = new TConcreteFunctor( this, + &PanelButtonContainer::GenericButtonEvent ); + //end of the event definition + this->m_ButtonContainerPanel = new ButtonContainerPanel( this, + this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ) ); + //Using AuiManager to Manage the Panels + this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT ); + // CartoSettingsPanel Management + this->m_AuiManager->AddPane( + this->m_ButtonPanel, + wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( + _("Panel") ). CaptionVisible( ).CloseButton( false ).Left( ).MinSize(wxSize(300,300)) ); + //CartoButtonPanel Management + this->m_AuiManager->AddPane( + this->m_ButtonContainerPanel, + wxAuiPaneInfo( ).Name( _T("creaButtonContainer") ).Caption( + _("creaButtonContainer") ). CaptionVisible( ).CloseButton( false ).Left( ) .MinSize(wxSize(300,300) ) ); + this->m_AuiManager->Update( ); + //this->createGimmick(); + } + + PanelButtonContainer::~PanelButtonContainer( ) + { + } + + void + PanelButtonContainer::UpdatePanel( const std::string &buttonName ) + { + //Hiding the last CartoSettingsPanel + this->m_ButtonPanel->Show( false ); + //Finding the CartoSettingsPanel of the ButtonClicket + this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton( + buttonName ); + //CartoSettingsPanel Management + this->m_AuiManager->GetPane( _T("ButtonPanel") ).window + = this->m_ButtonPanel; + //Updating the manager + this->m_AuiManager->Update( ); + } + + void + PanelButtonContainer::GenericButtonEvent( const std::string &buttonName ) + { + this->UpdatePanel( buttonName ); + } + +}//ecapseman + +