]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/view/buttonContainerPanel.cxx
3265447de31e53d75e8c3703609f2918acda461b
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / view / buttonContainerPanel.cxx
1 /*!
2  * @file buttonGroup.cxx
3  * @brief Implements the ButtonGroup class.
4  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * @date  2011-05-24
6  */
7
8 #include "buttonContainerPanel.h"
9
10 namespace creaButtonContainer
11 {
12         namespace view
13         {
14                 // ----------------------------------------------------------------------------------
15                 ButtonContainerPanel::ButtonContainerPanel( wxWindow* parent,
16                     ButtonGroupSettings* settings ) :
17                             wxScrolledWindow(
18                                 parent,
19                                 -1,
20                                 wxDefaultPosition,
21                                 wxSize( 400, 400 ),
22                                 wxTAB_TRAVERSAL | wxVSCROLL | wxHSCROLL
23                                     | wxFULL_REPAINT_ON_RESIZE, _T("creaButtonContainer") )
24                 {
25                         ButtonGroupFactory factory;
26                         this->SetGroupContainer(
27                             factory.CreateButtonGroupContainer( this, settings ) );
28                         this->PanelInit( );
29                         this->m_ButtonCController = new BCController( this );
30                         this->m_ButtonCController->AddEvents( );
31                         this->SetEventHandler( this->m_ButtonCController );
32                 }
33                 // ----------------------------------------------------------------------------------
34                 ButtonContainerPanel::~ButtonContainerPanel( )
35                 {
36                 }
37                 // ----------------------------------------------------------------------------------
38                 void
39                 ButtonContainerPanel::SetGroupContainer( ButtonGroupList groupContainer )
40                 {
41                         this->m_ButtonGroupList = groupContainer;
42                 }
43                 // ----------------------------------------------------------------------------------
44                 void
45                 ButtonContainerPanel::PanelInit( )
46                 {
47                         try
48                         {
49                                 this->m_Sizer = new Sizer( 0, 1, 0, 0 );
50                                 for( ButtonGroupList::iterator it = this->m_ButtonGroupList.begin( ); it
51                                     != this->m_ButtonGroupList.end( ); ++it )
52                                 {
53                                         GroupManager* manager = new GroupManager( this, *it );
54                                         this->m_GroupManagerList[ manager->GetButtonID( ) ] = manager;
55                                         this->m_Sizer->Add( manager, 1, wxALL | wxALIGN_LEFT | wxALIGN_TOP, 5 );
56                                         std::cout << "creaButtonContainer: New ButtonGroup Sizer Added"
57                                             << std::endl;
58                                 }
59                                 this->SetSizer( this->m_Sizer );
60                                 this->FitSizer( );
61                         }//yrt
62                         catch ( const std::exception& e )
63                         {
64                                 std::cerr << "ButtonContainerPanel::PanelInit( ) " << "exception: "
65                                     << e.what( ) << std::endl;
66                         }//hctac
67                 }
68                 // ----------------------------------------------------------------------------------
69                 void
70                 ButtonContainerPanel::FitSizer( )
71                 {
72                         this->m_Sizer->Fit( this );
73                         this->m_Sizer->FitInside( this );
74                         this->SetScrollRate( 20, 20 );
75                         this->m_Sizer->SetSizeHints( this );
76                 }
77         // ----------------------------------------------------------------------------------
78         }//ecapseman
79 }//ecapseman