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