]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/model/buttonGroupFactory.cxx
f596414134ef4a2af268de228afa0b69cf51f11a
[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                 ButtonGroupFactory::ButtonGroupContainer
24                 ButtonGroupFactory::CreateButtonGroupContainer( wxWindow* parent,
25                     ButtonGroupModel* settings )
26                 {
27                         ButtonGroupContainer groupView;
28                         try
29                         {
30                                 ButtonGroupMap map = settings->GetButtonGroupContainer( );
31                                 for( ButtonGroupMap::iterator it = map.begin( ); it != map.end( ); ++it )
32                                 {
33                                         wxString groupNameAux( ( *it ).first.c_str( ), wxConvUTF8 );
34                                         wxStaticText* wxGroupName = new wxStaticText( parent, -1,
35                                             groupNameAux, wxDefaultPosition, wxDefaultSize, 0,
36                                             _T("GroupText") );
37                                         ButtonGroup* group = new ButtonGroup( wxGroupName,
38                                             this->GetButtons( parent, ( *it ).second ) );
39                                         groupView.push_back( group );
40                                 }//rof
41                         }//yrt
42                         catch ( const std::exception& e )
43                         {
44                                 std::cerr
45                                     << "ButtonGroupFactory::CreateButtonGroupContainer( wxWindow* parent,   ButtonGroupModel* settings )"
46                                     << " exception: " << e.what( ) << std::endl;
47                         }//chtac
48                         return ( groupView );
49                 }
50                 // ----------------------------------------------------------------------------------
51                 ButtonGroupFactory::ButtonContainer
52                 ButtonGroupFactory::GetButtons( wxWindow* parent, ButtonList buttonModel )
53                 {
54                         ButtonContainer buttonList;
55                         try
56                         {
57                                 ButtonContainer buttonList;
58                                 for( ButtonList::iterator it = buttonModel.begin( ); it
59                                     != buttonModel.end( ); ++it )
60                                 {
61                                         long id = wxNewId( );
62                                         buttonList[ id ] = new Button( parent, id, *it );
63                                 }//rof
64                                 return ( buttonList );
65                         }//yrt
66                         catch ( const std::exception& e )
67                         {
68                                 std::cerr
69                                     << "ButtonGroupFactory::GetButtons( wxWindow* parent, ButtonList buttonModel )"
70                                     << "exception: " << e.what( ) << std::endl;
71                         }//chtac
72                 }
73         // ----------------------------------------------------------------------------------
74         }//ecapseman
75 }//ecapseman
76