]> Creatis software - creaMaracasVisu.git/blob
9e77d001a742315363c8e8edff3ba9ba11e8ade1
[creaMaracasVisu.git] /
1 /*!
2  * @file creaPanelButtonContainer.h
3  * @brief implements PanelButtonContainer class
4  * @author Diego CACERES (diego.caceres[AT]creatis.insa-lyon.fr)
5  * @date  2011-06-02
6  */
7
8 #include "creaPanelButtonContainer.h"
9
10 namespace creaPanelButtonContainer
11 {
12         BEGIN_EVENT_TABLE(PanelButtonContainer,wxPanel)
13         //(*EventTable(ButtonContainerPanel)
14         //*)
15         END_EVENT_TABLE()
16         // ----------------------------------------------------------------------------------
17         typedef creaButtonContainer::model::TConcreteFunctor< PanelButtonContainer >   TConcreteFunctor;
18         // ----------------------------------------------------------------------------------
19         PanelButtonContainer::PanelButtonContainer( wxWindow* parent,  ButtonContainerSettings* bcSettings ) 
20                 : wxPanel( parent, -1, wxDefaultPosition, wxDefaultSize, wxDEFAULT_FRAME_STYLE, _T("creaPanelButtonContainer") )
21         {
22                 this->m_ButtonContainerSettings = bcSettings;
23                 this->m_ButtonPanel = new wxPanel( this );
24
25                 //Class that manages the event!!!
26         //EED 20/01/2012
27                 TConcreteFunctor* functor = new TConcreteFunctor( this, &PanelButtonContainer::GenericButtonEvent );
28 //              TConcreteFunctor* functor = new TConcreteFunctor( this->m_ButtonPanel, &PanelButtonContainer::GenericButtonEvent );
29                 //end of the event definition
30
31                 this->m_ButtonContainerPanel = new ButtonContainerPanel( this, this->m_ButtonContainerSettings->GetButtonGroupSettings( functor ) );
32
33                 //Using AuiManager to Manage the Panels
34                 this->m_AuiManager = new wxAuiManager( this, wxAUI_MGR_DEFAULT );
35
36                 this->m_AuiManager->AddPane(this->m_ButtonPanel, wxAuiPaneInfo( ).Name( _T("ButtonPanel") ).Caption( _("Panel") ). CaptionVisible(true ).CloseButton( false ).Bottom( ).Resizable( true ) );
37                 //CartoButtonPanel Management
38                 this->m_AuiManager->AddPane( this->m_ButtonContainerPanel,wxAuiPaneInfo( ).Name( _T("creaButtonContainer") ).Caption(_("creaButtonContainer") ). CaptionVisible( false ).CloseButton(false ).Center( ).Resizable( true ) );
39                 this->m_AuiManager->Update( );
40         }
41         // ----------------------------------------------------------------------------------
42         PanelButtonContainer::~PanelButtonContainer( )
43         {
44         }
45         // ----------------------------------------------------------------------------------
46         void
47         PanelButtonContainer::UpdatePanel( const std::string &buttonName )
48         {
49                 try
50                 {
51                         //Hiding the last CartoSettingsPanel
52                         this->m_ButtonPanel->Show( false );
53                         //Finding the CartoSettingsPanel of the ButtonClicket
54                         this->m_ButtonPanel = this->m_ButtonContainerSettings->GetPanelButton(buttonName );
55                         //changing the parent of the panel!
56                         if ( this->m_ButtonPanel->GetParent( ) != this )
57                         {
58                                 this->m_ButtonPanel->Reparent( this );
59                         }//fi
60                         //CartoSettingsPanel Management
61                         this->m_AuiManager->GetPane( _T("ButtonPanel") ).window = this->m_ButtonPanel;
62                         //Updating the manager
63                         this->m_AuiManager->Update( );
64                 }//yrt
65                 catch ( const std::exception& e )
66                 {
67                         std::cerr
68                             << "PanelButtonContainer::UpdatePanel( const std::string &buttonName )"
69                             << "exception: " << e.what( ) << std::endl;
70                         std::cout << "Maybe the panel of the button is NULL" << std::endl;
71                         exit( 1 );
72                 }//hctac
73         }
74         // ----------------------------------------------------------------------------------
75         void
76         PanelButtonContainer::GenericButtonEvent( const std::string &buttonName )
77         {
78                 this->UpdatePanel( buttonName );
79         }
80 // ----------------------------------------------------------------------------------
81 }//ecapseman
82
83