]> Creatis software - creaMaracasVisu.git/blob - lib/maracasVisuLib/src/interface/wxWindows/widgets/creaButtonContainer/controller/buttonContainerController.cxx
Diego Caceres: creaButtonContainer & creaPanelButtonContainer
[creaMaracasVisu.git] / lib / maracasVisuLib / src / interface / wxWindows / widgets / creaButtonContainer / controller / buttonContainerController.cxx
1 /***************************************************************
2  * Name:      @file buttonContainerController.h
3  * Purpose:   @brief This contains ContainerSettings class
4  * Author:    @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * Modified:  2011-05-09
6  * Copyright: Diego CACERES (http://www.creatis.insa-lyon.fr/~caceres/)
7  * License:
8  **************************************************************/
9
10 #include "buttonContainerController.h"
11 using namespace std;
12
13 namespace creaButtonContainer
14 {
15         namespace controller
16         {
17                 ButtonContainerController::ButtonContainerController( BCPanel* panel )
18                 {
19                         this->m_BCPanel = panel;
20                 }
21                 ButtonContainerController::~ButtonContainerController( )
22                 {
23                 }
24                 void
25                 ButtonContainerController::AddEvents( )
26                 {
27                         //Adding ButtonManagerEvents
28                         for( GroupManagerList::iterator it =
29                             this->m_BCPanel->m_GroupManagerList.begin( ); it
30                             != this->m_BCPanel->m_GroupManagerList.end( ); ++it )
31                         {
32                                 this->Connect( ( *it ).first, wxEVT_COMMAND_BUTTON_CLICKED,
33                                     (wxObjectEventFunction) &ButtonContainerController::ButtonExpEvent );
34                         }//rof
35
36                         //Adding ButtonEvents
37                         for( ButtonGroupList::iterator it =
38                             this->m_BCPanel->m_ButtonGroupList.begin( ); it
39                             != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
40                         {
41                                 KeyList keylist = ( *it )->GetButtonIdContainer( );
42                                 for( KeyList::iterator it2 = keylist.begin( ); it2 != keylist.end( ); ++it2 )
43                                 {
44                                         this->Connect( ( *it2 ), wxEVT_COMMAND_BUTTON_CLICKED,
45                                             (wxObjectEventFunction) &ButtonContainerController::ButtonEvent );
46                                 }//rof
47                         }//rof
48                 }
49                 // -------------------------------------------------------------------
50                 void
51                 ButtonContainerController::ButtonExpEvent( wxCommandEvent& event )
52                 {
53                         long id = event.GetId( );
54
55                         if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
56                             _("+") ) == 0 )
57                         {
58                                 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
59                                     _("-") );
60                                 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( false );
61                         }
62                         else if ( this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->GetLabel( ).Cmp(
63                             _("-") ) == 0 )
64                         {
65                                 this->m_BCPanel->m_GroupManagerList[ id ]->GetButton( )->SetLabel(
66                                     _("+") );
67                                 this->m_BCPanel->m_GroupManagerList[ id ]->HideSubPanel( true );
68                         }
69                         this->m_BCPanel->FitSizer( );
70                 }
71                 // -------------------------------------------------------------------
72                 void
73                 ButtonContainerController::ButtonEvent( wxCommandEvent& event )
74                 {
75                         for( ButtonGroupList::iterator it =
76                             this->m_BCPanel->m_ButtonGroupList.begin( ); it
77                             != this->m_BCPanel->m_ButtonGroupList.end( ); ++it )
78                         {
79                                 if ( ( *it )->GetButton( event.GetId( ) ) != NULL )
80                                         ( *it )->GetButton( event.GetId( ) )->Execute( );
81                         }
82                 }
83         }//ecapsename
84 }//ecapsename
85