]> Creatis software - creaMaracasVisu.git/blobdiff - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/containerSettings.cxx
creaButtonContainer: new structure to make easy the button settings
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / model / containerSettings.cxx
index 188d0890677b6fd9cc39eaa2b35c4e70489b3d1e..10e387a71764ddccdbbf33386295331da857c81e 100644 (file)
@@ -2,7 +2,7 @@
  * @file containerSettings.cxx
  * @brief Implements the ContainerSettings class.
  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
- * @date  2011-05-19
+ * @date  2011-05-24
  */
 
 #include "containerSettings.h"
@@ -49,11 +49,11 @@ namespace creaButtonContainer
                    const std::string buttonName, const std::string iconpath,
                    const std::string buttonDescription, FunctionEventType event )
                {
-                       ButtonPair* pair = new ButtonPair(
-                           new ButtonInfo( buttonName, iconpath ),
-                           new ButtonAction( buttonDescription, event ) );
                        try
                        {
+                               ButtonPair* pair = new ButtonPair(
+                                   new ButtonInfo( buttonName, iconpath ),
+                                   new ButtonAction( buttonDescription, event ) );
                                for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
                                    != this->m_GroupNameList.end( ); ++it )
                                {
@@ -75,6 +75,53 @@ namespace creaButtonContainer
                                    << e.what( ) << std::endl;
                        }//hctac
                }
+               // ----------------------------------------------------------------------------------
+               void
+               ContainerSettings::AddButton( BCSettingsStruct* info )
+               {
+                       try
+                       {
+                               ButtonPair* pair = new ButtonPair(
+                                   new ButtonInfo( info->buttonName, info->iconpath ),
+                                   new ButtonAction( info->buttonDescription, info->eventFunction ) );
+                               for( KeyMapList::iterator it = this->m_GroupNameList.begin( ); it
+                                   != this->m_GroupNameList.end( ); ++it )
+                               {
+                                       if ( ( *it ).compare( info->groupName ) == 0 )
+                                       {
+                                               this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
+                                               return;
+                                       }//fi
+                               }//rof
+                               this->m_GroupNameList.push_back( info->groupName );
+                               this->m_ButtonGroupContainer[ info->groupName ].push_back( pair );
+                       }//yrt
+                       catch ( std::exception& e )
+                       {
+                               std::cerr
+                                   << "void ContainerSettings::AddButton( BCSettingsStruct* info ) "
+                                   << "exception: " << e.what( ) << std::endl;
+                       }//hctac
+               }
+               // ----------------------------------------------------------------------------------
+               void
+               ContainerSettings::AddButtons( BCStructVectorType infoList )
+               {
+                       try
+                       {
+                               for( BCStructVectorType::iterator it = infoList.begin( ); it
+                                   != infoList.end( ); ++it )
+                               {
+                                       this->AddButton( *it );
+                               }//rof
+                       }//yrt
+                       catch ( std::exception& e )
+                       {
+                               std::cerr
+                                   << "ContainerSettings::AddButtons( BCStructVectorType infoList ) "
+                                   << "exception: " << e.what( ) << std::endl;
+                       }//hctac
+               }
        // ----------------------------------------------------------------------------------
        }//ecapseman
 }//ecapseman