]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/buttonGroupFactory.cxx
no message
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / model / buttonGroupFactory.cxx
1 /*!
2  * @file buttonGroupFactory.cxx
3  * @brief Implements the ButtonGroupFactory class.
4  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * @date  2011-06-02
6  */
7
8 #include "buttonGroupFactory.h"
9
10 namespace creaButtonContainer
11 {
12         namespace model
13         {
14                 // ----------------------------------------------------------------------------------
15                 ButtonGroupFactory::ButtonGroupFactory( )
16                 {
17                 }
18                 // ----------------------------------------------------------------------------------
19                 ButtonGroupFactory::~ButtonGroupFactory( )
20                 {
21                 }
22                 
23                 // ----------------------------------------------------------------------------------
24                 ButtonGroupFactory::ButtonGroupContainer ButtonGroupFactory::CreateButtonGroupContainer( wxWindow* parent,  ButtonGroupModel* settings )
25                 {
26                         ButtonGroupContainer groupView;
27                         try
28                         {
29                                 ButtonGroupMap map = settings->GetButtonGroupContainer( );
30                                 for( ButtonGroupMap::iterator it = map.begin( ); it != map.end( ); ++it )
31                                 {
32                                         wxString groupNameAux( ( *it ).first.c_str( ), wxConvUTF8 );
33                                         wxStaticText* wxGroupName = new wxStaticText( parent, -1, groupNameAux, wxDefaultPosition, wxDefaultSize, 0, _T("GroupText") );
34                                         ButtonGroup* group = new ButtonGroup( wxGroupName, this->GetButtons( parent, ( *it ).second ) );
35                                         groupView.push_back( group );
36                                 }//rof
37                         }//yrt
38                         catch ( const std::exception& e )
39                         {
40                                 std::cerr
41                                     << "ButtonGroupFactory::CreateButtonGroupContainer( wxWindow* parent,   ButtonGroupModel* settings )"
42                                     << " exception: " << e.what( ) << std::endl;
43                         }//chtac
44                         return ( groupView );
45                 }
46                 
47                 // ----------------------------------------------------------------------------------
48                 ButtonGroupFactory::ButtonContainer ButtonGroupFactory::GetButtons( wxWindow* parent, ButtonList buttonModel )
49                 {
50                         ButtonContainer buttonList;
51                         try
52                         {
53                                 for( ButtonList::iterator it = buttonModel.begin( ); it
54                                     != buttonModel.end( ); ++it )
55                                 {
56                                         long id = wxNewId( );
57                                         buttonList[ id ] = new Button( parent, id, *it );
58                                 }//rof
59                                 //return ( buttonList ); // JPR
60                         }//yrt
61                         catch ( const std::exception& e )
62                         {
63                                 std::cerr
64                                     << "ButtonGroupFactory::GetButtons( wxWindow* parent, ButtonList buttonModel )"
65                                     << "exception: " << e.what( ) << std::endl;
66                         }//chtac
67                         
68                         return ( buttonList );   // JPR
69                 }
70         // ----------------------------------------------------------------------------------
71         }//ecapseman
72 }//ecapseman
73