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